Updating modules/backend/models

This commit is contained in:
Stefan Talen 2014-10-11 00:04:51 +02:00
parent 6ccf49bdd9
commit 07a0a7e428
4 changed files with 16 additions and 12 deletions

View File

@ -37,5 +37,4 @@ class AccessLog extends Model
return $record; return $record;
} }
} }

View File

@ -66,8 +66,9 @@ class User extends UserBase
// return parent::getPersistCode(); // return parent::getPersistCode();
// Option B: // Option B:
if (!$this->persist_code) if (!$this->persist_code) {
return parent::getPersistCode(); return parent::getPersistCode();
}
return $this->persist_code; return $this->persist_code;
} }
@ -77,18 +78,23 @@ class User extends UserBase
*/ */
public function getAvatarThumb($size = 25, $default = null) public function getAvatarThumb($size = 25, $default = null)
{ {
if ($this->avatar) if ($this->avatar) {
return $this->avatar->getThumb($size, $size); return $this->avatar->getThumb($size, $size);
else } else {
return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?s='.$size.'&d='.urlencode($default); return '//www.gravatar.com/avatar/'.
md5(strtolower(trim($this->email))) .
'?s='. $size .
'&d='. urlencode($default);
}
} }
public function afterCreate() public function afterCreate()
{ {
$this->restorePurgedValues(); $this->restorePurgedValues();
if ($this->send_invite) if ($this->send_invite) {
$this->sendInvitation(); $this->sendInvitation();
}
} }
public function sendInvitation() public function sendInvitation()
@ -100,10 +106,8 @@ class User extends UserBase
'link' => Backend::url('backend'), 'link' => Backend::url('backend'),
]; ];
Mail::send('backend::mail.invite', $data, function($message) Mail::send('backend::mail.invite', $data, function ($message) {
{
$message->to($this->email, $this->full_name); $message->to($this->email, $this->full_name);
}); });
} }
} }

View File

@ -31,8 +31,9 @@ class UserPreferences extends PreferencesBase
public function resolveUser($user) public function resolveUser($user)
{ {
$user = BackendAuth::getUser(); $user = BackendAuth::getUser();
if (!$user) if (!$user) {
throw new SystemException(trans('backend::lang.user.preferences.not_authenticated')); throw new SystemException(trans('backend::lang.user.preferences.not_authenticated'));
}
return $user; return $user;
} }