File/includes/functions.php

Description

Most of WebCalendar's functions.

  • author: Craig Knudsen <cknudsen@cknudsen.com>
  • copyright: Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
  • license: GNU GPL
Functions
activate_urls (line 58)

Looks for URLs in the given text, and makes them into links.

  • return: The text altered to have HTML links for any web links.
string activate_urls (string $text)
  • string $text: Input text
activity_log (line 93)

Adds something to the activity log for an event.

The information will be saved to the webcal_entry_log table.

void activity_log (int $event_id, string $user, string $user_cal, string $type, string $text)
  • int $event_id: Event ID
  • string $user: Username of user doing this
  • string $user_cal: Username of user whose calendar is affected
  • string $type: Type of activity we are logging:
    • LOG_APPROVE
    • LOG_APPROVE_T
    • LOG_ATTACHMENT
    • LOG_COMMENT
    • LOG_CREATE
    • LOG_CREATE_T
    • LOG_DELETE
    • LOG_DELETE_T
    • LOG_LOGIN_FAILURE
    • LOG_NEWUSER_FULL
    • LOG_NEWUSEREMAIL
    • LOG_NOTIFICATION
    • LOG_REJECT
    • LOG_REJECT_T
    • LOG_REMINDER
    • LOG_UPDATE
    • LOG_UPDATE_T
    • LOG_USER_ADD
    • LOG_USER_DELETE
    • LOG_USER_UPDATE
  • string $text: Text comment to add with activity log entry
add_dstfree_time (line 121)

Get the corrected timestamp after adding or subtracting ONE_HOUR to compensate for DST.

void add_dstfree_time ( $date,  $span, [ $interval = 1])
  • $date
  • $span
  • $interval
add_duration (line 144)

Return the time in HHMMSS format of input time + duration

  • return: The time in HHMMSS format.
string add_duration (string $time, int $duration)
  • string $time: format "235900"
  • int $duration: number of minutes
boss_must_approve_event (line 5779)

Checks the boss user preferences to see if the boss must approve events added to their calendar.

  • return: True if the boss must approve new events.
bool boss_must_approve_event (string $assistant, string $boss)
  • string $assistant: Assistant login
  • string $boss: Boss login
boss_must_be_notified (line 5795)

Checks the boss user preferences to see if the boss wants to be notified via email on changes to their calendar.

  • return: True if the boss wants email notifications.
bool boss_must_be_notified (string $assistant, string $boss)
  • string $assistant: Assistant login
  • string $boss: Boss login
build_entry_label (line 182)

Builds the HTML for the event label.

  • return: The HTML for the event label
string build_entry_label ( $event,  $popupid, string $can_access,  $timestr, [string $time_only = 'N'])
  • string $can_access
  • string $time_only
  • $event
  • $popupid
  • $timestr
build_entry_popup (line 5888)

Builds the HTML for the entry popup.

string build_entry_popup (string $popupid, string $user, [string $description = ''], string $time, [string $site_extras = ''], [ $location = ''], [ $name = ''], [ $id = ''], [ $reminder = ''])
  • string $popupid: CSS id to use for event popup
  • string $user: Username of user the event pertains to
  • string $description: Event description
  • string $time: Time of the event (already formatted in a display format)
  • string $site_extras: HTML for any site_extras for this event
  • $location
  • $name
  • $id
  • $reminder
bump_local_timestamp (line 166)

Bump UNIX local timestamp with the given duration.

param int $ts input timestamp param int $hour hour duration param int $minute minute duration param int $second second duration param int $month month duration param int $day day duration param int $year year duration

This function overcomes problems due to daylight saving change dates; it is based on the fact that function mktime() accepts out of range data.

void bump_local_timestamp ( $ts, [ $hour = 0], [ $minute = 0], [ $second = 0], [ $month = 0], [ $day = 0], [ $year = 0])
  • $ts
  • $hour
  • $minute
  • $second
  • $month
  • $day
  • $year
calc_time_slot (line 256)

Calculates which row/slot this time represents.

This is used in day and week views where hours of the time are separeted into different cells in a table.

Note: the global variable $TIME_SLOTS is used to determine how many time slots there are and how many minutes each is. This variable is defined user preferences (or defaulted to admin system settings).

  • return: The time slot index.
int calc_time_slot (string $time, [bool $round_down = false])
  • string $time: Input time in HHMMSS format
  • bool $round_down: Should we change 1100 to 1059? (This will make sure a 10AM-100AM appointment just shows up in the 10AM slow and not in the 11AM slot also.)
check_for_conflicts (line 293)

Checks for conflicts.

Find overlaps between an array of dates and the other dates in the database.

Limits on number of appointments: if enabled in System Settings ($LIMIT_APPTS global variable), too many appointments can also generate a scheduling conflict.

  • return: string for no conflicts or return the HTML of the conflicts when one or more are found.
  • todo: Update this to handle exceptions to repeating events.
Empty check_for_conflicts (array $dates, int $duration, int $eventstart, array $participants, string $login, int $id)
  • array $dates: Array of dates in Timestamp format that is checked for overlaps.
  • int $duration: Event duration in minutes
  • int $eventstart: GMT starttime timestamp
  • array $participants: Array of users whose calendars are to be checked
  • string $login: The current user name
  • int $id: Current event id (this keeps overlaps from wrongly checking an event against itself)
