MDL-27856 coding style cleanup

This commit is contained in:
Petr Škoda 2012-09-02 11:00:01 +02:00
parent 94335e5a97
commit e7193380d8
12 changed files with 56 additions and 76 deletions

View file

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -18,8 +17,7 @@
/** /**
* Adds new instance of enrol_cohort to specified course. * Adds new instance of enrol_cohort to specified course.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -28,7 +26,7 @@ require('../../config.php');
require_once("$CFG->dirroot/enrol/cohort/addinstance_form.php"); require_once("$CFG->dirroot/enrol/cohort/addinstance_form.php");
require_once("$CFG->dirroot/enrol/cohort/locallib.php"); require_once("$CFG->dirroot/enrol/cohort/locallib.php");
$id = required_param('id', PARAM_INT); // course id $id = required_param('id', PARAM_INT); // Course id.
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST);
@ -42,7 +40,7 @@ $PAGE->set_pagelayout('admin');
navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
// Try and make the manage instances node on the navigation active // Try and make the manage instances node on the navigation active.
$courseadmin = $PAGE->settingsnav->get('courseadmin'); $courseadmin = $PAGE->settingsnav->get('courseadmin');
if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->get('manageinstances')) { if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->get('manageinstances')) {
$courseadmin->get('users')->get('manageinstances')->make_active(); $courseadmin->get('users')->get('manageinstances')->make_active();

View file

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -18,8 +17,7 @@
/** /**
* Adds instance form * Adds instance form
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -42,7 +40,7 @@ class enrol_cohort_addinstance_form extends moodleform {
$enrol = enrol_get_plugin('cohort'); $enrol = enrol_get_plugin('cohort');
$cohorts = array('' => get_string('choosedots')); $cohorts = array('' => get_string('choosedots'));
list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($coursecontext)); list($sqlparents, $params) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids());
$sql = "SELECT id, name, contextid $sql = "SELECT id, name, contextid
FROM {cohort} FROM {cohort}
WHERE contextid $sqlparents WHERE contextid $sqlparents
@ -59,7 +57,7 @@ class enrol_cohort_addinstance_form extends moodleform {
$roles = get_assignable_roles($coursecontext); $roles = get_assignable_roles($coursecontext);
$roles[0] = get_string('none'); $roles[0] = get_string('none');
$roles = array_reverse($roles, true); // descending default sortorder $roles = array_reverse($roles, true); // Descending default sortorder.
$mform->addElement('header','general', get_string('pluginname', 'enrol_cohort')); $mform->addElement('header','general', get_string('pluginname', 'enrol_cohort'));

View file

@ -20,8 +20,7 @@
* The general idea behind this file is that any errors should throw exceptions * The general idea behind this file is that any errors should throw exceptions
* which will be returned and acted upon by the calling AJAX script. * which will be returned and acted upon by the calling AJAX script.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2011 Sam Hemelryk * @copyright 2011 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -33,7 +32,7 @@ require_once($CFG->dirroot.'/enrol/locallib.php');
require_once($CFG->dirroot.'/enrol/cohort/locallib.php'); require_once($CFG->dirroot.'/enrol/cohort/locallib.php');
require_once($CFG->dirroot.'/group/lib.php'); require_once($CFG->dirroot.'/group/lib.php');
// Must have the sesskey // Must have the sesskey.
$id = required_param('id', PARAM_INT); // course id $id = required_param('id', PARAM_INT); // course id
$action = required_param('action', PARAM_ALPHANUMEXT); $action = required_param('action', PARAM_ALPHANUMEXT);
@ -50,7 +49,7 @@ require_login($course);
require_capability('moodle/course:enrolreview', $context); require_capability('moodle/course:enrolreview', $context);
require_sesskey(); require_sesskey();
echo $OUTPUT->header(); // send headers echo $OUTPUT->header(); // Send headers.
$manager = new course_enrolment_manager($PAGE, $course); $manager = new course_enrolment_manager($PAGE, $course);

View file

@ -23,8 +23,7 @@
* - you need to change the "www-data" to match the apache user account * - you need to change the "www-data" to match the apache user account
* - use "su" if "sudo" not available * - use "su" if "sudo" not available
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2011 Petr Skoda {@link http://skodak.org} * @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -35,7 +34,7 @@ require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); require_once($CFG->libdir.'/clilib.php');
require_once("$CFG->dirroot/enrol/cohort/locallib.php"); require_once("$CFG->dirroot/enrol/cohort/locallib.php");
// now get cli options // Now get cli options.
list($options, $unrecognized) = cli_get_params(array('verbose'=>false, 'help'=>false), array('v'=>'verbose', 'h'=>'help')); list($options, $unrecognized) = cli_get_params(array('verbose'=>false, 'help'=>false), array('v'=>'verbose', 'h'=>'help'));
if ($unrecognized) { if ($unrecognized) {

View file

@ -36,7 +36,7 @@ $capabilities = array(
) )
), ),
/* This is used only when sync suspends users instead of full unenrolment */ /* This is used only when sync suspends users instead of full unenrolment. */
'enrol/cohort:unenrol' => array( 'enrol/cohort:unenrol' => array(
'captype' => 'write', 'captype' => 'write',
@ -47,8 +47,3 @@ $capabilities = array(
), ),
); );

