[ Index ] |
PHP Cross Reference of Unnamed Project |
[Source view] [Print] [Project Stats]
Library functions for messaging
Copyright: | 2008 Luis Rodrigues |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 2976 lines (116 kb) |
Included or required: | 3 times |
Referenced: | 12 times |
Includes or requires: | 2 files message/search.html message/search_advanced.html |
message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showactionlinks, $page=0) X-Ref |
Print the selector that allows the user to view their contacts, course participants, their recent conversations etc param: int $countunreadtotal how many unread messages does the user have? param: int $viewing What is the user viewing? ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_SEARCH etc param: object $user1 the user whose messages are being viewed param: object $user2 the user $user1 is talking to param: array $blockedusers an array of users blocked by $user1 param: array $onlinecontacts an array of $user1's online contacts param: array $offlinecontacts an array of $user1's offline contacts param: array $strangers an array of users who have messaged $user1 who aren't contacts param: bool $showactionlinks show action links (add/remove contact etc) param: int $page if there are so many users listed that they have to be split into pages what page are we viewing return: void |
message_print_participants($context, $courseid, $contactselecturl=null, $showactionlinks=true, $titletodisplay=null, $page=0, $user2=null) X-Ref |
Print course participants. Called by message_print_contact_selector() param: object $context the course context param: int $courseid the course ID param: string $contactselecturl the url to send the user to when a contact's name is clicked param: bool $showactionlinks show action links (add/remove contact etc) next to the users param: string $titletodisplay Optionally specify a title to display above the participants param: int $page if there are so many users listed that they have to be split into pages what page are we viewing param: object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of participants return: void |
message_get_blocked_users($user1=null, $user2=null) X-Ref |
Retrieve users blocked by $user1 param: object $user1 the user whose messages are being viewed param: object $user2 the user $user1 is talking to. If they are being blocked return: array the users blocked by $user1 |
message_print_blocked_users($blockedusers, $contactselecturl=null, $showactionlinks=true, $titletodisplay=null, $user2=null) X-Ref |
Print users blocked by $user1. Called by message_print_contact_selector() param: array $blockedusers the users blocked by $user1 param: string $contactselecturl the url to send the user to when a contact's name is clicked param: bool $showactionlinks show action links (add/remove contact etc) next to the users param: string $titletodisplay Optionally specify a title to display above the participants param: object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of blocked users return: void |
message_get_contacts($user1=null, $user2=null) X-Ref |
Retrieve $user1's contacts (online, offline and strangers) param: object $user1 the user whose messages are being viewed param: object $user2 the user $user1 is talking to. If they are a contact return: array containing 3 arrays. array($onlinecontacts, $offlinecontacts, $strangers) |
message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $contactselecturl=null, $minmessages=0, $showactionlinks=true, $titletodisplay=null, $user2=null) X-Ref |
Print $user1's contacts. Called by message_print_contact_selector() param: array $onlinecontacts $user1's contacts which are online param: array $offlinecontacts $user1's contacts which are offline param: array $strangers users which are not contacts but who have messaged $user1 param: string $contactselecturl the url to send the user to when a contact's name is clicked param: int $minmessages The minimum number of unread messages required from a user for them to be displayed param: bool $showactionlinks show action links (add/remove contact etc) next to the users param: string $titletodisplay Optionally specify a title to display above the participants param: object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of contacts return: void |
message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages, $user1 = null) X-Ref |
Print a select box allowing the user to choose to view new messages, course participants etc. Called by message_print_contact_selector() param: int $viewing What page is the user viewing ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_RECENT_CONVERSATIONS etc param: array $courses array of course objects. The courses the user is enrolled in. param: array $coursecontexts array of course contexts. Keyed on course id. param: int $countunreadtotal how many unread messages does the user have? param: int $countblocked how many users has the current user blocked? param: stdClass $user1 The user whose messages we are viewing. param: string $strunreadmessages a preconstructed message about the number of unread messages the user has return: void |
message_get_course_contexts($courses) X-Ref |
Load the course contexts for all of the users courses param: array $courses array of course objects. The courses the user is enrolled in. return: array of course contexts |
message_remove_url_params($moodleurl) X-Ref |
strip off action parameters like 'removecontact' param: moodle_url/string $moodleurl a URL. Typically the current page URL. return: string the URL minus parameters that perform actions (like adding/removing/blocking a contact). |
message_count_messages($messagearray, $field='', $value='') X-Ref |
Count the number of messages with a field having a specified value. if $field is empty then return count of the whole array if $field is non-existent then return 0 param: array $messagearray array of message objects param: string $field the field to inspect on the message objects param: string $value the value to test the field against |
message_count_unread_messages($user1=null, $user2=null) X-Ref |
Returns the count of unread messages for user. Either from a specific user or from all users. param: object $user1 the first user. Defaults to $USER param: object $user2 the second user. If null this function will count all of user 1's unread messages. return: int the count of $user1's unread messages |
message_count_blocked_users($user1=null) X-Ref |
Count the number of users blocked by $user1 param: object $user1 user object return: int the number of blocked users |
message_print_search($advancedsearch = false, $user1=null) X-Ref |
Print the search form and search results if a search has been performed param: boolean $advancedsearch show basic or advanced search form param: object $user1 the current user return: boolean true if a search was performed |
message_get_recent_conversations($user, $limitfrom=0, $limitto=100) X-Ref |
Get the users recent conversations meaning all the people they've recently sent or received a message from plus the most recent message sent to or received from each other user param: object $user the current user param: int $limitfrom can be used for paging param: int $limitto can be used for paging return: array |
message_get_recent_notifications($user, $limitfrom=0, $limitto=100) X-Ref |
Get the users recent event notifications param: object $user the current user param: int $limitfrom can be used for paging param: int $limitto can be used for paging return: array |
message_print_recent_conversations($user1 = null, $showicontext = false, $showactionlinks = true) X-Ref |
Print the user's recent conversations param: stdClass $user the current user param: bool $showicontext flag indicating whether or not to show text next to the action icons |
message_print_recent_notifications($user=null) X-Ref |
Print the user's recent notifications param: stdClass $user the current user |
message_print_recent_messages_table($messages, $user = null, $showotheruser = true, $showicontext = false, $forcetexttohtml = false, $showactionlinks = true) X-Ref |
Print a list of recent messages param: array $messages the messages to display param: stdClass $user the current user param: bool $showotheruser display information on the other user? param: bool $showicontext show text next to the action icons? param: bool $forcetexttohtml Force text to go through @see text_to_html() via @see format_text() param: bool $showactionlinks return: void |
message_format_message_text($message, $forcetexttohtml = false) X-Ref |
Try to guess how to convert the message to html. param: stdClass $message param: bool $forcetexttohtml return: string html fragment |
message_add_contact($contactid, $blocked=0) X-Ref |
Add the selected user as a contact for the current user param: int $contactid the ID of the user to add as a contact param: int $blocked 1 if you wish to block the contact return: bool/int false if the $contactid isnt a valid user id. True if no changes made. |
message_remove_contact($contactid) X-Ref |
remove a contact param: int $contactid the user ID of the contact to remove return: bool returns the result of delete_records() |
message_unblock_contact($contactid) X-Ref |
Unblock a contact. Note that this reverts the previously blocked user back to a non-contact. param: int $contactid the user ID of the contact to unblock return: bool returns the result of delete_records() |
message_block_contact($contactid) X-Ref |
Block a user. param: int $contactid the user ID of the user to block return: bool |
message_can_delete_message($message, $userid) X-Ref |
Checks if a user can delete a message. param: stdClass $message the message to delete param: string $userid the user id of who we want to delete the message for (this may be done by the admin return: bool Returns true if a user can delete the message, false otherwise. |
message_delete_message($message, $userid) X-Ref |
Deletes a message. This function does not verify any permissions. param: stdClass $message the message to delete param: string $userid the user id of who we want to delete the message for (this may be done by the admin return: bool |
message_get_contact($contactid) X-Ref |
Load a user's contact record param: int $contactid the user ID of the user whose contact record you want return: array message contacts |
message_print_search_results($frm, $showicontext=false, $currentuser=null) X-Ref |
Print the results of a message search param: mixed $frm submitted form data param: bool $showicontext show text next to action icons? param: object $currentuser the current user return: void |
message_print_user($user=false, $iscontact=false, $isblocked=false, $includeicontext=false) X-Ref |
Print information on a user. Used when printing search results. param: object/bool $user the user to display or false if you just want $USER param: bool $iscontact is the user being displayed a contact? param: bool $isblocked is the user being displayed blocked? param: bool $includeicontext include text next to the action icons? return: void |
message_contact_link($userid, $linktype='add', $return=false, $script=null, $text=false, $icon=true) X-Ref |
Print a message contact link param: int $userid the ID of the user to apply to action to param: string $linktype can be add, remove, block or unblock param: bool $return if true return the link as a string. If false echo the link. param: string $script the URL to send the user to when the link is clicked. If null, the current page. param: bool $text include text next to the icons? param: bool $icon include a graphical icon? return: string if $return is true otherwise bool |
message_history_link($userid1, $userid2, $return=false, $keywords='', $position='', $linktext='') X-Ref |
echo or return a link to take the user to the full message history between themselves and another user param: int $userid1 the ID of the user displayed on the left (usually the current user) param: int $userid2 the ID of the other user param: bool $return true to return the link as a string. False to echo the link. param: string $keywords any keywords to highlight in the message history param: string $position anchor name to jump to within the message history param: string $linktext optionally specify the link text return: string|bool. Returns a string if $return is true. Otherwise returns a boolean. |
message_search_users($courseids, $searchtext, $sort='', $exceptions='') X-Ref |
Search through course users. If $courseids contains the site course then this function searches through all undeleted and confirmed users. param: int|array $courseids Course ID or array of course IDs. param: string $searchtext the text to search for. param: string $sort the column name to order by. param: string|array $exceptions comma separated list or array of user IDs to exclude. return: array An array of {@link $USER} records. |
message_search($searchterms, $fromme=true, $tome=true, $courseid='none', $userid=0) X-Ref |
Search a user's messages Returns a list of posts found using an array of search terms eg word +word -word param: array $searchterms an array of search terms (strings) param: bool $fromme include messages from the user? param: bool $tome include messages to the user? param: mixed $courseid SITEID for admins searching all messages. Other behaviour not yet implemented param: int $userid the user ID of the current user return: mixed An array of messages or false if no matching messages were found |
message_shorten_message($message, $minlength = 0) X-Ref |
Given a message object that we already know has a long message this function truncates the message nicely to the first sane place between $CFG->forum_longpost and $CFG->forum_shortpost param: string $message the message param: int $minlength the minimum length to trim the message to return: string the shortened message |
message_get_fragment($message, $keywords) X-Ref |
Given a string and an array of keywords, this function looks for the first keyword in the string, and then chops out a small section from the text that shows that word in context. param: string $message the text to search param: array $keywords array of keywords to find |
message_get_history($user1, $user2, $limitnum=0, $viewingnewmessages=false) X-Ref |
Retrieve the messages between two users param: object $user1 the current user param: object $user2 the other user param: int $limitnum the maximum number of messages to retrieve param: bool $viewingnewmessages are we currently viewing new messages? |
message_print_message_history($user1, $user2 ,$search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false, $showactionlinks = true) X-Ref |
Print the message history between two users param: object $user1 the current user param: object $user2 the other user param: string $search search terms to highlight param: int $messagelimit maximum number of messages to return param: string $messagehistorylink the html for the message history link or false param: bool $viewingnewmessages are we currently viewing new messages? |
message_format_message($message, $format='', $keywords='', $class='other') X-Ref |
Format a message for display in the message history param: object $message the message object param: string $format optional date format param: string $keywords keywords to highlight param: string $class CSS class to apply to the div around the message return: string the formatted message |
message_format_contexturl($message) X-Ref |
Format a the context url and context url name of a message for display param: object $message the message object return: string the formatted string |
message_post_message($userfrom, $userto, $message, $format) X-Ref |
Send a message from one user to another. Will be delivered according to the message recipients messaging preferences param: object $userfrom the message sender param: object $userto the message recipient param: string $message the message param: int $format message format such as FORMAT_PLAIN or FORMAT_HTML return: int|false the ID of the new message or false |
message_print_contactlist_user($contact, $incontactlist = true, $isblocked = false, $selectcontacturl = null, $showactionlinks = true, $selecteduser=null) X-Ref |
Print a row of contactlist displaying user picture, messages waiting and block links etc param: object $contact contact object containing all fields required for $OUTPUT->user_picture() param: bool $incontactlist is the user a contact of ours? param: bool $isblocked is the user blocked? param: string $selectcontacturl the url to send the user to when a contact's name is clicked param: bool $showactionlinks display action links next to the other users (add contact, block user etc) param: object $selecteduser the user the current user is viewing (if any). They will be highlighted. return: void |
message_get_contact_add_remove_link($incontactlist, $isblocked, $contact, $script=null, $text=false, $icon=true) X-Ref |
Constructs the add/remove contact link to display next to other users param: bool $incontactlist is the user a contact param: bool $isblocked is the user blocked param: stdClass $contact contact object param: string $script the URL to send the user to when the link is clicked. If null, the current page. param: bool $text include text next to the icons? param: bool $icon include a graphical icon? return: string |
message_get_contact_block_link($incontactlist, $isblocked, $contact, $script=null, $text=false, $icon=true) X-Ref |
Constructs the block contact link to display next to other users param: bool $incontactlist is the user a contact? param: bool $isblocked is the user blocked? param: stdClass $contact contact object param: string $script the URL to send the user to when the link is clicked. If null, the current page. param: bool $text include text next to the icons? param: bool $icon include a graphical icon? return: string |
message_move_userfrom_unread2read($userid) X-Ref |
Moves messages from a particular user from the message table (unread messages) to message_read This is typically only used when a user is deleted param: object $userid User id return: boolean success |
message_mark_messages_read($touserid, $fromuserid) X-Ref |
marks ALL messages being sent from $fromuserid to $touserid as read param: int $touserid the id of the message recipient param: int $fromuserid the id of the message sender return: void |
message_mark_message_read($message, $timeread, $messageworkingempty=false) X-Ref |
Mark a single message as read param: stdClass $message An object with an object property ie $message->id which is an id in the message table param: int $timeread the timestamp for when the message should be marked read. Usually time(). param: bool $messageworkingempty Is the message_working table already confirmed empty for this message? return: int the ID of the message in the message_read table |
get_message_processors($ready = false, $reset = false, $resetonly = false) X-Ref |
Get all message processors, validate corresponding plugin existance and system configuration param: bool $ready only return ready-to-use processors param: bool $reset Reset list of message processors (used in unit tests) param: bool $resetonly Just reset, then exit return: mixed $processors array of objects containing information on message processors |
get_message_providers() X-Ref |
Get all message providers, validate their plugin existance and system configuration return: mixed $processors array of objects containing information on message processors |
get_message_processor($type) X-Ref |
Get an instance of the message_output class for one of the output plugins. param: string $type the message output type. E.g. 'email' or 'jabber'. return: message_output message_output the requested class. |
get_message_output_default_preferences() X-Ref |
Get messaging outputs default (site) preferences return: object $processors object containing information on message processors |
translate_message_default_setting($plugindefault, $processorname) X-Ref |
Translate message default settings from binary value to the array of string representing the settings to be stored. Also validate the provided value and use default if it is malformed. param: int $plugindefault Default setting suggested by plugin param: string $processorname The name of processor return: array $settings array of strings in the order: $permitted, $loggedin, $loggedoff. |
message_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 |
message_get_messages($useridto, $useridfrom = 0, $notifications = -1, $read = true,$sort = 'mr.timecreated DESC', $limitfrom = 0, $limitnum = 0) X-Ref |
Get messages sent or/and received by the specified users. Please note that this function return deleted messages too. param: int $useridto the user id who received the message param: int $useridfrom the user id who sent the message. -10 or -20 for no-reply or support user param: int $notifications 1 for retrieving notifications, 0 for messages, -1 for both param: bool $read true for retrieving read messages, false for unread param: string $sort the column name to order by including optionally direction param: int $limitfrom limit from param: int $limitnum limit num return: external_description |
message_messenger_requirejs() X-Ref |
Requires the JS libraries to send a message using a dialog. return: void |
message_messenger_sendmessage_link_params($user) X-Ref |
Returns the attributes to place on a link to open the 'Send message' dialog. param: object $user User object. return: void |
message_can_post_message($recipient, $sender = null) X-Ref |
Determines if a user is permitted to send another user a private message. If no sender is provided then it defaults to the logged in user. param: object $recipient User object. param: object $sender User object. return: bool true if user is permitted, false otherwise. |
message_is_user_non_contact_blocked($recipient, $sender = null) X-Ref |
Checks if the recipient is allowing messages from users that aren't a contact. If not then it checks to make sure the sender is in the recipient's contacts. param: object $recipient User object. param: object $sender User object. return: bool true if $sender is blocked, false otherwise. |
message_is_user_blocked($recipient, $sender = null) X-Ref |
Checks if the recipient has specifically blocked the sending user. Note: This function will always return false if the sender has the readallmessages capability at the system context level. param: object $recipient User object. param: object $sender User object. return: bool true if $sender is blocked, false otherwise. |
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |