public function userAction()
 {
     $auth = $this->session->get('auth');
     $email = $auth['email'];
     $user = Users::findFirstByemail($email);
     $security_groups = $user->SecurityGroup;
     $user_dashboards = array();
     foreach ($security_groups as $security_group) {
         $dashboards = $security_group->Dashboard;
         $user_dashboards = array_merge($user_dashboards, $dashboards->ToArray());
     }
     if ($user_dashboards) {
         $dashboard = $user_dashboards[0];
         $this->response->redirect("/dashboards/" . $dashboard['type'] . "/render/" . $dashboard['id'] . "/dashboard");
     }
 }
Example #2
0
 /**
  * Builds header menu with left and right items
  *
  * @return string
  */
 public function getMenu()
 {
     $menu = array();
     $auth = $this->session->get('auth');
     $email = $auth['email'];
     $user = Users::findFirstByemail($email);
     $security_groups = $user->SecurityGroup;
     $user_dashboards = array();
     foreach ($security_groups as $security_group) {
         $dashboards = $security_group->Dashboard;
         $user_dashboards = array_merge($user_dashboards, $dashboards->ToArray());
     }
     foreach ($user_dashboards as $dashboard) {
         $newMenuLink = array('link' => "/dashboards/" . $dashboard['type'] . "/render/" . $dashboard['id'] . "/dashboard", 'title' => $dashboard['title'], 'icon' => $dashboard['icon'], 'selected' => 'false');
         array_push($menu, $newMenuLink);
     }
     if ($auth) {
         if ($auth['role'] == 'User') {
             foreach ($this->_userMenu as $controller => $option) {
                 $newMenuLink = array('link' => '/' . $controller . '/' . $option['action'], 'title' => $option['caption'], 'icon' => $option['icon'], 'selected' => 'false');
                 array_push($menu, $newMenuLink);
             }
         } elseif ($auth['role'] == 'Admin') {
             foreach ($this->_adminMenu as $controller => $option) {
                 $newMenuLink = array('link' => '/' . $controller . '/' . $option['action'], 'title' => $option['caption'], 'icon' => $option['icon'], 'selected' => 'false');
                 array_push($menu, $newMenuLink);
             }
         } elseif ($auth['role'] == 'Supervisor') {
             foreach ($this->_supervisorMenu as $controller => $option) {
                 $newMenuLink = array('link' => '/' . $controller . '/' . $option['action'], 'title' => $option['caption'], 'icon' => $option['icon'], 'selected' => 'false');
                 array_push($menu, $newMenuLink);
             }
         }
     }
     return $menu;
 }
 /**
  * This actions receive the input from the login form
  *
  */
 public function startAction($external = 'false')
 {
     if ($external == 'true') {
         $this->view->disable();
         if ($this->request->isPost()) {
             $email = $this->request->getPost('email', 'email');
             $password = $this->request->getPost('password');
             $password = sha1($password);
             $user = Users::findFirst("email='{$email}' AND password='******'");
             if ($user != false) {
                 if ($user->status == 'enable') {
                     $this->_registerSession($user);
                     echo 'success';
                 } else {
                     echo 'Your account is currently disabled';
                 }
             } else {
                 echo 'Wrong email/password';
             }
         }
     } else {
         if ($this->request->isPost()) {
             $email = $this->request->getPost('email', 'email');
             $password = $this->request->getPost('password');
             $password = sha1($password);
             $user = Users::findFirst("email='{$email}' AND password='******'");
             if ($user != false) {
                 if ($user->status == 'enable') {
                     $this->_registerSession($user);
                     return $this->forward('index/' . $user->role);
                 } else {
                     $this->flash->error('Your account is currently disabled');
                     return $this->forward('session/index');
                 }
             }
             $this->flash->error('Wrong email/password');
         }
         return $this->forward('session/index');
     }
 }
 /**
  * Deletes a user
  *
  * @param string $email
  */
 public function deleteAction()
 {
     $email = $this->request->getPost("id");
     $user = Users::findFirstByemail($email);
     if (!$user) {
         $this->flash->error("User was not found");
         return $this->dispatcher->forward(array("controller" => "users", "action" => "index"));
     }
     if (!$user->delete()) {
         foreach ($user->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "users", "action" => "index"));
     }
     $this->flash->success("User was deleted successfully");
     return $this->dispatcher->forward(array("controller" => "users", "action" => "index"));
 }