18 require_once SQ_CORE_PACKAGE_PATH.
'/folder/folder_edit_fns.inc';
41 parent::__construct();
42 unset($this->static_screens[
'workflow']);
43 unset($this->static_screens[
'metadataSchemas']);
44 unset($this->static_screens[
'metadata']);
62 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
63 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
66 $step_logic = $asset->
attr(
'logic');
67 $step_logic_num = $asset->
attr(
'logic_num');
68 if (!$step_logic_num) $step_logic_num =
'';
71 echo
'<i>'.$wfm->_valid_step_logic[$step_logic];
72 if ($step_logic_num) {
73 echo
' '.$step_logic_num.
' condition'.(($step_logic_num > 1) ?
's' :
'').
' must be met</i>';
76 combo_box($prefix.
'_logic', $wfm->_valid_step_logic, FALSE, $step_logic);
78 text_box($prefix.
'_logic_num', $step_logic_num, 4);
79 echo
' '.translate(
'conditions_must_be_met_in_this_step');
83 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'workflow_step_condition', TRUE,
'major', NULL, TRUE, TRUE);
84 if (!empty($current_links)) {
87 <table
class=
"sq-backend-table">
89 <td
class=
"sq-backend-table-header"> </td>
90 <td
class=
"sq-backend-table-header"><?php echo translate(
'notify_when_live'); ?></td>
91 <td
class=
"sq-backend-table-header"><?php echo translate(
'require_comment'); ?></td>
92 <td
class=
"sq-backend-table-header" width=
"270"><?php echo translate(
'group_logic'); ?></td>
95 ?><td align=
"center" width=
"70" class=
"sq-backend-table-header"><b><?php echo translate(
'delete_question'); ?></b></td><?php
100 foreach ($current_links as $link_data) {
101 $condition = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
102 if (is_null($condition))
continue;
103 $edit_fns = $condition->getEditFns();
105 if (!$edit_fns->paintStepCondition($condition, $o)) {
109 ?><td align=
"center" class=
"sq-backend-table-cell"><?php
110 check_box($prefix.
'_delete_conditions['.$link_data[
'linkid'].
']')
119 $o->
openField(translate(
'require_comment_from_unlisted_users'));
120 $require_comment_attr = $asset->
getAttribute(
'require_comment_from_unlisted_users');
121 $xml = simplexml_load_string(
'<boolean true_text="yes" false_text="no" />');
122 $require_comment_attr->setEditParams($xml);
123 $require_comment_attr->paint($prefix.
'_require_comment_from_unlisted_users', !$write_access);
124 $o->
note(translate(
'require_comment_from_unlisted_users_explanation'));
128 $o->
openField(translate(
'new_condition_question'));
129 asset_finder($prefix.
'_new_condition', 0, Array(
'user' =>
'D',
'user_group' =>
'D'),
'sq_sidenav', FALSE,
'null', Array(
'clear'));
134 $comparator_attr->paint($prefix.
'_expiry_time', !$write_access);
135 $o->
note(translate(
'step_not_completed_in_time_explanation'));
139 $xml = simplexml_load_string(
'<boolean true_text="yes" false_text="no" />');
140 $comparator_attr->setEditParams($xml);
141 $comparator_attr->paint($prefix.
'_escalate', !$write_access);
142 $o->
note(translate(
'escalate_note'));
143 if ($asset->
attr(
'escalate') == TRUE) {
146 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'workflow_step', TRUE,
'major', NULL, TRUE, FALSE);
147 if (!empty($current_links)) {
150 foreach ($current_links as $link) {
151 $assetids[$link[
'minorid']] =
'details';
153 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($assetids));
154 $asset_href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($assetids);
158 <table
class=
"sq-backend-table">
160 <td
class=
"sq-backend-table-header"><b><?php echo translate(
'step_name'); ?></b></td>
161 <td width=
"150" class=
"sq-backend-table-header"><b><?php echo translate(
'edit_step'); ?></b></td>
164 ?><td align=
"center" width=
"70" class=
"sq-backend-table-header"><b><?php echo translate(
'delete_question'); ?></b></td><?php
169 foreach ($current_links as $link_data) {
170 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
171 if (is_null($field))
continue;
174 <td align=
"left" class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($field->id);?></td>
175 <td align=
"left" class=
"sq-backend-table-cell">[ <a href=
"<?php echo $asset_href[$field->id];?>"><?php echo translate(
'edit_step'); ?></a> ]</td>
178 ?><td align=
"center" class=
"sq-backend-table-cell"><?php
179 check_box($prefix.
'_delete_steps['.$link_data[
'linkid'].
']')
189 $o->
openField(
'Create New Escalation Step');
190 text_box($prefix.
'_new_escalation_step',
'', 20);
197 return $write_access;
221 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
222 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
227 if (isset($_POST[$prefix.
'_logic'])) {
228 $step_logic = trim($_POST[$prefix.
'_logic']);
230 if (isset($_POST[$prefix.
'_logic_num']) && $step_logic !=
'all') {
232 if (is_numeric(trim($_POST[$prefix.
'_logic_num']))) {
233 $step_logic_num = (int) trim($_POST[$prefix.
'_logic_num']);
237 if ($step_logic_num <= 0) $step_logic_num = 1;
240 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
241 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
244 if (!$asset->
setAttrValue(
'logic_num', $step_logic_num)) {
245 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
246 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
251 $require_comment_attr = $asset->
getAttribute(
'require_comment_from_unlisted_users');
252 $require_comment_attr->process($prefix.
'_require_comment_from_unlisted_users');
253 if ($require_comment_attr->processed) {
254 $asset->
setAttrValue(
'require_comment_from_unlisted_users', $require_comment_attr->value);
259 $expiry_time_attr = $asset->
getAttribute(
'expiry_time');
260 $expiry_time_attr->process($prefix.
'_expiry_time');
261 if ($expiry_time_attr->processed) {
262 $asset->
setAttrValue(
'expiry_time', $expiry_time_attr->value);
268 $escalate_attr->process($prefix.
'_escalate');
269 if ($escalate_attr->processed) {
270 $asset->
setAttrValue(
'escalate', $escalate_attr->value);
275 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
276 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
281 if (isset($_POST[$prefix.
'_delete_steps'])) {
282 $delete_steps = $_POST[$prefix.
'_delete_steps'];
283 foreach ($delete_steps as $linkid => $on) {
284 if ($asset->
deleteLink($linkid)) $updated = TRUE;
288 if (isset($_POST[$prefix.
'_new_escalation_step']) && trim($_POST[$prefix.
'_new_escalation_step'])) {
289 $new_step_name = trim($_POST[$prefix.
'_new_escalation_step']);
290 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'workflow_step');
292 $schema_link = Array(
'asset' => &$asset,
'link_type' => SQ_LINK_TYPE_2,
'sort_order' => -1,
'is_dependant' => 1);
293 $new_step->setAttrValue(
'name', $new_step_name);
295 if ($new_step->create($schema_link)) $updated = TRUE;
299 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'workflow_step_condition', TRUE,
'major', NULL, TRUE, TRUE);
300 if (!empty($current_links)) {
301 foreach ($current_links as $link_data) {
302 $condition = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
303 if (is_null($condition))
continue;
304 $edit_fns = $condition->getEditFns();
305 if ($edit_fns->processStepCondition($condition, $o)) {
312 if (isset($_POST[$prefix.
'_delete_conditions'])) {
313 $delete_conds = $_POST[$prefix.
'_delete_conditions'];
314 foreach ($delete_conds as $linkid => $on) {
315 if ($asset->
deleteLink($linkid)) $updated = TRUE;
320 if (isset($_POST[$prefix.
'_new_condition'][
'assetid']) && $_POST[$prefix.
'_new_condition'][
'assetid'] > 0) {
321 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'workflow_step_condition');
323 $step_link = Array(
'asset' => &$asset,
'link_type' => SQ_LINK_TYPE_2,
'sort_order' => -1,
'is_dependant' => 1,
'is_exclusive' => 1);
324 $new_cond->setAttrValue(
'userid', $_POST[$prefix.
'_new_condition'][
'assetid']);
325 if ($new_cond->create($step_link)) $updated = TRUE;
328 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
329 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
350 $workflow_array = Array();
351 $workflow_array[
'conditions'] = Array();
352 $workflow_array[
'escalation_steps'] = Array();
353 $workflow_array[
'step_name'] = $asset->name;
354 $workflow_array[
'started'] = 0;
355 $workflow_array[
'expiry_time'] = $asset->
attr(
'expiry_time');
356 $workflow_array[
'escalate'] = $asset->
attr(
'escalate');
357 $workflow_array[
'completed'] = 0;
358 $workflow_array[
'expired'] = 0;
359 $workflow_array[
'require_comment_from_unlisted_users'] = $asset->
attr(
'require_comment_from_unlisted_users');
361 $workflow_array[
'message_invitation'] = $asset->
attr(
'message_invitation');
362 $workflow_array[
'message_review_invitation'] = $asset->
attr(
'message_review_invitation');
363 $workflow_array[
'message_approve'] = $asset->
attr(
'message_approve');
364 $workflow_array[
'message_reject'] = $asset->
attr(
'message_reject');
365 $workflow_array[
'message_review_cancel'] = $asset->
attr(
'message_review_cancel');
366 $workflow_array[
'message_stale'] = $asset->
attr(
'message_stale');
367 $workflow_array[
'message_escalated'] = $asset->
attr(
'message_escalated');
369 $workflow_array[
'subject_invitation'] = $asset->
attr(
'subject_invitation');
370 $workflow_array[
'subject_review_invitation'] = $asset->
attr(
'subject_review_invitation');
371 $workflow_array[
'subject_approve'] = $asset->
attr(
'subject_approve');
372 $workflow_array[
'subject_reject'] = $asset->
attr(
'subject_reject');
373 $workflow_array[
'subject_review_cancel'] = $asset->
attr(
'subject_review_cancel');
374 $workflow_array[
'subject_stale'] = $asset->
attr(
'subject_stale');
375 $workflow_array[
'subject_escalated'] = $asset->
attr(
'subject_escalated');
378 $logic = $asset->
attr(
'logic');
379 $logic_num = $asset->
attr(
'logic_num');
380 $logic = $logic.(($logic_num) ?
" $logic_num" :
'');
381 $workflow_array[
'logic'] = $logic;
383 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'workflow_step_condition', TRUE,
'major', NULL, TRUE, TRUE);
384 foreach ($current_links as $link_data) {
385 $condition = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
386 if (is_null($condition))
continue;
387 $edit_fns = $condition->getEditFns();
388 if (!$edit_fns->generateWorkflowArray($condition, $workflow_array[
'conditions'])) {
395 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'workflow_step', TRUE,
'major', NULL, TRUE, FALSE);
397 foreach ($current_links as $link_data) {
398 $step = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
399 if (is_null($step))
continue;
400 $workflow_array[
'escalation_steps'][$i] = Array();
401 $edit_fns = $step->getEditFns();
402 if (!$edit_fns->generateWorkflowArray($step, $workflow_array[
'escalation_steps'][$i])) {