clean_html (line 454)

Replaces unsafe characters with HTML encoded equivalents.

  • return: The cleaned text.
string clean_html (string $value)
  • string $value: Input text
clean_int (line 469)

Removes non-digits from the specified text.

  • return: The converted text.
string clean_int (string $data)
  • string $data: Input text
clean_whitespace (line 479)

Removes whitespace from the specified text.

  • return: The converted text.
string clean_whitespace (string $data)
  • string $data: Input text
clean_word (line 489)

Removes non-word characters from the specified text.

  • return: The converted text.
string clean_word (string $data)
  • string $data: Input text
combine_and_sort_events (line 502)

Combines the repeating and nonrepeating event arrays and sorts them

The returned events will be sorted by time of day.

  • return: Array of Events.
array combine_and_sort_events (array $ev, array $rep)
  • array $ev: Array of events
  • array $rep: Array of repeating events
daily_matrix (line 528)

Draws a daily outlook style availability grid showing events that are approved and awaiting approval.

  • return: HTML to display matrix.
string daily_matrix (string $date, array $participants, [string $popup = ''])
  • string $date: Date to show the grid for
  • array $participants: Which users should be included in the grid
  • string $popup: Not used
date_selection (line 759)

Generate HTML for a date selection for use in a form.

  • return: HTML for the selection box.
string date_selection (string $prefix, string $date, [bool $trigger = false], [int $num_years = 20])
  • string $prefix: Prefix to use in front of form element names
  • string $date: Currently selected date (in YYYYMMDD format)
  • bool $trigger: Add onchange event trigger that calls javascript function $prefix_datechanged ()
  • int $num_years: Number of years to display
date_to_epoch (line 812)

Converts a date to a timestamp.

  • return: Timestamp representing, in UTC or LOCAL time.
int date_to_epoch (string $d, [bool $gmt = true])
  • string $d: Date in YYYYMMDD or YYYYMMDDHHIISS format
  • bool $gmt: Whether to use GMT or LOCAL
date_to_str (line 859)

Converts a date in YYYYMMDD format into "Friday, December 31, 1999", "Friday, 12-31-1999" or whatever format the user prefers.

  • return: Date in the specified format.
  • global: string $DATE_FORMAT: Preferred date format
  • TODO: Add other date () parameters like ( j, n )
string date_to_str (string $indate, [string $format = ''], [bool $show_weekday = true], [bool $short_months = false], [bool $forceTranslate = false])
  • string $indate: Date in YYYYMMDD format
  • string $format: Format to use for date (default is "__month__ __dd__, __yyyy__")
  • bool $show_weekday: Should the day of week also be included?
  • bool $short_months: Should the abbreviated month names be used instead of the full month names?
  • bool $forceTranslate: Check to see if there is a translation for the specified data format. If there is, then use the translated format from the language file, but only if $DATE_FORMAT is language-defined.
decode_string (line 914)

Extracts a user's name from a session id.

This prevents users from begin able to edit their cookies.txt file and set the username in plain text.

  • return: The decoded string.
  • global: array $offsets: Array of offsets
  • see: encode_string()
string decode_string (string $instr)
  • string $instr: A hex-encoded string. "Hello" would be "678ea786a5".
delete_entry_by_id (line 6121)

Delete everything about this entry

void delete_entry_by_id (int $id)
  • int $id: The cal_id of this entry
display_activity_log (line 935)

Display a text for a single activity log entry.

  • return: HTML for one log entry.
string display_activity_log (string $cal_type, [string $cal_text = ''], [ $break = '&lt;br/&gt;&amp;nbsp;'])
  • string $cal_type: the log entry type
  • string $cal_text: addiitonal text to display
  • $break
display_admin_link (line 1001)

Display the <<Admin link on pages if menus are not enabled

  • return: HTML for Admin Home link
  • global: string $MENU_ENABLED: (Y/N) Is the Top Menu Enabled
string display_admin_link ([bool $break = true])
  • bool $break: If true, include break if empty
display_month (line 1014)

Generate HTML to create a month display.

void display_month ( $thismonth,  $thisyear, [ $demo = false])
  • $thismonth
  • $thisyear
  • $demo
display_navigation (line 1119)

Generate the HTML for the navigation bar.

void display_navigation ( $name, [ $show_arrows = true], [ $show_cats = true])
  • $name
  • $show_arrows
  • $show_cats
display_small_month (line 1193)

Prints out a minicalendar for a month.

  • todo: Make day.php NOT be a special case
void display_small_month (int $thismonth, int $thisyear, bool $showyear, [bool $show_weeknums = false], [string $minical_id = ''], [string $month_link = 'month.php?'])
  • int $thismonth: Number of the month to print
  • int $thisyear: Number of the year
  • bool $showyear: Show the year in the calendar's title?
  • bool $show_weeknums: Show week numbers to the left of each row?
  • string $minical_id: id attribute for the minical table
  • string $month_link: URL and query string for month link that should come before the date specification (e.g. month.php? or view_l.php?id=7&amp;)
