MDL-37562 calendar: Adding a api calendar_update_subscription() to update calendar events

This commit is contained in:
Ankit Agarwal
2013-04-08 13:45:24 +08:00
parent 422f68fb86
commit 1f7981e079
+23
View File
@@ -3056,6 +3056,29 @@ function calendar_update_subscription_events($subscriptionid) {
return $return;
}
/**
* Update a calendar subscription. Also updates the associated cache.
*
* @param stdClass|array $subscription Subscription record.
* @throws coding_exception If something goes wrong
* @since Moodle 2.5
*/
function calendar_update_subscription($subscription) {
global $DB;
if (is_array($subscription)) {
$subscription = (object)$subscription;
}
if (empty($subscription->id) || !$DB->record_exists('event_subscriptions', array('id' => $subscription->id))) {
throw new coding_exception('Cannot update a subscription without a valid id');
}
$DB->update_record('event_subscriptions', $subscription);
// Update cache.
$cache = cache::make('core', 'calendar_subscriptions');
$cache->set($subscription->id, $subscription);
}
/**
* Checks to see if the user can edit a given subscription feed.
*