/** * Deletes a User * * @param int $id */ public function deleteAction($id) { $user = Users::findFirstById($id); if (!$user) { $this->flash->error("User was not found"); return $this->dispatcher->forward(array('action' => 'index')); } if (!$user->delete()) { $this->flash->error($user->getMessages()); } else { $this->flash->success("User was deleted"); } return $this->dispatcher->forward(array('action' => 'index')); }
/** * Get the entity related to user in the active identity * * @return \Dsc\Admin\Models\Users */ public function getUser() { $identity = $this->session->get('auth-identity'); if (isset($identity['id'])) { $user = Users::findFirstById($identity['id']); if ($user == false) { throw new \Exception('The user does not exist'); } return $user; } return false; }