display_small_tasks (line 1357)

Prints small task list for this $login user.

void display_small_tasks ( $cat_id)
  • $cat_id
display_time (line 1488)

Displays a time in either 12 or 24 hour format.

  • return: The time in the user's timezone and preferred format.
string display_time ([string $time = ''], [int $control = 0], [int $timestamp = ''], [string $format = ''])
  • string $time: Input time in HHMMSS format Optionally, the format can be YYYYMMDDHHMMSS
  • int $control: bitwise command value
    1. default
    2. ignore_offset Do not use the timezone offset
    3. show_tzid Show abbrev TZ id ie EST after time
    4 use server's timezone
  • int $timestamp: optional input time in timestamp format
  • string $format: user's TIME_FORMAT when sending emails
display_unapproved_events (line 1553)

Checks for any unnaproved events.

If any are found, display a link to the unapproved events (where they can be approved).

If the user is an admin user, also count up any public events. If the user is a nonuser admin, count up events on the nonuser calendar.

void display_unapproved_events (string $user)
  • string $user: Current user login
do_debug (line 38)

Logs a debug message.

Generally, we try not to leave calls to this function in the code. It is used for debugging only.

void do_debug (string $msg)
  • string $msg: Text to be logged
do_redirect (line 1640)

Sends a redirect to the specified page.

The database connection is closed and execution terminates in this function.

Note: MS IIS/PWS has a bug that does not allow sending a cookie and a redirect in the same HTTP header. When we detect that the web server is IIS, we accomplish the redirect using meta-refresh. See the following for more info on the IIS bug: http://www.faqts.com/knowledge_base/view.phtml/aid/9316/fid/4

  • global: string $_SERVER: Type of webserver
  • global: array $c: Server variables
  • global: resource $SERVER_SOFTWARE: Database connection
void do_redirect (string $url)
  • string $url: The page to redirect to. In theory, this should be an absolute URL, but all browsers accept relative URLs (like "month.php").
encode_string (line 1678)

Takes an input string and encode it into a slightly encoded hexval that we can use as a session cookie.

  • return: The encoded text.
  • global: array $offsets: Array of offsets
  • see: decode_string()
string encode_string (string $instr)
  • string $instr: Text to encode
error_check (line 1701)

Check for errors and return required HTML for display

string error_check (string $nextURL, [bool $redirect = true])
  • string $nextURL: URL the redirect to
  • bool $redirect: Redirect OR popup Confirmation window
event_get_external_users (line 1732)

Gets the list of external users for an event from the webcal_entry_ext_user table in HTML format.

  • return: The list of external users for an event formated in HTML.
string event_get_external_users (int $event_id, [int $use_mailto = 0])
  • int $event_id: Event ID
  • int $use_mailto: When set to 1, email address will contain an href link with a mailto URL.
format_site_extras (line 5999)

Formats site_extras for display according to their type.

This will return an array containing formatted extras indexed on their unique names. Each formatted extra is another array containing two indices: 'name' and 'data', which hold the name of the site_extra and the formatted data, respectively. So, to access the name and data of an extra uniquely name 'Reminder', you would access $array['Reminder']['name'] and $array['Reminder']['data']

  • return: Array of formatted extras.
array format_site_extras (array $extras, [int $filter = ''])
  • array $extras: Array of site_extras for an event as returned by ()
  • int $filter: CONSTANT 'view settings' values from site_extras.php
generate_activity_log (line 1779)

Generate activity log

  • return: HTML to diplay log.
string generate_activity_log ([int $id = ''], [bool $sys = false], [int $startid = ''])
  • int $id: Event id if called from view_entry.php
  • bool $sys: Display System Log ro Event Log
  • int $startid: Event number to start off list
generate_application_name (line 1868)

Generate Application Name

void generate_application_name ([bool $custom = true])
  • bool $custom: Allow user name to be displayed
generate_printer_friendly (line 1892)

Generate HTML to add Printer Friendly Link.

If called without parameter, return only the href string.

  • return: URL to printer friendly page.
  • global: array $_SERVER: SERVER
  • global: string $MENU_ENABLED: SCRIPT name
  • global: string $SCRIPT: (Y/N) Top menu enabled
string generate_printer_friendly ([string $hrefin = ''])
  • string $hrefin: script name
generate_refresh_meta (line 1920)

Generate Refresh Meta Tag.

  • return: for Meta Tag.
HTML generate_refresh_meta ()
getByday (line 2277)
void getByday ( $cdate,  $byday,  $type,  $date)
  • $cdate
  • $byday
  • $type
  • $date
getBymonth (line 2240)
void getBymonth ( $cdate,  $bymonth)
  • $cdate
  • $bymonth
getBymonthday (line 2266)
void getBymonthday ( $cdate,  $bymonthday)
  • $cdate
  • $bymonthday
getByweekno (line 2247)
void getByweekno ( $cdate,  $byweekno)
  • $cdate
  • $byweekno
getByyearday (line 2254)
void getByyearday ( $cdate,  $byyearday)
  • $cdate
  • $byyearday
getMoonPhases (line 3043)

