MDL-58219 cibot: Fixes
Fixes for cibot warnings. Part of MDL-58220
This commit is contained in:
@@ -109,7 +109,6 @@ class api {
|
||||
$context = context_user::instance($userid);
|
||||
require_capability('auth/oauth2:managelinkedlogins', $context);
|
||||
|
||||
|
||||
$record = new stdClass();
|
||||
$record->issuerid = $issuer->get('id');
|
||||
$record->username = $userinfo['username'];
|
||||
|
||||
@@ -164,7 +164,7 @@ class auth extends \auth_plugin_base {
|
||||
/**
|
||||
* Return the userinfo from the oauth handshake. Will only be valid
|
||||
* for the logged in user.
|
||||
* @param $string username
|
||||
* @param string $username
|
||||
*/
|
||||
public function get_userinfo($username) {
|
||||
$cached = $this->get_static_user_info();
|
||||
@@ -306,8 +306,12 @@ class auth extends \auth_plugin_base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the config after the form is saved.
|
||||
* @param stdClass $config
|
||||
*/
|
||||
public function process_config($config) {
|
||||
// Set to defaults if undefined
|
||||
// Set to defaults if undefined.
|
||||
if (!isset($config->allowlinkedlogins)) {
|
||||
$config->allowlinkedlogins = false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Class for loading/storing issuers from the DB.
|
||||
*
|
||||
* @package core_oauth2
|
||||
* @package auth_oauth2
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -35,7 +35,6 @@ use core\persistent;
|
||||
*/
|
||||
class linked_login extends persistent {
|
||||
|
||||
/** @const TABLE */
|
||||
const TABLE = 'auth_oauth2_linked_login';
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = [
|
||||
|
||||
'auth/oauth2:managelinkedlogins' => array(
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade function
|
||||
*
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
|
||||
+34
-1
@@ -1,5 +1,38 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Callbacks for auth_oauth2
|
||||
*
|
||||
* @package auth_oauth2
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Navigation hook to add to preferences page.
|
||||
*
|
||||
* @param navigation_node $useraccount
|
||||
* @param stdClass $user
|
||||
* @param context_user $context
|
||||
* @param stdClass $course
|
||||
* @param context_course $coursecontext
|
||||
*/
|
||||
function auth_oauth2_extend_navigation_user_settings(navigation_node $useraccount,
|
||||
stdClass $user,
|
||||
context_user $context,
|
||||
@@ -11,7 +44,7 @@ function auth_oauth2_extend_navigation_user_settings(navigation_node $useraccoun
|
||||
|
||||
if (get_config('auth_oauth2', 'allowlinkedlogins')) {
|
||||
$parent = $useraccount->parent->find('useraccount', navigation_node::TYPE_CONTAINER);
|
||||
$thingnode = $parent->add(get_string('linkedlogins', 'auth_oauth2'), new moodle_url('/auth/oauth2/linkedlogins.php'));
|
||||
$parent->add(get_string('linkedlogins', 'auth_oauth2'), new moodle_url('/auth/oauth2/linkedlogins.php'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2017031000; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016112900; // Requires this Moodle version
|
||||
$plugin->component = 'auth_oauth2'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->version = 2017031000; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2016112900; // Requires this Moodle version.
|
||||
$plugin->component = 'auth_oauth2'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
@@ -45,7 +45,7 @@ class core_calendar_export_form extends moodleform {
|
||||
global $CFG, $OUTPUT;
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('html', '<p>' . $OUTPUT->doc_link('calendar/export', get_string('exporthelp', 'calendar'), true) . '</p>');
|
||||
$mform->addElement('html', $OUTPUT->doc_link('calendar/export', get_string('exporthelp', 'calendar'), true));
|
||||
|
||||
$export = array();
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsall', 'calendar'), 'all');
|
||||
|
||||
@@ -242,7 +242,7 @@ class api {
|
||||
* Get the system account for an installed OAuth service.
|
||||
* Never ever ever expose this to a webservice because it contains the refresh token which grants API access.
|
||||
*
|
||||
* @param \core\oauth2\issuer $id
|
||||
* @param \core\oauth2\issuer $issuer
|
||||
* @return \core\oauth2\client
|
||||
*/
|
||||
public static function get_system_account(issuer $issuer) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Configurable oauth2 client class.
|
||||
*
|
||||
* @package core\oauth2
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Class for loading/storing oauth2 endpoints from the DB.
|
||||
*
|
||||
* @package core_oauth2
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -36,7 +36,6 @@ use lang_string;
|
||||
*/
|
||||
class endpoint extends persistent {
|
||||
|
||||
/** @const TABLE */
|
||||
const TABLE = 'oauth2_endpoint';
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Class for loading/storing issuers from the DB.
|
||||
*
|
||||
* @package core_oauth2
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -35,7 +35,6 @@ use core\persistent;
|
||||
*/
|
||||
class issuer extends persistent {
|
||||
|
||||
/** @const TABLE */
|
||||
const TABLE = 'oauth2_issuer';
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,12 +21,18 @@
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\oauth2;
|
||||
|
||||
use \core\task\scheduled_task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Simple task to delete old messaging records.
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class refresh_system_tokens_task extends scheduled_task {
|
||||
|
||||
@@ -47,7 +53,7 @@ class refresh_system_tokens_task extends scheduled_task {
|
||||
$admins = get_admins();
|
||||
|
||||
if (empty($admins)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
foreach ($admins as $admin) {
|
||||
$strparams = ['siteurl' => $CFG->wwwroot, 'issuer' => $issuer->get('name')];
|
||||
|
||||
@@ -63,6 +63,7 @@ abstract class rest {
|
||||
*
|
||||
* @param string $functionname
|
||||
* @param array $functionargs
|
||||
* @param string $rawpost Optional param to include in the body of a post.
|
||||
*/
|
||||
public function call($functionname, $functionargs, $rawpost = false) {
|
||||
$functions = $this->get_api_functions();
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
/**
|
||||
* When using OAuth sometimes it makes sense to authenticate as a system user, and not the current user.
|
||||
* In this case we use a refresh token to get an access token and the system admin must manually authorize the
|
||||
* system account.
|
||||
*
|
||||
* @package core_oauth2
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -37,7 +35,6 @@ use core\persistent;
|
||||
*/
|
||||
class system_account extends persistent {
|
||||
|
||||
/** @const TABLE */
|
||||
const TABLE = 'oauth2_system_account';
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Class for loading/storing oauth2 endpoints from the DB.
|
||||
*
|
||||
* @package core_oauth2
|
||||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -35,7 +35,6 @@ use core\persistent;
|
||||
*/
|
||||
class user_field_mapping extends persistent {
|
||||
|
||||
/** @const TABLE */
|
||||
const TABLE = 'oauth2_user_field_mapping';
|
||||
|
||||
/** @var array $userfields - List of standard Moodle userfields. */
|
||||
|
||||
+2
-2
@@ -260,7 +260,7 @@ function file_postupdate_standard_editor($data, $field, array $options, $context
|
||||
* For all files in this file area - walk the file list and copy each to a system owned account, making them read-only.
|
||||
*
|
||||
* @category files
|
||||
* @param stdClass $context context - must already exist
|
||||
* @param int $contextid context id - must already exist
|
||||
* @param string $component
|
||||
* @param string $filearea file area name
|
||||
* @param int $itemid
|
||||
@@ -3495,7 +3495,7 @@ class curl {
|
||||
$options['CURLOPT_POSTFIELDS'] = $this->_tmp_file_post_params;
|
||||
unset($this->_tmp_file_post_params);
|
||||
} else {
|
||||
// $params is the raw post data
|
||||
// The variable $params is the raw post data.
|
||||
$options['CURLOPT_POSTFIELDS'] = $params;
|
||||
}
|
||||
return $this->request($url, $options);
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatab
|
||||
protected $_options = array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 0, 'changeformat' => 0,
|
||||
'areamaxbytes' => FILE_AREA_MAX_BYTES_UNLIMITED, 'context' => null, 'noclean' => 0, 'trusttext' => 0,
|
||||
'return_types' => 15, 'enable_filemanagement' => true);
|
||||
// $_options['return_types'] = FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE | FILE_CONTROLLED_LINK
|
||||
// 15 is $_options['return_types'] = FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE | FILE_CONTROLLED_LINK.
|
||||
|
||||
/** @var array values for editor */
|
||||
protected $_values = array('text'=>null, 'format'=>null, 'itemid'=>null);
|
||||
|
||||
+8
-8
@@ -383,21 +383,21 @@ class oauth_helper {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class oauth2_client extends curl {
|
||||
/** var string client identifier issued to the client */
|
||||
/** @var string $clientid client identifier issued to the client */
|
||||
private $clientid = '';
|
||||
/** var string The client secret. */
|
||||
/** @var string $clientsecret The client secret. */
|
||||
private $clientsecret = '';
|
||||
/** var moodle_url URL to return to after authenticating */
|
||||
/** @var moodle_url $returnurl URL to return to after authenticating */
|
||||
private $returnurl = null;
|
||||
/** var string scope of the authentication request */
|
||||
/** @var string $scope of the authentication request */
|
||||
protected $scope = '';
|
||||
/** var stdClass access token object */
|
||||
/** @var stdClass $accesstoken access token object */
|
||||
private $accesstoken = null;
|
||||
/** var stdClass refresh token string */
|
||||
/** @var string $refreshtoken refresh token string */
|
||||
private $refreshtoken = '';
|
||||
/** var string mocknextresponse string */
|
||||
/** @var string $mocknextresponse string */
|
||||
private $mocknextresponse = '';
|
||||
/** var array $upgradedcodes list of upgraded codes in this request */
|
||||
/** @var array $upgradedcodes list of upgraded codes in this request */
|
||||
private static $upgradedcodes = [];
|
||||
|
||||
/**
|
||||
|
||||
@@ -585,7 +585,7 @@ abstract class assign_plugin {
|
||||
|
||||
if ($this->get_subtype() == 'assignsubmission') {
|
||||
if ($itemid) {
|
||||
$record = $DB->get_record('assign_submission', array('id'=>$itemid), 'userid,groupid', IGNORE_MISSING);
|
||||
$record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid,groupid', IGNORE_MISSING);
|
||||
if (!$record) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ $data->returnurl = $returnurl;
|
||||
$data->subwikiid = $subwiki->id;
|
||||
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
|
||||
$types = FILE_INTERNAL | FILE_REFERENCE | FILE_CONTROLLED_LINK;
|
||||
$options = array('subdirs'=>0, 'maxbytes'=>$maxbytes, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>$types);
|
||||
$options = array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => '*', 'return_types' => $types);
|
||||
file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_wiki', 'attachments', $subwiki->id);
|
||||
|
||||
$mform = new mod_wiki_filesedit_form(null, array('data'=>$data, 'options'=>$options));
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$definitions = array(
|
||||
|
||||
// Used to store file ids for folders.
|
||||
|
||||
@@ -73,7 +73,7 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Get a cached user authenticated oauth client.
|
||||
*
|
||||
* @param moodle_url $usecurrenturl - Use this url instead of the repo callback.
|
||||
* @param moodle_url $overrideurl - Use this url instead of the repo callback.
|
||||
* @return \core\oauth2\client
|
||||
*/
|
||||
protected function get_user_oauth_client($overrideurl = false) {
|
||||
@@ -668,9 +668,9 @@ class repository_googledocs extends repository {
|
||||
|
||||
/**
|
||||
* List the permissions on a file.
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param string $fileid The id of the file.
|
||||
*
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The id of the file.
|
||||
* @return array
|
||||
*/
|
||||
protected function list_file_permissions(\repository_googledocs\rest $client, $fileid) {
|
||||
@@ -681,10 +681,9 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* See if a folder exists within a folder
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $foldername The folder we are looking for.
|
||||
* @param string $parentid The parent folder we are looking in.
|
||||
*
|
||||
* @return string|boolean The file id if it exists or false.
|
||||
*/
|
||||
protected function folder_exists_in_folder(\repository_googledocs\rest $client, $foldername, $parentid) {
|
||||
@@ -704,7 +703,7 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Create a folder within a folder
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $foldername The folder we are creating.
|
||||
* @param string $parentid The parent folder we are creating in.
|
||||
*
|
||||
@@ -725,7 +724,7 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Get capabilities for a file.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are checking.
|
||||
*
|
||||
* @return stdClass The file info with capabilities.
|
||||
@@ -742,7 +741,7 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Get simple file info for humans.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are querying.
|
||||
*
|
||||
* @return stdClass
|
||||
@@ -759,8 +758,9 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Update file owner.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @param string $owneremail
|
||||
*
|
||||
* @return boolean Did it work?
|
||||
*/
|
||||
@@ -783,7 +783,7 @@ class repository_googledocs extends repository {
|
||||
* Copy a file and return the new file details. A side effect of the copy
|
||||
* is that the owner will be the account authenticated with this oauth client.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are copying.
|
||||
* @param string $name The original filename (don't change it).
|
||||
*
|
||||
@@ -811,14 +811,13 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Delete a file (for the current user).
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are deleting.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function delete_file($client, $fileid) {
|
||||
protected function delete_file(\repository_googledocs\rest $client, $fileid) {
|
||||
$params = ['fileid' => $fileid];
|
||||
$response = $client->call('delete', $params, ' ');
|
||||
var_dump($response);
|
||||
if (empty($response->id)) {
|
||||
$details = 'Cannot delete file: ' . $fileid;
|
||||
throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
|
||||
@@ -829,12 +828,12 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Add a writer to the permissions on the file (temporary).
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @param string $email The email of the writer account to add.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function add_temp_writer_to_file($client, $fileid, $email) {
|
||||
protected function add_temp_writer_to_file(\repository_googledocs\rest $client, $fileid, $email) {
|
||||
// Expires in 7 days.
|
||||
$expires = new DateTime();
|
||||
$expires->add(new DateInterval("P7D"));
|
||||
@@ -858,12 +857,12 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Add a writer to the permissions on the file.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @param string $email The email of the writer account to add.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function add_writer_to_file($client, $fileid, $email) {
|
||||
protected function add_writer_to_file(\repository_googledocs\rest $client, $fileid, $email) {
|
||||
$updateeditor = [
|
||||
'emailAddress' => $email,
|
||||
'role' => 'writer',
|
||||
@@ -881,12 +880,12 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Move from root to folder
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @param string $folderid The id of the folder we are moving to
|
||||
* @return boolean
|
||||
*/
|
||||
protected function move_file_from_root_to_folder($client, $fileid, $folderid) {
|
||||
protected function move_file_from_root_to_folder(\repository_googledocs\rest $client, $fileid, $folderid) {
|
||||
// Set the parent.
|
||||
$params = [
|
||||
'fileid' => $fileid, 'addParents' => $folderid, 'removeParents' => 'root'
|
||||
@@ -902,12 +901,12 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Remove parent
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @param string $folderid The id of the folder we are removing
|
||||
* @return boolean
|
||||
*/
|
||||
protected function remove_file_parent($client, $fileid, $folderid) {
|
||||
protected function remove_file_parent(\repository_googledocs\rest $client, $fileid, $folderid) {
|
||||
// Set the parent.
|
||||
$params = [
|
||||
'fileid' => $fileid, 'removeParents' => $folderid
|
||||
@@ -923,11 +922,11 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Prevent writers from sharing.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function prevent_writers_from_sharing_file($client, $fileid) {
|
||||
protected function prevent_writers_from_sharing_file(\repository_googledocs\rest $client, $fileid) {
|
||||
// We don't want anyone but Moodle to change the sharing settings.
|
||||
$params = [
|
||||
'fileid' => $fileid
|
||||
@@ -946,11 +945,11 @@ class repository_googledocs extends repository {
|
||||
/**
|
||||
* Allow anyone with the link to read the file.
|
||||
*
|
||||
* @param \core\oauth2\client $client Authenticated client.
|
||||
* @param \repository_googledocs\rest $client Authenticated client.
|
||||
* @param string $fileid The file we are updating.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function set_file_sharing_anyone_with_link_can_read($client, $fileid) {
|
||||
protected function set_file_sharing_anyone_with_link_can_read(\repository_googledocs\rest $client, $fileid) {
|
||||
$updateread = [
|
||||
'type' => 'anyone',
|
||||
'role' => 'reader',
|
||||
@@ -1030,7 +1029,7 @@ class repository_googledocs extends repository {
|
||||
$foldername = $context->get_context_name();
|
||||
$fullpath .= '/' . $foldername;
|
||||
|
||||
$folderid = $cache->get('fullpath');
|
||||
$folderid = $cache->get('fullpath');
|
||||
if (empty($folderid)) {
|
||||
$folderid = $this->folder_exists_in_folder($systemservice, $foldername, $parentid);
|
||||
}
|
||||
@@ -1179,7 +1178,11 @@ class repository_googledocs extends repository {
|
||||
}
|
||||
}
|
||||
|
||||
// Icon from: http://www.iconspedia.com/icon/google-2706.html.
|
||||
/**
|
||||
* Callback to get the required scopes for system account.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function repository_googledocs_oauth2_system_scopes() {
|
||||
return 'https://www.googleapis.com/auth/drive';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user