Browse Source

Create new setting to control default, and set correct value in db for existing records.

MOODLE_35_STABLE
Dan Marsden 7 years ago
parent
commit
a6576acd19
  1. 10
      add_form.php
  2. 4
      db/upgrade.php
  3. 3
      settings.php
  4. 7
      update_form.php

10
add_form.php

@ -125,10 +125,16 @@ class mod_attendance_add_form extends moodleform {
array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext));
$mform->setType('sdescription', PARAM_RAW);
if (!empty($pluginconfig->enablecalendar)) {
$mform->addElement('checkbox', 'calendarevent', '', get_string('calendarevent', 'attendance'));
$mform->addHelpButton('calendarevent', 'calendarevent', 'attendance');
// XXX - this should be modified to use a different config setting if we keep enablecalendar's current meaning
$mform->setDefault('calendarevent', get_config('attendance', 'enablecalendar'));
if (isset($pluginconfig->calendarevent_default)) {
$mform->setDefault('calendarevent', $pluginconfig->calendarevent_default);
}
} else {
$mform->addElement('hidden', 'calendarevent', 0);
$mform->setType('calendarevent', PARAM_INT);
}
// If warnings allow selector for reporting.
if (!empty(get_config('attendance', 'enablewarnings'))) {

4
db/upgrade.php

@ -517,6 +517,10 @@ function xmldb_attendance_upgrade($oldversion=0) {
XMLDB_NOTNULL, null, '1', 'caleventid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
if (empty(get_config('attendance', 'enablecalendar'))) {
// Calendar disabled on this site, set calendarevent for existing records to 0;
$DB->execute("UPDATE {attendance_sessions} set calendarevent = 0");
}
}
upgrade_mod_savepoint(true, 2018051402, 'attendance');
}

3
settings.php

@ -105,6 +105,9 @@ if ($ADMIN->fulltree) {
$description = new lang_string('defaultsessionsettings_help', 'mod_attendance');
$settings->add(new admin_setting_heading('defaultsessionsettings', $name, $description));
$settings->add(new admin_setting_configcheckbox('attendance/calendarevent_default',
get_string('calendarevent', 'attendance'), '', 1));
$settings->add(new admin_setting_configcheckbox('attendance/absenteereport_default',
get_string('includeabsentee', 'attendance'), '', 1));

7
update_form.php

@ -113,10 +113,13 @@ class mod_attendance_update_form extends moodleform {
array('rows' => 1, 'columns' => 80), $defopts);
$mform->setType('sdescription', PARAM_RAW);
if (!empty(get_config('attendance', 'enablecalendar'))) {
$mform->addElement('checkbox', 'calendarevent', '', get_string('calendarevent', 'attendance'));
$mform->addHelpButton('calendarevent', 'calendarevent', 'attendance');
// XXX - this should be modified to use a different config setting if we keep enablecalendar's current meaning
// $mform->setDefault('calendarevent', get_config('attendance', 'enablecalendar'));
} else {
$mform->addElement('hidden', 'calendarevent', 0);
$mform->setType('calendarevent', PARAM_INT);
}
// If warnings allow selector for reporting.
if (!empty(get_config('attendance', 'enablewarnings'))) {

Loading…
Cancel
Save