View file

@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/* List of handlers */ /* List of handlers. */
$handlers = array ( $handlers = array (
'cohort_member_added' => array ( 'cohort_member_added' => array (
'handlerfile' => '/enrol/cohort/locallib.php', 'handlerfile' => '/enrol/cohort/locallib.php',

View file

@ -17,8 +17,7 @@
/** /**
* Meta link enrolment plugin uninstallation. * Meta link enrolment plugin uninstallation.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2011 Petr Skoda {@link http://skodak.org} * @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -38,4 +37,4 @@ function xmldb_enrol_cohort_uninstall() {
role_unassign_all(array('component'=>'enrol_cohort')); role_unassign_all(array('component'=>'enrol_cohort'));
return true; return true;
} }

View file

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -16,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Strings for component 'enrol_cohort', language 'en', branch 'MOODLE_20_STABLE' * Strings for component 'enrol_cohort', language 'en'
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */

View file

@ -17,8 +17,7 @@
/** /**
* Cohort enrolment plugin. * Cohort enrolment plugin.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -32,9 +31,9 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class enrol_cohort_plugin extends enrol_plugin { class enrol_cohort_plugin extends enrol_plugin {
/** /**
* Returns localised name of enrol instance * Returns localised name of enrol instance.
* *
* @param object $instance (null is accepted too) * @param stdClass $instance (null is accepted too)
* @return string * @return string
*/ */
public function get_instance_name($instance) { public function get_instance_name($instance) {
@ -67,12 +66,12 @@ class enrol_cohort_plugin extends enrol_plugin {
if (!$this->can_add_new_instances($courseid)) { if (!$this->can_add_new_instances($courseid)) {
return NULL; return NULL;
} }
// multiple instances supported - multiple parent courses linked // Multiple instances supported - multiple parent courses linked.
return new moodle_url('/enrol/cohort/addinstance.php', array('id'=>$courseid)); return new moodle_url('/enrol/cohort/addinstance.php', array('id'=>$courseid));
} }
/** /**
* Given a courseid this function returns true if the user is able to enrol or configure cohorts * Given a courseid this function returns true if the user is able to enrol or configure cohorts.
* AND there are cohorts that the user can view. * AND there are cohorts that the user can view.
* *
* @param int $courseid * @param int $courseid
@ -100,7 +99,6 @@ class enrol_cohort_plugin extends enrol_plugin {
return false; return false;
} }
/** /**
* Called for all enabled enrol plugins that returned true from is_cron_required(). * Called for all enabled enrol plugins that returned true from is_cron_required().
* @return void * @return void
@ -116,8 +114,8 @@ class enrol_cohort_plugin extends enrol_plugin {
* Called after updating/inserting course. * Called after updating/inserting course.
* *
* @param bool $inserted true if course just inserted * @param bool $inserted true if course just inserted
* @param object $course * @param stdClass $course
* @param object $data form data * @param stdClass $data form data
* @return void * @return void
*/ */
public function course_updated($inserted, $course, $data) { public function course_updated($inserted, $course, $data) {
@ -158,7 +156,7 @@ class enrol_cohort_plugin extends enrol_plugin {
} }
/** /**
* Gets an array of the user enrolment actions * Gets an array of the user enrolment actions.
* *
* @param course_enrolment_manager $manager * @param course_enrolment_manager $manager
* @param stdClass $ue A user enrolment object * @param stdClass $ue A user enrolment object
@ -210,7 +208,7 @@ class enrol_cohort_plugin extends enrol_plugin {
$button->strings_for_js('cohort', 'cohort'); $button->strings_for_js('cohort', 'cohort');
$button->strings_for_js('users', 'moodle'); $button->strings_for_js('users', 'moodle');
// No point showing this at all if the user cant manually enrol users // No point showing this at all if the user cant manually enrol users.
$hasmanualinstance = has_capability('enrol/manual:enrol', $manager->get_context()) && $manager->has_instance('manual'); $hasmanualinstance = has_capability('enrol/manual:enrol', $manager->get_context()) && $manager->has_instance('manual');
$modules = array('moodle-enrol_cohort-quickenrolment', 'moodle-enrol_cohort-quickenrolment-skin'); $modules = array('moodle-enrol_cohort-quickenrolment', 'moodle-enrol_cohort-quickenrolment-skin');

View file

@ -17,8 +17,7 @@
/** /**
* Local stuff for cohort enrolment plugin. * Local stuff for cohort enrolment plugin.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -36,7 +35,7 @@ require_once($CFG->dirroot . '/enrol/locallib.php');
*/ */
class enrol_cohort_handler { class enrol_cohort_handler {
/** /**
* Event processor - cohort member added * Event processor - cohort member added.
* @param stdClass $ca * @param stdClass $ca
* @return bool * @return bool
*/ */
@ -47,7 +46,7 @@ class enrol_cohort_handler {
return true; return true;
} }
// does any enabled cohort instance want to sync with this cohort? // Does any enabled cohort instance want to sync with this cohort?
$sql = "SELECT e.*, r.id as roleexists $sql = "SELECT e.*, r.id as roleexists
FROM {enrol} e FROM {enrol} e
LEFT JOIN {role} r ON (r.id = e.roleid) LEFT JOIN {role} r ON (r.id = e.roleid)
@ -60,14 +59,14 @@ class enrol_cohort_handler {
$plugin = enrol_get_plugin('cohort'); $plugin = enrol_get_plugin('cohort');
foreach ($instances as $instance) { foreach ($instances as $instance) {
if ($instance->status != ENROL_INSTANCE_ENABLED ) { if ($instance->status != ENROL_INSTANCE_ENABLED ) {
// no roles for disabled instances // No roles for disabled instances.
$instance->roleid = 0; $instance->roleid = 0;
} else if ($instance->roleid and !$instance->roleexists) { } else if ($instance->roleid and !$instance->roleexists) {
// invalid role - let's just enrol, they will have to create new sync and delete this one // Invalid role - let's just enrol, they will have to create new sync and delete this one.
$instance->roleid = 0; $instance->roleid = 0;
} }
unset($instance->roleexists); unset($instance->roleexists);
// no problem if already enrolled // No problem if already enrolled.
$plugin->enrol_user($instance, $ca->userid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE); $plugin->enrol_user($instance, $ca->userid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE);
} }
@ -75,14 +74,14 @@ class enrol_cohort_handler {
} }
/** /**
* Event processor - cohort member removed * Event processor - cohort member removed.
* @param stdClass $ca * @param stdClass $ca
* @return bool * @return bool
*/ */
public static function member_removed($ca) { public static function member_removed($ca) {
global $DB; global $DB;
// does anything want to sync with this cohort? // Does anything want to sync with this cohort?
if (!$instances = $DB->get_records('enrol', array('customint1'=>$ca->cohortid, 'enrol'=>'cohort'), 'id ASC')) { if (!$instances = $DB->get_records('enrol', array('customint1'=>$ca->cohortid, 'enrol'=>'cohort'), 'id ASC')) {
return true; return true;
} }
@ -110,14 +109,14 @@ class enrol_cohort_handler {
} }
/** /**
* Event processor - cohort deleted * Event processor - cohort deleted.
* @param stdClass $cohort * @param stdClass $cohort
* @return bool * @return bool
*/ */
public static function deleted($cohort) { public static function deleted($cohort) {
global $DB; global $DB;
// does anything want to sync with this cohort? // Does anything want to sync with this cohort?
if (!$instances = $DB->get_records('enrol', array('customint1'=>$cohort->id, 'enrol'=>'cohort'), 'id ASC')) { if (!$instances = $DB->get_records('enrol', array('customint1'=>$cohort->id, 'enrol'=>'cohort'), 'id ASC')) {
return true; return true;
} }
@ -149,7 +148,7 @@ class enrol_cohort_handler {
function enrol_cohort_sync($courseid = NULL, $verbose = false) { function enrol_cohort_sync($courseid = NULL, $verbose = false) {
global $CFG, $DB; global $CFG, $DB;
// purge all roles if cohort sync disabled, those can be recreated later here by cron or CLI // Purge all roles if cohort sync disabled, those can be recreated later here by cron or CLI.
if (!enrol_is_enabled('cohort')) { if (!enrol_is_enabled('cohort')) {
if ($verbose) { if ($verbose) {
mtrace('Cohort sync plugin is disabled, unassigning all plugin roles and stopping.'); mtrace('Cohort sync plugin is disabled, unassigning all plugin roles and stopping.');
@ -158,7 +157,7 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
return 2; return 2;
} }
// unfortunately this may take a long time, this script can be interrupted without problems // Unfortunately this may take a long time, this script can be interrupted without problems.
@set_time_limit(0); @set_time_limit(0);
raise_memory_limit(MEMORY_HUGE); raise_memory_limit(MEMORY_HUGE);
@ -173,7 +172,7 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
$unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL); $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL);
// iterate through all not enrolled yet users // Iterate through all not enrolled yet users.
$onecourse = $courseid ? "AND e.courseid = :courseid" : ""; $onecourse = $courseid ? "AND e.courseid = :courseid" : "";
$sql = "SELECT cm.userid, e.id AS enrolid, ue.status $sql = "SELECT cm.userid, e.id AS enrolid, ue.status
FROM {cohort_members} cm FROM {cohort_members} cm
@ -204,7 +203,7 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
$rs->close(); $rs->close();
// unenrol as necessary // Unenrol as necessary.
$sql = "SELECT ue.*, e.courseid $sql = "SELECT ue.*, e.courseid
FROM {user_enrolments} ue FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'cohort' $onecourse) JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'cohort' $onecourse)
@ -217,14 +216,14 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
} }
$instance = $instances[$ue->enrolid]; $instance = $instances[$ue->enrolid];
if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) { if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) {
// remove enrolment together with group membership, grades, preferences, etc. // Temove enrolment together with group membership, grades, preferences, etc.
$plugin->unenrol_user($instance, $ue->userid); $plugin->unenrol_user($instance, $ue->userid);
if ($verbose) { if ($verbose) {
mtrace(" unenrolling: $ue->userid ==> $instance->courseid via cohort $instance->customint1"); mtrace(" unenrolling: $ue->userid ==> $instance->courseid via cohort $instance->customint1");
} }
} else { // ENROL_EXT_REMOVED_SUSPENDNOROLES } else { // ENROL_EXT_REMOVED_SUSPENDNOROLES
// just disable and ignore any changes // Just disable and ignore any changes.
if ($ue->status != ENROL_USER_SUSPENDED) { if ($ue->status != ENROL_USER_SUSPENDED) {
$plugin->update_user_enrol($instance, $ue->userid, ENROL_USER_SUSPENDED); $plugin->update_user_enrol($instance, $ue->userid, ENROL_USER_SUSPENDED);
$context = context_course::instance($instance->courseid); $context = context_course::instance($instance->courseid);
@ -239,7 +238,7 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
unset($instances); unset($instances);
// now assign all necessary roles to enrolled users - skip suspended instances and users // Now assign all necessary roles to enrolled users - skip suspended instances and users.
$onecourse = $courseid ? "AND e.courseid = :courseid" : ""; $onecourse = $courseid ? "AND e.courseid = :courseid" : "";
$sql = "SELECT e.roleid, ue.userid, c.id AS contextid, e.id AS itemid, e.courseid $sql = "SELECT e.roleid, ue.userid, c.id AS contextid, e.id AS itemid, e.courseid
FROM {user_enrolments} ue FROM {user_enrolments} ue
@ -264,7 +263,7 @@ function enrol_cohort_sync($courseid = NULL, $verbose = false) {
$rs->close(); $rs->close();
// remove unwanted roles - sync role can not be changed, we only remove role when unenrolled // Remove unwanted roles - sync role can not be changed, we only remove role when unenrolled.
$onecourse = $courseid ? "AND e.courseid = :courseid" : ""; $onecourse = $courseid ? "AND e.courseid = :courseid" : "";
$sql = "SELECT ra.roleid, ra.userid, ra.contextid, ra.itemid, e.courseid $sql = "SELECT ra.roleid, ra.userid, ra.contextid, ra.itemid, e.courseid
FROM {role_assignments} ra FROM {role_assignments} ra
@ -384,7 +383,7 @@ function enrol_cohort_get_cohorts(course_enrolment_manager $manager) {
} }
/** /**
* Check if cohort exists and user is allowed to enrol it * Check if cohort exists and user is allowed to enrol it.
* *
* @global moodle_database $DB * @global moodle_database $DB
* @param int $cohortid Cohort ID * @param int $cohortid Cohort ID
@ -426,10 +425,10 @@ function enrol_cohort_search_cohorts(course_enrolment_manager $manager, $offset
list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($context)); list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($context));
// Add some additional sensible conditions // Add some additional sensible conditions.
$tests = array('contextid ' . $sqlparents); $tests = array('contextid ' . $sqlparents);
// Modify the query to perform the search if required // Modify the query to perform the search if required.
if (!empty($search)) { if (!empty($search)) {
$conditions = array( $conditions = array(
'name', 'name',
@ -452,17 +451,17 @@ function enrol_cohort_search_cohorts(course_enrolment_manager $manager, $offset
$order = ' ORDER BY name ASC'; $order = ' ORDER BY name ASC';
$rs = $DB->get_recordset_sql($fields . $sql . $order, $params, $offset); $rs = $DB->get_recordset_sql($fields . $sql . $order, $params, $offset);
// Produce the output respecting parameters // Produce the output respecting parameters.
foreach ($rs as $c) { foreach ($rs as $c) {
// Track offset // Track offset.
$offset++; $offset++;
// Check capabilities // Check capabilities.
$context = context::instance_by_id($c->contextid); $context = context::instance_by_id($c->contextid);
if (!has_capability('moodle/cohort:view', $context)) { if (!has_capability('moodle/cohort:view', $context)) {
continue; continue;
} }
if ($limit === 0) { if ($limit === 0) {
// we have reached the required number of items and know that there are more, exit now // we have reached the required number of items and know that there are more, exit now.
$offset--; $offset--;
break; break;
} }
@ -472,9 +471,9 @@ function enrol_cohort_search_cohorts(course_enrolment_manager $manager, $offset
'users'=>$DB->count_records('cohort_members', array('cohortid'=>$c->id)), 'users'=>$DB->count_records('cohort_members', array('cohortid'=>$c->id)),
'enrolled'=>in_array($c->id, $enrolled) 'enrolled'=>in_array($c->id, $enrolled)
); );
// Count items // Count items.
$limit--; $limit--;
} }
$rs->close(); $rs->close();
return array('more' => !(bool)$limit, 'offset' => $offset, 'cohorts' => $cohorts); return array('more' => !(bool)$limit, 'offset' => $offset, 'cohorts' => $cohorts);
} }

View file

@ -17,8 +17,7 @@
/** /**
* Cohort enrolment plugin settings and presets. * Cohort enrolment plugin settings and presets.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -45,4 +44,3 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configselect('enrol_cohort/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_UNENROL, $options)); $settings->add(new admin_setting_configselect('enrol_cohort/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_UNENROL, $options));
} }
} }

View file

@ -17,8 +17,7 @@
/** /**
* Cohort enrolment plugin version specification. * Cohort enrolment plugin version specification.
* *
* @package enrol * @package enrol_cohort
* @subpackage cohort
* @copyright 2010 Petr Skoda {@link http://skodak.org} * @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -28,4 +27,4 @@ defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX) $plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012061700; // Requires this Moodle version $plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component = 'enrol_cohort'; // Full name of the plugin (used for diagnostics) $plugin->component = 'enrol_cohort'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 60*60; // run cron every hour by default, it is not out-of-sync often $plugin->cron = 60*60; // run cron every hour by default, it is not out-of-sync often