本文整理汇总了PHP中message_remove_contact函数的典型用法代码示例。如果您正苦于以下问题:PHP message_remove_contact函数的具体用法?PHP message_remove_contact怎么用?PHP message_remove_contact使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message_remove_contact函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_message_contact_removed
/**
* Test the message contact removed event.
*/
public function test_message_contact_removed() {
// Set this user as the admin.
$this->setAdminUser();
// Create a user to add to the admin's contact list.
$user = $this->getDataGenerator()->create_user();
// Add the user to the admin's contact list.
message_add_contact($user->id);
// Trigger and capture the event when adding a contact.
$sink = $this->redirectEvents();
message_remove_contact($user->id);
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\core\event\message_contact_removed', $event);
$this->assertEquals(context_user::instance(2), $event->get_context());
$expected = array(SITEID, 'message', 'remove contact', 'index.php?user1=' . $user->id .
'&user2=2', $user->id);
$this->assertEventLegacyLogData($expected, $event);
$url = new moodle_url('/message/index.php', array('user1' => $event->userid, 'user2' => $event->relateduserid));
$this->assertEquals($url, $event->get_url());
}
示例2: message_add_contact
$PAGE->set_pagelayout('standard');
$PAGE->set_context(context_user::instance($user1->id));
}
if (!empty($user1->id) && $user1->id != $USER->id) {
$PAGE->navigation->extend_for_user($user1);
}
if (!empty($user2->id) && $user2realuser && $user2->id != $USER->id) {
$PAGE->navigation->extend_for_user($user2);
}
/// Process any contact maintenance requests there may be
if ($addcontact and confirm_sesskey()) {
message_add_contact($addcontact);
redirect($CFG->wwwroot . '/message/index.php?viewing=contacts&id=' . $addcontact);
}
if ($removecontact and confirm_sesskey()) {
message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
message_unblock_contact($unblockcontact);
}
//was a message sent? Do NOT allow someone looking at someone else's messages to send them.
$messageerror = null;
if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $systemcontext)) {
// Check that the user is not blocking us!!
if ($contact = $DB->get_record('message_contacts', array('userid' => $user2->id, 'contactid' => $user1->id))) {
if ($contact->blocked and !has_capability('moodle/site:readallmessages', $systemcontext)) {
$messageerror = get_string('userisblockingyou', 'message');
}
示例3: delete_contacts
/**
* Delete contacts.
*
* @param array $userids array of user IDs.
* @return null
* @since Moodle 2.5
*/
public static function delete_contacts($userids)
{
global $CFG;
// Check if messaging is enabled.
if (!$CFG->messaging) {
throw new moodle_exception('disabled', 'message');
}
$params = array('userids' => $userids);
$params = self::validate_parameters(self::delete_contacts_parameters(), $params);
foreach ($params['userids'] as $id) {
message_remove_contact($id);
}
return null;
}
示例4: test_message_remove_contact
/**
* Test message_remove_contact.
*/
public function test_message_remove_contact()
{
// Set this user as the admin.
$this->setAdminUser();
// Create a user to add to the admin's contact list.
$user = $this->getDataGenerator()->create_user();
// Add the user to the admin's contact list.
message_add_contact($user->id);
$this->assertNotEmpty(message_get_contact($user->id));
// Remove user from admin's contact list.
message_remove_contact($user->id);
$this->assertEquals(false, message_get_contact($user->id));
}
示例5: delete_contacts
/**
* Delete contacts.
*
* @param array $userids array of user IDs.
* @return null
* @since 2.5
*/
public static function delete_contacts($userids) {
$params = array('userids' => $userids);
$params = self::validate_parameters(self::delete_contacts_parameters(), $params);
foreach ($params['userids'] as $id) {
message_remove_contact($id);
}
return null;
}
示例6: delete_contacts
/**
* Delete contacts.
*
* @param array $userids array of user IDs.
* @param int $userid The id of the user we are deleting the contacts for
* @return null
* @since Moodle 2.5
*/
public static function delete_contacts($userids, $userid = 0)
{
global $CFG, $USER;
// Check if messaging is enabled.
if (empty($CFG->messaging)) {
throw new moodle_exception('disabled', 'message');
}
if (empty($userid)) {
$userid = $USER->id;
}
// Validate context.
$context = context_system::instance();
self::validate_context($context);
$capability = 'moodle/site:manageallmessaging';
if ($USER->id != $userid && !has_capability($capability, $context)) {
throw new required_capability_exception($context, $capability, 'nopermissions', '');
}
$params = array('userids' => $userids, 'userid' => $userid);
$params = self::validate_parameters(self::delete_contacts_parameters(), $params);
foreach ($params['userids'] as $id) {
message_remove_contact($id, $userid);
}
return null;
}