Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
backend_user.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/users/user/user.inc';
19 
20 
32 class Backend_User extends User
33 {
34 
35 
42  function Backend_User($assetid=0)
43  {
44  $this->User($assetid);
45 
46  }//end constructor
47 
48 
58  function canAccessBackend()
59  {
60  return TRUE;
61 
62  }//end canAccessBackend()
63 
64 
65  /*
66  * Delete backend user asset from the trash
67  *
68  * Note that the asset <i>MUST</i> be in the trash to delete it <i>FROM</i> the trash.
69  *
70  * @param boolean $release_lock should we realease the lock after deleting
71  *
72  * @return boolean
73  * @access public
74  */
75  public function delete($release_lock=TRUE)
76  {
77  $success = FALSE;
78 
79  if (parent::delete($release_lock)) {
80 
81  $sql = 'SELECT lockid FROM '.SQ_TABLE_RUNNING_PREFIX.'lock WHERE userid = \''.$this->id.'\'';
82 
83  try {
84  $query = MatrixDAL::preparePdoQuery($sql);
85  $result = MatrixDAL::executePdoAssoc($query);
86  } catch (Exception $e) {
87  throw new Exception('Unable to get lock info for backend user due to database error: '.$e->getMessage());
88  }
89 
90  $success = TRUE;
91 
92  // Release all the locks held by this backend user
93  foreach($result as $key => $val) {
94  $lockid = $val['lockid'];
95 
96  if (($err_msg = $GLOBALS['SQ_SYSTEM']->releaseLock($lockid)) !== TRUE) {
97  trigger_localised_error('SYS0109', E_USER_NOTICE, $lock_type, $asset->name, $err_msg);
98  $success = FALSE;
99  continue;
100  }
101  }// End foreach
102  }
103 
104  return $success;
105 
106  }
107 
108 }//end class
109 ?>