Skip to content

Commit

Permalink
MDL-37217 repository: Google Docs repository uses Google SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart authored and FMCorz committed Feb 19, 2013
1 parent 0acb074 commit 3425813
Show file tree
Hide file tree
Showing 6 changed files with 426 additions and 50 deletions.
24 changes: 12 additions & 12 deletions lib/google/curlio.php
Expand Up @@ -28,10 +28,10 @@

/**
* Class moodle_google_curlio.
*
*
* The initial purpose of this class is to add support for our
* class curl in Google_CurlIO.
*
*
* @package core_google
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down Expand Up @@ -125,31 +125,31 @@ public function makeRequest(Google_HttpRequest $request) {
'CURLOPT_USERAGENT' => $request->getUserAgent()
));

$respData = $this->do_request($curl, $request);
$respdata = $this->do_request($curl, $request);

// Retry if certificates are missing.
if ($curl->get_errno() == CURLE_SSL_CACERT) {
error_log('SSL certificate problem, verify that the CA cert is OK.' .
' Retrying with the CA cert bundle from google-api-php-client.');
$curl->setopt(array('CURLOPT_CAINFO' => dirname(__FILE__) . '/io/cacerts.pem'));
$respData = $this->do_request($curl, $request);
$respdata = $this->do_request($curl, $request);
}

$infos = $curl->get_info();
$respHeaderSize = $infos['header_size'];
$respHttpCode = (int) $infos['http_code'];
$curlErrorNum = $curl->get_errno();
$curlError = $curl->error;
$respheadersize = $infos['header_size'];
$resphttpcode = (int) $infos['http_code'];
$curlerrornum = $curl->get_errno();
$curlerror = $curl->error;

if ($curlErrorNum != CURLE_OK) {
throw new Google_IOException("HTTP Error: ($respHttpCode) $curlError");
if ($curlerrornum != CURLE_OK) {
throw new Google_IOException("HTTP Error: ($resphttpcode) $curlerror");
}

// Parse out the raw response into usable bits.
list($responseHeaders, $responseBody) = self::parseHttpResponse($respData, $respHeaderSize);
list($responseHeaders, $responseBody) = self::parseHttpResponse($respdata, $respheadersize);

// Fill in the apiHttpRequest with the response values.
$request->setResponseHttpCode($respHttpCode);
$request->setResponseHttpCode($resphttpcode);
$request->setResponseHeaders($responseHeaders);
$request->setResponseBody($responseBody);

Expand Down
13 changes: 9 additions & 4 deletions lib/google/local_config.php
Expand Up @@ -32,7 +32,7 @@

global $apiConfig;
$apiConfig = array(
// The application_name is included in the User-Agent HTTP header.
// Application name.
'application_name' => 'Moodle ' . $CFG->release,

// Site name to show in the Google's OAuth 1 authentication screen.
Expand All @@ -41,7 +41,12 @@
// Which HTTP IO classes to use.
'ioClass' => 'moodle_google_curlio',

// IO Class dependent configuration, you only have to configure the values
// for the class that was configured as the ioClass above
'ioFileCache_directory' => $GoogleConfigTempDir
// Cache class directory, it should never be used but created just in case.
'ioFileCache_directory' => $GoogleConfigTempDir,

// Default Access Type for OAuth 2.0.
'oauth2_access_type' => 'online',

// Default Approval Prompt for OAuth 2.0.
'oauth2_approval_prompt' => 'auto'
);
10 changes: 5 additions & 5 deletions repository/googledocs/lang/en/repository_googledocs.php
Expand Up @@ -23,12 +23,12 @@
*/

$string['clientid'] = 'Client ID';
$string['configplugin'] = 'Configure Google Docs plugin';
$string['googledocs:view'] = 'View google docs repository';
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Docs and Picasa plugins.</p>';
$string['configplugin'] = 'Configure Google Drive plugin';
$string['googledocs:view'] = 'View Google Drive repository';
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Drive and Picasa plugins.</p><p>Please also note that you will have to enable the service \'Drive API\'.</p>';
$string['oauth2upgrade_message_subject'] = 'Important information regarding Google Docs repository plugin';
$string['oauth2upgrade_message_content'] = 'As part of the upgrade to Moodle 2.3, the Google Docs portfolio plugin has been disabled. To re-enable it, your Moodle site needs to be registered with Google, as described in the documentation {$a->docsurl}, in order to obtain a client ID and secret. The client ID and secret can then be used to configure all Google Docs and Picasa plugins.';
$string['oauth2upgrade_message_small'] = 'This plugin has been disabled, as it requires configuration as described in the documentation Google OAuth 2.0 setup.';
$string['pluginname'] = 'Google Docs';
$string['pluginname'] = 'Google Drive';
$string['secret'] = 'Secret';

$string['servicenotenabled'] = 'Access not configured. Make sure the service \'Drive API\' is enabled.';

0 comments on commit 3425813

Please sign in to comment.