Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
system_management_folder.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/folder/folder.inc';
18 
31 {
32 
33 
40  function __construct($assetid=0)
41  {
42  parent::__construct($assetid);
43 
44  }//end constructor
45 
46 
58  public function create(Array &$link)
59  {
60  require_once SQ_CORE_PACKAGE_PATH.'/system/system_asset_fns.inc';
61  if (!system_asset_fns_create_pre_check($this)) {
62  return FALSE;
63  }
64 
65  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
66  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
67 
68  if ($linkid = parent::create($link)) {
69  if (!system_asset_fns_create_cleanup($this)) {
70  $linkid = FALSE;
71  }
72  }
73 
74  if ($linkid) {
75  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
76  } else {
77  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
78  }
79 
80  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
81  return $linkid;
82 
83  }//end create()
84 
85 
92  public function canClone()
93  {
94  return FALSE;
95 
96  }//end canClone()
97 
98 
109  public function morph($new_type_code)
110  {
111  trigger_localised_error('CORE0091', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
112  return FALSE;
113 
114  }//end morph()
115 
116 
126  public function setAttrValue($name, $value)
127  {
128  if ($name == 'name') {
129  trigger_localised_error('CORE0111', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
130  return FALSE;
131  }
132 
133  return parent::setAttrValue($name, $value);
134 
135  }//end setAttrValue()
136 
137 
155  public function createLink(Asset $minor, $link_type, $value='', $sort_order=NULL, $dependant='0', $exclusive='0')
156  {
157  if ($GLOBALS['SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_LINK_INTEGRITY)) {
158  trigger_localised_error('CORE0117', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
159  return 0;
160  } else {
161  return parent::createLink($minor, $link_type, $value, $sort_order, $dependant, $exclusive);
162  }
163 
164  }//end createLink()
165 
166 
175  public function deleteLink($linkid)
176  {
177  trigger_localised_error('CORE0118', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
178  return FALSE;
179 
180  }//end deleteLink()
181 
182 
189  public function canDelete()
190  {
191  return FALSE;
192 
193  }//end canDelete()
194 
195 
203  public function _getAllowedLinks()
204  {
205  $allowed_links[SQ_LINK_TYPE_1] = Array();
206 
207  $packages = $GLOBALS['SQ_SYSTEM']->getInstalledPackages();
208  foreach ($packages as $data) {
209  $package = $data['code_name'];
210  if ($package == '__core__') {
211  require_once SQ_CORE_PACKAGE_PATH.'/package_manager_core.inc';
212  $class = 'package_manager_core';
213  } else {
214  require_once SQ_PACKAGES_PATH.'/'.$package.'/package_manager_'.$package.'.inc';
215  $class = 'package_manager_'.$package;
216  }
217 
218  eval('$sys_asset_types = '.$class.'::getSystemAssetTypes();');
219  foreach ($sys_asset_types as $type_code) {
220  $allowed_links[SQ_LINK_TYPE_1][$type_code] = Array('card' => '1', 'exclusive' => TRUE);
221  }//end foreach
222 
223  }//end foreach
224 
225  return $allowed_links;
226 
227  }//end _getAllowedLinks()
228 
229 
242  public function writeAccess($lock_type='', $assetids=Array())
243  {
244  // only root can write to this folder so we add this extra checking
245  // before going up to our parent to check access
246  if (empty($assetids)) {
247  if ($GLOBALS['SQ_SYSTEM']->userRoot()) {
248  return parent::writeAccess($lock_type, $assetids);
249  }
250  } else {
251  $root_user = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user');
252  if (in_array($root_user->id, $assetids)) {
253  return parent::writeAccess($lock_type, $assetids);
254  }
255  }
256  return FALSE;
257 
258  }//end writeAccess()
259 
260 
261 }//end class
262 ?>