Exemple #1
0
 public function action_login()
 {
     // already logged in?
     if (Auth::check()) {
         // yes, so go back to the page the user came from, or the
         // application dashboard if no previous page can be detected
         //Messages::info(__('login.already-logged-in'));
         Response::redirect_back('');
     }
     // was the login form posted?
     if (Input::method() == 'POST') {
         // check the credentials.
         print_r(Input::all());
         if (Auth::login(Input::param('email'), Input::param('password'))) {
             // did the user want to be remembered?
             if (Input::param('remember', false)) {
                 // create the remember-me cookie
                 Auth::remember_me();
             } else {
                 // delete the remember-me cookie if present
                 Auth::dont_remember_me();
             }
             // logged in, go back to the page the user came from, or the
             // application dashboard if no previous page can be detected
             Response::redirect_back('/home');
         } else {
             // login failed, show an error message
             $this->error = 'test';
         }
     }
     // display the login page
     return \View::forge('auth/login');
 }
Exemple #2
0
 public function action_confirm()
 {
     $contactForm = new ContactForm();
     $contactForm->excuteAutoBind(Input::all());
     $contactValidation = new ContactValidator();
     $validation = $contactValidation->validate();
     $contactForm->setValiator($validation);
     if ($validation->run()) {
         return Aspect::getViewForge(View::forge('member/confirm', $contactForm->toView()), $contactForm);
     } else {
         return Aspect::getViewForge(View::forge('member/contact', $contactForm->toView()), $contactForm);
     }
 }
Exemple #3
0
 /**
  * @param $module string
  * @return mixed
  * @throws Exception
  */
 public function action_ajax($module)
 {
     $result = array('error' => false, 'message' => '');
     $params = Input::all();
     try {
         if (array_intersect_key(Input::get(), Input::post())) {
             throw new Exception('Get and post mustn\'t have the same keys');
         }
         $class_name = 'Model_' . $module;
         if (!class_exists($class_name) or $class_name::ajax() !== true) {
             return Response::forge(\View::forge('errors/404.twig', array('msg' => "That page couldn't be found!")), 404);
         }
         //TODO: check for crsf token
         $class = new $class_name();
         // NOTE: it is possible to process each kind of request by using
         // GET, POST, DELETE, PUT
         // But not all of the browsers supports this methods for using in forms
         $method = Input::get('method', 'GET');
         switch ($method) {
             case 'INSERT':
                 if (!($message = $class::validation($params))) {
                     $result['error'] = true;
                     $result['message'] = $class::get_message('insert_failed');
                 } else {
                     $class::insert($params);
                     $result['message'] = $class::get_message('insert_success');
                 }
                 break;
             case 'UPDATE':
                 $action = Input::get('action', 'update');
                 if (!method_exists($class, $action)) {
                     throw new Exception("Method {$action} doesn't exists");
                 }
                 $message = $class::$action($params);
                 $result['message'] = $class::get_message($message);
                 break;
             case 'DELETE':
                 $id = Input::get('id', false);
                 if (!$id) {
                     throw new Exception('On delete method \'id\' is required');
                 }
                 if (method_exists($class, 'delete')) {
                     $class::delete($id);
                     $result['message'] = $class::get_message('delete_message');
                 }
                 break;
             case 'GET':
                 $action = Input::get('action', false);
                 if (!$action) {
                     throw new Exception('For get method parameter \'action\' is required');
                 }
                 if (method_exists($class, $action)) {
                     $result['data'] = $class::$action($params);
                     $result['message'] = $class::get_message($action);
                 }
                 break;
         }
     } catch (Exception $e) {
         $result = array('error' => true, 'message' => $e->getMessage());
     }
     if (Input::is_ajax()) {
         $result = Format::forge()->to_json($result);
         return Response::forge($result);
     } else {
         if (isset($params['redirect_url'])) {
             Response::forge()->redirect($params['redirect_url']);
         } else {
             Response::forge()->redirect_back('/');
         }
     }
 }
Exemple #4
0
 public function post_faculty()
 {
     $__postData = Input::all();
     $action = $__postData['action'];
     if (!isset($action)) {
         Response::redirect('errormsg/404');
     }
     $action_func = "faculty_make_" . $action;
     $this->{$action_func}($__postData);
 }
Exemple #5
0
 public function get_staff()
 {
     $data = Input::all();
     $this->template->__yield__ = View::forge('pages/staff', array());
 }