Skip to content

Commit

Permalink
MDL-37562 calendar: Remove all hardcoded updating of calendar subscri…
Browse files Browse the repository at this point in the history
…ptions, use calendar_update_subscription() instead
  • Loading branch information
ankitagarwal committed Apr 8, 2013
1 parent 5ae4e15 commit ab37339
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2801,18 +2801,14 @@ 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);
// we cannot cache the data here because $sub is not complete.
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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ab37339

Please sign in to comment.