$roleid = null;
}
+ if (empty($startdate)) {
+ if (!$startdate = get_config('enrol_manual', 'enrolstart')) {
+ // Default to now if there is no system setting.
+ $startdate = 4;
+ }
+ }
+
switch($startdate) {
case 2:
$timestart = $course->startdate;
break;
+ case 4:
+ $timestart = time();
+ break;
case 3:
default:
$today = time();
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2015091500) {
+ // We keep today as default enrolment start time on upgrades.
+ set_config('enrolstart', 3, 'enrol_manual');
+ upgrade_plugin_savepoint(true, 2015091500, 'enrol', 'manual');
+ }
+
return true;
}
$string['browseusers'] = 'Browse users';
$string['browsecohorts'] = 'Browse cohorts';
$string['confirmbulkdeleteenrolment'] = 'Are you sure you want to delete these users enrolments?';
+$string['defaultstart'] = 'Default enrolment start';
$string['defaultperiod'] = 'Default enrolment duration';
$string['defaultperiod_desc'] = 'Default length of time that the enrolment is valid. If set to zero, the enrolment duration will be unlimited by default.';
$string['defaultperiod_help'] = 'Default length of time that the enrolment is valid, starting with the moment the user is enrolled. If disabled, the enrolment duration will be unlimited by default.';
$string['manual:unenrol'] = 'Unenrol users from the course';
$string['manual:unenrolself'] = 'Unenrol self from the course';
$string['messageprovider:expiry_notification'] = 'Manual enrolment expiry notifications';
+$string['now'] = 'Now';
$string['pluginname'] = 'Manual enrolments';
$string['pluginname_desc'] = 'The manual enrolments plugin allows users to be enrolled manually via a link in the course administration settings, by a user with appropriate permissions such as a teacher. The plugin should normally be enabled, since certain other enrolment plugins, such as self enrolment, require it.';
$string['status'] = 'Enable manual enrolments';
$string['wscannotenrol'] = 'Plugin instance cannot manually enrol a user in the course id = {$a->courseid}';
$string['wsnoinstance'] = 'Manual enrolment plugin instance doesn\'t exist or is disabled for the course (id = {$a->courseid})';
$string['wsusercannotassign'] = 'You don\'t have the permission to assign this role ({$a->roleid}) to this user ({$a->userid}) in this course({$a->courseid}).';
-$string['manualpluginnotinstalled'] = 'The "Manual" plugin has not yet been installed';
\ No newline at end of file
+$string['manualpluginnotinstalled'] = 'The "Manual" plugin has not yet been installed';
$button->class .= ' enrol_manual_plugin';
$startdate = $manager->get_course()->startdate;
+ if (!$defaultstart = get_config('enrol_manual', 'enrolstart')) {
+ // Default to now if there is no system setting.
+ $defaultstart = 4;
+ }
$startdateoptions = array();
- $timeformat = get_string('strftimedatefullshort');
+ $dateformat = get_string('strftimedatefullshort');
if ($startdate > 0) {
- $startdateoptions[2] = get_string('coursestart') . ' (' . userdate($startdate, $timeformat) . ')';
+ $startdateoptions[2] = get_string('coursestart') . ' (' . userdate($startdate, $dateformat) . ')';
}
- $today = time();
- $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
- $startdateoptions[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
+ $now = time();
+ $today = make_timestamp(date('Y', $now), date('m', $now), date('d', $now), 0, 0, 0);
+ $startdateoptions[3] = get_string('today') . ' (' . userdate($today, $dateformat) . ')';
+ $startdateoptions[4] = get_string('now', 'enrol_manual') . ' (' . userdate($now, get_string('strftimedatetimeshort')) . ')';
$defaultduration = $instance->enrolperiod > 0 ? $instance->enrolperiod / 86400 : '';
$modules = array('moodle-enrol_manual-quickenrolment', 'moodle-enrol_manual-quickenrolment-skin');
'optionsStartDate' => $startdateoptions,
'defaultRole' => $instance->roleid,
'defaultDuration' => $defaultduration,
+ 'defaultStartDate' => (int)$defaultstart,
'disableGradeHistory' => $CFG->disablegradehistory,
'recoverGradesDefault'=> '',
'cohortsAvailable' => cohort_get_available_cohorts($manager->get_context(), COHORT_WITH_NOTENROLLED_MEMBERS_ONLY, 0, 1) ? true : false
$enrolid = required_param('enrolid', PARAM_INT);
$roleid = optional_param('roleid', -1, PARAM_INT);
$extendperiod = optional_param('extendperiod', 0, PARAM_INT);
-$extendbase = optional_param('extendbase', 3, PARAM_INT);
+$extendbase = optional_param('extendbase', 0, PARAM_INT);
$instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'manual'), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
$seconds = $i * 86400;
$periodmenu[$seconds] = get_string('numdays', '', $i);
}
-// Work out the apropriate default setting.
+// Work out the apropriate default settings.
if ($extendperiod) {
$defaultperiod = $extendperiod;
} else {
$defaultperiod = $instance->enrolperiod;
}
+if (empty($extendbase)) {
+ if (!$extendbase = get_config('enrol_manual', 'enrolstart')) {
+ // Default to now if there is no system setting.
+ $extendbase = 4;
+ }
+}
// Build the list of options for the starting from dropdown.
-$timeformat = get_string('strftimedatefullshort');
-$today = time();
-$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
+$now = time();
+$today = make_timestamp(date('Y', $now), date('m', $now), date('d', $now), 0, 0, 0);
+$dateformat = get_string('strftimedatefullshort');
// Enrolment start.
$basemenu = array();
if ($course->startdate > 0) {
- $basemenu[2] = get_string('coursestart') . ' (' . userdate($course->startdate, $timeformat) . ')';
+ $basemenu[2] = get_string('coursestart') . ' (' . userdate($course->startdate, $dateformat) . ')';
}
-$basemenu[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
+$basemenu[3] = get_string('today') . ' (' . userdate($today, $dateformat) . ')';
+$basemenu[4] = get_string('now', 'enrol_manual') . ' (' . userdate($now, get_string('strftimedatetimeshort')) . ')';
// Process add and removes.
if ($canenrol && optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
case 2:
$timestart = $course->startdate;
break;
+ case 4:
+ $timestart = $now;
+ break;
case 3:
default:
$timestart = $today;
get_string('defaultrole', 'role'), '', $student->id, $options));
}
+ $options = array(2 => get_string('coursestart'), 3 => get_string('today'), 4 => get_string('now', 'enrol_manual'));
+ $settings->add(
+ new admin_setting_configselect('enrol_manual/enrolstart', get_string('defaultstart', 'enrol_manual'), '', 4, $options)
+ );
+
$settings->add(new admin_setting_configduration('enrol_manual/enrolperiod',
get_string('defaultperiod', 'enrol_manual'), get_string('defaultperiod_desc', 'enrol_manual'), 0));
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2015051100; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version = 2015091500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2015050500; // Requires this Moodle version
$plugin->component = 'enrol_manual'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 600;
value : 0
},
defaultStartDate : {
- value : 3,
+ value : 4,
validator : Y.Lang.isNumber
},
defaultDuration : {