Beispiel #1
0
 public function indexAction($boardroom = null)
 {
     $currentBoardroom = isset($boardroom) && !empty($boardroom) ? $boardroom : 1;
     $boardrooms = Config::get('calendar/boardrooms');
     $context = ['currentBoardroom' => $currentBoardroom, 'boardrooms' => $boardrooms, 'flash' => Session::flash('home')];
     $employee = new Employee();
     if ($employee->hasPermission('admin')) {
         $context['admin'] = true;
     }
     echo $this->view('home/index', $context);
 }
 public function sendMailToAllAction()
 {
     $context = [];
     $employee = new Employee();
     if (!$employee->hasPermission('admin')) {
         Redirect::to('home');
     }
     if (Input::exists()) {
         if (!Token::check(Input::get('token'))) {
             Redirect::to();
         }
         $data = ['subject' => Input::get('subject'), 'body' => Input::get('body')];
         $success = $this->model()->sendMailToAll($data);
         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/sendmailtoall', $context);
 }
Beispiel #3
0
if (Config::get('general/environment') == 'development') {
    /**
     *
     * Nice looking and informative error reporting
     *
     **/
    $whoops = new Run();
    $whoops->pushHandler(new PrettyPageHandler());
    $whoops->register();
} else {
    ini_set("display_errors", 0);
}
$loader = new Twig_Loader_Filesystem(APP . 'view');
$options = ['cache' => APP . 'storage/twig', 'auto_reload' => true];
$twig = new Twig_Environment($loader, $options);
header('Content-Type: text/html; charset=UTF-8');
/**
*
* "Remember me" functionality for login system
*
**/
$rememberCookieExists = Cookie::exists(Config::get('cookie_to_remember_employee_session/name'));
$employeeSessionExists = Session::exists(Config::get('session/name'));
if ($rememberCookieExists === true && $employeeSessionExists === false) {
    $hash = Cookie::get(Config::get('cookie_to_remember_employee_session/name'));
    $hashCheck = Database::getInstance()->get('employee_session', ['hash', '=', $hash]);
    if ($hashCheck->count()) {
        $employee = new Employee($hashCheck->first()->employee_id);
        $employee->login();
    }
}
 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");
     }
 }
Beispiel #5
0
 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;
         }
     }
 }