17 require_once SQ_INCLUDE_PATH.
'/asset_status/asset_status.inc';
50 $this->status_tag = SQ_STATUS_LIVE_APPROVAL;
64 return translate(
'status_live_approval');
81 if (!$this->owner->readAccess())
return $statii;
83 if ($this->owner->adminAccess(
'')) {
84 $statii[SQ_STATUS_EDITING] = translate(
'status_change_safe_edit');
87 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
88 $running_schemas = $wfm->getSchemas($this->owner->id,
true,
true);
90 if (!empty($running_schemas)) {
91 $userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
94 $publishers = $wfm->whoCanPublish($this->owner->id);
97 $admin_access = $this->owner->adminAccess(
'');
99 if (in_array($userid, $publishers) || $admin_access) {
101 $wf_complete = $wfm->testPublish($this->owner->id, $GLOBALS[
'SQ_SYSTEM']->currentUserId());
104 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
105 $is_dependant = $GLOBALS[
'SQ_SYSTEM']->am->isDependant($this->owner->id);
107 if ($mm->allowsMetadata($this->owner->id)) {
108 $m_complete = $mm->requiredFieldsComplete($this->owner->id);
109 if ($wf_complete && ((!$is_dependant && $m_complete) || $is_dependant)) {
110 $statii[SQ_STATUS_LIVE] = translate(
'status_change_approve_and_make_live');
111 }
else if (in_array($userid, $publishers)) {
112 $statii[SQ_STATUS_LIVE_APPROVAL] = translate(
'status_change_approve_review');
117 $statii[SQ_STATUS_LIVE] = translate(
'status_change_approve_and_make_live');
118 $statii[SQ_STATUS_LIVE_APPROVAL] = translate(
'status_change_approve_review');
121 $statii[SQ_STATUS_EDITING] = translate(
'status_change_safe_edit');
126 $statii[SQ_STATUS_LIVE] = translate(
'status_change_approve_and_make_live');
127 if ($this->owner->adminAccess(
'')) {
128 $statii[SQ_STATUS_ARCHIVED] = translate(
'status_change_archive');
150 if (!parent::processStatusChange($new_status, $update_parent)) {
154 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
155 $current_userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
157 if ($new_status == SQ_STATUS_EDITING) {
159 $running_schemas = $wfm->getSchemas($this->owner->id,
true,
true);
160 if (!empty($running_schemas)) {
162 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($GLOBALS[
'SQ_SYSTEM']->currentUserId());
164 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
165 $msg = $ms->newMessage();
167 'workflow_user' => $user->name,
168 'type_code' => $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->owner->type(),
'name'),
169 'asset_name' => $this->owner->name,
170 'assetid' => $this->owner->id,
171 'status' => get_status_description($new_status),
172 'workflow_url' => current_url().$this->owner->getBackendHref(
'workflow', FALSE),
174 $msg->replacements = $msg_reps;
175 $msg->type =
'asset.workflow.review.cancel';
176 $asset_edt_fns = $this->owner->getEditFns();
177 if (isset($asset_edt_fns->static_screens[
'preview'])) {
178 $msg->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'preview', FALSE);
180 $msg->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'details', FALSE);
183 if (!$wfm->cancelWorkflow($this->owner->id, $msg)) {
184 trigger_localised_error(
'SYS0260', E_USER_WARNING);
190 if (!$this->owner->saveSystemVersion()) {
191 trigger_localised_error(
'SYS0208', E_USER_WARNING);
195 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
198 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
199 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($current_userid);
201 if (!$wfm->silentWorkflowParty($this->owner->id)) {
202 $log = $ms->newMessage();
204 'workflow_user' => $user->name,
205 'type_code' => $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->owner->type(),
'name'),
206 'asset_name' => $this->owner->name,
207 'status' => get_status_description($new_status),
208 'workflow_url' => current_url().$this->owner->getBackendHref(
'workflow', FALSE),
210 $log->replacements = $msg_reps;
211 $asset_edt_fns = $this->owner->getEditFns();
212 if (isset($asset_edt_fns->static_screens[
'preview'])) {
213 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'preview', FALSE);
215 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'details', FALSE);
218 $log->type =
'asset.workflow.log.review.cancel';
219 $log->parameters[
'assetid'] = $this->owner->id;
220 $log->parameters[
'version'] = substr($this->owner->version, 0, strrpos($this->owner->version,
'.'));
226 $running_schemas = $wfm->getSchemas($this->owner->id,
true,
true);
227 if (!empty($running_schemas)) {
233 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
234 $m_complete = !$mm->allowsMetadata($this->owner->id) || $mm->requiredFieldsComplete($this->owner->id) || $GLOBALS[
'SQ_SYSTEM']->am->isDependant($this->owner->id);
236 if ($wfm->isWorkflowComplete($this->owner->id) && $m_complete && ($new_status & SQ_STATUS_LIVE)) {
237 if (!$wfm->completeWorkflow($this->owner->id)) {
238 trigger_localised_error(
'SYS0261', E_USER_WARNING);
243 if (!$wfm->recordPublish($this->owner->id, $current_userid)) {
244 trigger_localised_error(
'SYS0077', E_USER_WARNING, $current_userid, $this->owner->name);
250 if ($wfm->isWorkflowComplete($this->owner->id) && $m_complete && ($new_status & SQ_STATUS_LIVE)) {
251 if (!$wfm->completeWorkflow($this->owner->id)) {
252 trigger_localised_error(
'SYS0261', E_USER_WARNING);
258 if ($new_status == SQ_STATUS_LIVE) {
260 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
261 if (!$wfm->notifyOnLive($this->owner->id, $this->status_tag)) {
266 if (!$this->owner->setDate(
'published', time())) {
271 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
272 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($current_userid);
274 if (!$wfm->silentWorkflowParty($this->owner->id)) {
275 $log = $ms->newMessage();
277 'user_name' => $user->name,
278 'workflow_user' => $user->name,
279 'type_code' => $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->owner->type(),
'name'),
280 'asset_name' => $this->owner->name,
281 'status' => get_status_description($new_status),
282 'workflow_url' => current_url().$this->owner->getBackendHref(
'workflow', FALSE),
284 $log->replacements = $msg_reps;
286 $log->type =
'asset.workflow.log.review.complete';
287 $asset_edt_fns = $this->owner->getEditFns();
288 if (isset($asset_edt_fns->static_screens[
'preview'])) {
289 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'preview', FALSE);
291 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'details', FALSE);
294 $log->parameters[
'assetid'] = $this->owner->id;
295 $log->parameters[
'version'] = substr($this->owner->version, 0, strrpos($this->owner->version,
'.'));
296 $ms->enqueueMessage($log);