Merge branch 'MDL-30157_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2015-09-16 00:19:04 +02:00
commit a9285cd5d4
8 changed files with 57 additions and 18 deletions

View File

@ -128,10 +128,20 @@ switch ($action) {
$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();

View File

@ -66,6 +66,12 @@ function xmldb_enrol_manual_upgrade($oldversion) {
// 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;
}

View File

@ -29,6 +29,7 @@ $string['assignrole'] = 'Assign role';
$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.';
@ -56,6 +57,7 @@ $string['manual:manage'] = 'Manage user enrolments';
$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';
@ -71,4 +73,4 @@ $string['unenrolusers'] = 'Unenrol users';
$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';
$string['manualpluginnotinstalled'] = 'The "Manual" plugin has not yet been installed';

View File

@ -226,14 +226,19 @@ class enrol_manual_plugin extends enrol_plugin {
$button->class .= ' enrol_manual_plugin';
$startdate = $manager->get_course()->startdate;
$startdateoptions = array();
$timeformat = get_string('strftimedatefullshort');
if ($startdate > 0) {
$startdateoptions[2] = get_string('coursestart') . ' (' . userdate($startdate, $timeformat) . ')';
if (!$defaultstart = get_config('enrol_manual', 'enrolstart')) {
// Default to now if there is no system setting.
$defaultstart = 4;
}
$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) . ')' ;
$startdateoptions = array();
$dateformat = get_string('strftimedatefullshort');
if ($startdate > 0) {
$startdateoptions[2] = get_string('coursestart') . ' (' . userdate($startdate, $dateformat) . ')';
}
$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');
@ -245,6 +250,7 @@ class enrol_manual_plugin extends enrol_plugin {
'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

View File

@ -28,7 +28,7 @@ require_once($CFG->dirroot.'/enrol/manual/locallib.php');
$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);
@ -83,24 +83,31 @@ for ($i=1; $i<=365; $i++) {
$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()) {
@ -111,6 +118,9 @@ 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;

View File

@ -66,6 +66,11 @@ if ($ADMIN->fulltree) {
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));

View File

@ -24,7 +24,7 @@
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;

View File

@ -215,12 +215,12 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
var options = this.get(UEP.OPTIONSTARTDATE);
var index = 0, count = 0;
for (var i in options) {
count++;
var option = create('<option value="'+i+'">'+options[i]+'</option>');
if (i == defaultvalue) {
index = count;
}
select.append(option);
count++;
}
select.set('selectedIndex', index);
},
@ -608,7 +608,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
value : 0
},
defaultStartDate : {
value : 2,
value : 4,
validator : Y.Lang.isNumber
},
defaultDuration : {