Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
asset_status_bundle_approved.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_status/asset_status.inc';
18 
39 {
40 
41 
48  {
49  assert_is_a($owner, 'Workflow_Bundle');
50  $this->Asset_Status($owner);
51  $this->status_tag = SQ_STATUS_APPROVED;
52 
53  }//end constructor
54 
55 
63  public static function getDescription()
64  {
65  return translate('core_workflow_bundle_approved');
66 
67  }//end getDescription()
68 
69 
77  function getAvailableStatii()
78  {
79  $available_statuses = Array();
80 
81  // cant do anything without admin access to at least one bundled asset
82  if ($this->_bundledAssetAdminAccess() === TRUE) {
83  $available_statuses[SQ_STATUS_UNDER_CONSTRUCTION] = translate('status_change_reject_changes');
84  $available_statuses[SQ_STATUS_LIVE] = translate('status_change_make_live');
85  }
86 
87  return $available_statuses;
88 
89  }//end getAvailableStatii()
90 
91 
102  function processStatusChange($new_status, $update_parent=TRUE)
103  {
104  if (!parent::processStatusChange($new_status, $update_parent)) {
105  return FALSE;
106  }
107 
108  if ($new_status == SQ_STATUS_LIVE) {
109  // notify people that the asset has gone live
110  $wfm = $GLOBALS['SQ_SYSTEM']->getWorkflowManager();
111  if (!$wfm->notifyOnLive($this->owner->id, $this->status_tag)) {
112  return FALSE;
113  }
114 
115  // update the last published date
116  if (!$this->owner->setDate('published', time())) {
117  return FALSE;
118  }
119  }
120 
121  return TRUE;
122 
123  }//end processStatusChange()
124 
125 
133  protected function _bundledAssetAdminAccess()
134  {
135  if (array_key_exists('bundled_asset_admin', $this->_tmp) === FALSE) {
136  $this->_tmp['bundled_asset_links'] = FALSE;
137  $bundled_asset_links = $GLOBALS['SQ_SYSTEM']->am->getLinks($this->owner->id, SQ_LINK_NOTICE);
138 
139  foreach ($bundled_asset_links as $linkid => $bundled_asset_link) {
140  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($bundled_asset_link['minorid']);
141  if ($asset->adminAccess() === TRUE) {
142  $this->_tmp['bundled_asset_links'] = TRUE;
143  break;
144  } else {
145  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
146  unset($asset);
147  }
148  }
149  }//end if already cached
150 
151  return $this->_tmp['bundled_asset_links'];
152 
153  }//end _bundledAssetAdminAccess()
154 
155 
156 }//end class
157 
158 ?>