protected function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('html', get_string('compilatioexplain', 'plagiarism_compilatio'));
     $mform->addElement('checkbox', 'compilatio_use', get_string('usecompilatio', 'plagiarism_compilatio'));
     $mform->addElement('text', 'compilatio_api', get_string('compilatio_api', 'plagiarism_compilatio'));
     $mform->addHelpButton('compilatio_api', 'compilatio_api', 'plagiarism_compilatio');
     $mform->addRule('compilatio_api', null, 'required', null, 'client');
     $mform->setDefault('compilatio_api', 'http://service.compilatio.net/webservices/CompilatioUserClient2.wsdl');
     $mform->addElement('passwordunmask', 'compilatio_password', get_string('compilatio_password', 'plagiarism_compilatio'));
     $mform->addHelpButton('compilatio_password', 'compilatio_password', 'plagiarism_compilatio');
     $mform->addRule('compilatio_password', null, 'required', null, 'client');
     $mform->addElement('textarea', 'compilatio_student_disclosure', get_string('studentdisclosure', 'plagiarism_compilatio'), 'wrap="virtual" rows="6" cols="50"');
     $mform->addHelpButton('compilatio_student_disclosure', 'studentdisclosure', 'plagiarism_compilatio');
     $mform->setDefault('compilatio_student_disclosure', get_string('studentdisclosuredefault', 'plagiarism_compilatio'));
     $mods = get_plugin_list('mod');
     foreach ($mods as $mod => $modname) {
         if (plugin_supports('mod', $mod, FEATURE_PLAGIARISM)) {
             $modstring = 'compilatio_enable_mod_' . $mod;
             $mform->addElement('checkbox', $modstring, get_string('compilatio_enableplugin', 'plagiarism_compilatio', get_string('pluginname', 'mod_' . $mod)));
         }
     }
     $this->add_action_buttons(true);
 }
Ejemplo n.º 2
0
/**
 * Returns an array of reports to which the current user has access to.
 * @return array reports are ordered as they should be for display in tabs.
 */
function offlinequiz_report_list($context)
{
    global $DB;
    static $reportlist = null;
    if (!is_null($reportlist)) {
        return $reportlist;
    }
    $reports = $DB->get_records('offlinequiz_reports', null, 'displayorder DESC', 'name, capability');
    $reportdirs = get_plugin_list('offlinequiz');
    // Order the reports tab in descending order of displayorder.
    $reportcaps = array();
    foreach ($reports as $key => $report) {
        if (array_key_exists($report->name, $reportdirs)) {
            $reportcaps[$report->name] = $report->capability;
        }
    }
    // Add any other reports, which are on disc but not in the DB, on the end.
    foreach ($reportdirs as $reportname => $notused) {
        if (!isset($reportcaps[$reportname])) {
            $reportcaps[$reportname] = null;
        }
    }
    $reportlist = array();
    foreach ($reportcaps as $name => $capability) {
        if (empty($capability)) {
            $capability = 'mod/offlinequiz:viewreports';
        }
        if (has_capability($capability, $context)) {
            $reportlist[] = $name;
        }
    }
    return $reportlist;
}
Ejemplo n.º 3
0
/**
 * Returns instances of enrol plugins
 * @param bool $enabled return enabled only
 * @return array of enrol plugins name=>instance
 */
function enrol_get_plugins($enabled)
{
    global $CFG;
    $result = array();
    if ($enabled) {
        // sorted by enabled plugin order
        $enabled = explode(',', $CFG->enrol_plugins_enabled);
        $plugins = array();
        foreach ($enabled as $plugin) {
            $plugins[$plugin] = "{$CFG->dirroot}/enrol/{$plugin}";
        }
    } else {
        // sorted alphabetically
        $plugins = get_plugin_list('enrol');
        ksort($plugins);
    }
    foreach ($plugins as $plugin => $location) {
        if (!file_exists("{$location}/lib.php")) {
            continue;
        }
        include_once "{$location}/lib.php";
        $class = "enrol_{$plugin}_plugin";
        if (!class_exists($class)) {
            continue;
        }
        $result[$plugin] = new $class();
    }
    return $result;
}
Ejemplo n.º 4
0
 function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     //Accessibility: "Required" is bad legend text.
     $strgeneral = get_string('general');
     $strrequired = get_string('required');
     /// Add some extra hidden fields
     $mform->addElement('hidden', 'id');
     $mform->addElement('hidden', 'course', $COURSE->id);
     /// Print the required moodle fields first
     $mform->addElement('header', 'moodle', $strgeneral);
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $mform->addRule('username', $strrequired, 'required', null, 'client');
     $mform->setType('username', PARAM_RAW);
     $auths = get_plugin_list('auth');
     $auth_options = array();
     foreach ($auths as $auth => $unused) {
         $auth_options[$auth] = auth_get_plugin_title($auth);
     }
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->setAdvanced('auth');
     $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
     $mform->setHelpButton('newpassword', array('newpassword', get_string('leavetokeep')));
     $mform->setType('newpassword', PARAM_RAW);
     $mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
     $mform->setHelpButton('preference_auth_forcepasswordchange', array('forcepasswordchange', get_string('forcepasswordchange')));
     /// shared fields
     useredit_shared_definition($mform);
     /// Next the customisable profile fields
     profile_definition($mform);
     $this->add_action_buttons(false, get_string('updatemyprofile'));
 }
Ejemplo n.º 5
0
    /**
     * Is this the last plugin in the list?
     *
     * @return bool
     */
    public final function is_last() {
        if ((count(get_plugin_list($this->get_subtype()))-1) == get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder')) {
            return true;
        }

        return false;
    }
