diff --git a/workflow/engine/classes/class.pmDrive.php b/workflow/engine/classes/class.pmDrive.php index e271d4de0..56fa06b2b 100755 --- a/workflow/engine/classes/class.pmDrive.php +++ b/workflow/engine/classes/class.pmDrive.php @@ -94,12 +94,13 @@ class PMDrive extends PMGoogleApi */ public function listFolder($fileId) { - $this->setScope('https://www.googleapis.com/auth/drive'); - $this->setScope('https://www.googleapis.com/auth/drive.file'); - $this->setScope('https://www.googleapis.com/auth/drive.readonly'); - $this->setScope('https://www.googleapis.com/auth/drive.metadata.readonly'); - $this->setScope('https://www.googleapis.com/auth/drive.appdata'); - $this->setScope('https://www.googleapis.com/auth/drive.metadata'); + $this->setScope(static::DRIVE); + $this->setScope(static::DRIVE_FILE); + $this->setScope(static::DRIVE_READONLY); + $this->setScope(static::DRIVE_METADATA); + $this->setScope(static::DRIVE_METADATA_READONLY); + $this->setScope(static::DRIVE_APPDATA); + $service = $this->serviceDrive(); try { @@ -126,7 +127,7 @@ class PMDrive extends PMGoogleApi */ public function createFolder($name, $parentId = null) { - $this->setScope('https://www.googleapis.com/auth/drive.file'); + $this->setScope(static::DRIVE_FILE); $service = $this->serviceDrive(); @@ -159,7 +160,7 @@ class PMDrive extends PMGoogleApi */ public function uploadFile($mime, $src, $name, $parentId = null) { - $this->setScope('https://www.googleapis.com/auth/drive.file'); + $this->setScope(static::DRIVE_FILE); $service = $this->serviceDrive(); @@ -200,13 +201,13 @@ class PMDrive extends PMGoogleApi */ public function downloadFile($fileId) { - $this->setScope('https://www.googleapis.com/auth/drive'); - $this->setScope('https://www.googleapis.com/auth/drive.appdata'); - $this->setScope('https://www.googleapis.com/auth/drive.apps.readonly'); - $this->setScope('https://www.googleapis.com/auth/drive.file'); - $this->setScope('https://www.googleapis.com/auth/drive.metadata'); - $this->setScope('https://www.googleapis.com/auth/drive.metadata.readonly'); - $this->setScope('https://www.googleapis.com/auth/drive.readonly'); + $this->setScope(static::DRIVE); + $this->setScope(static::DRIVE_APPDATA); + $this->setScope(static::DRIVE_APPS_READONLY); + $this->setScope(static::DRIVE_FILE); + $this->setScope(static::DRIVE_METADATA); + $this->setScope(static::DRIVE_METADATA_READONLY); + $this->setScope(static::DRIVE_READONLY); $service = $this->serviceDrive(); $response = null; @@ -241,8 +242,8 @@ class PMDrive extends PMGoogleApi */ public function setPermission($fileId, $value, $type = 'user', $role = 'reader', $sendNotification = false) { - $this->setScope('https://www.googleapis.com/auth/drive'); - $this->setScope('https://www.googleapis.com/auth/drive.file'); + $this->setScope(static::DRIVE); + $this->setScope(static::DRIVE_FILE); $service = $this->serviceDrive(); diff --git a/workflow/engine/classes/class.pmGoogleApi.php b/workflow/engine/classes/class.pmGoogleApi.php index 89426007a..8d7d72c0a 100755 --- a/workflow/engine/classes/class.pmGoogleApi.php +++ b/workflow/engine/classes/class.pmGoogleApi.php @@ -9,6 +9,15 @@ require_once PATH_TRUNK . 'vendor' . PATH_SEP . 'google' . PATH_SEP . 'apiclient class PMGoogleApi { + const DRIVE = 'https://www.googleapis.com/auth/drive'; + const DRIVE_FILE = 'https://www.googleapis.com/auth/drive.file'; + const DRIVE_APPS_READONLY = 'https://www.googleapis.com/auth/drive.apps.readonly'; + const DRIVE_READONLY = 'https://www.googleapis.com/auth/drive.readonly'; + const DRIVE_METADATA = 'https://www.googleapis.com/auth/drive.metadata'; + const DRIVE_METADATA_READONLY = 'https://www.googleapis.com/auth/drive.metadata.readonly'; + const DRIVE_APPDATA = 'https://www.googleapis.com/auth/drive.appdata'; + const DRIVE_PHOTOS_READONLY = 'https://www.googleapis.com/auth/drive.photos.readonly'; + private $scope = array(); private $serviceAccountEmail; private $serviceAccountP12; @@ -244,13 +253,13 @@ class PMGoogleApi { $scope = array( - 'https://www.googleapis.com/auth/drive', - 'https://www.googleapis.com/auth/drive.file', - 'https://www.googleapis.com/auth/drive.readonly', - 'https://www.googleapis.com/auth/drive.metadata.readonly', - 'https://www.googleapis.com/auth/drive.appdata', - 'https://www.googleapis.com/auth/drive.metadata', - 'https://www.googleapis.com/auth/drive.photos.readonly' + static::DRIVE, + static::DRIVE_FILE, + static::DRIVE_READONLY, + static::DRIVE_METADATA, + static::DRIVE_METADATA_READONLY, + static::DRIVE_APPDATA, + static::DRIVE_PHOTOS_READONLY ); if ($credentials->typeAuth == 'webApplication') {