4 require_once SQ_SYSTEM_ROOT.
'/core/hipo/hipo_job.inc';
19 protected $_usual_statuses = Array(
20 SQ_STATUS_UNDER_CONSTRUCTION => SQ_SC_STATUS_CAN_APPROVE,
21 SQ_STATUS_PENDING_APPROVAL => SQ_SC_STATUS_PENDING,
22 SQ_STATUS_APPROVED => SQ_SC_STATUS_ALL_APPROVED,
23 SQ_STATUS_LIVE => SQ_STATUS_LIVE,
37 'SQ_HIPO_EDIT_BUNDLED_ASSETS_STATUS_THRESHOLD' => Array(
'editable' => 1,
'default' => 1),
65 if (SQ_HIPO_EDIT_BUNDLED_ASSETS_STATUS_THRESHOLD < 1) {
83 return translate(
'hipo_name_edit_bundled_assets_status');
101 return parent::getCodeName().
'-'.$this->_running_vars[
'bundle_assetid'];
117 'name' => translate(
'hipo_job_edit_bundled_assets_status_status'),
118 'function_call' => Array(
119 'paint_function' =>
'paintStatusChangeWarning',
120 'process_function' =>
'processStatusChangeWarning',
122 'running_mode' =>
'web',
123 'auto_step' => FALSE,
124 'skip_step' => FALSE,
125 'allow_cancel' => TRUE,
131 'name' => translate(
'hipo_job_edit_bundled_assets_status_status'),
132 'function_call' => Array(
133 'process_function' =>
'processBundledAsset',
135 'running_mode' =>
'server',
137 'allow_cancel' => TRUE,
143 'name' => translate(
'hipo_job_edit_bundled_assets_status_send'),
144 'function_call' => Array(
145 'process_function' =>
'sendBundleWorkflowMessage',
147 'running_mode' =>
'server',
149 'allow_cancel' => TRUE,
167 if (array_key_exists(
'bundle_assetid', $this->_running_vars) === FALSE) {
168 trigger_localised_error(
'HIPO0092', E_USER_WARNING);
173 $bundle_assetid = $this->_running_vars[
'bundle_assetid'];
174 $type_code = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($bundle_assetid,
'', TRUE,
'type_code');
177 if (count($type_code) === 0) {
178 trigger_localised_error(
'HIPO0093', E_USER_WARNING, $bundle_assetid);
183 if ($type_code[$bundle_assetid] !==
'workflow_bundle') {
184 trigger_localised_error(
'HIPO0094', E_USER_WARNING, $bundle_assetid);
188 if (array_key_exists(
'workflow_stream', $this->_running_vars) === FALSE) {
189 $this->_running_vars[
'workflow_stream'] =
'';
194 $this->_running_vars[
'todo_assetids'] = Array();
195 $this->_running_vars[
'warn_assetids'] = Array();
197 $bundle_status = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($bundle_assetid),
'', FALSE,
'status');
198 $this->_running_vars[
'bundle_current_status'] = (int)$bundle_status[$bundle_assetid];
200 foreach ($todo_assetids as $todo_assetid) {
201 $new_asset_status = $this->
_getNewAssetStatus($todo_assetid, (
int)$this->_running_vars[
'bundle_current_status'], (
int)$this->_running_vars[
'new_status'], $this->_running_vars[
'workflow_stream']);
202 $this->_running_vars[
'todo_assetids'][$todo_assetid] = $new_asset_status;
205 if ($new_asset_status !== NULL) {
206 if (((
int)$new_asset_status & $this->_usual_statuses[(
int)$this->_running_vars[
'new_status']]) === 0) {
207 $this->_running_vars[
'warn_assetids'][$new_asset_status][] = $todo_assetid;
212 if (count($this->_running_vars[
'warn_assetids']) === 0) {
216 $this->_running_vars[
'done_root'] = FALSE;
217 $this->_running_vars[
'done_assetids'] = Array();
219 $this->_running_vars[
'msg_filters'] = Array();
221 return parent::prepare();
240 parent::paint($o, $nested);
243 if (!empty($this->_running_vars[
'sub_job'])) {
244 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
245 $sub_job = $hh->getJob($this->_running_vars[
'sub_job']);
246 if (!is_null($sub_job)) {
247 $sub_job->paint($o, TRUE);
249 unset($this->_running_vars[
'sub_job']);
263 while (!empty($this->_running_vars[
'todo_assetids']) || !empty($this->_running_vars[
'sub_job'])) {
295 $o->
openSection(translate(
'hipo_job_edit_bundled_assets_status_status'));
298 echo translate(
'hipo_job_edit_bundled_assets_status_status_warning');
301 foreach ($this->_running_vars[
'warn_assetids'] as $status => $warn_assetids) {
302 $o->
openSection(translate(
'hipo_job_edit_bundled_assets_status_status_line', get_asset_status_icon($status), get_status_description($status)));
305 foreach ($warn_assetids as $assetid) {
307 echo get_asset_tag_line($assetid);
335 $complete = (($step_data[
'percent_done'] > 0) || (empty($this->_running_vars[
'warn_assetids']) === TRUE));
337 if ($complete === FALSE) {
338 $step_data[
'percent_done'] = 50;
340 $step_data[
'percent_done'] = 100;
341 $step_data[
'complete'] = TRUE;
360 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
361 if (empty($this->_running_vars[
'sub_job']) === FALSE) {
362 $sub_job = $hh->getJob($this->_running_vars[
'sub_job']);
363 if (empty($sub_job) === TRUE) {
367 $current_status = (int)$this->_running_vars[
'bundle_current_status'];
368 $new_status = (int)$this->_running_vars[
'new_status'];
370 if ($this->_running_vars[
'done_root'] === FALSE) {
371 $assetid = $this->_running_vars[
'bundle_assetid'];
372 $new_asset_status = $this->_running_vars[
'new_status'];
373 $this->_running_vars[
'done_root'] = TRUE;
375 $new_asset_status = reset($this->_running_vars[
'todo_assetids']);
376 $assetid = key($this->_running_vars[
'todo_assetids']);
377 unset($this->_running_vars[
'todo_assetids'][$assetid]);
380 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
382 if (isset($this->_running_vars[
'no_status_integrity'][$assetid])) {
383 $run_level = $GLOBALS[
'SQ_SYSTEM']->getRunLevel();
384 $GLOBALS[
'SQ_SYSTEM']->setRunLevel($run_level ^ SQ_SECURITY_STATUS_INTEGRITY);
388 if ($new_asset_status !== NULL) {
390 $asset_current_status = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($assetid),
'asset', FALSE,
'status');
391 $asset_current_status = $asset_current_status[$assetid];
397 if (empty($this->_running_vars[
'log_message']) === FALSE) {
398 if (($asset_current_status & SQ_SC_STATUS_PENDING) > 0) {
403 $this->_running_vars[
'sub_job'] = $code_name;
404 $sub_job = $hh->getJob($code_name);
405 $step_data[
'message'] = translate(
'hipo_edit_status', htmlentities($asset->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET), $assetid);
407 $step_data[
'message'] = translate(
'hipo_skipping_asset', $assetid);
412 'start' =>
'asset.workflow.invitation',
413 'progress' =>
'asset.workflow.invitation.progress',
414 'approve' =>
'asset.workflow.announce.approve',
415 'reject' =>
'asset.workflow.announce.reject',
416 'auto_approve_progress' =>
'asset.workflow.announce.started',
419 $msg_types = $this->
_getRequiredBundleMessages($this->_running_vars[
'bundle_current_status'], $this->_running_vars[
'new_status']);
420 $used_filters = Array();
421 foreach ($msg_types as $msg_type) {
422 $used_filters[$msg_type] = $filters[$msg_type];
425 if (empty($sub_job) === FALSE) {
426 if ($freestyle === TRUE) {
428 if ($sub_job->freestyle() === TRUE) {
429 $running_vars = $sub_job->getRunningVars();
430 $this->_running_vars[
'done_assetids'][] = $running_vars[
'assetid'];
434 if ((
string)$running_vars[
'assetid'] !== (
string)$this->_running_vars[
'bundle_assetid']) {
435 $job_messages = array_get_index($running_vars,
'messages', Array());
436 $this->
_filterMessages($running_vars[
'assetid'], $job_messages, $used_filters);
438 $job_messages = Array();
443 $this->_hipo_vars[
'errors'] = array_merge($this->_hipo_vars[
'errors'], $sub_job->_hipo_vars[
'errors']);
444 unset($this->_running_vars[
'sub_job']);
446 $hh->uncacheJob($sub_job->code_name);
449 $this->_hipo_vars[
'errors'] = array_merge($this->_hipo_vars[
'errors'], $sub_job->_hipo_vars[
'errors']);
453 if ($sub_job->process() === TRUE) {
454 if ($sub_job->complete() === TRUE) {
456 $running_vars = $sub_job->getRunningVars();
457 if (isset($running_vars[
'assetid'])) {
458 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($running_vars[
'assetid']);
459 $asset->_updated(FALSE);
460 $this->_running_vars[
'done_assetids'][] = $running_vars[
'assetid'];
464 if ((
string)$running_vars[
'assetid'] !== (
string)$this->_running_vars[
'bundle_assetid']) {
465 $job_messages = array_get_index($running_vars,
'messages', Array());
466 $this->
_filterMessages($running_vars[
'assetid'], $job_messages, $used_filters);
468 $job_messages = Array();
474 $this->_hipo_vars[
'errors'] = array_merge($this->_hipo_vars[
'errors'], $sub_job->_hipo_vars[
'errors']);
475 unset($this->_running_vars[
'sub_job']);
479 $this->_hipo_vars[
'errors'] = array_merge($this->_hipo_vars[
'errors'], $sub_job->_hipo_vars[
'errors']);
485 if (empty($job_messages) === FALSE) {
488 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
489 $ms->send($job_messages);
493 if (empty($this->_running_vars[
'todo_assetids'])) {
494 if (empty($this->_running_vars[
'sub_job'])) {
496 $step_data[
'percent_done'] = 100;
497 $step_data[
'complete'] = TRUE;
501 $step_data[
'complete'] = FALSE;
504 $total = count($this->_running_vars[
'todo_assetids']) + count($this->_running_vars[
'done_assetids']);
505 $step_data[
'percent_done'] =(count($this->_running_vars[
'done_assetids']) / $total) * 100;
506 $step_data[
'complete'] = FALSE;
509 if (isset($this->_running_vars[
'no_status_integrity'][$assetid])) {
510 unset($this->_running_vars[
'no_status_integrity'][$assetid]);
511 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
530 $bundle = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->_running_vars[
'bundle_assetid']);
532 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
534 $msg_types = Array();
538 'start' =>
'asset.workflow.bundle.invitation',
539 'progress' =>
'asset.workflow.bundle.invitation.progress',
540 'approve' =>
'asset.workflow.bundle.announce.approve',
541 'reject' =>
'asset.workflow.bundle.announce.reject',
542 'auto_approve_progress' =>
'asset.workflow.bundle.started',
545 $msg_types = $this->
_getRequiredBundleMessages($this->_running_vars[
'bundle_current_status'], $this->_running_vars[
'new_status']);
547 if (count($msg_types) > 0) {
548 foreach ($msg_types as $msg_type) {
549 if (empty($this->_running_vars[
'msg_filters'][$msg_type]) === FALSE) {
550 foreach ($this->_running_vars[
'msg_filters'][$msg_type] as $userid => $assets) {
551 $asset_list_lines = Array();
553 foreach ($assets as $assetid) {
557 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($assetid);
558 $format_line =
'<a href="'.$workflow_url.
'">'.$asset_info[$assetid][
'name'].
' (Id: #'.$assetid.
')</a> [<a href="'.$preview_url.
'">Preview</a>]';
560 $asset_list_lines[] = $format_line;
564 $body = trim($bundle->attr($msg_type.
'_workflow_msg'));
565 $subject = trim($bundle->attr($msg_type.
'_workflow_subject'));
566 $keywords = extract_keywords($body);
568 $replacements = Array();
571 $replacements[
'bundle_reject_url'] = $this->
_getBackendScreenKeywordReplacement($bundle->id,
'workflow').
'&asset_version='.$bundle->version.
'&workflow_link_action=reject';
572 $replacements[
'bundle_approve_url'] = $this->
_getBackendScreenKeywordReplacement($bundle->id,
'workflow').
'&asset_version='.$bundle->version.
'&workflow_link_action=approve';
574 $replacements[
'bundle_name'] = $bundle->name;
575 $replacements[
'bundle_assetid'] = $bundle->id;
576 $replacements[
'new_status'] = $bundle->getStatus()->getDescription();
579 if (count($asset_list_lines) > 0) {
580 $replacements[
'asset_list'] =
'<ul><li>'.implode(
'</li><li>', $asset_list_lines).
'</li></ul>';
582 $replacements[
'asset_list'] =
'';
586 $replacements[
'workflow_user'] = $GLOBALS[
'SQ_SYSTEM']->user->short_name;
587 $replacements[
'workflow_user_first_name'] = $GLOBALS[
'SQ_SYSTEM']->user->attr(
'first_name');
588 $replacements[
'workflow_user_last_name'] = $GLOBALS[
'SQ_SYSTEM']->user->attr(
'last_name');
589 $replacements[
'workflow_user_email'] = $GLOBALS[
'SQ_SYSTEM']->user->attr(
'email');
591 $msg = $ms->newMessage(Array($userid), $im_types[$msg_type], $replacements);
592 if ($subject !==
'') {
593 $msg->subject = $subject;
608 if (count($msg_list) > 0) {
609 $ms->send($msg_list);
612 $step_data[
'percent_done'] = 100;
613 $step_data[
'complete'] = TRUE;
635 require_once(SQ_SYSTEM_ROOT.
'/core/hipo/jobs/hipo_job_edit_status.inc');
637 $init_hipo =
new Hipo_Job_Edit_Status();
638 $options[
'auto_complete'] = TRUE;
643 $running_vars = Array(
644 'assetid' => $assetid,
645 'new_status' => $new_status,
646 'dependants_only' => TRUE,
647 'send_messages' => FALSE,
650 if (array_key_exists(
'workflow_stream', $this->_running_vars) === TRUE) {
651 $running_vars[
'workflow_stream'] = $this->_running_vars[
'workflow_stream'];
654 $init_hipo->setRunningVars($running_vars);
655 foreach ($options as $k => $v) {
656 $init_hipo->setOption($k, $v);
661 $code_name = $init_hipo->initialise($this->source_code_name);
662 if ($code_name)
return $code_name;
679 $linked_assets = Array();
680 $linked_asset_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($bundle_assetid, SQ_LINK_NOTICE);
682 foreach ($linked_asset_links as $linked_asset_link) {
683 $linked_assets[] = $linked_asset_link[
'minorid'];
686 return $linked_assets;
707 $status_changes = Array();
710 if ($assetid === $this->_running_vars[
'bundle_assetid']) {
714 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
716 $asset_status = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($assetid),
'', FALSE,
'status');
717 $asset_status = (int)$asset_status[$assetid];
719 $schemas = $wfm->getSchemas($assetid);
721 switch ($bundle_status) {
722 case SQ_STATUS_UNDER_CONSTRUCTION:
723 if ($new_status === SQ_STATUS_UNDER_CONSTRUCTION) {
725 $status_changes = Array(
728 SQ_STATUS_ARCHIVED => SQ_STATUS_UNDER_CONSTRUCTION,
729 SQ_STATUS_UNDER_CONSTRUCTION => NULL,
730 SQ_STATUS_PENDING_APPROVAL => NULL,
731 SQ_STATUS_APPROVED => NULL,
732 SQ_STATUS_LIVE => SQ_STATUS_EDITING,
733 SQ_STATUS_LIVE_APPROVAL => NULL,
734 SQ_STATUS_EDITING => NULL,
735 SQ_STATUS_EDITING_APPROVAL => NULL,
736 SQ_STATUS_EDITING_APPROVED => NULL,
739 }
else if ($new_status === SQ_STATUS_PENDING_APPROVAL) {
741 $status_changes = Array(
749 SQ_STATUS_ARCHIVED => SQ_STATUS_PENDING_APPROVAL,
750 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_PENDING_APPROVAL,
751 SQ_STATUS_PENDING_APPROVAL => NULL,
752 SQ_STATUS_APPROVED => NULL,
753 SQ_STATUS_LIVE => SQ_STATUS_EDITING_APPROVAL,
754 SQ_STATUS_LIVE_APPROVAL => NULL,
755 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVAL,
756 SQ_STATUS_EDITING_APPROVAL => NULL,
757 SQ_STATUS_EDITING_APPROVED => NULL,
760 if (count($schemas) === 0) {
769 $status_changes[SQ_STATUS_UNDER_CONSTRUCTION] = SQ_STATUS_LIVE;
770 $status_changes[SQ_STATUS_EDITING] = SQ_STATUS_EDITING_APPROVED;
773 $status_changes[SQ_STATUS_ARCHIVED] = SQ_STATUS_LIVE;
774 $status_changes[SQ_STATUS_LIVE] = SQ_STATUS_EDITING_APPROVED;
778 $status_changes[SQ_STATUS_PENDING_APPROVAL] = SQ_STATUS_APPROVED;
779 $status_changes[SQ_STATUS_APPROVED] = SQ_STATUS_LIVE;
780 $status_changes[SQ_STATUS_EDITING_APPROVAL] = SQ_STATUS_EDITING_APPROVED;
782 }
else if ($wfm->testPublish($assetid, $GLOBALS[
'SQ_SYSTEM']->currentUserId(), $workflow_stream) === TRUE) {
786 $status_changes[SQ_STATUS_UNDER_CONSTRUCTION] = SQ_STATUS_APPROVED;
787 $status_changes[SQ_STATUS_PENDING_APPROVAL] = SQ_STATUS_APPROVED;
788 $status_changes[SQ_STATUS_EDITING] = SQ_STATUS_EDITING_APPROVED;
789 $status_changes[SQ_STATUS_EDITING_APPROVAL] = SQ_STATUS_EDITING_APPROVED;
792 $status_changes[SQ_STATUS_ARCHIVED] = SQ_STATUS_APPROVED;
793 $status_changes[SQ_STATUS_LIVE] = SQ_STATUS_EDITING_APPROVED;
797 }
else if ($new_status === SQ_STATUS_APPROVED) {
802 $status_changes = Array(
806 SQ_STATUS_ARCHIVED => SQ_STATUS_APPROVED,
807 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_APPROVED,
808 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_APPROVED,
809 SQ_STATUS_APPROVED => NULL,
810 SQ_STATUS_LIVE => NULL,
811 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_LIVE,
812 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVED,
813 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING_APPROVED,
814 SQ_STATUS_EDITING_APPROVED => NULL,
817 if (count($schemas) === 0) {
823 $status_changes[SQ_STATUS_UNDER_CONSTRUCTION] = SQ_STATUS_LIVE;
826 $status_changes[SQ_STATUS_ARCHIVED] = SQ_STATUS_LIVE;
829 $status_changes[SQ_STATUS_PENDING_APPROVAL] = SQ_STATUS_LIVE;
830 $status_changes[SQ_STATUS_APPROVED] = SQ_STATUS_LIVE;
831 $status_changes[SQ_STATUS_EDITING_APPROVAL] = SQ_STATUS_EDITING_APPROVED;
835 }
else if ($new_status === SQ_STATUS_LIVE) {
839 $status_changes = Array(
846 SQ_STATUS_ARCHIVED => SQ_STATUS_LIVE,
847 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_LIVE,
848 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_LIVE,
849 SQ_STATUS_APPROVED => SQ_STATUS_LIVE,
850 SQ_STATUS_LIVE => NULL,
851 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_LIVE,
852 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVED,
853 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING_APPROVED,
854 SQ_STATUS_EDITING_APPROVED => SQ_STATUS_LIVE,
861 case SQ_STATUS_PENDING_APPROVAL:
862 if ($new_status === SQ_STATUS_PENDING_APPROVAL) {
866 $status_changes = Array(
870 SQ_STATUS_ARCHIVED => SQ_STATUS_PENDING_APPROVAL,
871 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_PENDING_APPROVAL,
872 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_PENDING_APPROVAL,
873 SQ_STATUS_APPROVED => NULL,
874 SQ_STATUS_LIVE => SQ_STATUS_EDITING_APPROVAL,
875 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_LIVE_APPROVAL,
876 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVAL,
877 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING_APPROVAL,
878 SQ_STATUS_EDITING_APPROVED => NULL,
881 if (count($schemas) === 0) {
885 $status_changes = Array();
887 }
else if ($wfm->testPublish($assetid, $GLOBALS[
'SQ_SYSTEM']->currentUserId()) === TRUE) {
891 $status_changes[SQ_STATUS_UNDER_CONSTRUCTION] = SQ_STATUS_APPROVED;
892 $status_changes[SQ_STATUS_PENDING_APPROVAL] = SQ_STATUS_APPROVED;
893 $status_changes[SQ_STATUS_EDITING] = SQ_STATUS_EDITING_APPROVED;
894 $status_changes[SQ_STATUS_EDITING_APPROVAL] = SQ_STATUS_EDITING_APPROVED;
897 $status_changes[SQ_STATUS_ARCHIVED] = SQ_STATUS_APPROVED;
901 }
else if ($new_status === SQ_STATUS_APPROVED) {
905 $status_changes = Array(
907 SQ_STATUS_ARCHIVED => SQ_STATUS_APPROVED,
908 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_APPROVED,
909 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_APPROVED,
910 SQ_STATUS_APPROVED => NULL,
911 SQ_STATUS_LIVE => NULL,
912 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_LIVE,
913 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVED,
914 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING_APPROVED,
915 SQ_STATUS_EDITING_APPROVED => NULL,
918 if (count($schemas) === 0) {
920 $status_changes[SQ_STATUS_UNDER_CONSTRUCTION] = SQ_STATUS_LIVE;
923 }
else if ($new_status === SQ_STATUS_UNDER_CONSTRUCTION) {
926 $this->_running_vars[
'no_status_integrity'][$assetid] = TRUE;
933 $status_changes = Array(
934 SQ_STATUS_ARCHIVED => NULL,
935 SQ_STATUS_UNDER_CONSTRUCTION => NULL,
936 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_UNDER_CONSTRUCTION,
937 SQ_STATUS_APPROVED => SQ_STATUS_UNDER_CONSTRUCTION,
938 SQ_STATUS_LIVE => NULL,
939 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_EDITING,
940 SQ_STATUS_EDITING => NULL,
941 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING,
942 SQ_STATUS_EDITING_APPROVED => SQ_STATUS_EDITING,
949 case SQ_STATUS_APPROVED:
950 if ($new_status === SQ_STATUS_LIVE) {
954 $status_changes = Array(
955 SQ_STATUS_ARCHIVED => NULL,
956 SQ_STATUS_UNDER_CONSTRUCTION => SQ_STATUS_LIVE,
957 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_LIVE,
958 SQ_STATUS_APPROVED => SQ_STATUS_LIVE,
959 SQ_STATUS_LIVE => NULL,
960 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_LIVE,
961 SQ_STATUS_EDITING => SQ_STATUS_EDITING_APPROVED,
962 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING_APPROVED,
963 SQ_STATUS_EDITING_APPROVED => SQ_STATUS_LIVE,
966 }
else if ($new_status === SQ_STATUS_UNDER_CONSTRUCTION) {
968 $status_changes = Array(
969 SQ_STATUS_ARCHIVED => NULL,
970 SQ_STATUS_UNDER_CONSTRUCTION => NULL,
971 SQ_STATUS_PENDING_APPROVAL => SQ_STATUS_UNDER_CONSTRUCTION,
972 SQ_STATUS_APPROVED => SQ_STATUS_UNDER_CONSTRUCTION,
973 SQ_STATUS_LIVE => NULL,
974 SQ_STATUS_LIVE_APPROVAL => SQ_STATUS_EDITING,
975 SQ_STATUS_EDITING => NULL,
976 SQ_STATUS_EDITING_APPROVAL => SQ_STATUS_EDITING,
977 SQ_STATUS_EDITING_APPROVED => SQ_STATUS_EDITING,
985 if ($new_status === SQ_STATUS_UNDER_CONSTRUCTION) {
989 $status_changes = Array(
990 SQ_STATUS_ARCHIVED => SQ_STATUS_UNDER_CONSTRUCTION,
991 SQ_STATUS_UNDER_CONSTRUCTION => NULL,
992 SQ_STATUS_PENDING_APPROVAL => NULL,
993 SQ_STATUS_APPROVED => NULL,
994 SQ_STATUS_LIVE => SQ_STATUS_EDITING,
995 SQ_STATUS_LIVE_APPROVAL => NULL,
996 SQ_STATUS_EDITING => NULL,
997 SQ_STATUS_EDITING_APPROVAL => NULL,
998 SQ_STATUS_EDITING_APPROVED => NULL,
1001 }
else if ($new_status === SQ_STATUS_LIVE) {
1003 $status_changes = Array(
1006 SQ_STATUS_ARCHIVED => NULL,
1007 SQ_STATUS_UNDER_CONSTRUCTION => NULL,
1008 SQ_STATUS_PENDING_APPROVAL => NULL,
1009 SQ_STATUS_APPROVED => SQ_STATUS_LIVE,
1010 SQ_STATUS_LIVE => NULL,
1011 SQ_STATUS_LIVE_APPROVAL => NULL,
1012 SQ_STATUS_EDITING => NULL,
1013 SQ_STATUS_EDITING_APPROVAL => NULL,
1014 SQ_STATUS_EDITING_APPROVED => SQ_STATUS_LIVE,
1023 return array_get_index($status_changes, $asset_status, NULL);
1047 if (count($filters) === 0) {
1051 foreach ($job_messages as $msg_key => $message) {
1055 foreach ($filters as $filter_name => $filter_msg_code) {
1056 if ($message->type === $filter_msg_code) {
1057 $msg_assetid = $message->parameters[
'assetid'];
1062 if ((
string)$msg_assetid === (
string)$assetid) {
1063 foreach ($message->to as $to_user) {
1064 $this->_running_vars[
'msg_filters'][$filter_name][$to_user][] = $msg_assetid;
1072 unset($job_messages[$msg_key]);
1095 $msg_types = Array();
1098 switch ($old_status) {
1099 case SQ_STATUS_UNDER_CONSTRUCTION:
1100 switch ($new_status) {
1101 case SQ_STATUS_PENDING_APPROVAL:
1105 $msg_types = Array(
'start',
'approve',
'auto_approve_progress');
1111 case SQ_STATUS_PENDING_APPROVAL:
1112 switch ($new_status) {
1113 case SQ_STATUS_UNDER_CONSTRUCTION:
1114 $msg_types = Array(
'reject');
1117 case SQ_STATUS_PENDING_APPROVAL:
1118 $msg_types = Array(
'approve',
'progress');
1121 case SQ_STATUS_APPROVED:
1122 $msg_types = Array(
'approve');
1128 case SQ_STATUS_APPROVED:
1129 switch ($new_status) {
1130 case SQ_STATUS_UNDER_CONSTRUCTION:
1131 $msg_types = Array(
'reject');
1155 $hrefs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref(Array($assetid => $screen_name), FALSE);
1157 if (empty($hrefs) === FALSE) {
1158 $href = str_replace(
'./',
'', current($hrefs));
1160 $current_url = sq_web_path(
'root_url');
1161 if ($current_url ===
'') {
1162 $root_urls = explode(
"\n", SQ_CONF_SYSTEM_ROOT_URLS);
1163 $current_url =
'http://'.current($root_urls);
1166 if (SQ_IN_LIMBO === TRUE) {
1167 $replacement = $current_url;
1168 $replacement .= (strpos($href, SQ_CONF_LIMBO_SUFFIX) !== FALSE) ?
'/'.$href :
'/'.SQ_CONF_LIMBO_SUFFIX.$href;
1170 $replacement = $current_url;
1171 $replacement .= (strpos($href, SQ_CONF_BACKEND_SUFFIX) !== FALSE) ?
'/'.$href :
'/'.SQ_CONF_BACKEND_SUFFIX.$href;
1175 return $replacement;
1189 $version = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($assetid),
'asset', FALSE,
'version');
1190 $version = $version[$assetid];
1192 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
1194 'message' => $message_body,
1196 $message = $ms->newMessage(Array(),
'asset.workflow.userlog', $msg_reps);
1197 $message->parameters[
'assetid'] = $assetid;
1198 $message->parameters[
'version'] = substr($version, 0, strrpos($version,
'.'));