function get_read_by($message_ID)
{
    global $read_status_list, $leave_status_list, $Blog, $current_User, $perm_abuse_management;
    $UserCache =& get_UserCache();
    if (empty($Blog)) {
        // Set avatar size for a case when blog is not defined
        $avatar_size = 'crop-top-32x32';
    } else {
        // Get avatar size from blog settings
        $avatar_size = $Blog->get_setting('image_size_messaging');
    }
    $read_recipients = array();
    $unread_recipients = array();
    foreach ($read_status_list as $user_ID => $first_unread_msg_ID) {
        if ($user_ID == $current_User->ID) {
            // Current user status: current user should not be displayed except in case of abuse management
            if ($perm_abuse_management) {
                // current user has seen all received messages for sure, set first unread msg to NULL
                $first_unread_msg_ID = NULL;
            } else {
                // not abuse management
                continue;
            }
        }
        $recipient_User = $UserCache->get_by_ID($user_ID, false);
        if (!$recipient_User) {
            // user not exists
            continue;
        }
        $leave_msg_ID = $leave_status_list[$user_ID];
        if (!empty($leave_msg_ID) && $leave_msg_ID < $message_ID) {
            // user has left the conversation and didn't receive this message
            $left_recipients[] = $recipient_User->login;
        } elseif (empty($first_unread_msg_ID) || $first_unread_msg_ID > $message_ID) {
            // user has read all message from this thread or at least this message
            // user didn't leave the conversation before this message
            $read_recipients[] = $recipient_User->login;
        } else {
            // User didn't read this message, but didn't leave the conversation either
            $unread_recipients[] = $recipient_User->login;
        }
    }
    $read_by = '';
    if (!empty($read_recipients)) {
        // There are users who have read this message
        asort($read_recipients);
        $read_by .= '<div>' . get_avatar_imgtags($read_recipients, true, false, $avatar_size, '', '', true, false);
        if (!empty($unread_recipients)) {
            $read_by .= '<br />';
        }
        $read_by .= '</div>';
    }
    if (!empty($unread_recipients)) {
        // There are users who didn't read this message
        asort($unread_recipients);
        $read_by .= '<div>' . get_avatar_imgtags($unread_recipients, true, false, $avatar_size, '', '', false, false) . '</div>';
    }
    if (!empty($left_recipients)) {
        // There are users who left the conversation before this message
        asort($left_recipients);
        $read_by .= '<div>' . get_avatar_imgtags($left_recipients, true, false, $avatar_size, '', '', 'left_message', false) . '</div>';
    }
    return $read_by;
}
Example #2
0
/**
 * Read? column
 *
 * @param integer Thread ID
 * @return string Status icons
 */
function col_thread_read_by($thread_ID)
{
    global $DB;
    // Select read/unread users for this thread
    $recipients_SQL = get_threads_recipients_sql($thread_ID);
    $read_by = '';
    if ($row = $DB->get_row($recipients_SQL->get())) {
        if (!empty($row->thr_read)) {
            $read_by .= get_avatar_imgtags($row->thr_read, false, false, 'crop-top-15x15', '', '', true, false);
        }
        if (!empty($row->thr_unread)) {
            if (!empty($read_by)) {
                $read_by .= '<br />';
            }
            $read_by .= get_avatar_imgtags($row->thr_unread, false, false, 'crop-top-15x15', '', '', false, false);
        }
        if (!empty($row->thr_left)) {
            if (!empty($read_by)) {
                $read_by .= '<br />';
            }
            $read_by .= get_avatar_imgtags($row->thr_left, false, false, 'crop-top-15x15', '', '', 'left', false);
        }
    }
    return $read_by;
}
     }
 }
 global $Messages;
 $Messages->clear();
 if (empty($available_recipients)) {
     // There are no other existing and not closed users who are still part of this conversation
     $Messages->add(T_('You cannot reply because this conversation was closed.'), 'warning');
     $Messages->display();
 } elseif (!empty($leave_msg_ID)) {
     // Current user has already left this conversation
     $Messages->add(T_('You cannot reply because you have already left this conversation.'), 'warning');
     $Messages->display();
 } else {
     // Current user is still part of this conversation, should be able to reply
     echo $params['messages_list_form_start'];
     $form_title = sprintf(T_('Reply to: %s'), get_avatar_imgtags($available_recipients, true, true, 'crop-top-15x15', 'avatar_before_login mb1'));
     if (is_admin_page()) {
         $form_title .= get_manual_link('messages-reply-to-thread');
     }
     if (!is_admin_page()) {
         echo $params['messages_list_title_start'] . $form_title . $params['messages_list_title_end'];
     }
     echo $params['messages_list_body_start'];
     $Form = new Form($params['form_action'], $params['form_name'], 'post', $params['form_layout']);
     if (!is_admin_page()) {
         // Add hidden blog ID to correctly redirect after message posting:
         $Form->hidden('blog', $Blog->ID);
     }
     $Form->switch_template_parts($params['skin_form_params']);
     $Form->begin_form($params['form_class_msg'], is_admin_page() ? $form_title : '');
     $Form->add_crumb('messaging_messages');