Beispiel #1
0
/**
 * Fetch a calendar subscription and update the events in the calendar.
 *
 * @param int $subscriptionid The course ID for the calendar.
 * @return string A log of the import progress, including errors.
 */
function calendar_update_subscription_events($subscriptionid)
{
    global $DB;
    $sub = $DB->get_record('event_subscriptions', array('id' => $subscriptionid));
    if (empty($sub)) {
        print_error('errorbadsubscription', 'calendar');
    }
    // Don't update a file subscription. TODO: Update from a new uploaded file.
    if (empty($sub->url)) {
        return 'File subscription not updated.';
    }
    $ical = calendar_get_icalendar($sub->url);
    $return = calendar_import_icalendar_events($ical, $sub->courseid, $subscriptionid);
    $sub->lastupdated = time();
    $DB->update_record('event_subscriptions', $sub);
    return $return;
}
Beispiel #2
0
/**
 * Fetch a calendar subscription and update the events in the calendar.
 *
 * @param int $subscriptionid The course ID for the calendar.
 * @return string A log of the import progress, including errors.
 */
function calendar_update_subscription_events($subscriptionid)
{
    global $DB;
    $sub = calendar_get_subscription($subscriptionid);
    // Don't update a file subscription. TODO: Update from a new uploaded file.
    if (empty($sub->url)) {
        return 'File subscription not updated.';
    }
    $ical = calendar_get_icalendar($sub->url);
    $return = calendar_import_icalendar_events($ical, $sub->courseid, $subscriptionid);
    $sub->lastupdated = time();
    calendar_update_subscription($sub);
    return $return;
}
Beispiel #3
0
/**
 * Fetch a calendar subscription and update the events in the calendar.
 *
 * @param int $subscriptionid The course ID for the calendar.
 * @return string A log of the import progress, including errors.
 */
function calendar_update_subscription_events($subscriptionid)
{
    global $DB;
    $sub = calendar_get_subscription($subscriptionid);
    // Don't update a file subscription. TODO: Update from a new uploaded file.
    if (empty($sub->url)) {
        return 'File subscription not updated.';
    }
    $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);
    return $return;
}