17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
55 $this->backend = $backend;
68 $o = $this->backend->out;
70 if (!isset($_REQUEST[
'am_section'])) {
71 if (isset($_GET[
'sq_from_frontend'])) {
72 $_REQUEST[
'am_section'] =
'edit_asset';
73 }
else if (SQ_IN_LIMBO) {
74 $_REQUEST[
'am_section'] =
'limbo';
76 $_REQUEST[
'am_section'] =
'';
80 $o->addFormActionGetVar(
'am_section', $_REQUEST[
'am_section']);
81 $o->addHiddenField(
'am_form_submitted',
'1');
83 switch ($_REQUEST[
'am_section']) {
87 $parent = $this->am->getAsset($_REQUEST[
'parent_assetid']);
88 if (is_null($parent)) {
89 trigger_localised_error(
'SYS0200', E_USER_WARNING, $_REQUEST[
'parent_assetid']);
94 if (($err_msg = $GLOBALS[
'SQ_SYSTEM']->am->canLinkToType($parent, $_REQUEST[
'type_code'], $_REQUEST[
'link_type'])) !== TRUE) {
95 trigger_localised_error(
'SYS0303', E_USER_WARNING, $err_msg);
99 $o->addFormActionGetVar(
'parent_assetid', $_REQUEST[
'parent_assetid']);
100 $o->addFormActionGetVar(
'pos', $_REQUEST[
'pos']);
101 $o->addFormActionGetVar(
'type_code', $_REQUEST[
'type_code']);
102 $o->addFormActionGetVar(
'link_type', $_REQUEST[
'link_type']);
104 $this->am->includeAsset($_REQUEST[
'type_code']);
105 $asset =
new $_REQUEST[
'type_code']();
108 if (!empty($_REQUEST[
'process_form']) && !empty($_REQUEST[
'am_form_submitted'])) {
113 'link_type' => $_REQUEST[
'link_type'],
115 'sort_order' => $_REQUEST[
'pos'],
118 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
119 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
120 $success = $asset->processBackend($this->backend->out, $link);
123 $o->addFormActionGetVar(
'am_section',
'edit_asset');
124 $o->addFormActionGetVar(
'assetid', $asset->id);
125 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
128 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
131 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
134 $asset->paintBackend($this->backend->out);
141 $asset = $this->am->getAsset($_REQUEST[
'assetid']);
142 if (is_null($asset)) {
143 trigger_localised_error(
'SYS0195', E_USER_WARNING, $_REQUEST[
'assetid']);
147 $limbo_asset = $this->am->getAsset($_REQUEST[
'limbo_assetid']);
149 if (is_null($limbo_asset)) $limbo_asset = $asset;
150 $o->addFormActionGetVar(
'limbo_assetid', $limbo_asset->id, TRUE);
153 $o->addFormActionGetVar(
'assetid', $asset->id);
154 $o->addHiddenField(
'backend_assetid', $asset->id);
158 if (!empty($_POST[
'process_form']) && !empty($_POST[
'am_form_submitted'])) {
160 $do_process_backend = TRUE;
163 if (!empty($_POST[
'sq_lock_acquire']) && !empty($_POST[
'sq_lock_type'])) {
164 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
166 'assetids' => Array($asset->id,),
167 'lock_type' => $_POST[
'sq_lock_type'],
168 'forceably_acquire' => (
bool) $_POST[
'sq_lock_acquire_by_force'],
170 $hh->queueHipo(
'hipo_job_acquire_locks', $vars);
171 $do_process_backend = FALSE;
175 if (!empty($_POST[
'sq_lock_release_manual']) && !empty($_POST[
'sq_lock_type'])) {
176 $this->am->releaseLock($asset->id, $_POST[
'sq_lock_type']);
179 if (SQ_IN_LIMBO && !empty($_POST[
'sq_limbo_lock_type'])) {
180 foreach (unserialize(urldecode($_POST[
'sq_limbo_lock_type'])) as $limbo_lock_type) {
181 if ($limbo_lock_type != $_POST[
'sq_lock_type']) {
182 $this->am->releaseLock($asset->id, $limbo_lock_type);
186 $do_process_backend = FALSE;
191 if ($do_process_backend && !$asset->accessEffective()){
192 if (!$this->am->releaseLock($asset->id,
'attributes')) {
193 trigger_localised_error(
'SYS0182', E_USER_WARNING,
'attributes', $asset->name);
194 $do_process_backend = FALSE;
198 if ($do_process_backend && $asset->processBackend($this->backend->out, $link)) {
200 if (!empty($_POST[
'sq_lock_release']) && !empty($_POST[
'sq_lock_type'])) {
202 if (!$this->am->releaseLock($asset->id, $_POST[
'sq_lock_type'])) {
203 trigger_localised_error(
'SYS0182', E_USER_WARNING, $_POST[
'sq_lock_type'], $asset->name);
207 if (!$this->am->updateLock($asset->id, $_POST[
'sq_lock_type'])) {
208 trigger_localised_error(
'SYS0181', E_USER_WARNING, $_POST[
'sq_lock_type'], $asset->name);
215 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
216 $url = $hh->runQueuedJobs();
217 if (!empty($url)) $o->setRedirect($url);
221 $limbo_asset->initLimbo();
222 $limbo_asset->printFrontend();
224 $asset->paintBackend($this->backend->out);
229 case 'forceably_acquire_lock' :
249 $o = $this->backend->out;
251 if (isset($_GET[
'forceably_acquire_confirm'])) {
253 $asset = $this->am->getAsset($_GET[
'assetid']);
254 if (is_null($asset)) {
255 trigger_localised_error(
'SYS0086', E_USER_WARNING, $_GET[
'assetid']);
260 if (!validate_security_key()) {
262 $o->openSection(translate(
'security_key_incorrect'));
263 $o->openField(
' ');
264 echo
'<b><i>'.translate(
'security_key_incorrect_message', $asset->name).
'</i></b>';
267 $o->addOnLoad(
'window.opener.parent.frames["sq_main"].set_hidden_field(\'sq_lock_acquire_by_force\', \'1\'); window.opener.parent.frames["sq_main"].set_hidden_field(\'sq_lock_acquire\', \'1\'); window.opener.parent.frames["sq_main"].set_hidden_field(\'sq_lock_type\', \''.addslashes($_GET[
'sq_lock_type']).
'\'); window.opener.parent.frames[
"sq_main"].submit_form(); window.close();
');
272 $o->addFormActionGetVar('assetid
', $_GET['assetid
']);
273 $o->addFormActionGetVar('sq_lock_type
', $_GET['sq_lock_type
']);
274 $o->addFormActionGetVar('forceably_acquire_confirm
', '1
');
275 $o->addFormActionGetVar('ignore_frames
', '1
');
276 $asset = $this->am->getAsset($_GET['assetid
']);
277 if (is_null($asset)) {
278 trigger_localised_error('SYS0086
', E_USER_WARNING, $_GET['assetid
']);
282 $locks = $this->am->getLockInfo($asset->id, $_GET['sq_lock_type
'], TRUE, TRUE);
284 foreach ($locks as $lock_type => $lock) {
291 $o->addOnLoad('alert(js_translate(
"no_lock_held",
"'.addslashes($asset->name).'")); window.close();
');
295 $o->openSection(translate('forcibly_acquire
'));
297 $o->note(translate('forcibly_acquire_lock_can_cause_losses
', htmlspecialchars($asset->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET), htmlspecialchars($asset->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)));
303 <?php echo translate('enter_eight_character_security_string
'); ?>
307 <td valign="top"><?php security_key(8, 20, 2.5); ?></td>
310 <table class="sq-backend-table" style="width: auto;">
312 <td class="sq-backend-table-header">
313 <?php echo translate('lock_type
'); ?>
315 <td class="sq-backend-table-header">
318 <td class="sq-backend-table-header">
319 <?php echo translate('other_assets_in_chain
'); ?>
324 foreach ($locks as $lock_type => $lock) {
325 if (empty($lock)) continue;
326 // if this lock is held the current user, we aren't really forcing
this one
327 if ($lock[
'userid'] == $GLOBALS[
'SQ_SYSTEM']->currentUserId()) {
332 <td
class=
"sq-backend-table-cell">
333 <?php echo ucwords(str_replace(
'_',
' ', $lock_type)); ?>
335 <td
class=
"sq-backend-table-cell">
340 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
341 $editing = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'source_assetid']);
343 if (SQ_ROLLBACK_VIEW) {
344 $now = strtotime($_SESSION[
'sq_rollback_view'][
'rollback_time']);
349 if (is_null($lock[
'expires'])) {
350 $expires_in = translate(
'lock_held_indefinitely');
352 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
353 $expires_in = easy_time_total(($lock[
'expires'] - $now), TRUE);
355 $expires_in =
'1 '.translate(
'second');
357 $expires_in = translate(
'due_to_expire', $expires_in);
361 <p
class=
"sq-backend-locked-by-someone-else">
362 Held by user
"<?php echo htmlspecialchars($user->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET); ?>" at
"<?php echo htmlspecialchars($editing->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET); ?>".<br>
363 <?php echo $expires_in; ?>
366 <td
class=
"sq-backend-table-cell">
368 if (empty($lock[
'chained_assets'])) {
369 echo
'<i>No other assets are in this lock chain.</i>';
372 foreach ($lock[
'chained_assets'] as $chained_info) {
373 $chained_asset = $this->am->getAsset($chained_info[
'assetid']);
374 if (is_null($chained_asset)) {
375 trigger_localised_error(
'SYS0086', E_USER_WARNING, $chained_info[
'assetid']);
378 echo
'<li class="sq-backend-data">'.htmlspecialchars($chained_asset->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET).
'</li>';
393 $o->openField(
'',
'commit');
394 normal_button(
'cancel', translate(
'cancel'),
'window.close()');
396 submit_button(
'commit', SQ_CONF_COMMIT_BUTTON_TEXT);
409 $o = $this->backend->out;
411 $o->setHeading(
'Asset Types', sq_get_icon($o->filesPath(
'/images/icons/header/asset_tree.png'), 20, 20,
'Asset Tree'));
412 $o->setPageTitle(
'Asset Types');
414 $o->addHiddenField(
'am_action');
415 $o->addHiddenField(
'am_new_type_code');
417 $o->openSection(translate(
'asset_types'));
418 $o->openField(
'',
'new_line');
421 $offspring = Array();
422 for (reset($this->am->_asset_types); NULL !== ($type_code = key($this->am->_asset_types)); next($this->am->_asset_types)) {
423 $parent = $this->am->_asset_types[$type_code][
'parent_type'];
424 if (!isset($offspring[$parent])) {
425 $offspring[$parent] = Array();
427 $offspring[$parent][] = $type_code;
430 for (reset($offspring); NULL !== ($type_code = key($offspring)); next($offspring)) {
431 sort($offspring[$type_code]);
435 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
437 <td><img src=
"<?php echo $o->filesPath('/images/blank.gif'); ?>" width=
"1" height=
"20" border=
"0" alt=
"branch" /></td>
443 <td><img src=
"<?php echo $o->filesPath('/images/blank.gif'); ?>" width=
"1" height=
"1" alt=
"blank" /></td>
451 <td><img src=
"<?php echo $o->filesPath('/images/blank.gif'); ?>" width=
"1" height=
"1" alt=
"blank" /></td>
471 $o = $this->backend->out;
474 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
476 $num_kids = count($offspring[$parent]);
477 for ($i = 0; $i < $num_kids; $i++) {
479 $type_code = $offspring[$parent][$i];
480 $end = ($i == $num_kids - 1);
481 $bg = ($end) ?
'' :
'background="'.$o->filesPath(
'/images/tree/stalk.gif').
'"';
484 <td <?php echo $bg; ?>><img src=
"<?php echo $o->filesPath('/images/tree/branch.gif');?>" width=
"20" height=
"20" border=
"0" alt=
"branch" /></td>
486 <?php sq_print_icon($this->am->getAssetIconURL($type_code),
"16",
"16",
""); ?> <?php echo $this->am->_asset_types[$type_code][
'name'].
' ('.$type_code.
')';?>
490 if (!empty($offspring[$type_code])) {
493 <td <?php echo $bg; ?>><img src=
"<?php echo $o->filesPath('/images/blank.gif'); ?>" width=
"1" height=
"1" alt=
"blank" /></td>