Get the moonphases for a given year and month.

Will only work if optional moon_phases.php file exists in includes folder.

  • return: = phase name, $val = Ymd value.
  • global: string $DISPLAY_MOON_PHASES: (Y/N) Display Moon Phases
array getMoonPhases (int $year, int $month)
  • int $year: Year in YYYY format
  • int $month: Month in m format Jan =1
getOverLap (line 3075)

Calculate event rollover to next day and add partial event as needed.

Create a cloned event on the fly as needed to display in next day slot. The event times will be adjusted so that the total of all times will equal the total time of the original event. This function will get called recursively until all time has been accounted for.

  • global: string $DISABLE_CROSSDAY_EVENTS: (Y/N) Do we want to use cross day display
  • staticvar: int $realEndTS: The true end of the original event
  • staticvar: string $originalDate: The start date of the original event
  • staticvar: mixed $originalItem: The original event object
void getOverLap (mixed $item, int $i, [bool $parent = true])
  • mixed $item: Event Object
  • int $i: Current count of event array
  • bool $parent:

    flag to keep track of the original event object

    $global array $result Array of events

getReminders (line 3136)

Get the reminder data for a given entry id.

array getReminders (int $id, [bool $display = false])
  • int $id: cal_id of requested entry
  • bool $display: if true, will create a displayable string
getShortTime (line 3205)

Remove :00 from times based on $DISPLAY_MINUTES value.

  • global: string $DISPLAY_MINUTES: (Y/N) Display 00 if on the hour
void getShortTime (string $timestr)
  • string $timestr: time value to shorten
get_all_dates (line 1950)

Returns all the dates a specific event will fall on accounting for the repeating.

Any event with no end will be assigned one.

  • return: Array of dates (in UNIX time format).
array get_all_dates (int $date, string $rpt_type, [int $interval = 1], [array $Byxxx = ''], [int $Count = 999], [string $Until = null], [string $Wkst = 'MO'], [array $ex_days = ''], [array $inc_days = ''], [int $jump = ''])
  • int $date: Initial date in raw format
  • string $rpt_type: Repeating type as stored in the database
  • int $interval: Interval of repetition
  • array $Byxxx: Array of Byxxx values
  • int $Count: Max number of events to return
  • string $Until: Last day of repeat
  • string $Wkst: First day of week ('MO' is default)
  • array $ex_days: Array of exception dates for this event in YYYYMMDD format
  • array $inc_days: Array of inclusion dates for this event in YYYYMMDD format
  • int $jump: Date to short cycle loop counts to, also makes output YYYYMMDD
get_byday (line 2295)

Get the dates the correspond to the byday values.

  • return: Dates that match ByDay (YYYYMMDD format).
array get_byday (array $byday, string $cdate, [string $type = 'month'], string $date)
  • array $byday: ByDay values to process (MO,TU,-1MO,20MO...)
  • string $cdate: First day of target search (Unix timestamp)
  • string $type: Month, Year, Week (default = month)
  • string $date: First day of event (Unix timestamp)
get_bymonthday (line 2378)

Get the dates the correspond to the bymonthday values.

  • return: Dates that match ByMonthDay (YYYYMMDD format).
array get_bymonthday (array $bymonthday, string $cdate, string $date, string $realend)
  • array $bymonthday: ByMonthDay values to process (1,2,-1,-2...)
  • string $cdate: First day of target search (Unix timestamp)
  • string $date: First day of event (Unix timestamp)
  • string $realend: Last day of event (Unix timestamp)
get_categories_by_id (line 2407)

Get categories for a given event id Global categories are changed to negative numbers

  • return: Array containing category names.
array get_categories_by_id (int $id, string $user, [bool $asterisk = false])
  • int $id: Id of event
  • string $user: normally this is $login
  • bool $asterisk: Include '*' if Global
get_entries (line 2441)

Gets all the events for a specific date.

Events are retreived from the array of pre-loaded events (which was loaded all at once to improve performance).

The returned events will be sorted by time of day.

  • return: Array of Events.
array get_entries (string $date, [bool $get_unapproved = true])
  • string $date: Date to get events for in YYYYMMDD format in user's timezone
  • bool $get_unapproved: Load unapproved events?
get_last_view (line 2467)

Gets the last page stored using ().

  • return: The URL of the last view or an empty string if it cannot be determined.
  • global: array 0: Cookies
string get_last_view ([ $clear = true])
  • $clear
get_my_nonusers (line 2496)

Gets a list of nonusers.

If groups are enabled, this will restrict the list of nonusers to only those that are in the same group(s) as the user (unless the user is an admin) or the nonuser is a public calendar. We allow admin users to see all users because they can also edit someone else's events (so they may need access to users who are not in the same groups).

If user access control is enabled, then we also check to see if this user is allowed to view each nonuser's calendar. If not, then that nonuser is not included in the list.

  • return: Array of nonusers, where each element in the array is an array with the following keys:
    • cal_login
    • cal_lastname
    • cal_firstname
    • cal_is_public
array get_my_nonusers ([ $user = ''], [ $add_public = false], [ $reason = 'invite'])
  • $user
  • $add_public
  • $reason
