/** * */ protected function replacements(array $patterns, $entry, array $options = null) { $field = $this->_field; $edit = !empty($options['edit']); // Set the group object. $group = new \stdClass(); if ($entry->id < 0) { $entry->groupid = $field->df->currentgroup; } $group->id = $entry->groupid; $group->idnumber = isset($entry->groupidnumber) ? $entry->groupidnumber : null; $group->name = isset($entry->groupname) ? $entry->groupname : null; $group->hidepicture = isset($entry->grouphidepic) ? $entry->grouphidepic : null; $group->picture = isset($entry->grouppic) ? $entry->grouppic : null; $replacements = array(); foreach ($patterns as $pattern) { $replacements[$pattern] = ''; list(, $pvar, $part) = array_pad(explode(':', trim($pattern, '[]')), 3, null); switch ($pvar) { case 'id': $replacements[$pattern] = $group->id ? $group->id : '0'; break; case 'idnumber': $replacements[$pattern] = $group->idnumber; break; case 'name': $replacements[$pattern] = $group->name; break; case 'description': // Currently we do not fetch group description. break; case 'picture': $replacements[$pattern] = print_group_picture($group, $field->df->course->id, false, true); break; case 'picturelarge': $replacements[$pattern] = print_group_picture($group, $field->df->course->id, true, true); break; case 'edit': if ($edit and has_capability('mod/dataform:manageentries', $field->df->context)) { $replacements[$pattern] = array(array($this, 'display_edit'), array($entry)); } else { $replacements[$pattern] = $group->name; } break; case 'members': $replacements[$pattern] = $this->render_browse_members($entry, array('part' => $part)); break; } } return $replacements; }
/** * Extend the form definition after the data has been parsed. */ public function definition_after_data() { global $COURSE, $DB; $mform = $this->_form; $groupid = $mform->getElementValue('id'); if ($group = $DB->get_record('groups', array('id' => $groupid))) { // Print picture. if (!($pic = print_group_picture($group, $COURSE->id, true, true, false))) { $pic = get_string('none'); if ($mform->elementExists('deletepicture')) { $mform->removeElement('deletepicture'); } } $imageelement = $mform->getElement('currentpicture'); $imageelement->setValue($pic); } else { if ($mform->elementExists('currentpicture')) { $mform->removeElement('currentpicture'); } if ($mform->elementExists('deletepicture')) { $mform->removeElement('deletepicture'); } } }
/** * Print a specified group's avatar. * * @param group $group A single {@link group} object OR array of groups. * @param int $courseid The course ID. * @param boolean $large Default small picture, or large. * @param boolean $return If false print picture, otherwise return the output as string * @param boolean $link Enclose image in a link to view specified course? * @return string * @todo Finish documenting this function */ function print_group_picture($group, $courseid, $large = false, $return = false, $link = true) { global $CFG; if (is_array($group)) { $output = ''; foreach ($group as $g) { $output .= print_group_picture($g, $courseid, $large, true, $link); } if ($return) { return $output; } else { echo $output; return; } } $context = get_context_instance(CONTEXT_COURSE, $courseid); if ($group->hidepicture and !has_capability('moodle/course:managegroups', $context)) { return ''; } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output = '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $courseid . '&group=' . $group->id . '">'; } else { $output = ''; } if ($large) { $file = 'f1'; } else { $file = 'f2'; } if ($group->picture) { // Print custom group picture require_once $CFG->libdir . '/filelib.php'; $grouppictureurl = get_file_url($group->id . '/' . $file . '.jpg', null, 'usergroup'); $output .= '<img class="grouppicture" src="' . $grouppictureurl . '"' . ' alt="' . s(get_string('group') . ' ' . $group->name) . '" title="' . s($group->name) . '"/>'; } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output .= '</a>'; } if ($return) { return $output; } else { echo $output; } }
if (is_object($group) and groups_is_member($group->id, $user->id) or !is_object($group) and $group == 0 and in_array($user->id, $notingroup)) { // this is our fake group and this user is not a member of another group if (isset($form->mailto) && in_array($user->id, $form->mailto)) { $checked = 'checked="checked"'; } else { $checked = ''; } $cells[] = "<input type=\"checkbox\" {$checked} id=\"mailto{$t}\" value=\"{$user->id}\" name=\"mailto[{$user->id}]\" />" . "<label for=\"mailto{$t}\">" . fullname($user, true) . '</label>'; $t++; } } $end = $t; // cell1 has the group picture, name and check button $cell1 = ''; if ($group) { $cell1 .= print_group_picture($group, $course->id, false, true) . '<br />'; } if ($group) { $cell1 .= groups_get_group_name($group->id); } else { $cell1 .= get_string('notingroup', 'block_quickmail'); } if (count($groups) > 1 and !empty($cells)) { $selectlinks = '<a href="javascript:void(0);" onclick="block_quickmail_toggle(true, ' . $start . ', ' . $end . ');">' . get_string('selectall') . '</a> / <a href="javascript:void(0);" onclick="block_quickmail_toggle(false, ' . $start . ', ' . $end . ');">' . get_string('deselectall') . '</a>'; } else { $selectlinks = ''; } $buttoncount++; // cell2 has the checkboxes and the user names inside of a table if (empty($cells) and !$group) {
function data_print_comment($data, $comment, $page = 0) { global $USER, $CFG; $cm = get_coursemodule_from_instance('data', $data->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $stredit = get_string('edit'); $strdelete = get_string('delete'); $user = get_record('user', 'id', $comment->userid); echo '<table cellspacing="0" align="center" width="50%" class="datacomment forumpost">'; echo '<tr class="header"><td class="picture left">'; print_user_picture($user, $data->course, $user->picture); echo '</td>'; echo '<td class="topic starter" align="left"><div class="author">'; $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context)); $by = new object(); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $data->course . '">' . $fullname . '</a>'; $by->date = userdate($comment->modified); print_string('bynameondate', 'data', $by); echo '</div></td></tr>'; echo '<tr><td class="left side">'; if ($groups = groups_get_all_groups($data->course, $comment->userid, $cm->groupingid)) { print_group_picture($groups, $data->course, false, false, true); } else { echo ' '; } // Actual content echo '</td><td class="content" align="left">' . "\n"; // Print whole message echo format_text($comment->content, $comment->format); // Commands echo '<div class="commands">'; if (data_isowner($comment->recordid) or has_capability('mod/data:managecomments', $context)) { echo '<a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&mode=edit&commentid=' . $comment->id . '&page=' . $page . '">' . $stredit . '</a>'; echo '| <a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&mode=delete&commentid=' . $comment->id . '&page=' . $page . '">' . $strdelete . '</a>'; } echo '</div>'; echo '</td></tr></table>' . "\n\n"; }
if ($groupingid and $groupingid != $gpgid) { continue; // do not show } $table = new html_table(); $table->head = array(get_string('groupscount', 'group', count($groupdata)), get_string('groupmembers', 'group'), get_string('usercount', 'group')); $table->size = array('20%', '70%', '10%'); $table->align = array('left', 'left', 'center'); $table->width = '90%'; $table->data = array(); foreach ($groupdata as $gpid => $users) { if ($groupid and $groupid != $gpid) { continue; } $line = array(); $name = print_group_picture($groups[$gpid], $course->id, false, true, false) . format_string($groups[$gpid]->name); $description = file_rewrite_pluginfile_urls($groups[$gpid]->description, 'pluginfile.php', $context->id, 'group', 'description', $gpid); $options = new stdClass(); $options->noclean = true; $options->overflowdiv = true; $jsdescription = trim(format_text($description, $groups[$gpid]->descriptionformat, $options)); if (empty($jsdescription)) { $line[] = $name; } else { $line[] = html_writer::tag('span', $name, array('id' => 'group_' . $gpid)); $hoverevents['group_' . $gpid] = $jsdescription; } $fullnames = array(); foreach ($users as $user) { $fullnames[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . fullname($user, true) . '</a>'; }
/** * Given the data about a posting, builds up the HTML to display it and * returns the HTML in a string. This is designed for sending via HTML email. */ function referentiel_make_mail_post($type, $context, $course, $post, $userfrom, $userto, $ownpost = false, $link = false, $rate = false, $footer = "") { global $CFG; global $OUTPUT; $output = ''; if (REFERENTIEL_DEBUG) { mtrace("DEBUG : cron_lib.php : 2342 : referentiel_make_mail_post \n TYPE: " . $type . "\n"); mtrace("CONTEXT\n"); print_r($context); mtrace("COURSE ID " . $course->id . "\n"); //print_r($course); mtrace("POST\n"); print_r($post); mtrace("USERFROM ID : " . $userfrom->id . "\n"); //print_r($userfrom); mtrace("USERTO ID : " . $userto->id . "\n"); //print_r($userto); } if ($userfrom && $course) { // JF 2011/10/25 if (!isset($userfrom->viewfullnames[$post->id])) { $viewfullnamesfrom = has_capability('moodle/site:viewfullnames', $context, $userfrom->id); } else { $viewfullnamesfrom = $userfrom->viewfullnames[$post->id]; } $fullnamefrom = fullname($userfrom, $viewfullnamesfrom); $by = new object(); $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $userfrom->id . '&course=' . $course->id . '">' . $fullnamefrom . '</a>'; if ($type == TYPE_CERTIFICAT) { if ($post->date_decision) { $by->date = userdate($post->date_decision, "", $userfrom->timezone); } else { $by->date = userdate(time(), "", $userfrom->timezone); } } elseif ($type == TYPE_TACHE) { if ($post->date_modif) { $by->date = userdate($post->date_modif, "", $userto->timezone); } else { $by->date = userdate($post->date_creation, "", $userto->timezone); } } else { if ($post->date_modif) { $by->date = userdate($post->date_modif, "", $userto->timezone); } elseif ($post->date_modif_student) { $by->date = userdate($post->date_modif_student, "", $userto->timezone); } else { $by->date = userdate($post->date_creation, "", $userto->timezone); } } // JF 2011/10/25 // groupes if (isset($userfrom->groups)) { $groups = $userfrom->groups[$post->id]; } else { $groups = groups_get_all_groups($course->id, $userfrom->id); } $groupname = ''; if ($groups) { // mtrace("\n lib.php :: 2038\n"); // print_r($groups); foreach ($groups as $groupe) { // mtrace("\n lib.php :: 2041\n"); // print_r($groupe); if (!empty($groupe->name)) { $groupname .= $groupe->name . ' '; } } } $strbynameondate = get_string('bynameondate', 'referentiel', $by); if (!empty($groupname)) { $strbynameondate .= ' - ' . get_string('groupe', 'referentiel', $groupname); } if (!isset($userto->viewfullnames[$post->id])) { $viewfullnames = has_capability('moodle/site:viewfullnames', $context, $userto->id); } else { $viewfullnames = $userto->viewfullnames[$post->id]; } // format the post body $strreferentiel = get_string('referentiel', 'referentiel') . ' ' . referentiel_get_referentiel_name($post->ref_referentiel); $output = '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">'; $output .= '<tr class="header"><td width="35" valign="top" class="picture left">'; if (!empty($userfrom->id)) { $output .= $OUTPUT->user_picture($userfrom, array('courseid' => $course->id, 'link' => true)); } $output .= '</td>'; $output .= '<td class="topic starter">'; if ($type == TYPE_CERTIFICAT) { $output .= '<div class="subject">' . format_string(get_string('certificat', 'referentiel')) . '</div>'; $output .= '<div class="author">' . $strbynameondate . '</div>'; $output .= '</td></tr>'; $output .= '<tr><td class="left side" valign="top">'; if (isset($userfrom->groups)) { $groups = $userfrom->groups[$post->id]; } else { $group = groups_get_all_groups($course->id, $userfrom->id); } if ($groups) { $output .= print_group_picture($groups, $course->id, false, true, true); } else { $output .= ' '; } $output .= '</td><td class="content">'; $output .= "<hr>\n"; $output .= trusttext_strip("<b>" . get_string('certificat', 'referentiel') . "</b> </i>" . $post->id . "</i>"); $output .= "<br />"; $la_liste_competences = referentiel_digest_competences_certificat($post->competences_certificat, $post->ref_referentiel, true); $output .= trusttext_strip($la_liste_competences); $output .= "<br />\n"; if ($post->decision_jury) { $output .= trusttext_strip(get_string('decision_jury', 'referentiel') . ': ' . $post->decision_jury); if ($post->date_decision) { $output .= ' ' . trusttext_strip(get_string('date_decision', 'referentiel') . ': ' . userdate($post->date_decision)); } $output .= "<br />\n"; } if ($post->teacherid) { $output .= trusttext_strip(get_string('referent', 'referentiel') . ': ' . referentiel_get_user_info($post->teacherid)); if ($post->verrou) { $output .= ' ' . trusttext_strip(get_string('verrou', 'referentiel')); } $output .= "<br />\n"; } if ($post->commentaire_certificat) { $output .= trusttext_strip(get_string('commentaire', 'referentiel') . ': ' . $post->commentaire_certificat); $output .= "<br />\n"; } if ($post->synthese_certificat) { $output .= trusttext_strip(get_string('synthese_certificat', 'referentiel') . ': ' . $post->synthese_certificat); $output .= "<br />\n"; } $output .= "<hr>\n"; // Context link to post if required if ($link) { $output .= '<div class="link">'; $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $post->ref_instance . '&certificat_id=' . $post->id . '">' . get_string('postincontext', 'referentiel') . '</a>'; $output .= '</div>'; } } elseif ($type == TYPE_TACHE) { if (isset($post->auteurid) && $post->auteurid) { $auteur_info = referentiel_get_user_info($post->auteurid); } else { $auteur_info = get_string('un_enseignant', 'referentiel'); } $output .= '<div class="subject">' . format_string($post->type_task) . '</div>'; $output .= '<div class="author">' . $strbynameondate . '</div>'; $output .= '</td></tr>'; $output .= '<tr><td class="left side" valign="top">'; if (isset($userfrom->groups)) { $groups = $userfrom->groups[$post->id]; } else { if (!($cm = get_coursemodule_from_instance('referentiel', $post->ref_instance, $course->id))) { print_error('Course Module ID was incorrect'); } $group = groups_get_all_groups($course->id, $userfrom->id); } if ($groups) { $output .= print_group_picture($groups, $course->id, false, true, true); } else { $output .= ' '; } $output .= '</td><td class="content">'; /* // Plus tard proposer les documents attachés ? if ($post->attachment) { $post->course = $course->id; $output .= '<div class="attachments">'; $output .= forum_print_attachments($post, 'html'); $output .= "</div>"; } */ // $output .= $formattedtext; $output .= "<hr>\n"; $output .= trusttext_strip("<b>" . get_string('task', 'referentiel') . "</b> </i>" . $post->id . "</i>"); $output .= "<br />"; $output .= trusttext_strip(get_string('description', 'referentiel') . ' : ' . $post->description_task); $output .= "<br />"; $output .= trusttext_strip(get_string('certificat_sel_activite_competences', 'referentiel') . ': ' . $post->competences_task); $output .= "<br />\n"; $output .= trusttext_strip(get_string('auteur', 'referentiel') . ': ' . $auteur_info); $output .= "<br />\n"; $output .= trusttext_strip(get_string('date_fin', 'referentiel') . ': ' . userdate($post->date_fin)); $output .= "<br />\n"; if ($post->criteres_evaluation) { $output .= trusttext_strip(get_string('criteres_evaluation', 'referentiel') . ': ' . $post->criteres_evaluation); $output .= "<br />\n"; } if ($post->souscription_libre) { $output .= trusttext_strip(get_string('souscription_libre', 'referentiel')); } if (isset($post->cle_souscription) && $post->cle_souscription != '') { $output .= ' ' . trusttext_strip(get_string('obtenir_cle_souscription', 'referentiel', $auteur_info)); } if (isset($post->tache_masquee) && $post->tache_masquee != 0) { $output .= ' ' . trusttext_strip(get_string('tache_masquee_num', 'referentiel', $post->id)); $output .= "\n"; } $output .= "<br />\n"; $output .= "<hr>\n"; // Context link to post if required if ($link) { $output .= '<div class="link">'; // $output .= '<a target="_blank" href="'.$CFG->wwwroot.'/mod/referentiel/task.php?d='.$post->ref_instance.'&task_id='.$post->id.'&userid='.$post->auteurid.'&mode=listtasksingle">'. $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/referentiel/task.php?d=' . $post->ref_instance . '&task_id=' . $post->id . '">' . get_string('postincontext', 'referentiel') . '</a>'; $output .= '</div>'; } } else { // ACTIVITE $output .= '<div class="subject">' . format_string($post->type_activite) . '</div>'; $output .= '<div class="author">' . $strbynameondate . '</div>'; $output .= '</td></tr>'; $output .= '<tr><td class="left side" valign="top">'; if (isset($userfrom->groups)) { $groups = $userfrom->groups[$post->id]; } else { if (!($cm = get_coursemodule_from_instance('referentiel', $post->ref_instance, $course->id))) { print_error('Course Module ID was incorrect'); } $group = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid); } if ($groups) { $output .= print_group_picture($groups, $course->id, false, true, true); } else { $output .= ' '; } $output .= '</td><td class="content">'; /* // Plus tard proposer les documents attachés ? if ($post->attachment) { $post->course = $course->id; $output .= '<div class="attachments">'; $output .= forum_print_attachments($post, 'html'); $output .= "</div>"; } */ // $output .= $formattedtext; $output .= "<hr>\n"; $output .= trusttext_strip('<b>' . get_string('activite', 'referentiel') . '</b> </i>' . $post->id . '</i>'); $output .= "<br />"; $output .= trusttext_strip('<b>' . get_string('auteur', 'referentiel') . '</b> '); $output .= trusttext_strip(referentiel_get_user_info($post->userid)); $output .= "<br />"; $output .= trusttext_strip('<b>' . get_string('type_activite', 'referentiel') . '</b> : ' . $post->type_activite); $output .= "<br />"; $output .= trusttext_strip('<b>' . get_string('description', 'referentiel') . '</b> : ' . $post->description_activite); $output .= "<br />"; $output .= trusttext_strip('<b>' . get_string('certificat_sel_activite_competences', 'referentiel') . '</b> : ' . $post->competences_activite); $output .= "<br />\n"; if ($post->teacherid) { $output .= trusttext_strip('<b>' . get_string('referent', 'referentiel') . '</b> : ' . referentiel_get_user_info($post->teacherid)); if ($post->approved) { $output .= ' ' . trusttext_strip(get_string('approved', 'referentiel')); } $output .= "<br />\n"; } if ($post->commentaire_activite) { $output .= trusttext_strip('<b>' . get_string('commentaire', 'referentiel') . '</b> : ' . $post->commentaire_activite); $output .= "<br />\n"; } $output .= "<hr>\n"; // Context link to post if required if ($link) { $output .= '<div class="link">'; $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/referentiel/activite.php?d=' . $post->ref_instance . '&activite_id=' . $post->id . '">' . get_string('postincontext', 'referentiel') . '</a>'; $output .= '</div>'; } } if ($footer) { $output .= '<div class="footer">' . $footer . '</div>'; } $output .= '</td></tr></table>' . "\n\n"; } if (REFERENTIEL_DEBUG) { mtrace("\nOUTPUT: \n" . $output . "\n"); } return $output; }
function lightboxgallery_print_comment($comment, $context) { global $CFG, $COURSE; $user = get_record('user', 'id', $comment->userid); echo '<table cellspacing="0" width="50%" class="boxaligncenter datacomment forumpost">'; echo '<tr class="header"><td class="picture left">' . print_user_picture($user, $COURSE->id, $user->picture, 0, true) . '</td>'; echo '<td class="topic starter" align="left"><a name="c' . $comment->id . '"></a><div class="author">'; echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $COURSE->id . '">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</a> - ' . userdate($comment->timemodified); echo '</div></td></tr>'; echo '<tr><td class="left side">'; if ($groups = user_group($COURSE->id, $user->id)) { print_group_picture($groups, $COURSE->id, false, false, true); } else { echo ' '; } echo '</td><td class="content" align="left">'; echo format_text($comment->comment, FORMAT_MOODLE); echo '<div class="commands">'; if (has_capability('mod/lightboxgallery:edit', $context)) { echo '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/comment.php?id=' . $comment->gallery . '&delete=' . $comment->id . '">' . get_string('delete') . '</a>'; } echo '</div>'; echo '</td></tr></table>'; }
/** * Print a specified group's avatar. * * @global object * @uses CONTEXT_COURSE * @param array|stdClass $group A single {@link group} object OR array of groups. * @param int $courseid The course ID. * @param boolean $large Default small picture, or large. * @param boolean $return If false print picture, otherwise return the output as string * @param boolean $link Enclose image in a link to view specified course? * @return string|void Depending on the setting of $return */ function print_group_picture($group, $courseid, $large = false, $return = false, $link = true) { global $CFG; if (is_array($group)) { $output = ''; foreach ($group as $g) { $output .= print_group_picture($g, $courseid, $large, true, $link); } if ($return) { return $output; } else { echo $output; return; } } $context = get_context_instance(CONTEXT_COURSE, $courseid); // If there is no picture, do nothing if (!$group->picture) { return ''; } // If picture is hidden, only show to those with course:managegroups if ($group->hidepicture and !has_capability('moodle/course:managegroups', $context)) { return ''; } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output = '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $courseid . '&group=' . $group->id . '">'; } else { $output = ''; } if ($large) { $file = 'f1'; } else { $file = 'f2'; } $grouppictureurl = moodle_url::make_pluginfile_url($context->id, 'group', 'icon', $group->id, '/', $file); $output .= '<img class="grouppicture" src="' . $grouppictureurl . '"' . ' alt="' . s(get_string('group') . ' ' . $group->name) . '" title="' . s($group->name) . '"/>'; if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output .= '</a>'; } if ($return) { return $output; } else { echo $output; } }
/** * Displays group pictures. This may make a (single) DB query if group * data has not yet been retrieved for this discussion. * @return string Group pictures HTML (empty string if none) for groups * that post author belongs to */ public function display_group_pictures() { $groups = $this->discussion->get_user_groups($this->get_user()->id); if (count($groups) == 0) { return ''; } return print_group_picture($groups, $this->get_forum()->get_course_id(), false, true); }
/** * This function prints the overview of a discussion in the quora listing. * It needs some discussion information and some post information, these * happen to be combined for efficiency in the $post parameter by the function * that calls this one: quora_print_latest_discussions() * * @global object * @global object * @param object $post The post object (passed by reference for speed). * @param object $quora The quora object. * @param int $group Current group. * @param string $datestring Format to use for the dates. * @param boolean $cantrack Is tracking enabled for this quora. * @param boolean $quoratracked Is the user tracking this quora. * @param boolean $canviewparticipants True if user has the viewparticipants permission for this course */ function quora_print_discussion_header(&$post, $quora, $group = -1, $datestring = "", $cantrack = true, $quoratracked = true, $canviewparticipants = true, $modcontext = NULL) { global $COURSE, $USER, $CFG, $OUTPUT; static $rowcount; static $strmarkalldread; if (empty($modcontext)) { if (!($cm = get_coursemodule_from_instance('quora', $quora->id, $quora->course))) { print_error('invalidcoursemodule'); } $modcontext = context_module::instance($cm->id); } if (!isset($rowcount)) { $rowcount = 0; $strmarkalldread = get_string('markalldread', 'quora'); } else { $rowcount = ($rowcount + 1) % 2; } $post->subject = format_string($post->subject, true); echo "\n\n"; echo '<tr class="discussion r' . $rowcount . '">'; // Topic echo '<td class="topic starter">'; echo '<a href="' . $CFG->wwwroot . '/mod/quora/discuss.php?d=' . $post->discussion . '">' . $post->subject . '</a>'; echo "</td>\n"; // Picture $postuser = new stdClass(); $postuserfields = explode(',', user_picture::fields()); $postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields); $postuser->id = $post->userid; echo '<td class="picture">'; echo $OUTPUT->user_picture($postuser, array('courseid' => $quora->course)); echo "</td>\n"; // User name $fullname = fullname($postuser, has_capability('moodle/site:viewfullnames', $modcontext)); echo '<td class="author">'; echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $quora->course . '">' . $fullname . '</a>'; echo "</td>\n"; // Group picture if ($group !== -1) { // Groups are active - group is a group data object or NULL echo '<td class="picture group">'; if (!empty($group->picture) and empty($group->hidepicture)) { if ($canviewparticipants && $COURSE->groupmode) { $picturelink = true; } else { $picturelink = false; } print_group_picture($group, $quora->course, false, false, $picturelink); } else { if (isset($group->id)) { if ($canviewparticipants && $COURSE->groupmode) { echo '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $quora->course . '&group=' . $group->id . '">' . $group->name . '</a>'; } else { echo $group->name; } } } echo "</td>\n"; } if (has_capability('mod/quora:viewdiscussion', $modcontext)) { // Show the column with replies echo '<td class="replies">'; echo '<a href="' . $CFG->wwwroot . '/mod/quora/discuss.php?d=' . $post->discussion . '">'; echo $post->replies . '</a>'; echo "</td>\n"; if ($cantrack) { echo '<td class="replies">'; if ($quoratracked) { if ($post->unread > 0) { echo '<span class="unread">'; echo '<a href="' . $CFG->wwwroot . '/mod/quora/discuss.php?d=' . $post->discussion . '#unread">'; echo $post->unread; echo '</a>'; echo '<a title="' . $strmarkalldread . '" href="' . $CFG->wwwroot . '/mod/quora/markposts.php?f=' . $quora->id . '&d=' . $post->discussion . '&mark=read&returnpage=view.php">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . $strmarkalldread . '" /></a>'; echo '</span>'; } else { echo '<span class="read">'; echo $post->unread; echo '</span>'; } } else { echo '<span class="read">'; echo '-'; echo '</span>'; } echo "</td>\n"; } } echo '<td class="lastpost">'; $usedate = empty($post->timemodified) ? $post->modified : $post->timemodified; // Just in case $parenturl = ''; $usermodified = new stdClass(); $usermodified->id = $post->usermodified; $usermodified = username_load_fields_from_object($usermodified, $post, 'um'); // In QA quoras we check that the user can view participants. if ($quora->type !== 'qanda' || $canviewparticipants) { echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $quora->course . '">' . fullname($usermodified) . '</a><br />'; $parenturl = empty($post->lastpostid) ? '' : '&parent=' . $post->lastpostid; } echo '<a href="' . $CFG->wwwroot . '/mod/quora/discuss.php?d=' . $post->discussion . $parenturl . '">' . userdate($usedate, $datestring) . '</a>'; echo "</td>\n"; // is_guest should be used here as this also checks whether the user is a guest in the current course. // Guests and visitors cannot subscribe - only enrolled users. if (!is_guest($modcontext, $USER) && isloggedin() && has_capability('mod/quora:viewdiscussion', $modcontext)) { // Discussion subscription. if (\mod_quora\subscriptions::is_subscribable($quora)) { echo '<td class="discussionsubscription">'; echo quora_get_discussion_subscription_icon($quora, $post->discussion); echo '</td>'; } } echo "</tr>\n\n"; }
/** * Print a specified group's avatar. * * @param group $group A single {@link group} object OR array of groups. * @param int $courseid The course ID. * @param boolean $large Default small picture, or large. * @param boolean $return If false print picture, otherwise return the output as string * @param boolean $link Enclose image in a link to view specified course? * @return string * @todo Finish documenting this function */ function print_group_picture($group, $courseid, $large = false, $return = false, $link = true) { global $CFG; if (is_array($group)) { $output = ''; foreach ($group as $g) { $output .= print_group_picture($g, $courseid, $large, true, $link); } if ($return) { return $output; } else { echo $output; return; } } $context = get_context_instance(CONTEXT_COURSE, $courseid); if ($group->hidepicture and !has_capability('moodle/course:managegroups', $context)) { return ''; } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output = '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $courseid . '&group=' . $group->id . '">'; } else { $output = ''; } if ($large) { $file = 'f1'; $size = 100; } else { $file = 'f2'; $size = 35; } if ($group->picture) { // Print custom group picture if ($CFG->slasharguments) { // Use this method if possible for better caching $output .= '<img class="grouppicture" src="' . $CFG->wwwroot . '/user/pixgroup.php/' . $group->id . '/' . $file . '.jpg"' . ' style="width:' . $size . 'px;height:' . $size . 'px;" alt="' . s(get_string('group') . ' ' . $group->name) . '" title="' . s($group->name) . '"/>'; } else { $output .= '<img class="grouppicture" src="' . $CFG->wwwroot . '/user/pixgroup.php?file=/' . $group->id . '/' . $file . '.jpg"' . ' style="width:' . $size . 'px;height:' . $size . 'px;" alt="' . s(get_string('group') . ' ' . $group->name) . '" title="' . s($group->name) . '"/>'; } } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output .= '</a>'; } if ($return) { return $output; } else { echo $output; } }
/** * The HTML for a group picture. * * @return string */ public function get_group_picture() { if (isset($this->userfrom->groups)) { $groups = $this->userfrom->groups[$this->forum->id]; } else { $groups = groups_get_all_groups($this->course->id, $this->author->id, $this->cm->groupingid); } if ($this->get_is_firstpost()) { return print_group_picture($groups, $this->course->id, false, true, true); } }
/** * Renders the 'statsinfo' widget - info chart on a blog/post * @param oublog_statsinfo $info * @return string */ public function render_oublog_statsinfo(oublog_statsinfo $info) { global $COURSE, $OUTPUT; $out = ''; // Get the avatar picture for user/group. if (isset($info->user->courseid)) { // Group not user. if (!($userpic = print_group_picture($info->user, $info->user->courseid, true, true, false))) { // No group pic set, use default user image. $userpic = $OUTPUT->pix_icon('u/f2', ''); } } else { $userpic = $this->output->user_picture($info->user, array('courseid' => $COURSE->id, 'link' => false)); } $avatar = html_writer::link($info->url, $userpic, array('class' => 'oublog_statsinfo_avatar')); $infodiv = html_writer::start_div('oublog_statsinfo_infocol'); if ($info->stat) { $infodiv .= html_writer::start_div('oublog_statsinfo_bar'); $infodiv .= html_writer::tag('span', $info->stat, array('class' => 'percent_' . $info->percent)); $infodiv .= html_writer::end_div(); } $infodiv .= html_writer::div($info->label, 'oublog_statsinfo_label'); $infodiv .= html_writer::end_div(); $out = $avatar . $infodiv; return $this->output->container($out, 'oublog_statsinfo'); }
/** * This function prints the overview of a discussion in the anonforum listing. * It needs some discussion information and some post information, these * happen to be combined for efficiency in the $post parameter by the function * that calls this one: anonforum_print_latest_discussions() * * @global object * @global object * @param object $post The post object (passed by reference for speed). * @param object $anonforum The anonforum object. * @param int $group Current group. * @param string $datestring Format to use for the dates. * @param boolean $cantrack Is tracking enabled for this anonforum. * @param boolean $anonforumtracked Is the user tracking this anonforum. * @param boolean $canviewparticipants True if user has the viewparticipants permission for this course */ function anonforum_print_discussion_header(&$post, $anonforum, $group = -1, $datestring = "", $cantrack = true, $anonforumtracked = true, $canviewparticipants = true, $modcontext = NULL) { global $USER, $CFG, $OUTPUT, $DB; static $rowcount; static $strmarkalldread; if (empty($modcontext)) { if (!($cm = get_coursemodule_from_instance('anonforum', $anonforum->id, $anonforum->course))) { print_error('invalidcoursemodule'); } $modcontext = context_module::instance($cm->id); } if (!isset($rowcount)) { $rowcount = 0; $strmarkalldread = get_string('markalldread', 'anonforum'); } else { $rowcount = ($rowcount + 1) % 2; } $post->subject = format_string($post->subject, true); echo "\n\n"; echo '<tr class="discussion r' . $rowcount . '">'; // Topic echo '<td class="topic starter">'; echo '<a href="' . $CFG->wwwroot . '/mod/anonforum/discuss.php?d=' . $post->discussion . '">' . $post->subject . '</a>'; echo "</td>\n"; // Picture $postuser = new stdClass(); if (empty($post->anonymouspost)) { $postuserfields = explode(',', user_picture::fields()); $postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields); $postuser->id = $post->userid; echo '<td class="picture">'; echo $OUTPUT->user_picture($postuser, array('courseid' => $anonforum->course)); echo "</td>\n"; // User name $fullname = fullname($postuser, has_capability('moodle/site:viewfullnames', $modcontext)); echo '<td class="author">'; echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $anonforum->course . '">' . $fullname . '</a>'; echo "</td>\n"; } else { $postuser->id = $post->userid; $postuser->firstname = get_string('anonymoususer', 'anonforum'); $postuser->lastname = ''; $postuser->imagealt = ''; $postuser->picture = ''; $postuser->email = ''; $postuser->firstnamephonetic = ''; $postuser->lastnamephonetic = ''; $postuser->middlename = ''; $postuser->alternatename = ''; echo '<td class="picture">'; echo anon_user_picture($postuser); echo "</td>\n"; echo '<td class="author">'; echo get_string('anonymoususer', 'anonforum'); echo "</td>\n"; } // Group picture if ($group !== -1) { // Groups are active - group is a group data object or NULL echo '<td class="picture group">'; if (!empty($group->picture) and empty($group->hidepicture)) { print_group_picture($group, $anonforum->course, false, false, true); } else { if (isset($group->id)) { if ($canviewparticipants) { echo '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $anonforum->course . '&group=' . $group->id . '">' . $group->name . '</a>'; } else { echo $group->name; } } } echo "</td>\n"; } if (has_capability('mod/anonforum:viewdiscussion', $modcontext)) { // Show the column with replies echo '<td class="replies">'; echo '<a href="' . $CFG->wwwroot . '/mod/anonforum/discuss.php?d=' . $post->discussion . '">'; echo $post->replies . '</a>'; echo "</td>\n"; if ($cantrack) { echo '<td class="replies">'; if ($anonforumtracked) { if ($post->unread > 0) { echo '<span class="unread">'; echo '<a href="' . $CFG->wwwroot . '/mod/anonforum/discuss.php?d=' . $post->discussion . '#unread">'; echo $post->unread; echo '</a>'; echo '<a title="' . $strmarkalldread . '" href="' . $CFG->wwwroot . '/mod/anonforum/markposts.php?f=' . $anonforum->id . '&d=' . $post->discussion . '&mark=read&returnpage=view.php">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . $strmarkalldread . '" /></a>'; echo '</span>'; } else { echo '<span class="read">'; echo $post->unread; echo '</span>'; } } else { echo '<span class="read">'; echo '-'; echo '</span>'; } echo "</td>\n"; } } echo '<td class="lastpost">'; $usedate = empty($post->timemodified) ? $post->modified : $post->timemodified; // Just in case $parenturl = empty($post->lastpostid) ? '' : '&parent=' . $post->lastpostid; $usermodified = new stdClass(); $usermodified->id = $post->usermodified; // In the event of some db error it is better to not show information until we can confirm that we should. $usermodified->firstname = get_string('anonymoususer', 'anonforum'); $usermodified->lastname = ''; $usermodified->link = get_string('anonymoususer', 'anonforum') . '<br />'; // Check if we have a lastpost (or if this is the last post) and if it is not anonymous if (!empty($post->lastpostid)) { $lastpost = $DB->get_record('anonforum_posts', array('id' => $post->lastpostid), 'id, anonymouspost', 'anonymouspost'); if (empty($lastpost->anonymouspost)) { $usermodified->id = $post->usermodified; $usermodified = username_load_fields_from_object($usermodified, $post, 'um'); $usermodified->link = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $anonforum->course . '">' . fullname($usermodified) . '</a><br />'; foreach (get_all_user_name_fields() as $addname) { $temp = 'um' . $addname; $usermodified->{$addname} = $post->{$temp}; } } } else { if (empty($post->lastpostid) && empty($post->anonymouspost)) { $usermodified->id = $post->usermodified; $usermodified = username_load_fields_from_object($usermodified, $post, 'um'); $usermodified->link = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $anonforum->course . '">' . fullname($usermodified) . '</a><br />'; foreach (get_all_user_name_fields() as $addname) { $temp = 'um' . $addname; $usermodified->{$addname} = $post->{$temp}; } } } echo $usermodified->link; echo '<a href="' . $CFG->wwwroot . '/mod/anonforum/discuss.php?d=' . $post->discussion . $parenturl . '">' . userdate($usedate, $datestring) . '</a>'; echo "</td>\n"; echo "</tr>\n\n"; }
/** * This function prints the overview of a discussion in the forum listing. * It needs some discussion information and some post information, these * happen to be combined for efficiency in the $post parameter by the function * that calls this one: forum_print_latest_discussions() * * @global object * @global object * @param object $post The post object (passed by reference for speed). * @param object $forum The forum object. * @param int $group Current group. * @param string $datestring Format to use for the dates. * @param boolean $cantrack Is tracking enabled for this forum. * @param boolean $forumtracked Is the user tracking this forum. * @param boolean $canviewparticipants True if user has the viewparticipants permission for this course * @param boolean $canviewhiddentimedposts True if user has the viewhiddentimedposts permission for this forum */ function forum_print_discussion_header(&$post, $forum, $group = -1, $datestring = "", $cantrack = true, $forumtracked = true, $canviewparticipants = true, $modcontext = null, $canviewhiddentimedposts = false) { global $COURSE, $USER, $CFG, $OUTPUT, $PAGE; static $rowcount; static $strmarkalldread; if (empty($modcontext)) { if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course))) { print_error('invalidcoursemodule'); } $modcontext = context_module::instance($cm->id); } if (!isset($rowcount)) { $rowcount = 0; $strmarkalldread = get_string('markalldread', 'forum'); } else { $rowcount = ($rowcount + 1) % 2; } $post->subject = format_string($post->subject, true); $timeddiscussion = !empty($CFG->forum_enabletimedposts) && ($post->timestart || $post->timeend); $timedoutsidewindow = ''; if ($timeddiscussion && ($post->timestart > time() || $post->timeend != 0 && $post->timeend < time())) { $timedoutsidewindow = ' dimmed_text'; } echo "\n\n"; echo '<tr class="discussion r' . $rowcount . $timedoutsidewindow . '">'; $topicclass = 'topic starter'; if (FORUM_DISCUSSION_PINNED == $post->pinned) { $topicclass .= ' pinned'; } echo '<td class="' . $topicclass . '">'; if (FORUM_DISCUSSION_PINNED == $post->pinned) { echo $OUTPUT->pix_icon('i/pinned', get_string('discussionpinned', 'forum'), 'mod_forum'); } $canalwaysseetimedpost = $USER->id == $post->userid || $canviewhiddentimedposts; if ($timeddiscussion && $canalwaysseetimedpost) { echo $PAGE->get_renderer('mod_forum')->timed_discussion_tooltip($post, empty($timedoutsidewindow)); } echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . $post->subject . '</a>'; echo "</td>\n"; // Picture $postuser = new stdClass(); $postuserfields = explode(',', user_picture::fields()); $postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields); $postuser->id = $post->userid; echo '<td class="picture">'; echo $OUTPUT->user_picture($postuser, array('courseid' => $forum->course)); echo "</td>\n"; // User name $fullname = fullname($postuser, has_capability('moodle/site:viewfullnames', $modcontext)); echo '<td class="author">'; echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $forum->course . '">' . $fullname . '</a>'; echo "</td>\n"; // Group picture if ($group !== -1) { // Groups are active - group is a group data object or NULL echo '<td class="picture group">'; if (!empty($group->picture) and empty($group->hidepicture)) { if ($canviewparticipants && $COURSE->groupmode) { $picturelink = true; } else { $picturelink = false; } print_group_picture($group, $forum->course, false, false, $picturelink); } else { if (isset($group->id)) { if ($canviewparticipants && $COURSE->groupmode) { echo '<a href="' . $CFG->wwwroot . '/user/index.php?id=' . $forum->course . '&group=' . $group->id . '">' . $group->name . '</a>'; } else { echo $group->name; } } } echo "</td>\n"; } if (has_capability('mod/forum:viewdiscussion', $modcontext)) { // Show the column with replies echo '<td class="replies">'; echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">'; echo $post->replies . '</a>'; echo "</td>\n"; if ($cantrack) { echo '<td class="replies">'; if ($forumtracked) { if ($post->unread > 0) { echo '<span class="unread">'; echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#unread">'; echo $post->unread; echo '</a>'; echo '<a title="' . $strmarkalldread . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&d=' . $post->discussion . '&mark=read&returnpage=view.php&sesskey=' . sesskey() . '">' . '<img src="' . $OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="' . $strmarkalldread . '" /></a>'; echo '</span>'; } else { echo '<span class="read">'; echo $post->unread; echo '</span>'; } } else { echo '<span class="read">'; echo '-'; echo '</span>'; } echo "</td>\n"; } } echo '<td class="lastpost">'; $usedate = empty($post->timemodified) ? $post->modified : $post->timemodified; // Just in case $parenturl = ''; $usermodified = new stdClass(); $usermodified->id = $post->usermodified; $usermodified = username_load_fields_from_object($usermodified, $post, 'um'); // In QA forums we check that the user can view participants. if ($forum->type !== 'qanda' || $canviewparticipants) { echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->usermodified . '&course=' . $forum->course . '">' . fullname($usermodified) . '</a><br />'; $parenturl = empty($post->lastpostid) ? '' : '&parent=' . $post->lastpostid; } echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $parenturl . '">' . userdate($usedate, $datestring) . '</a>'; echo "</td>\n"; // is_guest should be used here as this also checks whether the user is a guest in the current course. // Guests and visitors cannot subscribe - only enrolled users. if (!is_guest($modcontext, $USER) && isloggedin() && has_capability('mod/forum:viewdiscussion', $modcontext)) { // Discussion subscription. if (\mod_forum\subscriptions::is_subscribable($forum)) { echo '<td class="discussionsubscription">'; echo forum_get_discussion_subscription_icon($forum, $post->discussion); echo '</td>'; } } echo "</tr>\n\n"; }
/** * This function prints the overview of a discussion in the forum listing. * It needs some discussion information and some post information, these * happen to be combined for efficiency in the $post parameter by the function * that calls this one: forum_print_latest_discussions() * * @global object * @global object * @param object $post The post object (passed by reference for speed). * @param object $forum The forum object. * @param int $group Current group. * @param string $datestring Format to use for the dates. * @param boolean $cantrack Is tracking enabled for this forum. * @param boolean $forumtracked Is the user tracking this forum. * @param boolean $canviewparticipants True if user has the viewparticipants permission for this course */ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring="", $cantrack=true, $forumtracked=true, $canviewparticipants=true, $modcontext=NULL) { global $USER, $CFG, $OUTPUT; static $rowcount; static $strmarkalldread; if (empty($modcontext)) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { print_error('invalidcoursemodule'); } $modcontext = context_module::instance($cm->id); } if (!isset($rowcount)) { $rowcount = 0; $strmarkalldread = get_string('markalldread', 'forum'); } else { $rowcount = ($rowcount + 1) % 2; } $post->subject = format_string($post->subject,true); echo "\n\n"; echo '<tr class="discussion r'.$rowcount.'">'; // Topic echo '<td class="topic starter">'; echo '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'">'.$post->subject.'</a>'; echo "</td>\n"; // Picture $postuser = new stdClass(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; $postuser->email = $post->email; echo '<td class="picture">'; echo $OUTPUT->user_picture($postuser, array('courseid'=>$forum->course)); echo "</td>\n"; // User name $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $modcontext)); echo '<td class="author">'; echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$post->userid.'&course='.$forum->course.'">'.$fullname.'</a>'; echo "</td>\n"; // Group picture if ($group !== -1) { // Groups are active - group is a group data object or NULL echo '<td class="picture group">'; if (!empty($group->picture) and empty($group->hidepicture)) { print_group_picture($group, $forum->course, false, false, true); } else if (isset($group->id)) { if($canviewparticipants) { echo '<a href="'.$CFG->wwwroot.'/user/index.php?id='.$forum->course.'&group='.$group->id.'">'.$group->name.'</a>'; } else { echo $group->name; } } echo "</td>\n"; } if (has_capability('mod/forum:viewdiscussion', $modcontext)) { // Show the column with replies echo '<td class="replies">'; echo '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'">'; echo $post->replies.'</a>'; echo "</td>\n"; if ($cantrack) { echo '<td class="replies">'; if ($forumtracked) { if ($post->unread > 0) { echo '<span class="unread">'; echo '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#unread">'; echo $post->unread; echo '</a>'; echo '<a title="'.$strmarkalldread.'" href="'.$CFG->wwwroot.'/mod/forum/markposts.php?f='. $forum->id.'&d='.$post->discussion.'&mark=read&returnpage=view.php">' . '<img src="'.$OUTPUT->pix_url('t/markasread') . '" class="iconsmall" alt="'.$strmarkalldread.'" /></a>'; echo '</span>'; } else { echo '<span class="read">'; echo $post->unread; echo '</span>'; } } else { echo '<span class="read">'; echo '-'; echo '</span>'; } echo "</td>\n"; } } echo '<td class="lastpost">'; $usedate = (empty($post->timemodified)) ? $post->modified : $post->timemodified; // Just in case $parenturl = (empty($post->lastpostid)) ? '' : '&parent='.$post->lastpostid; $usermodified = new stdClass(); $usermodified->id = $post->usermodified; $usermodified->firstname = $post->umfirstname; $usermodified->lastname = $post->umlastname; echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$post->usermodified.'&course='.$forum->course.'">'. fullname($usermodified).'</a><br />'; echo '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.$parenturl.'">'. userdate($usedate, $datestring).'</a>'; echo "</td>\n"; echo "</tr>\n\n"; }
// conditions haven't been met - reset $mode = MODE_BRIEF; } echo '<td class="right">'; $formatmenu = array('0' => get_string('brief'), '1' => get_string('userdetails')); if ($allowenroldetails) { $formatmenu['2'] = get_string('enroldetails'); } popup_form($baseurl . '&mode=', $formatmenu, 'formatmenu', $mode, '', '', '', false, 'self', get_string('userlist')); echo '</td></tr></table>'; if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group if ($group = groups_get_group($currentgroup)) { if (!empty($group->description) or !empty($group->picture) and empty($group->hidepicture)) { echo '<table class="groupinfobox"><tr><td class="left side picture">'; print_group_picture($group, $course->id, true, false, false); echo '</td><td class="content">'; echo '<h3>' . $group->name; if (has_capability('moodle/course:managegroups', $context)) { echo ' <a title="' . get_string('editgroupprofile') . '" href="' . $CFG->wwwroot . '/group/group.php?id=' . $group->id . '&courseid=' . $group->courseid . '">'; echo '<img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('editgroupprofile') . '" />'; echo '</a>'; } echo '</h3>'; echo format_text($group->description); echo '</td></tr></table>'; } } } /// Define a table showing a list of users in the current role selection $tablecolumns = array('userpic', 'fullname');
function oldgroups_print_user_group_info($currentgroup, $isseparategroups, $courseid) { global $CFG; $context = get_context_instance(CONTEXT_COURSE, $courseid); if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group if ($group = get_record('groups', 'id', $currentgroup)) { if (!empty($group->description) or !empty($group->picture) and empty($group->hidepicture)) { echo '<table class="groupinfobox"><tr><td class="left side picture">'; print_group_picture($group, $course->id, true, false, false); echo '</td><td class="content">'; echo '<h3>' . $group->name; if (has_capability('moodle/site:accessallgroups', $context)) { echo ' <a title="' . get_string('editgroupprofile') . '" href="../course/groups.php?id=' . $course->id . '&group=' . $group->id . '">'; echo '<img src="' . $CFG->pixpath . '/t/edit.gif" alt="" border="0">'; echo '</a>'; } echo '</h3>'; echo format_text($group->description); echo '</td></tr></table>'; } } } }
} elseif ($data = $editform->get_data()) { if ($data->id) { if (!groups_update_group($data, $editform->_upload_manager)) { error('Error updating group'); } } else { if (!($id = groups_create_group($data, $editform->_upload_manager))) { error('Error creating group'); } $returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&group=' . $id; } redirect($returnurl); } $strgroups = get_string('groups'); $strparticipants = get_string('participants'); if ($id) { $strheading = get_string('editgroupsettings', 'group'); } else { $strheading = get_string('creategroup', 'group'); } $navlinks = array(array('name' => $strparticipants, 'link' => $CFG->wwwroot . '/user/index.php?id=' . $courseid, 'type' => 'misc'), array('name' => $strgroups, 'link' => $CFG->wwwroot . '/group/index.php?id=' . $courseid, 'type' => 'misc'), array('name' => $strheading, 'link' => '', 'type' => 'misc')); $navigation = build_navigation($navlinks); /// Print header print_header_simple($strgroups, ': ' . $strgroups, $navigation, '', '', true, '', user_login_string($course) . '<hr style="width:95%">' . navmenu($course)); echo '<div id="grouppicture">'; if ($id) { print_group_picture($group, $course->id); } echo '</div>'; $editform->display(); print_footer($course);
/** * Given the data about a posting, builds up the HTML to display it and * returns the HTML in a string. This is designed for sending via HTML email. * * @global object * @param object $course * @param object $cm * @param object $forum * @param object $discussion * @param object $post * @param object $userform * @param object $userto * @param bool $ownpost * @param bool $reply * @param bool $link * @param bool $rate * @param string $footer * @return string */ function hsuforum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $ownpost = false, $reply = false, $link = false, $rate = false, $footer = "") { global $CFG, $OUTPUT; $modcontext = context_module::instance($cm->id); if (!isset($userto->viewfullnames[$forum->id])) { $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id); } else { $viewfullnames = $userto->viewfullnames[$forum->id]; } $postuser = hsuforum_anonymize_user($userfrom, $forum, $post); // add absolute file links $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_hsuforum', 'post', $post->id); // format the post body $options = new stdClass(); $options->para = true; $formattedtext = format_text($post->message, $post->messageformat, $options, $course->id); $output = '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">'; $output .= '<tr class="header"><td width="35" valign="top" class="picture left">'; $output .= $OUTPUT->user_picture($postuser, array('courseid' => $course->id, 'link' => !hsuforum_is_anonymous_user($postuser))); $output .= '</td>'; if ($post->parent) { $output .= '<td class="topic">'; } else { $output .= '<td class="topic starter">'; } $output .= '<div class="subject">' . format_string($post->subject) . '</div>'; $fullname = fullname($postuser, $viewfullnames); $by = new stdClass(); if (!hsuforum_is_anonymous_user($postuser)) { $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $postuser->id . '&course=' . $course->id . '">' . $fullname . '</a>'; } else { $by->name = $fullname; } $by->date = userdate($post->modified, '', $userto->timezone); $output .= '<div class="author">' . get_string('bynameondate', 'hsuforum', $by) . '</div>'; $output .= '</td></tr>'; $output .= '<tr><td class="left side" valign="top">'; if (isset($userfrom->groups)) { $groups = $userfrom->groups[$forum->id]; } else { $groups = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid); } if ($groups) { $output .= print_group_picture($groups, $course->id, false, true, true); } else { $output .= ' '; } $output .= '</td><td class="content">'; $attachments = hsuforum_print_attachments($post, $cm, 'html'); if ($attachments !== '') { $output .= '<div class="attachments">'; $output .= $attachments; $output .= '</div>'; } $output .= $formattedtext; // Commands $commands = array(); if ($post->parent) { $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/hsuforum/discuss.php?d=' . $post->discussion . '&parent=' . $post->parent . '">' . get_string('parent', 'hsuforum') . '</a>'; } if ($reply) { $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/hsuforum/post.php?reply=' . $post->id . '">' . get_string('reply', 'hsuforum') . '</a>'; } $output .= '<div class="commands">'; $output .= implode(' | ', $commands); $output .= '</div>'; // Context link to post if required if ($link) { $output .= '<div class="link">'; $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/hsuforum/discuss.php?d=' . $post->discussion . '#p' . $post->id . '">' . get_string('postincontext', 'hsuforum') . '</a>'; $output .= '</div>'; } if ($footer) { $output .= '<div class="footer">' . $footer . '</div>'; } $output .= '</td></tr></table>' . "\n\n"; return $output; }
$select = new single_select($baseurl, 'mode', $formatmenu, $mode, null, 'formatmenu'); $select->set_label(get_string('userlist')); $userlistcell = new html_table_cell(); $userlistcell->attributes['class'] = 'right'; $userlistcell->text = $OUTPUT->render($select); $controlstable->data[0]->cells[] = $userlistcell; echo html_writer::table($controlstable); if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { // Display info about the group. if ($group = groups_get_group($currentgroup)) { if (!empty($group->description) or !empty($group->picture) and empty($group->hidepicture)) { $groupinfotable = new html_table(); $groupinfotable->attributes['class'] = 'groupinfobox'; $picturecell = new html_table_cell(); $picturecell->attributes['class'] = 'left side picture'; $picturecell->text = print_group_picture($group, $course->id, true, true, false); $contentcell = new html_table_cell(); $contentcell->attributes['class'] = 'content'; $contentheading = $group->name; if (has_capability('moodle/course:managegroups', $context)) { $aurl = new moodle_url('/group/group.php', array('id' => $group->id, 'courseid' => $group->courseid)); $contentheading .= ' ' . $OUTPUT->action_icon($aurl, new pix_icon('t/edit', get_string('editgroupprofile'))); } $group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id); if (!isset($group->descriptionformat)) { $group->descriptionformat = FORMAT_MOODLE; } $options = array('overflowdiv' => true); $formatteddesc = format_text($group->description, $group->descriptionformat, $options); $contentcell->text = $OUTPUT->heading($contentheading, 3) . $formatteddesc; $groupinfotable->data[] = new html_table_row(array($picturecell, $contentcell));
/** * @param user object * return HTML code to show user picture * @return String */ function user_picture($user) { global $OUTPUT; if ($this->is_group_activity()) { return print_group_picture($this->get_usergroup($user->id), $this->get_course()->id, false, true); } else { return $OUTPUT->user_picture($user); } }