Merge branch 'MOODLE_22_STABLE' into install_22_STABLE
|
@ -50,8 +50,10 @@ if ($course) {
|
|||
|
||||
// security first
|
||||
require_login($course, false, $cm);
|
||||
$safeoverridesonly = false;
|
||||
if (!has_capability('moodle/role:override', $context)) {
|
||||
require_capability('moodle/role:safeoverride', $context);
|
||||
$safeoverridesonly = true;
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context($context);
|
||||
|
@ -119,7 +121,7 @@ if (empty($overridableroles[$roleid])) {
|
|||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, false);
|
||||
$overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
|
||||
$overridestable->read_submitted_permissions();
|
||||
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
|
|
|
@ -413,6 +413,8 @@ class core_calendar_renderer extends plugin_renderer_base {
|
|||
|
||||
$table = new html_table();
|
||||
$table->attributes = array('class'=>'calendarmonth calendartable');
|
||||
$time = make_timestamp($calendar->year, $calendar->month);
|
||||
$table->summary = get_string('calendarheading', 'calendar', userdate($time, get_string('strftimemonthyear')));
|
||||
$table->data = array();
|
||||
|
||||
$header = new html_table_row();
|
||||
|
|
|
@ -569,7 +569,7 @@ class comment {
|
|||
$c->format = $u->cformat;
|
||||
$c->timecreated = $u->ctimecreated;
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$u->id, 'course'=>$this->courseid));
|
||||
$c->profileurl = $url->out();
|
||||
$c->profileurl = $url->out(false);
|
||||
$c->fullname = fullname($u);
|
||||
$c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig'));
|
||||
$c->content = format_text($c->content, $c->format, $formatoptions);
|
||||
|
|
|
@ -1,63 +1,80 @@
|
|||
<?php
|
||||
// Displays the top level category or all courses
|
||||
// In editing mode, allows the admin to edit a category,
|
||||
// and rearrange courses
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
/**
|
||||
* Displays the top level category or all courses
|
||||
* In editing mode, allows the admin to edit a category,
|
||||
* and rearrange courses
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Category id
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // how many per page
|
||||
$categoryedit = optional_param('categoryedit', -1, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
$moveto = optional_param('moveto', 0, PARAM_INT);
|
||||
$resort = optional_param('resort', 0, PARAM_BOOL);
|
||||
require_once("../config.php");
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$site = get_site();
|
||||
$id = required_param('id', PARAM_INT); // Category id
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); // how many per page
|
||||
$categoryedit = optional_param('categoryedit', -1, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
$moveto = optional_param('moveto', 0, PARAM_INT);
|
||||
$resort = optional_param('resort', 0, PARAM_BOOL);
|
||||
$sesskey = optional_param('sesskey', '', PARAM_RAW);
|
||||
|
||||
if (empty($id)) {
|
||||
if (empty($id)) {
|
||||
print_error("unknowcategory");
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_category_by_id($id);
|
||||
$urlparams = array('id' => $id);
|
||||
if ($page) {
|
||||
$urlparams['page'] = $page;
|
||||
}
|
||||
if ($perpage) {
|
||||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
$PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
|
||||
navigation_node::override_active_url($PAGE->url);
|
||||
$context = $PAGE->context;
|
||||
$category = $PAGE->category;
|
||||
$PAGE->set_category_by_id($id);
|
||||
$PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
|
||||
// This is sure to be the category context
|
||||
$context = $PAGE->context;
|
||||
// And the object has been loaded for us no need for another DB call
|
||||
$category = $PAGE->category;
|
||||
|
||||
$canedit = can_edit_in_category($category->id);
|
||||
if ($canedit) {
|
||||
$canedit = can_edit_in_category($category->id);
|
||||
if ($canedit) {
|
||||
if ($categoryedit !== -1) {
|
||||
$USER->editing = $categoryedit;
|
||||
}
|
||||
require_login();
|
||||
$editingon = $PAGE->user_is_editing();
|
||||
} else {
|
||||
} else {
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
$editingon = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$category->visible) {
|
||||
if (!$category->visible) {
|
||||
require_capability('moodle/category:viewhiddencategories', $context);
|
||||
}
|
||||
}
|
||||
|
||||
// Process any category actions.
|
||||
if (has_capability('moodle/category:manage', $context)) {
|
||||
/// Resort the category if requested
|
||||
if ($resort and confirm_sesskey()) {
|
||||
$canmanage = has_capability('moodle/category:manage', $context);
|
||||
$sesskeyprovided = !empty($sesskey) && confirm_sesskey($sesskey);
|
||||
|
||||
// Process any category actions.
|
||||
if ($canmanage && $resort && $sesskeyprovided) {
|
||||
// Resort the category if requested
|
||||
if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
||||
$i = 1;
|
||||
foreach ($courses as $course) {
|
||||
|
@ -66,13 +83,14 @@
|
|||
}
|
||||
fix_course_sortorder(); // should not be needed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process any course actions.
|
||||
if ($editingon) {
|
||||
/// Move a specified course to a new category
|
||||
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
// Process any course actions.
|
||||
if ($editingon && $sesskeyprovided) {
|
||||
|
||||
// Move a specified course to a new category
|
||||
if (!empty($moveto) and $data = data_submitted()) {
|
||||
// Some courses are being moved
|
||||
// user must have category update in both cats to perform this
|
||||
require_capability('moodle/category:manage', $context);
|
||||
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveto));
|
||||
|
@ -100,8 +118,8 @@
|
|||
move_courses($courses, $data->moveto);
|
||||
}
|
||||
|
||||
/// Hide or show a course
|
||||
if ((!empty($hide) or !empty($show)) and confirm_sesskey()) {
|
||||
// Hide or show a course
|
||||
if (!empty($hide) or !empty($show)) {
|
||||
if (!empty($hide)) {
|
||||
$course = $DB->get_record('course', array('id' => $hide));
|
||||
$visible = 0;
|
||||
|
@ -113,14 +131,16 @@
|
|||
if ($course) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:visibility', $coursecontext);
|
||||
// Set the visibility of the course
|
||||
$DB->set_field('course', 'visible', $visible, array('id' => $course->id));
|
||||
$DB->set_field('course', 'visibleold', $visible, array('id' => $course->id)); // we set the old flag when user manually changes visibility of course
|
||||
// we set the old flag when user manually changes visibility of course
|
||||
$DB->set_field('course', 'visibleold', $visible, array('id' => $course->id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Move a course up or down
|
||||
if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) {
|
||||
// Move a course up or down
|
||||
if (!empty($moveup) or !empty($movedown)) {
|
||||
require_capability('moodle/category:manage', $context);
|
||||
|
||||
// Ensure the course order has continuous ordering
|
||||
|
@ -146,17 +166,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
} // End of editing stuff
|
||||
} // End of editing stuff
|
||||
|
||||
// Print headings
|
||||
$numcategories = $DB->count_records('course_categories');
|
||||
// Prepare the standard URL params for this page. We'll need them later.
|
||||
$urlparams = array('id' => $id);
|
||||
if ($page) {
|
||||
$urlparams['page'] = $page;
|
||||
}
|
||||
if ($perpage) {
|
||||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strcategories = get_string('categories');
|
||||
$strcategory = get_string('category');
|
||||
$strcourses = get_string('courses');
|
||||
|
||||
if ($editingon && can_edit_in_category()) {
|
||||
// Begin output
|
||||
if ($editingon && can_edit_in_category()) {
|
||||
// Integrate into the admin tree only if the user can edit categories at the top level,
|
||||
// otherwise the admin block does not appear to this user, and you get an error.
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
@ -170,27 +192,28 @@
|
|||
$PAGE->navbar->add($settingsnode->text, $settingsnode->action);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
} else {
|
||||
} else {
|
||||
$site = get_site();
|
||||
$PAGE->set_title("$site->shortname: $category->name");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
$PAGE->set_button(print_course_search('', true, 'navbar'));
|
||||
$PAGE->set_pagelayout('coursecategory');
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the category selector
|
||||
$displaylist = array();
|
||||
$notused = array();
|
||||
make_categories_list($displaylist, $notused);
|
||||
$displaylist = array();
|
||||
$notused = array();
|
||||
make_categories_list($displaylist, $notused);
|
||||
|
||||
echo '<div class="categorypicker">';
|
||||
$select = new single_select(new moodle_url('category.php'), 'id', $displaylist, $category->id, null, 'switchcategory');
|
||||
$select->set_label($strcategories.':');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
echo '<div class="categorypicker">';
|
||||
$select = new single_select(new moodle_url('/course/category.php'), 'id', $displaylist, $category->id, null, 'switchcategory');
|
||||
$select->set_label(get_string('categories').':');
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
|
||||
/// Print current category description
|
||||
if (!$editingon && $category->description) {
|
||||
if (!$editingon && $category->description) {
|
||||
echo $OUTPUT->box_start();
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
|
@ -202,92 +225,94 @@
|
|||
$text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null);
|
||||
echo format_text($text, $category->descriptionformat, $options);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
}
|
||||
|
||||
if ($editingon && has_capability('moodle/category:manage', $context)) {
|
||||
if ($editingon && $canmanage) {
|
||||
echo $OUTPUT->container_start('buttons');
|
||||
|
||||
// Print button to update this category
|
||||
$options = array('id' => $category->id);
|
||||
echo $OUTPUT->single_button(new moodle_url('/course/editcategory.php', $options), get_string('editcategorythis'), 'get');
|
||||
$url = new moodle_url('/course/editcategory.php', array('id' => $category->id));
|
||||
echo $OUTPUT->single_button($url, get_string('editcategorythis'), 'get');
|
||||
|
||||
// Print button for creating new categories
|
||||
$options = array('parent' => $category->id);
|
||||
echo $OUTPUT->single_button(new moodle_url('/course/editcategory.php', $options), get_string('addsubcategory'), 'get');
|
||||
$url = new moodle_url('/course/editcategory.php', array('parent' => $category->id));
|
||||
echo $OUTPUT->single_button($url, get_string('addsubcategory'), 'get');
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out all the sub-categories
|
||||
if ($subcategories = $DB->get_records('course_categories', array('parent' => $category->id), 'sortorder ASC')) {
|
||||
$firstentry = true;
|
||||
foreach ($subcategories as $subcategory) {
|
||||
if ($subcategory->visible || has_capability('moodle/category:viewhiddencategories', $context)) {
|
||||
$subcategorieswereshown = true;
|
||||
if ($firstentry) {
|
||||
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter">';
|
||||
echo '<tr><th scope="col">'.get_string('subcategories').'</th></tr>';
|
||||
echo '<tr><td style="white-space: nowrap">';
|
||||
$firstentry = false;
|
||||
}
|
||||
$catlinkcss = $subcategory->visible ? '' : ' class="dimmed" ';
|
||||
echo '<a '.$catlinkcss.' href="category.php?id='.$subcategory->id.'">'.
|
||||
format_string($subcategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $subcategory->id))).'</a><br />';
|
||||
}
|
||||
}
|
||||
if (!$firstentry) {
|
||||
echo '</td></tr></table>';
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
// Print out all the sub-categories
|
||||
// In order to view hidden subcategories the user must have the viewhiddencategories
|
||||
// capability in the current category.
|
||||
if (has_capability('moodle/category:viewhiddencategories', $context)) {
|
||||
$categorywhere = '';
|
||||
} else {
|
||||
$categorywhere = 'AND cc.visible = 1';
|
||||
}
|
||||
// We're going to preload the context for the subcategory as we know that we
|
||||
// need it later on for formatting.
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('cc.id', CONTEXT_COURSECAT, 'ctx');
|
||||
$sql = "SELECT cc.* $ctxselect
|
||||
FROM {course_categories} cc
|
||||
$ctxjoin
|
||||
WHERE cc.parent = :parentid
|
||||
$categorywhere
|
||||
ORDER BY cc.sortorder ASC";
|
||||
$subcategories = $DB->get_recordset_sql($sql, array('parentid' => $category->id));
|
||||
// Prepare a table to display the sub categories.
|
||||
$table = new html_table;
|
||||
$table->attributes = array('border' => '0', 'cellspacing' => '2', 'cellpadding' => '4', 'class' => 'generalbox boxaligncenter category_subcategories');
|
||||
$table->head = array(get_string('subcategories'));
|
||||
$table->data = array();
|
||||
$baseurl = new moodle_url('/course/category.php');
|
||||
foreach ($subcategories as $subcategory) {
|
||||
// Preload the context we will need it to format the category name shortly.
|
||||
context_instance_preload($subcategory);
|
||||
$context = get_context_instance(CONTEXT_COURSECAT, $subcategory->id);
|
||||
// Prepare the things we need to create a link to the subcategory
|
||||
$attributes = $subcategory->visible ? array() : array('class' => 'dimmed');
|
||||
$text = format_string($subcategory->name, true, array('context' => $context));
|
||||
// Add the subcategory to the table
|
||||
$baseurl->param('id', $subcategory->id);
|
||||
$table->data[] = array(html_writer::link($baseurl, $text, $attributes));
|
||||
}
|
||||
|
||||
/// Print out all the courses
|
||||
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
||||
$subcategorieswereshown = (count($table->data) > 0);
|
||||
if ($subcategorieswereshown) {
|
||||
echo html_writer::table($table);
|
||||
}
|
||||
|
||||
// Print out all the courses
|
||||
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
||||
'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible',
|
||||
$totalcount, $page*$perpage, $perpage);
|
||||
$numcourses = count($courses);
|
||||
$numcourses = count($courses);
|
||||
|
||||
if (!$courses) {
|
||||
if (!$courses) {
|
||||
if (empty($subcategorieswereshown)) {
|
||||
echo $OUTPUT->heading(get_string("nocoursesyet"));
|
||||
}
|
||||
|
||||
} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
|
||||
} else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
|
||||
echo $OUTPUT->box_start('courseboxes');
|
||||
print_courses($category);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
} else {
|
||||
} else {
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "/course/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');
|
||||
|
||||
|
||||
echo '<form id="movecourses" action="category.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<table border="0" cellspacing="2" cellpadding="4" class="generalbox boxaligncenter"><tr>';
|
||||
echo '<th class="header" scope="col">'.$strcourses.'</th>';
|
||||
echo '<th class="header" scope="col">'.get_string('courses').'</th>';
|
||||
if ($editingon) {
|
||||
echo '<th class="header" scope="col">'.$stredit.'</th>';
|
||||
echo '<th class="header" scope="col">'.$strselect.'</th>';
|
||||
echo '<th class="header" scope="col">'.get_string('edit').'</th>';
|
||||
echo '<th class="header" scope="col">'.get_string('select').'</th>';
|
||||
} else {
|
||||
echo '<th class="header" scope="col"> </th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
$count = 0;
|
||||
$abletomovecourses = false; // for now
|
||||
|
||||
|
@ -305,6 +330,7 @@
|
|||
$atlastpage = true;
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('/course/category.php', $urlparams + array('sesskey' => sesskey()));
|
||||
foreach ($courses as $acourse) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id);
|
||||
|
||||
|
@ -319,60 +345,51 @@
|
|||
if ($editingon) {
|
||||
echo '<td>';
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/edit.php',
|
||||
array('id' => $acourse->id, 'category' => $id, 'returnto' => 'category')),
|
||||
new pix_icon('t/edit', $strsettings));
|
||||
$url = new moodle_url('/course/edit.php', array('id' => $acourse->id, 'category' => $id, 'returnto' => 'category'));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/edit', get_string('settings')));
|
||||
}
|
||||
|
||||
// role assignment link
|
||||
if (has_capability('moodle/course:enrolreview', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/enrol/users.php', array('id' => $acourse->id)),
|
||||
new pix_icon('i/users', get_string('enrolledusers', 'enrol')));
|
||||
$url = new moodle_url('/enrol/users.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('i/users', get_string('enrolledusers', 'enrol')));
|
||||
}
|
||||
|
||||
if (can_delete_course($acourse->id)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/delete.php', array('id' => $acourse->id)),
|
||||
new pix_icon('t/delete', $strdelete));
|
||||
$url = new moodle_url('/course/delete.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/delete', get_string('delete')));
|
||||
}
|
||||
|
||||
// MDL-8885, users with no capability to view hidden courses, should not be able to lock themselves out
|
||||
if (has_capability('moodle/course:visibility', $coursecontext) && has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
||||
if (!empty($acourse->visible)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'hide' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/hide', $strhide));
|
||||
$url = new moodle_url($baseurl, array('hide' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/hide', get_string('hide')));
|
||||
} else {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'show' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/show', $strshow));
|
||||
$url = new moodle_url($baseurl, array('show' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/show', get_string('show')));
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/backup/backup.php', array('id' => $acourse->id)),
|
||||
new pix_icon('t/backup', $strbackup));
|
||||
$url = new moodle_url('/backup/backup.php', array('id' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/backup', get_string('backup')));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id)),
|
||||
new pix_icon('t/restore', $strrestore));
|
||||
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/restore', get_string('restore')));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/category:manage', $context)) {
|
||||
if ($canmanage) {
|
||||
if ($up) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'moveup' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/up', $strmoveup));
|
||||
$url = new moodle_url($baseurl, array('moveup' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')));
|
||||
}
|
||||
|
||||
if ($down) {
|
||||
echo $OUTPUT->action_icon(new moodle_url('/course/category.php',
|
||||
array('id' => $category->id, 'page' => $page, 'perpage' => $perpage,
|
||||
'movedown' => $acourse->id, 'sesskey' => sesskey())),
|
||||
new pix_icon('t/down', $strmovedown));
|
||||
$url = new moodle_url($baseurl, array('movedown' => $acourse->id));
|
||||
echo $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')));
|
||||
}
|
||||
$abletomovecourses = true;
|
||||
}
|
||||
|
@ -390,9 +407,9 @@
|
|||
}
|
||||
}
|
||||
if (!empty($acourse->summary)) {
|
||||
$link = new moodle_url("/course/info.php?id=$acourse->id");
|
||||
echo $OUTPUT->action_link($link, '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />',
|
||||
new popup_action('click', $link, 'courseinfo'), array('title'=>$strsummary));
|
||||
$url = new moodle_url("/course/info.php?id=$acourse->id");
|
||||
echo $OUTPUT->action_link($url, '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />',
|
||||
new popup_action('click', $url, 'courseinfo'), array('title'=>get_string('summary')));
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
|
@ -414,32 +431,26 @@
|
|||
echo '</table>';
|
||||
echo '</div></form>';
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="buttons">';
|
||||
if (has_capability('moodle/category:manage', $context) and $numcourses > 1) {
|
||||
/// Print button to re-sort courses by name
|
||||
unset($options);
|
||||
$options['id'] = $category->id;
|
||||
$options['resort'] = 'name';
|
||||
$options['sesskey'] = sesskey();
|
||||
echo $OUTPUT->single_button(new moodle_url('category.php', $options), get_string('resortcoursesbyname'), 'get');
|
||||
}
|
||||
echo '<div class="buttons">';
|
||||
if ($canmanage and $numcourses > 1) {
|
||||
// Print button to re-sort courses by name
|
||||
$url = new moodle_url('/course/category.php', array('id' => $category->id, 'resort' => 'name', 'sesskey' => sesskey()));
|
||||
echo $OUTPUT->single_button($url, get_string('resortcoursesbyname'), 'get');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:create', $context)) {
|
||||
/// Print button to create a new course
|
||||
unset($options);
|
||||
$options['category'] = $category->id;
|
||||
$options['returnto'] = 'category';
|
||||
echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get');
|
||||
}
|
||||
if (has_capability('moodle/course:create', $context)) {
|
||||
// Print button to create a new course
|
||||
$url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'category'));
|
||||
echo $OUTPUT->single_button($url, get_string('addnewcourse'), 'get');
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->defaultrequestcategory) {
|
||||
if (!empty($CFG->enablecourserequests) && $category->id == $CFG->defaultrequestcategory) {
|
||||
print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_course_search();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
print_course_search();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Page for creating or editing course category name/parent/description.
|
||||
* When called with an id parameter, edits the category with that id.
|
||||
* Otherwise it creates a new category with default parent from the parent
|
||||
* parameter, which may be 0.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
* @copyright 2007 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
|
@ -108,6 +128,21 @@ if ($mform->is_cancelled()) {
|
|||
redirect('category.php?id='.$newcategory->id.'&categoryedit=on');
|
||||
}
|
||||
|
||||
// Unfortunately the navigation never generates correctly for this page because technically
|
||||
// this page doesn't actually exist on the navigation you get here through the course
|
||||
// management page.
|
||||
try {
|
||||
// First up we'll try to make the course management page active seeing as that is
|
||||
// where the user thinks they are.
|
||||
// The big prolem here is that the course management page is a common page
|
||||
// for both editing users and common users.
|
||||
$PAGE->settingsnav->get('root')->get('courses')->get('coursemgmt')->make_active();
|
||||
} catch (Exception $ex) {
|
||||
// Failing that we'll override the URL, not as accurate and chances are things
|
||||
// won't be 100% correct all the time but should work most times.
|
||||
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryedit' => 'on')));
|
||||
}
|
||||
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
|
|
@ -177,6 +177,7 @@ if (!$categories = get_categories()) { /// No category yet!
|
|||
$tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
|
||||
mark_context_dirty('/'.SYSCONTEXTID);
|
||||
fix_course_sortorder(); // Required to build course_categories.depth and .path.
|
||||
set_config('defaultrequestcategory', $tempcat->id);
|
||||
}
|
||||
|
||||
/// Move a category to a new parent if required
|
||||
|
|
|
@ -15,10 +15,19 @@
|
|||
$blocklist = optional_param('blocklist', 0, PARAM_INT);
|
||||
$modulelist= optional_param('modulelist', '', PARAM_PLUGIN);
|
||||
|
||||
$PAGE->set_url('/course/search.php', compact('search', 'page', 'perpage', 'blocklist', 'modulelist', 'edit'));
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$search = trim(strip_tags($search)); // trim & clean raw searched string
|
||||
// List of minimum capabilities which user need to have for editing/moving course
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
|
||||
// List of category id's in which current user has course:create and category:manage capability.
|
||||
$usercatlist = array();
|
||||
|
||||
// List of parent category id's
|
||||
$catparentlist = array();
|
||||
|
||||
//Populate usercatlist with list of category id's with required capabilities.
|
||||
make_categories_list($usercatlist, $catparentlist, $capabilities);
|
||||
|
||||
$search = trim(strip_tags($search)); // trim & clean raw searched string
|
||||
if ($search) {
|
||||
$searchterms = explode(" ", $search); // Search for words independently
|
||||
foreach ($searchterms as $key => $searchterm) {
|
||||
|
@ -32,7 +41,7 @@
|
|||
$site = get_site();
|
||||
|
||||
$urlparams = array();
|
||||
foreach (array('search', 'page', 'blocklist', 'modulelist') as $param) {
|
||||
foreach (array('search', 'page', 'blocklist', 'modulelist', 'edit') as $param) {
|
||||
if (!empty($$param)) {
|
||||
$urlparams[$param] = $$param;
|
||||
}
|
||||
|
@ -41,24 +50,30 @@
|
|||
$urlparams['perpage'] = $perpage;
|
||||
}
|
||||
$PAGE->set_url('/course/search.php', $urlparams);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
|
||||
if (can_edit_in_category()) {
|
||||
//Editing is possible if user have system or category level create and manage capability
|
||||
if (can_edit_in_category() || !empty($usercatlist)) {
|
||||
if ($edit !== -1) {
|
||||
$USER->editing = $edit;
|
||||
}
|
||||
$adminediting = $PAGE->user_is_editing();
|
||||
|
||||
// Set perpage if user can edit in category
|
||||
if ($perpage != 99999) {
|
||||
$perpage = 30;
|
||||
}
|
||||
} else {
|
||||
$adminediting = false;
|
||||
}
|
||||
|
||||
/// Editing functions
|
||||
if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/course:visibility', context_system::instance())) {
|
||||
/// Hide or show a course
|
||||
if ($hide or $show and confirm_sesskey()) {
|
||||
if ($hide) {
|
||||
|
@ -74,11 +89,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM)) && ($perpage != 99999)) {
|
||||
$perpage = 30;
|
||||
}
|
||||
|
||||
$displaylist = array();
|
||||
$parentlist = array();
|
||||
make_categories_list($displaylist, $parentlist);
|
||||
|
@ -94,7 +104,7 @@
|
|||
$strfrontpage = get_string('frontpage', 'admin');
|
||||
$strnovalidcourses = get_string('novalidcourses');
|
||||
|
||||
if (empty($search) and empty($blocklist) and empty($modulelist)) {
|
||||
if (empty($search) and empty($blocklist) and empty($modulelist) and empty($moveto) and ($edit != -1)) {
|
||||
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
||||
$PAGE->navbar->add($strsearch);
|
||||
$PAGE->set_title("$site->fullname : $strsearch");
|
||||
|
@ -114,18 +124,28 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $data->moveto);
|
||||
if (!$destcategory = $DB->get_record("course_categories", array("id" => $moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $moveto);
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
//User should have manage and create capablity on destination category.
|
||||
require_capability('moodle/category:manage', context_coursecat::instance($moveto));
|
||||
require_capability('moodle/course:create', context_coursecat::instance($moveto));
|
||||
|
||||
foreach ( $data as $key => $value ) {
|
||||
if (preg_match('/^c\d+$/', $key)) {
|
||||
array_push($courses, substr($key, 1));
|
||||
$courseid = substr($key, 1);
|
||||
// user must have category:manage and course:create capability for the course to be moved.
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
foreach ($capabilities as $capability) {
|
||||
require_capability($capability, $coursecontext);
|
||||
array_push($courses, $courseid);
|
||||
}
|
||||
}
|
||||
move_courses($courses, $data->moveto);
|
||||
}
|
||||
move_courses($courses, $moveto);
|
||||
}
|
||||
|
||||
// get list of courses containing blocks if required
|
||||
|
@ -148,9 +168,7 @@
|
|||
foreach ($courses as $course) {
|
||||
$courses[$course->id] = $course;
|
||||
}
|
||||
}
|
||||
// get list of courses containing modules if required
|
||||
elseif (!empty($modulelist) and confirm_sesskey()) {
|
||||
} elseif (!empty($modulelist) and confirm_sesskey()) { // get list of courses containing modules
|
||||
$modulename = $modulelist;
|
||||
$sql = "SELECT DISTINCT c.id FROM {".$modulelist."} module, {course} c"
|
||||
." WHERE module.course=c.id";
|
||||
|
@ -172,18 +190,14 @@
|
|||
else {
|
||||
$totalcount = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (!empty($searchterm)) { //Donot do search for empty search request.
|
||||
$courses = get_courses_search($searchterms, "fullname ASC",
|
||||
$page, $perpage, $totalcount);
|
||||
}
|
||||
|
||||
$searchform = print_course_search($search, true, "navbar");
|
||||
|
||||
if (!empty($courses) && has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$searchform = '';
|
||||
// not sure if this capability is the best here
|
||||
if (has_capability('moodle/category:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
//Turn editing should be visible if user have system or category level capability
|
||||
if (!empty($courses) && (can_edit_in_category() || !empty($usercatlist))) {
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$string = get_string("turneditingoff");
|
||||
$edit = "off";
|
||||
|
@ -191,15 +205,11 @@
|
|||
$string = get_string("turneditingon");
|
||||
$edit = "on";
|
||||
}
|
||||
|
||||
$aurl = new moodle_url("$CFG->wwwroot/course/search.php", array(
|
||||
'edit' => $edit,
|
||||
'sesskey' => sesskey(),
|
||||
'search' => $search,
|
||||
'page' => $page,
|
||||
'perpage' => $perpage));
|
||||
$params = array_merge($urlparams, array('sesskey' => sesskey(), 'edit' => $edit));
|
||||
$aurl = new moodle_url("$CFG->wwwroot/course/search.php", $params);
|
||||
$searchform = $OUTPUT->single_button($aurl, $string, 'get');
|
||||
}
|
||||
} else {
|
||||
$searchform = print_course_search($search, true, "navbar");
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
||||
|
@ -228,25 +238,30 @@
|
|||
|
||||
print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink);
|
||||
|
||||
if (!$adminediting) {
|
||||
// Show list of courses
|
||||
if (!$adminediting) { //Not editing mode
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// front page don't belong to any category and block can exist.
|
||||
if ($course->category > 0) {
|
||||
$course->summary .= "<br /><p class=\"category\">";
|
||||
$course->summary .= "$strcategory: <a href=\"category.php?id=$course->category\">";
|
||||
$course->summary .= $displaylist[$course->category];
|
||||
$course->summary .= "</a></p>";
|
||||
}
|
||||
print_course($course, $search);
|
||||
echo $OUTPUT->spacer(array('height'=>5, 'width'=>5, 'br'=>true)); // should be done with CSS instead
|
||||
}
|
||||
} else {
|
||||
/// Show editing UI.
|
||||
} else { //editing mode
|
||||
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
|
||||
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"page\" value=\"$page\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"perpage\" value=\"$perpage\" /></div>\n";
|
||||
if (!empty($modulelist) and confirm_sesskey()) {
|
||||
echo "<input type=\"hidden\" name=\"modulelist\" value=\"$modulelist\" /></div>\n";
|
||||
} else if (!empty($blocklist) and confirm_sesskey()) {
|
||||
echo "<input type=\"hidden\" name=\"blocklist\" value=\"$blocklist\" /></div>\n";
|
||||
}
|
||||
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\" class=\"generalbox boxaligncenter\">\n<tr>\n";
|
||||
echo "<th scope=\"col\">$strcourses</th>\n";
|
||||
echo "<th scope=\"col\">$strcategory</th>\n";
|
||||
|
@ -255,7 +270,7 @@
|
|||
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
|
||||
|
||||
|
@ -278,9 +293,8 @@
|
|||
echo "<td>".$displaylist[$course->category]."</td>\n";
|
||||
echo "<td>\n";
|
||||
|
||||
// this is ok since this will get inherited from course category context
|
||||
// if it is set
|
||||
if (has_capability('moodle/category:manage', $coursecontext)) {
|
||||
// If user has all required capabilities to move course then show selectable checkbox
|
||||
if (has_all_capabilities($capabilities, $coursecontext)) {
|
||||
echo "<input type=\"checkbox\" name=\"c$course->id\" />\n";
|
||||
} else {
|
||||
echo "<input type=\"checkbox\" name=\"c$course->id\" disabled=\"disabled\" />\n";
|
||||
|
@ -338,7 +352,8 @@
|
|||
echo "<br />";
|
||||
echo "<input type=\"button\" onclick=\"checkall()\" value=\"$strselectall\" />\n";
|
||||
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
|
||||
echo html_writer::select($displaylist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
|
||||
//Select box should only show categories in which user has min capability to move course.
|
||||
echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo "</td>\n</tr>\n";
|
||||
echo "</table>\n</form>";
|
||||
|
@ -384,7 +399,7 @@
|
|||
$defaultperpage = 10;
|
||||
//If user has course:create or category:manage capability the show 30 records.
|
||||
$capabilities = array('moodle/course:create', 'moodle/category:manage');
|
||||
if (has_any_capability($capabilities, get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_any_capability($capabilities, context_system::instance())) {
|
||||
$defaultperpage = 30;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ require_once $CFG->dirroot.'/grade/report/grader/lib.php';
|
|||
|
||||
$courseid = required_param('id', PARAM_INT); // course id
|
||||
$page = optional_param('page', 0, PARAM_INT); // active page
|
||||
$perpageurl = optional_param('perpage', 0, PARAM_INT);
|
||||
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
|
||||
|
||||
$sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
|
||||
|
@ -127,12 +126,6 @@ if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/gr
|
|||
$warnings = array();
|
||||
}
|
||||
|
||||
|
||||
// Override perpage if set in URL
|
||||
if ($perpageurl) {
|
||||
$report->user_prefs['studentsperpage'] = $perpageurl;
|
||||
}
|
||||
|
||||
// final grades MUST be loaded after the processing
|
||||
$report->load_users();
|
||||
$numusers = $report->get_numusers();
|
||||
|
@ -162,6 +155,7 @@ if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback')
|
|||
echo '<input type="hidden" value="'.s($courseid).'" name="id" />';
|
||||
echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
|
||||
echo '<input type="hidden" value="grader" name="report"/>';
|
||||
echo '<input type="hidden" value="'.$page.'" name="page"/>';
|
||||
echo $reporthtml;
|
||||
echo '<div class="submit"><input type="submit" value="'.s(get_string('update')).'" /></div>';
|
||||
echo '</div></form>';
|
||||
|
|
|
@ -135,12 +135,11 @@ class grade_report_grader extends grade_report {
|
|||
|
||||
$this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
|
||||
|
||||
$studentsperpage = $this->get_pref('studentsperpage');
|
||||
if (!empty($studentsperpage)) {
|
||||
$this->baseurl->params(array('perpage' => $studentsperpage, 'page' => $this->page));
|
||||
if (!empty($this->page)) {
|
||||
$this->baseurl->params(array('page' => $this->page));
|
||||
}
|
||||
|
||||
$this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid, 'perpage' => $studentsperpage));
|
||||
$this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid));
|
||||
|
||||
$this->setup_groups();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ $cancel = optional_param('cancel', false, PARAM_BOOL);
|
|||
$group = $DB->get_record('groups', array('id'=>$groupid), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id'=>$group->courseid), '*', MUST_EXIST);
|
||||
|
||||
$PAGE->set_url('/groups/members.php', array('id'=>$groupid));
|
||||
$PAGE->set_url('/group/members.php', array('group'=>$groupid));
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
require_login($course);
|
||||
|
|
|
@ -54,6 +54,8 @@ $string['blogentriesbyuseraboutmodule'] = 'Blog entries about this {$a->mod} by
|
|||
$string['blogentrybyuser'] = 'Blog entry by {$a}';
|
||||
$string['blogpreferences'] = 'Blog preferences';
|
||||
$string['blogs'] = 'Blogs';
|
||||
$string['blogscourse'] = 'Course blogs';
|
||||
$string['blogssite'] = 'Site blogs';
|
||||
$string['blogtags'] = 'Blog tags';
|
||||
$string['cannotviewcourseblog'] = 'You do not have the required permissions to view blogs in this course';
|
||||
$string['cannotviewcourseorgroupblog'] = 'You do not have the required permissions to view blogs in this course/group';
|
||||
|
|
|
@ -128,6 +128,7 @@ $string['settings'] = 'Settings';
|
|||
$string['settingssaved'] = 'Your settings have been saved';
|
||||
$string['showmessagewindow'] = 'Popup window on new message';
|
||||
$string['strftimedaydatetime'] = '%A, %d %B %Y, %I:%M %p';
|
||||
$string['thisconversation'] = 'this conversation';
|
||||
$string['timenosee'] = 'Minutes since I was last seen online';
|
||||
$string['timesent'] = 'Time sent';
|
||||
$string['touserdoesntexist'] = 'You can not send a message to a user id ({$a}) that doesn\'t exist';
|
||||
|
|
|
@ -46,7 +46,11 @@ foreach ($files as $fsfile) {
|
|||
// does not exist
|
||||
continue;
|
||||
}
|
||||
if (strpos($jsfile, $CFG->dirroot . DIRECTORY_SEPARATOR) !== 0) {
|
||||
if ($CFG->dirroot === '/') {
|
||||
// Some shared hosting sites serve files directly from '/',
|
||||
// this is NOT supported, but at least allow JS when showing
|
||||
// errors and warnings.
|
||||
} else if (strpos($jsfile, $CFG->dirroot . DIRECTORY_SEPARATOR) !== 0) {
|
||||
// hackers - not in dirroot
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1061,7 +1061,10 @@ class global_navigation extends navigation_node {
|
|||
|
||||
$mycourses = enrol_get_my_courses(NULL, 'visible DESC,sortorder ASC', $limit);
|
||||
$showallcourses = (count($mycourses) == 0 || !empty($CFG->navshowallcourses));
|
||||
$showcategories = ($showallcourses && $this->show_categories());
|
||||
// When checking if we are to show categories there is an additional override.
|
||||
// If the user is viewing a category then we will load it regardless of settings.
|
||||
// to ensure that the navigation is consistent.
|
||||
$showcategories = $this->page->context->contextlevel == CONTEXT_COURSECAT || ($showallcourses && $this->show_categories());
|
||||
$issite = ($this->page->course->id == SITEID);
|
||||
$ismycourse = (array_key_exists($this->page->course->id, $mycourses));
|
||||
|
||||
|
@ -1086,7 +1089,6 @@ class global_navigation extends navigation_node {
|
|||
|
||||
$canviewcourseprofile = true;
|
||||
|
||||
if (!$issite) {
|
||||
// Next load context specific content into the navigation
|
||||
switch ($this->page->context->contextlevel) {
|
||||
case CONTEXT_SYSTEM :
|
||||
|
@ -1098,9 +1100,17 @@ class global_navigation extends navigation_node {
|
|||
// This has already been loaded we just need to map the variable
|
||||
$coursenode = $frontpagecourse;
|
||||
$this->load_all_categories($this->page->context->instanceid, $showcategories);
|
||||
if (array_key_exists($this->page->context->instanceid, $this->addedcategories)) {
|
||||
$this->addedcategories[$this->page->context->instanceid]->make_active();
|
||||
}
|
||||
break;
|
||||
case CONTEXT_BLOCK :
|
||||
case CONTEXT_COURSE :
|
||||
if ($issite) {
|
||||
// If it is the front page course, or a block on it then
|
||||
// everything has already been loaded.
|
||||
break;
|
||||
}
|
||||
// Load the course associated with the page into the navigation
|
||||
$course = $this->page->course;
|
||||
if ($showcategories && !$ismycourse) {
|
||||
|
@ -1149,6 +1159,18 @@ class global_navigation extends navigation_node {
|
|||
}
|
||||
break;
|
||||
case CONTEXT_MODULE :
|
||||
if ($issite) {
|
||||
// If this is the site course then most information will have
|
||||
// already been loaded.
|
||||
// However we need to check if there is more content that can
|
||||
// yet be loaded for the specific module instance.
|
||||
$activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY);
|
||||
if ($activitynode) {
|
||||
$this->load_activity($this->page->cm, $this->page->course, $activitynode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$course = $this->page->course;
|
||||
$cm = $this->page->cm;
|
||||
|
||||
|
@ -1234,6 +1256,11 @@ class global_navigation extends navigation_node {
|
|||
}
|
||||
break;
|
||||
case CONTEXT_USER :
|
||||
if ($issite) {
|
||||
// The users profile information etc is already loaded
|
||||
// for the front page.
|
||||
break;
|
||||
}
|
||||
$course = $this->page->course;
|
||||
if ($showcategories && !$ismycourse) {
|
||||
$this->load_all_categories($course->category, $showcategories);
|
||||
|
@ -1258,17 +1285,6 @@ class global_navigation extends navigation_node {
|
|||
$sections = $this->load_course_sections($course, $coursenode);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// We need to check if the user is viewing a front page module.
|
||||
// If so then there is potentially more content to load yet for that
|
||||
// module.
|
||||
if ($this->page->context->contextlevel == CONTEXT_MODULE) {
|
||||
$activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY);
|
||||
if ($activitynode) {
|
||||
$this->load_activity($this->page->cm, $this->page->course, $activitynode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$limit = 20;
|
||||
if (!empty($CFG->navcourselimit)) {
|
||||
|
@ -1347,7 +1363,9 @@ class global_navigation extends navigation_node {
|
|||
protected function show_categories() {
|
||||
global $CFG, $DB;
|
||||
if ($this->showcategories === null) {
|
||||
$this->showcategories = !empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1;
|
||||
$show = $this->page->context->contextlevel == CONTEXT_COURSECAT;
|
||||
$show = $show || (!empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1);
|
||||
$this->showcategories = $show;
|
||||
}
|
||||
return $this->showcategories;
|
||||
}
|
||||
|
@ -2274,7 +2292,7 @@ class global_navigation extends navigation_node {
|
|||
if (($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
|
||||
and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
|
||||
$participants->add(get_string('blogs','blog'), $blogsurls->out());
|
||||
$participants->add(get_string('blogscourse','blog'), $blogsurls->out());
|
||||
}
|
||||
if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) {
|
||||
$participants->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$course->id)));
|
||||
|
@ -2339,7 +2357,7 @@ class global_navigation extends navigation_node {
|
|||
and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
|
||||
and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
|
||||
$coursenode->add(get_string('blogs','blog'), $blogsurls->out());
|
||||
$coursenode->add(get_string('blogssite','blog'), $blogsurls->out());
|
||||
}
|
||||
|
||||
// Notes
|
||||
|
|
|
@ -441,6 +441,12 @@ class theme_config {
|
|||
if (is_readable($rendererfile)) {
|
||||
// may contain core and plugin renderers and renderer factory
|
||||
include_once($rendererfile);
|
||||
} else {
|
||||
// check if renderers.php file is missnamed renderer.php
|
||||
if (is_readable($this->dir.'/renderer.php')) {
|
||||
debugging('Developer hint: '.$this->dir.'/renderer.php should be renamed to ' . $this->dir."/renderers.php.
|
||||
See: http://docs.moodle.org/dev/Output_renderers#Theme_renderers.", DEBUG_DEVELOPER);
|
||||
}
|
||||
}
|
||||
|
||||
// cascade all layouts properly
|
||||
|
|
|
@ -408,7 +408,7 @@ class page_requirements_manager {
|
|||
array('saving', 'repository'), array('search', 'repository'), array('searching', 'repository'), array('size', 'repository'),
|
||||
array('submit', 'repository'), array('sync', 'repository'), array('title', 'repository'), array('upload', 'repository'),
|
||||
array('uploading', 'repository'), array('xhtmlerror', 'repository'),
|
||||
array('cancel'), array('chooselicense', 'repository'), array('author', 'repository'),
|
||||
array('cancel'), array('chooselicense', 'repository'), array('author', 'repository'),array('next', 'moodle'),
|
||||
array('ok', 'moodle'), array('error', 'moodle'), array('info', 'moodle'), array('norepositoriesavailable', 'repository'), array('norepositoriesexternalavailable', 'repository'),
|
||||
array('nofilesattached', 'repository'), array('filepicker', 'repository'),
|
||||
array('nofilesavailable', 'repository'), array('overwrite', 'repository'),
|
||||
|
|
|
@ -359,14 +359,14 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
|
|||
|
||||
/// First of all, search for reasons to switch to standard SQL generation
|
||||
/// Only mysql are supported for now
|
||||
if ($DB->get_db_family() != 'mysql') {
|
||||
if ($DB->get_dbfamily() != 'mysql') {
|
||||
return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
|
||||
$userfirstnamefield, $userlastnamefield, $timefield, $instancefield);
|
||||
}
|
||||
|
||||
/// Some languages don't have "word separators" and MySQL FULLTEXT doesn't perform well with them, so
|
||||
/// switch to standard SQL search generation
|
||||
if ($DB->get_db_family() == 'mysql') {
|
||||
if ($DB->get_dbfamily() == 'mysql') {
|
||||
$nonseparatedlangs = array('ja', 'th', 'zh_cn', 'zh_tw');
|
||||
if (in_array(current_language(), $nonseparatedlangs)) {
|
||||
return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield,
|
||||
|
@ -445,12 +445,12 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
|
|||
$text_sql_string .= ', ' . $metafield;
|
||||
}
|
||||
/// Begin with the AGAINST clause
|
||||
$text_sql_string .= ') AGAINST (' . "'";
|
||||
$text_sql_string .= ') AGAINST (';
|
||||
/// Add the search terms
|
||||
$text_sql_string .= ':sgt'.$p;
|
||||
$params['sgt'.$p++] = trim($datasearch_clause);
|
||||
/// Close AGAINST clause
|
||||
$text_sql_string .= "' IN BOOLEAN MODE)";
|
||||
$text_sql_string .= " IN BOOLEAN MODE)";
|
||||
}
|
||||
}
|
||||
/// Now add the metasearch_clause
|
||||
|
@ -463,12 +463,12 @@ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfie
|
|||
}
|
||||
$text_sql_string .= 'MATCH (' . $metafield;
|
||||
/// Begin with the AGAINST clause
|
||||
$text_sql_string .= ') AGAINST (' . "'";
|
||||
$text_sql_string .= ') AGAINST (';
|
||||
/// Add the search terms
|
||||
$text_sql_string .= ':sgt'.$p;
|
||||
$params['sgt'.$p++] = trim($metasearch_clause);
|
||||
/// Close AGAINST clause
|
||||
$text_sql_string .= "' IN BOOLEAN MODE)";
|
||||
$text_sql_string .= " IN BOOLEAN MODE)";
|
||||
}
|
||||
}
|
||||
/// Finally add the non-text conditions
|
||||
|
|
|
@ -31,12 +31,9 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults
|
|||
$disableall = optional_param('disableall', 0, PARAM_BOOL); //disable all of this user's notifications
|
||||
|
||||
$url = new moodle_url('/message/edit.php');
|
||||
if ($userid !== $USER->id) {
|
||||
$url->param('id', $userid);
|
||||
}
|
||||
if ($course != SITEID) {
|
||||
$url->param('course', $course);
|
||||
}
|
||||
$url->param('id', $userid);
|
||||
$url->param('course', $course);
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id' => $course))) {
|
||||
|
|
|
@ -816,6 +816,12 @@ function message_print_recent_conversations($user=null, $showicontext=false) {
|
|||
|
||||
$conversations = message_get_recent_conversations($user);
|
||||
|
||||
// Attach context url information to create the "View this conversation" type links
|
||||
foreach($conversations as $conversation) {
|
||||
$conversation->contexturl = new moodle_url("/message/index.php?user2={$conversation->id}");
|
||||
$conversation->contexturlname = get_string('thisconversation', 'message');
|
||||
}
|
||||
|
||||
$showotheruser = true;
|
||||
message_print_recent_messages_table($conversations, $user, $showotheruser, $showicontext);
|
||||
}
|
||||
|
|
|
@ -349,10 +349,10 @@ if ($do_show == 'edit') {
|
|||
echo '<span class="feedback_item_command_toggle">';
|
||||
if ($feedbackitem->required == 1) {
|
||||
$buttontitle = get_string('switch_item_to_not_required', 'feedback');
|
||||
$buttonimg = 'pics/required.gif';
|
||||
$buttonimg = $OUTPUT->pix_url('required', 'feedback');
|
||||
} else {
|
||||
$buttontitle = get_string('switch_item_to_required', 'feedback');
|
||||
$buttonimg = 'pics/notrequired.gif';
|
||||
$buttonimg = $OUTPUT->pix_url('notrequired', 'feedback');
|
||||
}
|
||||
$urlparams = array('switchitemrequired'=>$feedbackitem->id);
|
||||
$requiredurl = new moodle_url($url, $urlparams);
|
||||
|
|
|
@ -216,6 +216,7 @@ class feedback_item_multichoice extends feedback_item_base {
|
|||
}
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
global $OUTPUT;
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
|
@ -237,7 +238,7 @@ class feedback_item_multichoice extends feedback_item_base {
|
|||
$pixnr = 0;
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = "pics/$intvalue.gif";
|
||||
$pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
|
||||
$pixnr++;
|
||||
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
|
||||
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
|
||||
|
|
|
@ -192,6 +192,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
|||
}
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
global $OUTPUT;
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
|
@ -212,7 +213,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
|||
$avg = 0.0;
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = "pics/$intvalue.gif";
|
||||
$pix = $OUTPUT->pix_url('multichoice/' . $intvalue, 'feedback');
|
||||
$pixnr++;
|
||||
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
|
||||
|
||||
|
|
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 217 B |
|
@ -58,6 +58,7 @@ if ($mform->is_cancelled()) {
|
|||
|
||||
} else if ($formdata = $mform->get_data()) {
|
||||
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0);
|
||||
$DB->set_field('folder', 'revision', $folder->revision+1, array('id'=>$folder->id));
|
||||
redirect(new moodle_url('/mod/folder/view.php', array('id'=>$cm->id)));
|
||||
}
|
||||
|
||||
|
|
|
@ -2882,7 +2882,12 @@ function glossary_comment_validate($comment_param) {
|
|||
if (!$record = $DB->get_record('glossary_entries', array('id'=>$comment_param->itemid))) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$record->glossaryid))) {
|
||||
if ($record->sourceglossaryid && $record->sourceglossaryid == $comment_param->cm->instance) {
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$record->sourceglossaryid));
|
||||
} else {
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$record->glossaryid));
|
||||
}
|
||||
if (!$glossary) {
|
||||
throw new comment_exception('invalidid', 'data');
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id'=>$glossary->course))) {
|
||||
|
|
|
@ -145,8 +145,7 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
$answers = $this->get_used_answers();
|
||||
$ncorrect = 0;
|
||||
$nhits = 0;
|
||||
$correctresponse = '';
|
||||
$wrongresponse = '';
|
||||
$responses = array();
|
||||
$correctanswerid = 0;
|
||||
$wronganswerid = 0;
|
||||
// store student's answers for displaying on feedback page
|
||||
|
@ -155,6 +154,9 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
foreach ($studentanswers as $answerid) {
|
||||
if ($answerid == $answer->id) {
|
||||
$result->studentanswer .= '<br />'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
|
||||
if (trim(strip_tags($answer->response))) {
|
||||
$responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,10 +184,6 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
if ($correctanswerid == 0) {
|
||||
$correctanswerid = $answer->id;
|
||||
}
|
||||
// ...also save any response from the correct answers...
|
||||
if (trim(strip_tags($answer->response))) {
|
||||
$correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
|
||||
}
|
||||
} else {
|
||||
// save the first jumpto page id, may be needed!...
|
||||
if (!isset($wrongpageid)) {
|
||||
|
@ -196,10 +194,6 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
if ($wronganswerid == 0) {
|
||||
$wronganswerid = $answer->id;
|
||||
}
|
||||
// ...and from the incorrect ones, don't know which to use at this stage
|
||||
if (trim(strip_tags($answer->response))) {
|
||||
$wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -220,10 +214,6 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
if ($correctanswerid == 0) {
|
||||
$correctanswerid = $answer->id;
|
||||
}
|
||||
// ...also save any response from the correct answers...
|
||||
if (trim(strip_tags($answer->response))) {
|
||||
$correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
|
||||
}
|
||||
} else {
|
||||
// save the first jumpto page id, may be needed!...
|
||||
if (!isset($wrongpageid)) {
|
||||
|
@ -234,20 +224,16 @@ class lesson_page_type_multichoice extends lesson_page {
|
|||
if ($wronganswerid == 0) {
|
||||
$wronganswerid = $answer->id;
|
||||
}
|
||||
// ...and from the incorrect ones, don't know which to use at this stage
|
||||
if (trim(strip_tags($answer->response))) {
|
||||
$wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((count($studentanswers) == $ncorrect) and ($nhits == $ncorrect)) {
|
||||
$result->correctanswer = true;
|
||||
$result->response = $correctresponse;
|
||||
$result->response = implode('<br />', $responses);
|
||||
$result->newpageid = $correctpageid;
|
||||
$result->answerid = $correctanswerid;
|
||||
} else {
|
||||
$result->response = $wrongresponse;
|
||||
$result->response = implode('<br />', $responses);
|
||||
$result->newpageid = $wrongpageid;
|
||||
$result->answerid = $wronganswerid;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,29 @@ M.mod_quiz.nav.init = function(Y) {
|
|||
|
||||
var form = Y.one('#responseform');
|
||||
if (form) {
|
||||
function find_enabled_submit() {
|
||||
// This is rather inelegant, but the CSS3 selector
|
||||
// return form.one('input[type=submit]:enabled');
|
||||
// does not work in IE7, 8 or 9 for me.
|
||||
var enabledsubmit = null;
|
||||
form.all('input[type=submit]').each(function(submit) {
|
||||
if (!enabledsubmit && !submit.get('disabled')) {
|
||||
enabledsubmit = submit;
|
||||
}
|
||||
});
|
||||
return enabledsubmit;
|
||||
}
|
||||
|
||||
function nav_to_page(pageno) {
|
||||
Y.one('#followingpage').set('value', pageno);
|
||||
|
||||
// Automatically submit the form. We do it this strange way because just
|
||||
// calling form.submit() does not run the form's submit event handlers.
|
||||
var submit = find_enabled_submit();
|
||||
submit.set('name', '');
|
||||
submit.getDOMNode().click();
|
||||
};
|
||||
|
||||
Y.delegate('click', function(e) {
|
||||
if (this.hasClass('thispage')) {
|
||||
return;
|
||||
|
@ -157,22 +180,20 @@ M.mod_quiz.nav.init = function(Y) {
|
|||
} else {
|
||||
pageno = 0;
|
||||
}
|
||||
Y.one('#followingpage').set('value', pageno);
|
||||
|
||||
var questionidmatch = this.get('href').match(/#q(\d+)/);
|
||||
if (questionidmatch) {
|
||||
form.set('action', form.get('action') + '#q' + questionidmatch[1]);
|
||||
}
|
||||
|
||||
form.submit();
|
||||
nav_to_page(pageno);
|
||||
}, document.body, '.qnbutton');
|
||||
}
|
||||
|
||||
if (Y.one('a.endtestlink')) {
|
||||
Y.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
Y.one('#followingpage').set('value', -1);
|
||||
Y.one('#responseform').submit();
|
||||
nav_to_page(-1);
|
||||
}, 'a.endtestlink');
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,8 @@ require_login($course->id, true, $cm);
|
|||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:managewiki', $context);
|
||||
add_to_log($course->id, "wiki", "admin", "admin.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
add_to_log($course->id, "wiki", "admin", "admin.php?pageid=".$page->id, $page->id, $cm->id);
|
||||
|
||||
//Delete page if a page ID to delete was supplied
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
|
|
|
@ -59,7 +59,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
|
|||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
add_to_log($course->id, 'wiki', 'comments', 'comments.php?id=' . $cm->id, $wiki->id);
|
||||
add_to_log($course->id, 'wiki', 'comments', "comments.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
/// Print the page header
|
||||
$wikipage = new page_wiki_comments($wiki, $subwiki, $cm);
|
||||
|
|
|
@ -66,8 +66,6 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
|
|||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
add_to_log($course->id, 'createpage', 'createpage', 'view.php?id=' . $cm->id, $wiki->id);
|
||||
|
||||
$wikipage = new page_wiki_create($wiki, $subwiki, $cm);
|
||||
|
||||
if (!empty($swid)) {
|
||||
|
@ -80,22 +78,25 @@ if (!empty($swid)) {
|
|||
$wikipage->set_uid($uid);
|
||||
}
|
||||
|
||||
if (!empty($title)) {
|
||||
$wikipage->set_title($title);
|
||||
} else {
|
||||
$wikipage->set_title(get_string('newpage', 'wiki'));
|
||||
if (empty($title)) {
|
||||
$title = get_string('newpage', 'wiki');
|
||||
}
|
||||
$wikipage->set_title($title);
|
||||
|
||||
// set page action, and initialise moodle form
|
||||
$wikipage->set_action($action);
|
||||
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
$wikipage->create_page($title);
|
||||
$newpageid = $wikipage->create_page($title);
|
||||
add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=".$newpageid, $newpageid, $cm->id);
|
||||
redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid='.$newpageid);
|
||||
break;
|
||||
case 'new':
|
||||
if ((int)$wiki->forceformat == 1 && !empty($title)) {
|
||||
$wikipage->create_page($title);
|
||||
$newpageid = $wikipage->create_page($title);
|
||||
add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=".$newpageid, $newpageid, $cm->id);
|
||||
redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid='.$newpageid);
|
||||
} else {
|
||||
// create link from moodle navigation block without pagetitle
|
||||
$wikipage->print_header();
|
||||
|
|
|
@ -192,7 +192,7 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
|||
array("flags","meta","lastmodified");
|
||||
*/
|
||||
case "GETALL":
|
||||
switch ($DB->get_db_family()) {
|
||||
switch ($DB->get_dbfamily()) {
|
||||
case 'postgres':
|
||||
// All but the latest version eliminated by DISTINCT
|
||||
// ON (pagename)
|
||||
|
|
|
@ -67,13 +67,14 @@ if ($compare >= $comparewith) {
|
|||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
add_to_log($course->id, "wiki", "diff", "diff.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
$wikipage = new page_wiki_diff($wiki, $subwiki, $cm);
|
||||
|
||||
$wikipage->set_page($page);
|
||||
$wikipage->set_comparison($compare, $comparewith);
|
||||
|
||||
add_to_log($course->id, "wiki", "diff", "diff.php?pageid=".$pageid."&comparewith=".$comparewith."&compare=".$compare, $pageid, $cm->id);
|
||||
|
||||
$wikipage->print_header();
|
||||
|
||||
$wikipage->print_content();
|
||||
|
|
|
@ -77,8 +77,6 @@ require_login($course, true, $cm);
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:editpage', $context);
|
||||
|
||||
add_to_log($course->id, 'wiki', 'edit', "edit.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
if ($option == get_string('save', 'wiki')) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error(get_string('invalidsesskey', 'wiki'));
|
||||
|
@ -87,6 +85,7 @@ if ($option == get_string('save', 'wiki')) {
|
|||
$wikipage->set_page($page);
|
||||
$wikipage->set_newcontent($newcontent);
|
||||
$wikipage->set_upload(true);
|
||||
add_to_log($course->id, 'wiki', 'edit', "view.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
} else {
|
||||
if ($option == get_string('preview')) {
|
||||
if (!confirm_sesskey()) {
|
||||
|
|
|
@ -61,7 +61,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
|
|||
require_login($course->id, true, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:viewpage', $context);
|
||||
add_to_log($course->id, 'wiki', 'history', 'history.php?id=' . $cm->id, $wiki->id);
|
||||
add_to_log($course->id, 'wiki', 'history', "history.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
/// Print the page header
|
||||
$wikipage = new page_wiki_history($wiki, $subwiki, $cm);
|
||||
|
|
|
@ -45,7 +45,7 @@ require_login($course->id, true);
|
|||
$PAGE->set_pagelayout('incourse');
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
add_to_log($course->id, 'wiki', 'view all', "index.php?id=$course->id", "");
|
||||
add_to_log($course->id, 'wiki', 'view', "index.php?id=".$id, "");
|
||||
|
||||
/// Get all required stringswiki
|
||||
$strwikis = get_string("modulenameplural", "wiki");
|
||||
|
|
|
@ -94,12 +94,12 @@ if ($action == 'delete') {
|
|||
|
||||
if ($action == 'edit') {
|
||||
$comm->set_action($action, $id, $content);
|
||||
|
||||
} else {
|
||||
$action = 'add';
|
||||
$comm->set_action($action, 0, $content);
|
||||
}
|
||||
}
|
||||
add_to_log($course->id, 'wiki', 'comment', "comments.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
$comm->print_header();
|
||||
$comm->print_content();
|
||||
|
|
|
@ -71,8 +71,6 @@ require_login($course->id, false, $cm);
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:editpage', $context);
|
||||
|
||||
//add_to_log($course->id, "wiki", "lock", "lock.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
$wikipage = new page_wiki_lock($wiki, $subwiki, $cm);
|
||||
$wikipage->set_page($page);
|
||||
|
||||
|
|
|
@ -56,13 +56,11 @@ if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
|
|||
require_login($course->id, true, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:viewpage', $context);
|
||||
add_to_log($course->id, "wiki", "map", "map.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
/// Print page header
|
||||
|
||||
/// Finish the page
|
||||
$wikipage = new page_wiki_map($wiki, $subwiki, $cm);
|
||||
add_to_log($course->id, "wiki", "map", "map.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
// Print page header
|
||||
$wikipage->set_view($option);
|
||||
$wikipage->set_page($page);
|
||||
$wikipage->print_header();
|
||||
|
|
|
@ -67,8 +67,6 @@ require_login($course->id, true, $cm);
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:overridelock', $context);
|
||||
|
||||
add_to_log($course->id, "wiki", "overridelocks", "overridelocks.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error(get_string('invalidsesskey', 'wiki'));
|
||||
}
|
||||
|
@ -79,6 +77,7 @@ $wikipage->set_page($page);
|
|||
if (!empty($section)) {
|
||||
$wikipage->set_section($sectioncontent, $section);
|
||||
}
|
||||
add_to_log($course->id, "wiki", "overridelocks", "view.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
$wikipage->print_header();
|
||||
|
||||
|
|
|
@ -935,11 +935,14 @@ class page_wiki_create extends page_wiki {
|
|||
$this->subwiki = wiki_get_subwiki($swid);
|
||||
}
|
||||
if ($data) {
|
||||
$this->set_title($data->pagetitle);
|
||||
$id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
|
||||
} else {
|
||||
$this->set_title($pagetitle);
|
||||
$id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
|
||||
}
|
||||
redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $id);
|
||||
$this->page = $id;
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,10 @@ require_login($course->id, true, $cm);
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:viewpage', $context);
|
||||
|
||||
add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=$pageid", "$wiki->id");
|
||||
|
||||
$wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
|
||||
|
||||
$wikipage->set_page($page);
|
||||
add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
|
|
@ -60,8 +60,6 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
|
|||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
add_to_log($course->id, "restore", "restore", "view.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
if ($confirm) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error(get_string('invalidsesskey', 'wiki'));
|
||||
|
@ -77,6 +75,7 @@ if ($confirm) {
|
|||
$wikipage->set_versionid($versionid);
|
||||
|
||||
}
|
||||
add_to_log($course->id, "wiki", "restore", "view.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
|
|
@ -269,8 +269,6 @@ require_login($course, true, $cm);
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:viewpage', $context);
|
||||
|
||||
add_to_log($course->id, 'wiki', 'view', 'view.php?id=' . $cm->id, $wiki->id);
|
||||
|
||||
// Update 'viewed' state if required by completion system
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
$completion = new completion_info($course);
|
||||
|
@ -294,6 +292,14 @@ if ($id) {
|
|||
$wikipage->set_gid($currentgroup);
|
||||
$wikipage->set_page($page);
|
||||
|
||||
if($pageid) {
|
||||
add_to_log($course->id, 'wiki', 'view', "view.php?pageid=".$pageid, $pageid, $cm->id);
|
||||
} else if($id) {
|
||||
add_to_log($course->id, 'wiki', 'view', "view.php?id=".$id, $id, $cm->id);
|
||||
} else if($wid && $title) {
|
||||
add_to_log($course->id, 'wiki', 'view', "view.php?wid=".$wid."&title=".$title, $wid, $cm->id);
|
||||
}
|
||||
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
||||
|
|
|
@ -59,14 +59,15 @@ if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
|
|||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
add_to_log($course->id, "wiki", "history", "history.php?id=$cm->id", "$wiki->id");
|
||||
|
||||
/// Print the page header
|
||||
$wikipage = new page_wiki_viewversion($wiki, $subwiki, $cm);
|
||||
|
||||
$wikipage->set_page($page);
|
||||
$wikipage->set_versionid($versionid);
|
||||
|
||||
add_to_log($course->id, "wiki", "history", "viewversion.php?pageid=".$pageid."&versionid=".$versionid, $pageid, $cm->id);
|
||||
|
||||
// Print the page header
|
||||
$wikipage->print_header();
|
||||
$wikipage->print_content();
|
||||
|
||||
|
|
|
@ -1430,9 +1430,7 @@ class question_bank_view {
|
|||
if ($question->id == $this->lastchangedid) {
|
||||
$classes[] ='highlight';
|
||||
}
|
||||
if (!empty($this->extrarows)) {
|
||||
$classes[] = 'r' . ($rowcount % 2);
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
|
|
@ -884,10 +884,10 @@ class question_attempt {
|
|||
case self::PARAM_MARK:
|
||||
// Special case to work around PARAM_NUMBER converting '' to 0.
|
||||
$mark = $this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata);
|
||||
if ($mark === '') {
|
||||
if ($mark === '' || is_null($mark)) {
|
||||
return $mark;
|
||||
} else {
|
||||
return $this->get_submitted_var($name, PARAM_NUMBER, $postdata);
|
||||
return clean_param(str_replace(',', '.', $mark), PARAM_NUMBER);
|
||||
}
|
||||
|
||||
case self::PARAM_FILES:
|
||||
|
|
|
@ -123,6 +123,16 @@ class question_attempt_test extends UnitTestCase {
|
|||
'name', question_attempt::PARAM_MARK, array('name' => '123')));
|
||||
}
|
||||
|
||||
public function test_get_submitted_var_param_mark_number_uk_decimal() {
|
||||
$this->assertIdentical(123.45, $this->qa->get_submitted_var(
|
||||
'name', question_attempt::PARAM_MARK, array('name' => '123.45')));
|
||||
}
|
||||
|
||||
public function test_get_submitted_var_param_mark_number_eu_decimal() {
|
||||
$this->assertIdentical(123.45, $this->qa->get_submitted_var(
|
||||
'name', question_attempt::PARAM_MARK, array('name' => '123,45')));
|
||||
}
|
||||
|
||||
public function test_get_submitted_var_param_mark_invalid() {
|
||||
$this->assertIdentical(0.0, $this->qa->get_submitted_var(
|
||||
'name', question_attempt::PARAM_MARK, array('name' => 'frog')));
|
||||
|
|
|
@ -44,7 +44,7 @@ question_bank = {
|
|||
question_bank.firstcheckbox = document.getElementById(firstcbid);
|
||||
|
||||
// Add the event handler.
|
||||
YAHOO.util.Event.addListener(question_bank.headercheckbox, 'change', question_bank.header_checkbox_click);
|
||||
YAHOO.util.Event.addListener(question_bank.headercheckbox, 'click', question_bank.header_checkbox_click);
|
||||
},
|
||||
|
||||
header_checkbox_click: function() {
|
||||
|
|
|
@ -149,7 +149,11 @@ M.core_filepicker.init = function(Y, options) {
|
|||
// error checking
|
||||
if (data && data.error) {
|
||||
scope.print_msg(data.error, 'error');
|
||||
scope.list();
|
||||
if (args.onerror) {
|
||||
args.onerror(id,data,p);
|
||||
} else {
|
||||
Y.one(panel_id).set('innerHTML', '');
|
||||
}
|
||||
return;
|
||||
} else if (data && data.event) {
|
||||
switch (data.event) {
|
||||
|
@ -678,6 +682,9 @@ M.core_filepicker.init = function(Y, options) {
|
|||
client_id: client_id,
|
||||
repository_id: repository_id,
|
||||
'params': params,
|
||||
onerror: function(id, obj, args) {
|
||||
scope.view_files();
|
||||
},
|
||||
callback: function(id, obj, args) {
|
||||
if (scope.options.editor_target && scope.options.env=='editor') {
|
||||
scope.options.editor_target.value=obj.url;
|
||||
|
@ -1188,6 +1195,9 @@ M.core_filepicker.init = function(Y, options) {
|
|||
params: {'savepath':scope.options.savepath},
|
||||
repository_id: scope.active_repo.id,
|
||||
form: {id: id, upload:true},
|
||||
onerror: function(id, o, args) {
|
||||
scope.create_upload_form(data);
|
||||
},
|
||||
callback: function(id, o, args) {
|
||||
if (scope.options.editor_target&&scope.options.env=='editor') {
|
||||
scope.options.editor_target.value=o.url;
|
||||
|
@ -1370,15 +1380,21 @@ M.core_filepicker.init = function(Y, options) {
|
|||
var r = this.active_repo;
|
||||
var str = '';
|
||||
var action = '';
|
||||
if(r.pages > 1) {
|
||||
var lastpage = r.pages;
|
||||
var lastpagetext = r.pages;
|
||||
if (r.pages == -1) {
|
||||
lastpage = r.page + 1;
|
||||
lastpagetext = M.str.moodle.next;
|
||||
}
|
||||
if (lastpage > 1) {
|
||||
str += '<div class="fp-paging" id="paging-'+html_id+'-'+client_id+'">';
|
||||
str += this.get_page_button(1)+'1</a> ';
|
||||
|
||||
var span = 5;
|
||||
var ex = (span-1)/2;
|
||||
|
||||
if (r.page+ex>=r.pages) {
|
||||
var max = r.pages;
|
||||
if (r.page+ex>=lastpage) {
|
||||
var max = lastpage;
|
||||
} else {
|
||||
if (r.page<span) {
|
||||
var max = span;
|
||||
|
@ -1405,11 +1421,11 @@ M.core_filepicker.init = function(Y, options) {
|
|||
}
|
||||
|
||||
// won't display upper boundary
|
||||
if (max==r.pages) {
|
||||
str += this.get_page_button(r.pages)+r.pages+'</a>';
|
||||
if (max==lastpage) {
|
||||
str += this.get_page_button(lastpage)+lastpagetext+'</a>';
|
||||
} else {
|
||||
str += this.get_page_button(max)+max+'</a>';
|
||||
str += ' ... '+this.get_page_button(r.pages)+r.pages+'</a>';
|
||||
str += ' ... '+this.get_page_button(lastpage)+lastpagetext+'</a>';
|
||||
}
|
||||
str += '</div>';
|
||||
}
|
||||
|
|
|
@ -206,9 +206,23 @@ case 'sign':
|
|||
}
|
||||
}
|
||||
if (!empty($list['page'])) {
|
||||
// TODO: need a better solution
|
||||
$pagingurl = new moodle_url("$CFG->httpswwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid");
|
||||
echo $OUTPUT->paging_bar($list['total'], $list['page'] - 1, $list['perpage'], $pagingurl);
|
||||
// TODO MDL-28482: need a better solution
|
||||
// paging_bar is not a good option because it starts page numbering from 0 and
|
||||
// repositories number pages starting from 1.
|
||||
$pagingurl = new moodle_url("$CFG->httpswwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid&sesskey=". sesskey());
|
||||
if (!isset($list['perpage']) && !isset($list['total'])) {
|
||||
$list['perpage'] = 10; // instead of setting perpage&total we use number of pages, the result is the same
|
||||
}
|
||||
if (empty($list['total'])) {
|
||||
if ($list['pages'] == -1) {
|
||||
$total = ($list['page'] + 2) * $list['perpage'];
|
||||
} else {
|
||||
$total = $list['pages'] * $list['perpage'];
|
||||
}
|
||||
} else {
|
||||
$total = $list['total'];
|
||||
}
|
||||
echo $OUTPUT->paging_bar($total, $list['page'], $list['perpage'], $pagingurl);
|
||||
}
|
||||
echo '<table>';
|
||||
foreach ($list['list'] as $item) {
|
||||
|
|
|
@ -66,7 +66,7 @@ if (empty($_POST) && !empty($action)) {
|
|||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
$err->error = get_string('invalidsesskey');
|
||||
$err->error = get_string('invalidsesskey', 'error');
|
||||
die(json_encode($err));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,41 @@ require_once('wikimedia.php');
|
|||
|
||||
class repository_wikimedia extends repository {
|
||||
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
|
||||
global $SESSION;
|
||||
parent::__construct($repositoryid, $context, $options);
|
||||
$this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
|
||||
if (empty($this->keyword)) {
|
||||
$this->keyword = optional_param('s', '', PARAM_RAW);
|
||||
}
|
||||
$sess_keyword = 'wikimedia_'.$this->id.'_keyword';
|
||||
if (empty($this->keyword) && optional_param('page', '', PARAM_RAW)) {
|
||||
// This is the request of another page for the last search, retrieve the cached keyword
|
||||
if (isset($SESSION->{$sess_keyword})) {
|
||||
$this->keyword = $SESSION->{$sess_keyword};
|
||||
}
|
||||
} else if (!empty($this->keyword)) {
|
||||
// save the search keyword in the session so we can retrieve it later
|
||||
$SESSION->{$sess_keyword} = $this->keyword;
|
||||
}
|
||||
}
|
||||
public function get_listing($path = '', $page = '') {
|
||||
$client = new wikimedia;
|
||||
$list = array();
|
||||
$list['list'] = $client->search_images($this->keyword);
|
||||
$list['page'] = (int)$page;
|
||||
if ($list['page'] < 1) {
|
||||
$list['page'] = 1;
|
||||
}
|
||||
$list['list'] = $client->search_images($this->keyword, $list['page'] - 1);
|
||||
$list['nologin'] = true;
|
||||
$list['norefresh'] = true;
|
||||
$list['nosearch'] = true;
|
||||
if (!empty($list['list'])) {
|
||||
$list['pages'] = -1; // means we don't know exactly how many pages there are but we can always jump to the next page
|
||||
} else if ($list['page'] > 1) {
|
||||
$list['pages'] = $list['page']; // no images available on this page, this is the last page
|
||||
} else {
|
||||
$list['pages'] = 0; // no paging
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
// login
|
||||
|
@ -57,10 +81,24 @@ class repository_wikimedia extends repository {
|
|||
$keyword->type = 'text';
|
||||
$keyword->name = 'wikimedia_keyword';
|
||||
$keyword->value = '';
|
||||
|
||||
if ($this->options['ajax']) {
|
||||
$form = array();
|
||||
$form['login'] = array($keyword);
|
||||
$form['nologin'] = true;
|
||||
$form['norefresh'] = true;
|
||||
$form['nosearch'] = true;
|
||||
$form['allowcaching'] = true; // indicates that login form can be cached in filepicker.js
|
||||
return $form;
|
||||
} else {
|
||||
echo <<<EOD
|
||||
<table>
|
||||
<tr>
|
||||
<td>{$keyword->label}</td><td><input name="{$keyword->name}" type="text" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" />
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
//search
|
||||
// if this plugin support global search, if this function return
|
||||
|
|
|
@ -141,13 +141,14 @@ class wikimedia {
|
|||
* @param string $keyword
|
||||
* @return array
|
||||
*/
|
||||
public function search_images($keyword) {
|
||||
public function search_images($keyword, $page = 0) {
|
||||
$files_array = array();
|
||||
$this->_param['action'] = 'query';
|
||||
$this->_param['generator'] = 'search';
|
||||
$this->_param['gsrsearch'] = $keyword;
|
||||
$this->_param['gsrnamespace'] = WIKIMEDIA_FILE_NS;
|
||||
$this->_param['gsrlimit'] = WIKIMEDIA_THUMBS_PER_PAGE;
|
||||
$this->_param['gsroffset'] = $page * WIKIMEDIA_THUMBS_PER_PAGE;
|
||||
$this->_param['prop'] = 'imageinfo';
|
||||
$this->_param['iiprop'] = 'url|dimensions|mime';
|
||||
$this->_param['iiurlwidth'] = WIKIMEDIA_IMAGE_SIDE_LENGTH;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
|
||||
class repository_youtube extends repository {
|
||||
/** @var int maximum number of thumbs per page */
|
||||
const YOUTUBE_THUMBS_PER_PAGE = 27;
|
||||
|
||||
/**
|
||||
* Youtube plugin constructor
|
||||
|
@ -35,9 +37,6 @@ class repository_youtube extends repository {
|
|||
* @param array $options
|
||||
*/
|
||||
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
|
||||
$this->start =1;
|
||||
$this->max = 27;
|
||||
$this->sort = optional_param('youtube_sort', 'relevance', PARAM_TEXT);
|
||||
parent::__construct($repositoryid, $context, $options);
|
||||
}
|
||||
|
||||
|
@ -50,11 +49,40 @@ class repository_youtube extends repository {
|
|||
* @param string $search_text
|
||||
* @return array
|
||||
*/
|
||||
public function search($search_text) {
|
||||
public function search($search_text, $page) {
|
||||
global $SESSION;
|
||||
$sort = optional_param('youtube_sort', '', PARAM_TEXT);
|
||||
$sess_keyword = 'youtube_'.$this->id.'_keyword';
|
||||
$sess_sort = 'youtube_'.$this->id.'_sort';
|
||||
|
||||
// This is the request of another page for the last search, retrieve the cached keyword and sort
|
||||
if ($page && !$search_text && isset($SESSION->{$sess_keyword})) {
|
||||
$search_text = $SESSION->{$sess_keyword};
|
||||
}
|
||||
if ($page && !$sort && isset($SESSION->{$sess_sort})) {
|
||||
$sort = $SESSION->{$sess_sort};
|
||||
}
|
||||
if (!$sort) {
|
||||
$sort = 'relevance'; // default
|
||||
}
|
||||
|
||||
// Save this search in session
|
||||
$SESSION->{$sess_keyword} = $search_text;
|
||||
$SESSION->{$sess_sort} = $sort;
|
||||
|
||||
$this->keyword = $search_text;
|
||||
$ret = array();
|
||||
$ret['nologin'] = true;
|
||||
$ret['list'] = $this->_get_collection($search_text, $this->start, $this->max, $this->sort);
|
||||
$ret['page'] = (int)$page;
|
||||
if ($ret['page'] < 1) {
|
||||
$ret['page'] = 1;
|
||||
}
|
||||
$start = ($ret['page'] - 1) * self::YOUTUBE_THUMBS_PER_PAGE + 1;
|
||||
$max = self::YOUTUBE_THUMBS_PER_PAGE;
|
||||
$ret['list'] = $this->_get_collection($search_text, $start, $max, $sort);
|
||||
$ret['norefresh'] = true;
|
||||
$ret['nosearch'] = true;
|
||||
$ret['pages'] = -1;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -142,6 +170,7 @@ class repository_youtube extends repository {
|
|||
$ret['login'] = array($search, $sort);
|
||||
$ret['login_btn_label'] = get_string('search');
|
||||
$ret['login_btn_action'] = 'search';
|
||||
$ret['allowcaching'] = true; // indicates that login form can be cached in filepicker.js
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,3 +123,6 @@
|
|||
|
||||
#page-course-index.dir-rtl .category .image {padding-left: 5px; padding-right: 0px;}
|
||||
#page-course-index.dir-rtl .indentation {padding-left: 0px;padding-right: 30px;}
|
||||
|
||||
table.category_subcategories {margin-bottom:1em;}
|
||||
table.category_subcategories td {white-space: nowrap;}
|
|
@ -23,7 +23,7 @@ if ($hascustommenu) {
|
|||
if (!empty($PAGE->theme->settings->tagline)) {
|
||||
$tagline = $PAGE->theme->settings->tagline;
|
||||
} else {
|
||||
$tagline = "Another Moodle Theme";
|
||||
$tagline = '<!-- There was no custom tagline set -->';
|
||||
}
|
||||
|
||||
if (!empty($PAGE->theme->settings->footertext)) {
|
||||
|
|
|
@ -4,35 +4,34 @@ defined('MOODLE_INTERNAL') || die;
|
|||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
// link color setting
|
||||
$name = 'theme_fusion/linkcolor';
|
||||
$title = get_string('linkcolor','theme_fusion');
|
||||
$description = get_string('linkcolordesc', 'theme_fusion');
|
||||
$default = '#2d83d5';
|
||||
$previewconfig = NULL;
|
||||
$setting = new admin_setting_configcolourpicker($name, $title, $description, $default, $previewconfig);
|
||||
$settings->add($setting);
|
||||
// link color setting
|
||||
$name = 'theme_fusion/linkcolor';
|
||||
$title = get_string('linkcolor','theme_fusion');
|
||||
$description = get_string('linkcolordesc', 'theme_fusion');
|
||||
$default = '#2d83d5';
|
||||
$previewconfig = NULL;
|
||||
$setting = new admin_setting_configcolourpicker($name, $title, $description, $default, $previewconfig);
|
||||
$settings->add($setting);
|
||||
|
||||
// Tag line setting
|
||||
$name = 'theme_fusion/tagline';
|
||||
$title = get_string('tagline','theme_fusion');
|
||||
$description = get_string('taglinedesc', 'theme_fusion');
|
||||
$setting = new admin_setting_configtext($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
|
||||
// Tag line setting
|
||||
$name = 'theme_fusion/tagline';
|
||||
$title = get_string('tagline','theme_fusion');
|
||||
$description = get_string('taglinedesc', 'theme_fusion');
|
||||
$setting = new admin_setting_configtextarea($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
// Foot note setting
|
||||
$name = 'theme_fusion/footertext';
|
||||
$title = get_string('footertext','theme_fusion');
|
||||
$description = get_string('footertextdesc', 'theme_fusion');
|
||||
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
|
||||
// Foot note setting
|
||||
$name = 'theme_fusion/footertext';
|
||||
$title = get_string('footertext','theme_fusion');
|
||||
$description = get_string('footertextdesc', 'theme_fusion');
|
||||
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
|
||||
// Custom CSS file
|
||||
$name = 'theme_fusion/customcss';
|
||||
$title = get_string('customcss','theme_fusion');
|
||||
$description = get_string('customcssdesc', 'theme_fusion');
|
||||
$setting = new admin_setting_configtextarea($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
// Custom CSS file
|
||||
$name = 'theme_fusion/customcss';
|
||||
$title = get_string('customcss','theme_fusion');
|
||||
$description = get_string('customcssdesc', 'theme_fusion');
|
||||
$setting = new admin_setting_configtextarea($name, $title, $description, '');
|
||||
$settings->add($setting);
|
||||
|
||||
}
|
|
@ -30,10 +30,10 @@
|
|||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2011120502.01; // 20111205 = branching date YYYYMMDD - do not modify!
|
||||
$version = 2011120502.02; // 20111205 = branching date YYYYMMDD - do not modify!
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
$release = '2.2.2+ (Build: 20120315)'; // Human-friendly version name
|
||||
$release = '2.2.2+ (Build: 20120323)'; // Human-friendly version name
|
||||
|
||||
$maturity = MATURITY_STABLE; // this version's maturity level
|
||||
|
|