17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
45 parent::__construct();
63 require_once SQ_INCLUDE_PATH.
'/asset_static_screens/details.inc';
64 _paintDetailsCurrentStatus($asset, $o, $prefix);
90 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
91 $url = $hh->runQueuedJobs();
98 if ((
int)$asset->status === SQ_STATUS_PENDING_APPROVAL) {
100 $o->
note(translate(
'asset_currently_in_workflow', $asset->
getBackendHref(
'workflow')));
102 require_once SQ_INCLUDE_PATH.
'/asset_static_screens/details.inc';
104 $need_commit = _paintDetailsChangeStatus($asset, $o, $prefix);
105 $status_output = ob_get_clean();
108 $found = preg_match(
'/<select.*"'.$prefix.
'_change_status"[^>]*>.*<\/select>/U', $status_output, $select_matches);
110 $filter_output .= $select_matches[0].
' ';
111 $found = preg_match(
'/<input.*"'.$prefix.
'_change_status_all_children"[^>]*><label [^>]*>.*<\/label>/', $status_output, $cb_matches);
113 $filter_output .= $cb_matches[0].
' ';
116 $status_output = $filter_output;
123 if (((
int)$asset->status === SQ_STATUS_UNDER_CONSTRUCTION) && ((array_key_exists(SQ_STATUS_PENDING_APPROVAL, $available_statuses) === TRUE) || (array_key_exists(SQ_STATUS_APPROVED, $available_statuses) === TRUE))) {
126 if (count($streams) > 0) {
128 foreach ($bypass_streams as $bypass_streamid) {
129 $streams[
'bypass'][$bypass_streamid] = $streams[
'workflow'][$bypass_streamid];
130 unset($streams[
'workflow'][$bypass_streamid]);
136 check_box($prefix.
'_change_status_all_children');
137 $cascade_box = ob_get_clean();
143 'workflow' => Array(),
147 $options[
'bypass'] = Array(
'SQ_USE_DEFAULT' =>
'Default Stream');
149 $options[
'workflow'] = Array(
'SQ_USE_DEFAULT' =>
'Default Stream');
153 foreach (array_keys($streams) as $stream_type) {
154 $streams[$stream_type] = array_unique($streams[$stream_type]);
155 foreach ($streams[$stream_type] as $workflow_stream_name) {
156 $options[$stream_type][$workflow_stream_name] = $workflow_stream_name;
161 if ($total_options > 1) {
163 combo_box($prefix.
'_change_status_stream', $options[
'workflow'], FALSE, Array(), 0,
' disabled="disabled" id="'.$prefix.
'_change_status_stream_workflow"');
164 combo_box($prefix.
'_change_status_stream', $options[
'bypass'], FALSE, Array(), 0,
' disabled="disabled" id="'.$prefix.
'_change_status_stream_bypass"');
165 $cb = ob_get_clean();
166 echo translate(
'workflow_stream_using_workflow_stream', $cb);
169 $all_options = $options[
'bypass'] + $options[
'workflow'];
171 hidden_field($prefix.
'_change_status_stream', key($all_options));
174 <script type=
"text/javascript">
176 var status_cb = document.getElementById(
"<?php echo $prefix ?>_change_status");
177 var stream_wf_cb = document.getElementById(
"<?php echo $prefix ?>_change_status_stream_workflow");
178 var stream_byp_cb = document.getElementById(
"<?php echo $prefix ?>_change_status_stream_bypass");
180 if (stream_wf_cb.options.length == 0) {
181 stream_wf_cb.style.display =
'none';
183 stream_byp_cb.style.display =
'none';
186 status_cb.onchange =
function() {
187 if ((this.value & <?php echo SQ_SC_STATUS_PENDING ?>) > 0) {
188 stream_wf_cb.disabled =
false;
189 stream_wf_cb.style.display =
'inline';
190 stream_byp_cb.style.display =
'none';
192 stream_wf_cb.disabled =
true;
195 if ((this.value & <?php echo SQ_SC_STATUS_ALL_APPROVED ?>) > 0) {
196 stream_byp_cb.disabled =
false;
197 stream_byp_cb.style.display =
'inline';
198 stream_wf_cb.style.display =
'none';
200 stream_byp_cb.disabled =
true;
205 $stream_box = ob_get_clean();
206 echo str_replace($cascade_box, $stream_box.$cascade_box, $status_output);
207 if (isset($this->_tmp[
'incomplete_metadata'])) {
208 $new_status = isset($_POST[$prefix.
'_change_status']) ?
' to \''.get_status_description($_POST[$prefix.
'_change_status']).
'\'' :
'';
209 echo
"<p>".translate(
'cannot_change_bundle_status_metadata_incomplete', $new_status);
210 foreach (array_keys($this->_tmp[
'incomplete_metadata']) as $incomplete_meta_assetid) {
211 $assetinfo = get_asset_tag_line($incomplete_meta_assetid,
'metadata');
212 echo
"<br />$assetinfo";
248 if (isset($_POST[$prefix.
'_change_status'])) {
249 $dependants_only = (isset($_POST[$prefix.
'_change_status_all_children']) && $_POST[$prefix.
'_change_status_all_children']) ? FALSE : TRUE;
250 if ($_POST[$prefix.
'_change_status'] > 0 || !$dependants_only) {
252 if ($_POST[$prefix.
'_change_status'] == 0 && !$dependants_only) {
253 $new_status = $asset->status;
254 }
else if ($_POST[$prefix.
'_change_status'] > 0) {
255 $new_status = $_POST[$prefix.
'_change_status'];
259 $this->_checkRequiredMetadataComplete($asset);
261 if (!isset($this->_tmp[
'incomplete_metadata'])) {
262 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
264 'bundle_assetid' => $asset->id,
265 'new_status' => $new_status,
267 if (isset($_POST[$prefix.
'_change_status_stream'])) {
268 if ($_POST[$prefix.
'_change_status_stream'] !==
'SQ_USE_DEFAULT') {
269 $vars[
'workflow_stream'] = $_POST[$prefix.
'_change_status_stream'];
272 $hh->queueHipo(
'hipo_job_edit_bundled_assets_status', $vars);
299 require_once SQ_INCLUDE_PATH.
'/asset_static_screens/details.inc';
301 $need_commit = _paintDetailsFutureStatusCurrent($asset, $o, $prefix);
302 $ok = $ok || $need_commit;
303 $current_fs_contents = ob_get_clean();
306 $need_commit = _paintDetailsFutureStatusNew($asset, $o, $prefix);
307 $ok = $ok || $need_commit;
308 $new_fs_contents = ob_get_clean();
311 if (empty($current_fs_contents) === FALSE) {
312 $o->
openField(translate(
'scheduled_future_status_change'),
'new_line');
313 echo $current_fs_contents;
319 $o->
openField(translate(
'add_new_future_status'),
'new_line');
320 echo $new_fs_contents;
340 require_once SQ_INCLUDE_PATH.
'/asset_static_screens/details.inc';
341 $need_commit = _processDetailsFutureStatusNew($asset, $o, $prefix);
364 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
365 $url = $hh->runQueuedJobs();
372 if ((
int)$asset->status === SQ_STATUS_PENDING_APPROVAL) {
375 text_area($prefix.
'_workflow_new_log_message',
'', 60, 6);
377 $comment_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(); }";
378 $o->
note(translate(
'workflow_must_enter_reason_for_decision_bundle'));
380 $comment_button_js =
'submit_form();';
381 $o->
note(translate(
'workflow_may_enter_reason_for_decision'));
385 $button_js =
'document.getElementById("'.$prefix.
'_workflow_new_status").value = %status%; '.$comment_button_js;
387 hidden_field($prefix.
'_workflow_new_status',
'0');
390 $reject_status = NULL;
391 $approve_status = NULL;
393 foreach ($available_statuses as $new_status => $status_text) {
394 if ((
int)$new_status < (
int)$asset->status) {
395 $reject_status = Array($new_status => $status_text);
397 $approve_status = Array($new_status => $status_text);
402 if ($approve_status !== NULL) {
403 normal_button($prefix.
'_workflow_status_update_approve', current($approve_status), str_replace(
'%status%', (
string)(key($approve_status)), $button_js));
406 if ($reject_status !== NULL) {
407 normal_button($prefix.
'_workflow_status_update_reject', current($reject_status), str_replace(
'%status%', (
string)(key($reject_status)), $button_js));
409 if (isset($this->_tmp[
'incomplete_metadata'])) {
410 $new_status = isset($_POST[$prefix.
'_workflow_new_status']) ?
' to \''.get_status_description($_POST[$prefix.
'_workflow_new_status']).
'\'' :
'';
411 echo
"<p>".translate(
'cannot_change_bundle_status_metadata_incomplete', $new_status);
412 foreach (array_keys($this->_tmp[
'incomplete_metadata']) as $incomplete_meta_assetid) {
413 $assetinfo = get_asset_tag_line($incomplete_meta_assetid,
'metadata');
414 echo
"<br />$assetinfo";
421 $o->
openField(translate(
'workflow_status'));
422 echo translate(
'workflow_bundle_not_current_step');
426 $o->
openField(translate(
'workflow_status'));
427 echo translate(
'workflow_not_running_bundle');
456 if (isset($_POST[$prefix.
'_workflow_new_status'])) {
457 $new_status = (int)$_POST[$prefix.
'_workflow_new_status'];
458 $log_message = array_get_index($_POST, $prefix.
'_workflow_new_log_message',
'');
464 if (!($new_status & SQ_STATUS_UNDER_CONSTRUCTION)) $this->_checkRequiredMetadataComplete($asset);
466 if (!isset($this->_tmp[
'incomplete_metadata'])) {
467 if ($new_status > 0) {
468 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
470 'bundle_assetid' => $asset->id,
471 'new_status' => $new_status,
472 'log_message' => $log_message,
474 $hh->queueHipo(
'hipo_job_edit_bundled_assets_status', $vars);
498 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
499 $current_userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
501 $bundled_asset_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE);
502 foreach ($bundled_asset_links as $linkid => $bundled_asset_link) {
503 $bundled_assetid = $bundled_asset_link[
'minorid'];
504 $approvers = $wfm->whoCanPublish($bundled_assetid);
508 if (in_array($current_userid, $approvers) === TRUE) {
511 $bundled_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bundled_assetid);
512 if ($bundled_asset->adminAccess() === TRUE) {
516 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bundled_asset);
517 unset($bundled_asset);
540 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
541 $current_userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
543 $bundled_asset_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE);
544 foreach ($bundled_asset_links as $linkid => $bundled_asset_link) {
545 $bundled_assetid = $bundled_asset_link[
'minorid'];
549 if ($wfm->requiresComment($bundled_assetid, $current_userid) === TRUE) {
567 private function _checkRequiredMetadataComplete(
Workflow_Bundle $asset)
569 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE);
570 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
571 $not_cool_assets = Array();
573 foreach ($links as $link) {
574 $assetid = $link[
'minorid'];
575 if (!isset($this->_tmp[
'incomplete_metadata'][$assetid]) && !$mm->requiredFieldsComplete($assetid)) {
576 $this->_tmp[
'incomplete_metadata'][$assetid] = TRUE;