Ejemplo n.º 1
0
<?php

use hypeJunction\Inbox\Inbox;
elgg_ajax_gatekeeper();
$user = elgg_get_logged_in_user_entity();
$inbox = new Inbox();
$inbox->setOwner($user)->displayThreaded(true);
$count = $inbox->getCount();
$messages = $inbox->getMessages();
$latest_messages = array();
// Fix for 'GROUP_BY' statememtn returning wrong order
foreach ($messages as $msg) {
    $lastMsg = $msg->getVolatileData('select:lastMsg');
    if ($lastMsg && $lastMsg != $msg->guid) {
        $latest_messages[] = get_entity($lastMsg);
    } else {
        $latest_messages[] = $msg;
    }
}
$messages = $latest_messages;
$unread = Inbox::countUnread($user);
elgg_push_context('widgets');
$list = elgg_view_entity_list($messages, array('list_class' => 'elgg-list-inbox', 'no_results' => elgg_echo('inbox:empty'), 'full_view' => false, 'size' => 'tiny', 'threaded' => false, 'pagination' => false, 'threaded' => true));
elgg_pop_context();
echo json_encode(array('list' => $list, 'unread' => $unread, 'count' => $count));
Ejemplo n.º 2
0
Archivo: inbox.php Proyecto: n8b/VMN
<?php

use ElggUser;
use hypeJunction\Inbox\Inbox;
$user = elgg_get_page_owner_entity();
if (!$user instanceof ElggUser) {
    return true;
}
$limit = get_input('limit', 20);
$offset = get_input('offset', 0);
$message_type = elgg_extract('message_type', $vars);
$read = elgg_extract('read', $vars);
$threaded = elgg_extract('threaded', $vars, true);
$inbox = new Inbox();
$inbox->setOwner($user)->setMessageType($message_type)->setReadStatus($read)->displayThreaded($threaded);
$count = $inbox->getCount();
$messages = $inbox->getMessages(array('limit' => $limit, 'offset' => $offset));
if ($threaded && $messages) {
    $latest_messages = array();
    // Fix for 'GROUP_BY' statememtn returning wrong order
    foreach ($messages as $msg) {
        $lastMsg = $msg->getVolatileData('select:lastMsg');
        if ($lastMsg && $lastMsg != $msg->guid) {
            $latest_messages[] = get_entity($lastMsg);
        } else {
            $latest_messages[] = $msg;
        }
    }
    $messages = $latest_messages;
}
$params = array('items' => $messages, 'limit' => $limit, 'offset' => $offset, 'count' => $count, 'threaded' => $threaded);
Ejemplo n.º 3
0
Archivo: Inbox.php Proyecto: n8b/VMN
 /**
  * Get a count of unread messages
  * 
  * @param ElggUser $user    Recipient
  * @param string   $msgType Message type
  * @param array    $options Additional options to pass to the getter
  * @return int
  */
 public static function countUnread(ElggUser $user, $msgType = '', array $options = array())
 {
     $instance = new Inbox();
     $instance->setOwner($user)->setMessageType($msgType)->setReadStatus(false);
     return $instance->getCount($options);
 }
Ejemplo n.º 4
0
Archivo: Model.php Proyecto: n8b/VMN
 /**
  * Count unread messages of a given type received by a given user
  *
  * @param string   $message_type Message type
  * @param ElggUser $user         User
  * @return int Count of unread messages
  */
 public function countUnreadMessages($message_type = null, $user = null)
 {
     if (is_null($user)) {
         $user = elgg_get_logged_in_user_entity();
     }
     if (!$user instanceof ElggUser) {
         return 0;
     }
     return Inbox::countUnread($user, $message_type);
 }
Ejemplo n.º 5
0
<?php

namespace hypeJunction\Inbox;

use ElggUser;
$user = elgg_get_page_owner_entity();
if (!$user instanceof ElggUser) {
    return true;
}
$limit = get_input('limit', 20);
$offset = get_input('offset', 0);
$message_type = elgg_extract('message_type', $vars);
$read = elgg_extract('read', $vars);
$inbox = new Inbox();
$inbox->setOwner($user)->setMessageType($message_type)->setReadStatus($read)->setDirection(Inbox::DIRECTION_SENT);
$count = $inbox->getCount();
$messages = $inbox->getMessages(array('limit' => $limit, 'offset' => $offset));
$params = array('items' => $messages, 'limit' => $limit, 'offset' => $offset, 'count' => $count, 'threaded' => false);
elgg_push_context('inbox-form');
echo elgg_view('framework/inbox/controls/inbox', $params);
echo elgg_view('framework/inbox/list', $params);
echo elgg_view('input/submit', array('class' => 'hidden'));
elgg_pop_context();