Ejemplo n.º 1
0
/**
 * Listen to the 'publish','object' event and send out notifications
 * to interested users, as well as anyone tagged
 *
 * @param string $event			Equals 'publish'
 * @param string $entity_type	Equals 'object'
 * @param ElggEntity $entity	Published entity
 */
function send_custom_notifications($event, $entity_type, $entity)
{
    if ($entity->origin !== 'wall') {
        return true;
    }
    // We only want to notify about wire posts and wall posts, all content created therewith is implied
    $accepted_subtypes = array('hjwall', 'thewire');
    if (!in_array($entity->getSubtype(), $accepted_subtypes)) {
        return true;
    }
    $poster = $entity->getOwnerEntity();
    $container = $entity->getContainerEntity();
    $message = format_wall_message($entity, true);
    $sent = array(elgg_get_logged_in_user_guid(), $poster->guid, $container->guid);
    // Notify wall owner
    if ($poster->guid !== $container->guid && elgg_instanceof($container, 'user')) {
        $to = $container->guid;
        $from = $poster->guid;
        $target = elgg_echo("wall:target:{$entity->getSubtype()}");
        $ownership = elgg_echo('wall:ownership:your', array($target));
        $subject = elgg_echo('wall:new:notification:subject', array($poster->name, $ownership));
        $summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
        $body = elgg_echo('wall:new:notification:message', array($poster->name, $ownership, $message, $entity->getURL()));
        notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'received'));
    }
    // Notify tagged users
    $tagged_friends = get_tagged_friends($entity);
    foreach ($tagged_friends as $tagged_friend) {
        // user tagged herself or the wall owner
        if ($tagged_friend->guid == $poster->guid || $tagged_friend->guid == $container->guid || in_array($tagged_friend->guid, $sent)) {
            continue;
        }
        $sent[] = $tagged_friend->guid;
        $to = $tagged_friend->guid;
        $from = $poster->guid;
        $subject = elgg_echo('wall:tagged:notification:subject', array($poster->name));
        $summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
        $body = elgg_echo('wall:tagged:notification:message', array($poster->name, $message, $entity->getURL()));
        notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'tagged'));
    }
    return true;
}
Ejemplo n.º 2
0
<?php

/**
 * Wall post tag river item
 */
namespace hypeJunction\Wall;

elgg_push_context('wall');
// River access level will vary from that of the original post
$ia = elgg_set_ignore_access(true);
$tagged_user = $vars['item']->getSubjectEntity();
$wall_post = $vars['item']->getObjectEntity();
$poster = $wall_post->getOwnerEntity();
$tagged_user_link = elgg_view('output/url', array('text' => $tagged_user->name, 'href' => $tagged_user->getURL()));
$poster_link = elgg_view('output/url', array('text' => $poster->name, 'href' => $poster->getURL()));
$wall_post_link = elgg_view('output/url', array('text' => elgg_echo('wall:tag:river:post'), 'href' => $wall_post->getURL()));
$summary = elgg_echo('wall:tag:river', array($poster_link, $tagged_user_link, $wall_post_link));
elgg_set_ignore_access($ia);
echo elgg_view('river/item', array('item' => $vars['item'], 'summary' => $summary, 'message' => format_wall_message($wall_post), 'attachments' => format_wall_attachments($wall_post)));
elgg_pop_context();
Ejemplo n.º 3
0
 /**
  * Pre 1.9 notifications
  *
  * Formats notification message
  *
  * @param string $hook    "notify:entity:message"
  * @param string $type    "object"
  * @param string $message Notification message
  * @param array  $params  Hook params
  * @return string
  */
 public function formatMessageLegacy($hook, $type, $message, $params)
 {
     $entity = elgg_extract('entity', $params);
     $to_entity = elgg_extract('to_entity', $params);
     if (!$entity instanceof Post || $entity->origin !== 'wall') {
         return $message;
     }
     $poster = $entity->getOwnerEntity();
     $wall_owner = $entity->getContainerEntity();
     $target = elgg_echo("wall:target:{$entity->getSubtype()}");
     if ($poster->guid == $wall_owner->guid) {
         $ownership = elgg_echo('wall:ownership:own', array($target));
     } else {
         if ($wall_owner->guid == $to_entity->guid) {
             $ownership = elgg_echo('wall:ownership:your', array($target));
         } else {
             $ownership = elgg_echo('wall:ownership:owner', array($wall_owner->name, $target));
         }
     }
     return elgg_echo('wall:new:notification:message', array($poster->name, $ownership, format_wall_message($entity, true), $entity->getURL()));
 }
