コード例 #1
0
ファイル: connect.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Get all remote files
  *
  * @param	   string	$service		Service name (google or dropbox)
  * @param	   integer	$uid			User ID
  * @param	   string	$since			last sync date
  * @param	   array	$connections	Array of local-remote connections
  *
  * @return	   array
  */
 public function getRemoteItems($service = 'google', $uid = 0, $since = '', $connections = array())
 {
     // Get api
     $apiService = $this->getAPI($service, $uid);
     $remotes = array();
     if (!$apiService) {
         if (!$this->getError()) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_SYNC_API_UNAVAILABLE'));
         }
         return false;
     }
     if ($service == 'google') {
         // Get remote folder ID
         $folderID = $this->getConfigParam($service, 'remote_dir_id');
         // Need remote folder
         if (!$folderID) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_SYNC_FAILED_SERVICE_UNAVAILABLE'));
             return false;
         }
         // Make sure master folder is there and not trashed
         try {
             $folder = $apiService->files->get($folderID);
             if ($folder && $folder['labels']['trashed'] == 1) {
                 // Untrash
                 Google::untrashItem($apiService, $folderID);
             }
         } catch (Exception $e) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_SYNC_FOLDER_UNAVAILABLE'));
             return false;
         }
         // Collect remote items with duplicate names
         $duplicates = array();
         // Get files in main project remote directory
         $remotes = Google::getFolderContent($apiService, $folderID, $remotes, '', $since, $connections, $duplicates);
     }
     return $remotes;
 }