caldav::get_sync_calendar (private)

 caldav::get_sync_calendar -user_id user_id

Defined in packages/caldav/tcl/caldav-procs.tcl

Get the calendar, to which we want to sync. This method returns the first (and only in usual installations) calendar_id if it is found.

Switches:
-user_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_get_calitems get_calitems (test caldav) caldav::get_sync_calendar caldav::get_sync_calendar test_get_calitems->caldav::get_sync_calendar caldav::CalDAV instproc PUT caldav::CalDAV instproc PUT (public) caldav::CalDAV instproc PUT->caldav::get_sync_calendar caldav::test::get_lowest_uid caldav::test::get_lowest_uid (private) caldav::test::get_lowest_uid->caldav::get_sync_calendar

Testcases:
get_calitems
Source code:
        set calendar_id [ns_cache_eval ns:memoize caldav-sync-cal-$user_id  ::xo::dc list get_sync_calendar {
                                 select calendar_id from calendars
                                 where private_p = 't' and owner_id = :user_id
                             }]
        if {[llength $calendar_id] > 1} {
            #
            # In general, there is no rule which states that there is
            # for a user just a single private calendar. However, in
            # typical installations, this is the case for "normal"
            # users. In case there are multiple such calendars, return
            # the first a sync calendar and issue a warning. Probably,
            # such cases should be fixed manually in the database.
            #
            ns_log warning "CalDAV: more than one sync calendar for user $user_id ($calendar_id);"  "fall back to first one"
            set calendar_id [lindex $calendar_id 0]
        } elseif {[llength $calendar_id] == 0} {
            #
            # On non-DotLRN installations, the private calendar is
            # created when a user visits the first time the calendar
            # package, and no personal calendar exists. Bail out if
            # no such calendar exists.
            #
            error "can't get sync calendar for user $user_id"
        }
        return $calendar_id
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: