Skip to content

Commit

Permalink
MDL-58219 cibot: Fixes
Browse files Browse the repository at this point in the history
Fixes for cibot warnings.

Part of MDL-58220
  • Loading branch information
Damyon Wiese committed Apr 3, 2017
1 parent dece386 commit 72fd103
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 63 deletions.
1 change: 0 additions & 1 deletion auth/oauth2/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public static function link_login($userinfo, $issuer, $userid = false) {
$context = context_user::instance($userid);
require_capability('auth/oauth2:managelinkedlogins', $context);


$record = new stdClass();
$record->issuerid = $issuer->get('id');
$record->username = $userinfo['username'];
Expand Down
8 changes: 6 additions & 2 deletions auth/oauth2/classes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function config_form($config, $err, $userfields) {
/**
* 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();
Expand Down Expand Up @@ -306,8 +306,12 @@ private function update_picture($user) {
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;
}
Expand Down
3 changes: 1 addition & 2 deletions auth/oauth2/classes/linked_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -35,7 +35,6 @@
*/
class linked_login extends persistent {

/** @const TABLE */
const TABLE = 'auth_oauth2_linked_login';

/**
Expand Down
3 changes: 3 additions & 0 deletions auth/oauth2/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions auth/oauth2/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
defined('MOODLE_INTERNAL') || die();

/**
* Upgrade function
*
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
Expand Down
35 changes: 34 additions & 1 deletion auth/oauth2/lib.php
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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'));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions auth/oauth2/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
2 changes: 1 addition & 1 deletion calendar/classes/export_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function definition() {
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');
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/oauth2/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static function get_user_field_mapping($id) {
* 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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/oauth2/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/oauth2/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -36,7 +36,6 @@
*/
class endpoint extends persistent {

/** @const TABLE */
const TABLE = 'oauth2_endpoint';

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/oauth2/issuer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -35,7 +35,6 @@
*/
class issuer extends persistent {

/** @const TABLE */
const TABLE = 'oauth2_issuer';

/**
Expand Down
8 changes: 7 additions & 1 deletion lib/classes/oauth2/refresh_system_tokens_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -47,7 +53,7 @@ protected function notify_admins(\core\oauth2\issuer $issuer) {
$admins = get_admins();

if (empty($admins)) {
return;
return;
}
foreach ($admins as $admin) {
$strparams = ['siteurl' => $CFG->wwwroot, 'issuer' => $issuer->get('name')];
Expand Down
1 change: 1 addition & 0 deletions lib/classes/oauth2/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public abstract function get_api_functions();
*
* @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();
Expand Down
5 changes: 1 addition & 4 deletions lib/classes/oauth2/system_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -37,7 +35,6 @@
*/
class system_account extends persistent {

/** @const TABLE */
const TABLE = 'oauth2_system_account';

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/classes/oauth2/user_field_mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -35,7 +35,6 @@
*/
class user_field_mapping extends persistent {

/** @const TABLE */
const TABLE = 'oauth2_user_field_mapping';

/** @var array $userfields - List of standard Moodle userfields. */
Expand Down
4 changes: 2 additions & 2 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3495,7 +3495,7 @@ public function patch($url, $params = '', $options = array()) {
$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);
Expand Down
2 changes: 1 addition & 1 deletion lib/form/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions lib/oauthlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,21 @@ function get_nonce() {
* @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 = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/assignmentplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public function get_file_info($browser, $filearea, $itemid, $filepath, $filename

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;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/filesedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
$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));
Expand Down
2 changes: 2 additions & 0 deletions repository/googledocs/db/caches.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 72fd103

Please sign in to comment.