Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Library of functions and constants for module chat
Copyright: | 1999 onwards Martin Dougiamas {@link http://moodle.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1607 lines (58 kb) |
Included or required: | 11 times |
Referenced: | 5 times |
Includes or requires: | 0 files |
move() X-Ref |
No description |
empty_field_and_submit() X-Ref |
No description |
padding($n) X-Ref |
param: int $n return: string |
chat_add_instance($chat) X-Ref |
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. param: object $chat return: int |
chat_update_instance($chat) X-Ref |
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. param: object $chat return: bool |
chat_delete_instance($id) X-Ref |
Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it. param: int $id return: bool |
chat_print_recent_activity($course, $viewfullnames, $timestart) X-Ref |
Given a course and a date, prints a summary of all chat rooms past and present This function is called from block_recent_activity param: object $course param: bool $viewfullnames param: int|string $timestart Timestamp return: bool |
chat_refresh_events($courseid = 0, $instance = null, $cm = null) X-Ref |
This standard function will check all instances of this module and make sure there are up-to-date events created for each of them. If courseid = 0, then every chat event in the site is checked, else only chat events belonging to the course specified are checked. This function is used, in its new format, by restore_refresh_events() param: int $courseid param: int|stdClass $instance Chat module instance or ID. param: int|stdClass $cm Course module object or ID. return: bool |
chat_prepare_update_events($chat, $cm = null) X-Ref |
Updates both the normal and completion calendar events for chat. param: stdClass $chat The chat object (from the DB) param: stdClass $cm The course module object. |
chat_get_users($chatid, $groupid=0, $groupingid=0) X-Ref |
param: int $chatid param: int $groupid param: int $groupingid return: array |
chat_get_latest_message($chatid, $groupid=0) X-Ref |
param: int $chatid param: int $groupid return: array |
chat_login_user($chatid, $version, $groupid, $course) X-Ref |
login if not already logged in param: int $chatid param: string $version param: int $groupid param: object $course return: bool|int Returns the chat users sid or false |
chat_delete_old_users() X-Ref |
Delete the old and in the way |
chat_calculate_next_chat_time(int $schedule, int $chattime) X-Ref |
Calculate next chat session time based on schedule. param: int $schedule param: int $chattime return: int timestamp |
chat_update_chat_times($chatid=0) X-Ref |
Updates chat records so that the next chat time is correct param: int $chatid return: void |
chat_send_chatmessage($chatuser, $messagetext, $issystem = false, $cm = null) X-Ref |
Send a message on the chat. param: object $chatuser The chat user record. param: string $messagetext The message to be sent. param: bool $issystem False for non-system messages, true for system messages. param: object $cm The course module object, pass it to save a database query when we trigger the event. return: int The message ID. |
chat_format_message_manually($message, $courseid, $sender, $currentuser, $chatlastrow = null) X-Ref |
param: object $message param: int $courseid param: object $sender param: object $currentuser param: string $chatlastrow return: bool|string Returns HTML or false |
chat_format_message($message, $courseid, $currentuser, $chatlastrow=null) X-Ref |
Given a message object this function formats it appropriately into text and html then returns the formatted data param: object $message param: int $courseid param: object $currentuser param: string $chatlastrow return: bool|string Returns HTML or false |
chat_format_message_theme($message, $chatuser, $currentuser, $groupingid, $theme = 'bubble') X-Ref |
param: object $message message to be displayed. param: mixed $chatuser user chat data param: object $currentuser current user for whom the message should be displayed. param: int $groupingid course module grouping id param: string $theme name of the chat theme. return: bool|string Returns HTML or false |
chat_format_userlist($users, $course) X-Ref |
param: object $users param: object $course return: array return formatted user list |
chat_print_error($level, $msg) X-Ref |
Print json format error param: string $level param: string $msg |
chat_get_view_actions() X-Ref |
List the actions that correspond to a view of this module. This is used by the participation report. Note: This is not used by new logging system. Event with crud = 'r' and edulevel = LEVEL_PARTICIPATING will be considered as view action. return: array |
chat_get_post_actions() X-Ref |
List the actions that correspond to a post of this module. This is used by the participation report. Note: This is not used by new logging system. Event with crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING will be considered as post action. return: array |
chat_print_overview() X-Ref |
chat_reset_course_form_definition(&$mform) X-Ref |
Implementation of the function for printing the form elements that control whether the course reset functionality affects the chat. param: object $mform form passed by reference |
chat_reset_course_form_defaults($course) X-Ref |
Course reset form defaults. param: object $course return: array |
chat_reset_userdata($data) X-Ref |
Actual implementation of the reset course functionality, delete all the chat messages for course $data->courseid. param: object $data the data submitted from the reset course. return: array status array |
chat_supports($feature) X-Ref |
param: string $feature FEATURE_xx constant for requested feature return: mixed True if module supports feature, null if doesn't know |
chat_extend_navigation($navigation, $course, $module, $cm) X-Ref |
No description |
chat_extend_settings_navigation(settings_navigation $settings, navigation_node $chatnode) X-Ref |
Adds module specific settings to the settings block param: settings_navigation $settings The settings navigation object param: navigation_node $chatnode The node to add module settings to |
chat_user_logout(\core\event\user_loggedout $event) X-Ref |
user logout event handler param: \core\event\user_loggedout $event The event. return: void |
chat_page_type_list($pagetype, $parentcontext, $currentcontext) X-Ref |
Return a list of page types param: string $pagetype current page type param: stdClass $parentcontext Block's parent context param: stdClass $currentcontext Current context of block |
chat_get_latest_messages($chatuser, $chatlasttime) X-Ref |
Return a list of the latest messages in the given chat session. param: stdClass $chatuser chat user session data param: int $chatlasttime last time messages were retrieved return: array list of messages |
chat_view($chat, $course, $cm, $context) X-Ref |
Mark the activity completed (if required) and trigger the course_module_viewed event. param: stdClass $chat chat object param: stdClass $course course object param: stdClass $cm course module object param: stdClass $context context object |
mod_chat_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0) X-Ref |
This function receives a calendar event and returns the action associated with it, or null if there is none. This is used by block_myoverview in order to display the event appropriately. If null is returned then the event is not displayed on the block. param: calendar_event $event param: \core_calendar\action_factory $factory param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default). return: \core_calendar\local\event\entities\action_interface|null |
chat_get_sessions($messages, $showall = false) X-Ref |
Given a set of messages for a chat, return the completed chat sessions (including optionally not completed ones). param: array $messages list of messages from a chat. It is assumed that these are sorted by timestamp in DESCENDING order. param: bool $showall whether to include incomplete sessions or not return: array the list of sessions |
chat_get_session_messages($chatid, $group = false, $start = 0, $end = 0, $sort = '') X-Ref |
Return the messages of the given chat session. param: int $chatid the chat id param: mixed $group false if groups not used, int if groups used, 0 means all groups param: int $start the session start timestamp (0 to not filter by time) param: int $end the session end timestamp (0 to not filter by time) param: string $sort an order to sort the results in (optional, a valid SQL ORDER BY parameter) return: array session messages |
chat_get_coursemodule_info($coursemodule) X-Ref |
Add a get_coursemodule_info function in case chat instance wants to add 'extra' information for the course (see resource). Given a course_module object, this function returns any "extra" information that may be needed when printing this activity in a course listing. See get_array_of_activities() in course/lib.php. param: stdClass $coursemodule The coursemodule object (record). return: cached_cm_info An object on information that the courses |