get_my_users (line 2609)

Gets a list of users.

If groups are enabled, this will restrict the list to only those users who are in the same group(s) as this user (unless the user is an admin). We allow admin users to see all users because they can also edit someone else's events (so they may need access to users who are not in the same groups).

If user access control is enabled, then we also check to see if this user is allowed to view each user's calendar. If not, then that user is not included in the list.

  • return: Array of users, where each element in the array is an array with the following keys:
    • cal_login
    • cal_lastname
    • cal_firstname
    • cal_is_admin
    • cal_email
    • cal_password
    • cal_fullname
array get_my_users ([ $user = ''], [ $reason = 'invite'])
  • $user
  • $reason
get_nonuser_cals (line 2709)

Gets a list of nonuser calendars and return info in an array.

  • return: Array of nonuser cals, where each is an array with the following fields:
    • cal_login
    • cal_lastname
    • cal_firstname
    • cal_admin
    • cal_fullname
    • cal_is_public
array get_nonuser_cals ([string $user = ''], [bool $remote = false])
  • string $user: Login of admin of the nonuser calendars
  • bool $remote: Return only remote calendar records
get_preferred_view (line 2837)

Gets user's preferred view.

The user's preferred view is stored in the $STARTVIEW global variable. This is loaded from the user preferences (or system settings if there are no user prefererences.)

  • return: URL of the user's preferred view.
string get_preferred_view ([string $indate = ''], [string $args = ''])
  • string $indate: Date to pass to preferred view in YYYYMMDD format
  • string $args: Arguments to include in the URL (such as "user=joe")
get_pref_setting (line 2803)

Gets a preference setting for the specified user.

If no value is found in the database, then the system default setting will be returned.

  • return: The value found in the webcal_user_pref table for the specified setting or the sytem default if no user settings was found.
string get_pref_setting (string $user, string $setting, [ $defaultValue = ''], stirng $defaultSetting)
  • string $user: User login we are getting preference for
  • string $setting: Name of the setting
  • stirng $defaultSetting: Value to return if no value foun in the database
  • $defaultValue
get_repeating_entries (line 2903)

Gets all the repeating events for the specified date.

Note: The global variable $repeated_events needs to be set by calling () first.

  • return: The query result resource on queries (which can then be passed to () to obtain the results), or true/false on insert or delete queries.
  • global: array $repeated_events: Array of RepeatingEvents retreived using ()
mixed get_repeating_entries (string $user,  $dateYmd, [bool $get_unapproved = true], string $date)
  • string $user: Username
  • string $date: Date to get events for in YYYYMMDD format
  • bool $get_unapproved: Include unapproved events in results?
  • $dateYmd
get_RRULE (line 2231)

Rule out days by using the Byxxx values

void get_RRULE (integer $date, integer $cdate, array $Byxxx)
  • integer $date: Timestamp of initial day
  • integer $cdate: Timestamp of day in question
  • array $Byxxx: Byxxx array
get_site_extras_names (line 6075)

Extract the names of all site_extras.

  • return: Array of site_extras names.
array get_site_extras_names ([int $filter = ''])
  • int $filter: CONSTANT 'view setting' from site_extras.php
get_site_extra_fields (line 6049)

Gets any site-specific fields for an entry that are stored in the database in the webcal_site_extras table.

  • return: Array with the keys as follows:
    • cal_name
    • cal_type
    • cal_date
    • cal_remind
    • cal_data
array get_site_extra_fields (int $eventid)
  • int $eventid: Event ID
get_tasks (line 2928)

Gets all the tasks for a specific date.

Events are retreived from the array of pre-loaded tasks (which was loaded all at once to improve performance).

The returned tasks will be sorted by time of day.

  • return: Array of Tasks.
array get_tasks (string $date, [bool $get_unapproved = true])
  • string $date: Date to get tasks for in YYYYMMDD format
  • bool $get_unapproved: Load unapproved events?
get_users_event_ids (line 2973)

Get event ids for all events this user is a participant.

void get_users_event_ids (string $user)
  • string $user: User to retrieve event ids
get_weekday_before (line 3017)

Gets the previous weekday of the week containing the specified date.

If the date specified is a Sunday, then that date is returned.

  • return: The date (in UNIX timestamp format).
int get_weekday_before (int $year, int $month, [int $day = 2])
  • int $year: Year
  • int $month: Month (1-12)
  • int $day: Day (1-31)
html_for_add_icon (line 3328)

Generates the HTML for an icon to add a new event.

  • return: The HTML for the add event icon.
string html_for_add_icon ([string $date = 0], [int $hour = ''], [int $minute = ''], [string $user = ''])
  • string $date: Date for new event in YYYYMMDD format
  • int $hour: Hour of day (0-23)
  • int $minute: Minute of the hour (0-59)
  • string $user: Participant to initially select for new event
html_for_event_day_at_a_glance (line 3360)

Generates the HTML for an event to be viewed in the day-at-glance (day.php).

The HTML will be stored in an array (global variable $hour_arr) indexed on the event's starting hour.

void html_for_event_day_at_a_glance (Event $event, string $date)
  • Event $event: The event
  • string $date: Date of event in YYYYMMDD format
