[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/calendar/ -> lib.php (summary)

Calendar extension

Copyright: 2004 Greek School Network (http://www.sch.gr), Jon Papaioannou,
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 3366 lines (134 kb)
Included or required:0 times
Referenced: 12 times
Includes or requires: 0 files

Defines 2 classes

calendar_event:: (16 methods):
  __construct()
  __set()
  __get()
  __isset()
  calculate_context()
  get_editoroptions()
  get_description()
  count_repeats()
  update()
  delete()
  properties()
  toggle_visibility()
  calendar_event_hook()
  load()
  create()
  format_external_text()

calendar_information:: (19 methods):
  __construct()
  prepare_for_view()
  checkdate()
  timestamp_today()
  timestamp_tomorrow()
  add_sidecalendar_blocks()
  calendar_get_pollinterval_choices()
  calendar_get_eventtype_choices()
  calendar_add_subscription()
  calendar_add_icalendar_event()
  calendar_process_subscription_row()
  calendar_delete_subscription()
  calendar_get_icalendar()
  calendar_import_icalendar_events()
  calendar_update_subscription_events()
  calendar_update_subscription()
  calendar_can_edit_subscription()
  calendar_cron()
  calendar_get_calendar_context()

Defines 19 functions

  calendar_get_days()
  calendar_get_subscription()
  calendar_get_starting_weekday()
  calendar_get_mini()
  calendar_get_popup()
  calendar_get_upcoming()
  calendar_get_courselink()
  calendar_add_event_metadata()
  calendar_get_events()
  calendar_get_events_by_id()
  calendar_top_controls()
  calendar_filter_controls_element()
  calendar_filter_controls()
  calendar_day_representation()
  calendar_time_representation()
  calendar_get_link_href()
  calendar_get_link_previous()
  calendar_get_link_next()
  calendar_wday_name()
  calendar_days_in_month()
  calendar_get_block_upcoming()
  calendar_add_month()
  calendar_sub_month()
  calendar_events_by_day()
  calendar_get_module_cached()
  calendar_get_course_cached()
  calendar_get_group_cached()
  calendar_set_filters()
  calendar_edit_event_allowed()
  calendar_get_default_courses()
  calendar_preferences_button()
  calendar_format_event_time()
  calendar_print_month_selector()
  calendar_show_event_type()
  calendar_set_event_type_display()
  calendar_get_allowed_types()
  calendar_user_can_add_event()
  calendar_add_event_allowed()

Class: calendar_event  - X-Ref

Manage calendar events

This class provides the required functionality in order to manage calendar events.
It was introduced as part of Moodle 2.0 and was created in order to provide a
better framework for dealing with calendar events in particular regard to file
handling through the new file API

__construct($data=null)   X-Ref
Instantiates a new event and optionally populates its properties with the
data provided

param: stdClass $data Optional. An object containing the properties to for

__set($key, $value)   X-Ref
Magic property method

Attempts to call a set_$key method if one exists otherwise falls back
to simply set the property

param: string $key property name
param: mixed $value value of the property

__get($key)   X-Ref
Magic get method

Attempts to call a get_$key method to return the property and ralls over
to return the raw property

param: string $key property name
return: mixed property value

__isset($key)   X-Ref
Stupid PHP needs an isset magic method if you use the get magic method and
still want empty calls to work.... blah ~!

param: string $key $key property name
return: bool|mixed property value, false if property is not exist

calculate_context(stdClass $data)   X-Ref
Calculate the context value needed for calendar_event.
Event's type can be determine by the available value store in $data
It is important to check for the existence of course/courseid to determine
the course event.
Default value is set to CONTEXT_USER

param: stdClass $data information about event
return: stdClass The context object.

get_editoroptions()   X-Ref
Returns an array of editoroptions for this event: Called by __get
Please use $blah = $event->editoroptions;

return: array event editor options

get_description()   X-Ref
Returns an event description: Called by __get
Please use $blah = $event->description;

return: string event description

count_repeats()   X-Ref
Return the number of repeat events there are in this events series

return: int number of event repeated

update($data, $checkcapability=true)   X-Ref
Update or create an event within the database

Pass in a object containing the event properties and this function will
insert it into the database and deal with any associated files

param: stdClass $data object of event
param: bool $checkcapability if moodle should check calendar managing capability or not
return: bool event updated

delete($deleterepeated=false)   X-Ref
Deletes an event and if selected an repeated events in the same series

This function deletes an event, any associated events if $deleterepeated=true,
and cleans up any files associated with the events.

param: bool $deleterepeated  delete event repeatedly
return: bool succession of deleting event

properties($prepareeditor=false)   X-Ref
Fetch all event properties

This function returns all of the events properties as an object and optionally
can prepare an editor for the description field at the same time. This is
designed to work when the properties are going to be used to set the default
values of a moodle forms form.

param: bool $prepareeditor If set to true a editor is prepared for use with
return: stdClass Object containing event properties

toggle_visibility($force=null)   X-Ref
Toggles the visibility of an event

param: null|bool $force If it is left null the events visibility is flipped,
return: bool if event is successfully updated, toggle will be visible

calendar_event_hook($action, array $args)   X-Ref
Attempts to call the hook for the specified action should a calendar type
by set $CFG->calendar, and the appopriate function defined

param: string $action One of `update_event`, `add_event`, `delete_event`, `show_event`, `hide_event`
param: array $args The args to pass to the hook, usually the event is the first element
return: bool attempts to call event hook

load($param)   X-Ref
Returns a calendar_event object when provided with an event id

This function makes use of MUST_EXIST, if the event id passed in is invalid
it will result in an exception being thrown

param: int|object $param event object or event id
return: calendar_event|false status for loading calendar_event

create($properties, $checkcapability = true)   X-Ref
Creates a new event and returns a calendar_event object

param: stdClass|array $properties An object containing event properties
param: bool $checkcapability Check caps or not
return: calendar_event|bool The event object or false if it failed

format_external_text()   X-Ref
Format the text using the external API.
This function should we used when text formatting is required in external functions.

return: array an array containing the text formatted and the text format

Class: calendar_information  - X-Ref

Calendar information class

This class is used simply to organise the information pertaining to a calendar
and is used primarily to make information easily available.

__construct($day = 0, $month = 0, $year = 0, $time = 0)   X-Ref
Creates a new instance

param: int $day the number of the day
param: int $month the number of the month
param: int $year the number of the year
param: int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth

prepare_for_view(stdClass $course, array $coursestoload, $ignorefilters = false)   X-Ref
Initialize calendar information

param: stdClass $course object
param: array $coursestoload An array of courses [$course->id => $course]
param: bool $ignorefilters options to use filter

checkdate($defaultonow = true)   X-Ref
Ensures the date for the calendar is correct and either sets it to now
or throws a moodle_exception if not

param: bool $defaultonow use current time
return: bool validation of checkdate

timestamp_today()   X-Ref
Gets todays timestamp for the calendar

return: int today timestamp

timestamp_tomorrow()   X-Ref
Gets tomorrows timestamp for the calendar

return: int tomorrow timestamp

add_sidecalendar_blocks(core_calendar_renderer $renderer, $showfilters=false, $view=null)   X-Ref
Adds the pretend blocks for the calendar

param: core_calendar_renderer $renderer
param: bool $showfilters display filters, false is set as default
param: string|null $view preference view options (eg: day, month, upcoming)

calendar_get_pollinterval_choices()   X-Ref
Returns option list for the poll interval setting.

return: array An array of poll interval options. Interval => description.

calendar_get_eventtype_choices($courseid)   X-Ref
Returns option list of available options for the calendar event type, given the current user and course.

param: int $courseid The id of the course
return: array An array containing the event types the user can create.

calendar_add_subscription($sub)   X-Ref
Add an iCalendar subscription to the database.

param: stdClass $sub The subscription object (e.g. from the form)
return: int The insert ID, if any.

calendar_add_icalendar_event($event, $courseid, $subscriptionid, $timezone='UTC')   X-Ref
Add an iCalendar event to the Moodle calendar.

param: stdClass $event The RFC-2445 iCalendar event
param: int $courseid The course ID
param: int $subscriptionid The iCalendar subscription ID
param: string $timezone The X-WR-TIMEZONE iCalendar property if provided
return: int Code: CALENDAR_IMPORT_EVENT_UPDATED = updated,  CALENDAR_IMPORT_EVENT_INSERTED = inserted, 0 = error

calendar_process_subscription_row($subscriptionid, $pollinterval, $action)   X-Ref
Update a subscription from the form data in one of the rows in the existing subscriptions table.

param: int $subscriptionid The ID of the subscription we are acting upon.
param: int $pollinterval The poll interval to use.
param: int $action The action to be performed. One of update or remove.
return: string A log of the import progress, including errors

calendar_delete_subscription($subscription)   X-Ref
Delete subscription and all related events.

param: int|stdClass $subscription subscription or it's id, which needs to be deleted.

calendar_get_icalendar($url)   X-Ref
From a URL, fetch the calendar and return an iCalendar object.

param: string $url The iCalendar URL
return: stdClass The iCalendar object

calendar_import_icalendar_events($ical, $courseid, $subscriptionid = null)   X-Ref
Import events from an iCalendar object into a course calendar.

param: stdClass $ical The iCalendar object.
param: int $courseid The course ID for the calendar.
param: int $subscriptionid The subscription ID.
return: string A log of the import progress, including errors.

calendar_update_subscription_events($subscriptionid)   X-Ref
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.

calendar_update_subscription($subscription)   X-Ref
Update a calendar subscription. Also updates the associated cache.

param: stdClass|array $subscription Subscription record.

calendar_can_edit_subscription($subscriptionorid)   X-Ref
Checks to see if the user can edit a given subscription feed.

param: mixed $subscriptionorid Subscription object or id
return: bool true if current user can edit the subscription else false

calendar_cron()   X-Ref
Update calendar subscriptions.

return: bool

calendar_get_calendar_context($subscription)   X-Ref
Helper function to determine the context of a calendar subscription.
Subscriptions can be created in two contexts COURSE, or USER.

param: stdClass $subscription
return: context instance

Functions
Functions that are not part of a class:

calendar_get_days()   X-Ref
Return the days of the week

return: array array of days

calendar_get_subscription($id)   X-Ref
Get the subscription from a given id

param: int $id id of the subscription
return: stdClass Subscription record from DB

calendar_get_starting_weekday()   X-Ref
Gets the first day of the week

Used to be define('CALENDAR_STARTING_WEEKDAY', blah);

return: int

calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyear = false, $placement = false,$courseid = false, $time = 0)   X-Ref
Generates the HTML for a miniature calendar

param: array $courses list of course to list events from
param: array $groups list of group
param: array $users user's info
param: int|bool $calmonth calendar month in numeric, default is set to false
param: int|bool $calyear calendar month in numeric, default is set to false
param: string|bool $placement the place/page the calendar is set to appear - passed on the the controls function
param: int|bool $courseid id of the course the calendar is displayed on - passed on the the controls function
param: int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth
return: string $content return html table for mini calendar

calendar_get_popup($today = false, $timestart, $popupcontent = '')   X-Ref
Gets the calendar popup

It called at multiple points in from calendar_get_mini.
Copied and modified from calendar_get_mini.

param: bool $is_today false except when called on the current day.
param: mixed $event_timestart $events[$eventid]->timestart, OR false if there are no events.
param: string $popupcontent content for the popup window/layout.
return: string eventid for the calendar_tooltip popup window/layout.

calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0)   X-Ref
Gets the calendar upcoming event

