コード例 #1
0
 public function getAction($id = null)
 {
     if (isset($id) && !empty($id)) {
         $appointment = $this->model()->getAppointment($id);
         if (!$appointment) {
             http_response_code(404);
             exit("No appointment was found by specified id");
         }
         $context = [];
         $creator = new Employee($appointment->employee_id);
         $context['creator'] = $creator->data();
         if ($appointment->employee_id == $this->employee->data()->id || $this->employee->hasPermission('admin')) {
             $context['rightToModify'] = true;
             $context['urlBase'] = URL_BASE;
         }
         $context['token'] = Token::generate();
         $context['values'] = $appointment;
         $context['clock'] = Config::get('calendar/clock');
         echo $this->view('reservation/get', $context);
     } else {
         http_response_code(404);
         exit("Dude, I think you're lost");
     }
 }
コード例 #2
0
 public function editAction($id = null)
 {
     $context = [];
     $employee = new Employee();
     if (!$employee->hasPermission('admin')) {
         Redirect::to('home');
     }
     if (!isset($id) || empty($id)) {
         Redirect::to('home');
     }
     $employee = new Employee($id);
     $context['values'] = $employee->data();
     if (Input::exists()) {
         if (!Token::check(Input::get('token'))) {
             Redirect::to();
         }
         $data = ['email' => Input::get('email'), 'first_name' => Input::get('first_name'), 'middle_name' => Input::get('middle_name'), 'last_name' => Input::get('last_name')];
         $success = $this->model()->edit($data, $id);
         if ($success) {
             Redirect::to('employee');
         } else {
             $context['errors'] = $this->model()->getErrors();
             $context['values'] = $data;
         }
     }
     $context['flash'] = Session::flash('home');
     $context['token'] = Token::generate();
     echo $this->view('employee/edit', $context);
 }
コード例 #3
0
ファイル: EmployeeModel.php プロジェクト: adiachenko/booker
 public function changePassword($data)
 {
     $errorHandler = new ErrorHandler();
     $validator = new Validate($errorHandler);
     $validator->check($data, ['password_current' => ['required' => true, 'minLength' => 8], 'password_new' => ['required' => true, 'minLength' => 8, 'doNotMatch' => 'password_current'], 'password_new_again' => ['required' => true, 'match' => 'password_new']]);
     if ($errorHandler->hasErrors()) {
         $this->errors = $errorHandler->all();
         return false;
     } else {
         $employee = new Employee();
         $passwordCheck = password_verify($data['password_current'], $employee->data()->password_hash);
         if ($passwordCheck === true) {
             $employee->update(['password_hash' => password_hash($data['password_new'], PASSWORD_BCRYPT)]);
             Session::flash('home', 'Your password was changed');
             return true;
         } else {
             $this->errors['password_current'][] = 'Wrong current password';
             return false;
         }
     }
 }