html_for_event_week_at_a_glance (line 3516)

Generates the HTML for an event to be viewed in the week-at-glance (week.php).

The HTML will be stored in an array (global variable $hour_arr) indexed on the event's starting hour.

void html_for_event_week_at_a_glance (Event $event, string $date, [string $override_class = ''], [bool $show_time = true])
  • Event $event: The event
  • string $date: Date for which we're printing (in YYYYMMDD format)
  • string $override_class: If set, then this is the class to use
  • bool $show_time: If enabled, then event time is displayed
html_to_8bits (line 3676)

Converts HTML entities in 8bit.

Note: Only supported for PHP4 (not PHP3).

  • return: The converted text.
string html_to_8bits (string $html)
  • string $html: HTML text
is_weekend (line 3725)

Determine if date is a weekend

  • return: True = Date is weekend
bool is_weekend (int $date)
  • int $date: Timestamp of subject date OR a weekday number 0-6
load_global_settings (line 3778)

Loads default system settings (which can be updated via admin.php).

System settings are stored in the webcal_config table.

Note: If the setting for server_url is not set, the value will be calculated and stored in the database.

  • global: string $_SERVER: User's login name
  • global: bool $APPLICATION_NAME: Readonly
  • global: string $FONTS: HTTP hostname
  • global: int $HTTP_HOST: Server's port number
  • global: string $LANGUAGE: Request string
  • global: array $REQUEST_URI: Server variables
void load_global_settings ()
load_nonuser_preferences (line 3855)

Loads nonuser preferences from the webcal_user_pref table if on a nonuser admin page.

void load_nonuser_preferences (string $nonuser)
  • string $nonuser: Login name for nonuser calendar
load_template (line 3898)

Returns a custom header, stylesheet or tailer.

The data will be loaded from the webcal_user_template table. If the global variable $ALLOW_EXTERNAL_HEADER is set to 'Y', then we load an external file using include. This can have serious security issues since a malicous user could open up /etc/passwd.

void load_template (string $login, string $type)
  • string $login: Current user login
  • string $type: type of template ('H' = header, 'S' = stylesheet, 'T' = trailer)
load_user_categories (line 3960)

Loads current user's category info and stuff it into category global variable.

void load_user_categories ([string $ex_global = ''])
  • string $ex_global: Don't include global categories ('' or '1')
load_user_layers (line 3999)

Loads current user's layer info into layer global variable.

If the system setting $ALLOW_VIEW_OTHER is not set to 'Y', then we ignore all layer functionality. If $force is 0, we only load layers if the current user preferences have layers turned on.

void load_user_layers ([string $user = ''], [int $force = 0])
  • string $user: Username of user to load layers for
  • int $force: If set to 1, then load layers for this user even if user preferences have layers turned off.
load_user_preferences (line 4040)

Loads the current user's preferences as global variables from the webcal_user_pref table.

Also loads the list of views for this user (not really a preference, but this is a convenient place to put this...)

Notes:

  • If $ALLOW_COLOR_CUSTOMIZATION is set to 'N', then we ignore any color preferences.
  • Other default values will also be set if the user has not saved a preference and no global value has been set by the administrator in the system settings.

void load_user_preferences ([ $guest = ''])
  • $guest
month_name (line 4175)

Returns the either the full name or the abbreviation of the specified month.

  • return: The name of the specified month.
string month_name (int $m, [string $format = 'F'])
  • int $m: Number of the month (0-11)
  • string $format: 'F' = full, 'M' = abbreviation
nonuser_load_variables (line 4238)

Loads nonuser variables (login, firstname, etc.).

The following variables will be set:

  • login
  • firstname
  • lastname
  • fullname
  • admin
  • email

void nonuser_load_variables (string $login, string $prefix)
  • string $login: Login name of nonuser calendar
  • string $prefix: Prefix to use for variables that will be set. For example, if prefix is "temp_", then the login will be stored in the $temp_login global variable.
print_category_menu (line 4273)

Prints dropdown HTML for categories.

void print_category_menu (string $form, [string $date = ''], [int $cat_id = ''])
  • string $form: The page to submit data to (without .php)
  • string $date: Date in YYYYMMDD format
  • int $cat_id: Category id that should be pre-selected
print_checkbox (line 4322)

Generates HTML to for checkbox form controls.

  • return: HTML for the checkbox control.
string print_checkbox (array $vals, [string $id = ''], [string $onchange = ''])
  • array $vals: (name, value, display, setting)
  • string $id: the id of the control
  • string $onchange: javascript function to call if needed
print_color_input_html (line 4366)

Generates HTML for color chooser options in admin and pref pages.

  • return: HTML for the color selector.
string print_color_input_html (string $varname, string $title, [string $varval = ''])
  • string $varname: the name of the variable to display
  • string $title: color description
  • string $varval: the default value to display
print_date_entries (line 4405)

Prints all the calendar entries for the specified user for the specified date.

If we are displaying data from someone other than the logged in user, then check the access permission of the entry.

void print_date_entries (string $date, string $user, [bool $ssi = false])
  • string $date: Date in YYYYMMDD format
  • string $user: Username
  • bool $ssi: Is this being called from week_ssi.php?
