17 require_once SQ_INCLUDE_PATH.
'/asset_status/asset_status.inc';
50 $this->status_tag = SQ_STATUS_PENDING_APPROVAL;
64 return translate(
'status_pending_approval');
82 if (!$this->owner->readAccess())
return $statii;
84 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
85 $running_schemas = $wfm->getSchemas($this->owner->id, TRUE, TRUE);
87 if (!empty($running_schemas)) {
88 $userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
91 $publishers = $wfm->whoCanPublish($this->owner->id);
94 $admin_access = $this->owner->adminAccess(
'');
96 if (in_array($userid, $publishers) || $admin_access) {
98 $wf_complete = $wfm->testPublish($this->owner->id, $GLOBALS[
'SQ_SYSTEM']->currentUserId());
101 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
102 if ($mm->allowsMetadata($this->owner->id)) {
103 $m_complete = $mm->requiredFieldsComplete($this->owner->id);
104 $is_dependant = $GLOBALS[
'SQ_SYSTEM']->am->isDependant($this->owner->id);
106 if ($wf_complete && (($m_complete && !$is_dependant) || $is_dependant)) {
107 $statii[SQ_STATUS_APPROVED] = translate(
'status_change_approve');
108 }
else if (in_array($userid, $publishers)) {
109 $statii[SQ_STATUS_PENDING_APPROVAL] = translate(
'status_change_approve_changes');
115 $statii[SQ_STATUS_APPROVED] = translate(
'status_change_approve');
116 $statii[SQ_STATUS_PENDING_APPROVAL] = translate(
'status_change_approve_changes');
120 $statii[SQ_STATUS_UNDER_CONSTRUCTION] = translate(
'status_change_reject_changes');
125 pre_echo(
'FIXME: SOMETHING HAS GONE WRONG HERE');
145 if (!parent::processStatusChange($new_status, $update_parent)) {
149 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
150 $current_userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
152 if ($new_status & SQ_SC_STATUS_CAN_APPROVE) {
154 if (!$wfm->cancelWorkflow($this->owner->id)) {
155 trigger_localised_error(
'SYS0260', E_USER_WARNING);
158 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
161 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
162 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($current_userid);
163 if (!$wfm->silentWorkflowParty($this->owner->id)) {
164 $log = $ms->newMessage();
166 'user_name' => $user->name,
167 'workflow_user' => $user->name,
168 'type_code' => $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->owner->type(),
'name'),
169 'asset_name' => $this->owner->name,
170 'status' => get_status_description($new_status),
171 'workflow_url' => current_url().$this->owner->getBackendHref(
'workflow', FALSE),
173 $log->replacements = $msg_reps;
174 $asset_edt_fns = $this->owner->getEditFns();
175 if (isset($asset_edt_fns->static_screens[
'preview'])) {
176 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'preview', FALSE);
178 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'details', FALSE);
180 $log->type =
'asset.workflow.log.reject';
181 $log->parameters[
'assetid'] = $this->owner->id;
182 $log->parameters[
'version'] = substr($this->owner->version, 0, strrpos($this->owner->version,
'.'));
189 $running_schemas = $wfm->getSchemas($this->owner->id, TRUE, TRUE);
190 if (!empty($running_schemas)) {
196 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
197 $m_complete = !$mm->allowsMetadata($this->owner->id) || $mm->requiredFieldsComplete($this->owner->id) || $GLOBALS[
'SQ_SYSTEM']->am->isDependant($this->owner->id);
199 if ($wfm->isWorkflowComplete($this->owner->id) && $m_complete && ($new_status & SQ_SC_STATUS_ALL_APPROVED)) {
200 if (!$wfm->completeWorkflow($this->owner->id)) {
201 trigger_localised_error(
'SYS0261', E_USER_WARNING);
206 if (!$wfm->recordPublish($this->owner->id, $current_userid)) {
207 trigger_localised_error(
'SYS0077', E_USER_WARNING, $current_userid,$this->owner->name);
213 if ($wfm->isWorkflowComplete($this->owner->id) && $m_complete && ($new_status & SQ_SC_STATUS_ALL_APPROVED)) {
214 if (!$wfm->completeWorkflow($this->owner->id)) {
215 trigger_localised_error(
'SYS0261', E_USER_WARNING);
222 if ($new_status == SQ_STATUS_APPROVED || $new_status == SQ_STATUS_EDITING_APPROVED) {
224 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
225 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($current_userid);
226 if (!$wfm->silentWorkflowParty($this->owner->id)) {
227 $log = $ms->newMessage();
228 $log->subject =
'Workflow Completed';
230 'type_code' => $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->owner->type(),
'name'),
231 'asset_name' => $this->owner->name,
232 'workflow_url' => current_url().$this->owner->getBackendHref(
'workflow', FALSE),
235 $log->replacements = $msg_reps;
236 $asset_edt_fns = $this->owner->getEditFns();
237 if (isset($asset_edt_fns->static_screens[
'preview'])) {
238 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'preview', FALSE);
240 $log->replacements[
'preview_url'] = current_url().$this->owner->getBackendHref(
'details', FALSE);
243 $log->type =
'asset.workflow.log.complete';
244 $log->parameters[
'assetid'] = $this->owner->id;
245 $log->parameters[
'version'] = substr($this->owner->version, 0, strrpos($this->owner->version,
'.'));
246 $ms->enqueueMessage($log);