diff --git a/calendar/lib.php b/calendar/lib.php index 7fed0c0ee76..ede82803316 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -110,6 +110,16 @@ define('CALENDAR_IMPORT_EVENT_UPDATED', 1); */ define('CALENDAR_IMPORT_EVENT_INSERTED', 2); +/** + * CALENDAR_SUBSCRIPTION_UPDATE - Used to represent update action for subscriptions in various forms. + */ +define('CALENDAR_SUBSCRIPTION_UPDATE', 1); + +/** + * CALENDAR_SUBSCRIPTION_REMOVE - Used to represent remove action for subscriptions in various forms. + */ +define('CALENDAR_SUBSCRIPTION_REMOVE', 2); + /** * Return the days of the week * @@ -2914,17 +2924,13 @@ function calendar_add_icalendar_event($event, $courseid, $subscriptionid) { * @return string A log of the import progress, including errors */ function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) { - global $DB; // Fetch the subscription from the database making sure it exists. $sub = calendar_get_subscription($subscriptionid); - $strupdate = get_string('update'); - $strremove = get_string('remove'); - // Update or remove the subscription, based on action. switch ($action) { - case $strupdate: + case CALENDAR_SUBSCRIPTION_UPDATE: // Skip updating file subscriptions. if (empty($sub->url)) { break; @@ -2935,7 +2941,7 @@ function calendar_process_subscription_row($subscriptionid, $pollinterval, $acti // Update the events. return "

".get_string('subscriptionupdated', 'calendar', $sub->name)."

" . calendar_update_subscription_events($subscriptionid); - case $strremove: + case CALENDAR_SUBSCRIPTION_REMOVE: calendar_delete_subscription($subscriptionid); return get_string('subscriptionremoved', 'calendar', $sub->name); break; diff --git a/calendar/managesubscriptions.php b/calendar/managesubscriptions.php index 21782aaa4d6..06d60b49342 100644 --- a/calendar/managesubscriptions.php +++ b/calendar/managesubscriptions.php @@ -33,7 +33,7 @@ $courseid = optional_param('course', SITEID, PARAM_INT); // Used for processing subscription actions. $subscriptionid = optional_param('id', 0, PARAM_INT); $pollinterval = optional_param('pollinterval', 0, PARAM_INT); -$action = optional_param('action', '', PARAM_ALPHA); +$action = optional_param('action', '', PARAM_INT); $url = new moodle_url('/calendar/managesubscriptions.php'); if ($courseid != SITEID) { diff --git a/calendar/renderer.php b/calendar/renderer.php index fbbc848ba97..4fc9a05d76c 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -836,9 +836,11 @@ class core_calendar_renderer extends plugin_renderer_base { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'course', 'value' => $courseid)); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $subscription->id)); if (!empty($subscription->url)) { - $html .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'action', 'value' => get_string('update'))); + $html .= html_writer::tag('button', get_string('update'), array('type' => 'submit', 'name' => 'action', + 'value' => CALENDAR_SUBSCRIPTION_UPDATE)); } - $html .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'action', 'value' => get_string('remove'))); + $html .= html_writer::tag('button', get_string('remove'), array('type' => 'submit', 'name' => 'action', + 'value' => CALENDAR_SUBSCRIPTION_REMOVE)); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); return $html;