Skip to content
Permalink
Browse files

Merge branch 'MDL-8307-master' of git://github.com/FMCorz/moodle

  • Loading branch information...
stronk7 committed Sep 10, 2012
2 parents 2c248bd + 59b9a14 commit 5e51915c8051947431cb3ae57b3c3e6f1a4fb942
Showing with 56 additions and 8 deletions.
  1. +1 −0 admin/settings/courses.php
  2. +13 −1 course/lib.php
  3. +13 −2 course/pending.php
  4. +10 −1 course/request_form.php
  5. +2 −0 lang/en/admin.php
  6. +3 −2 lib/db/install.xml
  7. +13 −1 lib/db/upgrade.php
  8. +1 −1 version.php
@@ -85,6 +85,7 @@
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('requestcategoryselection', new lang_string('requestcategoryselection', 'admin'), new lang_string('configrequestcategoryselection', 'admin'), 0));
$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);
@@ -4144,6 +4144,11 @@ public static function create($data) {
global $USER, $DB, $CFG;
$data->requester = $USER->id;
// Setting the default category is none set.
if (empty($data->category) || empty($CFG->requestcategoryselection)) {
$data->category = $CFG->defaultrequestcategory;
}
// Summary is a required field so copy the text over
$data->summary = $data->summary_editor['text'];
$data->summaryformat = $data->summary_editor['format'];
@@ -4293,7 +4298,6 @@ public function approve() {
$user = $DB->get_record('user', array('id' => $this->properties->requester, 'deleted'=>0), '*', MUST_EXIST);
$category = get_course_category($CFG->defaultrequestcategory);
$courseconfig = get_config('moodlecourse');
// Transfer appropriate settings
@@ -4302,6 +4306,14 @@ public function approve() {
unset($data->reason);
unset($data->requester);
// If the current user does not have the rights to change the category, or if the
// category does not exist, we set the default category to the course to be approved.
// The system level is used because the capability moodle/site:approvecourse is based on a system level.
if (!has_capability('moodle/course:changecategory', context_system::instance()) ||
(!$category = get_course_category($data->category))) {
$category = get_course_category($CFG->defaultrequestcategory);
}
// Set category
$data->category = $category->id;
$data->sortorder = $category->sortorder; // place as the first in category
@@ -101,20 +101,31 @@
$table = new html_table();
$table->attributes['class'] = 'pendingcourserequests generaltable';
$table->align = array('center', 'center', 'center', 'center', 'center', 'center');
$table->head = array(get_string('shortnamecourse'), get_string('fullnamecourse'),
get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action'));
$table->head = array(get_string('shortnamecourse'), get_string('fullnamecourse'), get_string('requestedby'),
get_string('summary'), get_string('category'), get_string('requestreason'), get_string('action'));
foreach ($pending as $course) {
$course = new course_request($course);
// Check here for shortname collisions and warn about them.
$course->check_shortname_collision();
// Retreiving category name.
// If the user does not have the capability to change the category, we fallback on the default one.
// Else, the category proposed is fetched, but we fallback on the default one if we can't find it.
// It is just a matter of displaying the right information because the logic when approving the category
// proceeds the same way. The system context level is used as moodle/site:approvecourse uses it.
if (!has_capability('moodle/course:changecategory', context_system::instance()) ||
(!$category = get_course_category($course->category))) {
$category = get_course_category($CFG->defaultrequestcategory);
}
$row = array();
$row[] = format_string($course->shortname);
$row[] = format_string($course->fullname);
$row[] = fullname($course->get_requester());
$row[] = $course->summary;
$row[] = format_string($category->name);
$row[] = format_string($course->reason);
$row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') .
$OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get');
@@ -42,7 +42,7 @@
*/
class course_request_form extends moodleform {
function definition() {
global $DB, $USER;
global $CFG, $DB, $USER;
$mform =& $this->_form;
@@ -68,6 +68,15 @@ function definition() {
$mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
$mform->setType('shortname', PARAM_TEXT);
if (!empty($CFG->requestcategoryselection)) {
$displaylist = array();
$parentlist = array();
make_categories_list($displaylist, $parentlist, '');
$mform->addElement('select', 'category', get_string('category'), $displaylist);
$mform->setDefault('category', $CFG->defaultrequestcategory);
$mform->addHelpButton('category', 'category');
}
$mform->addElement('editor', 'summary_editor', get_string('summary'), null, course_request::summary_editor_options());
$mform->addHelpButton('summary_editor', 'coursesummary');
$mform->setType('summary_editor', PARAM_RAW);
@@ -283,6 +283,7 @@
$string['configrcachettl'] = 'Time-to-live for cached records, in seconds. Use a short (<15) value here.';
$string['configrecaptchaprivatekey'] = 'String of characters used to communicate between your Moodle server and the recaptcha server. Obtain one for this site by visiting http://www.google.com/recaptcha';
$string['configrecaptchapublickey'] = 'String of characters used to display the reCAPTCHA element in the signup form. Generated by http://www.google.com/recaptcha';
$string['configrequestcategoryselection'] = 'Allow the selection of a category when requesting a course.';
$string['configrequestedstudentname'] = 'Word for student used in requested courses';
$string['configrequestedstudentsname'] = 'Word for students used in requested courses';
$string['configrequestedteachername'] = 'Word for teacher used in requested courses';
@@ -871,6 +872,7 @@
$string['purgecaches']= 'Purge all caches';
$string['purgecachesconfirm']= 'Moodle can cache themes, javascript, language strings, filtered text, rss feeds and many other pieces of calculated data. Purging these caches will delete that data from the server and force browsers to refetch data, so that you can be sure you are seeing the most up-to-date values produced by the current code. There is no danger in purging caches, but your site may appear slower for a while until the server and clients calculate new information and cache it.';
$string['purgecachesfinished']= 'All caches were purged.';
$string['requestcategoryselection'] = 'Enable category selection';
$string['restorernewroleid'] = 'Restorers\' role in courses';
$string['restorernewroleid_help'] = 'If the user does not already have the permission to manage the newly restored course, the user is automatically assigned this role and enrolled if necessary. Select "None" if you do not want restorers to be able to manage every restored course.';
$string['reverseproxy'] = 'Reverse proxy';
@@ -426,8 +426,9 @@
<FIELD NAME="fullname" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="shortname"/>
<FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="fullname" NEXT="summary"/>
<FIELD NAME="summary" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="shortname" NEXT="summaryformat"/>
<FIELD NAME="summaryformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="summary" NEXT="reason"/>
<FIELD NAME="reason" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="summaryformat" NEXT="requester"/>
<FIELD NAME="summaryformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="summary" NEXT="category"/>
<FIELD NAME="category" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="summaryformat" NEXT="reason"/>
<FIELD NAME="reason" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="category" NEXT="requester"/>
<FIELD NAME="requester" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="reason" NEXT="password"/>
<FIELD NAME="password" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" PREVIOUS="requester"/>
</FIELDS>
@@ -1122,8 +1122,8 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2012082300.01) {
// Add more custom enrol fields.
$table = new xmldb_table('enrol');
$field = new xmldb_field('customint5', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'customint4');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
@@ -1194,5 +1194,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012090500.00);
}
if ($oldversion < 2012090700.01) {
// Add a category field in the course_request table
$table = new xmldb_table('course_request');
$field = new xmldb_field('category', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'summaryformat');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2012090700.01);
}
return true;
}
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012090700.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012090700.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit 5e51915

Please sign in to comment.
You can’t perform that action at this time.