17 require_once SQ_INCLUDE_PATH.
'/asset_status/asset_status.inc';
51 assert_is_a($owner,
'Workflow_Bundle');
53 $this->status_tag = SQ_STATUS_UNDER_CONSTRUCTION;
67 return translate(
'core_workflow_bundle_editing');
81 $available_statuses = Array();
84 if (!$this->owner->writeAccess(
'')) {
85 return $available_statuses;
99 $has_workflow = FALSE;
100 $needs_workflow = FALSE;
101 $can_complete = FALSE;
105 $wfm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
106 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
108 $our_asset_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->owner->id, SQ_LINK_NOTICE);
110 foreach ($our_asset_links as $our_asset_link) {
116 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($our_asset_link[
'minorid']);
118 if ($has_workflow === FALSE) {
119 $status = (int)$asset_info[$our_asset_link[
'minorid']][
'status'];
120 if ($status === SQ_STATUS_EDITING) {
121 $has_workflow = TRUE;
123 $schemas = $wfm->getSchemas($our_asset_link[
'minorid'], TRUE);
124 if (count($schemas) > 0) {
125 $has_workflow = TRUE;
131 if ($m_complete === TRUE) {
132 if ($mm->allowsMetadata($this->owner->id) && !$GLOBALS[
'SQ_SYSTEM']->am->isDependant($this->owner->id)) {
133 $m_complete = $mm->requiredFieldsComplete($this->owner->id);
138 if (($has_workflow === TRUE) && ($m_complete === FALSE)) {
144 if ($has_workflow === TRUE) {
145 if ($m_complete === FALSE) {
146 $available_statuses[SQ_STATUS_PENDING_APPROVAL] = translate(
'status_change_apply_for_approval');
148 $all_streams = $this->owner->getAllBundleStreams();
149 $bypassable_streams = $this->owner->getAllBypassableBundleStreams();
150 $default_bypassable = $this->owner->isDefaultStreamBypassable();
152 $needs_approve = FALSE;
153 $needs_apply = FALSE;
155 if ($default_bypassable === TRUE) {
157 $needs_approve = TRUE;
158 }
else if (count($bypassable_streams) > 0) {
160 $needs_approve = TRUE;
163 if (($default_bypassable === FALSE) || (count($bypassable_streams) < count($all_streams))) {
169 if ($needs_apply === TRUE) {
170 $available_statuses[SQ_STATUS_PENDING_APPROVAL] = translate(
'status_change_apply_for_approval');
174 if ($needs_approve === TRUE) {
175 $available_statuses[SQ_STATUS_APPROVED] = translate(
'status_change_approve');
179 $available_statuses[SQ_STATUS_LIVE] = translate(
'status_change_approve_and_make_live');
182 return $available_statuses;