17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
43 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
44 $schemas = $mm->getAssetSchemaInfo($owner->id, NULL, TRUE, FALSE);
47 foreach ($schemas as $schemaid => $granted) {
48 if (!isset($direct[$granted])) {
49 $direct[$granted] = Array();
51 $direct[$granted][] = $schemaid;
55 if (empty($direct))
return FALSE;
60 <table
class=
"sq-backend-table">
62 <td
class=
"sq-backend-table-header">
63 <?php echo translate(
'metadata_schema'); ?>
65 <td
class=
"sq-backend-table-header" align=
"right">
66 <?php echo translate(
'access'); ?>
71 foreach ($direct as $granted => $schemaids) {
72 foreach ($schemaids as $schemaid) {
74 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
82 <td
class=
"sq-backend-table-cell">
84 echo get_asset_tag_line($schemaid);
87 <td
class=
"sq-backend-table-cell" align=
"right">
88 <span style=
"color: <?php echo (($granted == '0') ? 'red' : 'green'); ?>; font-weight: bold; "><?php echo (($granted ==
'0') ? translate(
'denied') : translate(
'applied')) ?></span>
122 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
123 $schemas = $mm->getAssetSchemaInfo($owner->id);
126 foreach ($schemas as $schemaid => $schema_info) {
127 $granted = $schema_info[
'granted'];
128 if (!isset($direct[$granted])) {
129 $direct[$granted] = Array();
131 $direct[$granted][$schemaid] = $schema_info;
136 if (!empty($direct)) {
138 foreach ($direct as $granted => $schema_list) {
140 <table
class=
"sq-backend-table">
142 <td
class=
"sq-backend-table-header">
143 <span style=
"color: <?php echo (($granted == '0') ? 'red' : 'green'); ?>"><?php echo (($granted ==
'0') ? translate(
'denied') : translate(
'applied')) ?></span>
145 <td align=
"center" width=
"100" class=
"sq-backend-table-header">
146 <?php echo translate(
'cascade_question'); ?>
150 ?><td align=
"center" width=
"100" class=
"sq-backend-table-header"><?php echo translate(
'delete_question'); ?></td><?php
155 foreach ($schema_list as $schemaid => $schema_detail) {
157 $schema_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($schemaid),
'metadata_schema', FALSE);
158 if (empty($schema_info))
continue;
162 <td
class=
"sq-backend-table-cell">
164 echo get_asset_tag_line($schemaid);
167 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
170 check_box($prefix.
'_metadata[cascades]['.$schemaid.
']', 1, $schema_detail[
'cascades']);
173 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo ($schema_detail['cascades'] ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" />
180 ?><td align=
"center" width=
"100" class=
"sq-backend-table-cell"><?php
181 check_box($prefix.
'_metadata[delete]['.$schemaid.
']');
199 $o->
openField(translate(
'new_question'),
'new_line');
200 combo_box($prefix.
'_metadata[new][granted]', Array(
'' =>
'',
'1' => translate(
'apply'),
'0' => translate(
'deny')), FALSE,
'');
201 echo
' '.translate(
'metadata_schema').
' ';
202 asset_finder($prefix.
'_metadata[new][schemaid]', 0, Array(
'metadata_schema' =>
'D'),
'sq_sidenav', FALSE,
'null', Array(
'clear'));
204 $o->
openField(translate(
'cascade_question'),
'new_line');
205 check_box($prefix.
'_metadata[new][cascades]', 1, TRUE);
206 ?> Cascade
this new schema to newly-created children<?php
213 $kiddies = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($owner->id);
214 if (count($kiddies)) {
217 echo translate(
'action_affects_assets_below_this', count($kiddies), htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET));
220 check_box($prefix.
'_metadata[cascade_changes]',
'1', TRUE);
221 label(translate(
'cascade_schema_changes'), $prefix.
'_metadata[cascade_changes]');
223 check_box($prefix.
'_metadata[manual_cascade]');
224 label(translate(
'manually_cascade_schema'), $prefix.
'_metadata[manual_cascade]');
230 return $admin_access;
251 $GLOBALS[
'SQ_SYSTEM']->paintLogin(translate(
'login'), translate(
'cannot_access_asset', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)));
256 if (!$owner->
adminAccess(
'metadata'))
return FALSE;
259 if (!isset($_POST[$prefix.
'_metadata']))
return FALSE;
261 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
264 $cascade_changes = FALSE;
265 if (isset($_POST[$prefix.
'_metadata'][
'cascade_changes']) && $_POST[$prefix.
'_metadata'][
'cascade_changes']) {
266 $cascade_changes = TRUE;
269 $schema_vars = Array();
270 $post_data = $_POST[$prefix.
'_metadata'];
273 if (!empty($post_data[
'new'][
'schemaid'][
'assetid'])) {
274 if (!isset($post_data[
'new'][
'granted']) || $post_data[
'new'][
'granted'] ==
'') {
275 trigger_localised_error(
'SYS0268', E_USER_NOTICE, $post_data[
'new'][
'schemaid'][
'assetid']);
279 if ($cascade_changes && isset($post_data[
'new'][
'cascades'])) {
281 $schema_vars[] = Array(
282 'assetids' => Array($owner->id),
283 'granted' => (
int)$post_data[
'new'][
'granted'],
284 'schemaid' => (
int)$post_data[
'new'][
'schemaid'][
'assetid'],
285 'cascades' => (
int)(isset($post_data[
'new'][
'cascades']) ? 1 : 0),
286 'previous_access' => NULL,
290 if (!$mm->setSchema($owner->id, (
int)$post_data[
'new'][
'schemaid'][
'assetid'], (
int)$post_data[
'new'][
'granted'], (isset($post_data[
'new'][
'cascades']) ? 1 : 0))) {
298 if (!empty($post_data[
'delete'])) {
299 foreach ($post_data[
'delete'] as $schemaid => $on) {
300 $schemaid = (int)$schemaid;
301 $schema_info = $mm->getAssetSchemaInfo($owner->id, $schemaid);
302 if ($cascade_changes && $schema_info[
'cascades']) {
303 $current_access = $schema_info[
'granted'];
304 $schema_vars[] = Array(
305 'assetids' => Array($owner->id),
307 'schemaid' => $schemaid,
308 'cascades' => $cascade_changes,
309 'previous_access' => $current_access,
312 if (!$mm->deleteSchema($owner->id, $schemaid)) {
320 $schemas = $mm->getAssetSchemaInfo($owner->id);
321 foreach ($schemas as $schemaid => $schema_info) {
323 if (isset($post_data[
'new'][
'schemaid'][
'assetid']) && $post_data[
'new'][
'schemaid'][
'assetid'] == $schemaid) {
327 $cascades = isset($post_data[
'cascades'][$schemaid]);
328 if ((
boolean)$cascades != (
boolean)$schema_info[
'cascades']) {
329 if (!$mm->setSchema($owner->id, (
int)$schemaid, (
int)$schema_info[
'granted'], (
int)$cascades)) {
335 if (isset($_POST[$prefix.
'_metadata'][
'manual_cascade']) && $_POST[$prefix.
'_metadata'][
'manual_cascade']) {
336 $schemas = $mm->getAssetSchemaInfo($owner->id, NULL, TRUE);
337 foreach ($schemas as $schemaid => $schema_info) {
338 $schema_vars[] = Array(
339 'assetids' => Array($owner->id),
340 'granted' => $schema_info[
'granted'],
342 'schemaid' => $schemaid,
343 'previous_access' => NULL,
349 if (!empty($schema_vars)) {
350 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
351 $vars = Array(
'schema_changes' => $schema_vars);
352 $hh->queueHipo(
'hipo_job_edit_metadata_schemas', $vars);