Ejemplo n.º 6
0
 /**
  * items in the form
  */
 public function definition()
 {
     global $CURMAN, $CFG;
     parent::definition();
     $mform =& $this->_form;
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('text', 'name', get_string('userset_name', 'local_elisprogram'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', get_string('required'), 'required', NULL, 'client');
     $mform->addHelpButton('name', 'userset_name', 'local_elisprogram');
     $mform->addElement('textarea', 'display', get_string('userset_description', 'local_elisprogram'), array('cols' => 40, 'rows' => 2));
     $mform->setType('display', PARAM_CLEAN);
     $mform->addHelpButton('display', 'userset_description', 'local_elisprogram');
     $current_cluster_id = isset($this->_customdata['obj']->id) ? $this->_customdata['obj']->id : '';
     //obtain the non-child clusters that we could become the child of, with availability
     //determined based on the edit capability
     $contexts = usersetpage::get_contexts('local/elisprogram:userset_edit');
     $non_child_clusters = cluster_get_non_child_clusters($current_cluster_id, $contexts);
     //parent dropdown
     $mform->addElement('select', 'parent', get_string('userset_parent', 'local_elisprogram'), $non_child_clusters);
     $mform->addHelpButton('parent', 'userset_parent', 'local_elisprogram');
     // allow plugins to add their own fields
     $mform->addElement('header', 'userassociationfieldset', get_string('userset_userassociation', 'local_elisprogram'));
     $plugins = get_plugin_list(userset::ENROL_PLUGIN_TYPE);
     foreach ($plugins as $plugin => $plugindir) {
         require_once elis::plugin_file(userset::ENROL_PLUGIN_TYPE . '_' . $plugin, 'lib.php');
         call_user_func('cluster_' . $plugin . '_edit_form', $this, $mform, $current_cluster_id);
     }
     // custom fields
     $this->add_custom_fields('cluster', 'local/elisprogram:userset_edit', 'local/elisprogram:userset_view', 'cluster');
     $this->add_action_buttons();
 }
Ejemplo n.º 7
0
 /**
  * Returns a list of all components installed on the server
  *
  * @return array (string)legacyname => (string)frankenstylename
  */
 public static function list_components()
 {
     $list['moodle'] = 'core';
     $coresubsystems = get_core_subsystems();
     ksort($coresubsystems);
     // should be but just in case
     foreach ($coresubsystems as $name => $location) {
         if ($name != 'moodle.org') {
             $list[$name] = 'core_' . $name;
         }
     }
     $plugintypes = get_plugin_types();
     foreach ($plugintypes as $type => $location) {
         $pluginlist = get_plugin_list($type);
         foreach ($pluginlist as $name => $ununsed) {
             if ($type == 'mod') {
                 if (array_key_exists($name, $list)) {
                     throw new Exception('Activity module and core subsystem name collision');
                 }
                 $list[$name] = $type . '_' . $name;
             } else {
                 $list[$type . '_' . $name] = $type . '_' . $name;
             }
         }
     }
     return $list;
 }
 function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     $editoroptions = null;
     $filemanageroptions = null;
     $userid = $USER->id;
     if (is_array($this->_customdata)) {
         if (array_key_exists('editoroptions', $this->_customdata)) {
             $editoroptions = $this->_customdata['editoroptions'];
         }
         if (array_key_exists('filemanageroptions', $this->_customdata)) {
             $filemanageroptions = $this->_customdata['filemanageroptions'];
         }
         if (array_key_exists('userid', $this->_customdata)) {
             $userid = $this->_customdata['userid'];
         }
     }
     //Accessibility: "Required" is bad legend text.
     $strgeneral = get_string('general');
     $strrequired = get_string('required');
     /// Add some extra hidden fields
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'course', $COURSE->id);
     $mform->setType('course', PARAM_INT);
     /// Print the required moodle fields first
     $mform->addElement('header', 'moodle', $strgeneral);
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $mform->addRule('username', $strrequired, 'required', null, 'client');
     $mform->setType('username', PARAM_RAW);
     $auths = get_plugin_list('auth');
     $auth_options = array();
     foreach ($auths as $auth => $unused) {
         $auth_options[$auth] = get_string('pluginname', "auth_{$auth}");
     }
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
     $mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
     $mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
     $mform->addHelpButton('suspended', 'suspended', 'auth');
     if (!empty($CFG->passwordpolicy)) {
         $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
     }
     $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
     $mform->addHelpButton('newpassword', 'newpassword');
     $mform->setType('newpassword', PARAM_RAW);
     $mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
     $mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
     /// shared fields
     useredit_shared_definition($mform, $editoroptions, $filemanageroptions);
     /// Next the customisable profile fields
     profile_definition($mform, $userid);
     if ($userid == -1) {
         $btnstring = get_string('createuser');
     } else {
         $btnstring = get_string('updatemyprofile');
     }
     $this->add_action_buttons(false, $btnstring);
 }
Ejemplo n.º 9
0
    public function test_get_submission_plugins() {
        $this->setUser($this->editingteachers[0]);
        $assign = $this->create_instance();
        $installedplugins = array_keys(get_plugin_list('assignsubmission'));

        foreach ($assign->get_submission_plugins() as $plugin) {
            $this->assertContains($plugin->get_type(), $installedplugins, 'Submission plugin not in list of installed plugins');
        }
    }
Ejemplo n.º 10
0
    /**
     * Is this the last plugin in the list?
     *
     * @return bool
     */
    public final function is_last() {
        $lastindex = count(get_plugin_list($this->get_subtype()))-1;
        $currentindex = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder');
        if ($lastindex == $currentindex) {
            return true;
        }

        return false;
    }
Ejemplo n.º 11
0
 function __construct()
 {
     $listPlugins = get_plugin_list("local");
     if (isset($listPlugins["tpebbb"])) {
         require_once $listPlugins["tpebbb"] . "/lib.php";
     } else {
         throw new Exception("require plugin 'local/tpebbb'");
     }
     $this->tpebbb = new TpeBigBlueButton();
     global $LS_KEY, $SC_KEY, $BASIC_KEY, $INTER_KEY, $ADVAN_KEY;
     $LS_KEY = "LS";
     $SC_KEY = "SC";
     $BASIC_KEY = 'Basic';
     $INTER_KEY = 'Inter';
     $ADVAN_KEY = 'Advan';
 }
