MDL-37562 calendar: Remove all hardcoded updating of calendar subscriptions, use calendar_update_subscription() instead

This commit is contained in:
Ankit Agarwal 2013-03-21 15:19:15 +08:00
parent 5ae4e15344
commit ab37339d09

View File

@ -2801,8 +2801,6 @@ function calendar_add_subscription($sub) {
$sub->pollinterval = 0;
}
$cache = cache::make('core', 'calendar_subscriptions');
if (!empty($sub->name)) {
if (empty($sub->id)) {
$id = $DB->insert_record('event_subscriptions', $sub);
@ -2810,9 +2808,7 @@ function calendar_add_subscription($sub) {
return $id;
} else {
// Why are we doing an update here?
$DB->update_record('event_subscriptions', $sub);
// update cache.
$cache->set($sub->id, $sub);
calendar_update_subscription($sub);
return $sub->id;
}
} else {
@ -2920,11 +2916,7 @@ function calendar_process_subscription_row($subscriptionid, $pollinterval, $acti
break;
}
$sub->pollinterval = $pollinterval;
$DB->update_record('event_subscriptions', $sub);
// update the cache.
$cache = cache::make('core', 'calendar_subscriptions');
$cache->set($sub->id, $sub);
calendar_update_subscription($sub);
// Update the events.
return "<p>".get_string('subscriptionupdated', 'calendar', $sub->name)."</p>" . calendar_update_subscription_events($subscriptionid);
@ -3049,10 +3041,7 @@ function calendar_update_subscription_events($subscriptionid) {
$ical = calendar_get_icalendar($sub->url);
$return = calendar_import_icalendar_events($ical, $sub->courseid, $subscriptionid);
$sub->lastupdated = time();
$DB->update_record('event_subscriptions', $sub);
// Update the cache.
$cache = cache::make('core', 'calendar_subscriptions');
$cache->set($subscriptionid, $sub);
calendar_update_subscription($sub);
return $return;
}