print_day_at_a_glance (line 4482)

Prints all the calendar entries for the specified user for the specified date in day-at-a-glance format.

If we are displaying data from someone other than the logged in user, then check the access permission of the entry.

void print_day_at_a_glance (string $date, string $user, [ $can_add = 0])
  • string $date: Date in YYYYMMDD format
  • string $user: Username of calendar
  • $can_add
print_entry (line 4602)

Prints the HTML for one event in the month view.

  • staticvar: int $key: Used to ensure all event popups have a unique id.
  • uses: build_entry_popup()
void print_entry (Event $event, string $date)
  • Event $event: The event
  • string $date: The data for which we're printing (YYYYMMDD)
print_error (line 4748)

Generate standardized error message

string print_error (string $error, [bool $full = false])
  • string $error: Message to display
  • bool $full: Include extra text in display
print_error_header (line 4756)

An h2 header error message.

void print_error_header ()
print_not_auth (line 4770)

Generate standardized Not Authorized message

string print_not_auth ([int $errno = ''], [bool $full = false])
  • int $errno: Optional Error number to display
  • bool $full: Include ERROR title
print_radio (line 4789)

Generates HTML for radio buttons.

  • return: HTML for the radio control.
string print_radio (string $variable, [array $vals = ''], [string $onclick = ''], [string $defIdx = ''], [string $sep = '&amp;nbsp;'])
  • string $variable: the name of the variable to display
  • array $vals: the value and display variables if empty ( Yes/No options will be displayed )
  • string $onclick: javascript function to call if needed
  • string $defIdx: default array index to select
  • string $sep: HTML value between radio options (&nbsp;,
    )
print_success (line 4829)

Generate standardized Success message.

  • return: HTML to display error.
string print_success (bool $saved)
  • bool $saved
print_timezone_select_html (line 4845)

Prints Timezone select for use on forms

  • return: HTML for select control.
string print_timezone_select_html (string $prefix, string $tz)
  • string $prefix: Prefix for select control's name
  • string $tz: Current timezone of logged in user
query_events (line 4929)

Reads events visible to a user.

Includes layers and possibly public access if enabled. NOTE: The values for the global variables $thisyear and $thismonth MUST be set! (This will determine how far in the future to caclulate repeating event dates.)

array query_events (string $user, bool $want_repeated, string $date_filter, [int $cat_id = ''], [bool $is_task = false])
  • string $user: Username
  • bool $want_repeated: Get repeating events?
  • string $date_filter: SQL phrase starting with AND, to be appended to the WHERE clause. May be empty string.
  • int $cat_id: Category ID to filter on. May be empty.
  • bool $is_task: Used to restrict results to events OR tasks
read_events (line 5217)

Reads all the events for a user for the specified range of dates.

This is only called once per page request to improve performance. All the events get loaded into the array $events sorted by time of day (not date).

array read_events (string $user, string $startdate, string $enddate, [int $cat_id = ''])
  • string $user: Username
  • string $startdate: Start date range, inclusive (in timestamp format) in user's timezone
  • string $enddate: End date range, inclusive (in timestamp format) in user's timezone
  • int $cat_id: Category ID to filter on
read_repeated_events (line 5255)

Reads all the repeated events for a user.

This is only called once per page request to improve performance. All the events get loaded into the array $repeated_events sorted by time of day (not date).

This will load all the repeated events into memory.

Notes:

  • To get which events repeat on a specific date, use ().
  • To get all the dates that one specific event repeats on, call ().

  • return: Array of RepeatingEvents sorted by time of day.
  • uses: query_events()
array read_repeated_events (string $user, [int $date = ''], [ $enddate = ''], [int $cat_id = ''])
  • string $user: Username
  • int $cat_id: Category ID to filter on (May be empty)
  • int $date: Cutoff date for repeating event cal_end in timestamp format (may be empty)
  • $enddate
read_tasks (line 5285)

Reads all the tasks for a user with due date within the specified date range.

This is only called once per page request to improve performance. All the tasks get loaded into the array $tasks sorted by time of day (not date).

array read_tasks (string $user, string $duedate, [int $cat_id = ''])
  • string $user: Username
  • string $duedate: End date range, inclusive (in timestamp format) in user's timezone
  • int $cat_id: Category ID to filter on
remember_this_view (line 5303)

Generates a cookie that saves the last calendar view.

Cookie is based on the current $REQUEST_URI.

We save this cookie so we can return to this same page after a user edits/deletes/etc an event.

  • global: string $REQUEST_URI: Request string
void remember_this_view ([bool $view = false])
  • bool $view: Determine if we are using a view_x.php file
send_doctype (line 5323)

This just sends the DOCTYPE used in a lot of places in the code.

void send_doctype ([string $doc_title = ''])
  • string $doc_title: lang
send_http_login (line 5349)

Sends an HTTP login request to the browser and stops execution.

  • global: string 1: Application Name
  • global: string $lang_file: name of language file
void send_http_login ()
send_no_cache_header (line 5381)

Sends HTTP headers that tell the browser not to cache this page.

