Esempio n. 1
0
 /**
  * 
  * @return ApiManager
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new ApiManager();
     }
     return self::$_instance;
 }
Esempio n. 2
0
 /** singletonインスタンスの取得 */
 public static function getInstance()
 {
     //自己インスタンスの生成
     if (!isset(self::$_instance)) {
         self::$_instance = new ApiManager();
     }
     return self::$_instance;
 }
Esempio n. 3
0
 public static function getRelatedFromPolicy(Policy $policy)
 {
     $ret = array();
     $authm = new AuthManager();
     $apim = new ApiManager();
     $allAuths = $authm->getAllAuths(true);
     $relatedAuthIds = array();
     $relatedAuths = array();
     $authPropsArr = array();
     $allApis = $apim->getAllApis(true);
     $relatedApiIds = array();
     $relatedApis = array();
     $apiPropsArr = array();
     foreach ($allAuths as $auth) {
         /**
          * @var $auth Auth
          */
         foreach ($policy->getAuthIds() as $authBucket) {
             if ($authBucket->getAuthIds() && in_array($auth->getId(), $authBucket->getAuthIds())) {
                 $relatedAuths[] = $auth;
             }
         }
     }
     foreach ($relatedAuths as $auth) {
         $props = $auth->getProperties();
         if (!empty($props)) {
             $authPropsArr[$auth->getId()] = array_keys($props);
         }
     }
     $relatedApiIds = $policy->getApiIds();
     foreach ($allApis as $api) {
         /**
          * @var $api Api
          */
         if (in_array($api->getId(), $relatedApiIds)) {
             $relatedApis[] = $api;
         }
     }
     foreach ($relatedApis as $api) {
         $props = $api->getProperties();
         if (!empty($props)) {
             if ($api->getDisplayName()) {
                 $apiPropsArr[$api->getDisplayName()] = array_keys($props);
             } else {
                 $apiPropsArr[$api->getId()] = array_keys($props);
             }
         }
     }
     if (!empty($authPropsArr)) {
         $ret["auth"] = $authPropsArr;
     }
     if (!empty($apiPropsArr)) {
         $ret["api"] = $apiPropsArr;
     }
     return json_encode($ret);
 }
Esempio n. 4
0
 /**
  * Remove an User from the system
  * 
  * @param String $params The id of the user to remove
  */
 public static function deleteUser($params)
 {
     if (!isset($params) || !is_string($params)) {
         throw new EyeInvalidArgumentException('Missing or invalid $params');
     }
     $myUManager = UMManager::getInstance();
     $user = $myUManager->getUserById($params);
     $myUManager->deletePrincipal($user);
     $apiManager = new ApiManager();
     $apiManager->deleteMetadataUser($user->getId());
     $oauthManager = new OAuthManager();
     $token = new Token();
     $token->setUserID($user->getId());
     $oauthManager->deleteToken($token);
     //$apiManager->deleteCalendarAndEventsByUser($user->getName());
 }
Esempio n. 5
0
 public static function deleteCommentCloud($params)
 {
     $result['status'] = 'KO';
     $result['error'] = -1;
     if (isset($params['id']) && isset($params['time_created']) && isset($params['cloud']) && isset($_SESSION['access_token_' . $params['cloud'] . '_v2'])) {
         $id = $params['id'];
         $time_created = $params['time_created'];
         $cloud = $params['cloud'];
         $token = $_SESSION['access_token_' . $params['cloud'] . '_v2'];
         $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getName();
         $resourceUrl = self::getResourceUrl();
         $apiManager = new ApiManager();
         $result = $apiManager->deleteComment($cloud, $token, $id, $user, $time_created, $resourceUrl);
     }
     return $result;
 }
Esempio n. 6
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;
 }
Esempio n. 7
0
 public function getInvoice()
 {
     $this->load->model('setting/setting');
     $this->load->model('module/invoice_map');
     $id = $this->request->get['id'];
     $hash = $this->request->get['h'];
     $ifi_invoice = $this->model_setting_setting->getSetting('ifi_invoice');
     $settings_hash = $ifi_invoice[ModelModuleInvoiceMap::API_HASH];
     if (!ApiManager::getInstance()->checkIfirmaHash($hash, $settings_hash)) {
         $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'], 'SSL'));
     }
     $invoice = $this->model_module_invoice_map->get($id);
     header('Content-Type: application/pdf');
     header('Content-disposition: attachment; filename="' . ApiManager::getInstance()->getDocumentPdfName($invoice) . '"');
     echo ApiManager::getInstance()->getDocumentAsPdf($invoice);
 }
