Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Files | Namespaces | Classes | Functions | Variables
mod_chat

Files

file  access.php
 Plugin capabilities.
 
file  activity.php
 Search area for mod_chat activities.
 
file  activity_base.php
 Activity base class.
 
file  backup_chat_activity_task.class.php
 Defines backup_chat_activity_task class.
 
file  backup_chat_stepslib.php
 @subpackage backup-moodle2
 
file  chat_message_exporter.php
 Class for exporting a chat message.
 
file  cognitive_depth.php
 Cognitive depth indicator - chat.
 
file  course_module_instance_list_viewed.php
 The mod_chat instance list viewed event.
 
file  course_module_viewed.php
 The mod_chat course module viewed event.
 
file  cron_task.php
 A scheduled task for chat cron.
 
file  events.php
 Event observers definition.
 
file  external.php
 Chat external API.
 
file  lib.php
 Provides support for the conversion of moodle1 backup to the moodle2 format Based off of a template @ http://docs.moodle.org/dev/Backup_1.9_conversion_for_developers.
 
file  lib.php
 Library of functions and constants for module chat.
 
file  locallib.php
 Library of functions for chat outside of the core api.
 
file  log.php
 Definition of log events.
 
file  message_sent.php
 The mod_chat message sent event.
 
file  provider.php
 Data provider.
 
file  renderer.php
 Chat module rendering methods.
 
file  restore_chat_activity_task.class.php
 @subpackage backup-moodle2
 
file  restore_chat_stepslib.php
 @subpackage backup-moodle2
 
file  services.php
 Chat external functions and service definitions.
 
file  sessions_viewed.php
 The mod_chat sessions viewed event.
 
file  social_breadth.php
 Social breadth indicator - chat.
 
file  tasks.php
 Definition of chat scheduled tasks.
 
file  upgrade.php
 Upgrade code for the chat activity.
 
file  version.php
 Version information.
 

Namespaces

namespace  mod_chat\analytics\indicator
  
 
namespace  mod_chat\event
  
 
namespace  mod_chat\external
  
 
namespace  mod_chat\privacy
  
 
namespace  mod_chat\search
  
 
namespace  mod_chat\task
  
 

Classes

class  backup_chat_activity_structure_step
 Define all the backup steps that will be used by the backup_chat_activity_task. More...
 
class  backup_chat_activity_task
 Provides the steps to perform one complete backup of the Chat instance. More...
 
class  chat_portfolio_caller
 
class  event_message
 A chat event such a user entering or leaving a chat activity. More...
 
class  mod_chat\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_chat\analytics\indicator\cognitive_depth
 Cognitive depth indicator - chat. More...
 
class  mod_chat\analytics\indicator\social_breadth
 Social breadth indicator - chat. More...
 
class  mod_chat\event\course_module_instance_list_viewed
 The mod_chat instance list viewed event class. More...
 
class  mod_chat\event\course_module_viewed
 The mod_chat course module viewed event class. More...
 
class  mod_chat\event\message_sent
 The mod_chat message sent event class. More...
 
class  mod_chat\event\sessions_viewed
 
class  mod_chat\external\chat_message_exporter
 Class for exporting a chat message. More...
 
class  mod_chat\privacy\provider
 Data provider class. More...
 
class  mod_chat\search\activity
 Search area for mod_chat activities. More...
 
class  mod_chat\task\cron_task
 The main schedule task for the chat module. More...
 
class  mod_chat_external
 
class  mod_chat_renderer
 Chat module renderer class. More...
 
class  moodle1_mod_chat_handler
 Chat conversion handler. More...
 
class  restore_chat_activity_structure_step
 Define all the restore steps that will be used by the restore_chat_activity_task. More...
 
class  restore_chat_activity_task
 chat restore task that provides all the settings and steps to perform one complete restore of the activity More...
 
class  user_message
 A chat message from a user. More...
 

Functions

object chat_add_instance ($chat)
 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. More...
 
object chat_delete_instance ($id)
 Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it. More...
 
object chat_delete_old_users ()
 Delete the old and in the way. More...
 
 chat_extend_navigation ($navigation, $course, $module, $cm)
 
 chat_extend_settings_navigation (settings_navigation $settings, navigation_node $chatnode)
 Adds module specific settings to the settings block. More...
 
