if (is_null($_user_dest->datetime_sent)) {
                     if ($msg = $_user_dest->delete()) {
                         CAppUI::stepAjax($msg, UI_MSG_ERROR);
                     }
                 } else {
                     $delete_message = false;
                 }
             }
             if ($delete_message) {
                 if ($msg = $user_message->delete()) {
                     CAppUI::stepAjax($msg, UI_MSG_ERROR);
                 }
             }
         } else {
             $usermessagedest->deleted = '1';
             if ($msg = $usermessagedest->store()) {
                 CAppUI::stepAjax($msg, UI_MSG_ERROR);
             }
         }
         break;
     case 'mark_read':
         $usermessagedest->datetime_read = CMbDT::dateTime();
         break;
     case 'mark_unread':
         $usermessagedest->datetime_read = '';
         break;
     default:
         break;
 }
 if ($action != 'delete') {
     if ($msg = $usermessagedest->store()) {
            if ($msg = $_dest->delete()) {
                CAppUI::stepAjax($msg, UI_MSG_ERROR);
            }
            continue;
        }
    }
    foreach ($dests as $_dest) {
        $destinataire = new CUserMessageDest();
        $destinataire->user_message_id = $usermessage->_id;
        $destinataire->from_user_id = $usermessage->creator_id;
        $destinataire->to_user_id = $_dest;
        $destinataire->loadMatchingObject();
        if ($send_it) {
            $destinataire->datetime_sent = $date;
        }
        if ($msg = $destinataire->store()) {
            CAppUI::stepAjax($msg, UI_MSG_ERROR);
        }
    }
    $msg = $_POST["usermessage_id"] ? 'CUserMessage-msg-modify' : 'CUserMessage-msg-create';
    if ($send_it) {
        $msg = 'CUserMessage-msg-sent';
    }
}
CAppUI::setMsg($msg, UI_MSG_OK);
$smarty = new CSmartyDP();
$messages = CAppUI::getMsg();
$smarty->assign('messages', $messages);
$smarty->display('inc_callback_modal.tpl');
if ($callback) {
    CAppUI::callbackAjax($callback, 'internal', $message_id);