Пример #1
0
 /**
  * Register page.
  */
 public function registerAction()
 {
     $user = new User();
     if (Request::method() == 'post') {
         $user->set(['name' => Request::$post['name'], 'password' => Request::$post['password'], 'email' => Request::$post['email']]);
         if ($user->save()) {
             Request::redirectTo('/login');
         }
     }
     $this->set(compact('user'));
 }
Пример #2
0
 /**
  * Delete user
  *
  * @param integer $id
  */
 public function deleteAction($id)
 {
     $user = User::find($id);
     // Make sure the user exists
     if (!$user) {
         return $this->show404();
     }
     // Delete user
     if ($user->delete()) {
         Request::redirectTo('/admin/users');
     }
 }
Пример #3
0
 public function indexAction()
 {
     $information = ['tickets' => []];
     // Tickets
     $information['tickets']['open'] = Ticket::select()->where('is_closed = ?', 0)->rowCount();
     $information['tickets']['resolved'] = Ticket::select()->where('is_closed = ?', 1)->rowCount();
     $information['tickets']['total'] = $information['tickets']['open'] + $information['tickets']['resolved'];
     // Tickets
     $information['users']['newest'] = User::select()->orderBy('id', 'DESC')->fetch();
     $information['users']['total'] = User::select('id')->rowCount();
     $this->set(compact('information'));
 }
Пример #4
0
 /**
  * Does the checking for the session cookie and fetches the users info.
  *
  * @access private
  */
 private function getUser()
 {
     // Check if the session cookie is set, if so, check if it matches a user
     // and set set the user info.
     if (isset($_COOKIE['ticketer']) and $user = User::find('login_hash', $_COOKIE['ticketer'])) {
         $this->currentUser = $user;
         define("LOGGEDIN", true);
     } else {
         $this->currentUser = new User(array('id' => 0, 'username' => l('guest'), 'group_id' => 3));
         define("LOGGEDIN", false);
     }
     // Set the current_user variable in the views.
     View::set('currentUser', $this->currentUser);
 }