Example #1
0
 /**
  * @return array
  * @throws Exception
  */
 public function getCloudsList()
 {
     $clouds = array();
     try {
         $apiManager = new ApiManager();
         $oauthManager = new OAuthManager();
         $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
         $response = json_decode($apiManager->getCloudsList());
         foreach ($response as $cloud) {
             $isActive = false;
             $token = $oauthManager->getTokenUserCloud($user, $cloud);
             if ($token) {
                 if (strlen($token->getTsecret()) > 0) {
                     $isActive = true;
                     $tokenAux = new stdClass();
                     $tokenAux->key = $token->getTKey();
                     $tokenAux->secret = $token->getTSecret();
                     $_SESSION['access_token_' . $cloud . '_v2'] = $tokenAux;
                 }
             }
             array_push($clouds, array("name" => $cloud, "isActive" => $isActive));
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return $clouds;
 }
Example #2
0
 public static function getTypeCalendars()
 {
     $result['status'] = 'KO';
     $result['error'] = -1;
     $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $oauthManager = new OAuthManager();
     $apiManager = new ApiManager();
     $clouds = json_decode($apiManager->getCloudsList());
     if (!isset($clouds->error) && count($clouds) > 0) {
         $result['status'] = 'OK';
         unset($result['error']);
         $result['clouds'] = array();
         foreach ($clouds as $cloud) {
             $cloudType = array();
             $cloudType['cloud'] = $cloud;
             $calendar = $apiManager->getControlCalendarCloud($cloud);
             if (!isset($calendar->error)) {
                 $token = $oauthManager->getTokenUserCloud($user, $cloud);
                 if ($token) {
                     if (strlen($token->getTsecret()) > 0) {
                         $cloudType['permission'] = $calendar->calendar;
                     }
                 }
             }
             array_push($result['clouds'], $cloudType);
         }
     }
     return $result;
 }