diff --git a/lib/google/curlio.php b/lib/google/curlio.php index 2a287c2d88c..72e7d2fb859 100644 --- a/lib/google/curlio.php +++ b/lib/google/curlio.php @@ -23,9 +23,8 @@ */ defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir . '/filelib.php'); -require_once($CFG->libdir . '/google/src/Google/IO/Curl.php'); -require_once($CFG->libdir . '/google/src/Google/IO/Exception.php'); /** * Class moodle_google_curlio. diff --git a/lib/google/lib.php b/lib/google/lib.php index cca4dee9b87..94fa2fe84a1 100644 --- a/lib/google/lib.php +++ b/lib/google/lib.php @@ -24,11 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->libdir . '/weblib.php'); - -// Update the include_path so that the library can use require_once in its own files. -set_include_path(get_include_path() . PATH_SEPARATOR . $CFG->libdir . '/google'); -require_once($CFG->libdir . '/google/src/Google/Client.php'); +// All Google API classes support autoload with this. +require_once($CFG->libdir . '/google/autoload.php'); +// To be able to use our custom IO class. require_once($CFG->libdir . '/google/curlio.php'); /** diff --git a/lib/google/readme_moodle.txt b/lib/google/readme_moodle.txt index 44e95d413a7..cdf5ae4e834 100644 --- a/lib/google/readme_moodle.txt +++ b/lib/google/readme_moodle.txt @@ -1,9 +1,9 @@ Google APIs Client Library for PHP ================================== -Only the source, README and autoloader files have been kept in this directory: +Only the source, LICENSE, README and autoloader files have been kept in this directory: -- Copy /src/Google to /src/Google +- Copy /src/Google to /src/Google - Copy /LICENSE to LICENSE - Copy /README.md to README.md - Copy /autoload.php to autoload.php @@ -16,6 +16,17 @@ Here are the files that we have added. that should be used throughout Moodle. It also takes care of including the required files and updating the include_path. + Every use of the Google PHP API should always start by requiring this file. + Apart from the wrapping of Google_Client above... it's also responsible for + enabling the autoload of all the API classes. + + So, basically, every use of the Google Client API should be something like: + + require_once($CFG->libdir . '/google/lib.php'); + $client = get_google_client(); + + And, from there, use the Client API normally. Everything will be autoloaded. + /curlio.php An override of the default Google_IO_Curl class to use our Curl class @@ -23,6 +34,8 @@ Here are the files that we have added. Curl class should be checked to ensure that its functionalities are covered in this file. + This should not ever be used directly. The wrapper above uses it automatically. + Information ----------- diff --git a/portfolio/googledocs/lib.php b/portfolio/googledocs/lib.php index a4716b57ea2..04733dda0f5 100644 --- a/portfolio/googledocs/lib.php +++ b/portfolio/googledocs/lib.php @@ -22,7 +22,6 @@ */ require_once($CFG->libdir.'/portfolio/plugin.php'); require_once($CFG->libdir . '/google/lib.php'); -require_once($CFG->libdir . '/google/src/Google/Service/Drive.php'); class portfolio_plugin_googledocs extends portfolio_plugin_push_base { /** diff --git a/repository/googledocs/lib.php b/repository/googledocs/lib.php index 9b975f4eade..ca3566996b9 100644 --- a/repository/googledocs/lib.php +++ b/repository/googledocs/lib.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/repository/lib.php'); require_once($CFG->libdir . '/google/lib.php'); -require_once($CFG->libdir . '/google/src/Google/Service/Drive.php'); /** * Google Docs Plugin