17 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
18 require_once DIRNAME(__FILE__).
'/details.inc';
43 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
44 $schemas = $wfm->getSchemas($owner->id, NULL, FALSE, TRUE);
46 if (empty($schemas))
return FALSE;
49 foreach ($schemas as $schemaid => $schema_info) {
50 $granted = $schema_info[
'granted'];
51 if (!isset($direct[$granted])) {
52 $direct[$granted] = Array();
54 $direct[$granted][] = $schemaid;
61 <table
class=
"sq-backend-table">
63 <td
class=
"sq-backend-table-header">
64 <?php echo translate(
'workflow_schema'); ?>
66 <td
class=
"sq-backend-table-header" align=
"right">
67 <?php translate(
'access'); ?>
72 if (!empty($direct)) {
73 foreach ($direct as $granted => $schemaids) {
74 foreach ($schemaids as $schemaid) {
76 $schema_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($schemaid),
'workflow_schema', FALSE);
77 if (empty($schema_info))
continue;
81 <td
class=
"sq-backend-table-cell">
83 echo get_asset_tag_line($schemaid);
86 <td
class=
"sq-backend-table-cell" align=
"right">
87 <span style=
"color: <?php echo (($granted == '0') ? 'red' : 'green'); ?>; font-weight: bold;"><?php echo (($granted ==
'0') ? translate(
'denied') : translate(
'applied')) ?></span>
117 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
118 $schemas = $wfm->getSchemas($owner->id);
119 $running_schemas = $wfm->getSchemas($owner->id, TRUE, TRUE);
124 $publishers = $wfm->whoCanPublish($owner->id);
125 $current_userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
126 $can_publish = in_array($current_userid, $publishers);
128 $email_link_require_comment = FALSE;
129 $wf_email_link_updated = FALSE;
130 $no_access_to_edit = FALSE;
134 if (isset($_REQUEST[
'asset_version'])) {
135 $link_asset_version = $_REQUEST[
'asset_version'];
136 $link_asset_version_wo_micro = substr($link_asset_version, 0, strrpos($link_asset_version,
'.'));
137 $owner_version_wo_micro = substr($owner->version, 0, strrpos($owner->version,
'.'));
140 if (isset($_REQUEST[
'workflow_link_action'])) {
141 if (isset($_REQUEST[
'asset_version']) && version_compare($link_asset_version_wo_micro,$owner_version_wo_micro )== 0 ) {
143 ksort($available_statii);
145 if ($_REQUEST[
'workflow_link_action'] ==
'approve') {
146 foreach ($available_statii as $status_val => $desc) {
147 if ($owner->status <= $status_val) {
148 $new_status = $status_val;
152 }
else if ($_REQUEST[
'workflow_link_action'] ==
'reject') {
153 foreach ($available_statii as $status_val => $desc) {
154 if ($owner->status >= $status_val) {
155 $new_status = $status_val;
161 if (!$wfm->requiresComment($owner->id, $GLOBALS[
'SQ_SYSTEM']->user->id)) {
162 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
164 'assetid' => $owner->id,
165 'dependants_only' => TRUE,
167 if ($new_status != NULL) {
168 $vars[
'new_status'] = $new_status;
169 $hh->freestyleHipo(
'hipo_job_edit_status', $vars);
171 $wf_email_link_updated = TRUE;
173 $email_link_require_comment = TRUE;
174 $default_selection = $_REQUEST[
'workflow_link_action'];
177 $no_access_to_edit = TRUE;
180 trigger_localised_error(
'CORE0280', E_USER_WARNING);
186 $running_schemas = $wfm->getSchemas($owner->id, TRUE, TRUE);
188 $root = $ei->
findScreen(
'static_screen_workflow');
189 if (is_null($root))
return FALSE;
192 $print_commit_button = FALSE;
194 foreach ($root->section as $section) {
197 if (is_null($keywords)) {
199 if (SQ_IN_LIMBO && (!isset($section->attributes()->limbo_access) || (
int)$section->attributes()->limbo_access == 0)) {
204 $section_access = $ei->
_getAccess($owner, $section, $prefix);
205 if (!($section_access & SQ_EI_READ)) {
209 if (!is_null($keywords) && isset($keywords[
'sections'][strtolower(str_replace(
' ',
'_', $section->attributes()->name))])) {
213 $o->
openSection(array_get_index($section->attributes(),
'display_name', $section->attributes()->name));
215 if (!($num_fields = count($section->children()))) {
219 foreach ($section->field as $field) {
221 switch (strtolower($field->attributes()->code)) {
225 case 'workflow_status_change' :
228 if ((!$can_publish) && (!$admin_access)) {
229 if ($no_access_to_edit) {
230 trigger_localised_error(
'CORE0281', E_USER_WARNING, $_REQUEST[
'workflow_link_action']. ($_REQUEST[
'workflow_link_action'] ==
'approve' ?
'd' :
'ed'));
235 if ($wf_email_link_updated) {
238 echo
'<b class="sq-backend-warning">['.translate(
'workflow_email_link_updated', ($_REQUEST[
'workflow_link_action']. ($_REQUEST[
'workflow_link_action'] ==
'approve' ?
'd' :
'ed'))).
']</b>';
243 if (!empty($running_schemas)) {
244 if ($email_link_require_comment) {
247 echo
'<b class="sq-backend-warning">['.translate(
'email_link_require_comment').
']</b>';
251 $o->
openField(translate(
'change_status'));
252 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_status_change'])) {
257 _paintStatusChange($owner, $o, $prefix, $available_statii, $email_link_require_comment ? $new_status : 0);
258 ?><span
class=
"sq-backend-fineprint"><?php
259 if (!empty($available_statii)) {
260 echo
'<br />'.translate(
'change_to_approve_or_reject');
262 echo translate(
'cannot_approve_or_reject');
267 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_status_change'])) {
268 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_status_change']] = ob_get_contents();
276 case 'workflow_log_message' :
279 if ((!$can_publish) && (!$admin_access)) {
282 if (!empty($running_schemas)) {
285 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_log_message'])) {
289 text_area($prefix.
'_workflow_new_log_message',
'', 60, 6);
292 if ($wfm->requiresComment($owner->id, $GLOBALS[
'SQ_SYSTEM']->user->id)) {
293 echo translate(
'workflow_must_enter_reason_for_decision');
295 echo translate(
'workflow_may_enter_reason_for_decision');
299 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_log_message'])) {
300 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_log_message']] = ob_get_contents();
308 case 'workflow_status_commit' :
311 if ((!$can_publish) && (!$admin_access)) {
314 if (!empty($running_schemas)) {
317 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_status_commit'])) {
320 $require_comment = $wfm->requiresComment($owner->id, $GLOBALS[
'SQ_SYSTEM']->user->id);
321 $button_js =
'submit_form()';
322 if ($require_comment) {
323 $button_js =
"elt = document.getElementById('".$prefix.
"_workflow_new_log_message'); if (elt && elt.value.replace(".
'/^\s+|\s+$/g'.
", '').length == 0) alert(js_translate('must_enter_comment_error')); else submit_form();";
325 normal_button($prefix.
'_workflow_status_update', SQ_CONF_COMMIT_BUTTON_TEXT, $button_js);
328 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_status_commit'])) {
329 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_status_commit']] = ob_get_contents();
337 case 'workflow_logs' :
339 $o->
openField(translate(
'workflow_logs'));
340 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_logs'])) {
344 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
345 $logs = $ms->getLogs(
'asset.workflow.log.*', Array(
'assetid' => $owner->id));
347 $user_logs = $ms->getLogs(
'asset.workflow.userlog', Array(
'assetid' => $owner->id));
348 usort($logs, Array(
'Messaging_Service',
'sortMessages'));
349 usort($user_logs, Array(
'Messaging_Service',
'sortMessages'));
351 if (!empty($user_logs) || !empty($logs)) {
353 <table
class=
"sq-backend-table">
355 <td
class=
"sq-backend-table-header" nowrap width=
"120"><?php echo translate(
'log_time'); ?></td>
356 <td
class=
"sq-backend-table-header" nowrap width=
"120"><?php echo translate(
'logged_by'); ?></td>
357 <td
class=
"sq-backend-table-header" width=
"100%"><?php echo translate(
'message'); ?></td>
360 if (!empty($user_logs)) {
363 <td
class=
"sq-backend-table-header" colspan=
"3"><?php echo translate(
'most_recent_user_log_message'); ?></td>
366 for ($log_num = 0; $log_num < 4; $log_num++) {
367 if (!isset($user_logs[$log_num]))
break;
368 $log_data = $user_logs[$log_num];
371 <td
class=
"sq-backend-table-cell" nowrap><?php echo ts_iso8601($log_data[
'sent']); ?></td>
372 <td
class=
"sq-backend-table-cell" nowrap><?php echo $log_data[
'from_name']; ?></td>
373 <td
class=
"sq-backend-table-cell" width=
"100%"><?php echo $log_data[
'body']; ?></td>
382 <td
class=
"sq-backend-table-header" colspan=
"3"><?php echo translate(
'most_recent_system_workflow_message'); ?></td>
385 for ($log_num = 0; $log_num < 4; $log_num++) {
386 if (!isset($logs[$log_num]))
break;
387 $log_data = $logs[$log_num];
390 <td
class=
"sq-backend-table-cell" nowrap><?php echo ts_iso8601($log_data[
'sent']); ?></td>
391 <td
class=
"sq-backend-table-cell" nowrap><?php echo $log_data[
'from_name']; ?></td>
392 <td
class=
"sq-backend-table-cell" width=
"100%"><b><?php echo $log_data[
'subject']; ?></b><br/><?php echo $log_data[
'body']; ?></td>
399 <td
class=
"sq-backend-table-header" colspan=
"3" align=
"middle">
400 <a
class=
"sq-backend-table-header" href=
"<?php echo $owner->getBackendHref('logs'); ?>&sq_backend_log_type=asset.workflow"><?php echo translate(
'view_all_workflow_logs'); ?></a>
409 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_logs'])) {
410 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_logs']] = ob_get_contents();
419 case 'workflow_report' :
421 if (!empty($running_schemas)) {
425 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_report'])) {
429 $schema_workflows = $wfm->getSchemaWorkflows($owner->id);
430 foreach ($schema_workflows as $schemaid => $workflow) {
432 if (!in_array($schemaid, $running_schemas))
continue;
434 if (!isset($workflow[
'stream_name'])) $workflow[
'stream_name'] = translate(
'default_stream');
435 $schema_title = translate(
'running_workflow').
' - '.$workflow[
'schema_name'].
' - '.$workflow[
'stream_name'];
436 if (isset($workflow[
'complete']) && $workflow[
'complete']) {
437 $schema_title .=
' <span style="color:#008800">['.translate(
'completed').
']</span>';
439 $schema_title .=
' <span style="color:#880000">['.translate(
'not_completed').
']</span>';
446 $o->
openField(translate(
'workflow_started'));
447 echo $GLOBALS[
'SQ_SYSTEM']->datetime($workflow[
'started']);
450 $o->
openField(translate(
'time_running'));
451 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
452 echo easy_time_total(time() - $workflow[
'started'], TRUE);
456 foreach ($workflow[
'steps'] as $stepid => $step_data) {
457 $section_title =
"Step $stepid - ".$step_data[
'step_name'];
459 if ($step_data[
'expired']) {
460 $section_title .=
' <span style="color:#FF9900">['.translate(
'escalated').
']</span>';
462 if ($step_data[
'completed']) {
463 $section_title .=
' <span style="color:#008800">['.translate(
'completed').
']</span>';
465 $section_title .=
' <span style="color:#880000">['.translate(
'not_completed').
']</span>';
470 if ($step_data[
'started']) {
471 $o->
openField(translate(
'step_duration'));
472 echo $GLOBALS[
'SQ_SYSTEM']->datetime($step_data[
'started']);
474 if ($step_data[
'completed']) {
475 echo $GLOBALS[
'SQ_SYSTEM']->datetime($step_data[
'completed']);
480 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
481 if ($step_data[
'completed']) {
482 echo easy_time_total($step_data[
'completed'] - $step_data[
'started'], TRUE);
484 echo easy_time_total(time() - $step_data[
'started'], TRUE);
488 if ($step_data[
'expiry_time'] > 0) {
490 $expiry_time = $step_data[
'started'] + $step_data[
'expiry_time'];
491 echo $GLOBALS[
'SQ_SYSTEM']->datetime($expiry_time);
493 echo easy_time_total($expiry_time - time(), TRUE);
497 $o->
openField(translate(
'automatically_escalate'));
498 if ($step_data[
'escalate']) {
499 echo translate(
'yes');
501 echo translate(
'no');
506 if (isset($wfm->_valid_cond_logic[$step_data[
'logic']])) {
508 $step_logic = $step_data[
'logic'];
509 $step_logic_num =
'';
511 if ($step_data[
'logic'] !=
'all') {
512 list($step_logic, $step_logic_num) = explode(
' ', $step_data[
'logic']);
515 $step_logic_num =
'';
519 echo
'<i>'.$wfm->_valid_step_logic[$step_logic];
520 if ($step_logic_num) {
521 echo
" $step_logic_num condition".(($step_logic_num > 1) ?
's' :
'').
' must be met</i>';
530 <table
class=
"sq-backend-table">
532 <td
class=
"sq-backend-table-header"> </td>
533 <td
class=
"sq-backend-table-header" width=
"270"><b><?php echo translate(
'group_logic'); ?></b></td>
534 <td align=
"center" width=
"100" class=
"sq-backend-table-header"><b><?php echo translate(
'complete_question'); ?></b></td>
537 foreach ($step_data[
'conditions'] as $pub => $cond_data) {
538 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($pub);
539 if (!$asset->id)
continue;
542 <td
class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($pub); ?></td>
543 <td
class=
"sq-backend-table-cell">
545 if (isset($wfm->_valid_cond_logic[$cond_data[
'logic']])) {
547 $cond_logic = $cond_data[
'logic'];
548 $cond_logic_num =
'';
550 if ($cond_data[
'logic'] !=
'all') {
551 list($cond_logic, $cond_logic_num) = explode(
' ', $cond_data[
'logic']);
554 $cond_logic_num =
'';
558 if ($asset instanceof
User) {
561 echo
'<i>'.$wfm->_valid_cond_logic[$cond_logic];
562 if ($cond_logic_num) {
563 echo
" $cond_logic_num group member".(($cond_logic_num > 1) ?
's' :
'').
' must approve</i>';
569 <td align=
"center" class=
"sq-backend-table-cell">
571 if (isset($cond_data[
'complete']) && $cond_data[
'complete']) {
572 echo
'<span style="color:#008800"><b>'.translate(
'yes').
'</b></span>';
575 if ($asset instanceof User) {
576 echo ((isset($cond_data[
'published_by'][$asset->id])) ?
'<span style="color:#008800"><b>'.translate(
'yes').
'</b></span>' :
' ');
578 if ($cond_logic_num) {
579 $user_count = $cond_logic_num;
581 $user_count = count($GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id, Array(
'user'), FALSE));
584 echo
'<span style="color:#';
585 if (count($cond_data[
'published_by']) >= $user_count) {
591 echo count($cond_data[
'published_by']).
' of '.$user_count;
605 echo translate(
'none');
614 if ($step_data[
'expired']) {
616 $esc_address = Array();
617 foreach ($step_data[
'escalation_steps'] as $esc_stepid => $esc_step_data) {
618 $esc_step_address = Array($stepid);
619 $esc_step_address[] = $esc_stepid;
621 _paintWorkflowStep($owner, $o, $ei, $workflow, $esc_step_address);
631 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_report'])) {
632 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_report']] = ob_get_contents();
639 $o->
openField(translate(
'workflow_status'));
640 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_report'])) {
644 echo translate(
'workflow_not_running');
647 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_report'])) {
648 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_report']] = ob_get_contents();
658 case 'workflow_metadata_warning' :
661 if ($owner->status & SQ_SC_STATUS_PENDING) {
662 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
663 if ($mm->allowsMetadata($owner->id)) {
664 $m_complete = $mm->requiredFieldsComplete($owner->id);
666 $o->
openField(
'<span class="sq-backend-warning"><b>'.ucfirst(strtolower(translate(
'warning'))).
'</b></span>');
667 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_metadata_warning'])) {
672 <p
class=
"sq-backend-data">
673 <span
class=
"sq-backend-warning">
674 <b><?php echo translate(
'metadata_in_approval_requires_fields_completion', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)); ?></b>
676 <?php echo translate(
'metadata_fields_only_completed_by_administrator', htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET),
'<a href="'.$owner->getBackendHref(
'metadata').
'">'.translate(
'metadata_screen').
'</a>'); ?>
681 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_metadata_warning'])) {
682 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_metadata_warning']] = ob_get_contents();
694 case 'workflow_schemas' :
696 $schemas = $wfm->getAssetSchemaInfo($owner->id);
699 foreach ($schemas as $schemaid => $schema_info) {
700 $granted = $schema_info[
'granted'];
701 if (!isset($direct[$granted])) {
702 $direct[$granted] = Array();
704 $direct[$granted][$schemaid] = $schema_info;
710 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_schemas'])) {
714 if (empty($direct)) {
715 echo translate(
'no_workflow_schemas');
717 foreach ($direct as $granted => $schema_list) {
719 <table
class=
"sq-backend-table">
721 <td
class=
"sq-backend-table-header">
722 <span style=
"color: <?php echo (($granted == '0') ? 'red' : 'green'); ?>"><?php echo (($granted ==
'0') ? translate(
'denied') : translate(
'applied')) ?></span>
724 <td align=
"center" width=
"100" class=
"sq-backend-table-header">
725 <?php echo translate(
'cascade_question'); ?>
728 if ($admin_access && $wfm->isWorkflowComplete($owner->id)) {
729 ?><td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'delete_question'); ?></td><?php
734 foreach ($schema_list as $schemaid => $schema_detail) {
736 $schema_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($schemaid),
'workflow_schema', FALSE);
737 if (empty($schema_info))
continue;
741 <td
class=
"sq-backend-table-cell">
743 echo get_asset_tag_line($schemaid);
746 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
747 <?php
if ($admin_access && $wfm->isWorkflowComplete($owner->id)) {
748 check_box($prefix.
'_workflow[cascades]['.$schemaid.
']', 1, $schema_detail[
'cascades']);
750 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo ($schema_detail['cascades'] ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" /><?php
755 if ($admin_access && $wfm->isWorkflowComplete($owner->id)) {
756 ?><td align=
"center" width=
"100" class=
"sq-backend-table-cell"><?php
757 check_box($prefix.
'_workflow[delete]['.$schemaid.
']');
773 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_schemas'])) {
774 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_schemas']] = ob_get_contents();
779 $o->
sectionNote(
'The "Cascade ?" option determines whether new children of this asset will automatically have the schema cascaded to them. If this setting is changed, existing non-dependant children will NOT be affected. If you want to apply a schema to existing children where they have not been before, please do a Manual Cascade after toggling this setting on.');
786 case 'workflow_add_schemas' :
788 if ($admin_access && empty($running_schemas)) {
791 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_add_schemas'])) {
795 $o->
openField(
'Select Schema',
'new_line');
796 combo_box($prefix.
'_workflow[new][granted]', Array(
'' =>
'',
'1' => translate(
'apply'),
'0' => translate(
'deny')), FALSE,
'');
797 echo
' '.translate(
'workflow_schema').
' ';
798 asset_finder($prefix.
'_workflow[new][schemaid]', 0, Array(
'workflow_schema' =>
'D'),
'sq_sidenav', FALSE,
'null', Array(
'clear'));
801 if (is_null($keywords) || isset($keywords[
'fields'][
'workflow_add_schemas'])) {
802 $print_commit_button = TRUE;
806 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_add_schemas'])) {
807 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_add_schemas']] = ob_get_contents();
813 $o->
openField(translate(
'cascade_question'),
'new_line');
814 check_box($prefix.
'_workflow[new][cascades]', 1, TRUE);
815 ?> Automatically cascade
this schema to
new children<?php
816 $o->
note(
'If unchecked, the schema will be applied or denied only to dependants of this asset, regardless of the Cascade Changes settings below. It will also not apply the workflow to any asset that becomes a new child of this asset (through creating a new asset, or moving an existing one, or creating a new link from one). This setting can be toggled after being applied.');
826 case 'workflow_cascade_options' :
829 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_cascade_options'])) {
833 if ($admin_access && empty($running_schemas)) {
834 $kiddies = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($owner->id);
835 if (count($kiddies)) {
836 echo translate(
'action_affects_assets_below_this', count($kiddies), htmlspecialchars($owner->name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
'<br /><br />';
838 check_box($prefix.
'_workflow[cascade_changes]',
'1', TRUE);
840 label(translate(
'cascade_schema_changes'), $prefix.
'_workflow[cascade_changes]');
842 check_box($prefix.
'_workflow[manual_cascade]');
844 label(translate(
'manually_cascade_schema'), $prefix.
'_workflow[manual_cascade]');
847 echo translate(
'no_children_to_cascade_workflow');
849 }
else if ($admin_access) {
850 echo translate(
'cannot_cascade_while_workflow_running');
852 echo translate(
'no_access_to_cascade_workflow');
856 if (!is_null($keywords) && isset($keywords[
'fields'][
'workflow_cascade_options'])) {
857 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'fields'][
'workflow_cascade_options']] = ob_get_contents();
866 $note = (string) $field->note;
875 if (!is_null($keywords) && isset($keywords[
'sections'][strtolower(str_replace(
' ',
'_', $section->attributes()->name))])) {
876 $ei->_tmp[
'layout_keyword_replacements'][$keywords[
'sections'][strtolower(str_replace(
' ',
'_', $section->attributes()->name))]] = ob_get_contents();
882 return $print_commit_button;
904 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
905 $running_schemas = $wfm->getSchemas($owner->id, TRUE, TRUE);
909 if (isset($_REQUEST[$prefix.
'_workflow_new_log_message'])) {
910 $message_body = trim($_REQUEST[$prefix.
'_workflow_new_log_message']);
914 $require_comment = $wfm->requiresComment($owner->id, $GLOBALS[
'SQ_SYSTEM']->user->id);
917 if (!empty($message_body)) {
918 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
920 'message' => $message_body,
922 $message = $ms->newMessage(Array(),
'asset.workflow.userlog', $msg_reps);
923 $message->parameters[
'assetid'] = $owner->id;
924 $message->parameters[
'version'] = substr($owner->version, 0, strrpos($owner->version,
'.'));
930 if (!empty($running_schemas) && !($require_comment && empty($message_body))) {
931 _processStatusChange($owner, $o, $prefix);
936 if (!$owner->
adminAccess(
'workflow'))
return $updated;
938 if (!isset($_POST[$prefix.
'_workflow'])) {
942 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
945 $cascade_changes = FALSE;
946 if (isset($_POST[$prefix.
'_workflow'][
'cascade_changes']) && $_POST[$prefix.
'_workflow'][
'cascade_changes']) {
947 $cascade_changes = TRUE;
950 $schema_vars = Array();
951 $post_data = $_POST[$prefix.
'_workflow'];
952 $depandants = $GLOBALS[
'SQ_SYSTEM']->am->getDependantChildren($owner->id);
953 $has_dependants = !empty($depandants);
956 if (!empty($post_data[
'new'][
'schemaid'][
'assetid'])) {
957 if (!isset($post_data[
'new'][
'granted']) || $post_data[
'new'][
'granted'] ==
'') {
958 trigger_localised_error(
'SYS0268', E_USER_NOTICE, $post_data[
'new'][
'schemaid'][
'assetid']);
963 if (($cascade_changes && isset($post_data[
'new'][
'cascades'])) || $has_dependants) {
965 $schema_vars[] = Array(
966 'assetids' => Array($owner->id),
967 'granted' => (
int)$post_data[
'new'][
'granted'],
968 'schemaid' => (
int)$post_data[
'new'][
'schemaid'][
'assetid'],
969 'cascades' => (
int)isset($post_data[
'new'][
'cascades']) ? 1 : 0,
970 'previous_access' => NULL,
971 'dependants_only' => !($cascade_changes && isset($post_data[
'new'][
'cascades'])) && $has_dependants,
975 if (!$wfm->setSchema($owner->id, (
int)$post_data[
'new'][
'schemaid'][
'assetid'], (
int)$post_data[
'new'][
'granted'], (isset($post_data[
'new'][
'cascades']) ? 1 : 0))) {
983 if (!empty($post_data[
'delete'])) {
984 foreach ($post_data[
'delete'] as $schemaid => $on) {
985 $schemaid = (int)$schemaid;
986 $schema_info = $wfm->getAssetSchemaInfo($owner->id, $schemaid);
987 if (($cascade_changes && $schema_info[
'cascades']) || $has_dependants) {
988 $current_access = $schema_info[
'granted'];
989 $schema_vars[] = Array(
990 'assetids' => Array($owner->id),
992 'schemaid' => $schemaid,
993 'cascades' => $cascade_changes,
994 'previous_access' => $current_access,
995 'dependants_only' => !($cascade_changes && $schema_info[
'cascades']) && $has_dependants,
998 if (!$wfm->deleteSchema($owner->id, $schemaid)) {
1006 $schemas = $wfm->getAssetSchemaInfo($owner->id);
1007 foreach ($schemas as $schemaid => $schema_info) {
1008 $cascades = isset($post_data[
'cascades'][$schemaid]);
1009 if ((
boolean)$cascades != (
boolean)$schema_info[
'cascades']) {
1010 if ($has_dependants) {
1011 $current_access = $schema_info[
'granted'];
1012 $schema_vars[] = Array(
1013 'assetids' => Array($owner->id),
1014 'granted' => $current_access,
1015 'schemaid' => $schemaid,
1016 'cascades' => $cascades,
1017 'previous_access' => NULL,
1018 'dependants_only' => 1,
1021 if (!$wfm->setSchema($owner->id, (
int)$schemaid, (
int)$schema_info[
'granted'], (
int)$cascades)) {
1028 if (isset($_POST[$prefix.
'_workflow'][
'manual_cascade']) && $_POST[$prefix.
'_workflow'][
'manual_cascade']) {
1029 $schemas = $wfm->getAssetSchemaInfo($owner->id, NULL, TRUE);
1030 foreach ($schemas as $schemaid => $schema_info) {
1031 $schema_vars[] = Array(
1032 'assetids' => Array($owner->id),
1033 'granted' => $schema_info[
'granted'],
1035 'schemaid' => $schemaid,
1036 'previous_access' => NULL,
1042 if (!empty($schema_vars)) {
1043 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
1045 'schema_changes' => $schema_vars,
1047 $hh->queueHipo(
'hipo_job_edit_workflow_schemas', $vars);
1069 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
1070 $step_data =& $wfm->getCurrentStep($workflow, $step_address);
1071 $section_title =
'Step '.implode(
'.',$step_address).
' - '.$step_data[
'step_name'];
1073 if ($step_data[
'expired']) {
1074 $section_title .=
' <span style="color:#FF9900">['.translate(
'escalated').
']</span>';
1076 if ($step_data[
'completed']) {
1077 $section_title .=
' <span style="color:#008800">['.translate(
'completed').
']</span>';
1079 $section_title .=
' <span style="color:#880000">['.translate(
'not_completed').
']</span>';
1084 if ($step_data[
'started']) {
1085 $o->
openField(translate(
'step_duration'));
1086 echo $GLOBALS[
'SQ_SYSTEM']->datetime($step_data[
'started']);
1088 if ($step_data[
'completed']) {
1089 echo $GLOBALS[
'SQ_SYSTEM']->datetime($step_data[
'completed']);
1094 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
1095 if ($step_data[
'completed']) {
1096 echo easy_time_total($step_data[
'completed'] - $step_data[
'started'], TRUE);
1098 echo easy_time_total(time() - $step_data[
'started'], TRUE);
1102 if ($step_data[
'expiry_time'] > 0) {
1103 $o->
openField(translate(
'expiry_time'));
1104 $expiry_time = $step_data[
'started'] + $step_data[
'expiry_time'];
1105 echo $GLOBALS[
'SQ_SYSTEM']->datetime($expiry_time);
1107 echo easy_time_total($expiry_time - time(), TRUE);
1111 $o->
openField(translate(
'automatically_escalate'));
1112 if ($step_data[
'escalate']) {
1113 echo translate(
'yes');
1115 echo translate(
'no');
1123 if (isset($wfm->_valid_cond_logic[$step_data[
'logic']])) {
1125 $step_logic = $step_data[
'logic'];
1126 $step_logic_num =
'';
1128 if ($step_data[
'logic'] !=
'all') {
1129 list($step_logic, $step_logic_num) = explode(
' ', $step_data[
'logic']);
1131 $step_logic =
'all';
1132 $step_logic_num =
'';
1136 echo
'<i>'.$wfm->_valid_step_logic[$step_logic];
1137 if ($step_logic_num) {
1138 echo
" $step_logic_num condition".(($step_logic_num > 1) ?
's' :
'').
' must be met</i>';
1147 <table
class=
"sq-backend-table">
1149 <td
class=
"sq-backend-table-header"> </td>
1150 <td
class=
"sq-backend-table-header" width=
"270"><b><?php echo translate(
'group_logic'); ?></b></td>
1151 <td align=
"center" width=
"100" class=
"sq-backend-table-header"><b><?php echo translate(
'complete_question'); ?></b></td>
1154 foreach ($step_data[
'conditions'] as $pub => $cond_data) {
1155 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($pub);
1156 if (!$asset->id)
continue;
1159 <td
class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($pub); ?></td>
1160 <td
class=
"sq-backend-table-cell">
1162 if (isset($wfm->_valid_cond_logic[$cond_data[
'logic']])) {
1164 $cond_logic = $cond_data[
'logic'];
1165 $cond_logic_num =
'';
1167 if ($cond_data[
'logic'] !=
'all') {
1168 list($cond_logic, $cond_logic_num) = explode(
' ', $cond_data[
'logic']);
1170 $cond_logic =
'all';
1171 $cond_logic_num =
'';
1175 if ($asset instanceof User) {
1178 echo
'<i>'.$wfm->_valid_cond_logic[$cond_logic];
1179 if ($cond_logic_num) {
1180 echo
" $cond_logic_num group member".(($cond_logic_num > 1) ?
's' :
'').
' must approve</i>';
1186 <td align=
"center" class=
"sq-backend-table-cell">
1188 if (isset($cond_data[
'complete']) && $cond_data[
'complete']) {
1189 echo
'<span style="color:#008800"><b>'.translate(
'yes').
'</b></span>';
1192 if ($asset instanceof User) {
1193 echo ((isset($cond_data[
'published_by'][$asset->id])) ?
'<span style="color:#008800"><b>'.translate(
'yes').
'</b></span>' :
' ');
1195 if ($cond_logic_num) {
1196 $user_count = $cond_logic_num;
1198 $user_count = count($GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id, Array(
'user'), FALSE));
1201 echo
'<span style="color:#';
1202 if (count($cond_data[
'published_by']) >= $user_count) {
1208 echo count($cond_data[
'published_by']).
' of '.$user_count;
1222 echo translate(
'none');
1231 if ($step_data[
'expired']) {
1233 foreach ($step_data[
'escalation_steps'] as $esc_stepid => $esc_step) {
1234 $esc_step_address = $step_address;
1235 $esc_step_address[] = $esc_stepid;
1236 _paintWorkflowStep($owner, $o, $ei, $workflow, $esc_step_address);