public function executeDeleteStaffScheduleBreak()
 {
     $break = new AB_ScheduleItemBreak();
     $break->load(1);
     $break->delete();
     exit;
 }
Exemplo n.º 2
0
 /**
  * Extend parent method to control access on staff member level.
  *
  * @param string $action
  * @return bool
  */
 protected function hasAccess($action)
 {
     if (parent::hasAccess($action)) {
         if (!AB_Utils::isCurrentUserAdmin()) {
             $staff = new AB_Staff();
             switch ($action) {
                 case 'executeEditStaff':
                 case 'executeDeleteStaffAvatar':
                 case 'executeStaffServices':
                 case 'executeStaffSchedule':
                 case 'executeStaffHolidays':
                     $staff->load($this->getParameter('id'));
                     break;
                 case 'executeStaffServicesUpdate':
                 case 'executeStaffHolidaysUpdate':
                     $staff->load($this->getParameter('staff_id'));
                     break;
                 case 'executeStaffScheduleHandleBreak':
                     $staffScheduleItem = new AB_StaffScheduleItem();
                     $staffScheduleItem->load($this->getParameter('staff_schedule_item_id'));
                     $staff->load($staffScheduleItem->get('staff_id'));
                     break;
                 case 'executeDeleteStaffScheduleBreak':
                     $break = new AB_ScheduleItemBreak();
                     $break->load($this->getParameter('id'));
                     $staffScheduleItem = new AB_StaffScheduleItem();
                     $staffScheduleItem->load($break->get('staff_schedule_item_id'));
                     $staff->load($staffScheduleItem->get('staff_id'));
                     break;
                 case 'executeStaffScheduleUpdate':
                     if ($this->hasParameter('days')) {
                         foreach ($this->getParameter('days') as $id => $day_index) {
                             $staffScheduleItem = new AB_StaffScheduleItem();
                             $staffScheduleItem->load($id);
                             $staff = new AB_Staff();
                             $staff->load($staffScheduleItem->get('staff_id'));
                             if ($staff->get('wp_user_id') != get_current_user_id()) {
                                 return false;
                             }
                         }
                     }
                     break;
                 default:
                     return false;
             }
             return $staff->get('wp_user_id') == get_current_user_id();
         }
         return true;
     }
     return false;
 }