Skip to content

Commit

Permalink
MDL-76270 group: Update to match coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhilton committed Apr 20, 2023
1 parent 7beda01 commit 661c8d3
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions group/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$groupid = optional_param('group', false, PARAM_INT);
$userid = optional_param('user', false, PARAM_INT);
$action = groups_param_action();
// Support either single group= parameter, or array groups[]
// Support either single group= parameter, or array groups[].
if ($groupid) {
$groupids = array($groupid);
} else {
Expand All @@ -40,11 +40,10 @@
$returnurl = $CFG->wwwroot.'/group/index.php?id='.$courseid;

// Get the course information so we can print the header and
// check the course id is valid
// check the course id is valid.
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);

$url = new moodle_url('/group/index.php', array('id'=>$courseid));
$url = new moodle_url('/group/index.php', array('id' => $courseid));
navigation_node::override_active_url($url);
if ($userid) {
$url->param('user', $userid);
Expand All @@ -63,7 +62,7 @@
$PAGE->requires->js('/group/clientlib.js', true);
$PAGE->requires->js('/group/module.js', true);

// Check for multiple/no group errors
// Check for multiple/no group errors.
if (!$singlegroup) {
switch($action) {
case 'ajax_getmembersingroup':
Expand All @@ -75,7 +74,7 @@
}

switch ($action) {
case false: //OK, display form.
case false: // OK, display form.
break;

case 'ajax_getmembersingroup':
Expand All @@ -93,11 +92,11 @@

$viewfullnames = has_capability('moodle/site:viewfullnames', $context);

foreach($groupmemberroles as $roleid=>$roledata) {
foreach ($groupmemberroles as $roleid => $roledata) {
$shortroledata = new stdClass();
$shortroledata->name = $roledata->name;
$shortroledata->users = array();
foreach($roledata->users as $member) {
foreach ($roledata->users as $member) {
$shortmember = new stdClass();
$shortmember->id = $member->id;
$shortmember->name = fullname($member, $viewfullnames);
Expand All @@ -123,48 +122,48 @@
throw new \moodle_exception('errorselectsome', 'group', $returnurl);
}
$groupidlist = implode(',', $groupids);
redirect(new moodle_url('/group/delete.php', array('courseid'=>$courseid, 'groups'=>$groupidlist)));
redirect(new moodle_url('/group/delete.php', array('courseid' => $courseid, 'groups' => $groupidlist)));
break;

case 'showcreateorphangroupform':
redirect(new moodle_url('/group/group.php', array('courseid'=>$courseid)));
redirect(new moodle_url('/group/group.php', array('courseid' => $courseid)));
break;

case 'showautocreategroupsform':
redirect(new moodle_url('/group/autogroup.php', array('courseid'=>$courseid)));
redirect(new moodle_url('/group/autogroup.php', array('courseid' => $courseid)));
break;

case 'showimportgroups':
redirect(new moodle_url('/group/import.php', array('id'=>$courseid)));
redirect(new moodle_url('/group/import.php', array('id' => $courseid)));
break;

case 'showgroupsettingsform':
redirect(new moodle_url('/group/group.php', array('courseid'=>$courseid, 'id'=>$groupids[0])));
redirect(new moodle_url('/group/group.php', array('courseid' => $courseid, 'id' => $groupids[0])));
break;

case 'updategroups': //Currently reloading.
case 'updategroups': // Currently reloading.
break;

case 'removemembers':
break;

case 'showaddmembersform':
redirect(new moodle_url('/group/members.php', array('group'=>$groupids[0])));
redirect(new moodle_url('/group/members.php', array('group' => $groupids[0])));
break;

case 'updatemembers': //Currently reloading.
case 'updatemembers': // Currently reloading.
break;

default: //ERROR.
default: // ERROR.
throw new \moodle_exception('unknowaction', '', $returnurl);
break;
}

// Print the page and form
// Print the page and form.
$strgroups = get_string('groups');
$strparticipants = get_string('participants');

/// Print header
// Print header.
$PAGE->set_title($strgroups);
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('standard');
Expand Down Expand Up @@ -260,16 +259,15 @@
*/
function groups_param_action($prefix = 'act_') {
$action = false;
//($_SERVER['QUERY_STRING'] && preg_match("/$prefix(.+?)=(.+)/", $_SERVER['QUERY_STRING'], $matches)) { //b_(.*?)[&;]{0,1}/

if ($_POST) {
$form_vars = $_POST;
}
elseif ($_GET) {
$form_vars = $_GET;
$formvars = $_POST;
} else if ($_GET) {
$formvars = $_GET;
}
if ($form_vars) {
foreach ($form_vars as $key => $value) {

if ($formvars) {
foreach ($formvars as $key => $value) {
if (preg_match("/$prefix(.+)/", $key, $matches)) {
$action = $matches[1];
break;
Expand All @@ -280,6 +278,6 @@ function groups_param_action($prefix = 'act_') {
$action = false;
throw new \moodle_exception('unknowaction');
}
///if (debugging()) echo 'Debug: '.$action;

return $action;
}

0 comments on commit 661c8d3

Please sign in to comment.