param: array $courses array of courses
param: array|int|bool $groups array of groups, group id or boolean for all/no group events
param: array|int|bool $users array of users, user id or boolean for all/no user events
param: int $daysinfuture number of days in the future we 'll look
param: int $maxevents maximum number of events
param: int $fromtime start time
return: array $output array of upcoming events

calendar_get_courselink($courseid)   X-Ref
Get a HTML link to a course.

param: int $courseid the course id
return: string a link to the course (as HTML); empty if the course id is invalid

calendar_add_event_metadata($event)   X-Ref
Add calendar event metadata

param: stdClass $event event info
return: stdClass $event metadata

calendar_get_events($tstart, $tend, $users, $groups, $courses, $withduration=true, $ignorehidden=true)   X-Ref
Get calendar events

param: int $tstart Start time of time range for events
param: int $tend End time of time range for events
param: array|int|boolean $users array of users, user id or boolean for all/no user events
param: array|int|boolean $groups array of groups, group id or boolean for all/no group events
param: array|int|boolean $courses array of courses, course id or boolean for all/no course events
param: boolean $withduration whether only events starting within time range selected
param: boolean $ignorehidden whether to select only visible events or all events
return: array $events of selected events or an empty array if there aren't any (or there was an error)

calendar_get_events_by_id($eventids)   X-Ref
No description