Ejemplo n.º 12
0
 /**
  * Returns all the plugins having tests
  * @param string $testtype The kind of test we are looking for
  * @return array  all the plugins having tests
  */
 private static function get_all_plugins_with_tests($testtype)
 {
     $pluginswithtests = array();
     $plugintypes = get_plugin_types();
     ksort($plugintypes);
     foreach ($plugintypes as $type => $unused) {
         $plugs = get_plugin_list($type);
         ksort($plugs);
         foreach ($plugs as $plug => $fullplug) {
             // Look for tests recursively
             if (self::directory_has_tests($fullplug, $testtype)) {
                 $pluginswithtests[$type . '_' . $plug] = $fullplug;
             }
         }
     }
     return $pluginswithtests;
 }
 public function definition()
 {
     $mform = $this->_form;
     $behaviour = array('deferredfeedback' => 'Deferred feedback', 'adaptive' => 'Adaptive', 'adaptivenopenalty' => 'Adaptive (no penalties)');
     $qtypes = get_plugin_list('qtype');
     foreach ($qtypes as $qtype => $notused) {
         $qtypes[$qtype] = get_string($qtype, 'qtype_' . $qtype);
     }
     $mform->addElement('header', 'h1', 'Either extract a specific question_session');
     $mform->addElement('text', 'attemptid', 'Quiz attempt id', array('size' => '10'));
     $mform->addElement('text', 'questionid', 'Question id', array('size' => '10'));
     $mform->addElement('header', 'h2', 'Or find and extract an example by type');
     $mform->addElement('select', 'behaviour', 'Behaviour', $behaviour);
     $mform->addElement('text', 'statehistory', 'State history', array('size' => '10'));
     $mform->addElement('select', 'qtype', 'Question type', $qtypes);
     $mform->addElement('text', 'extratests', 'Extra conditions', array('size' => '50'));
     $this->add_action_buttons(false, 'Create test case');
 }
 public function validation($data)
 {
     $mform =& $this->_form;
     $errors = array();
     $indicators = get_plugin_list('engagementindicator');
     $sum = 0;
     foreach ($indicators as $indicator => $path) {
         $key = "weighting_{$indicator}";
         if (isset($data[$key]) && (!is_numeric($data[$key]) || $data[$key] > 100 || $data[$key] < 0)) {
             $errors["weight_group_{$indicator}"] = get_string('weightingmustbenumeric', 'coursereport_engagement');
             continue;
         }
         if (isset($data[$key])) {
             $sum += $data[$key];
         }
     }
     if ($sum != 100) {
         $errors['weightings_desc'] = get_string('weightingsumtoonehundred', 'coursereport_engagement');
     }
     return $errors;
 }
function coursereport_engagement_get_course_summary($courseid)
{
    global $CFG, $DB;
    $risks = array();
    // TODO: We want this to rely on enabled indicators in the course...
    require_once $CFG->libdir . '/pluginlib.php';
    require_once $CFG->dirroot . '/course/report/engagement/locallib.php';
    $pluginman = plugin_manager::instance();
    $instances = get_plugin_list('engagementindicator');
    if (!($weightings = $DB->get_records_menu('coursereport_engagement', array('course' => $courseid), '', 'indicator, weight'))) {
        // Setup default weightings, all equal.
        $weight = sprintf('%.2f', 1 / count($instances));
        foreach ($instances as $name => $path) {
            $record = new stdClass();
            $record->course = $courseid;
            $record->indicator = $name;
            $record->weight = $weight;
            $record->configdata = null;
            $wid = $DB->insert_record('coursereport_engagement', $record);
            $weightings[$name] = $weight;
        }
    }
    foreach ($instances as $name => $path) {
        $plugin = coursereport_engagement_get_plugin_info($pluginman, 'engagementindicator_' . $name);
        if ($plugin->is_enabled() && file_exists("{$path}/indicator.class.php")) {
            require_once "{$path}/indicator.class.php";
            $classname = "indicator_{$name}";
            $indicator = new $classname($courseid);
            $indicatorrisks = $indicator->get_course_risks();
            $weight = isset($weightings[$name]) ? $weightings[$name] : 0;
            foreach ($indicatorrisks as $userid => $risk) {
                if (!isset($risks[$userid])) {
                    $risks[$userid] = 0;
                }
                $risks[$userid] += $risk->risk * $weight;
            }
        }
    }
    return $risks;
}
Ejemplo n.º 16
0
 /**
  * Load all the blocks information needed for a given path within moodle2 backup
  *
  * This function, given one full path (course, activities/xxxx) will look for all the
  * blocks existing in the backup file, returning one array used to build the
  * proper restore plan by the @restore_plan_builder
  */
 public static function get_blocks_from_path($path)
 {
     global $DB;
     $blocks = array();
     // To return results
     static $availableblocks = array();
     // Get and cache available blocks
     if (empty($availableblocks)) {
         $availableblocks = array_keys(get_plugin_list('block'));
     }
     $path = $path . '/blocks';
     // Always look under blocks subdir
     if (!is_dir($path)) {
         return array();
     }
     if (!($dir = opendir($path))) {
         return array();
     }
     while (false !== ($file = readdir($dir))) {
         if ($file == '.' || $file == '..') {
             // Skip dots
             continue;
         }
         if (is_dir($path . '/' . $file)) {
             // Dir found, check it's a valid block
             if (!file_exists($path . '/' . $file . '/block.xml')) {
                 // Skip if xml file not found
                 continue;
             }
             // Extract block name
             $blockname = preg_replace('/(.*)_\\d+/', '\\1', $file);
             // Check block exists and is installed
             if (in_array($blockname, $availableblocks) && $DB->record_exists('block', array('name' => $blockname))) {
                 $blocks[$path . '/' . $file] = $blockname;
             }
         }
     }
     closedir($dir);
     return $blocks;
 }
 /**
  * Gets the list of plugin types and the system available ingredients
  */
 public function get_system_info()
 {
     // Load moodle plugins manager and get the plugins
     $pluginman = plugin_manager::instance();
     $pluginman->get_plugins();
     $pluginman->get_subplugins();
     // Getting the plugin types
     $plugintypes = get_plugin_types();
     foreach ($plugintypes as $type => $path) {
         $plugins = get_plugin_list($type);
         // We only add the plugin type if it has plugins
         if ($plugins) {
             // Core plugins
             if ($coreplugins = $pluginman->standard_plugins_list($type)) {
                 $coreplugins = array_combine($coreplugins, $coreplugins);
             }
             // The plugin type data
             $branchid = $type;
             $branchname = $pluginman->plugintype_name_plural($type);
             foreach ($plugins as $pluginname => $pluginpath) {
                 // We will only list the non standard plugins
                 if (!empty($coreplugins) && !empty($coreplugins[$pluginname])) {
                     continue;
                 }
                 $this->branches[$type]->branches[$pluginname] = new StdClass();
                 $this->branches[$type]->branches[$pluginname]->id = $pluginname;
                 // The plugin user friendly name
                 $pluginvisiblename = $this->get_system_plugin_visiblename($type, $pluginname);
                 $this->branches[$type]->branches[$pluginname]->name = $pluginvisiblename;
             }
             // Only if there is non core plugins
             if (empty($this->branches[$type]->branches)) {
                 continue;
             }
             $this->branches[$type]->id = $branchid;
             $this->branches[$type]->name = $branchname;
         }
     }
 }
