Ejemplo n.º 1
0
 /**
  * To register new user
  * Subject for validations (e.g username length)
  **/
 public function registration()
 {
     $username = Param::get('username');
     $password = Param::get('pword');
     $password_match = Param::get('pword_match');
     $fname = Param::get('fname');
     $lname = Param::get('lname');
     $email = Param::get('email');
     $registration = new Registration();
     $login_info = array('username' => $username, 'user_password' => $password, 'fname' => $fname, 'lname' => $lname, 'email' => $email);
     //To check if all keys are null
     if (!array_filter($login_info)) {
         $status = "";
     } else {
         try {
             foreach ($login_info as $key => $value) {
                 if (!is_complete($value)) {
                     throw new ValidationException("Please fill up all fields");
                 }
             }
             if (!is_password_match($password, $password_match)) {
                 throw new ValidationException("Password did not match");
             }
             $info = $registration->userRegistration($login_info);
             $status = notice("Registration Complete");
         } catch (ExistingUserException $e) {
             $status = notice($e->getMessage(), "error");
         } catch (ValidationException $e) {
             $status = notice($e->getMessage(), "error");
         }
     }
     $this->set(get_defined_vars());
 }