public function render($idLang) { $row = new RM_View_Form_Row(); $row->setDesc($this->getDesc()); $row->setHTML($this->getView()->partial(static::BASE_PATH . static::TPL, $this->addFieldData($idLang, array('isLinked' => $this->_accessToken instanceof Application_Model_Api_Google_AccessToken, 'linkUrl' => $this->_client ? $this->_client->createAuthUrl() : '', 'unlinkUrl' => $this->getView()->url(['idDoctor' => $this->_doctor->getId()], 'admin-unlink-google-account'))))); return $this->renderRow($row); }
public function refresh(Application_Model_Api_Google_AccessToken $accessToken) { $client = MedOptima_Service_Google_Config::getCalendarClient(); $client->setAccessToken($accessToken->jsonSerialize()); $client->refreshToken($accessToken->getRefreshToken()); return (new MedOptima_Service_Google_AccessToken_Initializer())->updateFromEncodedData($accessToken, $client->getAccessToken()); }
private static function _getApiConfig() { if (!self::$_apiConfig) { self::$_apiConfig = Zend_Registry::get('cfg')['api']['google']; } return self::$_apiConfig; }
public function __construct(Doctor $doctor) { $token = AccessToken::getByDoctor($doctor); if ($token instanceof AccessToken && !$token->isExpired()) { $client = MedOptima_Service_Google_Config::getCalendarClient(); $client->setAccessToken($token->jsonSerialize()); $this->_cal = new Google_CalendarService($client); } return $this; }
public function linkDoctorAccount(Doctor $doctor) { $token = AccessToken::getByDoctor($doctor); if (!$token instanceof AccessToken) { $token = AccessToken::create(); $token->setDoctor($doctor); } $client = MedOptima_Service_Google_Config::getCalendarClient(); if ($this->_request->getParam('code')) { $client->authenticate($this->_request->getParam('code')); (new MedOptima_Service_Google_AccessToken_Initializer())->updateFromEncodedData($token, $client->getAccessToken()); } $token->save(); return true; }