Ejemplo n.º 18
0
function scorm_report_list($context)
{
    global $CFG;
    static $reportlist;
    if (!empty($reportlist)) {
        return $reportlist;
    }
    $installed = get_plugin_list('scormreport');
    foreach ($installed as $reportname => $notused) {
        $pluginfile = $CFG->dirroot . '/mod/scorm/report/' . $reportname . '/report.php';
        if (is_readable($pluginfile)) {
            include_once $pluginfile;
            $reportclassname = "scorm_{$reportname}_report";
            if (class_exists($reportclassname)) {
                $report = new $reportclassname();
                if ($report->canview($context)) {
                    $reportlist[] = $reportname;
                }
            }
        }
    }
    return $reportlist;
}
Ejemplo n.º 19
0
 /**
  * Gathers and returns the information about all plugins of the given type.
  *
  * @param string $type the name of the plugintype, eg. mod, auth or workshopform
  * @param string $typerootdir full path to the location of the plugin dir
  * @param string $typeclass the name of the actually called class
  * @return array of plugintype classes, indexed by the plugin name
  */
 public static function get_plugins($plugintype, $plugintyperootdir, $plugintypeclass)
 {
     global $CFG, $DB;
     // Track our method result.
     $result = array();
     if (!$DB->get_manager()->table_exists('config_plugins')) {
         return $result;
     }
     // Obtain the list of all file plugins.
     $fileplugins = get_plugin_list('dhimport');
     foreach ($fileplugins as $pluginname => $pluginpath) {
         if (in_array($pluginname, array('sample', 'header', 'multiple'))) {
             // Filter-out bogus plugins
             continue;
         }
         // Set up the main plugin information.
         $instance = new $plugintypeclass();
         $instance->type = $plugintype;
         $instance->typerootdir = $plugintyperootdir;
         $instance->name = $pluginname;
         $instance->rootdir = $pluginpath;
         $instance->displayname = get_string('pluginname', $plugintype . '_' . $pluginname);
         // Track the current database version.
         $versiondb = get_config($plugintype . '_' . $pluginname, 'version');
         $instance->versiondb = $versiondb !== false ? $versiondb : null;
         // Track the proposed new version.
         $plugin = new \stdClass();
         include "{$instance->rootdir}/version.php";
         $instance->versiondisk = $plugin->version;
         $instance->init_is_standard();
         // Is this really needed?
         // Append to results.
         $result[$pluginname] = $instance;
     }
     return $result;
 }
