17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
39 function paintSettings(&$owner, &$o, &$ei, $keywords=NULL)
41 $root = $ei->findScreen(
'static_screen_settings');
42 if (is_null($root))
return FALSE;
44 $prefix = $owner->getPrefix();
48 if (count($root->children()) == 0) {
49 $o->openSection(translate(
'no_asset_settings', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)));
53 foreach ($root->section as $section) {
56 if (is_null($keywords)) {
57 if (SQ_IN_LIMBO && ((
string) $section[
'name'] ===
'limbo_access' || (
int) $section[
'limbo_access'] === 0)) {
62 if (!is_null($keywords) && isset($keywords[
'sections'][strtolower($section->attributes()->name)])) {
66 $o->openSection((is_null($section[
'display_name'])) ? $section[
'name'] : $section[
'display_name']);
68 foreach ($section->children() as $field) {
72 switch (strtolower((
string) $field[
'code'])) {
73 case 'version_current_version' :
74 if ((
string) $field[
'children'][0][
'name'] !=
'display_name') {
75 $display_name = translate(
'current_version');
77 $display_name = (string) $field[
'children'][0][
'content'];
79 $o->openField($display_name);
80 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
84 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
85 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][strtolower((
string) $field[
'code'])]] = ob_get_contents();
90 case 'version_update_version' :
92 if ($owner->adminAccess(
'all')) {
95 if ((
string) $field[
'children'][0][
'name'] !=
'display_name') {
96 $display_name = translate(
'update_major_version');
98 $display_name = (string) $field[
'children'][0][
'content'];
100 $o->openField($display_name);
101 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
105 check_box($prefix.
'_version_update_version');
106 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
107 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][strtolower((
string) $field[
'code'])]] = ob_get_contents();
116 case 'date_created_date' :
117 case 'date_published_date' :
119 $date_type = (strtolower((
string) $field[
'code']) ===
'date_created_date') ?
'created' :
'published';
120 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
122 'min' =>
'0000-00-00 00:00:00',
123 'max' =>
'9999-12-31 12:59:59',
124 'allow_circa' =>
'0',
125 'show' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
126 'null' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
135 'print_format' =>
'l, F jS, Y H:i:s',
138 if ($date_type ==
'created') {
139 $value = (!empty($owner->created)) ? ts_iso8601($owner->created) :
'---------- --:--:--';
140 $userid = $owner->created_userid;
142 $value = (!empty($owner->published)) ? ts_iso8601($owner->published) :
'---------- --:--:--';
143 $userid = $owner->published_userid;
146 if ((
string) $field[
'children'][0][
'name'] !==
'display_name') {
147 $display_name = translate($date_type.
'_date');
149 $display_name = (string) $field[
'children'][0][
'content'];
151 $o->openField($display_name);
152 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
156 $date_field =
new Datetime_Field($prefix.
'_date_'.$date_type, $value, $parameters);
158 if ($owner->adminAccess(
'all')) {
159 $date_field->printField();
162 <script language=
"javascript">
163 var TIME_UNITS =
new Array();
174 foreach ($units as $php_unit => $js_unit) {
175 echo
'TIME_UNITS[\''.$js_unit.
'\'] = \
''.date($php_unit).
'\';
';
179 function setCurrentTime(prefix) {
180 for (u in TIME_UNITS) {
181 var id = prefix + 'value_
' + u;
182 var unit = document.getElementById(id);
184 if (unit.type == 'text
') {
185 unit.value = TIME_UNITS[u];
187 for (var i = 0; i < unit.options.length; i++) {
188 if (TIME_UNITS[u] == unit.options[i].value) {
189 unit.selectedIndex = i;
197 normal_button($prefix.'_set_time_
'.$date_type, strtolower(translate('now
')), 'setCurrentTime(\
''.$prefix.
'_date_'.$date_type.
'\');
');
198 echo ' <b>
'.strtolower(translate('by
')).'</b>
';
199 asset_finder($prefix.'_date_
'.$date_type.'_userid
', $userid, Array('user
' => 'D
'));
203 if ($date_field->isEmpty() && $date_type == 'published
') {
204 echo translate('never_published
');
206 $info = $GLOBALS['SQ_SYSTEM
']->am->getAssetInfo(Array($userid), 'user
', FALSE);
208 $info[$userid] = Array('name
' => '<unknown>
');
211 echo ucfirst($date_type).' '.strtolower(translate('by
')).' '.htmlspecialchars($info[$userid]['name
'], ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET).' '.strtolower(translate('on
')).' '.date('d M Y H:i:s
', strtotime($date_field->value));
215 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
216 $ei->_tmp['layout_keyword_replacements
'][$keywords['fields
'][strtolower((string) $field['code
'])]] = ob_get_contents();
223 case 'force_secure
' :
224 if ((string) $field['children
'][0]['name
'] != 'display_name
') {
225 $display_name = translate('force_secure
');
227 $display_name = $field['children
'][0]['content
'];
229 $o->openField($display_name);
230 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
233 $current_langs = $owner->getLanguages();
234 // have to have admin access to set the force secure
236 '0
' => 'Allow all protocols
',
237 '1
' => 'Force secure protocol (HTTPS)
',
238 '-
' => 'Force insecure protocol (HTTP)
',
240 if ($owner->adminAccess('settings
')) {
242 combo_box($prefix.'_force_secure
', $options, FALSE, $owner->force_secure);
243 //check_box($prefix.'_force_secure
', '1
', ($owner->force_secure == '1
'));
245 echo $options[$owner->force_secure];
247 <img src="<?php echo sq_web_path('lib
'); ?>/web/images/<?php echo ($owner->force_secure) ? 'tick
' : 'cross
'; ?>.gif" width="15" height="15" />
250 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
251 $ei->_tmp['layout_keyword_replacements
'][$keywords['fields
'][strtolower((string) $field['code
'])]] = ob_get_contents();
258 case 'intl_languages
' :
260 if ($field['children
'][0]['name
'] != 'display_name
') {
261 $display_name = translate('languages
');
263 $display_name = $field['children
'][0]['content
'];
266 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
269 $o->openSection($display_name);
271 require SQ_FUDGE_PATH.'/standards_lists/languages.inc
';
273 if ($owner->writeAccess('settings
')) {
275 $standards_lists_languages = array_reverse($standards_lists_languages);
276 $standards_lists_languages[''] = '';
277 $standards_lists_languages = array_reverse($standards_lists_languages);
278 $o->openField(translate('add_language
'));
279 combo_box($prefix.'_add_intl_language
', $standards_lists_languages, FALSE, '');
283 $o->openField(translate('current
'));
284 $current_langs = $owner->getLanguages();
285 if (!empty($current_langs)) {
286 sort($current_langs);
288 <table class="sq-backend-table" style="width: 0%;">
289 <?php if ($owner->writeAccess('settings
')) {
292 <td class="sq-backend-table-header"> </td>
293 <td class="sq-backend-table-header"><b><?php echo translate('delete_question
'); ?></b></td>
298 foreach ($current_langs as $lang_code) {
301 <td class="sq-backend-table-cell"><?php echo $standards_lists_languages[$lang_code]; ?></td>
302 <?php if ($owner->writeAccess('settings
')) {
305 <td class="sq-backend-table-cell" align="center"><?php check_box($prefix.'_rem_intl_language[
'.$lang_code.']
'); ?></td>
313 echo translate('no_language_set
', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET));
319 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
320 $ei->_tmp['layout_keyword_replacements
'][$keywords['fields
'][strtolower((string) $field['code
'])]] = ob_get_contents();
325 case 'intl_character_set
' :
326 if ($field['children
'][0]['name
'] != 'display_name
') {
327 $display_name = translate('character_set
');
329 $display_name = $field['children
'][0]['content
'];
332 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
336 $o->openSection($display_name);
337 $o->openField('Current
');
338 require SQ_FUDGE_PATH.'/standards_lists/character_sets.inc
';
340 if ($owner->writeAccess('settings
')) {
342 $standards_lists_character_sets = array_reverse($standards_lists_character_sets);
343 $standards_lists_character_sets[''] = '** Use System Default **
';
344 $standards_lists_character_sets = array_reverse($standards_lists_character_sets);
345 combo_box($prefix.'_intl_character_set
', $standards_lists_character_sets, FALSE, $owner->charset);
347 if (isset($standards_lists_character_sets[$owner->charset])) {
348 echo $standards_lists_character_sets[$owner->charset];
349 } else if ($owner->charset == '') {
350 echo translate('no_character_set
', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET));
352 echo '<i>
'.translate('no_charactet_set_set
', $owner->charset, htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).'</i>
';
357 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
358 $ei->_tmp['layout_keyword_replacements
'][$keywords['fields
'][strtolower((string) $field['code
'])]] = ob_get_contents();
363 case 'morph_new_type
' :
364 if ($field['children
'][0]['name
'] != 'display_name
') {
365 $display_name = translate('new_type
');
367 $display_name = $field['children
'][0]['content
'];
370 $o->openField($display_name);
371 if (!is_null($keywords) && isset($keywords['fields
'][strtolower((string) $field['code
'])])) {
375 if ($owner->adminAccess('all
')) {
377 if ($owner->status != SQ_STATUS_UNDER_CONSTRUCTION) {
378 // cant morph an asset if it is not under construction
379 echo translate('only_morph_under_construction
');
381 $db = MatrixDAL::getDb();
382 $am = $GLOBALS['SQ_SYSTEM
']->am;
383 $user = $am->getAsset($GLOBALS['SQ_SYSTEM
']->currentUserid());
385 $types = array_merge($am->getTypeAncestors($owner->type()), $am->getTypeDescendants($owner->type()));
386 for ($i = 0; $i < count($types); $i++) {
387 $types[$i] = '\
''.$types[$i].
'\'';
389 $type_code_cond =
'IN ('.implode(
', ', $types).
')';
391 $user_types = $am->getTypeAncestors($user->type());
392 $user_types[] = $user->type();
393 for ($i = 0; $i < count($user_types); $i++) {
394 $user_types[$i] =
'\''.$user_types[$i].
'\'';
396 $user_type_cond =
'IN ('.implode(
', ', $user_types).
')';
398 $sql =
'SELECT type_code
400 WHERE allowed_access '.$user_type_cond.
'
401 AND type_code '.$type_code_cond;
406 }
catch (Exception $e) {
407 throw new Exception(
'Unable to get type codes for these user types: '.$user_types.
' due to database error: '.$e->getMessage());
410 if (empty($result)) {
411 echo translate(
'no_types_to_morph');
413 $morph_types = Array(
'' =>
'');
414 foreach ($result as $type_code) {
415 $code_name = str_replace(
'_',
' ', $type_code);
416 $code_name = ucwords($code_name);
417 $morph_types[$type_code] = $code_name;
419 combo_box($prefix.
'_morph_new_type', $morph_types, FALSE,
'');
423 <td
class=
"sq-backend-data"><?php echo translate(
'morph_confirmation'); ?></td>
426 <td valign=
"top"><?php security_key(15, 20, 2); ?></td>
433 echo translate(
'morph_no_access');
436 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
437 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][strtolower((
string) $field[
'code'])]] = ob_get_contents();
446 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
449 $system_designs = Array(
450 'design::system::frontend' => translate(
'asset_frontend_design'),
451 'design::system::login' => translate(
'asset_design_user_no_permissions'),
452 'design::system::password_change' => translate(
'asset_design_change_password'),
454 $our_designs = Array(
455 'design::system::frontend' => 0,
456 'design::system::login' => 0,
457 'design::system::password_change' => 0,
459 $override_designs = Array(
460 'design::system::frontend' => 0,
461 'design::system::login' => 0,
462 'design::system::password_change' => 0,
465 $our_design_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($owner->id, SQ_LINK_NOTICE,
'design', FALSE);
467 foreach ($our_design_links as $link) {
468 if (preg_match(
'/^design::(system|user)::.*$/', $link[
'value'])) {
469 $our_designs[$link[
'value']] = $link[
'minorid'];
470 }
else if (preg_match(
'/^override::design::(system|user)::.*$/', $link[
'value'])) {
471 $design_name = preg_replace(
'/^override::(.*)$/',
'$1', $link[
'value']);
472 $override_designs[$design_name] = $link[
'minorid'];
477 $design_lookups = $owner->getDesignLookups();
481 foreach ($design_lookups as $url => $designs) {
482 foreach ($designs as $design_name => $designid) {
483 if (!isset($our_designs[$design_name])) {
484 $our_designs[$design_name] = 0;
490 $our_designs[
'design::user::'] = 0;
492 foreach ($our_designs as $design_name => $designid) {
494 $override_designid = array_get_index($override_designs, $design_name, 0);
496 preg_match(
'/^design::(system|user)::(.*)$/', $design_name, $matches);
498 $design_type = $matches[1];
499 $design_code = $matches[2];
500 $new_user_design = ($design_type ==
'user' && $design_code ==
'' && !$designid);
501 if ($new_user_design && !$owner->writeAccess(
'links')) {
505 if (!$new_user_design) {
506 $display_name = translate(
'config_display_name', ucwords($design_type), ucwords(str_replace(
'_',
' ', $design_code)));
508 $display_name = translate(
'create_new_user_defined_design');
511 $o->openSection($display_name);
513 if ($new_user_design) {
514 $o->openField(translate(
'design_code'));
515 text_box($prefix.
'_designs['.$design_name.
'][name]',
'', 20, 30);
519 hidden_field($prefix.
'_designs['.$design_name.
'][name]', $design_name);
522 if ($design_type ==
'user') {
523 $o->openField(translate(
'design_code'));
529 if (!$new_user_design) {
530 $effective_designs = Array();
531 foreach ($design_lookups as $url => $designs) {
532 if (empty($designs[$design_name]))
continue;
533 $effective_designs[$url] = $designs[$design_name];
536 $o->openField(translate(
'current'));
538 if (!empty($effective_designs)) {
540 <table
class=
"sq-backend-table">
542 <td
class=
"sq-backend-table-header"><?php echo translate(
'url'); ?></td>
543 <td
class=
"sq-backend-table-header"><?php echo translate(
'effective_design'); ?></td>
546 foreach ($effective_designs as $url => $effective_designid) {
547 $effective_design_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($effective_designid));
548 if (empty($effective_design_info))
continue;
551 <td
class=
"sq-backend-table-cell"><?php echo $url; ?></td>
552 <td
class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($effective_designid); ?></td>
560 echo translate(
'no_effective_designs');
566 $o->openField(($designid) ? translate(
'change_question') : translate(
'new_question'));
568 if (!$owner->writeAccess(
'links')) {
571 echo translate(
'none');
573 echo get_asset_tag_line($designid);
579 $buttons = Array(
'clear');
580 if (!$new_user_design) $buttons[] =
'reset';
581 asset_finder($prefix.
'_designs['.$design_name.
'][designid]', $designid, Array(
'design' =>
'D'),
'sq_sidenav', FALSE,
'null', $buttons);
585 if ($design_type ==
'system' && isset($system_designs[$design_name])) {
586 $o->note($system_designs[$design_name]);
591 $o->openField(translate(
'override_design_question'));
593 if (!$owner->writeAccess(
'links')) {
595 if (!$override_designid) {
596 echo translate(
'none');
598 echo get_asset_tag_line($override_designid);
604 $buttons = Array(
'clear');
605 if (!$new_user_design) $buttons[] =
'reset';
606 asset_finder($prefix.
'_designs['.$design_name.
'][override]', $override_designid, Array(
'design' =>
'D'),
'sq_sidenav', FALSE,
'null', $buttons);
610 $o->note(translate(
'override_design_explanation'));
618 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
619 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][strtolower((
string) $field[
'code'])]] = ob_get_contents();
627 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
631 if ($print_note && (!is_null($field->note)) && (strlen((
string)$field->note) > 0)) {
632 $o->openField(
' ');
633 $o->note((
string) $field->note);
636 if (!is_null($keywords) && isset($keywords[
'fields'][strtolower((
string) $field[
'code'])])) {
637 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][strtolower((
string) $field[
'code'])]] .= ob_get_contents();
645 if (!is_null($keywords) && isset($keywords[
'sections'][strtolower((
string) $section[
'name'])])) {
646 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'sections'][strtolower((
string) $section[
'name'])]] = ob_get_contents();
669 function processSettings(&$owner, &$o, &$ei)
671 $prefix = $owner->getPrefix();
674 $assets_affected_lookups = Array();
677 if ($owner->adminAccess(
'all')) {
678 if (isset($_POST[$prefix.
'_version_update_version'])) {
679 if (!$owner->incrementVersion(
'major')) {
680 trigger_localised_error(
'SYS0184', E_USER_WARNING, $owner->name);
686 if ($owner->adminAccess(
'all')) {
687 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
689 foreach (Array(
'created',
'published') as $date_type) {
693 if (isset($_POST[$prefix.
'_date_'.$date_type.
'_userid'][
'assetid']) && $_POST[$prefix.
'_date_'.$date_type.
'_userid'][
'assetid'] != 0) {
694 $userid = $_POST[$prefix.
'_date_'.$date_type.
'_userid'][
'assetid'];
696 $userid = $GLOBALS[
'SQ_SYSTEM']->currentUserid();
701 'min' =>
'0000-00-00 00:00:00',
702 'max' =>
'9999-12-31 12:59:59',
703 'allow_circa' =>
'0',
704 'show' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
705 'null' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
714 'print_format' =>
'l, F jS, Y H:i:s',
717 $date_field =
new Datetime_Field($prefix.
'_date_'.$date_type, $value, $parameters);
718 $date_field->processField();
721 if (!$date_field->isEmpty() && !preg_match(
"/^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}\:?){3}$/", $date_field->value)) {
725 if ($date_type ==
'created') {
727 if ($date_field->isEmpty()) {
728 trigger_localised_error(
'SYS0212', E_USER_WARNING);
731 $current_date = $owner->created;
732 $current_userid = $owner->created_userid;
734 $current_date = $owner->published;
735 $current_userid = $owner->published_userid;
738 if ($date_field->value != $current_date || $current_userid != $userid) {
739 $timestamp = (!$date_field->isEmpty()) ? strtotime($date_field->value) : NULL;
742 if ($timestamp === -1)
continue;
744 $owner->setDate($date_type, $timestamp, $userid);
751 if ($owner->adminAccess(
'settings')) {
752 if ($owner->setForceSecure(array_get_index($_POST, $prefix.
'_force_secure', 0))) {
753 $assets_affected_lookups[] = $owner->id;
759 $current_langs = $owner->getLanguages();
760 $set_languages = Array();
762 if (!isset($_POST[$prefix.
'_rem_intl_language'])) {
763 $_POST[$prefix.
'_rem_intl_language'] = Array();
767 if (isset($_POST[$prefix.
'_add_intl_language']) && !empty($_POST[$prefix.
'_add_intl_language'])) {
768 $new_language = $_POST[$prefix.
'_add_intl_language'];
769 if (!in_array($new_language, $current_langs)) {
770 $set_languages[] = $new_language;
775 foreach ($current_langs as $lang_code) {
776 if (!isset($_POST[$prefix.
'_rem_intl_language'][$lang_code])) {
777 $set_languages[] = $lang_code;
781 $owner->setLanguages($set_languages);
785 if (isset($_POST[$prefix.
'_intl_character_set'])) {
786 $new_charset = $_POST[$prefix.
'_intl_character_set'];
787 $owner->setCharset($new_charset);
792 if ($owner->adminAccess(
'all') && $owner->status == SQ_STATUS_UNDER_CONSTRUCTION) {
793 if (isset($_POST[$prefix.
'_morph_new_type']) && !empty($_POST[$prefix.
'_morph_new_type'])) {
795 if (validate_security_key()) {
797 $owner->morph($_POST[$prefix.
'_morph_new_type']);
799 trigger_localised_error(
'SYS0214', E_USER_WARNING);
804 $update_design_cascade = FALSE;
806 if (!empty($_POST[$prefix.
'_designs']) && $owner->writeAccess(
'links')) {
808 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
809 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
811 $designs_changed = FALSE;
813 foreach ($_POST[$prefix.
'_designs'] as $design_name => $design_data) {
815 $new_designid = $design_data[
'designid'][
'assetid'];
816 $new_override_designid = $design_data[
'override'][
'assetid'];
818 if ($design_name ==
'design::user::') {
819 if (empty($design_data[
'name']))
continue;
821 $design_name .= strtolower($design_data[
'name']);
823 if ($GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'design', FALSE, $design_name)) {
824 trigger_localised_error(
'SYS0134', E_USER_WARNING, $design_data[
'name']);
829 $old_design_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'design', FALSE, $design_name);
830 $old_designid = (empty($old_design_link)) ? 0 : $old_design_link[
'minorid'];
832 $old_override_design_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'design', FALSE,
'override::'.$design_name);
833 $old_override_designid = (empty($old_override_design_link)) ? 0 : $old_override_design_link[
'minorid'];
838 if ($new_designid != $old_designid) {
841 if (!$owner->deleteLink($old_design_link[
'linkid'])) {
842 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
849 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_designid);
850 if (is_null($design) || !$design instanceof
Design) {
851 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
855 if (!$owner->createLink($design, SQ_LINK_NOTICE, $design_name)) {
856 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
861 $update_design_cascade = TRUE;
865 if ($new_override_designid != $old_override_designid) {
867 if ($old_override_designid) {
868 if (!$owner->deleteLink($old_override_design_link[
'linkid'])) {
869 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
875 if ($new_override_designid) {
876 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_override_designid);
877 if (is_null($design)) {
878 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
882 if (!$owner->createLink($design, SQ_LINK_NOTICE,
'override::'.$design_name)) {
883 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
890 $designs_changed = TRUE;
895 if ($designs_changed) {
896 if ($update_design_cascade == TRUE) {
897 $assets_affected_lookups[] = $owner->id;
900 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
903 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
907 if (!$owner->updateLookups())
return FALSE;