From 820c929ab38273c80d0930e2e6140dd7676ba4df Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 26 Mar 2016 14:43:41 -0400 Subject: Added avatar image upload --- app/Model/User.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'app/Model/User.php') diff --git a/app/Model/User.php b/app/Model/User.php index 0e11422b..b093d55f 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -283,12 +283,7 @@ class User extends Base { $this->prepare($values); $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values); - - // If the user is connected refresh his session - if ($this->userSession->getId() == $values['id']) { - $this->userSession->initialize($this->getById($this->userSession->getId())); - } - + $this->userSession->refresh($values['id']); return $result; } @@ -327,6 +322,9 @@ class User extends Base { return $this->db->transaction(function (Database $db) use ($user_id) { + // Remove Avatar + $this->avatarFile->remove($user_id); + // All assigned tasks are now unassigned (no foreign key) if (! $db->table(Task::TABLE)->eq('owner_id', $user_id)->update(array('owner_id' => 0))) { return false; -- cgit v1.2.3 From 8cae5d8da1d7d45d30c95c12203e2b0df7400e77 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 26 Mar 2016 21:08:16 -0400 Subject: Fix PHP 5.3 issue --- app/Model/User.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app/Model/User.php') diff --git a/app/Model/User.php b/app/Model/User.php index b093d55f..57993002 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -320,10 +320,9 @@ class User extends Base */ public function remove($user_id) { - return $this->db->transaction(function (Database $db) use ($user_id) { + $this->avatarFile->remove($user_id); - // Remove Avatar - $this->avatarFile->remove($user_id); + return $this->db->transaction(function (Database $db) use ($user_id) { // All assigned tasks are now unassigned (no foreign key) if (! $db->table(Task::TABLE)->eq('owner_id', $user_id)->update(array('owner_id' => 0))) { -- cgit v1.2.3