Ejemplo n.º 20
0
 /**
  * This function loads the course settings that are available for the user
  *
  * @param bool $forceopen If set to true the course node will be forced open
  * @return navigation_node|false
  */
 protected function load_course_settings($forceopen = false)
 {
     global $CFG;
     $course = $this->page->course;
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
     // note: do not test if enrolled or viewing here because we need the enrol link in Course administration section
     $coursenode = $this->add(get_string('courseadministration'), null, self::TYPE_COURSE, null, 'courseadmin');
     if ($forceopen) {
         $coursenode->force_open();
     }
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Add the turn on/off settings
         if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
             // We are on the course page, retain the current page params e.g. section.
             $baseurl = clone $this->page->url;
             $baseurl->param('sesskey', sesskey());
         } else {
             // Edit on the main course page.
             $baseurl = new moodle_url('/course/view.php', array('id' => $course->id, 'return' => $this->page->url->out_as_local_url(false), 'sesskey' => sesskey()));
         }
         $editurl = clone $baseurl;
         if ($this->page->user_is_editing()) {
             $editurl->param('edit', 'off');
             $editstring = get_string('turneditingoff');
         } else {
             $editurl->param('edit', 'on');
             $editstring = get_string('turneditingon');
         }
         $coursenode->add($editstring, $editurl, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
         // Add the module chooser toggle
         $modchoosertoggleurl = clone $baseurl;
         if ($this->page->user_is_editing() && course_ajax_enabled($course)) {
             if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
                 $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'off');
             } else {
                 $modchoosertogglestring = get_string('modchooserenable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'on');
             }
             $modchoosertoggle = $coursenode->add($modchoosertogglestring, $modchoosertoggleurl, self::TYPE_SETTING);
             $modchoosertoggle->add_class('modchoosertoggle');
             $modchoosertoggle->add_class('visibleifjs');
             user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
         }
         if ($this->page->user_is_editing()) {
             // Removed as per MDL-22732
             // $this->add_course_editing_links($course);
         }
         // Add the course settings link
         $url = new moodle_url('/course/edit.php', array('id' => $course->id));
         $coursenode->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         // Add the course completion settings link
         if ($CFG->enablecompletion && $course->enablecompletion) {
             $url = new moodle_url('/course/completion.php', array('id' => $course->id));
             $coursenode->add(get_string('completion', 'completion'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         }
     }
     // add enrol nodes
     enrol_add_course_navigation($coursenode, $course);
     // Manage filters
     if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
         $url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
     }
     // Add view grade report is permitted
     $reportavailable = false;
     if (has_capability('moodle/grade:viewall', $coursecontext)) {
         $reportavailable = true;
     } else {
         if (!empty($course->showgrades)) {
             $reports = get_plugin_list('gradereport');
             if (is_array($reports) && count($reports) > 0) {
                 // Get all installed reports
                 arsort($reports);
                 // user is last, we want to test it first
                 foreach ($reports as $plugin => $plugindir) {
                     if (has_capability('gradereport/' . $plugin . ':view', $coursecontext)) {
                         //stop when the first visible plugin is found
                         $reportavailable = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($reportavailable) {
         $url = new moodle_url('/grade/report/index.php', array('id' => $course->id));
         $gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', ''));
     }
     //  Add outcome if permitted
     if (!empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $coursecontext)) {
         $url = new moodle_url('/grade/edit/outcome/course.php', array('id' => $course->id));
         $coursenode->add(get_string('outcomes', 'grades'), $url, self::TYPE_SETTING, null, 'outcomes', new pix_icon('i/outcomes', ''));
     }
     // Backup this course
     if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
         $url = new moodle_url('/backup/backup.php', array('id' => $course->id));
         $coursenode->add(get_string('backup'), $url, self::TYPE_SETTING, null, 'backup', new pix_icon('i/backup', ''));
     }
     // Restore to this course
     if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
         $url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', ''));
     }
     // Import data from other courses
     if (has_capability('moodle/restore:restoretargetimport', $coursecontext)) {
         $url = new moodle_url('/backup/import.php', array('id' => $course->id));
         $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/restore', ''));
     }
     // Publish course on a hub
     if (has_capability('moodle/course:publish', $coursecontext)) {
         $url = new moodle_url('/course/publish/index.php', array('id' => $course->id));
         $coursenode->add(get_string('publish'), $url, self::TYPE_SETTING, null, 'publish', new pix_icon('i/publish', ''));
     }
     // Reset this course
     if (has_capability('moodle/course:reset', $coursecontext)) {
         $url = new moodle_url('/course/reset.php', array('id' => $course->id));
         $coursenode->add(get_string('reset'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/return', ''));
     }
     // Questions
     require_once $CFG->libdir . '/questionlib.php';
     question_extend_settings_navigation($coursenode, $coursecontext)->trim_if_empty();
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Repository Instances
         if (!$this->cache->cached('contexthasrepos' . $coursecontext->id)) {
             require_once $CFG->dirroot . '/repository/lib.php';
             $editabletypes = repository::get_editable_types($coursecontext);
             $haseditabletypes = !empty($editabletypes);
             unset($editabletypes);
             $this->cache->set('contexthasrepos' . $coursecontext->id, $haseditabletypes);
         } else {
             $haseditabletypes = $this->cache->{'contexthasrepos' . $coursecontext->id};
         }
         if ($haseditabletypes) {
             $url = new moodle_url('/repository/manage_instances.php', array('contextid' => $coursecontext->id));
             $coursenode->add(get_string('repositories'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/repository', ''));
         }
     }
     // Manage files
     if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $coursecontext)) {
         // hidden in new courses and courses where legacy files were turned off
         $url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('courselegacyfiles'), $url, self::TYPE_SETTING, null, 'coursefiles', new pix_icon('i/files', ''));
     }
     // Switch roles
     $roles = array();
     $assumedrole = $this->in_alternative_role();
     if ($assumedrole !== false) {
         $roles[0] = get_string('switchrolereturn');
     }
     if (has_capability('moodle/role:switchroles', $coursecontext)) {
         $availableroles = get_switchable_roles($coursecontext);
         if (is_array($availableroles)) {
             foreach ($availableroles as $key => $role) {
                 if ($assumedrole == (int) $key) {
                     continue;
                 }
                 $roles[$key] = $role;
             }
         }
     }
     if (is_array($roles) && count($roles) > 0) {
         $switchroles = $this->add(get_string('switchroleto'));
         if (count($roles) == 1 && array_key_exists(0, $roles) || $assumedrole !== false) {
             $switchroles->force_open();
         }
         $returnurl = $this->page->url;
         $returnurl->param('sesskey', sesskey());
         foreach ($roles as $key => $name) {
             $url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => $key, 'returnurl' => $returnurl->out(false)));
             $switchroles->add($name, $url, self::TYPE_SETTING, null, $key, new pix_icon('i/roles', ''));
         }
     }
     // Return we are done
     return $coursenode;
 }
 private function register_link_encoders()
 {
     $encoders = array();
     // Add the course encoder
     $encoders['backup_course_task'] = 'encode_content_links';
     // Add the module ones. Each module supporting moodle2 backups MUST have it
     $mods = get_plugin_list('mod');
     foreach ($mods as $mod => $moddir) {
         if (plugin_supports('mod', $mod, FEATURE_BACKUP_MOODLE2)) {
             $encoders['backup_' . $mod . '_activity_task'] = 'encode_content_links';
         }
     }
     // Add the block encoders
     $blocks = get_plugin_list('block');
     foreach ($blocks as $block => $blockdir) {
         if (class_exists('backup_' . $block . '_block_task')) {
             $encoders['backup_' . $block . '_block_task'] = 'encode_content_links';
         }
     }
     // Add the course format encodes
     // TODO: Same than blocks, need to know how courseformats are going to handle backup
     //       (1.9 was based in backuplib function, see code)
     // Add local encodes
     // TODO: Any interest? 1.9 never had that.
     return $encoders;
 }
