Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS - use moodle-extra standard #521

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
<rule ref="./phpcs.xml"/>
<rule ref="moodle-extra">
</rule>
</ruleset>
4 changes: 3 additions & 1 deletion backup/moodle2/backup_zoom_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

require_once($CFG->dirroot . '/mod/zoom/backup/moodle2/backup_zoom_stepslib.php');

use mod_zoom\backup_activity_structure_step;

/**
* Provides the steps to perform one complete backup of the zoom instance
*/
Expand All @@ -41,7 +43,7 @@ protected function define_my_settings() {
* Defines a backup step to store the instance data in the zoom.xml file
*/
protected function define_my_steps() {
$this->add_step(new backup_zoom_activity_structure_step('zoom_structure', 'zoom.xml'));
$this->add_step(new backup_activity_structure_step('zoom_structure', 'zoom.xml'));
}

/**
Expand Down
9 changes: 7 additions & 2 deletions backup/moodle2/backup_zoom_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Defines backup_zoom_activity_structure_step class.
* Defines backup_activity_structure_step class.
*
* @package mod_zoom
* @category backup
* @copyright 2015 UC Regents
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_zoom;

use backup;
use backup_nested_element;

/**
* Define the complete zoom structure for backup, with file and id annotations.
*/
class backup_zoom_activity_structure_step extends backup_activity_structure_step {
class backup_activity_structure_step extends \backup_activity_structure_step {
/**
* Defines the backup structure of the module.
*
Expand Down
4 changes: 3 additions & 1 deletion backup/moodle2/restore_zoom_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

require_once($CFG->dirroot . '/mod/zoom/backup/moodle2/restore_zoom_stepslib.php');

use mod_zoom\restore_activity_structure_step;

/**
* Restore task for the zoom activity module
*
Expand All @@ -45,7 +47,7 @@ protected function define_my_settings() {
*/
protected function define_my_steps() {
// We have just one structure step here.
$this->add_step(new restore_zoom_activity_structure_step('zoom_structure', 'zoom.xml'));
$this->add_step(new restore_activity_structure_step('zoom_structure', 'zoom.xml'));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion backup/moodle2/restore_zoom_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_zoom;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/mod/zoom/locallib.php');

use restore_path_element;

/**
* Structure step to restore one zoom activity
*/
class restore_zoom_activity_structure_step extends restore_activity_structure_step {
class restore_activity_structure_step extends \restore_activity_structure_step {
/**
* Defines structure of path elements to be processed during the restore
*
Expand Down
57 changes: 57 additions & 0 deletions classes/api_limit_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
// This file is part of the Zoom plugin for 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/>.

/**
* Exception class for Zoom API errors.
*
* @package mod_zoom
* @copyright 2023 Jonathan Champ <jrchamp@ncsu.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_zoom;

/**
* Exceeded daily API limit.
*/
class api_limit_exception extends webservice_exception {
/**
* Unix timestamp of next time to API can be called.
* @var int
*/
public $retryafter = null;

/**
* Constructor
* @param string $response Web service response
* @param int $errorcode Web service response error code
* @param int $retryafter Unix timestamp of next time to API can be called.
*/
public function __construct($response, $errorcode, $retryafter) {
$this->retryafter = $retryafter;

$a = new \stdClass();
$a->response = $response;
parent::__construct(
$response,
$errorcode,
'zoomerr_apilimit',
'mod_zoom',
'',
userdate($retryafter, get_string('strftimedaydatetime', 'core_langconfig'))
);
}
}
39 changes: 39 additions & 0 deletions classes/bad_request_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of the Zoom plugin for 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/>.

/**
* Exception class for Zoom API errors.
*
* @package mod_zoom
* @copyright 2023 Jonathan Champ <jrchamp@ncsu.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_zoom;

/**
* Bad request received by Zoom.
*/
class bad_request_exception extends webservice_exception {
/**
* Constructor
* @param string $response Web service response message
* @param int $errorcode Web service response error code
*/
public function __construct($response, $errorcode) {
parent::__construct($response, $errorcode, 'errorwebservice_badrequest', 'mod_zoom', '', $response);
}
}
13 changes: 10 additions & 3 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@
* @since Moodle 3.1
*/

namespace mod_zoom;

defined('MOODLE_INTERNAL') || die;

require_once("$CFG->libdir/externallib.php");

use external_api;
use external_function_parameters;
use external_single_structure;
use external_value;
use external_warnings;

/**
* Zoom external functions
*/
class mod_zoom_external extends external_api {
class external extends external_api {
/**
* Returns description of method parameters
*
Expand Down Expand Up @@ -79,7 +87,7 @@ public static function get_state($zoomid) {
require_capability('mod/zoom:view', $context);

// Call the zoom/locallib API.
list($inprogress, $available, $finished) = zoom_get_state($zoom);
[$inprogress, $available, $finished] = zoom_get_state($zoom);

$result = [];
$result['available'] = $available;
Expand Down Expand Up @@ -215,5 +223,4 @@ public static function grade_item_update_returns() {
]
);
}

}
30 changes: 22 additions & 8 deletions classes/invitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,24 @@ private function remove_element(string $invitation, string $element): string {

// If invitation is null, an error occurred in preg_replace.
if ($invitation === null) {
throw new \moodle_exception('invitationmodificationfailed', 'mod_zoom', $PAGE->url,
['element' => $element, 'pattern' => $configregex[$element]]);
throw new \moodle_exception(
'invitationmodificationfailed',
'mod_zoom',
$PAGE->url,
['element' => $element, 'pattern' => $configregex[$element]]
);
}

// Add debugging message to assist site administrator in testing regex patterns if no match is found.
if (empty($count)) {
debugging(get_string('invitationmatchnotfound', 'mod_zoom',
['element' => $element, 'pattern' => $configregex[$element]]),
DEBUG_DEVELOPER);
debugging(
get_string(
'invitationmatchnotfound',
'mod_zoom',
['element' => $element, 'pattern' => $configregex[$element]]
),
DEBUG_DEVELOPER
);
}

return $invitation;
Expand All @@ -169,9 +178,14 @@ private function add_paragraph_break_above_element(string $invitation, string $e
$result = preg_match($configregex[$element], $invitation, $matches, PREG_OFFSET_CAPTURE);
// If error occurred in preg_match, show debugging message to help site administrator.
if ($result === false) {
debugging(get_string('invitationmodificationfailed', 'mod_zoom',
['element' => $element, 'pattern' => $configregex[$element]]),
DEBUG_DEVELOPER);
debugging(
get_string(
'invitationmodificationfailed',
'mod_zoom',
['element' => $element, 'pattern' => $configregex[$element]]
),
DEBUG_DEVELOPER
);
}

// No match found, so return invitation string unaltered.
Expand Down
39 changes: 39 additions & 0 deletions classes/not_found_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of the Zoom plugin for 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/>.

/**
* Exception class for Zoom API errors.
*
* @package mod_zoom
* @copyright 2023 Jonathan Champ <jrchamp@ncsu.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_zoom;

/**
* Entry not found on Zoom.
*/
class not_found_exception extends webservice_exception {
/**
* Constructor
* @param string $response Web service response message
* @param int $errorcode Web service response error code
*/
public function __construct($response, $errorcode) {
parent::__construct($response, $errorcode, 'errorwebservice_notfound', 'mod_zoom');
}
}
1 change: 0 additions & 1 deletion classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,4 @@ public static function mobile_course_view($args) {
'files' => '',
];
}

}
30 changes: 16 additions & 14 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@
* Ad hoc task that performs the actions for approved data privacy requests.
*/
class provider implements
// This plugin has data.
\core_privacy\local\metadata\provider,

\core_privacy\local\request\core_userlist_provider,

// This plugin currently implements the original plugin_provider interface.
\core_privacy\local\metadata\provider,
\core_privacy\local\request\plugin\provider {
/**
* Returns meta data about this system.
Expand All @@ -53,17 +49,23 @@ public static function get_metadata(\core_privacy\local\metadata\collection $col
'duration' => 'privacy:metadata:zoom_meeting_participants:duration',
], 'privacy:metadata:zoom_meeting_participants');

$coll->add_database_table('zoom_meeting_details',
['topic' => 'privacy:metadata:zoom_meeting_details:topic'],
'privacy:metadata:zoom_meeting_details');
$coll->add_database_table(
'zoom_meeting_details',
['topic' => 'privacy:metadata:zoom_meeting_details:topic'],
'privacy:metadata:zoom_meeting_details'
);

$coll->add_database_table('zoom_meeting_recordings_view',
$coll->add_database_table(
'zoom_meeting_recordings_view',
['userid' => 'privacy:metadata:zoom_meeting_view:userid'],
'privacy:metadata:zoom_meeting_view');
'privacy:metadata:zoom_meeting_view'
);

$coll->add_database_table('zoom_breakout_participants',
$coll->add_database_table(
'zoom_breakout_participants',
['userid' => 'privacy:metadata:zoom_breakout_participants:userid'],
'privacy:metadata:zoom_breakout_participants');
'privacy:metadata:zoom_breakout_participants'
);

return $coll;
}
Expand Down Expand Up @@ -166,7 +168,7 @@ public static function export_user_data(\core_privacy\local\request\approved_con

$user = $contextlist->get_user();

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
[$contextsql, $contextparams] = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);

$sql = "SELECT zmp.id,
zmd.topic,
Expand Down Expand Up @@ -345,7 +347,7 @@ public static function delete_data_for_users(\core_privacy\local\request\approve

// Prepare SQL to gather all completed IDs.
$userids = $userlist->get_userids();
list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
[$insql, $inparams] = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$params = array_merge($inparams, ['contextid' => $context->id, 'modlevel' => CONTEXT_MODULE]);

$sql = "SELECT zmd.id
Expand Down
Loading
Loading