Esempio n. 8
0
 /**
  * Gets all APIs or returns false on error
  *
  * @param bool $allData
  * @return array(E3Api)|bool
  */
 public function getAllApis($allData = false)
 {
     $manager = new ApiManager();
     try {
         return $manager->getAllApis($allData);
     } catch (Exception $e) {
         $this->error($e);
     }
     return false;
 }
Esempio n. 9
0
 public static function refreshContent($params)
 {
     $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $file = FSI::getFile($params['path']);
     $path = AdvancedPathLib::getPhpLocalHackPath($file->getRealFile()->getAbsolutePath());
     $id = $params['id'];
     $cloud = $params['cloud'];
     $apiManager = new ApiManager();
     $token = $_SESSION['access_token_' . $cloud . '_v2'];
     $resourceUrl = null;
     if (isset($params['resource_url'])) {
         $token = new stdClass();
         $token->key = $params['access_token_key'];
         $token->secret = $params['access_token_secret'];
         $resourceUrl = $params['resource_url'];
     }
     $result = $apiManager->downloadMetadata($token, $id, $path, $user, false, $cloud, $resourceUrl);
     $content = self::fileOpen($params['path']);
     $result['content'] = $content[0];
     return $result;
 }
Esempio n. 10
0
 public function fileWritten(FileEvent $e)
 {
     //Logger::getLogger('sebas')->error('MetadataWritten:' . $e->getSource()->getPath());
     $apiManager = new ApiManager();
     $path = $e->getSource()->getPath();
     $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $userName = $user->getName();
     $cloud = $this->isCloud($path, $userName);
     $resourceUrl = null;
     if ($cloud->isCloud) {
         $pathU1db = substr($path, strlen($cloud->path));
         $lenfinal = strrpos($pathU1db, $e->getSource()->getName());
         $posfinal = $lenfinal > 1 ? $lenfinal - strlen($pathU1db) - 1 : $lenfinal - strlen($pathU1db);
         $pathParent = substr($pathU1db, 0, $posfinal);
         $folder = NULL;
         if ($pathParent !== '/') {
             $pos = strrpos($pathParent, '/');
             $folder = substr($pathParent, $pos + 1);
             $pathParent = substr($pathParent, 0, $pos + 1);
         }
         $parentId = false;
         if ($folder !== NULL) {
             $path = $pathParent . $folder . '/';
             $lista = new stdClass();
             $lista->cloud = $cloud->name;
             $lista->path = $pathParent;
             $lista->filename = $folder;
             $lista->user_eyeos = $user->getId();
             $u1db = json_decode($apiManager->callProcessU1db('parent', $lista));
             if ($u1db !== NULL && count($u1db) > 0) {
                 $parentId = $u1db[0]->id;
                 if (isset($u1db[0]->resource_url)) {
                     $resourceUrl = new stdClass();
                     $resourceUrl->resource_url = $u1db[0]->resource_url;
                     $resourceUrl->token = new stdClass();
                     $resourceUrl->token->key = $u1db[0]->access_token_key;
                     $resourceUrl->token->secret = $u1db[0]->access_token_secret;
                     if ($parentId === 'null') {
                         $parentId = 0;
                     }
                 }
             }
         } else {
             $parentId = '0';
             $path = $pathParent;
         }
         if ($parentId !== false) {
             $pathAbsolute = AdvancedPathLib::getPhpLocalHackPath($e->getSource()->getRealFile()->getAbsolutePath());
             $token = $_SESSION['access_token_' . $cloud->name . '_v2'];
             if ($resourceUrl) {
                 $token = $resourceUrl->token;
                 $resourceUrl = $resourceUrl->resource_url;
             }
             $result = $apiManager->createMetadata($cloud->name, $token, $user->getId(), true, $e->getSource()->getName(), $parentId, $path, $pathAbsolute, $resourceUrl);
             if ($result['status'] == 'OK') {
                 $params = array($e->getSource()->getParentPath(), $e->getSource()->getPath());
                 $message = new ClientBusMessage('file', 'refreshStackSync', $params);
                 ClientMessageBusController::getInstance()->queueMessage($message);
             } else {
                 if ($result['error'] == 403) {
                     $path = $this->cleanCloud($cloud->name, $user);
                     $params = array($path, $cloud->name);
                     $message = new ClientBusMessage('file', 'permissionDenied', $params);
                     ClientMessageBusController::getInstance()->queueMessage($message);
                 }
             }
         }
     }
 }