object chat_format_message ($message, $courseid, $currentuser, $chatlastrow=null)
 Given a message object this function formats it appropriately into text and html then returns the formatted data. More...
 
object chat_format_message_manually ($message, $courseid, $sender, $currentuser, $chatlastrow=null)
 @global object More...
 
object chat_format_message_theme ($message, $chatuser, $currentuser, $groupingid, $theme='bubble')
 
object chat_format_userlist ($users, $course)
 $DB @global object $CFG @global object $COURSE @global object $OUTPUT More...
 
object chat_get_latest_message ($chatid, $groupid=0)
 
 chat_get_latest_messages ($chatuser, $chatlasttime)
 Return a list of the latest messages in the given chat session. More...
 
 chat_get_post_actions ()
 List the actions that correspond to a post of this module. More...
 
 chat_get_session_messages ($chatid, $group=false, $start=0, $end=0, $sort='')
 Return the messages of the given chat session. More...
 
 chat_get_sessions ($messages, $showall=false)
 Given a set of messages for a chat, return the completed chat sessions (including optionally not completed ones). More...
 
object chat_get_users ($chatid, $groupid=0, $groupingid=0)
 
 chat_get_view_actions ()
 List the actions that correspond to a view of this module. More...
 
object chat_login_user ($chatid, $version, $groupid, $course)
 login if not already logged in More...
 
 chat_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 chat_prepare_update_events ($chat, $cm=null)
 Updates both the normal and completion calendar events for chat. More...
 
 chat_print_error ($level, $msg)
 Print json format error. More...
 
 chat_print_overview ()
 
object chat_print_recent_activity ($course, $viewfullnames, $timestart)
 Given a course and a date, prints a summary of all chat rooms past and present This function is called from block_recent_activity. More...
 
object chat_refresh_events ($courseid=0, $instance=null, $cm=null)
 This standard function will check all instances of this module and make sure there are up-to-date events created for each of them. More...
 
 chat_reset_course_form_defaults ($course)
 Course reset form defaults. More...
 
 chat_reset_course_form_definition (&$mform)
 Implementation of the function for printing the form elements that control whether the course reset functionality affects the chat. More...
 
object chat_reset_userdata ($data)
 Actual implementation of the reset course functionality, delete all the chat messages for course $data->courseid. More...
 
 chat_send_chatmessage ($chatuser, $messagetext, $issystem=false, $cm=null)
 Send a message on the chat. More...
 
 chat_supports ($feature)
 
object chat_update_chat_times ($chatid=0)
 Updates chat records so that the next chat time is correct. More...
 