calendar_top_controls($type, $data)   X-Ref
Get control options for Calendar

param: string $type of calendar
param: array $data calendar information
return: string $content return available control for the calender in html

calendar_filter_controls_element(moodle_url $url, $type)   X-Ref
Formats a filter control element.

param: moodle_url $url of the filter
param: int $type constant defining the type filter
return: string html content of the element

calendar_filter_controls(moodle_url $returnurl)   X-Ref
Get the controls filter for calendar.

Filter is used to hide calendar info from the display page

param: moodle_url $returnurl return-url for filter controls
return: string $content return filter controls in html

calendar_day_representation($tstamp, $now = false, $usecommonwords = true)   X-Ref
Return the representation day

param: int $tstamp Timestamp in GMT
param: int $now current Unix timestamp
param: bool $usecommonwords
return: string the formatted date/time

calendar_time_representation($time)   X-Ref
return the formatted representation time

param: int $time the timestamp in UTC, as obtained from the database
return: string the formatted date/time

calendar_get_link_href($linkbase, $d, $m, $y, $time = 0)   X-Ref
Adds day, month, year arguments to a URL and returns a moodle_url object.

param: string|moodle_url $linkbase
param: int $d The number of the day.
param: int $m The number of the month.
param: int $y The number of the year.
param: int $time the unixtime, used for multiple calendar support. The values $d,
return: moodle_url|null $linkbase