Ejemplo n.º 22
0
 /**
  * Returns array of relevant context capability records.
  *
  * @return array
  */
 public function get_capabilities()
 {
     global $DB, $CFG;
     $sort = 'ORDER BY contextlevel,component,name';
     // To group them sensibly for display
     $cm = $DB->get_record('course_modules', array('id' => $this->_instanceid));
     $module = $DB->get_record('modules', array('id' => $cm->module));
     $subcaps = array();
     $subpluginsfile = "{$CFG->dirroot}/mod/{$module->name}/db/subplugins.php";
     if (file_exists($subpluginsfile)) {
         $subplugins = array();
         // should be redefined in the file
         include $subpluginsfile;
         if (!empty($subplugins)) {
             foreach (array_keys($subplugins) as $subplugintype) {
                 foreach (array_keys(get_plugin_list($subplugintype)) as $subpluginname) {
                     $subcaps = array_merge($subcaps, array_keys(load_capability_def($subplugintype . '_' . $subpluginname)));
                 }
             }
         }
     }
     $modfile = "{$CFG->dirroot}/mod/{$module->name}/lib.php";
     if (file_exists($modfile)) {
         include_once $modfile;
         $modfunction = $module->name . '_get_extra_capabilities';
         if (function_exists($modfunction)) {
             $extracaps = $modfunction();
         }
     }
     if (empty($extracaps)) {
         $extracaps = array();
     }
     $extracaps = array_merge($subcaps, $extracaps);
     // All modules allow viewhiddenactivities. This is so you can hide
     // the module then override to allow specific roles to see it.
     // The actual check is in course page so not module-specific
     $extracaps[] = "moodle/course:viewhiddenactivities";
     list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
     $extra = "OR name {$extra}";
     $sql = "SELECT *\n                  FROM {capabilities}\n                 WHERE (contextlevel = " . CONTEXT_MODULE . "\n                       AND component = :component)\n                       {$extra}";
     $params['component'] = "mod_{$module->name}";
     return $DB->get_records_sql($sql . ' ' . $sort, $params);
 }
Ejemplo n.º 23
0
 /**
  * Returns the list of available grading strategy methods
  *
  * @return array ['string' => 'string']
  */
 public static function available_strategies_list() {
     $installed = get_plugin_list('workshopform');
     $forms = array();
     foreach ($installed as $strategy => $strategypath) {
         if (file_exists($strategypath . '/lib.php')) {
             $forms[$strategy] = get_string('pluginname', 'workshopform_' . $strategy);
         }
     }
     return $forms;
 }
Ejemplo n.º 24
0
 * @subpackage questionengine
 * @copyright  2011 The Open University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(__FILE__) . '/../config.php';
require_once $CFG->libdir . '/questionlib.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/pluginlib.php';
require_once $CFG->libdir . '/tablelib.php';
// Check permissions.
require_login();
$systemcontext = context_system::instance();
require_capability('moodle/question:config', $systemcontext);
admin_externalpage_setup('manageqbehaviours');
$thispageurl = new moodle_url('/admin/qbehaviours.php');
$behaviours = get_plugin_list('qbehaviour');
$pluginmanager = plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql_menu("\n        SELECT behaviour, COUNT(1)\n        FROM {question_attempts} GROUP BY behaviour");
$needed = array();
$archetypal = array();
foreach ($behaviours as $behaviour => $notused) {
    if (!array_key_exists($behaviour, $counts)) {
        $counts[$behaviour] = 0;
    }
    $needed[$behaviour] = $counts[$behaviour] > 0 || $pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour);
    $archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour);
}
foreach ($counts as $behaviour => $count) {
    if (!array_key_exists($behaviour, $behaviours)) {
        $counts['missing'] += $count;
Ejemplo n.º 25
0
<?php

// $Id$
// This file defines settingpages and externalpages under the "courses" category
if ($hassiteconfig or has_capability('moodle/site:backup', $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', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on', array('moodle/category:manage', 'moodle/course:create')));
    $ADMIN->add('courses', new admin_enrolment_page());
    /// 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', get_string('coursesettings'));
    $courseformats = get_plugin_list('format');
    $formcourseformats = array();
    foreach ($courseformats as $courseformat => $courseformatdir) {
        $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}", "format_{$courseformat}");
        if ($formcourseformats["{$courseformat}"] == "[[format{$courseformat}]]") {
            $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}");
        }
    }
    $temp->add(new admin_setting_configselect('moodlecourse/format', get_string('format'), get_string('coursehelpformat'), 'weeks', $formcourseformats));
    for ($i = 1; $i <= 52; $i++) {
        $sectionmenu[$i] = "{$i}";
    }
    $temp->add(new admin_setting_configselect('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10, $sectionmenu));
    $choices = array();
    $choices['0'] = get_string('hiddensectionscollapsed');
    $choices['1'] = get_string('hiddensectionsinvisible');
    $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), get_string('coursehelphiddensections'), 0, $choices));
    $options = range(0, 10);
    $temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), get_string('coursehelpnewsitemsnumber'), 5, $options));
