idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
28,200
function _storeArray ( $ elAry ) { if ( is_array ( $ this -> _currentGroup ) && ( 'group' != $ elAry [ 'type' ] ) ) { $ this -> _currentGroup [ 'elements' ] [ ] = $ elAry ; } elseif ( isset ( $ this -> _currentSection ) ) { $ this -> _ary [ 'sections' ] [ $ this -> _currentSection ] [ 'elements' ] [ ] = $ elAry ; } els...
Stores an array representation of an element in the form array
28,201
function setElementStyle ( $ elementName , $ styleName = null ) { if ( is_array ( $ elementName ) ) { $ this -> _elementStyles = array_merge ( $ this -> _elementStyles , $ elementName ) ; } else { $ this -> _elementStyles [ $ elementName ] = $ styleName ; } }
Sets a style to use for element rendering
28,202
public function get_gradinginstance ( ) { if ( is_array ( $ this -> gradingattributes ) && array_key_exists ( 'gradinginstance' , $ this -> gradingattributes ) ) { return $ this -> gradingattributes [ 'gradinginstance' ] ; } else { return null ; } }
Helper function to retrieve gradingform_instance passed in element attributes
28,203
public function onQuickFormEvent ( $ event , $ arg , & $ caller ) { if ( $ event == 'createElement' ) { $ attributes = $ arg [ 2 ] ; if ( ! is_array ( $ attributes ) || ! array_key_exists ( 'gradinginstance' , $ attributes ) || ! ( $ attributes [ 'gradinginstance' ] instanceof gradingform_instance ) ) { throw new moodl...
Called by HTML_QuickForm whenever form event is made on this element . Adds necessary rules to the element and checks that coorenct instance of gradingform_instance is passed in attributes
28,204
public static function search_messages ( $ userid , $ search , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; $ ufields = \ user_picture :: fields ( 'u' , array ( 'lastaccess' ) , 'userfrom_id' , 'userfrom_' ) ; $ ufields2 = \ user_picture :: fields ( 'u2' , array ( 'lastaccess' ) , 'userto_id' , 'userto_' ) ; $ un...
Handles searching for messages in the message area .
28,205
public static function search_users_in_course ( $ userid , $ courseid , $ search , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; list ( $ esql , $ params ) = get_enrolled_sql ( \ context_course :: instance ( $ courseid ) , '' , 0 , true ) ; $ sql = "SELECT u.*, mub.id as isblocked FROM {user} u ...
Handles searching for user in a particular course in the message area .
28,206
protected static function get_linked_conversation_extra_fields ( array $ conversations ) : array { global $ DB , $ PAGE ; $ renderer = $ PAGE -> get_renderer ( 'core' ) ; $ linkedconversations = [ ] ; foreach ( $ conversations as $ conversation ) { if ( ! is_null ( $ conversation -> component ) && ! is_null ( $ convers...
Gets extra fields like image url and subname for any conversations linked to components .
28,207
public static function get_conversations_between_users ( int $ userid1 , int $ userid2 , int $ limitfrom = 0 , int $ limitnum = 20 ) : array { global $ DB ; if ( $ userid1 == $ userid2 ) { return array ( ) ; } $ sql = "SELECT mc.id, mc.type, mc.name, mc.timecreated FROM {message_conversations} mc ...
Returns all conversations between two users
28,208
public static function set_favourite_conversation ( int $ conversationid , int $ userid ) : favourite { global $ DB ; if ( ! self :: is_user_in_conversation ( $ userid , $ conversationid ) ) { throw new \ moodle_exception ( "Conversation doesn't exist or user is not a member" ) ; } $ conversation = $ DB -> get_record (...
Mark a conversation as a favourite for the given user .
28,209
public static function unset_favourite_conversation ( int $ conversationid , int $ userid ) { global $ DB ; $ conversation = $ DB -> get_record ( 'message_conversations' , [ 'id' => $ conversationid ] ) ; $ userctx = \ context_user :: instance ( $ userid ) ; if ( empty ( $ conversation -> contextid ) ) { $ conversation...
Unset a conversation as a favourite for the given user .
28,210
public static function get_contacts ( $ userid , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; $ contactids = [ ] ; $ sql = "SELECT mc.* FROM {message_contacts} mc WHERE mc.userid = ? OR mc.contactid = ? ORDER BY timecreated DESC" ; if ( $ contacts = $ DB -> get_record...
Returns the contacts to display in the contacts area .
28,211
public static function get_user_contacts ( int $ userid , int $ limitfrom = 0 , int $ limitnum = 0 ) { global $ DB ; $ sql = "SELECT * FROM {message_contacts} mc WHERE mc.userid = ? OR mc.contactid = ? ORDER BY timecreated DESC, id ASC" ; if ( $ contacts = $ DB -> get_recor...
Get the contacts for a given user .
28,212
public static function count_contacts ( int $ userid ) : int { global $ DB ; $ sql = "SELECT COUNT(id) FROM {message_contacts} WHERE userid = ? OR contactid = ?" ; return $ DB -> count_records_sql ( $ sql , [ $ userid , $ userid ] ) ; }
Returns the contacts count .
28,213
public static function get_non_contacts_with_unread_message_count ( $ userid , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; $ userfields = \ user_picture :: fields ( 'u' , array ( 'lastaccess' ) ) ; $ unreadcountssql = "SELECT $userfields, count(m.id) as messagecount FROM {user} u ...
Returns the an array of the users the given user is in a conversation with who are not a contact and the number of unread messages .
28,214
public static function get_messages ( $ userid , $ otheruserid , $ limitfrom = 0 , $ limitnum = 0 , $ sort = 'timecreated ASC' , $ timefrom = 0 , $ timeto = 0 ) { if ( ! empty ( $ timefrom ) ) { $ userids = [ $ userid , $ otheruserid ] ; if ( ! $ conversationid = self :: get_conversation_between_users ( $ userids ) ) {...
Returns the messages to display in the message area .
28,215
public static function get_conversation_messages ( int $ userid , int $ convid , int $ limitfrom = 0 , int $ limitnum = 0 , string $ sort = 'timecreated ASC' , int $ timefrom = 0 , int $ timeto = 0 ) : array { if ( ! empty ( $ timefrom ) ) { $ cache = \ cache :: make ( 'core' , 'message_time_last_message_between_users'...
Returns the messages for the defined conversation .
28,216
public static function get_most_recent_message ( $ userid , $ otheruserid ) { if ( $ messages = helper :: get_messages ( $ userid , $ otheruserid , 0 , 0 , 2 , 'timecreated DESC' ) ) { $ messages = array_reverse ( $ messages ) ; $ arrmessages = helper :: create_messages ( $ userid , $ messages ) ; return array_pop ( $ ...
Returns the most recent message between two users .
28,217
public static function get_most_recent_conversation_message ( int $ convid , int $ currentuserid = 0 ) { global $ USER ; if ( empty ( $ currentuserid ) ) { $ currentuserid = $ USER -> id ; } if ( $ messages = helper :: get_conversation_messages ( $ currentuserid , $ convid , 0 , 0 , 1 , 'timecreated DESC' ) ) { $ convm...
Returns the most recent message in a conversation .
28,218
public static function get_profile ( $ userid , $ otheruserid ) { global $ CFG , $ PAGE ; require_once ( $ CFG -> dirroot . '/user/lib.php' ) ; $ user = \ core_user :: get_user ( $ otheruserid , '*' , MUST_EXIST ) ; $ data = new \ stdClass ( ) ; $ data -> userid = $ otheruserid ; $ data -> fullname = fullname ( $ user ...
Returns the profile information for a contact for a user .
28,219
public static function can_delete_conversation ( int $ userid , int $ conversationid = null ) : bool { global $ USER ; if ( is_null ( $ conversationid ) ) { debugging ( '\core_message\api::can_delete_conversation() now expects a \'conversationid\' to be passed.' , DEBUG_DEVELOPER ) ; return false ; } $ systemcontext = ...
Checks if a user can delete messages they have either received or sent .
28,220
public static function delete_conversation_by_id ( int $ userid , int $ conversationid ) { global $ DB , $ USER ; $ sql = "SELECT m.* FROM {messages} m INNER JOIN {message_conversations} mc ON m.conversationid = mc.id LEFT JOIN {message_user_actions} mua ...
Deletes a conversation for a specified user .
28,221
public static function can_mark_all_messages_as_read ( int $ userid , int $ conversationid ) : bool { global $ USER ; $ systemcontext = \ context_system :: instance ( ) ; if ( has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { return true ; } if ( ! self :: is_user_in_conversation ( $ userid , $ con...
Checks if a user can mark all messages as read .
28,222
public static function mark_all_messages_as_read ( $ userid , $ conversationid = null ) { global $ DB ; $ messagesql = "SELECT m.* FROM {messages} m INNER JOIN {message_conversations} mc ON mc.id = m.conversationid INNER JOIN {message...
Marks all messages being sent to a user in a particular conversation .
28,223
public static function mark_all_notifications_as_read ( $ touserid , $ fromuserid = null ) { global $ DB ; $ notificationsql = "SELECT n.* FROM {notifications} n WHERE useridto = ? AND timeread is NULL" ; $ notificationsparams = [ $ ...
Marks all notifications being sent from one user to another user as read .
28,224
public static function get_all_message_preferences ( $ processors , $ providers , $ user ) { $ preferences = helper :: get_providers_preferences ( $ providers , $ user -> id ) ; $ preferences -> userdefaultemail = $ user -> email ; foreach ( $ processors as $ processor ) { $ processor -> object -> load_data ( $ prefere...
Returns message preferences .
28,225
public static function count_blocked_users ( $ user = null ) { global $ USER , $ DB ; if ( empty ( $ user ) ) { $ user = $ USER ; } $ sql = "SELECT count(mub.id) FROM {message_users_blocked} mub WHERE mub.userid = :userid" ; return $ DB -> count_records_sql ( $ sql , array ( 'userid' =>...
Count the number of users blocked by a user .
28,226
public static function can_post_message ( $ recipient , $ sender = null ) { global $ USER ; if ( is_null ( $ sender ) ) { $ sender = $ USER ; } $ systemcontext = \ context_system :: instance ( ) ; if ( ! has_capability ( 'moodle/site:sendmessage' , $ systemcontext , $ sender ) ) { return false ; } if ( has_capability (...
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 .
28,227
public static function can_send_message_to_conversation ( int $ userid , int $ conversationid ) : bool { global $ DB ; $ systemcontext = \ context_system :: instance ( ) ; if ( ! has_capability ( 'moodle/site:sendmessage' , $ systemcontext , $ userid ) ) { return false ; } if ( ! self :: is_user_in_conversation ( $ use...
Determines if a user is permitted to send a message to a given conversation . If no sender is provided then it defaults to the logged in user .
28,228
public static function is_user_non_contact_blocked ( $ recipient , $ sender = null ) { debugging ( '\core_message\api::is_user_non_contact_blocked() is deprecated' , DEBUG_DEVELOPER ) ; global $ USER , $ CFG ; if ( is_null ( $ sender ) ) { $ sender = $ USER ; } $ privacypreference = self :: get_user_privacy_messaging_p...
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 .
28,229
public static function is_user_blocked ( $ recipientid , $ senderid = null ) { debugging ( '\core_message\api::is_user_blocked is deprecated and should not be used.' , DEBUG_DEVELOPER ) ; global $ USER ; if ( is_null ( $ senderid ) ) { $ senderid = $ USER -> id ; } $ systemcontext = \ context_system :: instance ( ) ; i...
Checks if the recipient has specifically blocked the sending user .
28,230
public static function get_message_processor ( $ name , $ ready = false ) { global $ DB , $ CFG ; $ processor = $ DB -> get_record ( 'message_processors' , array ( 'name' => $ name ) ) ; if ( empty ( $ processor ) ) { return array ( ) ; } $ processor = self :: get_processed_processor_object ( $ processor ) ; if ( $ rea...
Get specified message processor validate corresponding plugin existence and system configuration .
28,231
public static function update_processor_status ( $ processor , $ enabled ) { global $ DB ; $ cache = \ cache :: make ( 'core' , 'message_processors_enabled' ) ; $ cache -> delete ( $ processor -> name ) ; return $ DB -> set_field ( 'message_processors' , 'enabled' , $ enabled , array ( 'id' => $ processor -> id ) ) ; }
Set status of a processor .
28,232
public static function mark_message_as_read ( $ userid , $ message , $ timeread = null ) { global $ DB ; if ( is_null ( $ timeread ) ) { $ timeread = time ( ) ; } $ mua = new \ stdClass ( ) ; $ mua -> userid = $ userid ; $ mua -> messageid = $ message -> id ; $ mua -> action = self :: MESSAGE_ACTION_READ ; $ mua -> tim...
Mark a single message as read .
28,233
public static function can_delete_message ( $ userid , $ messageid ) { global $ DB , $ USER ; $ systemcontext = \ context_system :: instance ( ) ; $ conversationid = $ DB -> get_field ( 'messages' , 'conversationid' , [ 'id' => $ messageid ] , MUST_EXIST ) ; if ( has_capability ( 'moodle/site:deleteanymessage' , $ syst...
Checks if a user can delete a message .
28,234
public static function get_conversation_between_users ( array $ userids ) { global $ DB ; $ conversations = self :: get_individual_conversations_between_users ( [ $ userids ] ) ; $ conversation = $ conversations [ 0 ] ; if ( $ conversation ) { return $ conversation -> id ; } return false ; }
Returns the conversation between two users .
28,235
public static function get_individual_conversations_between_users ( array $ useridsets ) : array { global $ DB ; if ( empty ( $ useridsets ) ) { return [ ] ; } $ hashes = array_map ( function ( $ userids ) { return helper :: get_conversation_hash ( $ userids ) ; } , $ useridsets ) ; list ( $ inorequalsql , $ params ) =...
Returns the conversations between sets of users .
28,236
public static function get_self_conversation ( int $ userid ) { global $ DB ; $ conditions = [ 'type' => self :: MESSAGE_CONVERSATION_TYPE_SELF , 'convhash' => helper :: get_conversation_hash ( [ $ userid ] ) ] ; return $ DB -> get_record ( 'message_conversations' , $ conditions ) ; }
Returns the self conversation for a user .
28,237
public static function create_conversation_between_users ( array $ userids ) { debugging ( '\core_message\api::create_conversation_between_users is deprecated, please use ' . '\core_message\api::create_conversation instead.' , DEBUG_DEVELOPER ) ; $ conversation = self :: create_conversation ( self :: MESSAGE_CONVERSATI...
Creates a conversation between two users .
28,238
public static function create_conversation ( int $ type , array $ userids , string $ name = null , int $ enabled = self :: MESSAGE_CONVERSATION_ENABLED , string $ component = null , string $ itemtype = null , int $ itemid = null , int $ contextid = null ) { global $ DB ; $ validtypes = [ self :: MESSAGE_CONVERSATION_TY...
Creates a conversation with selected users and messages .
28,239
public static function can_create_group_conversation ( int $ userid , \ context $ context ) : bool { global $ CFG ; if ( empty ( $ CFG -> messaging ) ) { return false ; } return has_capability ( 'moodle/course:creategroupconversations' , $ context , $ userid ) ; }
Checks if a user can create a group conversation .
28,240
public static function can_create_contact ( int $ userid , int $ requesteduserid ) : bool { global $ CFG ; if ( empty ( $ CFG -> messaging ) ) { return false ; } if ( $ CFG -> messagingallusers ) { return true ; } return enrol_sharing_course ( $ userid , $ requesteduserid ) ; }
Checks if a user can create a contact request .
28,241
public static function create_contact_request ( int $ userid , int $ requesteduserid ) : \ stdClass { global $ DB , $ PAGE ; $ request = new \ stdClass ( ) ; $ request -> userid = $ userid ; $ request -> requesteduserid = $ requesteduserid ; $ request -> timecreated = time ( ) ; $ request -> id = $ DB -> insert_record ...
Handles creating a contact request .
28,242
public static function confirm_contact_request ( int $ userid , int $ requesteduserid ) { global $ DB ; if ( $ request = $ DB -> get_record ( 'message_contact_requests' , [ 'userid' => $ userid , 'requesteduserid' => $ requesteduserid ] ) ) { self :: add_contact ( $ userid , $ requesteduserid ) ; $ DB -> delete_records...
Handles confirming a contact request .
28,243
public static function decline_contact_request ( int $ userid , int $ requesteduserid ) { global $ DB ; if ( $ request = $ DB -> get_record ( 'message_contact_requests' , [ 'userid' => $ userid , 'requesteduserid' => $ requesteduserid ] ) ) { $ DB -> delete_records ( 'message_contact_requests' , [ 'id' => $ request -> ...
Handles declining a contact request .
28,244
public static function add_contact ( int $ userid , int $ contactid ) { global $ DB ; $ messagecontact = new \ stdClass ( ) ; $ messagecontact -> userid = $ userid ; $ messagecontact -> contactid = $ contactid ; $ messagecontact -> timecreated = time ( ) ; $ messagecontact -> id = $ DB -> insert_record ( 'message_conta...
Handles adding a contact .
28,245
public static function remove_contact ( int $ userid , int $ contactid ) { global $ DB ; if ( $ contact = self :: get_contact ( $ userid , $ contactid ) ) { $ DB -> delete_records ( 'message_contacts' , [ 'id' => $ contact -> id ] ) ; $ event = \ core \ event \ message_contact_removed :: create ( array ( 'objectid' => ...
Handles removing a contact .
28,246
public static function block_user ( int $ userid , int $ usertoblockid ) { global $ DB ; $ blocked = new \ stdClass ( ) ; $ blocked -> userid = $ userid ; $ blocked -> blockeduserid = $ usertoblockid ; $ blocked -> timecreated = time ( ) ; $ blocked -> id = $ DB -> insert_record ( 'message_users_blocked' , $ blocked ) ...
Handles blocking a user .
28,247
public static function unblock_user ( int $ userid , int $ usertounblockid ) { global $ DB ; if ( $ blockeduser = $ DB -> get_record ( 'message_users_blocked' , [ 'userid' => $ userid , 'blockeduserid' => $ usertounblockid ] ) ) { $ DB -> delete_records ( 'message_users_blocked' , [ 'id' => $ blockeduser -> id ] ) ; $ ...
Handles unblocking a user .
28,248
public static function is_contact ( int $ userid , int $ contactid ) : bool { global $ DB ; $ sql = "SELECT id FROM {message_contacts} mc WHERE (mc.userid = ? AND mc.contactid = ?) OR (mc.userid = ? AND mc.contactid = ?)" ; return $ DB -> record_exists_sql ( $ sql , [...
Checks if users are already contacts .
28,249
public static function get_contact ( int $ userid , int $ contactid ) { global $ DB ; $ sql = "SELECT mc.* FROM {message_contacts} mc WHERE (mc.userid = ? AND mc.contactid = ?) OR (mc.userid = ? AND mc.contactid = ?)" ; return $ DB -> get_record_sql ( $ sql , [ $ user...
Returns the row in the database table message_contacts that represents the contact between two people .
28,250
public static function is_blocked ( int $ userid , int $ blockeduserid ) : bool { global $ DB ; return $ DB -> record_exists ( 'message_users_blocked' , [ 'userid' => $ userid , 'blockeduserid' => $ blockeduserid ] ) ; }
Checks if a user is already blocked .
28,251
public static function get_contact_requests_between_users ( int $ userid , int $ requesteduserid ) : array { global $ DB ; $ sql = "SELECT * FROM {message_contact_requests} mcr WHERE (mcr.userid = ? AND mcr.requesteduserid = ?) OR (mcr.userid = ? AND mcr.requesteduser...
Get contact requests between users .
28,252
public static function does_contact_request_exist ( int $ userid , int $ requesteduserid ) : bool { global $ DB ; $ sql = "SELECT id FROM {message_contact_requests} mcr WHERE (mcr.userid = ? AND mcr.requesteduserid = ?) OR (mcr.userid = ? AND mcr.requesteduserid = ?)"...
Checks if a contact request already exists between users .
28,253
public static function is_user_in_conversation ( int $ userid , int $ conversationid ) : bool { global $ DB ; return $ DB -> record_exists ( 'message_conversation_members' , [ 'conversationid' => $ conversationid , 'userid' => $ userid ] ) ; }
Checks if a user is already in a conversation .
28,254
protected static function can_contact_user ( int $ recipientid , int $ senderid ) : bool { if ( has_capability ( 'moodle/site:messageanyuser' , \ context_system :: instance ( ) , $ senderid ) || $ recipientid == $ senderid ) { return true ; } $ cancontact = null ; if ( self :: is_blocked ( $ recipientid , $ senderid ) ...
Checks if the sender can message the recipient .
28,255
public static function add_members_to_conversation ( array $ userids , int $ convid ) { global $ DB ; $ conversation = $ DB -> get_record ( 'message_conversations' , [ 'id' => $ convid ] , '*' , MUST_EXIST ) ; if ( $ conversation -> type != self :: MESSAGE_CONVERSATION_TYPE_GROUP ) { throw new \ moodle_exception ( 'You...
Add some new members to an existing conversation .
28,256
public static function remove_members_from_conversation ( array $ userids , int $ convid ) { global $ DB ; $ conversation = $ DB -> get_record ( 'message_conversations' , [ 'id' => $ convid ] , '*' , MUST_EXIST ) ; if ( $ conversation -> type != self :: MESSAGE_CONVERSATION_TYPE_GROUP ) { throw new \ moodle_exception (...
Remove some members from an existing conversation .
28,257
public static function is_conversation_area_enabled ( string $ component , string $ itemtype , int $ itemid , int $ contextid ) : bool { global $ DB ; return $ DB -> record_exists ( 'message_conversations' , [ 'itemid' => $ itemid , 'contextid' => $ contextid , 'component' => $ component , 'itemtype' => $ itemtype , 'e...
Checks whether or not a conversation area is enabled .
28,258
public static function get_conversation_by_area ( string $ component , string $ itemtype , int $ itemid , int $ contextid ) { global $ DB ; return $ DB -> get_record ( 'message_conversations' , [ 'itemid' => $ itemid , 'contextid' => $ contextid , 'component' => $ component , 'itemtype' => $ itemtype ] ) ; }
Get conversation by area .
28,259
public static function enable_conversation ( int $ conversationid ) { global $ DB ; $ conversation = new \ stdClass ( ) ; $ conversation -> id = $ conversationid ; $ conversation -> enabled = self :: MESSAGE_CONVERSATION_ENABLED ; $ conversation -> timemodified = time ( ) ; $ DB -> update_record ( 'message_conversation...
Enable a conversation .
28,260
public static function disable_conversation ( int $ conversationid ) { global $ DB ; $ conversation = new \ stdClass ( ) ; $ conversation -> id = $ conversationid ; $ conversation -> enabled = self :: MESSAGE_CONVERSATION_DISABLED ; $ conversation -> timemodified = time ( ) ; $ DB -> update_record ( 'message_conversati...
Disable a conversation .
28,261
public static function update_conversation_name ( int $ conversationid , string $ name ) { global $ DB ; if ( $ conversation = $ DB -> get_record ( 'message_conversations' , array ( 'id' => $ conversationid ) ) ) { if ( $ name <> $ conversation -> name ) { $ conversation -> name = $ name ; $ conversation -> timemodifie...
Update the name of a conversation .
28,262
public static function get_unread_conversation_counts ( int $ userid ) : array { global $ DB ; $ unreadcountssql = 'SELECT conv.id, conv.type, indcounts.unreadcount FROM {message_conversations} conv INNER JOIN ( SELECT m.conversati...
Get the unread counts for all conversations for the user sorted by type and including favourites .
28,263
public static function mute_conversation ( int $ userid , int $ conversationid ) : void { global $ DB ; $ mutedconversation = new \ stdClass ( ) ; $ mutedconversation -> userid = $ userid ; $ mutedconversation -> conversationid = $ conversationid ; $ mutedconversation -> action = self :: CONVERSATION_ACTION_MUTED ; $ m...
Handles muting a conversation .
28,264
public static function unmute_conversation ( int $ userid , int $ conversationid ) : void { global $ DB ; $ DB -> delete_records ( 'message_conversation_actions' , [ 'userid' => $ userid , 'conversationid' => $ conversationid , 'action' => self :: CONVERSATION_ACTION_MUTED ] ) ; }
Handles unmuting a conversation .
28,265
public static function is_conversation_muted ( int $ userid , int $ conversationid ) : bool { global $ DB ; return $ DB -> record_exists ( 'message_conversation_actions' , [ 'userid' => $ userid , 'conversationid' => $ conversationid , 'action' => self :: CONVERSATION_ACTION_MUTED ] ) ; }
Checks whether a conversation is muted or not .
28,266
public static function delete_all_conversation_data ( int $ conversationid ) { global $ DB ; $ DB -> delete_records ( 'message_conversations' , [ 'id' => $ conversationid ] ) ; $ DB -> delete_records ( 'message_conversation_members' , [ 'conversationid' => $ conversationid ] ) ; $ DB -> delete_records ( 'message_conver...
Completely removes all related data in the DB for a given conversation .
28,267
public function col_unsubscribe ( \ tool_monitor \ subscription $ sub ) { global $ OUTPUT , $ CFG ; $ deleteurl = new \ moodle_url ( $ CFG -> wwwroot . '/admin/tool/monitor/index.php' , array ( 'subscriptionid' => $ sub -> id , 'action' => 'unsubscribe' , 'courseid' => $ this -> courseid , 'sesskey' => sesskey ( ) ) ) ...
Generate content for unsubscribe column .
28,268
public function genMessage ( ) { if ( $ this -> currentFile && $ this -> currentFile [ 'filename' ] ) { $ this -> message .= ' in ' . basename ( $ this -> currentFile [ 'filename' ] ) ; } if ( $ this -> index !== null ) { $ this -> getInput ( ) ; if ( $ this -> input ) { $ line = self :: getLineNumber ( ) ; $ this -> m...
Converts the exception to string
28,269
public function getLineNumber ( ) { if ( $ this -> index ) { if ( ini_get ( "mbstring.func_overload" ) ) { return substr_count ( substr ( $ this -> input , 0 , $ this -> index ) , "\n" ) + 1 ; } else { return substr_count ( $ this -> input , "\n" , 0 , $ this -> index ) + 1 ; } } return 1 ; }
Returns the line number the error was encountered
28,270
public function getColumn ( ) { $ part = substr ( $ this -> input , 0 , $ this -> index ) ; $ pos = strrpos ( $ part , "\n" ) ; return $ this -> index - $ pos ; }
Returns the column the error was encountered
28,271
public function get ( $ member ) { if ( $ this -> base && property_exists ( $ this -> base , $ member ) ) { return $ this -> base -> { $ member } ; } return $ this -> get_proxied_instance ( ) -> { $ member } ; }
Retrieve a member of the proxied class .
28,272
private static function init ( ) { if ( empty ( self :: $ eventfactory ) ) { self :: $ actionfactory = new action_factory ( ) ; self :: $ eventmapper = new event_mapper ( new event_factory ( function ( event_interface $ event ) { return $ event ; } , function ( ) { return true ; } , function ( ) { return false ; } , se...
Initialises the dependency graph if it hasn t yet been .
28,273
public static function reset_caches ( ) { self :: $ requestinguserid = null ; self :: $ eventfactory = null ; self :: $ eventmapper = null ; self :: $ eventvault = null ; self :: $ actionfactory = null ; self :: $ eventretrievalstrategy = null ; self :: $ coursecache = [ ] ; self :: $ modulecache = [ ] ; }
Reset all static caches called between tests .
28,274
public static function apply_component_provide_event_action ( event_interface $ event ) { $ mapper = self :: $ eventmapper ; $ action = null ; if ( $ event -> get_course_module ( ) ) { $ requestinguserid = self :: get_requesting_user ( ) ; $ legacyevent = $ mapper -> from_event_to_legacy_event ( $ event ) ; if ( empty ...
Calls callback core_calendar_provide_event_action from the component responsible for the event
28,275
public static function apply_component_is_event_visible ( event_interface $ event ) { $ mapper = self :: $ eventmapper ; $ eventvisible = null ; if ( $ event -> get_course_module ( ) ) { $ requestinguserid = self :: get_requesting_user ( ) ; $ legacyevent = $ mapper -> from_event_to_legacy_event ( $ event ) ; if ( empt...
Calls callback core_calendar_is_event_visible from the component responsible for the event
28,276
private function visitRulesetRoot ( $ rulesetNode ) { $ rulesetNode -> accept ( $ this ) ; if ( $ rulesetNode -> firstRoot || $ rulesetNode -> rules ) { return $ rulesetNode ; } return array ( ) ; }
Helper function for visitiRuleset
28,277
private function is_preference_enabled ( $ name ) { $ processor = $ this -> processor ; $ preferences = $ this -> preferences ; $ defaultpreferences = get_message_output_default_preferences ( ) ; $ checked = false ; if ( isset ( $ preferences -> { $ name } ) ) { $ checked = isset ( $ preferences -> { $ name } [ $ proce...
Check if the given preference is enabled or not .
28,278
public function tag_search_page ( $ query = '' , $ tagcollid = 0 ) { $ rv = $ this -> output -> heading ( get_string ( 'searchtags' , 'tag' ) , 2 ) ; $ searchbox = $ this -> search_form ( $ query , $ tagcollid ) ; $ rv .= html_writer :: div ( $ searchbox , '' , array ( 'id' => 'tag-search-box' ) ) ; $ tagcloud = core_t...
Renders the tag search page
28,279
public function tag_index_page ( $ tag , $ entities , $ tagareaid , $ exclusivemode , $ fromctx , $ ctx , $ rec , $ page ) { global $ CFG , $ OUTPUT ; $ this -> page -> requires -> js_call_amd ( 'core/tag' , 'initTagindexPage' ) ; $ tagname = $ tag -> get_display_name ( ) ; $ systemcontext = context_system :: instance ...
Renders the tag index page
28,280
protected function tag_links ( $ tag ) { if ( $ links = $ tag -> get_links ( ) ) { $ content = '<ul class="inline-list"><li>' . implode ( '</li> <li>' , $ links ) . '</li></ul>' ; return html_writer :: div ( $ content , 'tag-management-box' ) ; } return '' ; }
Prints a box that contains the management links of a tag
28,281
protected function search_form ( $ query = '' , $ tagcollid = 0 ) { $ searchurl = new moodle_url ( '/tag/search.php' ) ; $ output = '<form action="' . $ searchurl . '">' ; $ output .= '<label class="accesshide" for="searchform_query">' . get_string ( 'searchtags' , 'tag' ) . '</label>' ; $ output .= '<input id="searchf...
Prints the tag search box
28,282
public function setInitialTheta ( array $ theta ) { if ( count ( $ theta ) != $ this -> dimensions ) { throw new \ Exception ( "Number of values in the weights array should be $this->dimensions" ) ; } $ this -> theta = $ theta ; return $ this ; }
Sets the weights manually
28,283
public function get_additional_login_parameters ( ) { $ params = '' ; if ( $ this -> system ) { if ( ! empty ( $ this -> issuer -> get ( 'loginparamsoffline' ) ) ) { $ params = $ this -> issuer -> get ( 'loginparamsoffline' ) ; } } else { if ( ! empty ( $ this -> issuer -> get ( 'loginparams' ) ) ) { $ params = $ this ...
Override to append additional params to a authentication request .
28,284
protected function store_token ( $ token ) { if ( ! $ this -> system ) { parent :: store_token ( $ token ) ; return ; } $ this -> accesstoken = $ token ; $ persistedtoken = access_token :: get_record ( [ 'issuerid' => $ this -> issuer -> get ( 'id' ) ] ) ; if ( $ token !== null ) { if ( ! $ persistedtoken ) { $ persist...
Store a token between requests . Uses session named by get_tokenname for user account tokens and a database record for system account tokens .
28,285
protected function get_userinfo_mapping ( ) { $ fields = user_field_mapping :: get_records ( [ 'issuerid' => $ this -> issuer -> get ( 'id' ) ] ) ; $ map = [ ] ; foreach ( $ fields as $ field ) { $ map [ $ field -> get ( 'externalfield' ) ] = $ field -> get ( 'internalfield' ) ; } return $ map ; }
Get a list of the mapping user fields in an associative array .
28,286
public function upgrade_refresh_token ( system_account $ systemaccount ) { $ refreshtoken = $ systemaccount -> get ( 'refreshtoken' ) ; $ params = array ( 'refresh_token' => $ refreshtoken , 'grant_type' => 'refresh_token' ) ; if ( $ this -> basicauth ) { $ idsecret = urlencode ( $ this -> issuer -> get ( 'clientid' ) ...
Upgrade a refresh token from oauth 2 . 0 to an access token
28,287
public function get_userinfo ( ) { $ url = $ this -> get_issuer ( ) -> get_endpoint_url ( 'userinfo' ) ; $ response = $ this -> get ( $ url ) ; if ( ! $ response ) { return false ; } $ userinfo = new stdClass ( ) ; try { $ userinfo = json_decode ( $ response ) ; } catch ( \ Exception $ e ) { return false ; } $ map = $ ...
Fetch the user info from the user info endpoint and map all the fields back into moodle fields .
28,288
public function userConfirmationNeeded ( ) { $ return_path = $ this -> _headers [ 'Return-Path' ] ; if ( ! $ return_path || ( count ( $ return_path -> value ) > 1 ) ) { return true ; } $ addr_ob = ( $ hdr = $ this -> _headers [ self :: MDN_HEADER ] ) ? $ hdr -> getAddressList ( true ) : array ( ) ; switch ( count ( $ a...
Is user input required to send the MDN? Explicit confirmation is needed in some cases to prevent mail loops and the use of MDNs for mail bombing .
28,289
public function get_activities_list ( ) { $ activities = array ( ) ; $ sitecontext = context_system :: instance ( ) ; if ( $ this -> course -> id == SITEID && has_capability ( 'report/log:view' , $ sitecontext ) ) { $ activities [ "site_errors" ] = get_string ( "siteerrors" ) ; return $ activities ; } $ modinfo = get_f...
Helper function to return list of activities to show in selection filter .
28,290
public function get_selected_group ( ) { global $ SESSION , $ USER ; if ( empty ( $ this -> course ) ) { return 0 ; } $ context = context_course :: instance ( $ this -> course -> id ) ; $ selectedgroup = 0 ; $ groupmode = groups_get_course_groupmode ( $ this -> course ) ; if ( $ groupmode == SEPARATEGROUPS and ! has_ca...
Helper function to get selected group .
28,291
public function get_course_list ( ) { global $ DB , $ SITE ; $ courses = array ( ) ; $ sitecontext = context_system :: instance ( ) ; $ numcourses = $ DB -> count_records ( "course" ) ; if ( $ numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && ! $ this -> showcourses ) { $ this -> showcourses = 1 ; } if ( has_capability (...
Return list of courses to show in selector .
28,292
public function get_group_list ( ) { if ( empty ( $ this -> course ) ) { return array ( ) ; } $ context = context_course :: instance ( $ this -> course -> id ) ; $ groups = array ( ) ; $ groupmode = groups_get_course_groupmode ( $ this -> course ) ; if ( ( $ groupmode == VISIBLEGROUPS ) || ( $ groupmode == SEPARATEGROU...
Return list of groups .
28,293
public function get_user_list ( ) { global $ CFG , $ SITE ; $ courseid = $ SITE -> id ; if ( ! empty ( $ this -> course ) ) { $ courseid = $ this -> course -> id ; } $ context = context_course :: instance ( $ courseid ) ; $ limitfrom = empty ( $ this -> showusers ) ? 0 : '' ; $ limitnum = empty ( $ this -> showusers ) ...
Return list of users .
28,294
public function get_date_options ( ) { global $ SITE ; $ strftimedate = get_string ( "strftimedate" ) ; $ strftimedaydate = get_string ( "strftimedaydate" ) ; $ timenow = time ( ) ; $ timemidnight = usergetmidnight ( $ timenow ) ; $ dates = array ( "$timemidnight" => get_string ( "today" ) . ", " . userdate ( $ timenow...
Return list of date options .
28,295
public function get_origin_options ( ) { $ ret = array ( ) ; $ ret [ '' ] = get_string ( 'allsources' , 'report_log' ) ; $ ret [ 'cli' ] = get_string ( 'cli' , 'report_log' ) ; $ ret [ 'restore' ] = get_string ( 'restore' , 'report_log' ) ; $ ret [ 'web' ] = get_string ( 'web' , 'report_log' ) ; $ ret [ 'ws' ] = get_st...
Return list of components to show in selector .
28,296
public function download ( ) { $ filename = 'logs_' . userdate ( time ( ) , get_string ( 'backupnameformat' , 'langconfig' ) , 99 , false ) ; if ( $ this -> course -> id !== SITEID ) { $ courseshortname = format_string ( $ this -> course -> shortname , true , array ( 'context' => context_course :: instance ( $ this -> ...
Download logs in specified format .
28,297
public function get_item_tags ( $ namespace , $ tag ) { if ( isset ( $ this -> data [ 'child' ] [ $ namespace ] [ $ tag ] ) ) { return $ this -> data [ 'child' ] [ $ namespace ] [ $ tag ] ; } else { return null ; } }
Get data for an item - level element
28,298
public function get_title ( ) { if ( ! isset ( $ this -> data [ 'title' ] ) ) { if ( $ return = $ this -> get_item_tags ( SIMPLEPIE_NAMESPACE_ATOM_10 , 'title' ) ) { $ this -> data [ 'title' ] = $ this -> sanitize ( $ return [ 0 ] [ 'data' ] , $ this -> registry -> call ( 'Misc' , 'atom_10_construct_type' , array ( $ r...
Get the title of the item
28,299
public function get_categories ( ) { $ categories = array ( ) ; $ type = 'category' ; foreach ( ( array ) $ this -> get_item_tags ( SIMPLEPIE_NAMESPACE_ATOM_10 , $ type ) as $ category ) { $ term = null ; $ scheme = null ; $ label = null ; if ( isset ( $ category [ 'attribs' ] [ '' ] [ 'term' ] ) ) { $ term = $ this ->...
Get all categories for the item