/** * Load Google and Calendar Service data by Staff * * @param AB_Staff $staff * @return bool */ public function loadByStaff(AB_Staff $staff) { $this->staff = $staff; if ($staff->get('google_data')) { try { $this->client->setAccessToken($staff->get('google_data')); if ($this->client->isAccessTokenExpired()) { $this->client->refreshToken($this->client->getRefreshToken()); $staff->set('google_data', $this->client->getAccessToken()); $staff->save(); } $this->service = new Google_Service_Calendar($this->client); return true; } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } return false; }
public function executeDeleteStaffAvatar() { $staff = new AB_Staff(); $staff->load(1); unlink($staff->get('avatar_path')); $staff->set('avatar_url', ''); $staff->set('avatar_path', ''); $staff->save(); exit; }
public function executeDeleteStaffAvatar() { $staff = new AB_Staff(); $staff->load($this->getParameter('id')); unlink($staff->get('avatar_path')); $staff->set('avatar_url', ''); $staff->set('avatar_path', ''); $staff->save(); wp_send_json_success(); }