Exemplo n.º 1
0
$currentSection = 'inbox';
if (isset($_REQUEST['userId'])) {
    $userId = (int) $_REQUEST['userId'];
} else {
    $userId = claro_get_current_user_id();
}
if ($userId != claro_get_current_user_id() && !claro_is_platform_admin()) {
    claro_die(get_lang("Not allowed"));
}
// load the message
if (is_null($messageId) || is_null($type) || $type != "received" && $type != "sent") {
    claro_die(get_lang('Missing parameter : %param%', array('%param%' => get_lang('message id'))));
}
if ($type == "received") {
    try {
        $message = ReceivedMessage::fromId($messageId, $userId);
        if ($message->isDeleted()) {
            $currentSection = 'trashbox';
        } else {
            $currentSection = 'inbox';
        }
        if ($message === false) {
            claro_die('Message not found');
        }
        if (claro_get_current_user_id() == $userId) {
            $message->markRead();
        }
    } catch (Exeption $e) {
        claro_die(get_lang('Message not found'));
    }
} else {
Exemplo n.º 2
0
     $dialogBox = new DialogBox();
     $dialogBox->error(get_lang("Subject couldn't be empty"));
     $content .= $dialogBox->render();
     $addForm = TRUE;
 } else {
     $message = new MessageToSend(claro_get_current_user_id(), $subject, $message);
     if ($_REQUEST['typeRecipient'] == 'user') {
         $recipient = new SingleUserRecipient($_POST['userRecipient']);
         if (claro_is_in_a_group()) {
             $message->setCourse(claro_get_current_course_id());
             $message->setGroup(claro_get_current_group_id());
         } elseif (claro_is_in_a_course()) {
             $message->setCourse(claro_get_current_course_id());
         } elseif (!empty($_POST['responseTo'])) {
             if (can_answer_message((int) $_POST['responseTo'])) {
                 $messageParent = ReceivedMessage::fromId((int) $_POST['responseTo'], claro_get_current_user_id());
                 if (!is_null($messageParent->getCourseCode())) {
                     $message->setCourse($messageParent->getCourseCode());
                 }
                 if (!is_null($messageParent->getGroupId())) {
                     $message->setGroup($messageParent->getGroupId());
                 }
             } else {
                 claro_die(get_lang('Not allowed'));
             }
         } else {
             //No context to load
         }
     } elseif ($_REQUEST['typeRecipient'] == 'course') {
         $recipient = new CourseRecipient($_POST['courseRecipient']);
         $message->setCourse($_POST['courseRecipient']);