Esempio n. 1
0
echo '<td align="center">';
echo print_user_picture($user1->id, SITEID, $user1->picture, 100, true, true, 'userwindow') . '<br />';
echo fullname($user1);
echo '</td>';
echo '<td align="center">';
echo '<img src="' . $CFG->wwwroot . '/pix/t/left.gif" alt="' . get_string('from') . '" />';
echo '<img src="' . $CFG->wwwroot . '/pix/t/right.gif" alt="' . get_string('to') . '" />';
echo '</td>';
echo '<td align="center">';
echo print_user_picture($user2->id, SITEID, $user2->picture, 100, true, true, 'userwindow') . '<br />';
echo fullname($user2);
echo '</td>';
echo '</tr></table>';
print_simple_box_end();
/// Get all the messages and print them
if ($messages = message_get_history($user1, $user2)) {
    $current->mday = '';
    $current->month = '';
    $current->year = '';
    $messagedate = get_string('strftimetime');
    $blockdate = get_string('strftimedaydate');
    foreach ($messages as $message) {
        $date = usergetdate($message->timecreated);
        if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
            $current->mday = $date['mday'];
            $current->month = $date['month'];
            $current->year = $date['year'];
            echo '<a name="' . $date['year'] . $date['mon'] . $date['mday'] . '"></a>';
            print_heading(userdate($message->timecreated, $blockdate), 'center', 4);
        }
        if ($message->useridfrom == $user1->id) {
Esempio n. 2
0
/**
 * Print the message history between two users
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param string $search search terms to highlight
 * @param int $messagelimit maximum number of messages to return
 * @param string $messagehistorylink the html for the message history link or false
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_print_message_history($user1,$user2,$search='',$messagelimit=0, $messagehistorylink=false, $viewingnewmessages=false) {
    global $CFG, $OUTPUT;

    echo $OUTPUT->box_start('center');
    echo html_writer::start_tag('table', array('cellpadding' => '10', 'class' => 'message_user_pictures'));
    echo html_writer::start_tag('tr');

    echo html_writer::start_tag('td', array('align' => 'center', 'id' => 'user1'));
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user1), array('class' => 'heading'));
    echo html_writer::end_tag('td');

    echo html_writer::start_tag('td', array('align' => 'center'));
    echo html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/left'), 'alt' => get_string('from')));
    echo html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/right'), 'alt' => get_string('to')));
    echo html_writer::end_tag('td');

    echo html_writer::start_tag('td', array('align' => 'center', 'id' => 'user2'));
    echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));

    if (isset($user2->iscontact) && isset($user2->isblocked)) {
        $incontactlist = $user2->iscontact;
        $isblocked = $user2->isblocked;

        $script = null;
        $text = true;
        $icon = false;

        $strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $strblock   = message_get_contact_block_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $useractionlinks = $strcontact.'&nbsp;|'.$strblock;

        echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
    }

    echo html_writer::end_tag('td');
    echo html_writer::end_tag('tr');
    echo html_writer::end_tag('table');
    echo $OUTPUT->box_end();

    if (!empty($messagehistorylink)) {
        echo $messagehistorylink;
    }

    /// Get all the messages and print them
    if ($messages = message_get_history($user1, $user2, $messagelimit, $viewingnewmessages)) {
        $tablecontents = '';

        $current = new stdClass();
        $current->mday = '';
        $current->month = '';
        $current->year = '';
        $messagedate = get_string('strftimetime');
        $blockdate   = get_string('strftimedaydate');
        foreach ($messages as $message) {
            if ($message->notification) {
                $notificationclass = ' notification';
            } else {
                $notificationclass = null;
            }
            $date = usergetdate($message->timecreated);
            if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
                $current->mday = $date['mday'];
                $current->month = $date['month'];
                $current->year = $date['year'];

                $datestring = html_writer::empty_tag('a', array('name' => $date['year'].$date['mon'].$date['mday']));
                $tablecontents .= html_writer::tag('div', $datestring, array('class' => 'mdl-align heading'));

                $tablecontents .= $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'mdl-align');
            }

            $formatted_message = $side = null;
            if ($message->useridfrom == $user1->id) {
                $formatted_message = message_format_message($message, $messagedate, $search, 'me');
                $side = 'left';
            } else {
                $formatted_message = message_format_message($message, $messagedate, $search, 'other');
                $side = 'right';
            }
            $tablecontents .= html_writer::tag('div', $formatted_message, array('class' => "mdl-left $side $notificationclass"));
        }

        echo html_writer::nonempty_tag('div', $tablecontents, array('class' => 'mdl-left messagehistory'));
    } else {
        echo html_writer::nonempty_tag('div', '('.get_string('nomessagesfound', 'message').')', array('class' => 'mdl-align messagehistory'));
    }
}
Esempio n. 3
0
/**
 * Print the message history between two users
 *
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param string $search search terms to highlight
 * @param int $messagelimit maximum number of messages to return
 * @param string $messagehistorylink the html for the message history link or false
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_print_message_history($user1, $user2, $search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false, $showactionlinks = true)
{
    global $CFG, $OUTPUT;
    echo $OUTPUT->box_start('center', 'message_user_pictures');
    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user1');
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user1), array('class' => 'heading'));
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();
    $imgattr = array('src' => $OUTPUT->pix_url('i/twoway'), 'alt' => '', 'width' => 16, 'height' => 16);
    echo $OUTPUT->box(html_writer::empty_tag('img', $imgattr), 'between');
    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user2');
    // Show user picture with link is real user else without link.
    if (core_user::is_real_user($user2->id)) {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    } else {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID, 'link' => false));
    }
    echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));
    if ($showactionlinks && isset($user2->iscontact) && isset($user2->isblocked)) {
        $script = null;
        $text = true;
        $icon = false;
        $strcontact = message_get_contact_add_remove_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
        $strblock = message_get_contact_block_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
        $useractionlinks = $strcontact . '&nbsp;|&nbsp;' . $strblock;
        echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
    }
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();
    if (!empty($messagehistorylink)) {
        echo $messagehistorylink;
    }
    /// Get all the messages and print them
    if ($messages = message_get_history($user1, $user2, $messagelimit, $viewingnewmessages)) {
        $tablecontents = '';
        $current = new stdClass();
        $current->mday = '';
        $current->month = '';
        $current->year = '';
        $messagedate = get_string('strftimetime');
        $blockdate = get_string('strftimedaydate');
        foreach ($messages as $message) {
            if ($message->notification) {
                $notificationclass = ' notification';
            } else {
                $notificationclass = null;
            }
            $date = usergetdate($message->timecreated);
            if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
                $current->mday = $date['mday'];
                $current->month = $date['month'];
                $current->year = $date['year'];
                $datestring = html_writer::empty_tag('a', array('name' => $date['year'] . $date['mon'] . $date['mday']));
                $tablecontents .= html_writer::tag('div', $datestring, array('class' => 'mdl-align heading'));
                $tablecontents .= $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'mdl-align');
            }
            $formatted_message = $side = null;
            if ($message->useridfrom == $user1->id) {
                $formatted_message = message_format_message($message, $messagedate, $search, 'me');
                $side = 'left';
            } else {
                $formatted_message = message_format_message($message, $messagedate, $search, 'other');
                $side = 'right';
            }
            $tablecontents .= html_writer::tag('div', $formatted_message, array('class' => "mdl-left {$side} {$notificationclass}"));
        }
        echo html_writer::nonempty_tag('div', $tablecontents, array('class' => 'mdl-left messagehistory'));
    } else {
        echo html_writer::nonempty_tag('div', '(' . get_string('nomessagesfound', 'message') . ')', array('class' => 'mdl-align messagehistory'));
    }
}
Esempio n. 4
0
/**
 * Print the message history between two users
 *
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param string $search search terms to highlight
 * @param int $messagelimit maximum number of messages to return
 * @param string $messagehistorylink the html for the message history link or false
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_print_message_history($user1, $user2 ,$search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false, $showactionlinks = true) {
    global $OUTPUT, $PAGE;

    $PAGE->requires->yui_module(
        array('moodle-core_message-toolbox'),
        'M.core_message.toolbox.deletemsg.init',
        array(array())
    );

    echo $OUTPUT->box_start('center', 'message_user_pictures');
    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user1');
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user1), array('class' => 'heading'));
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();

    $imgattr = array('src' => $OUTPUT->pix_url('i/twoway'), 'alt' => '', 'width' => 16, 'height' => 16);
    echo $OUTPUT->box(html_writer::empty_tag('img', $imgattr), 'between');

    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user2');
    // Show user picture with link is real user else without link.
    if (core_user::is_real_user($user2->id)) {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    } else {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID, 'link' => false));
    }
    echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));

    if ($showactionlinks && isset($user2->iscontact) && isset($user2->isblocked)) {

        $script = null;
        $text = true;
        $icon = false;

        $strcontact = message_get_contact_add_remove_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
        $strblock   = message_get_contact_block_link($user2->iscontact, $user2->isblocked, $user2, $script, $text, $icon);
        $useractionlinks = $strcontact.'&nbsp;|&nbsp;'.$strblock;

        echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
    }
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();

    if (!empty($messagehistorylink)) {
        echo $messagehistorylink;
    }

    /// Get all the messages and print them
    if ($messages = message_get_history($user1, $user2, $messagelimit, $viewingnewmessages)) {
        $tablecontents = '';

        $current = new stdClass();
        $current->mday = '';
        $current->month = '';
        $current->year = '';
        $messagedate = get_string('strftimetime');
        $blockdate   = get_string('strftimedaydate');
        $messagenumber = 0;
        foreach ($messages as $message) {
            $messagenumber++;
            if ($message->notification) {
                $notificationclass = ' notification';
            } else {
                $notificationclass = null;
            }
            $date = usergetdate($message->timecreated);
            if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
                $current->mday = $date['mday'];
                $current->month = $date['month'];
                $current->year = $date['year'];

                $datestring = html_writer::empty_tag('a', array('name' => $date['year'].$date['mon'].$date['mday']));
                $tablecontents .= html_writer::tag('div', $datestring, array('class' => 'mdl-align heading'));

                $tablecontents .= $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'mdl-align');
            }

            if ($message->useridfrom == $user1->id) {
                $formatted_message = message_format_message($message, $messagedate, $search, 'me');
                $side = 'left';
            } else {
                $formatted_message = message_format_message($message, $messagedate, $search, 'other');
                $side = 'right';
            }

            // Check if it is a read message or not.
            if (isset($message->timeread)) {
                $type = 'message_read';
            } else {
                $type = 'message';
            }

            if (message_can_delete_message($message, $user1->id)) {
                $usergroup = optional_param('usergroup', MESSAGE_VIEW_UNREAD_MESSAGES, PARAM_ALPHANUMEXT);
                $viewing = optional_param('viewing', $usergroup, PARAM_ALPHANUMEXT);
                $deleteurl = new moodle_url('/message/index.php', array('user1' => $user1->id, 'user2' => $user2->id,
                    'viewing' => $viewing, 'deletemessageid' => $message->id, 'deletemessagetype' => $type,
                    'sesskey' => sesskey()));

                $deleteicon = $OUTPUT->action_icon($deleteurl, new pix_icon('t/delete', get_string('delete')));
                $deleteicon = html_writer::tag('div', $deleteicon, array('class' => 'deleteicon accesshide'));
                $formatted_message .= $deleteicon;
            }

            $tablecontents .= html_writer::tag('div', $formatted_message, array('class' => "mdl-left messagecontent
                $side $notificationclass", 'id' => 'message_' . $messagenumber));
        }

        echo html_writer::nonempty_tag('div', $tablecontents, array('class' => 'mdl-left messagehistory'));
    } else {
        echo html_writer::nonempty_tag('div', '('.get_string('nomessagesfound', 'message').')', array('class' => 'mdl-align messagehistory'));
    }
}
Esempio n. 5
0
function message_print_message_history($user1, $user2, $search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false)
{
    global $CFG, $OUTPUT;
    echo $OUTPUT->box_start('center');
    echo '<table cellpadding="10" class="message_user_pictures"><tr>';
    echo '<td align="center" id="user1">';
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo '<div class="heading">' . fullname($user1) . '</div>';
    echo '</td>';
    echo '<td align="center">';
    echo '<img src="' . $OUTPUT->pix_url('t/left') . '" alt="' . get_string('from') . '" />';
    echo '<img src="' . $OUTPUT->pix_url('t/right') . '" alt="' . get_string('to') . '" />';
    echo '</td>';
    echo '<td align="center" id="user2">';
    echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    echo '<div class="heading">' . fullname($user2) . '</div>';
    if (isset($user2->iscontact) && isset($user2->isblocked)) {
        $incontactlist = $user2->iscontact;
        $isblocked = $user2->isblocked;
        $script = null;
        $text = true;
        $icon = false;
        $strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $strblock = message_get_contact_block_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $useractionlinks = $strcontact . '&nbsp;|' . $strblock;
        echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
    }
    echo '</td>';
    echo '</tr></table>';
    echo $OUTPUT->box_end();
    if (!empty($messagehistorylink)) {
        echo $messagehistorylink;
    }
    /// Get all the messages and print them
    if ($messages = message_get_history($user1, $user2, $messagelimit, $viewingnewmessages)) {
        $tablecontents = '';
        $current = new stdClass();
        $current->mday = '';
        $current->month = '';
        $current->year = '';
        $messagedate = get_string('strftimetime');
        $blockdate = get_string('strftimedaydate');
        foreach ($messages as $message) {
            if ($message->notification) {
                $notificationclass = ' notification';
            } else {
                $notificationclass = null;
            }
            $date = usergetdate($message->timecreated);
            if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
                $current->mday = $date['mday'];
                $current->month = $date['month'];
                $current->year = $date['year'];
                $tablecontents .= '<div class="mdl-align heading"><a name="' . $date['year'] . $date['mon'] . $date['mday'] . '"></a>';
                $tablecontents .= $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'center') . '</div>';
            }
            if ($message->useridfrom == $user1->id) {
                $tablecontents .= "<div class='mdl-left left {$notificationclass}'>" . message_format_message($message, $user1, $messagedate, $search, 'me') . '</div><br />';
            } else {
                $tablecontents .= "<div class='mdl-left right {$notificationclass}'>" . message_format_message($message, $user2, $messagedate, $search, 'other') . '</div><br />';
            }
        }
        echo html_writer::nonempty_tag('div', $tablecontents, array('class' => 'mdl-left messagehistory'));
    } else {
        echo html_writer::nonempty_tag('div', '(' . get_string('nomessagesfound', 'message') . ')', array('class' => 'mdl-align messagehistory'));
    }
}