lib.php

Library of interface functions and constants for module ejsappbooking

All the core Moodle functions, neeeded to allow the module to work integrated in Moodle are here.

Functions

ejsappbooking_supports()

ejsappbooking_supports(string  $feature) : mixed

Returns the information on whether the module supports a feature

Parameters

string $feature

FEATURE_xx constant for requested feature

Returns

mixed —

true if the feature is supported, null if unknown

ejsappbooking_add_instance()

ejsappbooking_add_instance(object  $ejsappbooking) : integer

Saves a new instance of the ejsappbooking into the database

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance.

Parameters

object $ejsappbooking

An object from the form in mod_form.php

Returns

integer —

The id of the newly inserted ejsappbooking record

ejsappbooking_update_instance()

ejsappbooking_update_instance(object  $ejsappbooking) : boolean

Updates an instance of the ejsappbooking in the database

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.

Parameters

object $ejsappbooking

An object from the form in mod_form.php

Returns

boolean —

Success/Fail

ejsappbooking_delete_instance()

ejsappbooking_delete_instance(integer  $id) : boolean

Removes an instance of the ejsappbooking from the database

Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.

Parameters

integer $id

Id of the module instance

Returns

boolean —

Success/Failure

ejsappbooking_user_outline()

ejsappbooking_user_outline(integer  $course,   $user,   $mod,   $ejsappbooking) : \stdClass|null

Returns a small object with summary information about what a user has done with a given particular instance of this module Used for user activity reports.

$return->time = the time they did it $return->info = a short text description

Parameters

integer $course
$user
$mod
$ejsappbooking

Returns

\stdClass|null

ejsappbooking_user_complete()

ejsappbooking_user_complete(\stdClass  $course, \stdClass  $user, \cm_info  $mod, \stdClass  $ejsappbooking) : \void,

Prints a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.

Parameters

\stdClass $course

the current course record

\stdClass $user

the record of the user we are generating report for

\cm_info $mod

course module info

\stdClass $ejsappbooking

the module instance record

Returns

\void, —

is supposed to echp directly

ejsappbooking_print_recent_activity()

ejsappbooking_print_recent_activity(  $course,   $viewfullnames,   $timestart) : boolean

Given a course and a time, this module should find recent activity that has occurred in ejsappbooking activities and print it out.

Return true if there was output, or false is there was none.

Parameters

$course
$viewfullnames
$timestart

Returns

boolean

ejsappbooking_get_recent_mod_activity()

ejsappbooking_get_recent_mod_activity(array  $activities, integer  $index, integer  $timestart, integer  $courseid, integer  $cmid, integer  $userid, integer  $groupid) : void

Prepares the recent activity data

This callback function is supposed to populate the passed array with custom activity records. These records are then rendered into HTML via ejsappbooking_print_recent_mod_activity().

Parameters

array $activities

sequentially indexed array of objects with the 'cmid' property

integer $index

the index in the $activities to use for the next record

integer $timestart

append activity since this time

integer $courseid

the id of the course we produce the report for

integer $cmid

course module id

integer $userid

check for a particular user's activity only, defaults to 0 (all users)

integer $groupid

check for a particular group's activity only, defaults to 0 (all groups)

ejsappbooking_print_recent_mod_activity()

ejsappbooking_print_recent_mod_activity(  $activity,   $courseid,   $detail,   $modnames,   $viewfullnames) : void

Prints single activity item prepared by {@see ejsappbooking_get_recent_mod_activity()}

Parameters

$activity
$courseid
$detail
$modnames
$viewfullnames

ejsappbooking_cron()

ejsappbooking_cron() : boolean

Function to be run periodically according to the moodle cron This function checks whether all users and all ejsapps are in the ejsappbooking_usersaccess database. If not, it adds them. It is necessary when a ejsappbooking instance has already been added to a course and then new ejsapp are added or new users are enrolled to that course. Also, the function checks if there are users and ejsapps in the ejsappbooking_usersaccess database that no longer exist. In that case, it deletes them.

Returns

boolean

ejsappbooking_get_extra_capabilities()

ejsappbooking_get_extra_capabilities() : array

Returns all other caps used in the module

Returns

array

Examples

array('moodle/site:accessallgroups');
** File not found : return **

ejsappbooking_get_file_areas()

ejsappbooking_get_file_areas(\stdClass  $course, \stdClass  $cm, \stdClass  $context) : array

Returns the lists of all browsable file areas within the given module context

The file area 'intro' for the activity introduction field is added automatically by \file_browser::get_file_info_context_module()

Parameters

\stdClass $course
\stdClass $cm
\stdClass $context

Returns

array —

of [(string)filearea] => (string)description

ejsappbooking_get_file_info()

ejsappbooking_get_file_info(\file_browser  $browser, array  $areas, \stdClass  $course, \stdClass  $cm, \stdClass  $context, string  $filearea, integer  $itemid, string  $filepath, string  $filename) : \file_info

File browsing support for ejsappbooking file areas

Parameters

\file_browser $browser
array $areas
\stdClass $course
\stdClass $cm
\stdClass $context
string $filearea
integer $itemid
string $filepath
string $filename

Returns

\file_info —

instance or null if not found

ejsappbooking_pluginfile()

ejsappbooking_pluginfile(\stdClass  $course, \stdClass  $cm, \stdClass  $context, string  $filearea, array  $args, boolean  $forcedownload, array  $options = array()) 

Serves the files from the ejsappbooking file areas

Parameters

\stdClass $course

the course object

\stdClass $cm

the course module object

\stdClass $context

the ejsappbooking's context

string $filearea

the name of the file area

array $args

extra arguments (itemid, path)

boolean $forcedownload

whether or not force download

array $options

additional options affecting the file serving

ejsappbooking_extend_navigation()

ejsappbooking_extend_navigation(\navigation_node  $navref, \stdClass  $course, \stdClass  $module, \cm_info  $cm) 

Extends the global navigation tree by adding ejsappbooking nodes if there is a relevant content

This can be called by an AJAX request so do not rely on $PAGE as it might not be set up properly.

Parameters

\navigation_node $navref

An object representing the navigation tree node of the ejsappbooking module instance

\stdClass $course
\stdClass $module
\cm_info $cm

ejsappbooking_extend_settings_navigation()

ejsappbooking_extend_settings_navigation(\settings_navigation  $settings,   $ejsappbookingnode) : void

This function extends the settings navigation block for the site.

It is safe to rely on PAGE here as we will only ever be within the module context when this is called

Parameters

\settings_navigation $settings
$ejsappbookingnode