* $Id$
 *  
 * @category Messagerie
 * @package  Mediboard
 * @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_dest_ids = json_decode(stripslashes(CValue::get("user_dest_ids", '[]')));
$action = CValue::get("action");
$value = CValue::get("value");
foreach ($user_dest_ids as $user_dest_id) {
    $usermessagedest = new CUserMessageDest();
    $usermessagedest->load($user_dest_id);
    switch ($action) {
        case 'archive':
            $usermessagedest->archived = $value;
            if (!$usermessagedest->datetime_read) {
                $usermessagedest->datetime_read = CMbDT::dateTime();
            }
            break;
        case 'star':
            $usermessagedest->starred = $value;
            break;
        case 'delete':
            if (is_null($usermessagedest->datetime_sent)) {
                $user_message = $usermessagedest->loadRefMessage();
                $delete_message = true;
                $user_message->loadRefDests();
Ejemplo n.º 2
0
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
$user = CMediusers::get();
$to_id = CValue::get("to_id");
$answer_to_all = CValue::get('answer_to_all');
$in_reply_to = CValue::get("in_reply_to");
$message_id = CValue::getOrSession("usermessage_id");
$dest_message = CValue::get("usermessage_dest_id");
$subject = utf8_decode(CValue::get('subject'));
// classic case
$usermessage = new CUserMessage();
$usermessage->load($message_id);
if ($dest_message) {
    $dest = new CUserMessageDest();
    $dest->load($dest_message);
    $usermessage = $dest->loadRefMessage();
}
/** @var CUserMessageDest[] $destinataires */
// check if sent
$usermessage->_can_edit = true;
$usermessage->loadRefDestUser();
$destinataires = $usermessage->loadRefDests();
foreach ($destinataires as $_dest) {
    if ($_dest->datetime_sent) {
        $usermessage->_can_edit = false;
    }
    if ($_dest->to_user_id == $user->_id && $usermessage->_id && !$_dest->datetime_read) {
        $_dest->datetime_read = CMbDT::dateTime();
        $_dest->store();
    }