Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
designs_folder.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/folder/folder.inc';
19 
31 class Designs_Folder extends Folder
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
59  public function create(Array &$link)
60  {
61  require_once SQ_CORE_PACKAGE_PATH.'/system/system_asset_fns.inc';
62  if (!system_asset_fns_create_pre_check($this)) {
63  return FALSE;
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 
154  public function createLink(Asset $minor, $link_type, $value='', $sort_order=NULL, $dependant='0', $exclusive='0')
155  {
156  if ($GLOBALS['SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_LINK_INTEGRITY)) {
157  trigger_localised_error('CORE0117', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
158  return 0;
159 
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  return Array(SQ_LINK_TYPE_1 => Array('design' => Array('card' => 'M', 'exclusive' => TRUE)));
206 
207  }//end _getAllowedLinks()
208 
209 
222  public function writeAccess($lock_type='', Array $assetids=Array())
223  {
224  // only root can write to this folder so we add this extra checking
225  // before going up to our parent to check access
226  if (empty($assetids)) {
227  if ($GLOBALS['SQ_SYSTEM']->userRoot()) {
228  return parent::writeAccess($lock_type, $assetids);
229  }
230  } else {
231  $root_user = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user');
232  if (in_array($root_user->id, $assetids)) {
233  return parent::writeAccess($lock_type, $assetids);
234  }
235  }
236  return FALSE;
237 
238  }//end writeAccess()
239 
240 
241 }//end class
242 
243 ?>