Skip to content

Commit

Permalink
Merge branch '31830-26' of git://github.com/samhemelryk/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	theme/bootstrapbase/style/moodle.css
  • Loading branch information
Damyon Wiese committed Oct 7, 2013
2 parents 4d00df4 + 7fd307b commit d4770c9
Show file tree
Hide file tree
Showing 60 changed files with 13,816 additions and 1,285 deletions.
28 changes: 26 additions & 2 deletions admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

$contextid = required_param('contextid', PARAM_INT);
$roleid = optional_param('roleid', 0, PARAM_INT);
$returnto = optional_param('return', null, PARAM_ALPHANUMEXT);

list($context, $course, $cm) = get_context_info_array($contextid);

Expand Down Expand Up @@ -181,6 +182,9 @@

// Print the form.
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
if ($returnto !== null) {
$assignurl->param('return', $returnto);
}
?>
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
Expand Down Expand Up @@ -225,10 +229,17 @@
// Print a form to swap roles, and a link back to the all roles list.
echo '<div class="backlink">';

$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
$newroleurl = new moodle_url($PAGE->url);
if ($returnto !== null) {
$newroleurl->param('return', $returnto);
}
$select = new single_select($newroleurl, 'roleid', $nameswithcounts, $roleid, null);
$select->label = get_string('assignanotherrole', 'core_role');
echo $OUTPUT->render($select);
$backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
if ($returnto !== null) {
$backurl->param('return', $returnto);
}
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
echo '</div>';

Expand Down Expand Up @@ -266,6 +277,9 @@
}
} else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
if ($returnto !== null) {
$assignurl->param('return', $returnto);
}
$roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
} else {
$roleholdernames[$roleid] = '';
Expand All @@ -286,6 +300,9 @@
foreach ($assignableroles as $roleid => $rolename) {
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
if ($returnto !== null) {
$assignurl->param('return', $returnto);
}
$row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
$description, $assigncounts[$roleid]);
if ($showroleholders) {
Expand All @@ -297,8 +314,15 @@
echo html_writer::table($table);

if ($context->contextlevel > CONTEXT_USER) {

if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
} else {
$url = $context->get_url();
}

echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}
}
Expand Down
10 changes: 9 additions & 1 deletion admin/roles/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
$allow = optional_param('allow', 0, PARAM_BOOL);
$unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
$prohibit = optional_param('prohibit', 0, PARAM_BOOL);
$return = optional_param('return', null, PARAM_ALPHANUMEXT);

list($context, $course, $cm) = get_context_info_array($contextid);

Expand Down Expand Up @@ -201,8 +202,15 @@


if ($context->contextlevel > CONTEXT_USER) {

if ($context->contextlevel === CONTEXT_COURSECAT && $return === 'management') {
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
} else {
$url = $context->get_url();
}

echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}

Expand Down
68 changes: 46 additions & 22 deletions admin/settings/courses.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
<?php

// This file defines settingpages and externalpages under the "courses" category

if ($hassiteconfig
or has_capability('moodle/backup:backupcourse', $systemcontext)
or has_capability('moodle/category:manage', $systemcontext)
or has_capability('moodle/course:create', $systemcontext)
or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page

$ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/manage.php',
array('moodle/category:manage', 'moodle/course:create')));
// 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/>.

