From f83a4a963035f92ea9f8c4378ae24dd5f0f3b846 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Wed, 2 Apr 2014 13:17:14 +0000 Subject: [PATCH] Use orm to autoload related records --- include/class.user.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/include/class.user.php b/include/class.user.php index e5dbfd361..98d420157 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -74,11 +74,6 @@ class UserModel extends VerySimpleModel { ) ); - var $emails; - var $tickets; - var $account; - - static function objects() { $qs = parent::objects(); #$qs->select_related('default_email'); @@ -255,12 +250,7 @@ class User extends UserModel { } function getAccount() { - // XXX: return $this->account; - - if (!isset($this->_account)) - $this->_account = UserAccount::lookup(array('user_id'=>$this->getId())); - - return $this->_account; + return $this->account; } function getAccountStatus() { @@ -356,9 +346,9 @@ class User extends UserModel { } function delete() { - // TODO: Refuse to delete user with tickets - // Re-enable it once orm support resetting intrumented list - if (0 && $this->tickets->count()) + + // Refuse to delete a user with tickets + if ($this->tickets->count()) return false; // Delete account record (if any) -- GitLab