object chat_update_instance ($chat)
 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. More...
 
 chat_user_logout (\core\event\user_loggedout $event)
 user logout event handler More...
 
 chat_view ($chat, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event. More...
 
 mod_chat_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none. More...
 
 padding ($n)
 
 xmldb_chat_upgrade ($oldversion)
 

Variables

 $capabilities
 
global $CHAT_DUMMY_DATA = padding(200)
 
global $CHAT_HTMLHEAD
 
 $CHAT_HTMLHEAD_JS =
 
 $CHAT_HTMLHEAD_MSGINPUT
 
 $CHAT_HTMLHEAD_MSGINPUT_JS =
 
global $CHAT_HTMLHEAD_OUT
 
 $functions
 
 $logs
 
 $observers
 
 $plugin = 2020060900
 
 $tasks
 
const CHAT_EVENT_TYPE_CHATTIME 'chattime'
 
const CHAT_SESSION_GAP 300
 
$plugin component = 'mod_chat'
 
$plugin version = 2020061500
 

Detailed Description

Function Documentation

◆ chat_add_instance()

object chat_add_instance (   $chat)

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$chat
Return values
int

◆ chat_delete_instance()

object chat_delete_instance (   $id)

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

Parameters
int$id
Return values
bool

◆ chat_delete_old_users()

object chat_delete_old_users ( )

Delete the old and in the way.

@global object

◆ chat_extend_settings_navigation()

chat_extend_settings_navigation ( settings_navigation  $settings,
navigation_node  $chatnode 
)

Adds module specific settings to the settings block.

Parameters
settings_navigation$settingsThe settings navigation object
navigation_node$chatnodeThe node to add module settings to

◆ chat_format_message()

object chat_format_message (   $message,
  $courseid,
  $currentuser,
  $chatlastrow = null 
)

Given a message object this function formats it appropriately into text and html then returns the formatted data.

Parameters
object$message
int$courseid
object$currentuser
string$chatlastrow
Return values
bool|stringReturns HTML or false

◆ chat_format_message_manually()

object chat_format_message_manually (   $message,
  $courseid,
  $sender,
  $currentuser,
  $chatlastrow = null 
)

@global object

Parameters
object$message
int$courseid
object$sender
object$currentuser
string$chatlastrow
Return values
bool|stringReturns HTML or false

◆ chat_format_message_theme()

object chat_format_message_theme (   $message,
  $chatuser,
  $currentuser,
  $groupingid,
  $theme = 'bubble' 
)
Parameters
object$messagemessage to be displayed.
mixed$chatuseruser chat data
object$currentusercurrent user for whom the message should be displayed.
int$groupingidcourse module grouping id
string$themename of the chat theme.
Return values
bool|stringReturns HTML or false

◆ chat_format_userlist()

object chat_format_userlist (   $users,
  $course 
)

$DB @global object $CFG @global object $COURSE @global object $OUTPUT

Parameters
object$users
object$course
Return values
arrayreturn formatted user list

◆ chat_get_latest_message()

object chat_get_latest_message (   $chatid,
  $groupid = 0 
)
Parameters
int$chatid
int$groupid
Return values
array

◆ chat_get_latest_messages()

chat_get_latest_messages (   $chatuser,
  $chatlasttime 
)

Return a list of the latest messages in the given chat session.

Parameters
stdClass$chatuserchat user session data
int$chatlasttimelast time messages were retrieved
Return values
arraylist of messages
Since
Moodle 3.0

◆ chat_get_post_actions()

chat_get_post_actions ( )

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 values
array

◆ chat_get_session_messages()

chat_get_session_messages (   $chatid,
  $group = false,
  $start = 0,
  $end = 0,
  $sort = '' 
)

Return the messages of the given chat session.

Parameters
int$chatidthe chat id
mixed$groupfalse if groups not used, int if groups used, 0 means all groups
int$startthe session start timestamp (0 to not filter by time)
int$endthe session end timestamp (0 to not filter by time)
string$sortan order to sort the results in (optional, a valid SQL ORDER BY parameter)
Return values
arraysession messages
Since
Moodle 3.5

◆ chat_get_sessions()

chat_get_sessions (   $messages,
  $showall = false 
)

Given a set of messages for a chat, return the completed chat sessions (including optionally not completed ones).

Parameters
array$messageslist of messages from a chat. It is assumed that these are sorted by timestamp in DESCENDING order.
bool$showallwhether to include incomplete sessions or not
Return values
arraythe list of sessions
Since
Moodle 3.5

◆ chat_get_users()

object chat_get_users (   $chatid,
  $groupid = 0,
  $groupingid = 0 
)
Parameters
int$chatid
int$groupid
int$groupingid
Return values
array

◆ chat_get_view_actions()

chat_get_view_actions ( )

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 values
array

◆ chat_login_user()

object chat_login_user (   $chatid,
  $version,
  $groupid,
  $course 
)

login if not already logged in

@global object

Parameters
int$chatid
string$version
int$groupid
object$course
Return values
bool|intReturns the chat users sid or false

◆ chat_page_type_list()

chat_page_type_list (   $pagetype,
  $parentcontext,
  $currentcontext 
)

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

◆ chat_prepare_update_events()

chat_prepare_update_events (   $chat,
  $cm = null 
)

Updates both the normal and completion calendar events for chat.

Parameters
stdClass$chatThe chat object (from the DB)
stdClass$cmThe course module object.

◆ chat_print_error()

chat_print_error (   $level,
  $msg 
)

Print json format error.

Parameters
string$level
string$msg

◆ chat_print_overview()

chat_print_overview ( )
Deprecated:
since Moodle 3.3, when the block_course_overview block was removed.

◆ chat_print_recent_activity()

object chat_print_recent_activity (   $course,
  $viewfullnames,
  $timestart 
)

Given a course and a date, prints a summary of all chat rooms past and present This function is called from block_recent_activity.

@global object @global object

Parameters
object$course
bool$viewfullnames
int | string$timestartTimestamp
Return values
bool

◆ chat_refresh_events()

object chat_refresh_events (   $courseid = 0,
  $instance = null,
  $cm = null 
)

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()

Parameters
int$courseid
int | stdClass$instanceChat module instance or ID.
int | stdClass$cmCourse module object or ID.
Return values
bool

◆ chat_reset_course_form_defaults()

chat_reset_course_form_defaults (   $course)

Course reset form defaults.

Parameters
object$course
Return values
array

◆ chat_reset_course_form_definition()

chat_reset_course_form_definition ( $mform)

Implementation of the function for printing the form elements that control whether the course reset functionality affects the chat.

Parameters
object$mformform passed by reference

◆ chat_reset_userdata()

object chat_reset_userdata (   $data)

Actual implementation of the reset course functionality, delete all the chat messages for course $data->courseid.

@global object

Parameters
object$datathe data submitted from the reset course.
Return values
arraystatus array

◆ chat_send_chatmessage()

chat_send_chatmessage (   $chatuser,
  $messagetext,
  $issystem = false,
  $cm = null 
)

Send a message on the chat.

Parameters
object$chatuserThe chat user record.
string$messagetextThe message to be sent.
bool$issystemFalse for non-system messages, true for system messages.
object$cmThe course module object, pass it to save a database query when we trigger the event.
Return values
intThe message ID.
Since
Moodle 2.6

◆ chat_supports()

chat_supports (   $feature)
Parameters
string$featureFEATURE_xx constant for requested feature
Return values
mixedTrue if module supports feature, null if doesn't know

◆ chat_update_chat_times()

object chat_update_chat_times (   $chatid = 0)

Updates chat records so that the next chat time is correct.

Parameters
int$chatid
Return values
void

◆ chat_update_instance()

object chat_update_instance (   $chat)

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$chat
Return values
bool

◆ chat_user_logout()

chat_user_logout ( \core\event\user_loggedout  $event)

user logout event handler

Parameters
core::event::user_loggedout$eventThe event.
Return values
void

◆ chat_view()

chat_view (   $chat,
  $course,
  $cm,
  $context 
)

Mark the activity completed (if required) and trigger the course_module_viewed event.

Parameters
stdClass$chatchat object
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Since
Moodle 3.0

◆ mod_chat_core_calendar_provide_event_action()

mod_chat_core_calendar_provide_event_action ( calendar_event  $event,
core_calendar\action_factory  $factory,
int  $userid = 0 
)

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.

Parameters
calendar_event$event
core_calendar::action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar::local::event::entities::action_interface|null

◆ padding()

padding (   $n)
Parameters
int$n
Return values
string

Variable Documentation

◆ $CHAT_HTMLHEAD

$CHAT_HTMLHEAD
Initial value:
= "<!DOCTYPE HTML PUBLIC "-
global $CHAT_HTMLHEAD_JS

◆ $CHAT_HTMLHEAD_MSGINPUT

$CHAT_HTMLHEAD_MSGINPUT
Initial value:
= "<!DOCTYPE HTML PUBLIC "-
global $CHAT_HTMLHEAD_MSGINPUT_JS

◆ $CHAT_HTMLHEAD_OUT

$CHAT_HTMLHEAD_OUT
Initial value:
= "<!DOCTYPE HTML PUBLIC "-
global $CHAT_HTMLHEAD_MSGINPUT

◆ $logs

$logs
Initial value:
= array(
array('module' => 'chat', 'action' => 'view', 'mtable' => 'chat', 'field' => 'name'),
array('module' => 'chat', 'action' => 'add', 'mtable' => 'chat', 'field' => 'name'),
array('module' => 'chat', 'action' => 'update', 'mtable' => 'chat', 'field' => 'name'),
array('module' => 'chat', 'action' => 'report', 'mtable' => 'chat', 'field' => 'name'),
array('module' => 'chat', 'action' => 'talk', 'mtable' => 'chat', 'field' => 'name'),
)

◆ $observers

$observers
Initial value:
= array(
array(
'eventname' => '\core\event\user_loggedout',
'callback' => 'chat_user_logout',
'includefile' => '/mod/chat/lib.php'
)
)

◆ $tasks

$tasks
Initial value:
= array(
array(
'classname' => '\mod_chat\task\cron_task',
'blocking' => 0,
'minute' => '*/5',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
)