Skip to content
Permalink
Browse files

Merge branch 'MDL-30408-master' of git://github.com/sammarshallou/moodle

  • Loading branch information...
stronk7 committed Jan 17, 2012
2 parents 4374d03 + 5813c7f commit ec43e2267c7f8948c3a8899b25ca804f53fe6e49
Showing with 26 additions and 3 deletions.
  1. +9 −1 course/edit_form.php
  2. +2 −0 course/lib.php
  3. +13 −2 lib/adminlib.php
  4. +2 −0 lib/moodlelib.php
@@ -270,7 +270,15 @@ function definition() {
}
$mods = array(0=>get_string('allownone'));
$mods += $DB->get_records_menu('modules', array('visible'=>1), 'name', 'id, name');
$allmods = $DB->get_records_menu('modules', array('visible' => 1),
'name', 'id, name');
foreach ($allmods as $key => $value) {
// Add module to list unless it cannot be added by users anyway
if (plugin_supports('mod', $value, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER) !==
MOD_ARCHETYPE_SYSTEM) {
$mods[$key] = get_string('pluginname', $value);
}
}
$mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple'=>'multiple', 'size'=>'10'));
$mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
// defaults are already in $course
@@ -1858,6 +1858,8 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
$resources[$urlbase.$modname] = $modnamestr;
} else if ($archetype === MOD_ARCHETYPE_SYSTEM) {
// System modules cannot be added by user, do not add to dropdown
} else {
// all other archetypes are considered activity
$activities[$urlbase.$modname] = $modnamestr;
@@ -7896,16 +7896,21 @@ protected function process_form_data(array $form) {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_configmultiselect_modules extends admin_setting_configmultiselect {
private $excludesystem;
/**
* Calls parent::__construct - note array $choices is not required
*
* @param string $name setting name
* @param string $visiblename localised setting name
* @param string $description setting description
* @param array $defaultsetting a plain array of default module ids
* @param bool $excludesystem If true, excludes modules with 'system' archetype
*/
public function __construct($name, $visiblename, $description, $defaultsetting = array()) {
public function __construct($name, $visiblename, $description, $defaultsetting = array(),
$excludesystem = true) {
parent::__construct($name, $visiblename, $description, $defaultsetting, null);
$this->excludesystem = $excludesystem;
}
/**
@@ -7922,8 +7927,14 @@ public function load_choices() {
global $CFG, $DB;
$records = $DB->get_records('modules', array('visible'=>1), 'name');
foreach ($records as $record) {
// Exclude modules if the code doesn't exist
if (file_exists("$CFG->dirroot/mod/$record->name/lib.php")) {
$this->choices[$record->id] = $record->name;
// Also exclude system modules (if specified)
if (!($this->excludesystem &&
plugin_supports('mod', $record->name, FEATURE_MOD_ARCHETYPE) ===
MOD_ARCHETYPE_SYSTEM)) {
$this->choices[$record->id] = $record->name;
}
}
}
return true;
@@ -417,6 +417,8 @@
define('MOD_ARCHETYPE_RESOURCE', 1);
/** Assignment module archetype */
define('MOD_ARCHETYPE_ASSIGNMENT', 2);
/** System (not user-addable) module archetype */
define('MOD_ARCHETYPE_SYSTEM', 3);
/**
* Security token used for allowing access

0 comments on commit ec43e22

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