/** * Deletes all user views from that user and for that user (called on user delete). Temporary function !! * * @param int $userId * @return boolean true if ok, false with warning on sql error */ function _cbdeleteUserViews($userId) { $views = new UserViewTable(); return $views->deleteUserViews($userId); }
/** * Deletes this record (no checks) * * @param int $oid Key id of row to delete (otherwise it's the one of $this) * @param bool $cbUserOnly True: delete CB user only, False: delete CB and CMS user * @return boolean */ public function delete($oid = null, $cbUserOnly = false) { global $_CB_framework, $_PLUGINS; $k = $this->_tbl_key; if ($oid) { $this->{$k} = (int) $oid; } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeDeleteUser', array($this)); if ($_PLUGINS->is_errors()) { $this->setError($_PLUGINS->getErrorMSG()); return false; } else { deleteAvatar($this->avatar); $reports = new UserReportTable(); $reports->deleteUserReports($this->id); $views = new UserViewTable(); $views->deleteUserViews($this->id); if (!$cbUserOnly) { $cmsUser = $_CB_framework->_getCmsUserObject($this->id); try { $cmsUser->delete($this->id); } catch (\RuntimeException $e) { $this->setError($e->getMessage()); return false; } } if (!parent::delete($oid)) { return false; } $query = 'DELETE' . "\n FROM " . $this->_db->NameQuote('#__session') . "\n WHERE " . $this->_db->NameQuote('userid') . " = " . (int) $this->id; $this->_db->setQuery($query); $this->_db->query(); $_PLUGINS->trigger('onAfterDeleteUser', array($this, true)); } return true; }