/** * Edits a user * * @param string $email */ public function editAction($email) { if (!$this->request->isPost()) { $user = Users::findFirstByemail($email); if (!$user) { $this->flash->error("user was not found"); return $this->dispatcher->forward(array("controller" => "users", "action" => "index")); } $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW); $this->view->email = $user->email; $this->tag->setDefault("email", $user->email); $this->tag->setDefault("full_name", $user->full_name); $this->tag->setDefault("image_path", $user->image_path); $this->tag->setDefault("password", $user->password); $this->tag->setDefault("role", $user->role); $this->tag->setDefault("status", $user->status); $this->tag->setDefault("organisation_id", $user->organisation_id); $userdata = $user->SecurityGroup; $this->view->setVar("user_security_groups", $userdata); $data = SecurityGroup::find("organisation_id=" . $user->organisation_id); $data = $data->toArray(); foreach ($userdata->toArray() as $security_group) { if (($key = array_search($security_group, $data)) !== false) { unset($data[$key]); } } $object = json_decode(json_encode($data), FALSE); $this->view->setVar("security_groups", $object); $this->view->setVar("user", $user); } }
/** * Index action */ public function indexAction() { $this->persistent->parameters = null; $data = SecurityGroup::find("organisation_id= " . $this->organisation_id); $this->view->setVar("security_groups", $data); }