Ejemplo n.º 26
0
 /**
  * Builds the XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     // display strings
     $stradministration = get_string('administration');
     $strsettings = get_string('settings');
     $stredit = get_string('edit');
     $strprotocol = get_string('protocol', 'webservice');
     $strenable = get_string('enable');
     $strdisable = get_string('disable');
     $strversion = get_string('version');
     $struninstall = get_string('uninstallplugin', 'admin');
     $protocols_available = get_plugin_list('webservice');
     $active_protocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
     ksort($protocols_available);
     foreach ($active_protocols as $key => $protocol) {
         if (empty($protocols_available[$protocol])) {
             unset($active_protocols[$key]);
         }
     }
     $return = $OUTPUT->heading(get_string('actwebserviceshhdr', 'webservice'), 3, 'main');
     $return .= $OUTPUT->box_start('generalbox webservicesui');
     $table = new html_table();
     $table->head = array($strprotocol, $strversion, $strenable, $struninstall, $strsettings);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->width = '100%';
     $table->data = array();
     // iterate through auth plugins and add to the display table
     $url = "{$CFG->wwwroot}/{$CFG->admin}/webservice/protocols.php?sesskey=" . sesskey();
     foreach ($protocols_available as $protocol => $location) {
         $name = get_string('pluginname', 'webservice_' . $protocol);
         $plugin = new stdClass();
         if (file_exists($CFG->dirroot . '/webservice/' . $protocol . '/version.php')) {
             include $CFG->dirroot . '/webservice/' . $protocol . '/version.php';
         }
         $version = isset($plugin->version) ? $plugin->version : '';
         // hide/show link
         if (in_array($protocol, $active_protocols)) {
             $hideshow = "<a href=\"{$url}&amp;action=disable&amp;webservice={$protocol}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->pix_url('i/hide') . "\" class=\"icon\" alt=\"{$strdisable}\" /></a>";
             $displayname = "<span>{$name}</span>";
         } else {
             $hideshow = "<a href=\"{$url}&amp;action=enable&amp;webservice={$protocol}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->pix_url('i/show') . "\" class=\"icon\" alt=\"{$strenable}\" /></a>";
             $displayname = "<span class=\"dimmed_text\">{$name}</span>";
         }
         // delete link
         $uninstall = "<a href=\"{$url}&amp;action=uninstall&amp;webservice={$protocol}\">{$struninstall}</a>";
         // settings link
         if (file_exists($CFG->dirroot . '/webservice/' . $protocol . '/settings.php')) {
             $settings = "<a href=\"settings.php?section=webservicesetting{$protocol}\">{$strsettings}</a>";
         } else {
             $settings = '';
         }
         // add a row to the table
         $table->data[] = array($displayname, $version, $hideshow, $uninstall, $settings);
     }
     $return .= html_writer::table($table);
     $return .= get_string('configwebserviceplugins', 'webservice');
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Ejemplo n.º 27
0
 /**
  * Add subplugin structure to any element in the activity backup tree
  *
  * @param string $subplugintype type of subplugin as defined in activity db/subplugins.php
  * @param backup_nested_element $element element in the activity backup tree that
  *                                       we are going to add subplugin information to
  * @param bool $multiple to define if multiple subplugins can produce information
  *                       for each instance of $element (true) or no (false)
  * @return void
  */
 protected function add_subplugin_structure($subplugintype, $element, $multiple)
 {
     global $CFG;
     // Check the requested subplugintype is a valid one
     $subpluginsfile = $CFG->dirroot . '/mod/' . $this->task->get_modulename() . '/db/subplugins.php';
     if (!file_exists($subpluginsfile)) {
         throw new backup_step_exception('activity_missing_subplugins_php_file', $this->task->get_modulename());
     }
     include $subpluginsfile;
     if (!array_key_exists($subplugintype, $subplugins)) {
         throw new backup_step_exception('incorrect_subplugin_type', $subplugintype);
     }
     // Arrived here, subplugin is correct, let's create the optigroup
     $optigroupname = $subplugintype . '_' . $element->get_name() . '_subplugin';
     $optigroup = new backup_optigroup($optigroupname, null, $multiple);
     $element->add_child($optigroup);
     // Add optigroup to stay connected since beginning
     // Get all the optigroup_elements, looking across all the subplugin dirs
     $subpluginsdirs = get_plugin_list($subplugintype);
     foreach ($subpluginsdirs as $name => $subpluginsdir) {
         $classname = 'backup_' . $subplugintype . '_' . $name . '_subplugin';
         $backupfile = $subpluginsdir . '/backup/moodle2/' . $classname . '.class.php';
         if (file_exists($backupfile)) {
             require_once $backupfile;
             $backupsubplugin = new $classname($subplugintype, $name, $optigroup, $this);
             // Add subplugin returned structure to optigroup
             $backupsubplugin->define_subplugin_structure($element->get_name());
         }
     }
 }
