);
// Name field.
- $mform->addElement('text', 'name', get_string('name', 'tool_monitor'), 'size="50"');
+ $mform->addElement('text', 'name', get_string('rulename', 'tool_monitor'), 'size="50"');
$mform->addRule('name', get_string('required'), 'required');
$mform->setType('name', PARAM_TEXT);
- $mform->addHelpButton('name', 'name', 'tool_monitor');
// Plugin field.
- $mform->addElement('select', 'plugin', get_string('selectplugin', 'tool_monitor'), $pluginlist);
+ $mform->addElement('select', 'plugin', get_string('areatomonitor', 'tool_monitor'), $pluginlist);
$mform->addRule('plugin', get_string('required'), 'required');
- $mform->addHelpButton('plugin', 'selectplugin', 'tool_monitor');
// Event field.
- $mform->addElement('select', 'eventname', get_string('selectevent', 'tool_monitor'), $eventlist);
+ $mform->addElement('select', 'eventname', get_string('event', 'tool_monitor'), $eventlist);
$mform->addRule('eventname', get_string('required'), 'required');
- $mform->addHelpButton('eventname', 'selectevent', 'tool_monitor');
+ // Freeze plugin and event fields for editing if there's a subscription for this rule.
+ if ($subscriptioncount > 0) {
+ $mform->freeze('plugin');
+ $mform->setConstant('plugin', $rule->plugin);
+ $mform->freeze('eventname');
+ $mform->setConstant('eventname', $rule->eventname);
+ }
+
// Description field.
- $mform->addElement('editor', 'description', get_string('description', 'tool_monitor'), $editoroptions);
- $mform->addHelpButton('description', 'description', 'tool_monitor');
+ $mform->addElement('editor', 'description', get_string('description'), $editoroptions);
// Filters.
- $mform->addElement('header', 'customisefilters', get_string('customisefilters', 'tool_monitor'));
$freq = array(1 => 1, 5 => 5, 10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90,
100 => 100, 1000 => 1000);
- $mform->addElement('select', 'frequency', get_string('selectfrequency', 'tool_monitor'), $freq);
+ $mform->addElement('select', 'frequency', get_string('frequency', 'tool_monitor'), $freq);
$mform->addRule('frequency', get_string('required'), 'required');
- $mform->addHelpButton('frequency', 'selectfrequency', 'tool_monitor');
+ $mform->addHelpButton('frequency', 'frequency', 'tool_monitor');
$mins = array(1 => 1, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50,
55 => 55, 60 => 60);
}
$mform = new tool_monitor\rule_form(null, array('eventlist' => $eventlist, 'pluginlist' => $pluginlist, 'rule' => $rule,
- 'courseid' => $courseid));
+ 'courseid' => $courseid, 'subscriptioncount' => $subscriptioncount));
+ if ($mform->is_cancelled()) {
+ redirect(new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $courseid)));
+ exit();
+ }
+
if ($mformdata = $mform->get_data()) {
$rule = \tool_monitor\rule_manager::clean_ruledata_form($mformdata);
}
redirect($manageurl);
+} else {
+ echo $OUTPUT->header();
+ $mform->set_data($rule);
+ // If there's any subscription for this rule, display an information message.
+ if ($subscriptioncount > 0) {
+ echo $OUTPUT->notification(get_string('disablefieldswarning', 'tool_monitor'), 'notifyproblem');
+ }
+ $mform->display();
+ echo $OUTPUT->footer();
}
+ echo $OUTPUT->header();
+ if (!empty($ruleid)) {
+ echo $OUTPUT->heading(get_string('editrule', 'tool_monitor'));
+ } else {
+ echo $OUTPUT->heading(get_string('addrule', 'tool_monitor'));
+ }
+ $mform->set_data($rule);
+ $mform->display();
+ echo $OUTPUT->footer();
$string['addrule'] = 'Add a new rule';
$string['allevents'] = 'All events';
- $string['allmodules'] = 'All modules';
+ $string['allmodules'] = 'All instances';
+ $string['area'] = 'Area';
+ $string['areatomonitor'] = 'Area to monitor';
$string['core'] = 'Core';
- $string['context'] = 'Context';
- $string['customisefilters'] = 'Select the frequency of the events';
- $string['customisemessage'] = 'Customise the notification message';
$string['currentsubscriptions'] = 'Your current subscriptions';
- $string['description_help'] = "Description is displayed to users when they want to subscribe to this rule. This helps them understand what the rule is about.";
- $string['defaultmessagetpl'] = 'Rule "{rulename}" has happened. You can find further details at {link}';
+ $string['defaultmessagetemplate'] = 'The rule "{rulename}" you have subscribed to has occurred - please find further details at {link}';
$string['deleterule'] = 'Delete rule';
$string['deletesubscription'] = 'Delete subscription';
+$string['description'] = 'Description:';
+$string['disablefieldswarning'] = 'Plugin and events fields can not be edited because this rule already has subscriptions.';
$string['duplicaterule'] = 'Duplicate rule';
$string['editrule'] = 'Edit rule';
+ $string['event'] = 'Event';
$string['eventnotfound'] = 'Event not found';
$string['eventrulecreated'] = 'Rule created';
$string['eventruledeleted'] = 'Rule deleted';