18 require_once SQ_CORE_PACKAGE_PATH.
'/system/cron/cron_job/cron_job_edit_fns.inc';
42 parent::__construct();
62 $o->
openSection(($asset->id) ? $asset->name : translate(
'cron_new_future_linking'));
65 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT,
'', TRUE,
'minor');
66 $link_options = Array(0 =>
'',
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS' => translate(
'cron_fl_delete_all_existing_links'));
67 foreach ($links as $link) {
68 $parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'majorid'], $link[
'major_type_code']);
73 if (empty($link[
'linkid']))
continue;
75 if (is_null($parent))
continue;
76 $link_options[$link[
'linkid']] = translate(
'link').
' #'.$link[
'linkid'].
' - '.translate(
'parent').
' : '.$parent->name.
' (#'.$parent->id.
')';
79 $default_delete_linkid = $asset->
attr(
'delete_linkid');
80 if ($asset->
attr(
'delete_link_all')) {
81 $default_delete_linkid =
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS';
83 combo_box($prefix.
'_delete_linkid', $link_options, FALSE, $default_delete_linkid);
86 $o->
openField(translate(
'new_link_type'));
87 $link_info = $asset->
attr(
'link_info');
88 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
89 $editable_link_types = Array(
90 SQ_LINK_TYPE_1 => link_type_name(SQ_LINK_TYPE_1),
91 SQ_LINK_TYPE_2 => link_type_name(SQ_LINK_TYPE_2),
92 SQ_LINK_NOTICE => link_type_name(SQ_LINK_NOTICE),
94 $link_type = (isset($link_info[
'link_type'])) ? $link_info[
'link_type'] :
'';
95 combo_box($prefix.
'_link_type', $editable_link_types, FALSE, $link_type);
98 $o->
openField(translate(
'new_link_parent'));
100 asset_finder($prefix.
'_major_assetid', ((is_null($major)) ? 0 : $major->id), Array(),
'sq_sidenav', FALSE,
'null', Array(
'clear'));
102 if (is_null($major)) {
103 echo
'<a href="'.$major->getBackendHref().
'">'.translate(
'asset_format', $major->name, $major->id).
'</a>';
105 echo translate(
'not_set');
112 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
113 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), $GLOBALS[
'SQ_SYSTEM']->datetime($cron_mgr->timeOfNextRun())));
135 if (empty($_POST[$prefix.
'_delete_linkid']) && (empty($_POST[$prefix.
'_link_type']) || empty($_POST[$prefix.
'_major_assetid'][
'assetid']))) {
139 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
140 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
144 $delete_linkid = $_POST[$prefix.
'_delete_linkid'];
145 if ($delete_linkid ==
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS') {
146 $attribute = Array(
'name' =>
'delete_link_all',
'value' => TRUE);
148 $attribute = Array(
'name' =>
'delete_linkid',
'value' => $delete_linkid);
150 if (!$asset->
setAttrValue($attribute[
'name'], $attribute[
'value'])) {
151 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
152 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
156 if (!empty($_POST[$prefix.
'_major_assetid'][
'assetid'])) {
157 $major = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($_POST[$prefix.
'_major_assetid'][
'assetid']);
158 if (is_null($major)) {
159 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
160 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
163 $link_info = $asset->
attr(
'link_info');
164 $link_info[
'link_type'] = $_POST[$prefix.
'_link_type'];
166 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
167 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
173 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
174 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
178 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
179 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
201 $o->
openField(translate(
'new_link_parent'));
202 asset_finder($prefix.
'_major_assetid');
206 $o->
openField(translate(
'new_link_type'));
207 $editable_link_types = Array(
208 SQ_LINK_TYPE_1 => link_type_name(SQ_LINK_TYPE_1),
209 SQ_LINK_TYPE_2 => link_type_name(SQ_LINK_TYPE_2),
210 SQ_LINK_NOTICE => link_type_name(SQ_LINK_NOTICE),
212 combo_box($prefix.
'_link_type', $editable_link_types, FALSE, SQ_LINK_TYPE_1);
216 $o->
openField(translate(
'use_link_value'));
217 text_box($prefix.
'_link_value',
'', 20, 20);
224 $id_parts = explode(
':', $minor_asset->id);
227 if (isset($id_parts[1])) {
229 $o->
note(translate(
'cron_manager_future_not_available_create'));
236 $o->
note(translate(
'cron_manager_create_now_or_later'));
238 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
239 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), $GLOBALS[
'SQ_SYSTEM']->datetime($cron_mgr->timeOfNextRun())));
262 if ($major_id_array = array_get_index($_POST, $prefix.
'_major_assetid', FALSE)) {
264 $major_id = $major_id_array[
'assetid'];
267 if (empty($major_id))
return;
270 $link_type = array_get_index($_POST, $prefix.
'_link_type', SQ_LINK_TYPE_1);
273 $link_value = array_get_index($_POST, $prefix.
'_link_value',
'');
276 $future_time = Array();
277 $future_time[
'day'] = array_get_index($_REQUEST, $prefix.
'_when_day',
'');
278 $future_time[
'month'] = array_get_index($_REQUEST, $prefix.
'_when_month',
'');
279 $future_time[
'year'] = array_get_index($_REQUEST, $prefix.
'_when_year',
'');
280 $future_time[
'duration'] = array_get_index($_REQUEST, $prefix.
'_when_duration',
'');
281 $future_time[
'period'] = array_get_index($_REQUEST, $prefix.
'_when_period',
'');
284 $link_now = ($future_time[
'day'] ==
'') || ($future_time[
'month'] ==
'') || ($future_time[
'year'] ==
'') || ($future_time[
'duration'] ==
'') |
285 (($future_time[
'day'] ==
'--') && ($future_time[
'month'] ==
'--') && ($future_time[
'year'] ==
'--') && ($future_time[
'duration'] ==
'-'));
291 $new_parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($major_id);
292 $value = $link_value;
296 $am = $GLOBALS[
'SQ_SYSTEM']->am;
309 $id_parts = explode(
':', $minor_asset->id);
312 if (isset($id_parts[1])) {
313 $bridge = $am->getAsset($id_parts[0]);
314 $_links = $bridge->getLinks($minor_asset->id, SQ_SC_LINK_BACKEND_NAV,
'', TRUE,
'minor');
317 if (count($_links) <= 0)
return FALSE;
322 $_assets[$minor_asset->id] = Array(
323 'linkid' => $bridge->id.
':'.$minor_asset->id,
324 'link_type' => $link_type,
325 'parentid' => $_links[0][
'majorid'],
330 $_links = $am->getLink($minor_asset->id, NULL,
'', TRUE, NULL,
'minor');
333 $_assets[$minor_asset->id] = Array(
334 'linkid' => $_links[
'linkid'],
335 'link_type' => $link_type,
336 'parentid' => $_links[
'majorid'],
341 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($minor_asset->id);
342 $value = $link_value;
346 $asset->
prepareLink($new_parent,
'minor', $link_type, $value, $sort_order, $dependant, $exclusive);
347 $new_parent->prepareLink($asset,
'major', $link_type, $value, $sort_order, $dependant, $exclusive);
348 $can_create = $new_parent->canCreateLink($asset, $link_type, $exclusive);
351 if ($can_create !== TRUE) {
352 trigger_error($can_create);
357 'link_action' =>
'create',
358 'to_parent_assetid' => $major_id,
359 'to_parent_pos' => 1,
360 'assets' => $_assets,
361 'link_value' => $value,
363 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
364 $hh->queueHipo(
'hipo_job_create_links', $hipo_var);
367 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
369 $url = $hh->runQueuedJobs();
376 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
377 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
378 $major = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($major_id);
380 if (is_null($major)) {
381 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
382 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
385 $link_info = $asset->
attr(
'link_info');
386 $link_info[
'link_type'] = $link_type;
387 $link_info[
'value'] = $link_value;
389 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
390 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
395 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
396 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
400 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
401 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
428 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($minor->id, SQ_SC_LINK_SIGNIFICANT|SQ_LINK_NOTICE,
'', TRUE,
'minor');
429 $link_options = Array(0 =>
'',
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS' => translate(
'cron_fl_delete_all_existing_links'));
430 foreach ($links as $link) {
431 $print_link_type = $this->_printLinkType($link);
432 $parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'majorid'], $link[
'major_type_code']);
433 if (is_null($parent))
continue;
438 if (empty($link[
'linkid']))
continue;
439 if (empty($link[
'linkid'])) {
442 if (!empty($minor->id)) {
443 $id_parts = explode(
':', $minor->id);
444 if (isset($id_parts[1])) {
446 $link_options[$id_parts[0].
':'.$minor->id] = translate(
'link').
' #'.$id_parts[0].
':'.$minor->id.
' ('.$print_link_type.
') - '.translate(
'parent').
' : '.$parent->name.
' (#'.$id_parts[0].
')';
460 $link_options[$link[
'linkid']] = translate(
'link').
' #'.$link[
'linkid'].
' ('.$print_link_type.
') - '.translate(
'parent').
' : '.$parent->name.
' (#'.$parent->id.
')';
463 $default_delete_linkid = $asset->
attr(
'delete_linkid');
464 if ($asset->
attr(
'delete_link_all')) {
465 $default_delete_linkid =
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS';
467 combo_box($prefix.
'_delete_linkid', $link_options, FALSE, $default_delete_linkid);
474 $id_parts = explode(
':', $minor_asset->id);
477 if (isset($id_parts[1])) {
479 $o->
note(translate(
'cron_manager_future_not_available_delete'));
486 $o->
note(translate(
'cron_manager_delete_now_or_later'));
488 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
489 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), $GLOBALS[
'SQ_SYSTEM']->datetime($cron_mgr->timeOfNextRun())));
512 if (empty($_POST[$prefix.
'_delete_linkid'])) {
518 $delete_linkid = $_POST[$prefix.
'_delete_linkid'];
522 $future_time[] = Array();
523 $future_time[
'day'] = array_get_index($_REQUEST, $prefix.
'_when_day',
'');
524 $future_time[
'month'] = array_get_index($_REQUEST, $prefix.
'_when_month',
'');
525 $future_time[
'year'] = array_get_index($_REQUEST, $prefix.
'_when_year',
'');
526 $future_time[
'duration'] = array_get_index($_REQUEST, $prefix.
'_when_duration',
'');
527 $future_time[
'period'] = array_get_index($_REQUEST, $prefix.
'_when_period',
'');
530 $link_now = ($future_time[
'day'] ==
'') || ($future_time[
'month'] ==
'') || ($future_time[
'year'] ==
'') || ($future_time[
'duration'] ==
'') |
531 (($future_time[
'day'] ==
'--') && ($future_time[
'month'] ==
'--') && ($future_time[
'year'] ==
'--') && ($future_time[
'duration'] ==
'-'));
539 $trash_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trash_folder');
542 $am = $GLOBALS[
'SQ_SYSTEM']->am;
545 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
548 if ($delete_linkid ==
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS') {
549 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($minor_asset->id, SQ_SC_LINK_SIGNIFICANT,
'', TRUE,
'minor');
550 $link_options = Array();
552 $_assets[$minor_asset->id] = Array();
555 foreach ($links as $link) {
557 if (empty($link[
'linkid']))
continue;
560 $link_info = $am->getLinkById($link[
'linkid'], $minor_asset->id,
'minor');
563 if ($link_info[
'majorid'] == $trash_folder->id) {
569 $_assets[$minor_asset->id][] = Array(
570 'linkid' => $link_info[
'linkid'],
571 'link_type' => $link_info[
'link_type'],
572 'parentid' => $link_info[
'majorid'],
577 if (!empty($_assets[$minor_asset->id])) {
580 'link_action' =>
'move',
581 'to_parent_assetid' => $trash_folder->id,
582 'to_parent_pos' => 1,
583 'assets' => $_assets,
588 $hh->queueHipo(
'hipo_job_create_links', $hipo_vars);
591 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
593 $url = $hh->runQueuedJobs();
608 $link_info = $am->getLinkById($delete_linkid, $minor_asset->id,
'minor');
611 if ($link_info[
'link_type'] == SQ_LINK_NOTICE) {
613 if (is_null($link_info[
'major_type_code'])) {
614 $GLOBALS[
'SQ_SYSTEM']->am->deleteShadowAssetLink($link_info[
'linkid']);
616 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($link_info[
'linkid']);
624 if ($link_info[
'majorid'] == $trash_folder->id) {
630 $_assets[$minor_asset->id] = Array(
631 'linkid' => $link_info[
'linkid'],
632 'link_type' => $link_info[
'link_type'],
633 'parentid' => $link_info[
'majorid'],
638 'link_action' =>
'move',
639 'to_parent_assetid' => $trash_folder->id,
640 'to_parent_pos' => 1,
641 'assets' => $_assets,
644 $hh->queueHipo(
'hipo_job_create_links', $hipo_var);
647 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
649 $url = $hh->runQueuedJobs();
659 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
660 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
664 if ($delete_linkid ==
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS') {
665 $attribute = Array(
'name' =>
'delete_link_all',
'value' => TRUE);
667 $attribute = Array(
'name' =>
'delete_linkid',
'value' => $delete_linkid);
669 if (!$asset->
setAttrValue($attribute[
'name'], $attribute[
'value'])) {
670 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
671 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
676 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
677 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
681 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
682 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
705 $o->
openField(translate(
'new_link_child'));
706 asset_finder($prefix.
'_minor_assetid');
710 $o->
openField(translate(
'new_link_type'));
711 $editable_link_types = Array(
712 SQ_LINK_TYPE_1 => link_type_name(SQ_LINK_TYPE_1),
713 SQ_LINK_TYPE_2 => link_type_name(SQ_LINK_TYPE_2),
714 SQ_LINK_NOTICE => link_type_name(SQ_LINK_NOTICE),
716 combo_box($prefix.
'_link_type', $editable_link_types, FALSE, SQ_LINK_TYPE_1);
720 $o->
openField(translate(
'use_link_value'));
721 text_box($prefix.
'_link_value',
'', 20, 20);
728 $id_parts = explode(
':', $major_asset->id);
731 if (isset($id_parts[1])) {
733 $o->
note(translate(
'cron_manager_future_not_available_create'));
740 $o->
note(translate(
'cron_manager_create_now_or_later'));
742 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
743 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), $GLOBALS[
'SQ_SYSTEM']->datetime($cron_mgr->timeOfNextRun())));
766 if ($minor_id_array = array_get_index($_POST, $prefix.
'_minor_assetid', FALSE)) {
768 $minor_id = $minor_id_array[
'assetid'];
771 if (empty($minor_id))
return;
774 $link_type = array_get_index($_POST, $prefix.
'_link_type', SQ_LINK_TYPE_1);
777 $link_value = array_get_index($_POST, $prefix.
'_link_value',
'');
780 $future_time = Array();
781 $future_time[
'day'] = array_get_index($_REQUEST, $prefix.
'_when_day',
'');
782 $future_time[
'month'] = array_get_index($_REQUEST, $prefix.
'_when_month',
'');
783 $future_time[
'year'] = array_get_index($_REQUEST, $prefix.
'_when_year',
'');
784 $future_time[
'duration'] = array_get_index($_REQUEST, $prefix.
'_when_duration',
'');
785 $future_time[
'period'] = array_get_index($_REQUEST, $prefix.
'_when_period',
'');
788 $link_now = ($future_time[
'day'] ==
'') || ($future_time[
'month'] ==
'') || ($future_time[
'year'] ==
'') || ($future_time[
'duration'] ==
'') |
789 (($future_time[
'day'] ==
'--') && ($future_time[
'month'] ==
'--') && ($future_time[
'year'] ==
'--') && ($future_time[
'duration'] ==
'-'));
795 $value = $link_value;
799 $am = $GLOBALS[
'SQ_SYSTEM']->am;
812 $id_parts = explode(
':', $major_asset->id);
815 if (isset($id_parts[1])) {
816 $bridge = $am->getAsset($id_parts[0]);
817 $_links = $bridge->getLinks($major_asset->id, SQ_SC_LINK_BACKEND_NAV,
'', TRUE,
'major');
820 if (count($_links) <= 0)
return FALSE;
825 $_assets[$minor_asset->id] = Array(
826 'linkid' => $bridge->id.
':'.$minor_asset->id,
827 'link_type' => $link_type,
828 'parentid' => $_links[0][
'majorid'],
833 $_links = $am->getLink($major_asset->id, NULL,
'', TRUE, NULL,
'major');
836 $_assets[$minor_id] = Array(
837 'linkid' => isset($_links[
'linkid']) ? $_links[
'linkid'] :
'',
838 'link_type' => $link_type,
839 'parentid' => $major_asset->id,
844 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($minor_id);
845 $value = $link_value;
849 $asset->
prepareLink($major_asset,
'minor', $link_type, $value, $sort_order, $dependant, $exclusive);
850 $major_asset->prepareLink($asset,
'major', $link_type, $value, $sort_order, $dependant, $exclusive);
851 $can_create = $major_asset->canCreateLink($asset, $link_type, $exclusive);
854 if ($can_create !== TRUE)
return FALSE;
857 'link_action' =>
'create',
858 'to_parent_assetid' => $major_asset->id,
859 'to_parent_pos' => 1,
860 'assets' => $_assets,
861 'link_value' => $value,
863 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
864 $hh->queueHipo(
'hipo_job_create_links', $hipo_var);
867 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
869 $url = $hh->runQueuedJobs();
876 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
877 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
878 $minor_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($minor_id);
880 if (is_null($minor_asset)) {
881 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
882 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
885 $link_info = $asset->
attr(
'link_info');
886 $link_info[
'link_type'] = $link_type;
887 $link_info[
'value'] = $link_value;
889 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
890 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
895 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
896 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
901 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
902 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
906 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
907 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
933 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($major->id, SQ_SC_LINK_SIGNIFICANT|SQ_LINK_NOTICE,
'', TRUE,
'major');
934 $link_options = Array(0 =>
'',
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS' => translate(
'cron_fl_delete_all_existing_links'));
935 foreach ($links as $link) {
936 $print_link_type = $this->_printLinkType($link);
937 $child = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
938 if (is_null($child))
continue;
943 if (empty($link[
'linkid']))
continue;
946 $link_options[$link[
'linkid']] = translate(
'link').
' #'.$link[
'linkid'].
' ('.$print_link_type.
') - '.translate(
'child').
' : '.$child->name.
' (#'.$child->id.
')';
949 $default_delete_linkid = $asset->
attr(
'delete_linkid');
950 if ($asset->
attr(
'delete_link_all')) {
951 $default_delete_linkid =
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS';
953 combo_box($prefix.
'_delete_linkid', $link_options, FALSE, $default_delete_linkid);
960 $id_parts = explode(
':', $major_asset->id);
963 if (isset($id_parts[1])) {
965 $o->
note(translate(
'cron_manager_future_not_available_delete'));
972 $o->
note(translate(
'cron_manager_delete_now_or_later'));
974 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
975 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), $GLOBALS[
'SQ_SYSTEM']->datetime($cron_mgr->timeOfNextRun())));
998 if (empty($_POST[$prefix.
'_delete_linkid'])) {
1004 $delete_linkid = $_POST[$prefix.
'_delete_linkid'];
1008 $future_time[] = Array();
1009 $future_time[
'day'] = array_get_index($_REQUEST, $prefix.
'_when_day',
'');
1010 $future_time[
'month'] = array_get_index($_REQUEST, $prefix.
'_when_month',
'');
1011 $future_time[
'year'] = array_get_index($_REQUEST, $prefix.
'_when_year',
'');
1012 $future_time[
'duration'] = array_get_index($_REQUEST, $prefix.
'_when_duration',
'');
1013 $future_time[
'period'] = array_get_index($_REQUEST, $prefix.
'_when_period',
'');
1016 $link_now = ($future_time[
'day'] ==
'') || ($future_time[
'month'] ==
'') || ($future_time[
'year'] ==
'') || ($future_time[
'duration'] ==
'') |
1017 (($future_time[
'day'] ==
'--') && ($future_time[
'month'] ==
'--') && ($future_time[
'year'] ==
'--') && ($future_time[
'duration'] ==
'-'));
1025 $trash_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trash_folder');
1028 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1031 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
1034 if ($delete_linkid ==
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS') {
1035 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($major_asset->id, SQ_SC_LINK_SIGNIFICANT,
'', TRUE,
'major');
1036 $link_options = Array();
1041 foreach ($links as $link) {
1044 if (empty($link[
'linkid']))
continue;
1047 $link_info = $am->getLinkById($link[
'linkid'], $major_asset->id,
'major');
1049 $_assets[$link_info[
'minorid']] = Array();
1052 $_assets[$link_info[
'minorid']][] = Array(
1053 'linkid' => $link_info[
'linkid'],
1054 'link_type' => $link_info[
'link_type'],
1055 'parentid' => $major_asset->id,
1060 if (!empty($_assets)) {
1063 'link_action' =>
'move',
1064 'to_parent_assetid' => $trash_folder->id,
1065 'to_parent_pos' => 1,
1066 'assets' => $_assets,
1070 $hh->queueHipo(
'hipo_job_create_links', $hipo_vars);
1073 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
1075 $url = $hh->runQueuedJobs();
1090 $link_info = $am->getLinkById($delete_linkid, $major_asset->id,
'major');
1093 if ($link_info[
'link_type'] == SQ_LINK_NOTICE) {
1095 if (is_null($link_info[
'minor_type_code'])) {
1096 $GLOBALS[
'SQ_SYSTEM']->am->deleteShadowAssetLink($link_info[
'linkid']);
1098 $GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($link_info[
'linkid']);
1108 $_assets[$link_info[
'minorid']] = Array(
1109 'linkid' => $link_info[
'linkid'],
1110 'link_type' => $link_info[
'link_type'],
1111 'parentid' => $major_asset->id,
1116 'link_action' =>
'move',
1117 'to_parent_assetid' => $trash_folder->id,
1118 'to_parent_pos' => 1,
1119 'assets' => $_assets,
1122 $hh->queueHipo(
'hipo_job_create_links', $hipo_var);
1125 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
1127 $url = $hh->runQueuedJobs();
1137 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1138 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1142 if ($delete_linkid ==
'SQ_CRON_JOB_FUTURE_LINEAGE_DELETE_ALL_LINKS') {
1143 $attribute = Array(
'name' =>
'delete_link_all',
'value' => TRUE);
1145 $attribute = Array(
'name' =>
'delete_linkid',
'value' => $delete_linkid);
1147 if (!$asset->
setAttrValue($attribute[
'name'], $attribute[
'value'])) {
1148 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1149 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1154 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1155 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1160 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1161 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1165 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1166 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1180 private function _printLinkType($link_info)
1183 if (!isset($link_info[
'link_type'])) {
1184 return $type_return;
1187 switch ($link_info[
'link_type']) {
1188 case SQ_LINK_TYPE_1:
1189 $type_return =
'TYPE 1';
1191 case SQ_LINK_TYPE_2:
1192 $type_return =
'TYPE 2';
1194 case SQ_LINK_NOTICE:
1195 $type_return =
'NOTICE';
1201 return $type_return;