calendar_get_link_previous($text, $linkbase, $d, $m, $y, $accesshide = false, $time = 0)   X-Ref
Build and return a previous month HTML link, with an arrow.

param: string $text The text label.
param: string|moodle_url $linkbase The URL stub.
param: int $d The number of the date.
param: int $m The number of the month.
param: int $y year The number of the year.
param: bool $accesshide Default visible, or hide from all except screenreaders.
param: int $time the unixtime, used for multiple calendar support. The values $d,
return: string HTML string.

calendar_get_link_next($text, $linkbase, $d, $m, $y, $accesshide = false, $time = 0)   X-Ref
Build and return a next month HTML link, with an arrow.

param: string $text The text label.
param: string|moodle_url $linkbase The URL stub.
param: int $d the number of the Day
param: int $m The number of the month.
param: int $y The number of the year.
param: bool $accesshide Default visible, or hide from all except screenreaders.
param: int $time the unixtime, used for multiple calendar support. The values $d,
return: string HTML string.

calendar_wday_name($englishname)   X-Ref
Return the name of the weekday

param: string $englishname
return: string of the weekeday

calendar_days_in_month($month, $year)   X-Ref
Return the number of days in month

param: int $month the number of the month.
param: int $year the number of the year
return: int

calendar_get_block_upcoming($events, $linkhref = NULL, $showcourselink = false)   X-Ref
Get the upcoming event block

param: array $events list of events
param: moodle_url|string $linkhref link to event referer
param: boolean $showcourselink whether links to courses should be shown
return: string|null $content html block content