/**
* This file defines settingpages and externalpages under the "courses" category
*
* @package core
* @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$capabilities = array(
'moodle/backup:backupcourse',
'moodle/category:manage',
'moodle/course:create',
'moodle/site:approvecourse'
);
if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
// Speedup for non-admins, add all caps used on this page.
$ADMIN->add('courses',
new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
$CFG->wwwroot . '/course/management.php',
array('moodle/category:manage', 'moodle/course:create')
)
);
$ADMIN->add('courses',
new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
new moodle_url('/course/editcategory.php', array('parent' => 0)),
array('moodle/category:manage')
)
);

// Course Default Settings Page.
// NOTE: these settings must be applied after all other settings because they depend on them.


// Main course settings.
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
require_once($CFG->dirroot.'/course/lib.php');
Expand All @@ -25,7 +56,6 @@
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
1, $choices));


// Course format.
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));

Expand Down Expand Up @@ -55,7 +85,6 @@
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));


// Appearance.
$temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));

Expand All @@ -73,7 +102,6 @@
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
array(0 => new lang_string('no'), 1 => new lang_string('yes'))));


// Files and uploads.
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));

Expand All @@ -92,13 +120,11 @@
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
new lang_string('coursehelpmaximumupload'), key($choices), $choices));


// Completion tracking.
$temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));


// Groups.
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
$choices = array();
Expand All @@ -119,13 +145,13 @@
$temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
$ADMIN->add('courses', $temp);

/// Pending course requests.
// Pending course requests.
if (!empty($CFG->enablecourserequests)) {
$ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
}

// Add a category for backups
// Add a category for backups.
$ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));

// Create a page for general backups configuration and defaults.
Expand Down Expand Up @@ -239,10 +265,8 @@
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));


//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));

$ADMIN->add('backups', $temp);

} // end of speedup
}
4 changes: 2 additions & 2 deletions admin/tool/behat/tests/behat/data_generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Feature: Set up contextual data for tests
And I follow "Cat 3"
And I should see "Course 1"
And I should see "Course 2"
And I select "Cat 1 / Cat 2" from "Course categories:"
And I follow "Cat 2"
And I should see "No courses in this category"
And I select "Miscellaneous" from "Course categories:"
And I follow "Miscellaneous"
And I should see "Course 3"

@javascript
Expand Down
111 changes: 111 additions & 0 deletions course/ajax/management.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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/>.

/**
* Performs course category management ajax actions.
*
* Please note functions may throw exceptions, please ensure your JS handles them as well as the outcome objects.
*
* @package core_course
* @copyright 2013 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('AJAX_SCRIPT', true);

require_once('../../config.php');
require_once($CFG->dirroot.'/lib/coursecatlib.php');
require_once($CFG->dirroot.'/course/lib.php');

$action = required_param('action', PARAM_ALPHA);
require_sesskey(); // Gotta have the sesskey.
require_login(); // Gotta be logged in (of course).

// Prepare an outcome object. We always use this.
$outcome = new stdClass;
$outcome->error = false;
$outcome->outcome = false;

echo $OUTPUT->header();

switch ($action) {
case 'movecourseup' :
$courseid = required_param('courseid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_course_change_sortorder_up_one_by_record($courseid);
break;
case 'movecoursedown' :
$courseid = required_param('courseid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_course_change_sortorder_down_one_by_record($courseid);
break;
case 'movecourseintocategory':
$courseid = required_param('courseid', PARAM_INT);
$categoryid = required_param('categoryid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::move_courses_into_category($categoryid, $courseid);
break;
case 'movecourseafter' :
$courseid = required_param('courseid', PARAM_INT);
$moveaftercourseid = required_param('moveafter', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_course_change_sortorder_after_course(
$courseid, $moveaftercourseid);
break;
case 'hidecourse' :
$courseid = required_param('courseid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_course_hide_by_record($courseid);
break;
case 'showcourse' :
$courseid = required_param('courseid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_course_show_by_record($courseid);
break;
case 'movecategoryup' :
$categoryid = required_param('categoryid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_category_change_sortorder_up_one_by_id($categoryid);
break;
case 'movecategorydown' :
$categoryid = required_param('categoryid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_category_change_sortorder_down_one_by_id($categoryid);
break;
case 'hidecategory' :
$categoryid = required_param('categoryid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_category_hide_by_id($categoryid);
$outcome->categoryvisibility = \core_course\management\helper::get_category_children_visibility($categoryid);
$outcome->coursevisibility = \core_course\management\helper::get_category_courses_visibility($categoryid);
break;
case 'showcategory' :
$categoryid = required_param('categoryid', PARAM_INT);
$outcome->outcome = \core_course\management\helper::action_category_show_by_id($categoryid);
$outcome->categoryvisibility = \core_course\management\helper::get_category_children_visibility($categoryid);
$outcome->coursevisibility = \core_course\management\helper::get_category_courses_visibility($categoryid);
break;
case 'getsubcategorieshtml' :
$categoryid = required_param('categoryid', PARAM_INT);
/* @var core_course_management_renderer $renderer */
$renderer = $PAGE->get_renderer('core_course', 'management');
$outcome->html = html_writer::start_tag('ul', array('class' => 'ml'));
$coursecat = coursecat::get($categoryid);
foreach ($coursecat->get_children() as $subcat) {
$outcome->html .= $renderer->category_listitem($subcat, array(), $subcat->get_children_count());
}
$outcome->html .= html_writer::end_tag('ul');
$outcome->outcome = true;
break;
}

echo json_encode($outcome);
echo $OUTPUT->footer();
// Thats all folks.
// Don't ever even consider putting anything after this. It just wouldn't make sense.
// But you already knew that, you smart developer you.
exit;
5 changes: 2 additions & 3 deletions course/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
/**
* Displays the top level category or all courses
*
* @package core
* @subpackage course
* @package core_coure
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once("../config.php");

$categoryid = required_param('id', PARAM_INT); // Category id
$categoryid = required_param('id', PARAM_INT); // Category id.

debugging('Please use URL /course/index.php?categoryid=XXX instead of /course/category.php?id=XXX', DEBUG_DEVELOPER);

Expand Down
Loading

0 comments on commit d4770c9

Please sign in to comment.