diff options
Diffstat (limited to 'apps/files_external/3rdparty/google-api-php-client/src')
20 files changed, 1156 insertions, 261 deletions
diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Abstract.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Abstract.php index 344aad874f4..0832df3a408 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Abstract.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Abstract.php @@ -31,11 +31,5 @@ abstract class Google_Auth_Abstract * @return Google_Http_Request $request */ abstract public function authenticatedRequest(Google_Http_Request $request); - - abstract public function authenticate($code); abstract public function sign(Google_Http_Request $request); - abstract public function createAuthUrl($scope); - - abstract public function refreshToken($refreshToken); - abstract public function revokeToken(); } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/AssertionCredentials.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/AssertionCredentials.php index be93df33d50..3db0a779df3 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/AssertionCredentials.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/AssertionCredentials.php @@ -118,9 +118,14 @@ class Google_Auth_AssertionCredentials { $header = array('typ' => 'JWT', 'alg' => 'RS256'); + $payload = json_encode($payload); + // Handle some overzealous escaping in PHP json that seemed to cause some errors + // with claimsets. + $payload = str_replace('\/', '/', $payload); + $segments = array( Google_Utils::urlSafeB64Encode(json_encode($header)), - Google_Utils::urlSafeB64Encode(json_encode($payload)) + Google_Utils::urlSafeB64Encode($payload) ); $signingInput = implode('.', $segments); diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/OAuth2.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/OAuth2.php index 6cf7c1a190f..5630d755e04 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/OAuth2.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/OAuth2.php @@ -50,9 +50,9 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract private $state; /** - * @var string The token bundle. + * @var array The token bundle. */ - private $token; + private $token = array(); /** * @var Google_Client the base client @@ -97,37 +97,39 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract // We got here from the redirect from a successful authorization grant, // fetch the access token - $request = $this->client->getIo()->makeRequest( - new Google_Http_Request( - self::OAUTH2_TOKEN_URI, - 'POST', - array(), - array( - 'code' => $code, - 'grant_type' => 'authorization_code', - 'redirect_uri' => $this->client->getClassConfig($this, 'redirect_uri'), - 'client_id' => $this->client->getClassConfig($this, 'client_id'), - 'client_secret' => $this->client->getClassConfig($this, 'client_secret') - ) + $request = new Google_Http_Request( + self::OAUTH2_TOKEN_URI, + 'POST', + array(), + array( + 'code' => $code, + 'grant_type' => 'authorization_code', + 'redirect_uri' => $this->client->getClassConfig($this, 'redirect_uri'), + 'client_id' => $this->client->getClassConfig($this, 'client_id'), + 'client_secret' => $this->client->getClassConfig($this, 'client_secret') ) ); + $request->disableGzip(); + $response = $this->client->getIo()->makeRequest($request); - if ($request->getResponseHttpCode() == 200) { - $this->setAccessToken($request->getResponseBody()); + if ($response->getResponseHttpCode() == 200) { + $this->setAccessToken($response->getResponseBody()); $this->token['created'] = time(); return $this->getAccessToken(); } else { - $response = $request->getResponseBody(); - $decodedResponse = json_decode($response, true); + $decodedResponse = json_decode($response->getResponseBody(), true); if ($decodedResponse != null && $decodedResponse['error']) { - $response = $decodedResponse['error']; + $decodedResponse = $decodedResponse['error']; + if (isset($decodedResponse['error_description'])) { + $decodedResponse .= ": " . $decodedResponse['error_description']; + } } throw new Google_Auth_Exception( sprintf( "Error fetching OAuth2 access token, message: '%s'", - $response + $decodedResponse ), - $request->getResponseHttpCode() + $response->getResponseHttpCode() ); } } @@ -147,9 +149,15 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract 'client_id' => $this->client->getClassConfig($this, 'client_id'), 'scope' => $scope, 'access_type' => $this->client->getClassConfig($this, 'access_type'), - 'approval_prompt' => $this->client->getClassConfig($this, 'approval_prompt'), ); + $params = $this->maybeAddParam($params, 'approval_prompt'); + $params = $this->maybeAddParam($params, 'login_hint'); + $params = $this->maybeAddParam($params, 'hd'); + $params = $this->maybeAddParam($params, 'openid.realm'); + $params = $this->maybeAddParam($params, 'prompt'); + $params = $this->maybeAddParam($params, 'include_granted_scopes'); + // If the list of scopes contains plus.login, add request_visible_actions // to auth URL. $rva = $this->client->getClassConfig($this, 'request_visible_actions'); @@ -185,6 +193,15 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract return json_encode($this->token); } + public function getRefreshToken() + { + if (array_key_exists('refresh_token', $this->token)) { + return $this->token['refresh_token']; + } else { + return null; + } + } + public function setState($state) { $this->state = $state; @@ -223,7 +240,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract throw new Google_Auth_Exception( "The OAuth 2.0 access token has expired," ." and a refresh token is not available. Refresh tokens" - . "are not returned for responses that were auto-approved." + ." are not returned for responses that were auto-approved." ); } $this->refreshToken($this->token['refresh_token']); @@ -265,7 +282,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract if (!$assertionCredentials) { $assertionCredentials = $this->assertionCredentials; } - + $cacheKey = $assertionCredentials->getCacheKey(); if ($cacheKey) { @@ -280,7 +297,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract return; } } - + $this->refreshTokenRequest( array( 'grant_type' => 'assertion', @@ -288,7 +305,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract 'assertion' => $assertionCredentials->generateAssertion(), ) ); - + if ($cacheKey) { // Attempt to cache the token. $this->client->getCache()->set( @@ -306,6 +323,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract array(), $params ); + $http->disableGzip(); $request = $this->client->getIo()->makeRequest($http); $code = $request->getResponseHttpCode(); @@ -320,6 +338,9 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract throw new Google_Auth_Exception("Invalid token format"); } + if (isset($token['id_token'])) { + $this->token['id_token'] = $token['id_token']; + } $this->token['access_token'] = $token['access_token']; $this->token['expires_in'] = $token['expires_in']; $this->token['created'] = time(); @@ -328,17 +349,24 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract } } - /** - * Revoke an OAuth2 access token or refresh token. This method will revoke the current access - * token, if a token isn't provided. - * @throws Google_Auth_Exception - * @param string|null $token The token (access token or a refresh token) that should be revoked. - * @return boolean Returns True if the revocation was successful, otherwise False. - */ + /** + * Revoke an OAuth2 access token or refresh token. This method will revoke the current access + * token, if a token isn't provided. + * @throws Google_Auth_Exception + * @param string|null $token The token (access token or a refresh token) that should be revoked. + * @return boolean Returns True if the revocation was successful, otherwise False. + */ public function revokeToken($token = null) { if (!$token) { - $token = $this->token['access_token']; + if (!$this->token) { + // Not initialized, no token to actually revoke + return false; + } elseif (array_key_exists('refresh_token', $this->token)) { + $token = $this->token['refresh_token']; + } else { + $token = $this->token['access_token']; + } } $request = new Google_Http_Request( self::OAUTH2_REVOKE_URI, @@ -346,6 +374,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract array(), "token=$token" ); + $request->disableGzip(); $response = $this->client->getIo()->makeRequest($request); $code = $response->getResponseHttpCode(); if ($code == 200) { @@ -362,7 +391,7 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract */ public function isAccessTokenExpired() { - if (!$this->token) { + if (!$this->token || !isset($this->token['created'])) { return true; } @@ -576,4 +605,16 @@ class Google_Auth_OAuth2 extends Google_Auth_Abstract // All good. return new Google_Auth_LoginTicket($envelope, $payload); } + + /** + * Add a parameter to the auth params if not empty string. + */ + private function maybeAddParam($params, $name) + { + $param = $this->client->getClassConfig($this, $name); + if ($param != '') { + $params[$name] = $param; + } + return $params; + } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Simple.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Simple.php index 8fcf61e52ea..e83900fc26f 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Simple.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Auth/Simple.php @@ -51,36 +51,6 @@ class Google_Auth_Simple extends Google_Auth_Abstract return $this->io->makeRequest($request); } - public function authenticate($code) - { - throw new Google_Auth_Exception("Simple auth does not exchange tokens."); - } - - public function setAccessToken($accessToken) - { - /* noop*/ - } - - public function getAccessToken() - { - return null; - } - - public function createAuthUrl($scope) - { - return null; - } - - public function refreshToken($refreshToken) - { - /* noop*/ - } - - public function revokeToken() - { - /* noop*/ - } - public function sign(Google_Http_Request $request) { $key = $this->client->getClassConfig($this, 'developer_key'); diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/File.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/File.php index 530af80ff96..8d0d62fe88c 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/File.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/File.php @@ -48,14 +48,14 @@ class Google_Cache_File extends Google_Cache_Abstract if ($expiration) { $mtime = filemtime($storageFile); - if (($now - $mtime) >= $expiration) { + if ((time() - $mtime) >= $expiration) { $this->delete($key); return false; } } if ($this->acquireReadLock($storageFile)) { - $data = file_get_contents($storageFile); + $data = fread($this->fh, filesize($storageFile)); $data = unserialize($data); $this->unlock($storageFile); } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/Memcache.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/Memcache.php index 56676c24728..1104afb8aeb 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/Memcache.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Cache/Memcache.php @@ -47,7 +47,7 @@ class Google_Cache_Memcache extends Google_Cache_Abstract } else { $this->host = $client->getClassConfig($this, 'host'); $this->port = $client->getClassConfig($this, 'port'); - if (empty($this->host) || empty($this->port)) { + if (empty($this->host) || (empty($this->port) && (string) $this->port != "0")) { throw new Google_Cache_Exception("You need to supply a valid memcache host and port"); } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Client.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Client.php index e61daf7f16e..e15b4f4ea3c 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Client.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Client.php @@ -21,6 +21,7 @@ require_once 'Google/Cache/Memcache.php'; require_once 'Google/Config.php'; require_once 'Google/Collection.php'; require_once 'Google/Exception.php'; +require_once 'Google/IO/Curl.php'; require_once 'Google/IO/Stream.php'; require_once 'Google/Model.php'; require_once 'Google/Service.php'; @@ -35,7 +36,7 @@ require_once 'Google/Service/Resource.php'; */ class Google_Client { - const LIBVER = "1.0.3-beta"; + const LIBVER = "1.0.6-beta"; const USER_AGENT_SUFFIX = "google-api-php-client/"; /** * @var Google_Auth_Abstract $auth @@ -79,11 +80,6 @@ class Google_Client */ public function __construct($config = null) { - if (! ini_get('date.timezone') && - function_exists('date_default_timezone_set')) { - date_default_timezone_set('UTC'); - } - if (is_string($config) && strlen($config)) { $config = new Google_Config($config); } else if ( !($config instanceof Google_Config)) { @@ -92,11 +88,22 @@ class Google_Client if ($this->isAppEngine()) { // Automatically use Memcache if we're in AppEngine. $config->setCacheClass('Google_Cache_Memcache'); + } + + if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) { // Automatically disable compress.zlib, as currently unsupported. $config->setClassConfig('Google_Http_Request', 'disable_gzip', true); } } + if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) { + if (function_exists('curl_version') && function_exists('curl_exec')) { + $config->setIoClass("Google_IO_Curl"); + } else { + $config->setIoClass("Google_IO_Stream"); + } + } + $this->config = $config; } @@ -178,7 +185,7 @@ class Google_Client */ public function setAccessToken($accessToken) { - if ($accessToken == null || 'null' == $accessToken) { + if ($accessToken == 'null') { $accessToken = null; } $this->getAuth()->setAccessToken($accessToken); @@ -238,7 +245,16 @@ class Google_Client // The response is json encoded, so could be the string null. // It is arguable whether this check should be here or lower // in the library. - return (null == $token || 'null' == $token) ? null : $token; + return (null == $token || 'null' == $token || '[]' == $token) ? null : $token; + } + + /** + * Get the OAuth 2.0 refresh token. + * @return string $refreshToken refresh token or null if not available + */ + public function getRefreshToken() + { + return $this->getAuth()->getRefreshToken(); } /** @@ -281,6 +297,15 @@ class Google_Client } /** + * Set the login hint, email address or sub id. + * @param string $loginHint + */ + public function setLoginHint($loginHint) + { + $this->config->setLoginHint($loginHint); + } + + /** * Set the application name, this is included in the User-Agent HTTP header. * @param string $applicationName */ @@ -343,6 +368,50 @@ class Google_Client } /** + * Set the hd (hosted domain) parameter streamlines the login process for + * Google Apps hosted accounts. By including the domain of the user, you + * restrict sign-in to accounts at that domain. + * @param $hd string - the domain to use. + */ + public function setHostedDomain($hd) + { + $this->config->setHostedDomain($hd); + } + + /** + * Set the prompt hint. Valid values are none, consent and select_account. + * If no value is specified and the user has not previously authorized + * access, then the user is shown a consent screen. + * @param $prompt string + */ + public function setPrompt($prompt) + { + $this->config->setPrompt($prompt); + } + + /** + * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth + * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which + * an authentication request is valid. + * @param $realm string - the URL-space to use. + */ + public function setOpenidRealm($realm) + { + $this->config->setOpenidRealm($realm); + } + + /** + * If this is provided with the value true, and the authorization request is + * granted, the authorization will include any previous authorizations + * granted to this user/application combination for other scopes. + * @param $include boolean - the URL-space to use. + */ + public function setIncludeGrantedScopes($include) + { + $this->config->setIncludeGrantedScopes($include); + } + + /** * Fetches a fresh OAuth 2.0 access token with the given refresh token. * @param string $refreshToken * @return void @@ -414,9 +483,9 @@ class Google_Client $this->requestedScopes = array(); $this->addScope($scopes); } - + /** - * This functions adds a scope to be requested as part of the OAuth2.0 flow. + * This functions adds a scope to be requested as part of the OAuth2.0 flow. * Will append any scopes not previously requested to the scope parameter. * A single string will be treated as a scope to request. An array of strings * will each be appended. @@ -466,11 +535,11 @@ class Google_Client { $this->deferExecution = $defer; } - + /** * Helper method to execute deferred HTTP requests. * - * @returns object of the type of the expected class or array. + * @return object of the type of the expected class or array. */ public function execute($request) { diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Collection.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Collection.php index 60909a967a4..6e7bf9b0f1e 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Collection.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Collection.php @@ -13,29 +13,31 @@ class Google_Collection extends Google_Model implements Iterator, Countable public function rewind() { - if (is_array($this->data[$this->collection_key])) { - reset($this->data[$this->collection_key]); + if (isset($this->modelData[$this->collection_key]) + && is_array($this->modelData[$this->collection_key])) { + reset($this->modelData[$this->collection_key]); } } public function current() { $this->coerceType($this->key()); - if (is_array($this->data[$this->collection_key])) { - return current($this->data[$this->collection_key]); + if (is_array($this->modelData[$this->collection_key])) { + return current($this->modelData[$this->collection_key]); } } public function key() { - if (is_array($this->data[$this->collection_key])) { - return key($this->data[$this->collection_key]); + if (isset($this->modelData[$this->collection_key]) + && is_array($this->modelData[$this->collection_key])) { + return key($this->modelData[$this->collection_key]); } } public function next() { - return next($this->data[$this->collection_key]); + return next($this->modelData[$this->collection_key]); } public function valid() @@ -46,7 +48,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable public function count() { - return count($this->data[$this->collection_key]); + return count($this->modelData[$this->collection_key]); } public function offsetExists ($offset) @@ -54,7 +56,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable if (!is_numeric($offset)) { return parent::offsetExists($offset); } - return isset($this->data[$this->collection_key][$offset]); + return isset($this->modelData[$this->collection_key][$offset]); } public function offsetGet($offset) @@ -63,7 +65,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable return parent::offsetGet($offset); } $this->coerceType($offset); - return $this->data[$this->collection_key][$offset]; + return $this->modelData[$this->collection_key][$offset]; } public function offsetSet($offset, $value) @@ -71,7 +73,7 @@ class Google_Collection extends Google_Model implements Iterator, Countable if (!is_numeric($offset)) { return parent::offsetSet($offset, $value); } - $this->data[$this->collection_key][$offset] = $value; + $this->modelData[$this->collection_key][$offset] = $value; } public function offsetUnset($offset) @@ -79,16 +81,16 @@ class Google_Collection extends Google_Model implements Iterator, Countable if (!is_numeric($offset)) { return parent::offsetUnset($offset); } - unset($this->data[$this->collection_key][$offset]); + unset($this->modelData[$this->collection_key][$offset]); } private function coerceType($offset) { $typeKey = $this->keyType($this->collection_key); - if (isset($this->$typeKey) && !is_object($this->data[$this->collection_key][$offset])) { + if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) { $type = $this->$typeKey; - $this->data[$this->collection_key][$offset] = - new $type($this->data[$this->collection_key][$offset]); + $this->modelData[$this->collection_key][$offset] = + new $type($this->modelData[$this->collection_key][$offset]); } } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Config.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Config.php index 972c97fedd0..84083058fe5 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Config.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Config.php @@ -20,12 +20,17 @@ */ class Google_Config { - private $configuration; + const GZIP_DISABLED = true; + const GZIP_ENABLED = false; + const GZIP_UPLOADS_ENABLED = true; + const GZIP_UPLOADS_DISABLED = false; + const USE_AUTO_IO_SELECTION = "auto"; + protected $configuration; /** * Create a new Google_Config. Can accept an ini file location with the * local configuration. For example: - * application_name: "My App"; + * application_name="My App" * * @param [$ini_file_location] - optional - The location of the ini file to load */ @@ -37,7 +42,7 @@ class Google_Config // Which Authentication, Storage and HTTP IO classes to use. 'auth_class' => 'Google_Auth_OAuth2', - 'io_class' => 'Google_IO_Stream', + 'io_class' => self::USE_AUTO_IO_SELECTION, 'cache_class' => 'Google_Cache_File', // Don't change these unless you're working against a special development @@ -46,12 +51,21 @@ class Google_Config // Definition of class specific values, like file paths and so on. 'classes' => array( - // If you want to pass in OAuth 2.0 settings, they will need to be - // structured like this. + 'Google_IO_Abstract' => array( + 'request_timeout_seconds' => 100, + ), 'Google_Http_Request' => array( - // Disable the use of gzip on calls if set to true. - 'disable_gzip' => false + // Disable the use of gzip on calls if set to true. Defaults to false. + 'disable_gzip' => self::GZIP_ENABLED, + + // We default gzip to disabled on uploads even if gzip is otherwise + // enabled, due to some issues seen with small packet sizes for uploads. + // Please test with this option before enabling gzip for uploads in + // a production environment. + 'enable_gzip_for_uploads' => self::GZIP_UPLOADS_DISABLED, ), + // If you want to pass in OAuth 2.0 settings, they will need to be + // structured like this. 'Google_Auth_OAuth2' => array( // Keys for OAuth 2.0 access, see the API console at // https://developers.google.com/console @@ -64,9 +78,14 @@ class Google_Config 'developer_key' => '', // Other parameters. + 'hd' => '', + 'prompt' => '', + 'openid.realm' => '', + 'include_granted_scopes' => '', + 'login_hint' => '', + 'request_visible_actions' => '', 'access_type' => 'online', 'approval_prompt' => 'auto', - 'request_visible_actions' => '', 'federated_signon_certs_url' => 'https://www.googleapis.com/oauth2/v1/certs', ), @@ -75,11 +94,6 @@ class Google_Config 'directory' => sys_get_temp_dir() . '/Google_Client' ) ), - - // Definition of service specific values like scopes, oauth token URLs, - // etc. Example: - 'services' => array( - ), ); if ($ini_file_location) { $ini = parse_ini_file($ini_file_location, true); @@ -108,7 +122,7 @@ class Google_Config $this->configuration['classes'][$class] = $config; } } - + public function getClassConfig($class, $key = null) { if (!isset($this->configuration['classes'][$class])) { @@ -138,7 +152,7 @@ class Google_Config { return $this->configuration['auth_class']; } - + /** * Set the auth class. * @@ -154,7 +168,7 @@ class Google_Config } $this->configuration['auth_class'] = $class; } - + /** * Set the IO class. * @@ -267,7 +281,16 @@ class Google_Config { $this->setAuthConfig('approval_prompt', $approval); } - + + /** + * Set the login hint (email address or sub identifier) + * @param $hint string + */ + public function setLoginHint($hint) + { + $this->setAuthConfig('login_hint', $hint); + } + /** * Set the developer key for the auth class. Note that this is separate value * from the client ID - if it looks like a URL, its a client ID! @@ -279,13 +302,60 @@ class Google_Config } /** + * Set the hd (hosted domain) parameter streamlines the login process for + * Google Apps hosted accounts. By including the domain of the user, you + * restrict sign-in to accounts at that domain. + * @param $hd string - the domain to use. + */ + public function setHostedDomain($hd) + { + $this->setAuthConfig('hd', $hd); + } + + /** + * Set the prompt hint. Valid values are none, consent and select_account. + * If no value is specified and the user has not previously authorized + * access, then the user is shown a consent screen. + * @param $prompt string + */ + public function setPrompt($prompt) + { + $this->setAuthConfig('prompt', $prompt); + } + + /** + * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth + * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which + * an authentication request is valid. + * @param $realm string - the URL-space to use. + */ + public function setOpenidRealm($realm) + { + $this->setAuthConfig('openid.realm', $realm); + } + + /** + * If this is provided with the value true, and the authorization request is + * granted, the authorization will include any previous authorizations + * granted to this user/application combination for other scopes. + * @param $include boolean - the URL-space to use. + */ + public function setIncludeGrantedScopes($include) + { + $this->setAuthConfig( + 'include_granted_scopes', + $include ? "true" : "false" + ); + } + + /** * @return string the base URL to use for API calls */ public function getBasePath() { return $this->configuration['base_path']; } - + /** * Set the auth configuration for the current auth class. * @param $key - the key to set diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php index b96db84b3e7..8005db4bb48 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php @@ -51,17 +51,23 @@ class Google_Http_MediaFileUpload /** @var int $progress */ private $progress; - + /** @var Google_Client */ private $client; - + /** @var Google_Http_Request */ private $request; - + /** @var string */ private $boundary; /** + * Result code from last HTTP call + * @var int + */ + private $httpResultCode; + + /** * @param $mimeType string * @param $data string The bytes you want to upload. * @param $resumable bool @@ -89,7 +95,7 @@ class Google_Http_MediaFileUpload $this->chunkSize = $chunkSize; $this->progress = 0; $this->boundary = $boundary; - + // Process Media Request $this->process(); } @@ -102,8 +108,8 @@ class Google_Http_MediaFileUpload { $this->size = $size; } - - /** + + /** * Return the progress on the upload * @return int progress in bytes uploaded. */ @@ -111,7 +117,16 @@ class Google_Http_MediaFileUpload { return $this->progress; } - + + /** + * Return the HTTP result code from the last call made. + * @return int code + */ + public function getHttpResultCode() + { + return $this->httpResultCode; + } + /** * Send the next part of the file to upload. * @param [$chunk] the next set of bytes to send. If false will used $data passed @@ -141,22 +156,29 @@ class Google_Http_MediaFileUpload $headers, $chunk ); - $httpRequest->disableGzip(); // Disable gzip for uploads. + + if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) { + $httpRequest->enableGzip(); + } else { + $httpRequest->disableGzip(); + } + $response = $this->client->getIo()->makeRequest($httpRequest); $response->setExpectedClass($this->request->getExpectedClass()); $code = $response->getResponseHttpCode(); + $this->httpResultCode = $code; if (308 == $code) { // Track the amount uploaded. $range = explode('-', $response->getResponseHeader('range')); $this->progress = $range[1] + 1; - + // Allow for changing upload URLs. $location = $response->getResponseHeader('location'); if ($location) { $this->resumeUri = $location; } - + // No problems, but upload not complete. return false; } else { @@ -177,7 +199,7 @@ class Google_Http_MediaFileUpload $meta = $this->request->getPostBody(); $meta = is_string($meta) ? json_decode($meta, true) : $meta; - + $uploadType = $this->getUploadType($meta); $this->request->setQueryParam('uploadType', $uploadType); $this->transformToUploadUrl(); @@ -214,7 +236,7 @@ class Google_Http_MediaFileUpload $this->request->setRequestHeaders($contentTypeHeader); } } - + private function transformToUploadUrl() { $base = $this->request->getBaseComponent(); @@ -265,6 +287,15 @@ class Google_Http_MediaFileUpload if (200 == $code && true == $location) { return $location; } - throw new Google_Exception("Failed to start the resumable upload"); + $message = $code; + $body = @json_decode($response->getResponseBody()); + if (!empty( $body->error->errors ) ) { + $message .= ': '; + foreach ($body->error->errors as $error) { + $message .= "{$error->domain}, {$error->message};"; + } + $message = rtrim($message, ';'); + } + throw new Google_Exception("Failed to start the resumable upload (HTTP {$message})"); } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php index 5ea4b752808..3c318e44ceb 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php @@ -44,7 +44,6 @@ class Google_Http_REST return self::decodeHttpResponse($httpRequest); } - /** * Decode an HTTP Response. * @static @@ -57,7 +56,7 @@ class Google_Http_REST $code = $response->getResponseHttpCode(); $body = $response->getResponseBody(); $decoded = null; - + if ((intVal($code)) >= 300) { $decoded = json_decode($body, true); $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl(); @@ -79,7 +78,7 @@ class Google_Http_REST throw new Google_Service_Exception($err, $code, null, $errors); } - + // Only attempt to decode the response, if the response code wasn't (204) 'no content' if ($code != '204') { $decoded = json_decode($body, true); @@ -87,8 +86,6 @@ class Google_Http_REST throw new Google_Service_Exception("Invalid json in service response: $body"); } - $decoded = isset($decoded['data']) ? $decoded['data'] : $decoded; - if ($response->getExpectedClass()) { $class = $response->getExpectedClass(); $decoded = new $class($decoded); diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Abstract.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Abstract.php index 6367b5da40a..a4025e874ad 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Abstract.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Abstract.php @@ -26,8 +26,13 @@ require_once 'Google/Http/Request.php'; abstract class Google_IO_Abstract { + const UNKNOWN_CODE = 0; const FORM_URLENCODED = 'application/x-www-form-urlencoded'; - const CONNECTION_ESTABLISHED = "HTTP/1.0 200 Connection established\r\n\r\n"; + private static $CONNECTION_ESTABLISHED_HEADERS = array( + "HTTP/1.0 200 Connection established\r\n\r\n", + "HTTP/1.1 200 Connection established\r\n\r\n", + ); + private static $ENTITY_HTTP_METHODS = array("POST" => null, "PUT" => null); /** @var Google_Client */ protected $client; @@ -35,6 +40,10 @@ abstract class Google_IO_Abstract public function __construct(Google_Client $client) { $this->client = $client; + $timeout = $client->getClassConfig('Google_IO_Abstract', 'request_timeout_seconds'); + if ($timeout > 0) { + $this->setTimeout($timeout); + } } /** @@ -42,13 +51,36 @@ abstract class Google_IO_Abstract * @param Google_Http_Request $request * @return Google_Http_Request $request */ - abstract public function makeRequest(Google_Http_Request $request); + abstract public function executeRequest(Google_Http_Request $request); /** * Set options that update the transport implementation's behavior. * @param $options */ abstract public function setOptions($options); + + /** + * Set the maximum request time in seconds. + * @param $timeout in seconds + */ + abstract public function setTimeout($timeout); + + /** + * Get the maximum request time in seconds. + * @return timeout in seconds + */ + abstract public function getTimeout(); + + /** + * Test for the presence of a cURL header processing bug + * + * The cURL bug was present in versions prior to 7.30.0 and caused the header + * length to be miscalculated when a "Connection established" header added by + * some proxies was present. + * + * @return boolean + */ + abstract protected function needsQuirk(); /** * @visible for testing. @@ -67,6 +99,49 @@ abstract class Google_IO_Abstract return false; } + + /** + * Execute an HTTP Request + * + * @param Google_HttpRequest $request the http request to be executed + * @return Google_HttpRequest http request with the response http code, + * response headers and response body filled in + * @throws Google_IO_Exception on curl or IO error + */ + public function makeRequest(Google_Http_Request $request) + { + // First, check to see if we have a valid cached version. + $cached = $this->getCachedRequest($request); + if ($cached !== false && $cached instanceof Google_Http_Request) { + if (!$this->checkMustRevalidateCachedRequest($cached, $request)) { + return $cached; + } + } + + if (array_key_exists($request->getRequestMethod(), self::$ENTITY_HTTP_METHODS)) { + $request = $this->processEntityRequest($request); + } + + list($responseData, $responseHeaders, $respHttpCode) = $this->executeRequest($request); + + if ($respHttpCode == 304 && $cached) { + // If the server responded NOT_MODIFIED, return the cached request. + $this->updateCachedRequest($cached, $responseHeaders); + return $cached; + } + + if (!isset($responseHeaders['Date']) && !isset($responseHeaders['date'])) { + $responseHeaders['Date'] = date("r"); + } + + $request->setResponseHttpCode($respHttpCode); + $request->setResponseHeaders($responseHeaders); + $request->setResponseBody($responseData); + // Store the request in cache (the function checks to see if the request + // can actually be cached) + $this->setCachedRequest($request); + return $request; + } /** * @visible for testing. @@ -177,15 +252,29 @@ abstract class Google_IO_Abstract */ public function parseHttpResponse($respData, $headerSize) { - if (stripos($respData, self::CONNECTION_ESTABLISHED) !== false) { - $respData = str_ireplace(self::CONNECTION_ESTABLISHED, '', $respData); + // check proxy header + foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) { + if (stripos($respData, $established_header) !== false) { + // existed, remove it + $respData = str_ireplace($established_header, '', $respData); + // Subtract the proxy header size unless the cURL bug prior to 7.30.0 + // is present which prevented the proxy header size from being taken into + // account. + if (!$this->needsQuirk()) { + $headerSize -= strlen($established_header); + } + break; + } } if ($headerSize) { $responseBody = substr($respData, $headerSize); $responseHeaders = substr($respData, 0, $headerSize); } else { - list($responseHeaders, $responseBody) = explode("\r\n\r\n", $respData, 2); + $responseSegments = explode("\r\n\r\n", $respData, 2); + $responseHeaders = $responseSegments[0]; + $responseBody = isset($responseSegments[1]) ? $responseSegments[1] : + null; } $responseHeaders = $this->getHttpResponseHeaders($responseHeaders); @@ -209,13 +298,12 @@ abstract class Google_IO_Abstract private function parseStringHeaders($rawHeaders) { $headers = array(); - $responseHeaderLines = explode("\r\n", $rawHeaders); foreach ($responseHeaderLines as $headerLine) { if ($headerLine && strpos($headerLine, ':') !== false) { list($header, $value) = explode(': ', $headerLine, 2); $header = strtolower($header); - if (isset($responseHeaders[$header])) { + if (isset($headers[$header])) { $headers[$header] .= "\n" . $value; } else { $headers[$header] = $value; diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Curl.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Curl.php new file mode 100644 index 00000000000..57a057114cc --- /dev/null +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Curl.php @@ -0,0 +1,137 @@ +<?php +/* + * Copyright 2014 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Curl based implementation of Google_IO. + * + * @author Stuart Langley <slangley@google.com> + */ + +require_once 'Google/IO/Abstract.php'; + +class Google_IO_Curl extends Google_IO_Abstract +{ + // cURL hex representation of version 7.30.0 + const NO_QUIRK_VERSION = 0x071E00; + + private $options = array(); + /** + * Execute an HTTP Request + * + * @param Google_HttpRequest $request the http request to be executed + * @return Google_HttpRequest http request with the response http code, + * response headers and response body filled in + * @throws Google_IO_Exception on curl or IO error + */ + public function executeRequest(Google_Http_Request $request) + { + $curl = curl_init(); + + if ($request->getPostBody()) { + curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody()); + } + + $requestHeaders = $request->getRequestHeaders(); + if ($requestHeaders && is_array($requestHeaders)) { + $curlHeaders = array(); + foreach ($requestHeaders as $k => $v) { + $curlHeaders[] = "$k: $v"; + } + curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders); + } + + curl_setopt($curl, CURLOPT_URL, $request->getUrl()); + + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod()); + curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent()); + + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HEADER, true); + + if ($request->canGzip()) { + curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); + } + + foreach ($this->options as $key => $var) { + curl_setopt($curl, $key, $var); + } + + if (!isset($this->options[CURLOPT_CAINFO])) { + curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem'); + } + + $response = curl_exec($curl); + if ($response === false) { + throw new Google_IO_Exception(curl_error($curl)); + } + $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); + + list($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize); + + $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + return array($responseBody, $responseHeaders, $responseCode); + } + + /** + * Set options that update the transport implementation's behavior. + * @param $options + */ + public function setOptions($options) + { + $this->options = $options + $this->options; + } + + /** + * Set the maximum request time in seconds. + * @param $timeout in seconds + */ + public function setTimeout($timeout) + { + // Since this timeout is really for putting a bound on the time + // we'll set them both to the same. If you need to specify a longer + // CURLOPT_TIMEOUT, or a tigher CONNECTTIMEOUT, the best thing to + // do is use the setOptions method for the values individually. + $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout; + $this->options[CURLOPT_TIMEOUT] = $timeout; + } + + /** + * Get the maximum request time in seconds. + * @return timeout in seconds + */ + public function getTimeout() + { + return $this->options[CURLOPT_TIMEOUT]; + } + + /** + * Test for the presence of a cURL header processing bug + * + * {@inheritDoc} + * + * @return boolean + */ + protected function needsQuirk() + { + $ver = curl_version(); + $versionNum = $ver['version_number']; + return $versionNum < Google_IO_Curl::NO_QUIRK_VERSION; + } +} diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Stream.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Stream.php index d73e0e98356..917578d87a0 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Stream.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Stream.php @@ -25,8 +25,11 @@ require_once 'Google/IO/Abstract.php'; class Google_IO_Stream extends Google_IO_Abstract { + const TIMEOUT = "timeout"; const ZLIB = "compress.zlib://"; - private static $ENTITY_HTTP_METHODS = array("POST" => null, "PUT" => null); + private $options = array(); + private $trappedErrorNumber; + private $trappedErrorString; private static $DEFAULT_HTTP_CONTEXT = array( "follow_location" => 0, @@ -45,26 +48,12 @@ class Google_IO_Stream extends Google_IO_Abstract * response headers and response body filled in * @throws Google_IO_Exception on curl or IO error */ - public function makeRequest(Google_Http_Request $request) + public function executeRequest(Google_Http_Request $request) { - // First, check to see if we have a valid cached version. - $cached = $this->getCachedRequest($request); - if ($cached !== false) { - if (!$this->checkMustRevalidateCachedRequest($cached, $request)) { - return $cached; - } - } - $default_options = stream_context_get_options(stream_context_get_default()); $requestHttpContext = array_key_exists('http', $default_options) ? $default_options['http'] : array(); - if (array_key_exists( - $request->getRequestMethod(), - self::$ENTITY_HTTP_METHODS - )) { - $request = $this->processEntityRequest($request); - } if ($request->getPostBody()) { $requestHttpContext["content"] = $request->getPostBody(); @@ -101,43 +90,60 @@ class Google_IO_Stream extends Google_IO_Abstract ); $context = stream_context_create($options); - + $url = $request->getUrl(); - + if ($request->canGzip()) { $url = self::ZLIB . $url; } - $response_data = file_get_contents( - $url, - false, - $context - ); - - if (false === $response_data) { - throw new Google_IO_Exception("HTTP Error: Unable to connect"); + // We are trapping any thrown errors in this method only and + // throwing an exception. + $this->trappedErrorNumber = null; + $this->trappedErrorString = null; + + // START - error trap. + set_error_handler(array($this, 'trapError')); + $fh = fopen($url, 'r', false, $context); + restore_error_handler(); + // END - error trap. + + if ($this->trappedErrorNumber) { + throw new Google_IO_Exception( + sprintf( + "HTTP Error: Unable to connect: '%s'", + $this->trappedErrorString + ), + $this->trappedErrorNumber + ); } - $respHttpCode = $this->getHttpResponseCode($http_response_header); - $responseHeaders = $this->getHttpResponseHeaders($http_response_header); + $response_data = false; + $respHttpCode = self::UNKNOWN_CODE; + if ($fh) { + if (isset($this->options[self::TIMEOUT])) { + stream_set_timeout($fh, $this->options[self::TIMEOUT]); + } + + $response_data = stream_get_contents($fh); + fclose($fh); - if ($respHttpCode == 304 && $cached) { - // If the server responded NOT_MODIFIED, return the cached request. - $this->updateCachedRequest($cached, $responseHeaders); - return $cached; + $respHttpCode = $this->getHttpResponseCode($http_response_header); } - if (!isset($responseHeaders['Date']) && !isset($responseHeaders['date'])) { - $responseHeaders['Date'] = date("r"); + if (false === $response_data) { + throw new Google_IO_Exception( + sprintf( + "HTTP Error: Unable to connect: '%s'", + $respHttpCode + ), + $respHttpCode + ); } - $request->setResponseHttpCode($respHttpCode); - $request->setResponseHeaders($responseHeaders); - $request->setResponseBody($response_data); - // Store the request in cache (the function checks to see if the request - // can actually be cached) - $this->setCachedRequest($request); - return $request; + $responseHeaders = $this->getHttpResponseHeaders($http_response_header); + + return array($response_data, $responseHeaders, $respHttpCode); } /** @@ -146,10 +152,50 @@ class Google_IO_Stream extends Google_IO_Abstract */ public function setOptions($options) { - // NO-OP + $this->options = $options + $this->options; + } + + /** + * Method to handle errors, used for error handling around + * stream connection methods. + */ + public function trapError($errno, $errstr) + { + $this->trappedErrorNumber = $errno; + $this->trappedErrorString = $errstr; + } + + /** + * Set the maximum request time in seconds. + * @param $timeout in seconds + */ + public function setTimeout($timeout) + { + $this->options[self::TIMEOUT] = $timeout; + } + + /** + * Get the maximum request time in seconds. + * @return timeout in seconds + */ + public function getTimeout() + { + return $this->options[self::TIMEOUT]; + } + + /** + * Test for the presence of a cURL header processing bug + * + * {@inheritDoc} + * + * @return boolean + */ + protected function needsQuirk() + { + return false; } - private function getHttpResponseCode($response_headers) + protected function getHttpResponseCode($response_headers) { $header_count = count($response_headers); @@ -160,6 +206,6 @@ class Google_IO_Stream extends Google_IO_Abstract return $response[1]; } } - return 'UNKNOWN'; + return self::UNKNOWN_CODE; } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Model.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Model.php index 2b6e67ad5a0..2bb9a333d66 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Model.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Model.php @@ -16,7 +16,7 @@ */ /** - * This class defines attributes, valid values, and usage which is generated + * This class defines attributes, valid values, and usage which is generated * from a given json schema. * http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5 * @@ -25,7 +25,8 @@ */ class Google_Model implements ArrayAccess { - protected $data = array(); + protected $internal_gapi_mappings = array(); + protected $modelData = array(); protected $processed = array(); /** @@ -34,7 +35,7 @@ class Google_Model implements ArrayAccess */ public function __construct() { - if (func_num_args() == 1 && is_array(func_get_arg(0))) { + if (func_num_args() == 1 && is_array(func_get_arg(0))) { // Initialize the model with the array's contents. $array = func_get_arg(0); $this->mapTypes($array); @@ -46,20 +47,23 @@ class Google_Model implements ArrayAccess $keyTypeName = $this->keyType($key); $keyDataType = $this->dataType($key); if (isset($this->$keyTypeName) && !isset($this->processed[$key])) { - if (isset($this->data[$key])) { - $val = $this->data[$key]; + if (isset($this->modelData[$key])) { + $val = $this->modelData[$key]; + } else if (isset($this->$keyDataType) && + ($this->$keyDataType == 'array' || $this->$keyDataType == 'map')) { + $val = array(); } else { $val = null; } - + if ($this->isAssociativeArray($val)) { if (isset($this->$keyDataType) && 'map' == $this->$keyDataType) { foreach ($val as $arrayKey => $arrayItem) { - $this->data[$key][$arrayKey] = + $this->modelData[$key][$arrayKey] = $this->createObjectFromName($keyTypeName, $arrayItem); } } else { - $this->data[$key] = $this->createObjectFromName($keyTypeName, $val); + $this->modelData[$key] = $this->createObjectFromName($keyTypeName, $val); } } else if (is_array($val)) { $arrayObject = array(); @@ -67,12 +71,12 @@ class Google_Model implements ArrayAccess $arrayObject[$arrayIndex] = $this->createObjectFromName($keyTypeName, $arrayItem); } - $this->data[$key] = $arrayObject; + $this->modelData[$key] = $arrayObject; } $this->processed[$key] = true; } - return $this->data[$key]; + return isset($this->modelData[$key]) ? $this->modelData[$key] : null; } /** @@ -95,9 +99,9 @@ class Google_Model implements ArrayAccess $this->$camelKey = $val; } } - $this->data = $array; + $this->modelData = $array; } - + /** * Create a simplified object suitable for straightforward * conversion to JSON. This is relatively expensive @@ -108,27 +112,29 @@ class Google_Model implements ArrayAccess { $object = new stdClass(); + // Process all other data. + foreach ($this->modelData as $key => $val) { + $result = $this->getSimpleValue($val); + if ($result !== null) { + $object->$key = $result; + } + } + // Process all public properties. $reflect = new ReflectionObject($this); $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC); foreach ($props as $member) { $name = $member->getName(); $result = $this->getSimpleValue($this->$name); - if ($result != null) { + if ($result !== null) { + $name = $this->getMappedName($name); $object->$name = $result; } } - // Process all other data. - foreach ($this->data as $key => $val) { - $result = $this->getSimpleValue($val); - if ($result != null) { - $object->$key = $result; - } - } return $object; } - + /** * Handle different types of values, primarily * other objects and map and array data types. @@ -141,7 +147,8 @@ class Google_Model implements ArrayAccess $return = array(); foreach ($value as $key => $a_value) { $a_value = $this->getSimpleValue($a_value); - if ($a_value != null) { + if ($a_value !== null) { + $key = $this->getMappedName($key); $return[$key] = $a_value; } } @@ -151,6 +158,18 @@ class Google_Model implements ArrayAccess } /** + * If there is an internal name mapping, use that. + */ + private function getMappedName($key) + { + if (isset($this->internal_gapi_mappings) && + isset($this->internal_gapi_mappings[$key])) { + $key = $this->internal_gapi_mappings[$key]; + } + return $key; + } + + /** * Returns true only if the array is associative. * @param array $array * @return bool True if the array is associative. @@ -192,15 +211,14 @@ class Google_Model implements ArrayAccess { if ($obj && !is_array($obj)) { throw new Google_Exception( - "Incorrect parameter type passed to $method()," - . " expected an array." + "Incorrect parameter type passed to $method(). Expected an array." ); } } public function offsetExists($offset) { - return isset($this->$offset) || isset($this->data[$offset]); + return isset($this->$offset) || isset($this->modelData[$offset]); } public function offsetGet($offset) @@ -215,14 +233,14 @@ class Google_Model implements ArrayAccess if (property_exists($this, $offset)) { $this->$offset = $value; } else { - $this->data[$offset] = $value; + $this->modelData[$offset] = $value; $this->processed[$offset] = true; } } public function offsetUnset($offset) { - unset($this->data[$offset]); + unset($this->modelData[$offset]); } protected function keyType($key) @@ -234,4 +252,14 @@ class Google_Model implements ArrayAccess { return $key . "DataType"; } + + public function __isset($key) + { + return isset($this->modelData[$key]); + } + + public function __unset($key) + { + unset($this->modelData[$key]); + } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Service/Drive.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Service/Drive.php index a9ce7f2a1cc..291a6091232 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Service/Drive.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Service/Drive.php @@ -119,7 +119,20 @@ class Google_Service_Drive extends Google_Service ),'list' => array( 'path' => 'apps', 'httpMethod' => 'GET', - 'parameters' => array(), + 'parameters' => array( + 'languageCode' => array( + 'location' => 'query', + 'type' => 'string', + ), + 'appFilterExtensions' => array( + 'location' => 'query', + 'type' => 'string', + ), + 'appFilterMimeTypes' => array( + 'location' => 'query', + 'type' => 'string', + ), + ), ), ) ) @@ -444,6 +457,10 @@ class Google_Service_Drive extends Google_Service 'required' => true, ), ), + ),'emptyTrash' => array( + 'path' => 'files/trash', + 'httpMethod' => 'DELETE', + 'parameters' => array(), ),'get' => array( 'path' => 'files/{fileId}', 'httpMethod' => 'GET', @@ -511,6 +528,10 @@ class Google_Service_Drive extends Google_Service 'location' => 'query', 'type' => 'string', ), + 'corpus' => array( + 'location' => 'query', + 'type' => 'string', + ), 'projection' => array( 'location' => 'query', 'type' => 'string', @@ -529,18 +550,26 @@ class Google_Service_Drive extends Google_Service 'type' => 'string', 'required' => true, ), - 'convert' => array( + 'addParents' => array( 'location' => 'query', - 'type' => 'boolean', + 'type' => 'string', ), 'updateViewedDate' => array( 'location' => 'query', 'type' => 'boolean', ), + 'removeParents' => array( + 'location' => 'query', + 'type' => 'string', + ), 'setModifiedDate' => array( 'location' => 'query', 'type' => 'boolean', ), + 'convert' => array( + 'location' => 'query', + 'type' => 'boolean', + ), 'useContentAsIndexableText' => array( 'location' => 'query', 'type' => 'boolean', @@ -609,18 +638,26 @@ class Google_Service_Drive extends Google_Service 'type' => 'string', 'required' => true, ), - 'convert' => array( + 'addParents' => array( 'location' => 'query', - 'type' => 'boolean', + 'type' => 'string', ), 'updateViewedDate' => array( 'location' => 'query', 'type' => 'boolean', ), + 'removeParents' => array( + 'location' => 'query', + 'type' => 'string', + ), 'setModifiedDate' => array( 'location' => 'query', 'type' => 'boolean', ), + 'convert' => array( + 'location' => 'query', + 'type' => 'boolean', + ), 'useContentAsIndexableText' => array( 'location' => 'query', 'type' => 'boolean', @@ -969,6 +1006,10 @@ class Google_Service_Drive extends Google_Service 'type' => 'string', 'required' => true, ), + 'revision' => array( + 'location' => 'query', + 'type' => 'integer', + ), ), ),'update' => array( 'path' => 'files/{fileId}/realtime', @@ -1226,9 +1267,9 @@ class Google_Service_Drive_About_Resource extends Google_Service_Resource * @param array $optParams Optional parameters. * * @opt_param bool includeSubscribed - * When calculating the number of remaining change IDs, whether to include shared files and public - * files the user has opened. When set to false, this counts only change IDs for owned files and - * any shared or public files that the user has explictly added to a folder in Drive. + * When calculating the number of remaining change IDs, whether to include public files the user + * has opened and shared files. When set to false, this counts only change IDs for owned files and + * any shared or public files that the user has explicitly added to a folder they own. * @opt_param string maxChangeIdCount * Maximum number of remaining change IDs to count * @opt_param string startChangeId @@ -1272,6 +1313,18 @@ class Google_Service_Drive_Apps_Resource extends Google_Service_Resource * Lists a user's installed apps. (apps.listApps) * * @param array $optParams Optional parameters. + * + * @opt_param string languageCode + * A language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format + * (http://www.unicode.org/reports/tr35/). + * @opt_param string appFilterExtensions + * A comma-separated list of file extensions for open with filtering. All apps within the given app + * query scope which can open any of the given file extensions will be included in the response. If + * appFilterMimeTypes are provided as well, the result is a union of the two resulting app lists. + * @opt_param string appFilterMimeTypes + * A comma-separated list of MIME types for open with filtering. All apps within the given app + * query scope which can open any of the given MIME types will be included in the response. If + * appFilterExtensions are provided as well, the result is a union of the two resulting app lists. * @return Google_Service_Drive_AppList */ public function listApps($optParams = array()) @@ -1313,9 +1366,9 @@ class Google_Service_Drive_Changes_Resource extends Google_Service_Resource * @param array $optParams Optional parameters. * * @opt_param bool includeSubscribed - * Whether to include shared files and public files the user has opened. When set to false, the - * list will include owned files plus any shared or public files the user has explictly added to a - * folder in Drive. + * Whether to include public files the user has opened and shared files. When set to false, the + * list only includes owned files plus any shared or public files the user has explicitly added to + * a folder they own. * @opt_param string startChangeId * Change ID to start listing changes from. * @opt_param bool includeDeleted @@ -1339,9 +1392,9 @@ class Google_Service_Drive_Changes_Resource extends Google_Service_Resource * @param array $optParams Optional parameters. * * @opt_param bool includeSubscribed - * Whether to include shared files and public files the user has opened. When set to false, the - * list will include owned files plus any shared or public files the user has explictly added to a - * folder in Drive. + * Whether to include public files the user has opened and shared files. When set to false, the + * list only includes owned files plus any shared or public files the user has explicitly added to + * a folder they own. * @opt_param string startChangeId * Change ID to start listing changes from. * @opt_param bool includeDeleted @@ -1616,7 +1669,8 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource * The visibility of the new file. This parameter is only relevant when the source is not a native * Google Doc and convert=false. * @opt_param bool pinned - * Whether to pin the head revision of the new copy. + * Whether to pin the head revision of the new copy. A file can have a maximum of 200 pinned + * revisions. * @opt_param bool ocr * Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. * @opt_param string timedTextTrackName @@ -1645,6 +1699,17 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource return $this->call('delete', array($params)); } /** + * Permanently deletes all of the user's trashed files. (files.emptyTrash) + * + * @param array $optParams Optional parameters. + */ + public function emptyTrash($optParams = array()) + { + $params = array(); + $params = array_merge($params, $optParams); + return $this->call('emptyTrash', array($params)); + } + /** * Gets a file's metadata by ID. (files.get) * * @param string $fileId @@ -1678,7 +1743,8 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource * @opt_param string visibility * The visibility of the new file. This parameter is only relevant when convert=false. * @opt_param bool pinned - * Whether to pin the head revision of the uploaded file. + * Whether to pin the head revision of the uploaded file. A file can have a maximum of 200 pinned + * revisions. * @opt_param bool ocr * Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. * @opt_param string timedTextTrackName @@ -1702,6 +1768,8 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource * Query string for searching files. * @opt_param string pageToken * Page token for files. + * @opt_param string corpus + * The body of items (files/documents) to which the query applies. * @opt_param string projection * This parameter is deprecated and has no function. * @opt_param int maxResults @@ -1723,21 +1791,25 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource * @param Google_DriveFile $postBody * @param array $optParams Optional parameters. * - * @opt_param bool convert - * Whether to convert this file to the corresponding Google Docs format. + * @opt_param string addParents + * Comma-separated list of parent IDs to add. * @opt_param bool updateViewedDate * Whether to update the view date after successfully updating the file. + * @opt_param string removeParents + * Comma-separated list of parent IDs to remove. * @opt_param bool setModifiedDate * Whether to set the modified date with the supplied modified date. + * @opt_param bool convert + * Whether to convert this file to the corresponding Google Docs format. * @opt_param bool useContentAsIndexableText * Whether to use the content as indexable text. * @opt_param string ocrLanguage * If ocr is true, hints at the language to use. Valid values are ISO 639-1 codes. * @opt_param bool pinned - * Whether to pin the new revision. + * Whether to pin the new revision. A file can have a maximum of 200 pinned revisions. * @opt_param bool newRevision * Whether a blob upload should create a new revision. If false, the blob data in the current head - * revision is replaced. If not set or true, a new blob is created as head revision, and previous + * revision is replaced. If true or not set, a new blob is created as head revision, and previous * revisions are preserved (causing increased use of the user's data storage quota). * @opt_param bool ocr * Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. @@ -1803,21 +1875,25 @@ class Google_Service_Drive_Files_Resource extends Google_Service_Resource * @param Google_DriveFile $postBody * @param array $optParams Optional parameters. * - * @opt_param bool convert - * Whether to convert this file to the corresponding Google Docs format. + * @opt_param string addParents + * Comma-separated list of parent IDs to add. * @opt_param bool updateViewedDate * Whether to update the view date after successfully updating the file. + * @opt_param string removeParents + * Comma-separated list of parent IDs to remove. * @opt_param bool setModifiedDate * Whether to set the modified date with the supplied modified date. + * @opt_param bool convert + * Whether to convert this file to the corresponding Google Docs format. * @opt_param bool useContentAsIndexableText * Whether to use the content as indexable text. * @opt_param string ocrLanguage * If ocr is true, hints at the language to use. Valid values are ISO 639-1 codes. * @opt_param bool pinned - * Whether to pin the new revision. + * Whether to pin the new revision. A file can have a maximum of 200 pinned revisions. * @opt_param bool newRevision * Whether a blob upload should create a new revision. If false, the blob data in the current head - * revision is replaced. If not set or true, a new blob is created as head revision, and previous + * revision is replaced. If true or not set, a new blob is created as head revision, and previous * revisions are preserved (causing increased use of the user's data storage quota). * @opt_param bool ocr * Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. @@ -1995,7 +2071,8 @@ class Google_Service_Drive_Permissions_Resource extends Google_Service_Resource * @opt_param string emailMessage * A custom message to include in notification emails. * @opt_param bool sendNotificationEmails - * Whether to send notification emails when sharing to users or groups. + * Whether to send notification emails when sharing to users or groups. This parameter is ignored + * and an email is sent if the role is owner. * @return Google_Service_Drive_Permission */ public function insert($fileId, Google_Service_Drive_Permission $postBody, $optParams = array()) @@ -2198,6 +2275,11 @@ class Google_Service_Drive_Realtime_Resource extends Google_Service_Resource * @param string $fileId * The ID of the file that the Realtime API data model is associated with. * @param array $optParams Optional parameters. + * + * @opt_param int revision + * The revision of the Realtime API data model to export. Revisions start at 1 (the initial empty + * data model) and are incremented with each change. If this parameter is excluded, the most recent + * data model will be returned. */ public function get($fileId, $optParams = array()) { @@ -2455,6 +2537,9 @@ class Google_Service_Drive_Revisions_Resource extends Google_Service_Resource class Google_Service_Drive_About extends Google_Collection { + protected $collection_key = 'quotaBytesByService'; + protected $internal_gapi_mappings = array( + ); protected $additionalRoleInfoType = 'Google_Service_Drive_AboutAdditionalRoleInfo'; protected $additionalRoleInfoDataType = 'array'; public $domainSharingPolicy; @@ -2467,15 +2552,19 @@ class Google_Service_Drive_About extends Google_Collection protected $importFormatsDataType = 'array'; public $isCurrentAppInstalled; public $kind; + public $languageCode; public $largestChangeId; protected $maxUploadSizesType = 'Google_Service_Drive_AboutMaxUploadSizes'; protected $maxUploadSizesDataType = 'array'; public $name; public $permissionId; + protected $quotaBytesByServiceType = 'Google_Service_Drive_AboutQuotaBytesByService'; + protected $quotaBytesByServiceDataType = 'array'; public $quotaBytesTotal; public $quotaBytesUsed; public $quotaBytesUsedAggregate; public $quotaBytesUsedInTrash; + public $quotaType; public $remainingChangeIds; public $rootFolderId; public $selfLink; @@ -2562,6 +2651,16 @@ class Google_Service_Drive_About extends Google_Collection return $this->kind; } + public function setLanguageCode($languageCode) + { + $this->languageCode = $languageCode; + } + + public function getLanguageCode() + { + return $this->languageCode; + } + public function setLargestChangeId($largestChangeId) { $this->largestChangeId = $largestChangeId; @@ -2602,6 +2701,16 @@ class Google_Service_Drive_About extends Google_Collection return $this->permissionId; } + public function setQuotaBytesByService($quotaBytesByService) + { + $this->quotaBytesByService = $quotaBytesByService; + } + + public function getQuotaBytesByService() + { + return $this->quotaBytesByService; + } + public function setQuotaBytesTotal($quotaBytesTotal) { $this->quotaBytesTotal = $quotaBytesTotal; @@ -2642,6 +2751,16 @@ class Google_Service_Drive_About extends Google_Collection return $this->quotaBytesUsedInTrash; } + public function setQuotaType($quotaType) + { + $this->quotaType = $quotaType; + } + + public function getQuotaType() + { + return $this->quotaType; + } + public function setRemainingChangeIds($remainingChangeIds) { $this->remainingChangeIds = $remainingChangeIds; @@ -2685,6 +2804,9 @@ class Google_Service_Drive_About extends Google_Collection class Google_Service_Drive_AboutAdditionalRoleInfo extends Google_Collection { + protected $collection_key = 'roleSets'; + protected $internal_gapi_mappings = array( + ); protected $roleSetsType = 'Google_Service_Drive_AboutAdditionalRoleInfoRoleSets'; protected $roleSetsDataType = 'array'; public $type; @@ -2712,6 +2834,9 @@ class Google_Service_Drive_AboutAdditionalRoleInfo extends Google_Collection class Google_Service_Drive_AboutAdditionalRoleInfoRoleSets extends Google_Collection { + protected $collection_key = 'additionalRoles'; + protected $internal_gapi_mappings = array( + ); public $additionalRoles; public $primaryRole; @@ -2738,6 +2863,9 @@ class Google_Service_Drive_AboutAdditionalRoleInfoRoleSets extends Google_Collec class Google_Service_Drive_AboutExportFormats extends Google_Collection { + protected $collection_key = 'targets'; + protected $internal_gapi_mappings = array( + ); public $source; public $targets; @@ -2764,6 +2892,8 @@ class Google_Service_Drive_AboutExportFormats extends Google_Collection class Google_Service_Drive_AboutFeatures extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $featureName; public $featureRate; @@ -2790,6 +2920,9 @@ class Google_Service_Drive_AboutFeatures extends Google_Model class Google_Service_Drive_AboutImportFormats extends Google_Collection { + protected $collection_key = 'targets'; + protected $internal_gapi_mappings = array( + ); public $source; public $targets; @@ -2816,6 +2949,8 @@ class Google_Service_Drive_AboutImportFormats extends Google_Collection class Google_Service_Drive_AboutMaxUploadSizes extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $size; public $type; @@ -2840,11 +2975,43 @@ class Google_Service_Drive_AboutMaxUploadSizes extends Google_Model } } +class Google_Service_Drive_AboutQuotaBytesByService extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); + public $bytesUsed; + public $serviceName; + + public function setBytesUsed($bytesUsed) + { + $this->bytesUsed = $bytesUsed; + } + + public function getBytesUsed() + { + return $this->bytesUsed; + } + + public function setServiceName($serviceName) + { + $this->serviceName = $serviceName; + } + + public function getServiceName() + { + return $this->serviceName; + } +} + class Google_Service_Drive_App extends Google_Collection { + protected $collection_key = 'secondaryMimeTypes'; + protected $internal_gapi_mappings = array( + ); public $authorized; public $createInFolderTemplate; public $createUrl; + public $hasDriveWideScope; protected $iconsType = 'Google_Service_Drive_AppIcons'; protected $iconsDataType = 'array'; public $id; @@ -2864,6 +3031,7 @@ class Google_Service_Drive_App extends Google_Collection public $supportsCreate; public $supportsImport; public $supportsMultiOpen; + public $supportsOfflineCreate; public $useByDefault; public function setAuthorized($authorized) @@ -2896,6 +3064,16 @@ class Google_Service_Drive_App extends Google_Collection return $this->createUrl; } + public function setHasDriveWideScope($hasDriveWideScope) + { + $this->hasDriveWideScope = $hasDriveWideScope; + } + + public function getHasDriveWideScope() + { + return $this->hasDriveWideScope; + } + public function setIcons($icons) { $this->icons = $icons; @@ -3076,6 +3254,16 @@ class Google_Service_Drive_App extends Google_Collection return $this->supportsMultiOpen; } + public function setSupportsOfflineCreate($supportsOfflineCreate) + { + $this->supportsOfflineCreate = $supportsOfflineCreate; + } + + public function getSupportsOfflineCreate() + { + return $this->supportsOfflineCreate; + } + public function setUseByDefault($useByDefault) { $this->useByDefault = $useByDefault; @@ -3089,6 +3277,8 @@ class Google_Service_Drive_App extends Google_Collection class Google_Service_Drive_AppIcons extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $category; public $iconUrl; public $size; @@ -3126,12 +3316,26 @@ class Google_Service_Drive_AppIcons extends Google_Model class Google_Service_Drive_AppList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); + public $defaultAppIds; public $etag; protected $itemsType = 'Google_Service_Drive_App'; protected $itemsDataType = 'array'; public $kind; public $selfLink; + public function setDefaultAppIds($defaultAppIds) + { + $this->defaultAppIds = $defaultAppIds; + } + + public function getDefaultAppIds() + { + return $this->defaultAppIds; + } + public function setEtag($etag) { $this->etag = $etag; @@ -3175,6 +3379,8 @@ class Google_Service_Drive_AppList extends Google_Collection class Google_Service_Drive_Change extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $deleted; protected $fileType = 'Google_Service_Drive_DriveFile'; protected $fileDataType = ''; @@ -3257,6 +3463,9 @@ class Google_Service_Drive_Change extends Google_Model class Google_Service_Drive_ChangeList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_Change'; protected $itemsDataType = 'array'; @@ -3339,6 +3548,8 @@ class Google_Service_Drive_ChangeList extends Google_Collection class Google_Service_Drive_Channel extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $address; public $expiration; public $id; @@ -3451,8 +3662,17 @@ class Google_Service_Drive_Channel extends Google_Model } } +class Google_Service_Drive_ChannelParams extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); +} + class Google_Service_Drive_ChildList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_ChildReference'; protected $itemsDataType = 'array'; @@ -3524,6 +3744,8 @@ class Google_Service_Drive_ChildList extends Google_Collection class Google_Service_Drive_ChildReference extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $childLink; public $id; public $kind; @@ -3572,6 +3794,9 @@ class Google_Service_Drive_ChildReference extends Google_Model class Google_Service_Drive_Comment extends Google_Collection { + protected $collection_key = 'replies'; + protected $internal_gapi_mappings = array( + ); public $anchor; protected $authorType = 'Google_Service_Drive_User'; protected $authorDataType = ''; @@ -3744,6 +3969,8 @@ class Google_Service_Drive_Comment extends Google_Collection class Google_Service_Drive_CommentContext extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $type; public $value; @@ -3770,6 +3997,9 @@ class Google_Service_Drive_CommentContext extends Google_Model class Google_Service_Drive_CommentList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); protected $itemsType = 'Google_Service_Drive_Comment'; protected $itemsDataType = 'array'; public $kind; @@ -3830,6 +4060,8 @@ class Google_Service_Drive_CommentList extends Google_Collection class Google_Service_Drive_CommentReply extends Google_Model { + protected $internal_gapi_mappings = array( + ); protected $authorType = 'Google_Service_Drive_User'; protected $authorDataType = ''; public $content; @@ -3934,6 +4166,9 @@ class Google_Service_Drive_CommentReply extends Google_Model class Google_Service_Drive_CommentReplyList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); protected $itemsType = 'Google_Service_Drive_CommentReply'; protected $itemsDataType = 'array'; public $kind; @@ -3994,6 +4229,9 @@ class Google_Service_Drive_CommentReplyList extends Google_Collection class Google_Service_Drive_DriveFile extends Google_Collection { + protected $collection_key = 'properties'; + protected $internal_gapi_mappings = array( + ); public $alternateLink; public $appDataContents; public $copyable; @@ -4022,6 +4260,7 @@ class Google_Service_Drive_DriveFile extends Google_Collection protected $lastModifyingUserDataType = ''; public $lastModifyingUserName; public $lastViewedByMeDate; + public $markedViewedByMeDate; public $md5Checksum; public $mimeType; public $modifiedByMeDate; @@ -4033,18 +4272,25 @@ class Google_Service_Drive_DriveFile extends Google_Collection protected $ownersDataType = 'array'; protected $parentsType = 'Google_Service_Drive_ParentReference'; protected $parentsDataType = 'array'; + protected $permissionsType = 'Google_Service_Drive_Permission'; + protected $permissionsDataType = 'array'; protected $propertiesType = 'Google_Service_Drive_Property'; protected $propertiesDataType = 'array'; public $quotaBytesUsed; public $selfLink; public $shared; public $sharedWithMeDate; + protected $sharingUserType = 'Google_Service_Drive_User'; + protected $sharingUserDataType = ''; protected $thumbnailType = 'Google_Service_Drive_DriveFileThumbnail'; protected $thumbnailDataType = ''; public $thumbnailLink; public $title; protected $userPermissionType = 'Google_Service_Drive_Permission'; protected $userPermissionDataType = ''; + public $version; + protected $videoMediaMetadataType = 'Google_Service_Drive_DriveFileVideoMediaMetadata'; + protected $videoMediaMetadataDataType = ''; public $webContentLink; public $webViewLink; public $writersCanShare; @@ -4289,6 +4535,16 @@ class Google_Service_Drive_DriveFile extends Google_Collection return $this->lastViewedByMeDate; } + public function setMarkedViewedByMeDate($markedViewedByMeDate) + { + $this->markedViewedByMeDate = $markedViewedByMeDate; + } + + public function getMarkedViewedByMeDate() + { + return $this->markedViewedByMeDate; + } + public function setMd5Checksum($md5Checksum) { $this->md5Checksum = $md5Checksum; @@ -4379,6 +4635,16 @@ class Google_Service_Drive_DriveFile extends Google_Collection return $this->parents; } + public function setPermissions($permissions) + { + $this->permissions = $permissions; + } + + public function getPermissions() + { + return $this->permissions; + } + public function setProperties($properties) { $this->properties = $properties; @@ -4429,6 +4695,16 @@ class Google_Service_Drive_DriveFile extends Google_Collection return $this->sharedWithMeDate; } + public function setSharingUser(Google_Service_Drive_User $sharingUser) + { + $this->sharingUser = $sharingUser; + } + + public function getSharingUser() + { + return $this->sharingUser; + } + public function setThumbnail(Google_Service_Drive_DriveFileThumbnail $thumbnail) { $this->thumbnail = $thumbnail; @@ -4469,6 +4745,26 @@ class Google_Service_Drive_DriveFile extends Google_Collection return $this->userPermission; } + public function setVersion($version) + { + $this->version = $version; + } + + public function getVersion() + { + return $this->version; + } + + public function setVideoMediaMetadata(Google_Service_Drive_DriveFileVideoMediaMetadata $videoMediaMetadata) + { + $this->videoMediaMetadata = $videoMediaMetadata; + } + + public function getVideoMediaMetadata() + { + return $this->videoMediaMetadata; + } + public function setWebContentLink($webContentLink) { $this->webContentLink = $webContentLink; @@ -4500,8 +4796,16 @@ class Google_Service_Drive_DriveFile extends Google_Collection } } +class Google_Service_Drive_DriveFileExportLinks extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); +} + class Google_Service_Drive_DriveFileImageMediaMetadata extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $aperture; public $cameraMake; public $cameraModel; @@ -4738,6 +5042,8 @@ class Google_Service_Drive_DriveFileImageMediaMetadata extends Google_Model class Google_Service_Drive_DriveFileImageMediaMetadataLocation extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $altitude; public $latitude; public $longitude; @@ -4775,6 +5081,8 @@ class Google_Service_Drive_DriveFileImageMediaMetadataLocation extends Google_Mo class Google_Service_Drive_DriveFileIndexableText extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $text; public function setText($text) @@ -4790,6 +5098,8 @@ class Google_Service_Drive_DriveFileIndexableText extends Google_Model class Google_Service_Drive_DriveFileLabels extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $hidden; public $restricted; public $starred; @@ -4847,8 +5157,16 @@ class Google_Service_Drive_DriveFileLabels extends Google_Model } } +class Google_Service_Drive_DriveFileOpenWithLinks extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); +} + class Google_Service_Drive_DriveFileThumbnail extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $image; public $mimeType; @@ -4873,8 +5191,50 @@ class Google_Service_Drive_DriveFileThumbnail extends Google_Model } } +class Google_Service_Drive_DriveFileVideoMediaMetadata extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); + public $durationMillis; + public $height; + public $width; + + public function setDurationMillis($durationMillis) + { + $this->durationMillis = $durationMillis; + } + + public function getDurationMillis() + { + return $this->durationMillis; + } + + public function setHeight($height) + { + $this->height = $height; + } + + public function getHeight() + { + return $this->height; + } + + public function setWidth($width) + { + $this->width = $width; + } + + public function getWidth() + { + return $this->width; + } +} + class Google_Service_Drive_FileList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_DriveFile'; protected $itemsDataType = 'array'; @@ -4946,6 +5306,9 @@ class Google_Service_Drive_FileList extends Google_Collection class Google_Service_Drive_ParentList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_ParentReference'; protected $itemsDataType = 'array'; @@ -4995,6 +5358,8 @@ class Google_Service_Drive_ParentList extends Google_Collection class Google_Service_Drive_ParentReference extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $id; public $isRoot; public $kind; @@ -5054,6 +5419,9 @@ class Google_Service_Drive_ParentReference extends Google_Model class Google_Service_Drive_Permission extends Google_Collection { + protected $collection_key = 'additionalRoles'; + protected $internal_gapi_mappings = array( + ); public $additionalRoles; public $authKey; public $domain; @@ -5212,6 +5580,8 @@ class Google_Service_Drive_Permission extends Google_Collection class Google_Service_Drive_PermissionId extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $id; public $kind; @@ -5238,6 +5608,9 @@ class Google_Service_Drive_PermissionId extends Google_Model class Google_Service_Drive_PermissionList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_Permission'; protected $itemsDataType = 'array'; @@ -5287,6 +5660,8 @@ class Google_Service_Drive_PermissionList extends Google_Collection class Google_Service_Drive_Property extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $etag; public $key; public $kind; @@ -5357,6 +5732,9 @@ class Google_Service_Drive_Property extends Google_Model class Google_Service_Drive_PropertyList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_Property'; protected $itemsDataType = 'array'; @@ -5406,6 +5784,8 @@ class Google_Service_Drive_PropertyList extends Google_Collection class Google_Service_Drive_Revision extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $downloadUrl; public $etag; public $exportLinks; @@ -5607,8 +5987,17 @@ class Google_Service_Drive_Revision extends Google_Model } } +class Google_Service_Drive_RevisionExportLinks extends Google_Model +{ + protected $internal_gapi_mappings = array( + ); +} + class Google_Service_Drive_RevisionList extends Google_Collection { + protected $collection_key = 'items'; + protected $internal_gapi_mappings = array( + ); public $etag; protected $itemsType = 'Google_Service_Drive_Revision'; protected $itemsDataType = 'array'; @@ -5658,7 +6047,10 @@ class Google_Service_Drive_RevisionList extends Google_Collection class Google_Service_Drive_User extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $displayName; + public $emailAddress; public $isAuthenticatedUser; public $kind; public $permissionId; @@ -5675,6 +6067,16 @@ class Google_Service_Drive_User extends Google_Model return $this->displayName; } + public function setEmailAddress($emailAddress) + { + $this->emailAddress = $emailAddress; + } + + public function getEmailAddress() + { + return $this->emailAddress; + } + public function setIsAuthenticatedUser($isAuthenticatedUser) { $this->isAuthenticatedUser = $isAuthenticatedUser; @@ -5718,6 +6120,8 @@ class Google_Service_Drive_User extends Google_Model class Google_Service_Drive_UserPicture extends Google_Model { + protected $internal_gapi_mappings = array( + ); public $url; public function setUrl($url) diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Signer/P12.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Signer/P12.php index 2c9d17927c8..7cc6098bb63 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Signer/P12.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Signer/P12.php @@ -39,23 +39,32 @@ class Google_Signer_P12 extends Google_Signer_Abstract ); } - // This throws on error - $certs = array(); - if (!openssl_pkcs12_read($p12, $certs, $password)) { - throw new Google_Auth_Exception( - "Unable to parse the p12 file. " . - "Is this a .p12 file? Is the password correct? OpenSSL error: " . - openssl_error_string() - ); + // If the private key is provided directly, then this isn't in the p12 + // format. Different versions of openssl support different p12 formats + // and the key from google wasn't being accepted by the version available + // at the time. + if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) { + $this->privateKey = openssl_pkey_get_private($p12); + } else { + // This throws on error + $certs = array(); + if (!openssl_pkcs12_read($p12, $certs, $password)) { + throw new Google_Auth_Exception( + "Unable to parse the p12 file. " . + "Is this a .p12 file? Is the password correct? OpenSSL error: " . + openssl_error_string() + ); + } + // TODO(beaton): is this part of the contract for the openssl_pkcs12_read + // method? What happens if there are multiple private keys? Do we care? + if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) { + throw new Google_Auth_Exception("No private key found in p12 file."); + } + $this->privateKey = openssl_pkey_get_private($certs['pkey']); } - // TODO(beaton): is this part of the contract for the openssl_pkcs12_read - // method? What happens if there are multiple private keys? Do we care? - if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) { - throw new Google_Auth_Exception("No private key found in p12 file."); - } - $this->privateKey = openssl_pkey_get_private($certs["pkey"]); + if (!$this->privateKey) { - throw new Google_Auth_Exception("Unable to load private key in "); + throw new Google_Auth_Exception("Unable to load private key"); } } @@ -73,7 +82,8 @@ class Google_Signer_P12 extends Google_Signer_Abstract "PHP 5.3.0 or higher is required to use service accounts." ); } - if (!openssl_sign($data, $signature, $this->privateKey, "sha256")) { + $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; + if (!openssl_sign($data, $signature, $this->privateKey, $hash)) { throw new Google_Auth_Exception("Unable to sign data"); } return $signature; diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils.php index a991066f2d9..f5ef32cd4d6 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils.php @@ -46,7 +46,7 @@ class Google_Utils /** * Misc function used to count the number of bytes in a post body, in the - * world of multi-byte chars and the unpredictability of + * world of multi-byte chars and the unpredictability of * strlen/mb_strlen/sizeof, this is the only way to do that in a sane * manner at the moment. * @@ -128,6 +128,8 @@ class Google_Utils public static function camelCase($value) { $value = ucwords(str_replace(array('-', '_'), ' ', $value)); - return lcfirst(str_replace(' ', '', $value)); + $value = str_replace(' ', '', $value); + $value[0] = strtolower($value[0]); + return $value; } } diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils/URITemplate.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils/URITemplate.php index fee56725dab..f5ee38bb333 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils/URITemplate.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Utils/URITemplate.php @@ -48,7 +48,7 @@ class Google_Utils_URITemplate */ private $reserved = array( "=", ",", "!", "@", "|", ":", "/", "?", "#", - "[", "]","$", "&", "'", "(", ")", "*", "+", ";" + "[", "]",'$', "&", "'", "(", ")", "*", "+", ";" ); private $reservedEncoded = array( "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F", diff --git a/apps/files_external/3rdparty/google-api-php-client/src/Google/Verifier/Pem.php b/apps/files_external/3rdparty/google-api-php-client/src/Google/Verifier/Pem.php index 8b4d1ab1640..f281575e172 100644 --- a/apps/files_external/3rdparty/google-api-php-client/src/Google/Verifier/Pem.php +++ b/apps/files_external/3rdparty/google-api-php-client/src/Google/Verifier/Pem.php @@ -64,7 +64,8 @@ class Google_Verifier_Pem extends Google_Verifier_Abstract */ public function verify($data, $signature) { - $status = openssl_verify($data, $signature, $this->publicKey, "sha256"); + $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; + $status = openssl_verify($data, $signature, $this->publicKey, $hash); if ($status === -1) { throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string()); } |