/**
  * Delete entity from database.
  *
  * @return bool|false|int
  */
 public function delete()
 {
     $parent_result = parent::delete();
     if ($parent_result && $this->get('google_event_id')) {
         $google = new AB_Google();
         $google->loadByStaffId($this->get('staff_id'));
         $google->delete($this->get('google_event_id'));
         return $parent_result;
     } else {
         return false;
     }
 }
 /**
  * @return bool|object
  */
 public function save()
 {
     //verify google calendar
     if (array_key_exists('google_calendar_id', $this->data) && !empty($this->data['google_calendar_id'])) {
         $google = new AB_Google();
         if (!$google->loadByStaffId($this->data['id']) || !$google->validateCalendar($this->data['google_calendar_id'])) {
             $this->errors['google_calendar'] = implode('<br>', $google->getErrors());
             return false;
         }
     }
     return parent::save();
 }
Beispiel #3
0
 /**
  * Delete event from Google Calendar associated to this appointment.
  *
  * @return bool
  */
 public function deleteGoogleCalendarEvent()
 {
     $google = new AB_Google();
     if ($google->loadByStaffId($this->get('staff_id'))) {
         // Delete existing event in Google Calendar.
         return $google->delete($this->get('google_event_id'));
     }
     return false;
 }