本文整理匯總了PHP中print_user_picture函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_user_picture函數的具體用法?PHP print_user_picture怎麽用?PHP print_user_picture使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_user_picture函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: block_exabis_eportfolio_print_extcomments
function block_exabis_eportfolio_print_extcomments($itemid)
{
$stredit = get_string('edit');
$strdelete = get_string('delete');
$comments = get_records("block_exabeporitemcomm", "itemid", $itemid, 'timemodified DESC');
if (!$comments) {
return;
}
foreach ($comments as $comment) {
$user = get_record('user', 'id', $comment->userid);
echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">';
echo '<tr class="header"><td class="picture left">';
print_user_picture($comment->userid, SITEID, $user->picture);
echo '</td>';
echo '<td class="topic starter"><div class="author">';
$fullname = fullname($user, $comment->userid);
$by = new object();
$by->name = $fullname;
$by->date = userdate($comment->timemodified);
print_string('bynameondate', 'forum', $by);
echo '</div></td></tr>';
echo '<tr><td class="left side">';
echo '</td><td class="content">' . "\n";
echo format_text($comment->entry);
echo '</td></tr></table>' . "\n\n";
}
}
示例2: definition_after_data
function definition_after_data()
{
global $CFG, $DB;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
if (strpos($lang, '_utf8') === false) {
$lang = $lang . '_utf8';
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($lang);
}
// check lang exists
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = $DB->get_record('user', array('id' => $userid))) {
// remove description
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true));
} else {
$image_el->setValue(get_string('none'));
}
}
/// disable fields that are locked by auth plugins
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$mform->hardFreeze($field);
$mform->setConstant($field, $user->{$field});
}
}
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
示例3: get_hawthorn
/**
* Creates a new Hawthorn object.
* @param object $course Moodle course object. If not supplied, uses $COURSE.
* Only required field is ->id.
*/
function get_hawthorn($course = null)
{
global $USER, $COURSE, $CFG;
if ($course == null) {
$course = $COURSE;
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
// Work out user permissions
$permissions = '';
if (has_capability('block/hawthorn:chat', $context)) {
$permissions .= 'rw';
}
if (has_capability('block/hawthorn:moderate', $context)) {
$permissions .= 'm';
}
if (has_capability('block/hawthorn:admin', $context)) {
$permissions .= 'a';
}
// Get user picture URL
$userpic = print_user_picture($USER, $COURSE->id, NULL, 0, true, false);
$userpic = preg_replace('~^.*src="([^"]*)".*$~', '$1', $userpic);
// Decide key expiry (ms). Usually 1 hour, unless session timeout is lower.
$keyExpiry = 3600000;
if ($CFG->sessiontimeout * 1000 < $keyExpiry) {
// Set expiry to session timeout (note that the JS will make a re-acquire
// request 5 minutes before this)
$keyExpiry = $CFG->sessiontimeout * 1000;
}
// Get server list
$servers = empty($CFG->block_hawthorn_servers) ? array() : explode(',', $CFG->block_hawthorn_servers);
$magicnumber = empty($CFG->block_hawthorn_magicnumber) ? 'xxx' : $CFG->block_hawthorn_magicnumber;
// Construct Hawthorn object
return new hawthorn($magicnumber, $servers, hawthorn::escapeId($USER->username), fullname($USER), $userpic, $permissions, $CFG->wwwroot . '/blocks/hawthorn/hawthorn.js', $CFG->wwwroot . '/blocks/hawthorn/popup.php', $CFG->wwwroot . '/blocks/hawthorn/reacquire.php', false, $keyExpiry);
}
示例4: get_content
function get_content()
{
global $USER, $CFG;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) {
return $this->content;
}
$this->content->footer = '<a href="' . $CFG->wwwroot . '/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . get_string('messages', 'message') . '</a>...';
$users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count,\n u.firstname, u.lastname, u.picture, u.lastaccess\n FROM {$CFG->prefix}user u, \n {$CFG->prefix}message m \n WHERE m.useridto = '{$USER->id}' \n AND u.id = m.useridfrom\n GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess");
//Now, we have in users, the list of users to show
//Because they are online
if (!empty($users)) {
$this->content->text .= '<ul class="list">';
foreach ($users as $user) {
$timeago = format_time(time() - $user->lastaccess);
$this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->instance->pageid . '" title="' . $timeago . '">';
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 0, true, false, '', false);
$this->content->text .= fullname($user) . '</a></div>';
$this->content->text .= '<div class="message"><a href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\'; return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="' . $CFG->pixpath . '/t/message.gif" alt="" /> ' . $user->count . '</a>';
$this->content->text .= '</div></li>';
}
$this->content->text .= '</ul>';
} else {
$this->content->text .= '<div class="info">';
$this->content->text .= get_string('nomessages', 'message');
$this->content->text .= '</div>';
}
return $this->content;
}
示例5: glossary_show_entry_encyclopedia
function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode = '', $hook = '', $printicons = 1, $ratings = NULL, $aliases = true)
{
global $CFG, $USER, $DB;
$user = $DB->get_record('user', array('id' => $entry->userid));
$strby = get_string('writtenby', 'glossary');
$return = false;
if ($entry) {
echo '<table class="glossarypost encyclopedia" cellspacing="0">';
echo '<tr valign="top">';
echo '<td class="left picture">';
print_user_picture($user, $course->id, $user->picture);
echo '</td>';
echo '<th class="entryheader">';
echo '<div class="concept">';
glossary_print_entry_concept($entry);
echo '</div>';
$fullname = fullname($user);
$by = new object();
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . $fullname . '</a>';
$by->date = userdate($entry->timemodified);
echo '<span class="author">' . get_string('bynameondate', 'forum', $by) . '</span>';
echo '</th>';
echo '<td class="entryapproval">';
glossary_print_entry_approval($cm, $entry, $mode);
echo '</td>';
echo '</tr>';
echo '<tr valign="top">';
echo '<td class="left side" rowspan="2"> </td>';
echo '<td colspan="2" class="entry">';
if ($entry->attachment) {
$entry->course = $course->id;
if (strlen($entry->definition) % 2) {
$align = 'right';
} else {
$align = 'left';
}
glossary_print_entry_attachment($entry, $cm, null, $align, false);
}
glossary_print_entry_definition($entry, $glossary, $cm);
if ($printicons or $ratings or $aliases) {
echo '</td></tr>';
echo '<tr>';
echo '<td colspan="2" class="entrylowersection">';
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
echo ' ';
}
echo '</td></tr>';
echo "</table>\n";
} else {
echo '<div style="text-align:center">';
print_string('noentry', 'glossary');
echo '</div>';
}
return $return;
}
示例6: col_picture
function col_picture($attempt)
{
global $COURSE;
$user = new object();
$user->id = $attempt->userid;
$user->lastname = $attempt->lastname;
$user->firstname = $attempt->firstname;
$user->imagealt = $attempt->imagealt;
$user->picture = $attempt->picture;
return print_user_picture($user, $COURSE->id, $attempt->picture, false, true);
}
示例7: format_user_list
function format_user_list($data, $course)
{
global $CFG, $DB;
$users = array();
foreach ($data as $v) {
$user['name'] = fullname($v);
$user['url'] = $CFG->wwwroot . '/user/view.php?id=' . $v->id . '&course=' . $course->id;
$user['picture'] = print_user_picture($v->id, 0, $v->picture, false, true, false);
$user['id'] = $v->id;
$users[] = $user;
}
return $users;
}
示例8: definition_after_data
function definition_after_data()
{
global $CFG;
$mform =& $this->_form;
$userid = $mform->getElementValue('id');
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
if ($user = get_record('user', 'id', $userid)) {
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true));
} else {
$image_el->setValue(get_string('none'));
}
}
/// disable fields that are locked by auth plugins
$fields = get_user_fieldnames();
$freezefields = array();
$authplugin = get_auth_plugin($user->auth);
foreach ($fields as $field) {
if (!$mform->elementExists($field)) {
continue;
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$freezefields[] = $field;
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
$freezefields[] = $field;
}
}
}
}
$mform->hardFreeze($freezefields);
}
/// Next the customisable profile fields
profile_definition_after_data($mform);
}
示例9: definition_after_data
function definition_after_data()
{
global $USER, $CFG;
$mform =& $this->_form;
if ($userid = $mform->getElementValue('id')) {
$user = get_record('user', 'id', $userid);
} else {
$user = false;
}
// if language does not exist, use site default lang
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
$lang_el =& $mform->getElement('lang');
$lang_el->setValue($CFG->lang);
}
}
// user can not change own auth method
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// admin must choose some password and supply correct email
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
$email_el =& $mform->getElement('email');
if ($email_el->getValue() == 'root@localhost') {
$email_el->setValue('');
}
}
// require password for new users
if ($userid == -1) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
}
// print picture
if (!empty($CFG->gdversion)) {
$image_el =& $mform->getElement('currentpicture');
if ($user and $user->picture) {
$image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true));
} else {
$image_el->setValue(get_string('none'));
}
}
/// Next the customisable profile fields
profile_definition_after_data($mform);
}
示例10: display_submissions
//.........這裏部分代碼省略.........
foreach ($keys as $key) {
unset($users[$key]);
}
}
if (empty($users)) {
print_heading(get_string('noattempts', 'assignment'));
return true;
}
/// Construct the SQL
if ($where = $table->get_sql_where()) {
$where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
$sort = ' ORDER BY ' . $sort;
}
$select = 'SELECT u.id, u.firstname, u.lastname, u.picture,
s.id AS submissionid, s.grade, s.submissioncomment,
s.timemodified, s.timemarked,
COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ';
$sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid
AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
$table->pagesize($perpage, count($users));
///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
$offset = $page * $perpage;
$strupdate = get_string('update');
$strgrade = get_string('grade');
$grademenu = make_grades_menu($this->assignment->grade);
if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) {
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
foreach ($ausers as $auser) {
$final_grade = $grading_info->items[0]->grades[$auser->id];
/// Calculate user status
$auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified;
$picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true);
if (empty($auser->submissionid)) {
$auser->grade = -1;
//no submission yet
}
if (!empty($auser->submissionid)) {
///Prints student answer and student modified date
///attach file or print link to student answer, depending on the type of the assignment.
///Refer to print_student_answer in inherited classes.
if ($auser->timemodified > 0) {
$studentmodified = '<div id="ts' . $auser->id . '">' . $this->print_student_answer($auser->id) . userdate($auser->timemodified) . '</div>';
} else {
$studentmodified = '<div id="ts' . $auser->id . '"> </div>';
}
///Print grade, dropdown or text
if ($auser->timemarked > 0) {
$teachermodified = '<div id="tt' . $auser->id . '">' . userdate($auser->timemarked) . '</div>';
if ($final_grade->locked or $final_grade->overridden) {
$grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
} else {
if ($quickgrade) {
$menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
$grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
} else {
$grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
}
}
} else {
$teachermodified = '<div id="tt' . $auser->id . '"> </div>';
if ($final_grade->locked or $final_grade->overridden) {
$grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
} else {
if ($quickgrade) {
示例11: array_sum
$weights[] = $brainstorm->feedbackweight;
$gradeparts[] = $gradeset->feedback;
} else {
$feedbackgrade = '';
}
} else {
$feedbackgrade = "<img src=\"{$CFG->wwwroot}/mod/brainstorm/teachhat.jpg\" width=\"30\" />";
}
// calculates final
$weighting = array_sum($weights);
$finalgrade = 0;
for ($i = 0; $i < count($gradeparts); $i++) {
$finalgrade += $gradeparts[$i] * $weights[$i];
}
$finalgrade = sprintf("%0.2f", $finalgrade / $weighting);
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true, true);
$studentname = fullname($student);
$updatelink = "<a href=\"view.php?id={$cm->id}&gradefor={$student->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\"></a><br/>";
$deletelink = "<a href=\"view.php?id={$cm->id}&what=deletegrade&for={$student->id}\"><img src=\"{$CFG->pixpath}/t/delete.gif\"></a><br/>";
$table->data[] = array($picture, $studentname, $participategrade, $preparinggrade, $organizegrade, $feedbackgrade, "<b>{$finalgrade}</b>", $updatelink . ' ' . $deletelink);
}
print_table($table);
}
}
?>
</td>
</tr>
</table>
<?php
} else {
// grading a user
示例12: get_context_instance
$country = '(' . $user->country . ') ' . $countries[$user->country];
} else {
$country = $countries[$user->country];
}
}
if (!isset($user->context)) {
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
} else {
$usercontext = $user->context;
}
if ($piclink = $USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) || has_capability('moodle/user:viewdetails', $usercontext)) {
$profilelink = '<strong><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . fullname($user) . '</a></strong>';
} else {
$profilelink = '<strong>' . fullname($user) . '</strong>';
}
$data = array(print_user_picture($user, $course->id, $user->picture, false, true, $piclink), $profilelink . $hidden);
if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
$data[] = $user->city;
}
if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) {
$data[] = $country;
}
if (!isset($hiddenfields['lastaccess'])) {
$data[] = $lastaccess;
}
if ($course->enrolperiod) {
if ($user->timeend) {
$data[] = userdate($user->timeend, $timeformat);
} else {
$data[] = get_string('unlimited');
}
示例13: create_overview_table
function create_overview_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables)
{
global $CFG;
$strtimeformat = get_string('strftimedatetime');
$is_html = $options['reportformat'] == 'htm';
$spacer = $is_html ? ' ' : ' ';
$br = $is_html ? "<br />\n" : "\n";
// initialize $table
unset($table);
$table->border = 1;
$table->width = 10;
$table->head = array();
$table->align = array();
$table->size = array();
$table->wrap = array();
// picture column, if required
if ($is_html) {
$table->head[] = $spacer;
$table->align[] = 'center';
$table->size[] = 10;
$table->wrap[] = "nowrap";
}
array_push($table->head, get_string("name"), hotpot_grade_heading($hotpot, $options), get_string("attempt", "quiz"), get_string("time", "quiz"), get_string("reportstatus", "hotpot"), get_string("timetaken", "quiz"), get_string("score", "quiz"));
array_push($table->align, "left", "center", "center", "left", "center", "center", "center");
array_push($table->wrap, "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap");
array_push($table->size, "*", "*", "*", "*", "*", "*", "*");
$abandoned = 0;
foreach ($users as $user) {
// shortcut to user info held in first attempt record
$u =& $user->attempts[0];
$picture = '';
$name = fullname($u);
if ($is_html) {
$picture = print_user_picture($u->userid, $course->id, $u->picture, false, true);
$name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $u->userid . '&course=' . $course->id . '">' . $name . '</a>';
}
$grade = isset($user->grade) && $user->grade != ' ' ? $user->grade : $spacer;
$attemptcount = count($user->attempts);
if ($attemptcount > 1) {
$text = $name;
$name = NULL;
$name->text = $text;
$name->rowspan = $attemptcount;
$text = $grade;
$grade = NULL;
$grade->text = $text;
$grade->rowspan = $attemptcount;
}
$data = array();
if ($is_html) {
if ($attemptcount > 1) {
$text = $picture;
$picture = NULL;
$picture->text = $text;
$picture->rowspan = $attemptcount;
}
$data[] = $picture;
}
array_push($data, $name, $grade);
foreach ($user->attempts as $attempt) {
// increment count of abandoned attempts
// if attempt is marked as finished but has no score
if ($attempt->status == HOTPOT_STATUS_ABANDONED) {
$abandoned++;
}
$attemptnumber = $attempt->attempt;
$starttime = trim(userdate($attempt->timestart, $strtimeformat));
if ($is_html && isset($attempt->score) && (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review)) {
$attemptnumber = '<a href="review.php?hp=' . $hotpot->id . '&attempt=' . $attempt->id . '">' . $attemptnumber . '</a>';
$starttime = '<a href="review.php?hp=' . $hotpot->id . '&attempt=' . $attempt->id . '">' . $starttime . '</a>';
}
if ($is_html && has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id))) {
$checkbox = '<input type="checkbox" name="box' . $attempt->clickreportid . '" value="' . $attempt->clickreportid . '" />' . $spacer;
} else {
$checkbox = '';
}
$timetaken = empty($attempt->timefinish) ? $spacer : format_time($attempt->timefinish - $attempt->timestart);
$score = hotpot_format_score($attempt);
if ($is_html && is_numeric($score) && $score == $user->grade) {
// best grade
$score = '<span class="highlight">' . $score . '</span>';
}
array_push($data, $attemptnumber, $checkbox . $starttime, hotpot_format_status($attempt), $timetaken, $score);
$table->data[] = $data;
$data = array();
}
// end foreach $attempt
$table->data[] = 'hr';
}
// end foreach $user
// remove final 'hr' from data rows
array_pop($table->data);
// add the "delete" form to the table
if ($options['reportformat'] == 'htm' && has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id))) {
$strdeletecheck = get_string('deleteattemptcheck', 'quiz');
$table->start = $this->deleteform_javascript();
$table->start .= '<form method="post" action="report.php" id="deleteform" onsubmit="' . "return deletecheck('" . $strdeletecheck . "', 'selection')" . '">' . "\n";
$table->start .= '<input type="hidden" name="del" value="selection" />' . "\n";
$table->start .= '<input type="hidden" name="id" value="' . $cm->id . '" />' . "\n";
$table->finish = '<center>' . "\n";
//.........這裏部分代碼省略.........
示例14: message_post_message
if (!empty($refresh) and data_submitted()) {
$refreshedmessage = $message;
} else {
if (empty($refresh) and data_submitted() and confirm_sesskey()) {
if ($message != '') {
message_post_message($USER, $user, $message, $format, 'direct');
}
redirect('discussion.php?id=' . $userid . '&start=' . $start . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last);
}
}
$userfullname = fullname($user);
$mefullname = fullname($USER);
print_header(get_string('discussion', 'message') . ': ' . fullname($user), '', '', 'edit-message');
echo '<div class="message-discussion-noframes">';
echo '<div id="userinfo">';
echo print_user_picture($user->id, SITEID, $user->picture, 48, true, true, 'userwindow');
echo '<div class="name"><h1>' . $userfullname . '</h1></div>';
echo '<div class="commands"><ul>';
if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
if ($contact->blocked) {
echo '<li>';
message_contact_link($user->id, 'add', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true);
echo '</li><li>';
message_contact_link($user->id, 'unblock', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true);
echo '</li>';
} else {
echo '<li>';
message_contact_link($user->id, 'remove', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true);
echo '</li><li>';
message_contact_link($user->id, 'block', false, 'discussion.php?id=' . $user->id . '&noframesjs=' . $noframesjs . '&newonly=' . $newonly . '&last=' . $last, true);
echo '</li>';
示例15: display
//.........這裏部分代碼省略.........
}
// Reconstruct the sort string.
$sort = ' ORDER BY ' . implode(', ', $newsort);
}
// Fix some wired sorting.
if (empty($sort)) {
$sort = ' ORDER BY qa.id';
}
$table->pagesize($pagesize, $total);
}
// If there is feedback, include it in the query.
if ($hasfeedback) {
$select .= ', qf.feedbacktext ';
$from .= " JOIN {game_feedback} qf ON " . "qf.gameid = {$game->id} AND qf.mingrade <= qa.score * {$game->grade} AND qa.score * {$game->grade} < qf.maxgrade";
}
// Fetch the attempts.
if (!empty($from)) {
// If we're in the site course and displaying no attempts, it makes no sense to do the query.
if (!$download) {
$attempts = get_records_sql($select . $from . $where . $sort, $table->get_page_start(), $table->get_page_size());
} else {
$attempts = get_records_sql($select . $from . $where . $sort);
}
} else {
$attempts = array();
}
// Build table rows.
if (!$download) {
$table->initialbars($totalinitials > 20);
}
if (!empty($attempts) || !empty($noattempts)) {
if ($attempts) {
foreach ($attempts as $attempt) {
$picture = print_user_picture($attempt->userid, $course->id, $attempt->picture, false, true);
/* Uncomment the commented lines below if you are choosing to show unenrolled users and
* have uncommented the corresponding lines earlier in this script
* if (in_array($attempt->userid, $unenrolledusers)) {
* $userlink = '<a class="dimmed" href="'.$CFG->wwwroot.
* '/user/view.php?id='.$attempt->userid.'&course='.$course->id.'">'.fullname($attempt).'</a>';
*}
*else {
* $userlink = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.
* $attempt->userid.'&course='.$course->id.'">'.fullname($attempt).'</a>';
*}
*/
if (!$download) {
$row = array('<input type="checkbox" name="attemptid[]" value="' . $attempt->attempt . '" />', $picture, $userlink, empty($attempt->attempt) ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . userdate($attempt->timestart, $strtimeformat) . '</a>', empty($attempt->timefinish) ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . userdate($attempt->timefinish, $strtimeformat) . '</a>', empty($attempt->attempt) ? '-' : (empty($attempt->timefinish) ? get_string('unfinished', 'game') : format_time($attempt->duration)));
} else {
$row = array(fullname($attempt), empty($attempt->attempt) ? '-' : userdate($attempt->timestart, $strtimeformat), empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish, $strtimeformat), empty($attempt->attempt) ? '-' : (empty($attempt->timefinish) ? get_string('unfinished', 'game') : format_time($attempt->duration)));
}
if ($game->grade) {
if (!$download) {
$row[] = $attempt->score === null ? '-' : '<a href="review.php?q=' . $game->id . '&attempt=' . $attempt->attempt . '">' . round($attempt->score * $game->grade, $game->decimalpoints) . '</a>';
} else {
$row[] = $attempt->score === null ? '-' : round($attempt->score * $game->grade, $game->decimalpoints);
}
}
if ($detailedmarks) {
if (empty($attempt->attempt)) {
foreach ($questionids as $questionid) {
$row[] = '-';
}
} else {
foreach ($questionids as $questionid) {
if ($gradedstateid = get_field('question_sessions', 'newgraded', 'attemptid', $attempt->attemptuniqueid, 'questionid', $questionid)) {
$grade = round(get_field('question_states', 'grade', 'id', $gradedstateid), $game->decimalpoints);