Beispiel #1
0
 /**
  * Create a google calendar event
  */
 public function neweventAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (!empty($id) && is_numeric($id)) {
         if (Shineisp_Plugins_Calendar_Main::isReady()) {
             $domain = Domains::find($id, "expiring_date as end, CONCAT(domain, '.', ws.tld) as domain, CONCAT('http://www.', domain, '.', ws.tld) as url");
             if (!empty($domain[0])) {
                 $summary = $domain[0]['domain'];
                 $description = $this->translator->_("The domain %s expires today!", $domain[0]['url']);
                 $location = "";
                 if (true === Shineisp_Plugins_Calendar_Main::newEvent($summary, $location, $description, $domain[0]['end'], $domain[0]['end'])) {
                     $this->_helper->redirector('edit', 'domains', 'admin', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
                 }
             }
         }
         $this->_helper->redirector('edit', 'domains', 'admin', array('id' => $id, 'mex' => $this->translator->translate('Unable to process the request at this time.'), 'status' => 'danger'));
     }
     $this->_helper->redirector('edit', 'domains', 'admin', array('id' => $id, 'mex' => $this->translator->translate('Domain id has not been found.'), 'status' => 'danger'));
 }
Beispiel #2
0
 /**
  * Login in the calendar account
  * 
  * @return boolean
  * @throws Exception
  */
 protected static function login()
 {
     try {
         $client = new Google_Client();
         $client->setApplicationName("ShineISP Google Calendar Application");
         $clientid = Settings::findbyParam('calendar_clientid');
         $clientsecret = Settings::findbyParam('calendar_clientsecret');
         $redirecturi = Settings::findbyParam('calendar_redirecturi');
         $developerkey = Settings::findbyParam('calendar_developerkey');
         $client->setClientId($clientid);
         $client->setClientSecret($clientsecret);
         $client->setRedirectUri($redirecturi);
         $client->setDeveloperKey($developerkey);
         $cal = new Google_CalendarService($client);
         if (isset($_GET['logout'])) {
             unset($_SESSION['token']);
         }
         if (isset($_GET['code'])) {
             $client->authenticate($_GET['code']);
             $_SESSION['token'] = $client->getAccessToken();
             header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
         }
         if (isset($_SESSION['token'])) {
             $client->setAccessToken($_SESSION['token']);
         }
         if ($client->getAccessToken()) {
             self::$loggedIn = true;
             self::$calendar = $cal;
             return $cal;
         } else {
             $authUrl = $client->createAuthUrl();
             return $authUrl;
         }
     } catch (Exception $e) {
         Shineisp_Commons_Utilities::log($e->getMessage(), "plugin_calendar.log");
     }
 }