/** * This function is in lib and not in BlogInfo because entries being searched * might be found in any number of blogs rather than just one. * * $@param ... */ function blog_print_html_formatted_entries($postid, $filtertype, $filterselect, $tagid, $tag) { global $CFG, $USER; $blogpage = optional_param('blogpage', 0, PARAM_INT); $bloglimit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT); $start = $blogpage * $bloglimit; $sitecontext = get_context_instance(CONTEXT_SYSTEM); $morelink = '<br /> '; $totalentries = get_viewable_entry_count($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC'); $blogEntries = blog_fetch_entries($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC', true); print_paging_bar($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect), 'blogpage'); if ($CFG->enablerssfeeds) { blog_rss_print_link($filtertype, $filterselect, $tag); } if (has_capability('moodle/blog:create', $sitecontext)) { //the user's blog is enabled and they are viewing their own blog $addlink = '<div class="addbloglink">'; $addlink .= '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=add' . '">' . get_string('addnewentry', 'blog') . '</a>'; $addlink .= '</div>'; echo $addlink; } if ($blogEntries) { $count = 0; foreach ($blogEntries as $blogEntry) { blog_print_entry($blogEntry, 'list', $filtertype, $filterselect); //print this entry. $count++; } print_paging_bar($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect), 'blogpage'); if (!$count) { print '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />'; } print $morelink . '<br />' . "\n"; return; } $output = '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />'; print $output; }
$columndir = 'DESC'; } else { $columndir = 'ASC'; } } else { $columndir = $dir == 'ASC' ? 'DESC' : 'ASC'; if ($column == 'lastaccess') { $columnicon = $dir == 'ASC' ? 'up' : 'down'; } else { $columnicon = $dir == 'ASC' ? 'down' : 'up'; } $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } $hcolumns[$column] = "<a href=\"index.php?sort={$column}&dir={$columndir}&page={$page}&perpage={$perpage}\">" . $strcolumn . "</a>{$columnicon}"; } print_paging_bar($changescount, $page, $perpage, "index.php?sort={$sort}&dir={$dir}&perpage={$perpage}&"); $override = new object(); $override->firstname = 'firstname'; $override->lastname = 'lastname'; $fullnamelanguage = get_string('fullnamedisplay', '', $override); if ($CFG->fullnamedisplay == 'firstname lastname' or $CFG->fullnamedisplay == 'firstname' or $CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname') { $fullnamedisplay = $hcolumns['firstname'] . ' / ' . $hcolumns['lastname']; } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname') $fullnamedisplay = $hcolumns['lastname'] . ' / ' . $hcolumns['firstname']; } $table = new object(); $table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']); $table->align = array('left', 'left', 'left', 'left', 'left', 'left'); $table->size = array('30%', '10%', '10%', '10%', '20%', '20%'); $table->width = '95%';
if (!empty($studentsperpage)) { print_paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl); } $reporthtml = '<script src="functions.js" type="text/javascript"></script>'; $reporthtml .= '<table id="user-grades" class="gradestable flexible boxaligncenter generaltable">'; $reporthtml .= $report->get_headerhtml(); $reporthtml .= $report->get_iconshtml(); $reporthtml .= $report->get_rangehtml(); $reporthtml .= $report->get_studentshtml(); $reporthtml .= $report->get_avghtml(true); $reporthtml .= $report->get_avghtml(); $reporthtml .= "</table>"; // print submit button if ($USER->gradeediting[$course->id]) { echo '<form action="index.php" method="post">'; echo '<div>'; echo '<input type="hidden" value="' . $courseid . '" name="id" />'; echo '<input type="hidden" value="' . sesskey() . '" name="sesskey" />'; echo '<input type="hidden" value="grader" name="report"/>'; } echo $reporthtml; // print submit button if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) { echo '<div class="submit"><input type="submit" value="' . get_string('update') . '" /></div>'; echo '</div></form>'; } // prints paging bar at bottom for large pages if (!empty($studentsperpage) && $studentsperpage >= 20) { print_paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl); } print_footer($course);
/** * This function is not part of the public api. */ function start_html() { global $OUTPUT, $CFG; // Do we need to print initial bars? $this->print_initials_bar(); // Paging bar if ($this->use_pages) { // disable debugging for this function call $debug = $CFG->debug; $CFG->debug = false; print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[ILP_TABLE_VAR_PAGE]); $CFG->debug = $debug; } if (in_array(ILP_TABLE_P_TOP, $this->showdownloadbuttonsat)) { echo $this->download_buttons(); } $this->wrap_html_start(); // Start of main data table echo '<table' . $this->make_attributes_string($this->attributes) . '>'; }
/** * Prints the '1 2 3 ...' paging bar for when a query set is split across multiple pages. * @param $numitems total number of items in the query set */ function print_paging_bar($numitems) { // TODO: take a queryset as an argument rather than the number of items $sort = optional_param('sort', '', PARAM_ALPHA); $dir = optional_param('dir', '', PARAM_ALPHA); $locsearch = trim(optional_param('locsearch', '', PARAM_TEXT)); $namesearch = trim(optional_param('search', '', PARAM_TEXT)); $alpha = optional_param('alpha', '', PARAM_ALPHA); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 30, PARAM_INT); $params = array('search' => stripslashes($namesearch), 'locsearch' => stripslashes($locsearch), 'alpha' => $alpha, 'perpage' => $perpage); //add the parent cluster id as a parameter //(0 will signal no that there is no parent cluster) $params['id'] = $this->optional_param('id', 0, PARAM_INT); if (!empty($sort)) { $params['sort'] = $sort; } if (!empty($sort)) { $params['dir'] = $dir; } $target = $this->get_new_page($params); print_paging_bar($numitems, $page, $perpage, $target->get_url() . '&'); }
/// Print out all the courses unset($course); // To avoid unwanted language effects later $courses = get_courses_page($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible,c.teacher,c.guest,c.password', $totalcount, $page * $perpage, $perpage); $numcourses = count($courses); if (!$courses) { if (empty($subcategorieswereshown)) { print_heading(get_string("nocoursesyet")); } } else { if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$creatorediting) { print_box_start('courseboxes'); print_courses($category); print_box_end(); } else { print_paging_bar($totalcount, $page, $perpage, "category.php?id={$category->id}&perpage={$perpage}&"); $strcourses = get_string("courses"); $strselect = get_string("select"); $stredit = get_string("edit"); $strdelete = get_string("delete"); $strbackup = get_string("backup"); $strrestore = get_string("restore"); $strmoveup = get_string("moveup"); $strmovedown = get_string("movedown"); $strupdate = get_string("update"); $strhide = get_string("hide"); $strshow = get_string("show"); $strsummary = get_string("summary"); $strsettings = get_string("settings"); $strassignteachers = get_string("assignteachers"); $strallowguests = get_string("allowguests");
/** * * @global <type> $CFG */ function action_default() { global $CFG; $clsid = $this->required_param('id', PARAM_INT); $sort = $this->optional_param('sort', 'name', PARAM_ALPHANUM); $dir = $this->optional_param('dir', 'ASC', PARAM_ALPHA); $page = $this->optional_param('page', 0, PARAM_INT); $perpage = $this->optional_param('perpage', 30, PARAM_INT); // how many per page $namesearch = trim($this->optional_param('search', '', PARAM_TEXT)); $alpha = $this->optional_param('alpha', '', PARAM_ALPHA); $cls = new cmclass($clsid); $columns = array('idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('student_name_1', 'block_curr_admin'), 'enrolmenttime' => get_string('enrolment_time', 'block_curr_admin'), 'completetime' => get_string('completion_time', 'block_curr_admin'), 'completestatusid' => get_string('student_status', 'block_curr_admin'), 'grade' => get_string('student_grade', 'block_curr_admin'), 'credits' => get_string('student_credits', 'block_curr_admin'), 'locked' => get_string('student_locked', 'block_curr_admin'), 'buttons' => ''); $stus = student::get_listing($clsid, $sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $numstus = student::count_records($clsid, $namesearch, $alpha); $this->print_num_items($clsid, $cls->maxstudents); $this->print_alpha(); $this->print_search(); $this->print_list_view($stus, $columns, array(), 'users'); // TBD: students ? print_paging_bar($numstus, $page, $perpage, "index.php?s=stu&section=curr&id={$clsid}&sort={$sort}&" . "dir={$dir}&perpage={$perpage}&alpha={$alpha}&namesearch=" . urlencode(stripslashes($namesearch)) . "&"); echo "<form>"; // TODO: pass in query parameters if ($this->can_do('bulkedit')) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=bulkedit&id={$clsid}&sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&search=" . urlencode(stripslashes($namesearch)) . "';\" value=\"Bulk Edit\" />"; } if ($this->can_do('add')) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=add&id={$clsid}';\" value=\"" . get_string('enrolstudents', 'block_curr_admin') . "\" />"; } echo "</form>"; }
} $cms[$forum->id] = $cm; unset($cm); // do not use cm directly, it would break caching } $fullsubject = "<a href=\"view.php?f={$forum->id}\">" . format_string($forum->name, true) . "</a>"; if ($forum->type != 'single') { $fullsubject .= " -> <a href=\"discuss.php?d={$discussion->id}\">" . format_string($discussion->name, true) . "</a>"; if ($post->parent != 0) { $fullsubject .= " -> <a href=\"discuss.php?d={$post->discussion}&parent={$post->id}\">" . format_string($post->subject, true) . "</a>"; } } if ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) { $postcoursename = get_field('course', 'shortname', 'id', $forum->course); $fullsubject = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $forum->course . '">' . $postcoursename . '</a> -> ' . $fullsubject; } $post->subject = $fullsubject; $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; forum_print_post($post, $discussion, $forum, $cms[$forum->id], $course, false, false, false, $ratings, $fulllink); echo "<br />"; } print_paging_bar($totalcount, $page, $perpage, "user.php?id={$user->id}&course={$course->id}&mode={$mode}&perpage={$perpage}&"); } else { if ($mode == 'posts') { print_heading(get_string('noposts', 'forum')); } else { print_heading(get_string('nodiscussionsstartedby', 'forum')); } } echo '</div>'; print_footer($course);
} // checks whether user can do restore if (has_capability('moodle/site:restore', $coursecontext)) { echo "<a title=\"" . get_string("restore") . "\" href=\"../files/index.php?id={$course->id}&wdir=/backupdata\">\n<img" . " src=\"{$pixpath}/t/restore.gif\" class=\"iconsmall\" alt=\"" . get_string("restore") . "\" /></a>\n "; } echo "</td>\n</tr>\n"; } echo "<tr>\n<td colspan=\"4\" style=\"text-align:center\">\n"; echo "<br />"; echo "<input type=\"button\" onclick=\"checkall()\" value=\"{$strselectall}\" />\n"; echo "<input type=\"button\" onclick=\"uncheckall()\" value=\"{$strdeselectall}\" />\n"; choose_from_menu($displaylist, "moveto", "", get_string("moveselectedcoursesto"), "javascript: getElementById('movecourses').submit()"); echo "</td>\n</tr>\n"; echo "</table>\n</form>"; } print_paging_bar($totalcount, $page, $perpage, "search.php?search={$encodedsearch}&perpage={$perpage}&", 'page', $perpage == 99999); if ($perpage != 99999 && $totalcount > $perpage) { echo "<center><p>"; echo "<a href=\"search.php?search={$encodedsearch}&perpage=99999\">" . get_string("showall", "", $totalcount) . "</a>"; echo "</p></center>"; } } else { if (!empty($search)) { print_heading(get_string("nocoursesfound", "", s($search, true))); } else { print_heading($strnovalidcourses); } } echo "<br /><br />"; print_course_search($search); print_footer();
$link1 = "<a href=\"{$CFG->wwwroot}/mod/metadatadc/view.php?id={$cmdc->id}\">{$metadatadc->name}</a>"; $link2 = "<a href=\"{$CFG->wwwroot}/mod/" . $modlo[$metadatadc->resource] . "/view.php?id=" . $metadatadc->resource . "\">" . $namelo[$metadatadc->resource] . " (" . $modlo[$metadatadc->resource] . ")</a>"; $link3 = $metadatadc->description; // } $table->data[] = array($link0, $link1, $link2, $link3); } echo "<br />"; print_heading(get_string("modulenameplural", "metadatadc")); print_table($table); } ////////// $totalcount = $totalcountlom + $totalcountdc; echo "<hr><div align='center'>"; echo "{$strsearchresults} (LOM + DCMES): {$totalcountlom} + {$totalcountdc} = {$totalcount}"; echo "</div><hr>"; print_paging_bar($totalcount, $page, $perpage, "search_allmetadata.php?search=" . urlencode(stripslashes($search)) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); ///////////////FUNCTIONS function allmetadata_clean_search_terms($words, $prefix = '') { $searchterms = explode(' ', $words); foreach ($searchterms as $key => $searchterm) { if (strlen($searchterm) < 2) { unset($searchterms[$key]); } else { if ($prefix) { $searchterms[$key] = $prefix . $searchterm; } } } return trim(implode(' ', $searchterms));
function print_table() { $table = new stdClass(); $table->head = $this->setup_table(); // Make sure that student is in the sql // $this->keys[0] = 'student'; $where = $this->build_where(); $referral_total = count_records_sql("SELECT COUNT(ref.id) {$where}"); if (empty($referral_total)) { echo '<span class="error">' . get_string('no_referrals', 'block_student_gradeviewer') . '<span>'; return false; } echo '<div style="width: 100%; text-align:center;"> Found: ' . $referral_total . ' </div>'; $bar = print_paging_bar($referral_total, $this->page, $this->per_page, $this->baseurl, 'page', false, true); $show_all = ''; if (!empty($bar)) { $show_all = '<div class="show_all_referrals"> <a href="' . $this->baseurl . 'per_page=10000">' . get_string('showall') . '(' . $referral_total . ')</a> </div>'; } $referrals = $this->referral_process(); //$this->perform_prune(); $table->data = array_map(array($this, 'map_referral'), $referrals); echo $bar; print_table($table); echo $bar . $show_all; return true; }
} else { echo "<span> </span>"; } echo "<span class=spanimage>" . print_user_picture($use->id, $COURSE->id, $use->picture, 24, true, true) . "</span>"; echo "<span class=spantext>"; $remove_br = $expense->data; $bodytag = str_replace("<br>", "", $remove_br); $bodytag = str_replace("<br>", "", $remove_br); $slashes_remove = stripslashes($bodytag); echo "<span id=change_message" . $expense->id . ">" . $slashes_remove . "</span></span>"; $date_explode = $expense->date; $date_format = explode(" ", $date_explode); echo "<span class=spanright> <a href=" . $CFG->wwwroot . "/user/view.php?id=" . $use->id . "&course=" . $course_id . ">" . $fullname . "</a><br>" . $date_format[0] . ' ' . $date_format[1] . ' ' . $date_format[3] . ' ' . $date_format[4] . " "; if (has_capability('block/shoutbox:editownmessage', $context)) { if (has_capability('block/shoutbox:editallmessage', $context)) { echo "<a onClick=edit_shoutbox_message({$expense->id}) id=editid" . $expense->id . " class=edit_class >" . get_string('edit', 'block_shoutbox') . "</a>"; } else { if ($USER->id == $expense->user_id) { echo "<a onClick=edit_shoutbox_message({$expense->id}) id=editid" . $expense->id . " class=edit_class >" . get_string('edit', 'block_shoutbox') . "</a>"; } } } echo "</span><input name=hidden_data type=hidden value=" . $CFG->wwwroot . " id=hidden_data ><input name=insertion_block_c_id type=hidden value=" . $course_id . " id=insertion_block_c_id >"; echo "</div>"; $i++; } } echo "<input name=blockid type=hidden value=" . $block_id . " id=blockid_course >"; echo "</form></div>"; echo "<div class=paging style=display:none>" . print_paging_bar($count_records, $page, $perpage, "pop_window.php?course_id={$block_id}&submit=0&perpage={$perpage}&orderby={$orderby}&ordertype={$order_type}&") . "</div>";
/** * Return the HTML to for a view page that also allows editing. * * @return string The form HTML, without the form. */ function view_form_html($classid, $type = '', $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 0, $namesearch = '', $alpha = '') { global $CURMAN, $CFG; $output = ''; ob_start(); $table = new stdClass(); $can_unenrol = cmclasspage::can_enrol_into_class($classid); if (empty($this->id)) { $columns = array('unenrol' => get_string('unenrol', 'block_curr_admin'), 'idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('student_name_1', 'block_curr_admin'), 'enrolmenttime' => get_string('enrolment_time', 'block_curr_admin'), 'completetime' => get_string('completion_time', 'block_curr_admin'), 'completestatusid' => get_string('student_status', 'block_curr_admin'), 'grade' => get_string('student_grade', 'block_curr_admin'), 'credits' => get_string('student_credits', 'block_curr_admin'), 'locked' => get_string('student_locked', 'block_curr_admin')); if (!$can_unenrol) { unset($columns['unenrol']); } } else { $columns = array('idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('student_name_1', 'block_curr_admin'), 'enrolmenttime' => get_string('enrolment_time', 'block_curr_admin'), 'completetime' => get_string('completion_time', 'block_curr_admin'), 'completestatusid' => get_string('student_status', 'block_curr_admin'), 'grade' => get_string('student_grade', 'block_curr_admin'), 'credits' => get_string('student_credits', 'block_curr_admin'), 'locked' => get_string('student_locked', 'block_curr_admin')); } foreach ($columns as $column => $cdesc) { if ($sort != $column) { $columnicon = ""; $columndir = "ASC"; } else { $columndir = $dir == "ASC" ? "DESC" : "ASC"; $columnicon = $dir == "ASC" ? "down" : "up"; $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } if ($column != 'unenrol') { ${$column} = "<a href=\"index.php?s=stu&section=curr&id={$classid}&class={$classid}&" . "action=bulkedit&sort={$column}&dir={$columndir}&stype={$type}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } if (empty($this->id)) { $users = $this->get_users_enrolled($type, $sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $usercount = $this->count_users_enrolled($type, $namesearch, $alpha); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Bar of first initials echo "<p style=\"text-align:center\">"; echo "Last Name : "; if ($alpha) { echo " <a href=\"index.php?s=stu&section=curr&action=bulkedit&id={$classid}&class={$classid}&" . "sort=name&dir=ASC&perpage={$perpage}\">{$strall}</a> "; } else { echo " <b>{$strall}</b> "; } foreach ($alphabet as $letter) { if ($letter == $alpha) { echo " <b>{$letter}</b> "; } else { echo " <a href=\"index.php?s=stu&section=curr&action=bulkedit&id={$classid}&class={$classid}&" . "action=bulkedit&sort=name&dir=ASC&perpage={$perpage}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($usercount, $page, $perpage, "index.php?s=stu&section=curr&id={$classid}&class={$classid}&&action=bulkedit&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&stype={$type}" . "&search=" . urlencode(stripslashes($namesearch)) . "&"); flush(); } else { $user = $this->user; $user->name = cm_fullname($user); $users[] = $user; $usercount = 0; } if (empty($this->id) && !$users) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = "name: {$alpha}___"; } $matchstring = implode(", ", $match); echo 'No users matching ' . $matchstring; $table = NULL; } else { $stuobj = new student(); $table->width = "100%"; foreach ($users as $user) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'unenrol': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][unenrol]" value="1" />'; break; case 'name': case 'idnumber': case 'description': $newarr[] = $user->{$column}; break; case 'enrolmenttime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $user->enrolmenttime, true); break; case 'completetime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $user->completetime, true); break; case 'completestatusid': $choices = array(); foreach (student::$completestatusid_values as $key => $csidv) { $choices[$key] = get_string($csidv, 'block_curr_admin'); } $newarr[] = cm_choose_from_menu($choices, 'users[' . $user->id . '][completestatusid]', $user->completestatusid, '', '', '', true); break; case 'grade': $newarr[] = '<input type="text" name="users[' . $user->id . '][grade]" ' . 'value="' . $user->grade . '" size="5" />'; break; case 'credits': $newarr[] = '<input type="text" name="users[' . $user->id . '][credits]" ' . 'value="' . $user->credits . '" size="5" />'; break; case 'locked': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][locked]" ' . 'value="1" ' . ($user->locked ? 'checked="checked"' : '') . '/>' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />' . '<input type="hidden" name="users[' . $user->id . '][association_id]" ' . 'value="' . $user->association_id . '" />'; break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } } if (empty($this->id)) { echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset>"; echo '<input type="hidden" name="s" value="stu" />'; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="action" value="bulkedit" />'; echo '<input type="hidden" name="id" value="' . $classid . '" />'; echo '<input type="hidden" name="sort" value="' . $sort . '" />'; echo '<input type="hidden" name="dir" value="' . $dir . '" />'; /*echo '<input type="radio" name="stype" value="student" ' . (($type == 'student') ? ' checked' : '') . '/> Students ' . '<input type="radio" name="stype" value="instructor" ' . (($type == 'instructor') ? ' checked' : '') . '/> Instructors ' . '<input type="radio" name="stype" vale="" ' . (($type == '') ? ' checked' : '') . '/> All ';*/ echo "<input type=\"text\" name=\"search\" value=\"" . s($namesearch, true) . "\" size=\"20\" />"; echo "<input type=\"submit\" value=\"" . get_string('search', 'block_curr_admin') . "\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=bulkedit&id={$classid}';\" value=\"" . get_string('show_all_users', 'block_curr_admin') . "\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; echo '<form method="post" action="index.php?s=stu&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="updatemultiple" />' . "\n"; } else { echo '<form method="post" action="index.php?s=stu&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="updatemultiple" />' . "\n"; echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n"; echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n"; echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n"; } if (!empty($table)) { if (empty($this->id)) { require_js($CFG->wwwroot . '/curriculum/js/classform.js'); echo '<span class="checkbox selectall">'; echo '<input type="checkbox" onclick="class_bulkedit_set_all_selected()" id="class_bulkedit_select_all" name="class_bulkedit_select_all"/>'; echo '<label for="class_bulkedit_select_all">' . get_string('bulkedit_select_all', 'block_curr_admin') . '</label>'; echo '</span>'; } print_table($table); } if (isset($this->cmclass->course) && is_object($this->cmclass->course) && get_class($this->cmclass->course) == 'course' && ($elements = $this->cmclass->course->get_completion_elements())) { $select = "classid = {$this->classid} AND userid = {$this->userid}"; $grades = $CURMAN->db->get_records_select(CLSGRTABLE, $select, 'id', 'completionid,id,classid,userid,grade,locked,timegraded,timemodified'); $table = new stdClass(); $columns = array('element' => 'Grade Element', 'grade' => 'Grade', 'locked' => 'Locked', 'timegraded' => 'Date Graded'); foreach ($columns as $column => $cdesc) { if ($sort != $column) { $columnicon = ""; $columndir = "ASC"; } else { $columndir = $dir == "ASC" ? "DESC" : "ASC"; $columnicon = $dir == "ASC" ? "down" : "up"; $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } if ($column == 'name' || $column == 'description') { ${$column} = "<a href=\"index.php?s=stu&section=curr&id={$classid}&class={$classid}&" . "action=default&sort={$column}&dir={$columndir}&stype={$type}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } $table->width = "100%"; foreach ($elements as $element) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'element': if (isset($grades[$element->id])) { $name = 'element[' . $grades[$element->id]->id . ']'; $value = $element->id; } else { $name = 'newelement[' . $element->id . ']'; $value = $element->id; } $newarr[] = '<input type="hidden" name="' . $name . '" ' . 'value="' . $value . '" />' . s($element->idnumber); break; case 'timegraded': if (isset($grades[$element->id])) { $name = 'timegraded[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->timegraded; } else { $name = 'newtimegraded[' . $element->id . ']'; $value = 0; } $newarr[] = cm_print_date_selector($name . '[startday]', $name . '[startmonth]', $name . '[startyear]', $value, true); break; case 'grade': if (isset($grades[$element->id])) { $name = 'grade[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->grade; } else { $name = 'newgrade[' . $element->id . ']'; $value = 0; } $newarr[] = '<input type="text" name="' . $name . '" ' . 'value="' . $value . '" size="5" />'; break; case 'locked': if (isset($grades[$element->id])) { $name = 'locked[' . $grades[$element->id]->id . ']'; $value = $grades[$element->id]->locked; } else { $name = 'newlocked[' . $element->id . ']'; $value = 0; } $newarr[] = '<input type="checkbox" name="' . $name . '" ' . 'value="1" ' . ($value ? 'checked="checked"' : '') . '/>'; break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } if (!empty($table)) { echo '<br />'; print_table($table); } } if (!empty($users)) { echo '<br /><input type="submit" value="' . get_string('save_enrolment_changes', 'block_curr_admin') . '">' . "\n"; } echo "<input type=\"button\" onclick=\"document.location='index.php?s=stu&section=curr&" . "action=default&id={$classid}&sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&search=" . urlencode(stripslashes($namesearch)) . "';\" value=\"Cancel\" />"; echo '</form>' . "\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
$imageextra .= '</select></form>'; } else { if ($gallery->extinfo) { $iobj = lightboxgallery_image_info($imagelocal); $imageextra = sprintf('<br />%s<br />%s, %dx%d', $iobj->modified, $iobj->filesize, $iobj->imagesize[0], $iobj->imagesize[1]); } } $imagetitle = isset($captions[$image]) ? $captions[$image] : $image; echo '<div class="lightboxgalleryimage" style="float:right;padding:7px;"><a href="' . $imageurl . '" rel="lightbox[' . $gallery->name . ']" title="' . $imagetitle . '">' . lightboxgallery_image_thumbnail($course->id, $gallery, $image) . '</a><br />' . $imagelabel . $imageextra . '</div>'; } } else { print_string('errornoimages', 'lightboxgallery'); } print_simple_box_end(); if ($gallery->perpage) { print_paging_bar(count($allimages), $page, $gallery->perpage, $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id . '&' . ($editing ? 'editing=1&' : '')); } $showtags = !in_array('tag', explode(',', get_config('lightboxgallery', 'disabledplugins'))); if (!$editing && $showtags) { $sql = 'SELECT description FROM ' . $CFG->prefix . 'lightboxgallery_image_meta WHERE gallery = ' . $gallery->id . ' AND metatype = \'tag\' GROUP BY description ORDER BY COUNT(description) DESC, description ASC'; if ($tags = get_records_sql($sql, 0, 10)) { lightboxgallery_print_tags(get_string('tagspopular', 'lightboxgallery'), $tags, $course->id, $gallery->id); } } $options = array(); if ($gallery->folder && has_capability('mod/lightboxgallery:addimage', $context)) {
echo get_string('hidelocal', 'mnet') . ' | '; } if ($localusers == 1 && $remoteusers == 1) { echo '<a href="?ru=0">' . get_string('hideremote', 'mnet') . '</a>'; } elseif ($remoteusers == 0) { echo '<a href="?ru=1">' . get_string('showremote', 'mnet') . '</a>'; } else { echo get_string('hideremote', 'mnet'); } echo "</p>"; } echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"user.php\" method=\"get\"><fieldset class=\"invisiblefieldset\">"; echo "<input type=\"text\" name=\"search\" value=\"" . s($search, true) . "\" size=\"20\" />"; echo "<input type=\"submit\" value=\"{$strsearch}\" />"; if ($search) { echo "<input type=\"button\" onclick=\"document.location='user.php';\" value=\"{$strshowallusers}\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; if (has_capability('moodle/user:create', $sitecontext)) { print_heading('<a href="' . $securewwwroot . '/user/editadvanced.php?id=-1">' . get_string('addnewuser') . '</a>'); } if (!empty($table)) { print_table($table); print_paging_bar($usercount, $page, $perpage, "user.php?sort={$sort}&dir={$dir}&perpage={$perpage}" . "&firstinitial={$firstinitial}&lastinitial={$lastinitial}&search=" . urlencode(stripslashes($search)) . "&"); if (has_capability('moodle/user:create', $sitecontext)) { print_heading('<a href="' . $securewwwroot . '/user/editadvanced.php?id=-1">' . get_string('addnewuser') . '</a>'); } } admin_externalpage_print_footer($adminroot);
/** * Return the HTML to edit a specific instructor. * This could be extended to allow for application specific editing, for example * a Moodle interface to its formslib. * * @param $formid string A suffix to put on all 'id' and index for all 'name' attributes. * This should be unique if being used more than once in a form. * @param $extraclass string Any extra class information to add to the output. * * @return string The form HTML, without the form. */ function edit_form_html($classid, $sort = 'name', $dir = 'ASC', $page = 0, $perpage = 0, $namesearch = '', $alpha = '') { global $CFG; $output = ''; ob_start(); $table = new stdClass(); if (empty($this->id)) { $columns = array('assign' => 'Assign', 'idnumber' => 'ID Number', 'name' => 'Name', 'assigntime' => 'Assigned Time', 'completetime' => 'Completion Time'); } else { $columns = array('idnumber' => 'ID Number', 'name' => 'Name', 'assigntime' => 'Assigned Time', 'completetime' => 'Completion Time'); } foreach ($columns as $column => $cdesc) { if ($sort != $column) { $columnicon = ""; $columndir = "ASC"; } else { $columndir = $dir == "ASC" ? "DESC" : "ASC"; $columnicon = $dir == "ASC" ? "down" : "up"; $columnicon = " <img src=\"{$CFG->pixpath}/t/{$columnicon}.gif\" alt=\"\" />"; } if ($column == 'name' || $column == 'description') { ${$column} = "<a href=\"index.php?s=ins&section=curr&id={$classid}&" . "action=add&sort={$column}&dir={$columndir}&search=" . urlencode(stripslashes($namesearch)) . "&alpha={$alpha}\">" . $cdesc . "</a>{$columnicon}"; } else { ${$column} = $cdesc; } $table->head[] = ${$column}; $table->align[] = "left"; $table->wrap[] = true; } if (empty($this->id)) { $users = $this->get_users_avail($sort, $dir, $page * $perpage, $perpage, $namesearch, $alpha); $usercount = $this->count_users_avail($namesearch, $alpha); $alphabet = explode(',', get_string('alphabet')); $strall = get_string('all'); /// Bar of first initials echo "<p style=\"text-align:center\">"; echo get_string('tag_name', 'block_curr_admin') . " : "; if ($alpha) { echo " <a href=\"index.php?s=ins&section=curr&action=add&id={$classid}&" . "sort=name&dir=ASC&perpage={$perpage}\">{$strall}</a> "; } else { echo " <b>{$strall}</b> "; } foreach ($alphabet as $letter) { if ($letter == $alpha) { echo " <b>{$letter}</b> "; } else { echo " <a href=\"index.php?s=ins&section=curr&action=add&id={$classid}&" . "sort=name&dir=ASC&perpage={$perpage}&alpha={$letter}\">{$letter}</a> "; } } echo "</p>"; print_paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode(stripslashes($namesearch)) . "&"); flush(); } else { $user = $this->user; $user->name = cm_fullname($this->user); $users[] = $user; $usercount = 0; } if (empty($this->id) && !$users) { $match = array(); if ($namesearch !== '') { $match[] = s($namesearch); } if ($alpha) { $match[] = 'name' . ": {$alpha}" . "___"; } $matchstring = implode(", ", $match); echo get_string('no_users_matching', 'block_curr_admin') . $matchstring; $table = NULL; } else { $insobj = new instructor(); $table->width = "100%"; foreach ($users as $user) { $newarr = array(); foreach ($columns as $column => $cdesc) { switch ($column) { case 'assign': $newarr[] = '<input type="checkbox" name="users[' . $user->id . '][assign]" value="1" />' . '<input type="hidden" name="users[' . $user->id . '][idnumber]" ' . 'value="' . $user->idnumber . '" />'; break; case 'name': case 'idnumber': case 'description': $newarr[] = $user->{$column}; break; case 'assigntime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $this->assigntime, true); break; case 'completetime': $newarr[] = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $this->completetime, true); break; default: $newarr[] = ''; break; } } $table->data[] = $newarr; } } if (empty($this->id)) { echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"index.php\" method=\"get\"><fieldset>"; echo '<input type="hidden" name="s" value="ins" />'; echo '<input type="hidden" name="section" value="curr" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $classid . '" />'; echo '<input type="hidden" name="sort" value="' . $sort . '" />'; echo '<input type="hidden" name="dir" value="' . $dir . '" />'; echo "<input type=\"text\" name=\"search\" value=\"" . s($namesearch, true) . "\" size=\"20\" />"; echo "<input type=\"submit\" value=\"" . get_string('search', 'block_curr_admin') . "\" />"; if ($namesearch) { echo "<input type=\"button\" onclick=\"document.location='index.php?s=ins&section=curr&" . "action=add&id={$classid}';\" value=\"" . get_string('show_all_users', 'block_curr_admin') . "\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="savenew" />' . "\n"; } else { echo '<form method="post" action="index.php?s=ins&section=curr&id=' . $classid . '" >' . "\n"; echo '<input type="hidden" name="action" value="update" />' . "\n"; echo '<input type="hidden" name="association_id" value="' . $this->id . '" />' . "\n"; echo '<input type="hidden" name="id" value="' . $this->classid . '" />' . "\n"; echo '<input type="hidden" name="userid" value="' . $this->userid . '" />' . "\n"; } if (!empty($table)) { print_table($table); print_paging_bar($usercount, $page, $perpage, "index.php?s=ins&section=curr&id={$classid}&action=add&" . "sort={$sort}&dir={$dir}&perpage={$perpage}&alpha={$alpha}&" . "search=" . urlencode(stripslashes($namesearch)) . "&"); } if (empty($this->id)) { echo '<br /><input type="submit" value="' . get_string('assign_selected', 'block_curr_admin') . '">' . "\n"; } else { echo '<br /><input type="submit" value="' . get_string('update_assignment', 'block_curr_admin') . '">' . "\n"; } echo '</form>' . "\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
$table->align = array('left', 'left', 'center'); $table->width = "95%"; foreach ($acl as $aclrecord) { if ($aclrecord->accessctrl == 'allow') { $accesscolumn = get_string('allow', 'mnet') . " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=deny&sesskey={$USER->sesskey}\">" . get_string('deny', 'mnet') . "</a>)"; } else { $accesscolumn = get_string('deny', 'mnet') . " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey={$USER->sesskey}\">" . get_string('allow', 'mnet') . "</a>)"; } $deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey={$USER->sesskey}\">" . get_string('delete') . "</a>"; $table->data[] = array($aclrecord->username, $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn); } } if (!empty($table)) { print_table($table); echo '<p> </p>'; print_paging_bar($aclcount, $page, $perpage, "?sort={$sort}&dir={$dir}&perpage={$perpage}&"); } // output the add form print_simple_box_start('center', '90%', '', '20'); ?> <div class="mnetaddtoaclform"> <form id="mnetaddtoacl" method="post"> <input type="hidden" name="sesskey" value="<?php echo $sesskey; ?> " /> <?php // enter a username echo get_string('username') . ":\n"; if (!empty($formerror['username'])) { echo '<span class="error"> * </span>';
function action_default() { $id = $this->required_param('id', PARAM_INT); $sort = $this->optional_param('sort', 'idnumber', PARAM_ALPHANUM); $dir = $this->optional_param('dir', 'ASC', PARAM_ALPHA); $page = $this->optional_param('page', 0, PARAM_INT); $perpage = $this->optional_param('perpage', 30, PARAM_INT); $columns = array('idnumber' => get_string('student_idnumber', 'block_curr_admin'), 'name' => get_string('tag_name', 'block_curr_admin'), 'email' => get_string('email', 'block_curr_admin'), 'manage' => ''); $items = usertrack::get_users($id); $count = $items ? count($items) : 0; $items = usertrack::get_users($id, $sort, $dir, $page, $perpage); $baseurl = new moodle_url($this->get_url(), array('id' => $id, 'sort' => $sort, 'dir' => $dir, 'page' => $page, 'perpage' => $perpage)); print_paging_bar($count, $page, $perpage, $baseurl); $formatters = $this->create_link_formatters(array('idnumber', 'name'), 'usermanagementpage', 'userid'); $this->print_list_view($items, $columns, $formatters, 'users'); if ($this->can_do_add()) { $this->print_assign_link(); } }
function print_html() { global $CFG; if (!$this->setup) { return false; } $colcount = count($this->columns); // Do we need to print initial bars? if ($this->use_initials && isset($this->columns['fullname'])) { $strall = get_string('all'); $alpha = explode(',', get_string('alphabet')); // Bar of first initials echo '<div class="initialbar firstinitial">' . get_string('firstname') . ' : '; if (!empty($this->sess->i_first)) { echo '<a href="' . $this->baseurl . $this->request[TABLE_VAR_IFIRST] . '=">' . $strall . '</a>'; } else { echo '<strong>' . $strall . '</strong>'; } foreach ($alpha as $letter) { if ($letter == $this->sess->i_first) { echo ' <strong>' . $letter . '</strong>'; } else { echo ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_IFIRST] . '=' . $letter . '">' . $letter . '</a>'; } } echo '</div>'; // Bar of last initials echo '<div class="initialbar lastinitial">' . get_string('lastname') . ' : '; if (!empty($this->sess->i_last)) { echo '<a href="' . $this->baseurl . $this->request[TABLE_VAR_ILAST] . '=">' . $strall . '</a>'; } else { echo '<strong>' . $strall . '</strong>'; } foreach ($alpha as $letter) { if ($letter == $this->sess->i_last) { echo ' <strong>' . $letter . '</strong>'; } else { echo ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_ILAST] . '=' . $letter . '">' . $letter . '</a>'; } } echo '</div>'; } // End of initial bars code // Paging bar if ($this->use_pages) { print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]); } if (empty($this->data)) { print_heading(get_string('nothingtodisplay')); return true; } $suppress_enabled = array_sum($this->column_suppress); $suppress_lastrow = NULL; // Start of main data table echo '<table' . $this->make_attributes_string($this->attributes) . '>'; echo '<tr>'; foreach ($this->columns as $column => $index) { $icon_hide = ''; $icon_sort = ''; if ($this->is_collapsible) { if (!empty($this->sess->collapse[$column])) { // some headers contain < br/> tags, do not include in title $icon_hide = ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_SHOW] . '=' . $column . '"><img src="' . $CFG->pixpath . '/t/switch_plus.gif" title="' . get_string('show') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('show') . '" /></a>'; } else { if ($this->headers[$index] !== NULL) { // some headers contain < br/> tags, do not include in title $icon_hide = ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_HIDE] . '=' . $column . '"><img src="' . $CFG->pixpath . '/t/switch_minus.gif" title="' . get_string('hide') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('hide') . '" /></a>'; } } } $primary_sort_column = ''; $primary_sort_order = ''; if (reset($this->sess->sortby)) { $primary_sort_column = key($this->sess->sortby); $primary_sort_order = current($this->sess->sortby); } switch ($column) { case 'fullname': if ($this->is_sortable($column)) { $icon_sort_first = $icon_sort_last = ''; if ($primary_sort_column == 'firstname') { $lsortorder = get_string('asc'); if ($primary_sort_order == SORT_ASC) { $icon_sort_first = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />'; $fsortorder = get_string('asc'); } else { $icon_sort_first = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />'; $fsortorder = get_string('desc'); } } else { if ($primary_sort_column == 'lastname') { $fsortorder = get_string('asc'); if ($primary_sort_order == SORT_ASC) { $icon_sort_last = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />'; $lsortorder = get_string('asc'); } else { $icon_sort_last = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />'; $lsortorder = get_string('desc'); } } else { $fsortorder = get_string('asc'); $lsortorder = get_string('asc'); } } $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=firstname">' . get_string('firstname') . get_accesshide(get_string('sortby') . ' ' . get_string('firstname') . ' ' . $fsortorder) . '</a> ' . $icon_sort_first . ' / ' . '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=lastname">' . get_string('lastname') . get_accesshide(get_string('sortby') . ' ' . get_string('lastname') . ' ' . $lsortorder) . '</a> ' . $icon_sort_last; } break; case 'userpic': // do nothing, do not display sortable links break; default: if ($this->is_sortable($column)) { if ($primary_sort_column == $column) { if ($primary_sort_order == SORT_ASC) { $icon_sort = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />'; $localsortorder = get_string('asc'); } else { $icon_sort = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />'; $localsortorder = get_string('desc'); } } else { $localsortorder = get_string('asc'); } $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=' . $column . '">' . $this->headers[$index] . get_accesshide(get_string('sortby') . ' ' . $this->headers[$index] . ' ' . $localsortorder) . '</a>'; } } if ($this->headers[$index] === NULL) { echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col"> </th>'; } else { if (!empty($this->sess->collapse[$column])) { echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col">' . $icon_hide . '</th>'; } else { // took out nowrap for accessibility, might need replacement if (!is_array($this->column_style[$column])) { // $usestyles = array('white-space:nowrap'); $usestyles = ''; } else { // $usestyles = $this->column_style[$column]+array('white-space'=>'nowrap'); $usestyles = $this->column_style[$column]; } echo '<th class="header c' . $index . $this->column_class[$column] . '" ' . $this->make_styles_string($usestyles) . ' scope="col">' . $this->headers[$index] . $icon_sort . '<div class="commands">' . $icon_hide . '</div></th>'; } } } echo '</tr>'; if (!empty($this->data)) { $oddeven = 1; $colbyindex = array_flip($this->columns); foreach ($this->data as $row) { $oddeven = $oddeven ? 0 : 1; echo '<tr class="r' . $oddeven . '">'; // If we have a separator, print it if ($row === NULL && $colcount) { echo '<td colspan="' . $colcount . '"><div class="tabledivider"></div></td>'; } else { foreach ($row as $index => $data) { if ($index >= $colcount) { break; } $column = $colbyindex[$index]; echo '<td class="cell c' . $index . $this->column_class[$column] . '"' . $this->make_styles_string($this->column_style[$column]) . '>'; if (empty($this->sess->collapse[$column])) { if ($this->column_suppress[$column] && $suppress_lastrow !== NULL && $suppress_lastrow[$index] === $data) { echo ' '; } else { echo $data; } } else { echo ' '; } echo '</td>'; } } echo '</tr>'; if ($suppress_enabled) { $suppress_lastrow = $row; } } } echo '</table>'; // Paging bar if ($this->use_pages) { print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]); } }
/** * Prints the discussion view screen for a forum. * * @param object $course The current course object. * @param object $forum Forum to be printed. * @param int $maxdiscussions . * @param string $displayformat The display format to use (optional). * @param string $sort Sort arguments for database query (optional). * @param int $groupmode Group mode of the forum (optional). * @param void $unused (originally current group) * @param int $page Page mode, page to display (optional). * @param int perpage The maximum number of discussions per page(optional) * */ function forum_print_latest_discussions($course, $forum, $maxdiscussions = -1, $displayformat = 'plain', $sort = '', $currentgroup = -1, $groupmode = -1, $page = -1, $perpage = 100, $cm = NULL) { global $CFG, $USER; if (!$cm) { if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course))) { error('Course Module ID was incorrect'); } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (empty($sort)) { $sort = "d.timemodified DESC"; } $olddiscussionlink = false; // Sort out some defaults if ($perpage <= 0) { $perpage = 0; $page = -1; } if ($maxdiscussions == 0) { // all discussions - backwards compatibility $page = -1; $perpage = 0; if ($displayformat == 'plain') { $displayformat = 'header'; // Abbreviate display by default } } else { if ($maxdiscussions > 0) { $page = -1; $perpage = $maxdiscussions; } } $fullpost = false; if ($displayformat == 'plain') { $fullpost = true; } // Decide if current user is allowed to see ALL the current discussions or not // First check the group stuff if ($currentgroup == -1 or $groupmode == -1) { $groupmode = groups_get_activity_groupmode($cm, $course); $currentgroup = groups_get_activity_group($cm); } // If the user can post discussions, then this is a good place to put the // button for it. We do not show the button if we are showing site news // and the current user is a guest. if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context) || ($forum->type != 'news' and (isguestuser() or !isloggedin() or has_capability('moodle/legacy:guest', $context, NULL, false)))) { echo '<div class="singlebutton forumaddnew">'; echo "<form id=\"newdiscussionform\" method=\"get\" action=\"{$CFG->wwwroot}/mod/forum/post.php\">"; echo '<div>'; echo "<input type=\"hidden\" name=\"forum\" value=\"{$forum->id}\" />"; echo '<input type="submit" value="'; echo $forum->type == 'news' ? get_string('addanewtopic', 'forum') : ($forum->type == 'qanda' ? get_string('addanewquestion', 'forum') : get_string('addanewdiscussion', 'forum')); echo '" />'; echo '</div>'; echo '</form>'; echo "</div>\n"; } else { if (isguestuser() or !isloggedin() or $forum->type == 'news') { // no button and no info } else { if ($groupmode and has_capability('mod/forum:startdiscussion', $context)) { // inform users why they can not post new discussion if ($currentgroup) { notify(get_string('cannotadddiscussion', 'forum')); } else { notify(get_string('cannotadddiscussionall', 'forum')); } } } } // Get all the recent discussions we're allowed to see $getuserlastmodified = $displayformat == 'header'; if (!($discussions = forum_get_discussions($cm, $sort, $fullpost, null, $maxdiscussions, $getuserlastmodified, $page, $perpage))) { echo '<div class="forumnodiscuss">'; if ($forum->type == 'news') { echo '(' . get_string('nonews', 'forum') . ')'; } else { if ($forum->type == 'qanda') { echo '(' . get_string('noquestions', 'forum') . ')'; } else { echo '(' . get_string('nodiscussions', 'forum') . ')'; } } echo "</div>\n"; return; } // If we want paging if ($page != -1) { ///Get the number of discussions found $numdiscussions = forum_get_discussions_count($cm); ///Show the paging bar print_paging_bar($numdiscussions, $page, $perpage, "view.php?f={$forum->id}&"); if ($numdiscussions > 1000) { // saves some memory on sites with very large forums $replies = forum_count_discussion_replies($forum->id, $sort, $maxdiscussions, $page, $perpage); } else { $replies = forum_count_discussion_replies($forum->id); } } else { $replies = forum_count_discussion_replies($forum->id); if ($maxdiscussions > 0 and $maxdiscussions <= count($discussions)) { $olddiscussionlink = true; } } $canviewparticipants = has_capability('moodle/course:viewparticipants', $context); $strdatestring = get_string('strftimerecentfull'); // Check if the forum is tracked. if ($cantrack = forum_tp_can_track_forums($forum)) { $forumtracked = forum_tp_is_tracked($forum); } else { $forumtracked = false; } if ($forumtracked) { $unreads = forum_get_discussions_unread($cm); } else { $unreads = array(); } if ($displayformat == 'header') { echo '<table cellspacing="0" class="forumheaderlist">'; echo '<thead>'; echo '<tr>'; echo '<th class="header topic" scope="col">' . get_string('discussion', 'forum') . '</th>'; echo '<th class="header author" colspan="2" scope="col">' . get_string('startedby', 'forum') . '</th>'; if ($groupmode > 0) { echo '<th class="header group" scope="col">' . get_string('group') . '</th>'; } if (has_capability('mod/forum:viewdiscussion', $context)) { echo '<th class="header replies" scope="col">' . get_string('replies', 'forum') . '</th>'; // If the forum can be tracked, display the unread column. if ($cantrack) { echo '<th class="header replies" scope="col">' . get_string('unread', 'forum'); if ($forumtracked) { echo ' <a title="' . get_string('markallread', 'forum') . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&mark=read&returnpage=view.php">' . '<img src="' . $CFG->pixpath . '/t/clear.gif" class="iconsmall" alt="' . get_string('markallread', 'forum') . '" /></a>'; } echo '</th>'; } } echo '<th class="header lastpost" scope="col">' . get_string('lastpost', 'forum') . '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; } foreach ($discussions as $discussion) { if (!empty($replies[$discussion->discussion])) { $discussion->replies = $replies[$discussion->discussion]->replies; $discussion->lastpostid = $replies[$discussion->discussion]->lastpostid; } else { $discussion->replies = 0; } // SPECIAL CASE: The front page can display a news item post to non-logged in users. // All posts are read in this case. if (!$forumtracked) { $discussion->unread = '-'; } else { if (empty($USER)) { $discussion->unread = 0; } else { if (empty($unreads[$discussion->discussion])) { $discussion->unread = 0; } else { $discussion->unread = $unreads[$discussion->discussion]; } } } if (!empty($USER->id)) { $ownpost = $discussion->userid == $USER->id; } else { $ownpost = false; } // Use discussion name instead of subject of first post $discussion->subject = $discussion->name; switch ($displayformat) { case 'header': if ($groupmode > 0) { if (isset($groups[$discussion->groupid])) { $group = $groups[$discussion->groupid]; } else { $group = $groups[$discussion->groupid] = groups_get_group($discussion->groupid); } } else { $group = -1; } forum_print_discussion_header($discussion, $forum, $group, $strdatestring, $cantrack, $forumtracked, $canviewparticipants, $context); break; default: $link = false; if ($discussion->replies) { $link = true; } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $link = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext); } $discussion->forum = $forum->id; forum_print_post($discussion, $discussion, $forum, $cm, $course, $ownpost, 0, $link, false); break; } } if ($displayformat == "header") { echo '</tbody>'; echo '</table>'; } if ($olddiscussionlink) { if ($forum->type == 'news') { $strolder = get_string('oldertopics', 'forum'); } else { $strolder = get_string('olderdiscussions', 'forum'); } echo '<div class="forumolddiscuss">'; echo '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '&showall=1">'; echo $strolder . '</a> ...</div>'; } if ($page != -1) { ///Show the paging bar print_paging_bar($numdiscussions, $page, $perpage, "view.php?f={$forum->id}&"); } }
/** * Prints the table of questions in a category with interactions * * @param object $course The course object * @param int $categoryid The id of the question category to be displayed * @param int $cm The course module record if we are in the context of a particular module, 0 otherwise * @param int $recurse This is 1 if subcategories should be included, 0 otherwise * @param int $page The number of the page to be displayed * @param int $perpage Number of questions to show per page * @param boolean $showhidden True if also hidden questions should be displayed * @param boolean $showquestiontext whether the text of each question should be shown in the list */ function question_list($contexts, $pageurl, $categoryandcontext, $cm = null, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $sortorder = 'typename', $sortorderdecoded = 'qtype, name ASC', $showquestiontext = false, $addcontexts = array()) { global $USER, $CFG, $THEME, $COURSE; $lastchangedid = optional_param('lastchanged', 0, PARAM_INT); list($categoryid, $contextid) = explode(',', $categoryandcontext); $qtypemenu = question_type_menu(); $strcategory = get_string("category", "quiz"); $strquestion = get_string("question", "quiz"); $straddquestions = get_string("addquestions", "quiz"); $strimportquestions = get_string("importquestions", "quiz"); $strexportquestions = get_string("exportquestions", "quiz"); $strnoquestions = get_string("noquestions", "quiz"); $strselect = get_string("select", "quiz"); $strselectall = get_string("selectall", "quiz"); $strselectnone = get_string("selectnone", "quiz"); $strcreatenewquestion = get_string("createnewquestion", "quiz"); $strquestionname = get_string("questionname", "quiz"); $strdelete = get_string("delete"); $stredit = get_string("edit"); $strmove = get_string('moveqtoanothercontext', 'question'); $strview = get_string("view"); $straction = get_string("action"); $strrestore = get_string('restore'); $strtype = get_string("type", "quiz"); $strcreatemultiple = get_string("createmultiple", "quiz"); $strpreview = get_string("preview", "quiz"); if (!$categoryid) { echo "<p style=\"text-align:center;\"><b>"; print_string("selectcategoryabove", "quiz"); echo "</b></p>"; return; } if (!($category = get_record('question_categories', 'id', $categoryid, 'contextid', $contextid))) { notify('Category not found!'); return; } $catcontext = get_context_instance_by_id($contextid); $canadd = has_capability('moodle/question:add', $catcontext); //check for capabilities on all questions in category, will also apply to sub cats. $caneditall = has_capability('moodle/question:editall', $catcontext); $canuseall = has_capability('moodle/question:useall', $catcontext); $canmoveall = has_capability('moodle/question:moveall', $catcontext); if ($cm and $cm->modname == 'quiz') { $quizid = $cm->instance; } else { $quizid = 0; } $returnurl = $pageurl->out(); $questionurl = new moodle_url("{$CFG->wwwroot}/question/question.php", array('returnurl' => $returnurl)); if ($cm !== null) { $questionurl->param('cmid', $cm->id); } else { $questionurl->param('courseid', $COURSE->id); } $questionmoveurl = new moodle_url("{$CFG->wwwroot}/question/contextmoveq.php", array('returnurl' => $returnurl)); if ($cm !== null) { $questionmoveurl->param('cmid', $cm->id); } else { $questionmoveurl->param('courseid', $COURSE->id); } echo '<div class="boxaligncenter">'; $formatoptions = new stdClass(); $formatoptions->noclean = true; echo format_text($category->info, FORMAT_MOODLE, $formatoptions, $COURSE->id); echo '<table><tr>'; if ($canadd) { echo '<td valign="top" align="right">'; popup_form($questionurl->out(false, array('category' => $category->id)) . '&qtype=', $qtypemenu, "addquestion", "", "choose", "", "", false, "self", "<strong>{$strcreatenewquestion}</strong>"); echo '</td><td valign="top" align="right">'; helpbutton("questiontypes", $strcreatenewquestion, "quiz"); echo '</td>'; } else { echo '<td>'; print_string('nopermissionadd', 'question'); echo '</td>'; } echo '</tr></table>'; echo '</div>'; $categorylist = $recurse ? question_categorylist($category->id) : $category->id; // hide-feature $showhidden = $showhidden ? '' : " AND hidden = '0'"; if (!($totalnumber = count_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}"))) { echo "<p style=\"text-align:center;\">"; print_string("noquestions", "quiz"); echo "</p>"; return; } if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorderdecoded, '*', $page * $perpage, $perpage))) { // There are no questions on the requested page. $page = 0; if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorderdecoded, '*', 0, $perpage))) { // There are no questions at all echo "<p style=\"text-align:center;\">"; print_string("noquestions", "quiz"); echo "</p>"; return; } } print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage'); echo question_sort_options($pageurl, $sortorder); echo '<form method="post" action="edit.php">'; echo '<fieldset class="invisiblefieldset" style="display: block;">'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; echo $pageurl->hidden_params_out(); echo '<table id="categoryquestions" style="width: 100%"><tr>'; echo "<th style=\"white-space:nowrap;\" class=\"header\" scope=\"col\">{$straction}</th>"; echo "<th style=\"white-space:nowrap; text-align: left;\" class=\"header\" scope=\"col\">{$strquestionname}</th>\n <th style=\"white-space:nowrap; text-align: right;\" class=\"header\" scope=\"col\">{$strtype}</th>"; echo "</tr>\n"; foreach ($questions as $question) { $nameclass = ''; $textclass = ''; if ($question->hidden) { $nameclass = 'dimmed_text'; $textclass = 'dimmed_text'; } if ($showquestiontext) { $nameclass .= ' header'; } if ($question->id == $lastchangedid) { $nameclass = 'highlight'; } if ($nameclass) { $nameclass = 'class="' . $nameclass . '"'; } if ($textclass) { $textclass = 'class="' . $textclass . '"'; } echo "<tr>\n<td style=\"white-space:nowrap;\" {$nameclass}>\n"; $canuseq = question_has_capability_on($question, 'use', $question->category); if (function_exists('module_specific_actions')) { echo module_specific_actions($pageurl, $question->id, $cm->id, $canuseq); } // preview if ($canuseq) { $quizorcourseid = $quizid ? '&quizid=' . $quizid : '&courseid=' . $COURSE->id; link_to_popup_window('/question/preview.php?id=' . $question->id . $quizorcourseid, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS); } // edit, hide, delete question, using question capabilities, not quiz capabilieies if (question_has_capability_on($question, 'edit', $question->category) || question_has_capability_on($question, 'move', $question->category)) { echo "<a title=\"{$stredit}\" href=\"" . $questionurl->out(false, array('id' => $question->id)) . "\"><img\n src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"{$stredit}\" /></a> "; } elseif (question_has_capability_on($question, 'view', $question->category)) { echo "<a title=\"{$strview}\" href=\"" . $questionurl->out(false, array('id' => $question->id)) . "\"><img\n src=\"{$CFG->pixpath}/i/info.gif\" alt=\"{$strview}\" /></a> "; } if (question_has_capability_on($question, 'move', $question->category) && question_has_capability_on($question, 'view', $question->category)) { echo "<a title=\"{$strmove}\" href=\"" . $questionurl->out(false, array('id' => $question->id, 'movecontext' => 1)) . "\"><img\n src=\"{$CFG->pixpath}/t/move.gif\" alt=\"{$strmove}\" /></a> "; } if (question_has_capability_on($question, 'edit', $question->category)) { // hide-feature if ($question->hidden) { echo "<a title=\"{$strrestore}\" href=\"edit.php?" . $pageurl->get_query_string() . "&unhide={$question->id}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/restore.gif\" alt=\"{$strrestore}\" /></a>"; } else { echo "<a title=\"{$strdelete}\" href=\"edit.php?" . $pageurl->get_query_string() . "&deleteselected={$question->id}&q{$question->id}=1\"><img\n src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>"; } } if ($caneditall || $canmoveall || $canuseall) { echo " <input title=\"{$strselect}\" type=\"checkbox\" name=\"q{$question->id}\" value=\"1\" />"; } echo "</td>\n"; echo "<td {$nameclass}>" . format_string($question->name) . "</td>\n"; echo "<td {$nameclass} style='text-align: right'>\n"; print_question_icon($question); echo "</td>\n"; echo "</tr>\n"; if ($showquestiontext) { echo '<tr><td colspan="3" ' . $textclass . '>'; $formatoptions = new stdClass(); $formatoptions->noclean = true; $formatoptions->para = false; echo format_text($question->questiontext, $question->questiontextformat, $formatoptions, $COURSE->id); echo "</td></tr>\n"; } } echo "</table>\n"; $paging = print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage', false, true); if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) { if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) { $showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => 1000)) . '">' . get_string('showall', 'moodle', $totalnumber) . '</a>'; } else { $showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => DEFAULT_QUESTIONS_PER_PAGE)) . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>'; } if ($paging) { $paging = substr($paging, 0, strrpos($paging, '</div>')); $paging .= "<br />{$showall}</div>"; } else { $paging = "<div class='paging'>{$showall}</div>"; } } echo $paging; if ($caneditall || $canmoveall || $canuseall) { echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectall . '</a> /' . ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectnone . '</a>'; echo '<br />'; echo '<strong> ' . get_string('withselected', 'quiz') . ':</strong><br />'; if (function_exists('module_specific_buttons')) { echo module_specific_buttons($cm->id); } // print delete and move selected question if ($caneditall) { echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" />\n"; } if ($canmoveall && count($addcontexts)) { echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n"; question_category_select_menu($addcontexts, false, 0, "{$category->id},{$category->contextid}"); } if (function_exists('module_specific_controls') && $canuseall) { echo module_specific_controls($totalnumber, $recurse, $category, $cm->id); } } echo '</fieldset>'; echo "</form>\n"; }
function print_mnet_log($hostid, $course, $user = 0, $date = 0, $order = "l.time ASC", $page = 0, $perpage = 100, $url = "", $modname = "", $modid = 0, $modaction = "", $groupid = 0) { global $CFG; if (!($logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page * $perpage, $perpage, $modname, $modid, $modaction, $groupid))) { notify("No logs found!"); print_footer($course); exit; } if ($course->id == SITEID) { $courses[0] = ''; if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) { foreach ($ccc as $cc) { $courses[$cc->id] = $cc->shortname; } } } $totalcount = $logs['totalcount']; $count = 0; $ldcache = array(); $tt = getdate(time()); $today = mktime(0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]); $strftimedatetime = get_string("strftimedatetime"); echo "<div class=\"info\">\n"; print_string("displayingrecords", "", $totalcount); echo "</div>\n"; print_paging_bar($totalcount, $page, $perpage, "{$url}&perpage={$perpage}&"); echo "<table class=\"logtable\" cellpadding=\"3\" cellspacing=\"0\">\n"; echo "<tr>"; if ($course->id == SITEID) { echo "<th class=\"c0 header\">" . get_string('course') . "</th>\n"; } echo "<th class=\"c1 header\">" . get_string('time') . "</th>\n"; echo "<th class=\"c2 header\">" . get_string('ip_address') . "</th>\n"; echo "<th class=\"c3 header\">" . get_string('fullname') . "</th>\n"; echo "<th class=\"c4 header\">" . get_string('action') . "</th>\n"; echo "<th class=\"c5 header\">" . get_string('info') . "</th>\n"; echo "</tr>\n"; if (empty($logs['logs'])) { echo "</table>\n"; return; } $row = 1; foreach ($logs['logs'] as $log) { $log->info = $log->coursename; $row = ($row + 1) % 2; if (isset($ldcache[$log->module][$log->action])) { $ld = $ldcache[$log->module][$log->action]; } else { $ld = get_record('log_display', 'module', $log->module, 'action', $log->action); $ldcache[$log->module][$log->action] = $ld; } if (0 && $ld && !empty($log->info)) { // ugly hack to make sure fullname is shown correctly if ($ld->mtable == 'user' and $ld->field == sql_concat('firstname', "' '", 'lastname')) { $log->info = fullname(get_record($ld->mtable, 'id', $log->info), true); } else { $log->info = get_field($ld->mtable, $ld->field, 'id', $log->info); } } //Filter log->info $log->info = format_string($log->info); echo '<tr class="r' . $row . '">'; if ($course->id == SITEID) { echo "<td class=\"r{$row} c0\" >\n"; echo " <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">" . $courses[$log->course] . "</a>\n"; echo "</td>\n"; } echo "<td class=\"r{$row} c1\" align=\"right\">" . userdate($log->time, '%a') . ' ' . userdate($log->time, $strftimedatetime) . "</td>\n"; echo "<td class=\"r{$row} c2\" >\n"; link_to_popup_window("/iplookup/index.php?ip={$log->ip}&user={$log->userid}", 'iplookup', $log->ip, 400, 700); echo "</td>\n"; $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); echo "<td class=\"r{$row} c3\" >\n"; echo " <a href=\"{$CFG->wwwroot}/user/view.php?id={$log->userid}\">{$fullname}</a>\n"; echo "</td>\n"; echo "<td class=\"r{$row} c4\">\n"; echo $log->action . ': ' . $log->module; echo "</td>\n"; echo "<td class=\"r{$row} c5\">{$log->info}</td>\n"; echo "</tr>\n"; } echo "</table>\n"; print_paging_bar($totalcount, $page, $perpage, "{$url}&perpage={$perpage}&"); }
/** * Prints the table of questions in a category with interactions * * @param object $course The course object * @param int $categoryid The id of the question category to be displayed * @param int $quizid The quiz id if we are in the context of a particular quiz, 0 otherwise * @param int $recurse This is 1 if subcategories should be included, 0 otherwise * @param int $page The number of the page to be displayed * @param int $perpage Number of questions to show per page * @param boolean $showhidden True if also hidden questions should be displayed * @param boolean $showquestiontext whether the text of each question should be shown in the list */ function question_list($course, $categoryid, $quizid = 0, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $sortorder = 'qtype, name ASC', $showquestiontext = false) { global $USER, $CFG, $THEME; $qtypemenu = question_type_menu(); if ($rqp_types = get_records('question_rqp_types')) { foreach ($rqp_types as $type) { $qtypemenu['rqp_' . $type->id] = $type->name; } } $strcategory = get_string("category", "quiz"); $strquestion = get_string("question", "quiz"); $straddquestions = get_string("addquestions", "quiz"); $strimportquestions = get_string("importquestions", "quiz"); $strexportquestions = get_string("exportquestions", "quiz"); $strnoquestions = get_string("noquestions", "quiz"); $strselect = get_string("select", "quiz"); $strselectall = get_string("selectall", "quiz"); $strselectnone = get_string("selectnone", "quiz"); $strcreatenewquestion = get_string("createnewquestion", "quiz"); $strquestionname = get_string("questionname", "quiz"); $strdelete = get_string("delete"); $stredit = get_string("edit"); $straction = get_string("action"); $strrestore = get_string('restore'); $straddtoquiz = get_string("addtoquiz", "quiz"); $strtype = get_string("type", "quiz"); $strcreatemultiple = get_string("createmultiple", "quiz"); $strpreview = get_string("preview", "quiz"); if (!$categoryid) { echo "<p style=\"text-align:center;\"><b>"; print_string("selectcategoryabove", "quiz"); echo "</b></p>"; if ($quizid) { echo "<p>"; print_string("addingquestions", "quiz"); echo "</p>"; } return; } if (!($category = get_record('question_categories', 'id', $categoryid))) { notify('Category not found!'); return; } $canedit = has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course)); $editingquiz = false; if ($quizid) { $cm = get_coursemodule_from_instance('quiz', $quizid); $editingquiz = has_capability('mod/quiz:manage', get_context_instance(CONTEXT_MODULE, $cm->id)); } echo '<div class="boxaligncenter">'; $formatoptions = new stdClass(); $formatoptions->noclean = true; echo format_text($category->info, FORMAT_MOODLE, $formatoptions, $course->id); echo '<table><tr>'; // check if editing questions in this category is allowed if ($canedit) { echo "<td valign=\"top\"><b>{$strcreatenewquestion}:</b></td>"; echo '<td valign="top" align="right">'; popup_form("{$CFG->wwwroot}/question/question.php?category={$category->id}&qtype=", $qtypemenu, "addquestion", "", "choose", "", "", false, "self"); echo '</td><td valign="top" align="right">'; helpbutton("questiontypes", $strcreatenewquestion, "quiz"); echo '</td>'; } else { echo '<td>'; print_string("publishedit", "quiz"); echo '</td>'; } echo '</tr></table>'; echo '</div>'; $categorylist = $recurse ? question_categorylist($category->id) : $category->id; // hide-feature $showhidden = $showhidden ? '' : " AND hidden = '0'"; if (!($totalnumber = count_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}"))) { echo "<p style=\"text-align:center;\">"; print_string("noquestions", "quiz"); echo "</p>"; return; } if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', $page * $perpage, $perpage))) { // There are no questions on the requested page. $page = 0; if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', 0, $perpage))) { // There are no questions at all echo "<p style=\"text-align:center;\">"; print_string("noquestions", "quiz"); echo "</p>"; return; } } print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&perpage={$perpage}&"); echo '<form method="post" action="edit.php?courseid=' . $course->id . '">'; echo '<fieldset class="invisiblefieldset" style="display: block;">'; echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; echo '<table id="categoryquestions" style="width: 100%"><tr>'; echo "<th style=\"white-space:nowrap;\" class=\"header\" scope=\"col\">{$straction}</th>"; $sortoptions = array('name, qtype ASC' => get_string("sortalpha", "quiz"), 'qtype, name ASC' => get_string("sorttypealpha", "quiz"), 'id ASC' => get_string("sortage", "quiz")); $orderselect = choose_from_menu($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true); $orderselect .= '<noscript><div><input type="submit" value="' . get_string("sortsubmit", "quiz") . '" /></div></noscript>'; echo "<th style=\"white-space:nowrap; text-align: left;\" class=\"header\" scope=\"col\">{$strquestionname} {$orderselect}</th>\n <th style=\"white-space:nowrap; text-align: right;\" class=\"header\" scope=\"col\">{$strtype}</th>"; echo "</tr>\n"; foreach ($questions as $question) { $nameclass = ''; $textclass = ''; if ($question->hidden) { $nameclass = 'dimmed_text'; $textclass = 'dimmed_text'; } if ($showquestiontext) { $nameclass .= ' header'; } if ($nameclass) { $nameclass = 'class="' . $nameclass . '"'; } if ($textclass) { $textclass = 'class="' . $textclass . '"'; } echo "<tr>\n<td style=\"white-space:nowrap;\" {$nameclass}>\n"; // add to quiz if ($editingquiz) { echo "<a title=\"{$straddtoquiz}\" href=\"edit.php?addquestion={$question->id}&quizid={$quizid}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/moveleft.gif\" alt=\"{$straddtoquiz}\" /></a> "; } // preview link_to_popup_window('/question/preview.php?id=' . $question->id . '&quizid=' . $quizid, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS); // edit, hide, delete question, using question capabilities, not quiz capabilieies if ($canedit) { echo "<a title=\"{$stredit}\" href=\"{$CFG->wwwroot}/question/question.php?id={$question->id}\"><img\n src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"{$stredit}\" /></a> "; // hide-feature if ($question->hidden) { echo "<a title=\"{$strrestore}\" href=\"edit.php?courseid={$course->id}&unhide={$question->id}&sesskey={$USER->sesskey}\"><img\n src=\"{$CFG->pixpath}/t/restore.gif\" alt=\"{$strrestore}\" /></a>"; } else { echo "<a title=\"{$strdelete}\" href=\"edit.php?courseid={$course->id}&deleteselected={$question->id}&q{$question->id}=1\"><img\n src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>"; } } echo " <input title=\"{$strselect}\" type=\"checkbox\" name=\"q{$question->id}\" value=\"1\" />"; echo "</td>\n"; echo "<td {$nameclass}>" . format_string($question->name) . "</td>\n"; echo "<td {$nameclass} style='text-align: right'>\n"; print_question_icon($question); echo "</td>\n"; echo "</tr>\n"; if ($showquestiontext) { echo '<tr><td colspan="3" ' . $textclass . '>'; $formatoptions = new stdClass(); $formatoptions->noclean = true; $formatoptions->para = false; echo format_text($question->questiontext, $question->questiontextformat, $formatoptions, $course->id); echo "</td></tr>\n"; } } echo "</table>\n"; $paging = print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&perpage={$perpage}&", 'page', false, true); if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) { if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) { $showall = '<a href="edit.php?courseid=' . $course->id . '&perpage=1000">' . get_string('showall', 'moodle', $totalnumber) . '</a>'; } else { $showall = '<a href="edit.php?courseid=' . $course->id . '&perpage=' . DEFAULT_QUESTIONS_PER_PAGE . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>'; } if ($paging) { $paging = substr($paging, 0, strrpos($paging, '</div>')); $paging .= "<br />{$showall}</div>"; } else { $paging = "<div class='paging'>{$showall}</div>"; } } echo $paging; echo '<table class="quiz-edit-selected"><tr><td colspan="2">'; echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectall . '</a> /' . ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">' . $strselectnone . '</a>' . '</td><td align="right"><b> ' . get_string('withselected', 'quiz') . ':</b></td></tr><tr><td>'; if ($editingquiz) { echo "<input type=\"submit\" name=\"add\" value=\"{$THEME->larrow} {$straddtoquiz}\" />\n"; echo '</td><td>'; } // print delete and move selected question if ($canedit) { echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" /></td><td>\n"; echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n"; question_category_select_menu($course->id, false, true, $category->id); } echo "</td></tr></table>"; // add random question if ($editingquiz) { for ($i = 1; $i <= min(10, $totalnumber); $i++) { $randomcount[$i] = $i; } for ($i = 20; $i <= min(100, $totalnumber); $i += 10) { $randomcount[$i] = $i; } echo '<br />'; print_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true)); echo '<input type="hidden" name="recurse" value="' . $recurse . '" />'; echo "<input type=\"hidden\" name=\"categoryid\" value=\"{$category->id}\" />"; echo ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />'; helpbutton('random', get_string('random', 'quiz'), 'quiz'); } echo '</fieldset>'; echo "</form>\n"; }
$message = highlight($strippedsearch, format_text($post->message, $post->messageformat, $options, $course->id), 0, '<fgw9sdpq4>', '</fgw9sdpq4>'); foreach ($searchterms as $searchterm) { if (preg_match("/{$searchterm}/i", $message) && !preg_match('/<fgw9sdpq4>' . $searchterm . '<\\/fgw9sdpq4>/i', $message)) { $missing_terms .= " {$searchterm}"; } } if ($missing_terms) { $strmissingsearchterms = get_string('missingsearchterms', 'forum'); $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $post->message; } // Prepare a link to the post in context, to be displayed after the forum post. $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>"; // Now pring the post. forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, false, $fulllink, $strippedsearch, -99, false); } print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode($search) . "&id={$course->id}&perpage={$perpage}&"); print_footer($course); /** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro'); print_simple_box_start("center"); echo "<script type=\"text/javascript\">\n"; echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n"; echo "var timetoitems = ['today','tomonth','toyear','tohour','tominute'];\n"; echo "</script>\n"; echo '<form id="searchform" action="search.php" method="get">'; echo '<table cellpadding="10" class="searchbox" id="form">';
// Bar of last initials echo '<div class="initialbar lastinitial">' . get_string('lastname') . ' : '; if (!empty($lastinitial)) { echo '<a href="' . $baseurl . '&silast=">' . $strall . '</a>'; } else { echo '<strong>' . $strall . '</strong>'; } foreach ($alpha as $letter) { if ($letter == $lastinitial) { echo ' <strong>' . $letter . '</strong>'; } else { echo ' <a href="' . $baseurl . '&silast=' . $letter . '">' . $letter . '</a>'; } } echo '</div>'; print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl . '&', 'spage'); } if ($matchcount > 0) { $usersprinted = array(); foreach ($userlist as $user) { if (in_array($user->id, $usersprinted)) { /// Prevent duplicates by r.hidden - MDL-13935 continue; } $usersprinted[] = $user->id; /// Add new user to the array of users printed $user = make_context_subobj($user); print_user($user, $course, $bulkoperations); } } else { print_heading(get_string('nothingtodisplay'));
function build_table($components, $where, $page, $per_page) { global $CFG, $USER; $defaults = $components->as_dict(); list($table, $prequery) = get_pre_query($USER->id); // if they have the ability to view a particular sport then // we have to do some joins in our lookup $viewsports = (isset($where['sports']) or !empty($table)); if ($viewsports) { $extra_values = ", spo.code AS sports, spo.name "; $sports_tables = ", {$CFG->prefix}block_courseprefs_sports spo,\n {$CFG->prefix}block_courseprefs_sportusers spu "; $sports_where = " u.id = spu.usersid \n AND spu.sportsid = spo.id\n AND "; } else { $extra_values = ''; $sports_tables = ''; $sports_where = ''; } $count_sql = "SELECT COUNT(u.id) FROM {$CFG->prefix}block_courseprefs_users u "; $sql = "SELECT u.* {$extra_values}\n FROM {$CFG->prefix}block_courseprefs_users u "; // Do a prequery for those who have student gradeviewer assignments if ($prequery) { $where[] = $prequery; } $limit = $offset = ''; if (!empty($per_page)) { $limit = " LIMIT " . $per_page; $offset = " OFFSET " . $per_page * $page; } $where_sql = "WHERE " . $sports_where . implode(' AND ', $where); // Get our users, hopefully! $users = get_records_sql($sql . $sports_tables . $where_sql . $limit . $offset); $count = count_records_sql($count_sql . $sports_tables . $where_sql); if (!$viewsports) { array_pop($defaults); } // pop per page selector array_pop($defaults); $defaults['grades'] = get_string("grades"); $keys = array_keys($defaults); if (empty($users)) { echo '<div class = "results">' . get_string('content_no_results', 'block_courseprefs') . '</div>'; } else { // Finding where eligible components to preserve lookup $where_eligible_components = array_filter($components->components, create_function('$c', ' return $c->where_eligible(); ')); // Building param map from eligible components $html_params = implode('&', array_map(create_function('$c', 'return "$c->key=$c->value";'), $where_eligible_components)) . '&per_page=' . $per_page . '&'; // The html to do the paging $bar = print_paging_bar($count, $page, $per_page, 'viewgrades.php?' . $html_params, 'page', false, true); echo $bar; echo '<div class = "results">' . $count . get_string('content_results', 'block_courseprefs') . '</div>'; // print the results table $table = new stdClass(); $table->head = $defaults; $table->data = array(); foreach ($users as $user) { // pull the courses where the user is enrolled as a student $course_grades = pull_course_grades($user); // Boolean if they have or don't have courses $no_courses = empty($course_grades); $line = array(); foreach ($keys as $key) { if ($viewsports && $key == 'sports') { $value = flatten_sport($user); } else { if ($key == 'username') { $value = $no_courses ? $user->username : '******' . $CFG->wwwroot . '/blocks/student_gradeviewer/mentee.php?id=' . $user->id . '">' . $user->username . '</a>'; } else { if ($key == 'grades') { $value = $no_courses ? 'NA' : implode('<br/>', $course_grades); } else { $value = $user->{$key}; } } } $line[] = $value; } $table->data[] = $line; } print_table($table); echo $bar; } }
/** * Prints the tag search results * * @param string $query text that tag names will be matched against * @param int $page current page * @param int $perpage nr of users displayed per page * @param $return if true return html string */ function tag_print_search_results($query, $page, $perpage, $return = false) { global $CFG, $USER; $query = array_shift(tag_normalize($query, TAG_CASE_ORIGINAL)); $count = sizeof(tag_find_tags($query, false)); $tags = array(); if ($found_tags = tag_find_tags($query, true, $page * $perpage, $perpage)) { $tags = array_values($found_tags); } $baseurl = $CFG->wwwroot . '/tag/search.php?query=' . rawurlencode($query); $output = ''; // link "Add $query to my interests" $addtaglink = ''; if (!tag_record_tagged_with('user', $USER->id, $query)) { $addtaglink = '<a href="' . $CFG->wwwroot . '/tag/user.php?action=addinterest&sesskey=' . sesskey() . '&tag=' . rawurlencode($query) . '">'; $addtaglink .= get_string('addtagtomyinterests', 'tag', htmlspecialchars($query)) . '</a>'; } if (!empty($tags)) { // there are results to display!! $output .= print_heading(get_string('searchresultsfor', 'tag', htmlspecialchars($query)) . " : {$count}", '', 3, 'main', true); //print a link "Add $query to my interests" if (!empty($addtaglink)) { $output .= print_box($addtaglink, 'box', 'tag-management-box', true); } $nr_of_lis_per_ul = 6; $nr_of_uls = ceil(sizeof($tags) / $nr_of_lis_per_ul); $output .= '<ul id="tag-search-results">'; for ($i = 0; $i < $nr_of_uls; $i++) { $output .= '<li>'; foreach (array_slice($tags, $i * $nr_of_lis_per_ul, $nr_of_lis_per_ul) as $tag) { $tag_link = ' <a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $tag->id . '">' . tag_display_name($tag) . '</a>'; $output .= '•' . $tag_link . '<br/>'; } $output .= '</li>'; } $output .= '</ul>'; $output .= '<div> </div>'; // <-- small layout hack in order to look good in Firefox $output .= print_paging_bar($count, $page, $perpage, $baseurl . '&', 'page', false, true); } else { //no results were found!! $output .= print_heading(get_string('noresultsfor', 'tag', htmlspecialchars($query)), '', 3, 'main', true); //print a link "Add $query to my interests" if (!empty($addtaglink)) { $output .= print_box($addtaglink, 'box', 'tag-management-box', true); } } if ($return) { return $output; } else { echo $output; } }
//send the advanced flag through the URL so it is remembered while paging. $baseurl .= 'advanced=' . $advanced . '&'; if (!empty($search)) { $baseurl .= 'filter=1&'; } //pass variable to allow determining whether or not we are paging through results. $baseurl .= 'paging=' . $paging . '&'; print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar = 'page'); if (empty($data->listtemplate)) { notify(get_string('nolisttemplate', 'data')); data_generate_default_template($data, 'listtemplate', 0, false, false); } echo $data->listtemplateheader; data_print_template('listtemplate', $records, $data, $search, $page); echo $data->listtemplatefooter; print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar = 'page'); } } } $search = trim($search); if (empty($records)) { $records = array(); } //Advanced search form doesn't make sense for single (redirects list view) if (($maxcount || $mode == 'asearch') && $mode != 'single') { data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode); } /// If we have blocks, then print the left side here if (!empty($CFG->showblocksonmodpages)) { print_container_end(); echo '</td>';
function taoview_print_artefacts_form($artefacts, $viewtype, $tagfilter, $userfilter, $sort, $page, $perpage) { if (!empty($artefacts) && is_array($artefacts)) { print_paging_bar(count($artefacts), $page, $perpage, "taoview{$viewtype}.php?tag={$tagfilter}&filteruser={$userfilter}&sort={$sort}&"); echo "<form method=\"post\" action=\"rate.php\">"; echo "<input type='hidden' name='viewtype' value='{$viewtype}'/>"; taoview_print_artefacts($artefacts, $viewtype, $tagfilter, $userfilter, $sort, $page, $perpage); echo "</form>"; print_paging_bar(count($artefacts), $page, $perpage, "taoview{$viewtype}.php?tag={$tagfilter}&filteruser={$userfilter}&sort={$sort}&"); //now print tags cloud: taoview_print_tag_cloud($artefacts, $viewtype); } else { notify(get_string('noartefactsfound', 'local')); } }
$number = quiz_first_questionnumber($attempt->layout, $pagelist); foreach ($pagequestions as $i) { if (!isset($questions[$i])) { print_simple_box_start('center', '90%'); echo '<strong><font size="+1">' . $number . '</font></strong><br />'; notify(get_string('errormissingquestion', 'quiz', $i)); print_simple_box_end(); $number++; // Just guessing that the missing question would have lenght 1 continue; } $options->validation = QUESTION_EVENTVALIDATE === $states[$i]->event; $options->history = ($isteacher and !$attempt->preview) ? 'all' : 'graded'; // Print the question if ($i > 0) { echo "<br />\n"; } print_question($questions[$i], $states[$i], $number, $quiz, $options); $number += $questions[$i]->length; } // Print the navigation panel if required if ($numpages > 1 and !$showall) { print_paging_bar($numpages, $page, 1, 'review.php?attempt=' . $attempt->id . '&'); } // print javascript button to close the window, if necessary if (!$isteacher) { include 'attempt_close_js.php'; } if (empty($popup)) { print_footer($course); }