/** $Id$ **/
/**
* @package Mediboard
* @subpackage messagerie
* @version $Revision$
* @author Fabien
*/
CCanDo::checkRead();
$user_id = CValue::get('user_id');
$user = new CMediusers();
$user->load($user_id);
if (!$user->_id) {
    $user = CMediusers::get();
}
$selected_folder = CValue::get('selected_folder', 'inbox');
// Liste des messages reçus
$listInboxUnread = CUserMessageDest::countUnreadFor($user);
// Liste des messages archivés
$listArchived = CUserMessageDest::countArchivedFor($user);
// Liste des messages envoyés
$listSent = CUserMessageDest::countSentFor($user);
// Liste des brouillons
$countListDraft = CUserMessageDest::countDraftedFor($user);
$folders = array('inbox' => $listInboxUnread, 'archive' => $listArchived, 'sentbox' => $listSent, 'draft' => $countListDraft);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("user", $user);
$smarty->assign('folders', $folders);
$smarty->assign('selected_folder', $selected_folder);
$smarty->display("vw_list_usermessages.tpl");
Пример #2
0
    $where['usermessage_dest.deleted'] = " = '0'";
    $order = "usermessage_dest.starred DESC, usermessage_dest.datetime_sent DESC";
    $total_found = CUserMessageDest::countArchivedFor($user);
}
if ($mode == "sentbox") {
    $where = array();
    $where["from_user_id"] = " = '{$user->_id}'";
    $where["datetime_sent"] = " IS NOT NULL";
    $total_found = CUserMessageDest::countSentFor($user);
}
if ($mode == "draft") {
    $order = "usermessage.usermessage_id DESC";
    $where = array();
    $where["creator_id"] = " = '{$user->_id}'";
    $where["datetime_sent"] = " IS NULL";
    $total_found = CUserMessageDest::countDraftedFor($user);
}
$total_found = $total_found ? $total_found : 0;
$group = "usermessage.usermessage_id";
/** @var CUserMessage[] $usermessages */
$usermessages = $usermessage->loadList($where, $order, "{$page}, {$step}", $group, $lj);
foreach ($usermessages as $_usermessage) {
    $_usermessage->loadRefDestUser();
    /** @var CUserMessageDest[] $destinataires */
    $destinataires = $_usermessage->loadRefDests();
    /* We set the _ref_dest_user when the mode is draft for being able to delete a message */
    if ($mode == 'draft') {
        $_usermessage->_ref_dest_user = reset($_usermessage->_ref_destinataires);
    }
    foreach ($destinataires as $key => $_dest) {
        if (in_array($mode, array("inbox", "archive"))) {
<?php

/**
 * $Id$
 *  
 * @package    Mediboard
 * @subpackage messagerie
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 * @link       http://www.mediboard.org
 */
CCando::checkRead();
$user = CMediusers::get();
$counts = array(array('name' => 'inbox', 'count' => CUserMessageDest::countUnreadFor($user)), array('name' => 'archive', 'count' => CUserMessageDest::countArchivedFor($user)), array('name' => 'sentbox', 'count' => CUserMessageDest::countSentFor($user)), array('name' => 'draft', 'count' => CUserMessageDest::countDraftedFor($user)));
echo json_encode($counts);