calendar_add_month($month, $year)   X-Ref
Get the next following month

param: int $month the number of the month.
param: int $year the number of the year.
return: array the following month

calendar_sub_month($month, $year)   X-Ref
Get the previous month.

param: int $month the number of the month.
param: int $year the number of the year.
return: array previous month

calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday, &$courses)   X-Ref
Get per-day basis events

param: array $events list of events
param: int $month the number of the month
param: int $year the number of the year
param: array $eventsbyday event on specific day
param: array $durationbyday duration of the event in days
param: array $typesbyday event type (eg: global, course, user, or group)
param: array $courses list of courses
return: void

calendar_get_module_cached(&$coursecache, $modulename, $instance)   X-Ref
Get current module cache

param: array $coursecache list of course cache
param: string $modulename name of the module
param: int $instance module instance number
return: stdClass|bool $module information

calendar_get_course_cached(&$coursecache, $courseid)   X-Ref
Get current course cache

param: array $coursecache list of course cache
param: int $courseid id of the course
return: stdClass $coursecache[$courseid] return the specific course cache

calendar_get_group_cached($groupid)   X-Ref
Get group from groupid for calendar display

param: int $groupid
return: stdClass group object with fields 'id', 'name' and 'courseid'

calendar_set_filters(array $courseeventsfrom, $ignorefilters = false)   X-Ref
Returns the courses to load events for, the

param: array $courseeventsfrom An array of courses to load calendar events for
param: bool $ignorefilters specify the use of filters, false is set as default
return: array An array of courses, groups, and user to load calendar events for based upon filters

calendar_edit_event_allowed($event)   X-Ref
Return the capability for editing calendar event

param: calendar_event $event event object
return: bool capability to edit event

calendar_get_default_courses()   X-Ref
Returns the default courses to display on the calendar when there isn't a specific
course to display.

return: array $courses Array of courses to display

calendar_preferences_button(stdClass $course)   X-Ref
Display calendar preference button

param: stdClass $course course object
return: string return preference button in html

calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime = 0)   X-Ref
Get event format time

param: calendar_event $event event object
param: int $now current time in gmt
param: array $linkparams list of params for event link
param: bool $usecommonwords the words as formatted date/time.
param: int $showtime determine the show time GMT timestamp
return: string $eventtime link/string for event time

calendar_print_month_selector($name, $selected)   X-Ref
Display month selector options

param: string $name for the select element
param: string|array $selected options for select elements

calendar_show_event_type($type, $user = null)   X-Ref
Checks to see if the requested type of event should be shown for the given user.

param: CALENDAR_EVENT_GLOBAL|CALENDAR_EVENT_COURSE|CALENDAR_EVENT_GROUP|CALENDAR_EVENT_USER $type
param: stdClass|int|null $user The user to check for - by default the current user
return: bool True if the tyep should be displayed false otherwise

calendar_set_event_type_display($type, $display = null, $user = null)   X-Ref
Sets the display of the event type given $display.

If $display = true the event type will be shown.
If $display = false the event type will NOT be shown.
If $display = null the current value will be toggled and saved.

param: CALENDAR_EVENT_GLOBAL|CALENDAR_EVENT_COURSE|CALENDAR_EVENT_GROUP|CALENDAR_EVENT_USER $type object of CALENDAR_EVENT_XXX
param: bool $display option to display event type
param: stdClass|int $user moodle user object or id, null means current user

calendar_get_allowed_types(&$allowed, $course = null)   X-Ref
Get calendar's allowed types

param: stdClass $allowed list of allowed edit for event  type
param: stdClass|int $course object of a course or course id

calendar_user_can_add_event($course)   X-Ref
See if user can add calendar entries at all
used to print the "New Event" button

param: stdClass $course object of a course or course id
return: bool has the capability to add at least one event type

calendar_add_event_allowed($event)   X-Ref
Check wether the current user is permitted to add events

param: stdClass $event object of event
return: bool has the capability to add event



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1