public function __construct() { Auth::requireAdmin(); if (!$this->displayName) { $this->displayName = 'Manage Images'; } parent::__construct(); }
public function __construct() { Auth::requireAdmin(); if (!$this->noun) { $this->noun = preg_replace('/^.+\\\\/', '', $this->entity); } if (!$this->nounPlural) { $this->nounPlural = $this->noun . 's'; } if (!$this->displayName) { $this->displayName = 'Manage ' . $this->nounPlural; } parent::__construct(); }
public function save($checkLogin = true) { $db = Env::get('db'); if ($checkLogin) { Auth::requireAdmin(); $user = Auth::loggedInUser(); $isCurrentUser = $user && $user->id == $this->id; } else { $user = null; $isCurrentUser = false; } // apply new id (email may have changed) $oldId = $this->id; $this->id = sha1(strtolower($this->row->email) . Env::get('auth_salt')); $this->row->id = $this->id; // misc fields $this->row->modified = new \DateTime(); if ($user) { $this->row->modifiedBy = $user->id; } else { $this->row->modifiedBy = 'none'; } // reset password if it changed $newPassword = false; if (@$this->row->newPassword) { $this->row->password = Auth::hashForPassword($this->email, $this->newPassword); $newPassword = $this->row->newPassword; unset($this->row->newPassword); } if (!isset($this->password)) { $this->password = ''; } // hash everything $this->row->signature = Auth::signatureForUser($this); $db->User->archive($oldId); $db->User->write($this->id, $this->row, true); if ($isCurrentUser && $newPassword) { Auth::attemptLogin($this->row->email, $newPassword); } }