Ejemplo n.º 28
0
function lti_get_types()
{
    global $OUTPUT;
    $subtypes = array();
    foreach (get_plugin_list('ltisource') as $name => $dir) {
        if ($moretypes = component_callback("ltisource_{$name}", 'get_types')) {
            $subtypes = array_merge($subtypes, $moretypes);
        }
    }
    if (empty($subtypes)) {
        return MOD_SUBTYPE_NO_CHILDREN;
    }
    $types = array();
    $type = new stdClass();
    $type->modclass = MOD_CLASS_ACTIVITY;
    $type->type = 'lti_group_start';
    $type->typestr = '--' . get_string('modulenameplural', 'mod_lti');
    $types[] = $type;
    $link = get_string('modulename_link', 'mod_lti');
    $linktext = get_string('morehelp');
    $help = get_string('modulename_help', 'mod_lti');
    $help .= html_writer::tag('div', $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
    $type = new stdClass();
    $type->modclass = MOD_CLASS_ACTIVITY;
    $type->type = '';
    $type->typestr = get_string('generaltool', 'mod_lti');
    $type->help = $help;
    $types[] = $type;
    $types = array_merge($types, $subtypes);
    $type = new stdClass();
    $type->modclass = MOD_CLASS_ACTIVITY;
    $type->type = 'lti_group_end';
    $type->typestr = '--';
    $types[] = $type;
    return $types;
}
Ejemplo n.º 29
0
 /**
  * Create  courses
  *
  * @param array $courses
  * @return array courses (id and shortname only)
  * @since Moodle 2.2
  */
 public static function create_courses($courses)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/course/lib.php";
     require_once $CFG->libdir . '/completionlib.php';
     $params = self::validate_parameters(self::create_courses_parameters(), array('courses' => $courses));
     $availablethemes = get_plugin_list('theme');
     $availablelangs = get_string_manager()->get_list_of_translations();
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['courses'] as $course) {
         // Ensure the current user is allowed to run this function
         $context = context_coursecat::instance($course['categoryid'], IGNORE_MISSING);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             $exceptionparam = new stdClass();
             $exceptionparam->message = $e->getMessage();
             $exceptionparam->catid = $course['categoryid'];
             throw new moodle_exception('errorcatcontextnotvalid', 'webservice', '', $exceptionparam);
         }
         require_capability('moodle/course:create', $context);
         // Make sure lang is valid
         if (key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
             throw new moodle_exception('errorinvalidparam', 'webservice', '', 'lang');
         }
         // Make sure theme is valid
         if (key_exists('forcetheme', $course)) {
             if (!empty($CFG->allowcoursethemes)) {
                 if (empty($availablethemes[$course['forcetheme']])) {
                     throw new moodle_exception('errorinvalidparam', 'webservice', '', 'forcetheme');
                 } else {
                     $course['theme'] = $course['forcetheme'];
                 }
             }
         }
         //force visibility if ws user doesn't have the permission to set it
         $category = $DB->get_record('course_categories', array('id' => $course['categoryid']));
         if (!has_capability('moodle/course:visibility', $context)) {
             $course['visible'] = $category->visible;
         }
         //set default value for completion
         $courseconfig = get_config('moodlecourse');
         if (completion_info::is_enabled_for_site()) {
             if (!key_exists('enablecompletion', $course)) {
                 $course['enablecompletion'] = $courseconfig->enablecompletion;
             }
             if (!key_exists('completionstartonenrol', $course)) {
                 $course['completionstartonenrol'] = $courseconfig->completionstartonenrol;
             }
         } else {
             $course['enablecompletion'] = 0;
             $course['completionstartonenrol'] = 0;
         }
         $course['category'] = $course['categoryid'];
         // Summary format.
         $course['summaryformat'] = external_validate_format($course['summaryformat']);
         //Note: create_course() core function check shortname, idnumber, category
         $course['id'] = create_course((object) $course)->id;
         $resultcourses[] = array('id' => $course['id'], 'shortname' => $course['shortname']);
     }
     $transaction->allow_commit();
     return $resultcourses;
 }
Ejemplo n.º 30
0
 $setting = new admin_setting_configcheckbox('themedesignermode', new lang_string('themedesignermode', 'admin'), new lang_string('configthemedesignermode', 'admin'), 0);
 $setting->set_updatedcallback('theme_reset_all_caches');
 $temp->add($setting);
 $temp->add(new admin_setting_configcheckbox('allowuserthemes', new lang_string('allowuserthemes', 'admin'), new lang_string('configallowuserthemes', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('allowcoursethemes', new lang_string('allowcoursethemes', 'admin'), new lang_string('configallowcoursethemes', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('allowcategorythemes', new lang_string('allowcategorythemes', 'admin'), new lang_string('configallowcategorythemes', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1));
 $temp->add(new admin_setting_configcheckbox('allowblockstodock', new lang_string('allowblockstodock', 'admin'), new lang_string('configallowblockstodock', 'admin'), 1));
 $temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'), new lang_string('configcustommenuitems', 'admin'), '', PARAM_TEXT, '50', '10'));
 $temp->add(new admin_setting_configcheckbox('enabledevicedetection', new lang_string('enabledevicedetection', 'admin'), new lang_string('configenabledevicedetection', 'admin'), 1));
 $temp->add(new admin_setting_devicedetectregex('devicedetectregex', new lang_string('devicedetectregex', 'admin'), new lang_string('devicedetectregex_desc', 'admin'), ''));
 $ADMIN->add('themes', $temp);
 $ADMIN->add('themes', new admin_externalpage('themeselector', new lang_string('themeselector', 'admin'), $CFG->wwwroot . '/theme/index.php'));
 // settings for each theme
 foreach (get_plugin_list('theme') as $theme => $themedir) {
     $settings_path = "{$themedir}/settings.php";
     if (file_exists($settings_path)) {
         $settings = new admin_settingpage('themesetting' . $theme, new lang_string('pluginname', 'theme_' . $theme));
         include $settings_path;
         if ($settings) {
             $ADMIN->add('themes', $settings);
         }
     }
 }
 // calendar
 $temp = new admin_settingpage('calendar', new lang_string('calendarsettings', 'admin'));
 $temp->add(new admin_setting_special_adminseesall());
 //this is hacky because we do not want to include the stuff from calendar/lib.php
 $temp->add(new admin_setting_configselect('calendar_site_timeformat', new lang_string('pref_timeformat', 'calendar'), new lang_string('explain_site_timeformat', 'calendar'), '0', array('0' => new lang_string('default', 'calendar'), '%I:%M %p' => new lang_string('timeformat_12', 'calendar'), '%H:%M' => new lang_string('timeformat_24', 'calendar'))));
 $temp->add(new admin_setting_configselect('calendar_startwday', new lang_string('configstartwday', 'admin'), new lang_string('helpstartofweek', 'admin'), 0, array(0 => new lang_string('sunday', 'calendar'), 1 => new lang_string('monday', 'calendar'), 2 => new lang_string('tuesday', 'calendar'), 3 => new lang_string('wednesday', 'calendar'), 4 => new lang_string('thursday', 'calendar'), 5 => new lang_string('friday', 'calendar'), 6 => new lang_string('saturday', 'calendar'))));