Different browsers use different mechanisms for this, so a series of HTTP header directives are sent.

Note: This function needs to be called before any HTML output is sent to the browser.

void send_no_cache_header ()
send_to_preferred_view (line 5398)

Sends a redirect to the user's preferred view.

The user's preferred view is stored in the $STARTVIEW global variable. This is loaded from the user preferences (or system settings if there are no user prefererences.)

void send_to_preferred_view ([string $indate = ''], [string $args = ''])
  • string $indate: Date to pass to preferred view in YYYYMMDD format
  • string $args: Arguments to include in the URL (such as "user=joe")
set_env (line 5409)

Set an environment variable if system allows it.

  • return: true = success false = not allowed.
bool set_env (string $val, string $setting)
  • string $val: name of environment variable
  • string $setting: value to assign
set_today (line 5449)

Determines what the day is and sets it globally.

All times are in the user's timezone

The following global variables will be set:

  • $thisyear
  • $thismonth
  • $thisday
  • $thisdate
  • $today

void set_today ([string $date = ''])
  • string $date: The date in YYYYMMDD format
site_extras_for_popup (line 6099)

Generates the HTML used in an event popup for the site_extras fields.

  • return: The HTML to be used within the event popup for any site_extra fields found for the specified event.
string site_extras_for_popup (int $id)
  • int $id: Event ID
sort_events (line 5472)

Sorts the combined event arrays by timestamp then name.

Note: This is a user-defined comparison function for usort ().

void sort_events (passed $a,  $b)
  • passed $a: automatically by usort, don't pass them in your call
  • $b
sort_events_insensitive (line 5490)

Sorts the combined event arrays by timestamp then name (case insensitive).

Note: This is a user-defined comparison function for usort ().

void sort_events_insensitive (passed $a,  $b)
  • passed $a: automatically by usort, don't pass them in your call.
  • $b
sort_users (line 5507)

Sort user array based on $USER_SORT_ORDER.

Note: This is a user-defined comparison function for usort () that will be called from user-xxx.php.

  • TODO: Move to user.php along with migration to user.class.
void sort_users (passed $a,  $b)
  • passed $a: automatically by usort, don't pass them in your call.
  • $b
times_overlap (line 5542)

Checks to see if two events overlap.

  • return: True if the two times overlap, false if they do not.
bool times_overlap (string $time1, int $duration1, string $time2, int $duration2)
  • string $time1: Time 1 in HHMMSS format
  • int $duration1: Duration 1 in minutes
  • string $time2: Time 2 in HHMMSS format
  • int $duration2: Duration 2 in minutes
time_to_minutes (line 5529)

Converts a time format HHMMSS (like 130000 for 1PM) into number of minutes past midnight.

  • return: The number of minutes since midnight.
int time_to_minutes (string $time)
  • string $time: Input time in HHMMSS format
update_status (line 5574)

Updates event status and logs activity

  • global: string $error: logged in user
  • global: string $login: current error message
void update_status (string $status, string $user, int $id, [string $type = 'E'])
  • string $status: A,D,R,W to set cal_status
  • string $user: user to apply changes to
  • int $id: event id
  • string $type: event type for logging
user_get_boss_list (line 5835)

Gets a list of an assistant's boss from the webcal_asst table.

  • return: Array of bosses, where each boss is an array with the following fields:
    • cal_login
    • cal_fullname
array user_get_boss_list (string $assistant)
  • string $assistant: Login of assistant
user_has_boss (line 5861)

Is this user an assistant?

  • return: true if the user is an assistant to one or more bosses.
bool user_has_boss (string $assistant)
  • string $assistant: Login for user
user_is_assistant (line 5810)

Is this user an assistant of this boss?

  • return: True or false.
bool user_is_assistant (string $assistant, string $boss)
  • string $assistant: Login of potential assistant
  • string $boss: Login of potential boss
user_is_nonuser_admin (line 5622)

Checks the webcal_nonuser_cals table to determine if the user is the administrator for the nonuser calendar.

  • return: True if the user is the administrator for the nonuser calendar.
bool user_is_nonuser_admin (string $login, string $nonuser)
  • string $login: Login of user that is the potential administrator
  • string $nonuser: Login name for nonuser calendar
user_is_participant (line 5634)

Determine if the specified user is a participant in the event.

User must have status 'A' or 'W'.

void user_is_participant (int $id, string $user)
  • int $id: event id
  • string $user: user login
validate_domain (line 5661)

Checks to see if user's IP in in the IP Domain specified by the /includes/blacklist.php file

  • return: Is user's IP in required domain?
  • see: /includes/blacklist.php
  • todo: There has to be a way to vastly improve on this logic.
bool validate_domain ()
weekday_name (line 5722)

Returns either the full name or the abbreviation of the day.

  • return: The weekday name ("Sunday" or "Sun")
string weekday_name (int $w, [string $format = 'l'])
  • int $w: Number of the day in the week (0=Sun,...,6=Sat)
  • string $format: 'l' (lowercase L) = Full, 'D' = abbreviation.

Documentation generated on Thu, 10 Jun 2010 17:08:26 -0400 by phpDocumentor 1.4.3