Ejemplo n.º 4
0
<?php

namespace hypeJunction\Wall;

elgg_load_css('wall');
elgg_load_css('fonts.font-awesome');
elgg_load_css('fonts.open-sans');
$entity = elgg_extract('entity', $vars);
$poster = $entity->getOwnerEntity();
$wall_owner = $entity->getContainerEntity();
$message = format_wall_message($entity);
if ($wall_owner->guid !== $poster->guid && $poster->guid !== elgg_get_page_owner_guid() && $wall_owner->guid !== elgg_get_page_owner_guid()) {
    $by = elgg_view('output/url', array('text' => $poster->name, 'href' => $poster->getURL()));
    $on = elgg_view('output/url', array('text' => $wall_owner->name, 'href' => $wall_owner->getURL()));
    $summary = elgg_echo('wall:new:wall:post', array($by, $on));
} else {
    $author_link = elgg_view('output/url', array('text' => $poster->name, 'href' => $poster->getURL()));
    $message = "{$author_link}: {$message}";
}
if ($entity->address) {
    $att_str = elgg_view('output/wall/url', array('value' => $entity->address));
}
$att_str .= $entity->html;
$attachments = elgg_get_entities_from_relationship(array('relationship' => 'attached', 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => false));
if ($attachments) {
    if (count($attachments) > 1) {
        $att_str .= elgg_view_entity_list($attachments, array('list_type' => elgg_in_context('widgets') ? 'list' : 'gallery', 'full_view' => false, 'size' => 'small'));
    } else {
        foreach ($attachments as $attachment) {
            $att_str .= elgg_view('output/wall/attachment', array('entity' => $attachment));
        }
Ejemplo n.º 5
0
<?php

/**
 * Wall post tag river item
 */
namespace hypeJunction\Wall;

elgg_push_context('wall');
// River access level will vary from that of the original post
$ia = elgg_set_ignore_access(true);
$tagged_user = $vars['item']->getSubjectEntity();
$wall_post = $vars['item']->getObjectEntity();
$poster = $wall_post->getOwnerEntity();
$tagged_user_link = elgg_view('output/url', array('text' => $tagged_user->name, 'href' => $tagged_user->getURL()));
$poster_link = elgg_view('output/url', array('text' => $poster->name, 'href' => $poster->getURL()));
$wall_post_link = elgg_view('output/url', array('text' => elgg_echo('wall:tag:river:post'), 'href' => $wall_post->getURL()));
$summary = elgg_echo('wall:tag:river', array($poster_link, $tagged_user_link, $wall_post_link));
$attachment = format_wall_message($wall_post, true);
elgg_set_ignore_access($ia);
echo elgg_view('river/item', array('item' => $vars['item'], 'summary' => $summary, 'message' => $message, 'attachments' => $attachment));
elgg_pop_context();
Ejemplo n.º 6
0
<?php

namespace hypeJunction\Wall;

$subject = $vars['item']->getSubjectEntity();
$object = $vars['item']->getObjectEntity();
$wall_owner = $object->getContainerEntity();
$message = format_wall_message($object);
if ($wall_owner->guid !== $subject->guid && $wall_owner->guid !== elgg_get_page_owner_guid()) {
    $by = elgg_view('output/url', array('text' => $subject->name, 'href' => $subject->getURL()));
    $on = elgg_view('output/url', array('text' => $wall_owner->name, 'href' => $wall_owner->getURL()));
    $summary = elgg_echo('wall:new:wall:post', array($by, $on));
} else {
    $author_link = elgg_view('output/url', array('text' => $subject->name, 'href' => $subject->getURL()));
    $message = "{$author_link}: {$message}";
}
if (!$summary) {
    $summary = $message;
    $message = false;
}
if ($object->address) {
    $att_str = elgg_view('output/wall/url', array('value' => $object->address));
}
$att_str .= $object->html;
$attachments = get_attachments($object);
if ($attachments) {
    if (count($attachments) > 0) {
        $att_str .= elgg_view_entity_list($attachments, array('list_type' => elgg_in_context('widgets') ? 'list' : 'gallery', 'full_view' => false, 'icon_size' => 'large'));
    } else {
        foreach ($attachments as $attachment) {
            $att_str .= elgg_view('output/wall/attachment', array('entity' => $attachment));