Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trash_folder.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/folder/folder.inc';
19 
31 class Trash_Folder extends Folder
32 {
33 
34 
41  function Trash_Folder($assetid=0)
42  {
43  $this->Folder($assetid);
44 
45  }//end constructor
46 
47 
59  function create(&$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 
96  function _createAdditional(&$link)
97  {
98  if (!parent::_createAdditional($link)) return FALSE;
99 
100  // set public read access in the DB so it comes up in the asset map
101  // but we have to do this the hard way, because the system assets list won't
102  // have been saved yet
103  $public_userids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('public_user');
104  return $GLOBALS['SQ_SYSTEM']->am->setPermission($this->id, $public_userids[0], SQ_PERMISSION_READ, TRUE);
105 
106  }//end _createAdditional()
107 
108 
118  function paintBackend(&$o)
119  {
120  $prefix = $this->getPrefix($this);
121  if (isset($_REQUEST[$prefix.'_purge_complete']) && (int)$_REQUEST[$prefix.'_purge_complete'] === 1) {
122  $o->addOnLoad(' if (parent.frames["sq_sidenav"] && parent.frames["sq_sidenav"].reload_asset) {
123  parent.frames["sq_sidenav"].reload_asset("'.$this->id.'");
124  }');
125  }
126 
127  parent::paintBackend($o);
128 
129  }//end paintBackend()
130 
131 
138  function canClone()
139  {
140  return FALSE;
141 
142  }//end canClone()
143 
144 
155  function morph($new_type_code)
156  {
157  trigger_localised_error('CORE0091', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
158  return FALSE;
159 
160  }//end morph()
161 
162 
172  function setAttrValue($name, $value)
173  {
174  if ($name == 'name') {
175  trigger_localised_error('CORE0111', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
176  return FALSE;
177  }
178 
179  return parent::setAttrValue($name, $value);
180 
181  }//end setAttrValue()
182 
183 
195  function moveLinkPos($linkid, $sort_order=-1)
196  {
197  trigger_localised_error('CORE0019', E_USER_WARNING, $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name'));
198  return FALSE;
199 
200  }//end moveLinkPos()
201 
202 
213  function canCreateLink(&$minor, $link_type, $exclusive)
214  {
215  if (!$this->id) return FALSE;
216  if (!($minor instanceof Asset)) {
217  return translate('minor_not_asset');
218  }
219  return TRUE;
220 
221  }//end canCreateLink()
222 
223 
233  function readAccess($assetids=Array())
234  {
235  return TRUE;
236 
237  }//end readAccess()
238 
239 
252  function writeAccess($lock_type='', $assetids=Array())
253  {
254  return TRUE;
255 
256  }//end writeAccess()
257 
258 
265  function purgeAccess()
266  {
267  if ($GLOBALS['SQ_SYSTEM']->userRoot()) return TRUE;
268  if ($GLOBALS['SQ_SYSTEM']->userSystemAdmin()) {
269  return TRUE;
270  }
271  return FALSE;
272 
273  }//end purgeAccess()
274 
275 
276 }//end class
277 
278 ?>