Beispiel #1
0
/**
 * Delete notification about a group invitation when user accepts/deletes it
 *
 * @param string           $event  'delete'
 * @param string           $type   'relationship'
 * @param ElggRelationship $object The relationship being deleted
 * @return boolean
 */
function notifier_read_group_invitation_notification($event, $type, $object)
{
    $relationship = $object->relationship;
    // Proceed only if the relationship is an invitation
    if ($relationship != 'invited' && $relationship != 'membership_request') {
        return true;
    }
    // The group may be hidden, so ignore access
    $ia = elgg_set_ignore_access(true);
    if ($relationship === 'invited') {
        $group = get_entity($object->guid_one);
    } else {
        $group = get_entity($object->guid_two);
    }
    elgg_set_ignore_access($ia);
    // Proceed only if the invitation is for a group
    if (!$group instanceof ElggGroup) {
        return true;
    }
    $dbprefix = elgg_get_config('dbprefix');
    $has_object = ElggNotification::HAS_OBJECT;
    $options = array('joins' => array("JOIN {$dbprefix}entity_relationships er ON e.guid = er.guid_one"), 'wheres' => array("er.relationship = '{$has_object}' AND er.guid_two = {$group->guid}"));
    // Get unread notifications
    $notifications = notifier_get_unread($options);
    foreach ($notifications as $note) {
        if ($note->event === "create:relationship:{$relationship}") {
            $note->markRead();
        }
    }
    // Returning true means that the relationship deletion can now proceed
    return true;
}
Beispiel #2
0
<?php

/**
 * Mark all notifications read
 *
 * @package Notifier
 */
$notifications = notifier_get_unread();
foreach ($notifications as $item) {
    $item->markRead();
}
system_message(elgg_echo('notifier:message:dismissed_all'));