function definition() { global $USER, $CFG, $COURSE; $mform =& $this->_form; $this->set_upload_manager(new upload_manager('imagefile', false, false, null, false, 0, true, true, false)); //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); $modules = get_list_of_plugins('auth'); $auth_options = array(); foreach ($modules as $module) { $auth_options[$module] = get_string("auth_{$module}" . "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')); }
/** * Returns the list of all available converters and loads their classes * * Converter must be installed as a directory in backup/converter/ and its * method is_available() must return true to get to the list. * * @see base_converter::is_available() * @return array of strings */ public static function available_converters() { global $CFG; $converters = array(); $plugins = get_list_of_plugins('backup/converter'); foreach ($plugins as $name) { $classfile = "$CFG->dirroot/backup/converter/$name/lib.php"; $classname = "{$name}_converter"; if (!file_exists($classfile)) { throw new convert_helper_exception('converter_classfile_not_found', $classfile); } require_once($classfile); if (!class_exists($classname)) { throw new convert_helper_exception('converter_classname_not_found', $classname); } if (call_user_func($classname .'::is_available')) { $converters[] = $name; } } return $converters; }
protected function process_glossary($data) { global $DB; $data = (object) $data; $oldid = $data->id; $data->course = $this->get_courseid(); $data->assesstimestart = $this->apply_date_offset($data->assesstimestart); $data->assesstimefinish = $this->apply_date_offset($data->assesstimefinish); if ($data->scale < 0) { // scale found, get mapping $data->scale = -$this->get_mappingid('scale', abs($data->scale)); } $formats = get_list_of_plugins('mod/glossary/formats'); // Check format if (!in_array($data->displayformat, $formats)) { $data->displayformat = 'dictionary'; } if (!empty($data->mainglossary) and $data->mainglossary == 1 and $DB->record_exists('glossary', array('mainglossary' => 1, 'course' => $this->get_courseid()))) { // Only allow one main glossary in the course $data->mainglossary = 0; } // insert the glossary record $newitemid = $DB->insert_record('glossary', $data); $this->apply_activity_instance($newitemid); }
/** * This function returns a list of languages and their full names. The * list of available languages is fetched from install/lang/xx/installer.php * and it's used exclusively by the installation process * @return array An associative array with contents in the form of LanguageCode => LanguageName */ function install_get_list_of_languages() { global $CFG; $languages = array(); /// Get raw list of lang directories $langdirs = get_list_of_plugins('install/lang'); asort($langdirs); /// Get some info from each lang foreach ($langdirs as $lang) { if ($lang == 'en') { continue; } if (file_exists($CFG->dirroot . '/install/lang/' . $lang . '/installer.php')) { $string = array(); include $CFG->dirroot . '/install/lang/' . $lang . '/installer.php'; if (substr($lang, -5) === '_utf8') { //Remove the _utf8 suffix from the lang to show $shortlang = substr($lang, 0, -5); } else { $shortlang = $lang; } if (!empty($string['thislanguage'])) { $languages[$lang] = $string['thislanguage'] . ' (' . $shortlang . ')'; } } } /// Return array return $languages; }
/** * Get list of available import or export prints * @param string $type 'import' if import list, otherwise export list assumed * @return array sorted list of import/export prints available **/ function referentiel_get_print_formats($type, $classprefix = "") { global $CFG; $fileprints = get_list_of_plugins("mod/referentiel/print"); $fileprintnames = array(); require_once "{$CFG->dirroot}/mod/referentiel/print.php"; foreach ($fileprints as $key => $fileprint) { $print_file = $CFG->dirroot . "/mod/referentiel/print/{$fileprint}/print.php"; if (file_exists($print_file)) { require_once $print_file; } else { continue; } if ($classprefix) { $classname = $classprefix . "_" . $fileprint; } else { $classname = "pprint_{$fileprint}"; } $print_class = new $classname(); $provided = $print_class->provide_print(); if ($provided) { $printname = get_string($fileprint, "referentiel"); if ($printname == "[[{$fileprint}]]") { $printname = $fileprint; // Just use the raw folder name } $fileprintnames[$fileprint] = $printname; } } natcasesort($fileprintnames); return $fileprintnames; }
public function test_plugins() { $plugins = get_list_of_plugins('repository'); foreach ($plugins as $plugin) { // Instantiate a fake plugin instance $plugin_class = "partialmock_{$plugin}"; $plugin = new $plugin_class($this); // add common plugin tests here } }
function lightboxgallery_edit_types($showall = false) { global $CFG; $result = array(); $disabledplugins = explode(',', get_config('lightboxgallery', 'disabledplugins')); $edittypes = get_list_of_plugins('mod/lightboxgallery/edit'); foreach ($edittypes as $edittype) { if ($showall || !in_array($edittype, $disabledplugins)) { $result[$edittype] = get_string('edit_' . $edittype, 'lightboxgallery'); } } return $result; }
/** * Returns a new object of each available type. * @return array Array of forum_feature objects */ public static function get_all() { global $CFG; // Get directory listing (excluding simpletest, CVS, etc) $list = get_list_of_plugins('feature', '', $CFG->dirroot . '/mod/forumng'); // Create array and put one of each object in it $results = array(); foreach ($list as $name) { $results[] = self::get_new($name); } // Sort features into order and return usort($results, array('forum_feature', 'compare')); return $results; }
function definition() { global $USER, $CFG; $mform =& $this->_form; $mform->addElement('header', 'general', get_string('settings', 'grades')); $options = array(-1 => get_string('default', 'grades'), GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')); $default_gradedisplaytype = $CFG->grade_displaytype; foreach ($options as $key => $option) { if ($key == $default_gradedisplaytype) { $options[-1] = get_string('defaultprev', 'grades', $option); break; } } $mform->addElement('select', 'displaytype', get_string('gradedisplaytype', 'grades'), $options); $mform->setHelpButton('displaytype', array(false, get_string('gradedisplaytype', 'grades'), false, true, false, get_string('configgradedisplaytype', 'grades'))); $options = array(-1 => get_string('defaultprev', 'grades', $CFG->grade_decimalpoints), 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5); $mform->addElement('select', 'decimalpoints', get_string('decimalpoints', 'grades'), $options); $mform->setHelpButton('decimalpoints', array(false, get_string('decimalpoints', 'grades'), false, true, false, get_string('configdecimalpoints', 'grades'))); $options = array(-1 => get_string('default', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades')); $default_gradedisplaytype = $CFG->grade_aggregationposition; foreach ($options as $key => $option) { if ($key == $default_gradedisplaytype) { $options[-1] = get_string('defaultprev', 'grades', $option); break; } } $mform->addElement('select', 'aggregationposition', get_string('aggregationposition', 'grades'), $options); $mform->setHelpButton('aggregationposition', array(false, get_string('aggregationposition', 'grades'), false, true, false, get_string('configaggregationposition', 'grades'))); // add setting options for plugins $types = array('report', 'export', 'import'); foreach ($types as $type) { foreach (get_list_of_plugins('grade/' . $type) as $plugin) { // Include all the settings commands for this plugin if there are any if (file_exists($CFG->dirroot . '/grade/' . $type . '/' . $plugin . '/lib.php')) { require_once $CFG->dirroot . '/grade/' . $type . '/' . $plugin . '/lib.php'; $functionname = 'grade_' . $type . '_' . $plugin . '_settings_definition'; if (function_exists($functionname)) { $mform->addElement('header', 'grade_' . $type . $plugin, get_string('modulename', 'grade' . $type . '_' . $plugin, NULL, $CFG->dirroot . '/grade/' . $type . '/' . $plugin . '/lang/')); $functionname($mform); } } } } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $this->add_action_buttons(); }
function definition() { global $CFG; $mform =& $this->_form; $syscontext = get_context_instance(CONTEXT_SYSTEM); $actions = array(0 => get_string('choose') . '...'); $plugins = get_list_of_plugins($CFG->admin . '/user/actions', 'CVS'); foreach ($plugins as $dir) { if (check_action_capabilities($dir)) { $actions[$dir] = get_string('pluginname', 'bulkuseractions_' . $dir, NULL, $CFG->dirroot . '/admin/user/actions/' . $dir . '/lang/'); } } $objs = array(); $objs[] =& $mform->createElement('select', 'action', null, $actions); $objs[] =& $mform->createElement('submit', 'doaction', get_string('go')); $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false); }
/** * items in the form */ public function definition() { global $CURMAN, $CFG; parent::definition(); $mform =& $this->_form; $mform->addElement('hidden', 'id'); $mform->addElement('text', 'name', get_string('cluster_name', 'block_curr_admin') . ':'); $mform->addRule('name', get_string('required'), 'required', NULL, 'client'); $mform->setHelpButton('name', array('clusterform/name', get_string('cluster_name', 'block_curr_admin'), 'block_curr_admin')); $mform->addElement('textarea', 'display', get_string('cluster_description', 'block_curr_admin') . ':', array('cols' => 40, 'rows' => 2)); $mform->setHelpButton('display', array('clusterform/display', get_string('cluster_description', 'block_curr_admin'), 'block_curr_admin')); $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 = clusterpage::get_contexts('block/curr_admin:cluster:edit'); $non_child_clusters = cluster_get_non_child_clusters($current_cluster_id, $contexts); //parent dropdown $mform->addElement('select', 'parent', get_string('cluster_parent', 'block_curr_admin') . ':', $non_child_clusters); $mform->setHelpButton('parent', array('clusterform/parent', get_string('cluster_parent', 'block_curr_admin'), 'block_curr_admin')); // allow plugins to add their own fields $plugins = get_list_of_plugins('curriculum/cluster'); $mform->addElement('header', 'userassociationfieldset', get_string('userassociation', 'block_curr_admin')); foreach ($plugins as $plugin) { require_once CURMAN_DIRLOCATION . '/cluster/' . $plugin . '/lib.php'; call_user_func('cluster_' . $plugin . '_edit_form', $this); } // custom fields $fields = field::get_for_context_level('cluster'); $fields = $fields ? $fields : array(); $lastcat = null; $context = isset($this->_customdata['obj']) && isset($this->_customdata['obj']->id) ? get_context_instance(context_level_base::get_custom_context_level('cluster', 'block_curr_admin'), $this->_customdata['obj']->id) : get_context_instance(CONTEXT_SYSTEM); require_once CURMAN_DIRLOCATION . '/plugins/manual/custom_fields.php'; foreach ($fields as $rec) { $field = new field($rec); if (!isset($field->owners['manual'])) { continue; } if ($lastcat != $rec->categoryid) { $lastcat = $rec->categoryid; $mform->addElement('header', "category_{$lastcat}", htmlspecialchars($rec->categoryname)); } manual_field_add_form_element($this, $context, $field); } $this->add_action_buttons(); }
/** * Check here for new modules to add to the database. This happens every time the block is upgraded. * If you have added your own extension, increment the version number in block_ajax_marking.php * to trigger this process. Also called after install. */ function AMB_update_modules() { global $CFG; $modules = array(); echo "<br /><br />Scanning site for modules which have an AJAX Marking Block plugin... <br />"; // make a list of directories to check for module grading files $installed_modules = get_list_of_plugins('mod'); $directories = array($CFG->dirroot . '/blocks/ajax_marking'); foreach ($installed_modules as $module) { $directories[] = $CFG->dirroot . '/mod/' . $module; } // get module ids so that we can store these later $comma_modules = $installed_modules; foreach ($comma_modules as $key => $comma_module) { $comma_modules[$key] = "'" . $comma_module . "'"; } $comma_modules = implode(', ', $comma_modules); $sql = "\n SELECT name, id FROM {$CFG->prefix}modules\n WHERE name IN (" . $comma_modules . ")\n "; $module_ids = get_records_sql($sql); // Get files in each directory and check if they fit the naming convention foreach ($directories as $directory) { $files = scandir($directory); // check to see if they end in _grading.php foreach ($files as $file) { // this should lead to 'modulename' and 'grading.php' $pieces = explode('_', $file); if (isset($pieces[1]) && $pieces[1] == 'grading.php') { if (in_array($pieces[0], $installed_modules)) { $modname = $pieces[0]; // add the modulename part of the filename to the array $modules[$modname] = new stdClass(); $modules[$modname]->name = $modname; // do not store $CFG->dirroot so that any changes to it will not break the block $modules[$modname]->dir = str_replace($CFG->dirroot, '', $directory); //$modules[$modname]->dir = $directory; $modules[$modname]->id = $module_ids[$modname]->id; echo "Registered {$modname} module <br />"; } } } } echo '<br />For instructions on how to write extensions for this block, see the documentation on Moodle Docs<br /><br />'; set_config('modules', serialize($modules), 'block_ajax_marking'); }
/** * Returns the list of all available converters and loads their classes * * Converter must be installed as a directory in backup/converter/ and its * method is_available() must return true to get to the list. * * @see base_converter::is_available() * @return array of strings */ public static function available_converters($restore = true) { global $CFG; $converters = array(); // Only apply for backup converters if the (experimental) setting enables it. // This will be out once we get proper support of backup converters. MDL-29956 if (!$restore && empty($CFG->enablebackupconverters)) { return $converters; } $plugins = get_list_of_plugins('backup/converter'); foreach ($plugins as $name) { $filename = $restore ? 'lib.php' : 'backuplib.php'; $classuf = $restore ? '_converter' : '_export_converter'; $classfile = "{$CFG->dirroot}/backup/converter/{$name}/{$filename}"; $classname = "{$name}{$classuf}"; $zip_contents = "{$name}_zip_contents"; $store_backup_file = "{$name}_store_backup_file"; $convert = "{$name}_backup_convert"; if (!file_exists($classfile)) { throw new convert_helper_exception('converter_classfile_not_found', $classfile); } require_once $classfile; if (!class_exists($classname)) { throw new convert_helper_exception('converter_classname_not_found', $classname); } if (call_user_func($classname . '::is_available')) { if (!$restore) { if (!class_exists($zip_contents)) { throw new convert_helper_exception('converter_classname_not_found', $zip_contents); } if (!class_exists($store_backup_file)) { throw new convert_helper_exception('converter_classname_not_found', $store_backup_file); } if (!class_exists($convert)) { throw new convert_helper_exception('converter_classname_not_found', $convert); } } $converters[] = $name; } } return $converters; }
function cm_add_config_defaults() { global $CURMAN, $CFG; $defaults = array('userdefinedtrack' => 0, 'time_format_12h' => 0, 'auto_assign_user_idnumber' => 1, 'restrict_to_elis_enrolment_plugin' => 0, 'cluster_groups' => 0, 'site_course_cluster_groups' => 0, 'cluster_groupings' => 0, 'default_instructor_role' => 0, 'catalog_collapse_count' => 4, 'disablecoursecatalog' => 0, 'disablecertificates' => 1, 'notify_classenrol_user' => 0, 'notify_classenrol_role' => 0, 'notify_classenrol_supervisor' => 0, 'notify_classenrol_message' => get_string('notifyclassenrolmessagedef', 'block_curr_admin'), 'notify_classcompleted_user' => 0, 'notify_classcompleted_role' => 0, 'notify_classcompleted_supervisor' => 0, 'notify_classcompleted_message' => get_string('notifyclasscompletedmessagedef', 'block_curr_admin'), 'notify_classnotstarted_user' => 0, 'notify_classnotstarted_role' => 0, 'notify_classnotstarted_supervisor' => 0, 'notify_classnotstarted_message' => get_string('notifyclassnotstartedmessagedef', 'block_curr_admin'), 'notify_classnotstarted_days' => 10, 'notify_classnotcompleted_user' => 0, 'notify_classnotcompleted_role' => 0, 'notify_classnotcompleted_supervisor' => 0, 'notify_classnotcompleted_message' => get_string('notifyclassnotcompletedmessagedef', 'block_curr_admin'), 'notify_classnotcompleted_days' => 10, 'notify_curriculumnotcompleted_user' => 0, 'notify_curriculumnotcompleted_role' => 0, 'notify_curriculumnotcompleted_supervisor' => 0, 'notify_curriculumnotcompleted_message' => get_string('notifycurriculumnotcompletedmessagedef', 'block_curr_admin'), 'notify_classnotstarted_days' => 10, 'notify_trackenrol_user' => 0, 'notify_trackenrol_role' => 0, 'notify_trackenrol_supervisor' => 0, 'notify_ttrackenrol_message' => get_string('notifytrackenrolmessagedef', 'block_curr_admin'), 'notify_courserecurrence_user' => 0, 'notify_courserecurrence_role' => 0, 'notify_courserecurrence_supervisor' => 0, 'notify_courserecurrence_message' => get_string('notifycourserecurrencemessagedef', 'block_curr_admin'), 'notify_courserecurrence_days' => 10, 'notify_curriculumrecurrence_user' => 0, 'notify_curriculumrecurrence_role' => 0, 'notify_curriculumrecurrence_supervisor' => 0, 'notify_curriculumrecurrence_message' => get_string('notifycurriculumrecurrencemessagedef', 'block_curr_admin'), 'notify_curriculumrecurrence_days' => 10, 'num_block_icons' => 5, 'display_clusters_at_top_level' => 1, 'display_curricula_at_top_level' => 0, 'default_cluster_role_id' => 0, 'default_curriculum_role_id' => 0, 'default_course_role_id' => 0, 'default_class_role_id' => 0, 'default_track_role_id' => 0, 'autocreated_unknown_is_yes' => 1, 'legacy_show_inactive_users' => 0); // include defaults from plugins $plugins = get_list_of_plugins('curriculum/plugins'); foreach ($plugins as $plugin) { if (is_readable(CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/config.php')) { include_once CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/config.php'; if (function_exists("{$plugin}_get_config_defaults")) { $defaults += call_user_func("{$plugin}_get_config_defaults"); } } } foreach ($defaults as $key => $value) { if (!isset($CURMAN->config->{$key})) { $CURMAN->config->{$key} = $value; } } }
/** * Returns the list of all available converters and loads their classes * * Converter must be installed as a directory in backup/converter/ and its * method is_available() must return true to get to the list. * * @see base_converter::is_available() * @return array of strings */ public static function available_converters($restore = true) { global $CFG; $converters = array(); $plugins = get_list_of_plugins('backup/converter'); foreach ($plugins as $name) { $filename = $restore ? 'lib.php' : 'backuplib.php'; $classuf = $restore ? '_converter' : '_export_converter'; $classfile = "{$CFG->dirroot}/backup/converter/{$name}/{$filename}"; $classname = "{$name}{$classuf}"; $zip_contents = "{$name}_zip_contents"; $store_backup_file = "{$name}_store_backup_file"; $convert = "{$name}_backup_convert"; if (!file_exists($classfile)) { throw new convert_helper_exception('converter_classfile_not_found', $classfile); } require_once $classfile; if (!class_exists($classname)) { throw new convert_helper_exception('converter_classname_not_found', $classname); } if (call_user_func($classname . '::is_available')) { if (!$restore) { if (!class_exists($zip_contents)) { throw new convert_helper_exception('converter_classname_not_found', $zip_contents); } if (!class_exists($store_backup_file)) { throw new convert_helper_exception('converter_classname_not_found', $store_backup_file); } if (!class_exists($convert)) { throw new convert_helper_exception('converter_classname_not_found', $convert); } } $converters[] = $name; } } return $converters; }
/** * Get list of available import or export formats * @param string $type 'import' if import list, otherwise export list assumed * @return array sorted list of import/export formats available **/ function referentiel_get_import_export_formats($type, $classprefix = "") { global $CFG; $fileformats = get_list_of_plugins("blocks/referentiel/format"); $fileformatnames = array(); require_once "{$CFG->dirroot}/blocks/referentiel/format.php"; foreach ($fileformats as $key => $fileformat) { $format_file = $CFG->dirroot . "/blocks/referentiel/format/{$fileformat}/format.php"; if (file_exists($format_file)) { require_once $format_file; } else { continue; } if ($classprefix) { $classname = $classprefix . "_" . $fileformat; } else { $classname = "rformat_{$fileformat}"; } $format_class = new $classname(); if ($type == 'import') { $provided = $format_class->provide_import(); } else { $provided = $format_class->provide_export(); } if ($provided) { $formatname = get_string($fileformat, "referentiel"); if ($formatname == "[[{$fileformat}]]") { $formatname = $fileformat; // Just use the raw folder name } $fileformatnames[$fileformat] = $formatname; } } natcasesort($fileformatnames); return $fileformatnames; }
/** * load the available item plugins from given subdirectory of $CFG->dirroot * the default is "mod/feedback/item" * * @global object * @param string $dir the subdir * @return array pluginnames as string */ function feedback_load_feedback_items($dir = 'mod/feedback/item') { global $CFG; $names = get_list_of_plugins($dir); $ret_names = array(); foreach ($names as $name) { require_once($CFG->dirroot.'/'.$dir.'/'.$name.'/lib.php'); if (class_exists('feedback_item_'.$name)) { $ret_names[] = $name; } } return $ret_names; }
// speedup for non-admins, add all caps used on this page $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin')); $temp->add(new admin_setting_manageauths()); $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), '')); $temp->add(new admin_setting_special_registerauth()); $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'), get_string('showguestlogin', 'auth'), '1', array('0' => get_string('hide'), '1' => get_string('show')))); $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'), get_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot . '/login/index.php')), '')); $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'), get_string('forgottenpassword', 'auth'), '')); $temp->add(new admin_setting_configtextarea('auth_instructions', get_string('instructions', 'auth'), get_string('authinstructions', 'auth'), '')); $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS)); $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS)); $temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1)); $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS)); $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS)); $ADMIN->add('authsettings', $temp); if ($auths = get_list_of_plugins('auth')) { $authsenabled = get_enabled_auth_plugins(); $authbyname = array(); foreach ($auths as $auth) { $strauthname = auth_get_plugin_title($auth); $authbyname[$strauthname] = $auth; } ksort($authbyname); foreach ($authbyname as $strauthname => $authname) { if (file_exists($CFG->dirroot . '/auth/' . $authname . '/settings.php')) { // do not show disabled auths in tree, keep only settings link on manage page $settings = new admin_settingpage('authsetting' . $authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled)); if ($ADMIN->fulltree) { include $CFG->dirroot . '/auth/' . $authname . '/settings.php'; } // TODO: finish implementation of common settings - locking, etc.
<?php // $Id$ // "locations" settingpage $temp = new admin_settingpage('locationsettings', get_string('locationsettings', 'admin')); $options = get_list_of_timezones(); $options[99] = get_string('serverlocaltime'); $temp->add(new admin_setting_configselect('timezone', get_string('timezone', 'admin'), get_string('configtimezone', 'admin'), 99, $options)); $options[99] = get_string('timezonenotforced', 'admin'); $temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options)); $options = get_list_of_countries(); $options[0] = get_string('choose') . '...'; $temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0, $options)); $iplookups = array(); if ($plugins = get_list_of_plugins('iplookup')) { foreach ($plugins as $plugin) { $iplookups[$plugin] = $plugin; } } $temp->add(new admin_setting_configselect('iplookup', get_string('iplookup', 'admin'), get_string('configiplookup', 'admin'), 'hostip', $iplookups)); $ADMIN->add('location', $temp); $ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "{$CFG->wwwroot}/{$CFG->admin}/timezoneimport.php"));
//if( isteacher( $game->course, $USER->id)){ global $USER; $sesskey = $USER->sesskey; $url = "{$CFG->wwwroot}/course/mod.php?update={$cm->id}&return=true&sesskey={$sesskey}"; $row[] = new tabobject('edit', $url, get_string('edit')); //} } if ($currenttab == 'info' && count($row) == 1) { // Don't show only an info tab (e.g. to students). } else { $tabs[] = $row; } if ($currenttab == 'reports' and isset($mode)) { $inactive[] = 'reports'; $activated[] = 'reports'; $allreports = get_list_of_plugins("mod/game/report"); $reportlist = array('overview'); // Standard reports we want to show first foreach ($allreports as $report) { if (!in_array($report, $reportlist)) { $reportlist[] = $report; } } $row = array(); $currenttab = ''; foreach ($reportlist as $report) { $row[] = new tabobject($report, "{$CFG->wwwroot}/mod/game/report.php?q={$game->id}&mode={$report}", get_string($report, 'game')); if ($report == $mode) { $currenttab = $report; } }
$options = array(); foreach ($modules as $module) { $options[$module] = get_string("enrolname", "enrol_{$module}"); } asort($options); print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700'); echo "<form {$CFG->frametarget} id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">"; echo "<div>"; echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />"; $table = new stdClass(); $table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings); $table->align = array('left', 'center', 'center', 'center'); $table->size = array('60%', '', '', '15%'); $table->width = '700'; $table->data = array(); $modules = get_list_of_plugins("enrol"); $enabledplugins = explode(',', $CFG->enrol_plugins_enabled); foreach ($modules as $module) { // skip if directory is empty if (!file_exists("{$CFG->dirroot}/enrol/{$module}/enrol.php")) { continue; } $name = get_string("enrolname", "enrol_{$module}"); $plugin = enrolment_factory::factory($module); $enable = '<input type="checkbox" name="enable[]" value="' . $module . '"'; if (in_array($module, $enabledplugins)) { $enable .= ' checked="checked"'; } if ($module == 'manual') { $enable .= ' disabled="disabled"'; }
function definition() { global $USER, $CFG, $DB; $courseconfig = get_config('moodlecourse'); $mform =& $this->_form; $course = $this->_customdata['course']; $category = $this->_customdata['category']; $systemcontext = get_context_instance(CONTEXT_SYSTEM); $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id); $disable_meta = false; // basic meta course state protection; server-side security checks not needed if (!empty($course)) { $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $context = $coursecontext; if (course_in_meta($course)) { $disable_meta = get_string('metaalreadyinmeta'); } else { if ($course->metacourse) { if ($DB->count_records('course_meta', array('parent_course' => $course->id)) > 0) { $disable_meta = get_string('metaalreadyhascourses'); } } else { // if users already enrolled directly into coures, do not allow switching to meta, // users with metacourse manage permission are exception // please note that we do not need exact results - anything unexpected here prevents metacourse $managers = get_users_by_capability($coursecontext, 'moodle/course:managemetacourse', 'u.id'); $enrolroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $coursecontext); if ($users = get_role_users(array_keys($enrolroles), $coursecontext, false, 'u.id', 'u.id ASC')) { foreach ($users as $user) { if (!isset($managers[$user->id])) { $disable_meta = get_string('metaalreadyhasenrolments'); break; } } } unset($managers); unset($users); unset($enrolroles); } } } else { $coursecontext = null; $context = $categorycontext; } /// form definition with new course defaults //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); // Must have create course capability in both categories in order to move course if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = array(); $parentlist = array(); make_categories_list($displaylist, $parentlist, 'moodle/course:create'); $mform->addElement('select', 'category', get_string('category'), $displaylist); } else { $mform->addElement('hidden', 'category', null); } $mform->setHelpButton('category', array('coursecategory', get_string('category'))); $mform->setDefault('category', $category->id); $mform->setType('category', PARAM_INT); $fullname = get_string('defaultcoursefullname'); $shortname = get_string('defaultcourseshortname'); while ($DB->record_exists('course', array('fullname' => $fullname)) or $DB->record_exists('course', array('fullname' => $fullname))) { $fullname++; $shortname++; } $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->setHelpButton('fullname', array('coursefullname', get_string('fullnamecourse')), true); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_MULTILANG); if ($course and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->setDefault('fullname', $fullname); $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->setHelpButton('shortname', array('courseshortname', get_string('shortnamecourse')), true); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_MULTILANG); if ($course and !has_capability('moodle/course:changeshortname', $coursecontext)) { $mform->hardFreeze('shortname'); $mform->setConstant('shortname', $course->shortname); } $mform->setDefault('shortname', $shortname); $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100" size="10"'); $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true); $mform->setType('idnumber', PARAM_RAW); if ($course and !has_capability('moodle/course:changeidnumber', $coursecontext)) { $mform->hardFreeze('idnumber'); $mform->setConstants('idnumber', $course->idnumber); } $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows' => '10', 'cols' => '65')); $mform->setHelpButton('summary', array('text2', get_string('helptext')), true); $mform->setType('summary', PARAM_RAW); $courseformats = get_list_of_plugins('course/format'); $formcourseformats = array(); foreach ($courseformats as $courseformat) { $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}", "format_{$courseformat}"); if ($formcourseformats["{$courseformat}"] == "[[format{$courseformat}]]") { $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}"); } } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true); $mform->setDefault('format', $courseconfig->format); for ($i = 1; $i <= 52; $i++) { $sectionmenu[$i] = "{$i}"; } $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu); $mform->setDefault('numsections', $courseconfig->numsections); $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->setHelpButton('startdate', array('coursestartdate', get_string('startdate')), true); $mform->setDefault('startdate', time() + 3600 * 24); $choices = array(); $choices['0'] = get_string('hiddensectionscollapsed'); $choices['1'] = get_string('hiddensectionsinvisible'); $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices); $mform->setHelpButton('hiddensections', array('coursehiddensections', get_string('hiddensections')), true); $mform->setDefault('hiddensections', $courseconfig->hiddensections); $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $mform->setHelpButton('newsitems', array('coursenewsitems', get_string('newsitemsnumber')), true); $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->setHelpButton('showgrades', array('coursegrades', get_string('grades')), true); $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->setHelpButton('showreports', array('coursereports', get_string('activityreport')), true); $mform->setDefault('showreports', $courseconfig->showreports); $choices = get_max_upload_sizes($CFG->maxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->setHelpButton('maxbytes', array('courseuploadsize', get_string('maximumupload')), true); $mform->setDefault('maxbytes', $courseconfig->maxbytes); if (!empty($CFG->allowcoursethemes)) { $themes = array(); $themes[''] = get_string('forceno'); $themes += get_list_of_themes(); $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $meta = array(); $meta[0] = get_string('no'); $meta[1] = get_string('yes'); if ($disable_meta === false) { $mform->addElement('select', 'metacourse', get_string('managemeta'), $meta); $mform->setHelpButton('metacourse', array('metacourse', get_string('metacourse')), true); $mform->setDefault('metacourse', $courseconfig->metacourse); } else { // no metacourse element - we do not want to change it anyway! $mform->addElement('static', 'nometacourse', get_string('managemeta'), (empty($course->metacourse) ? $meta[0] : $meta[1]) . " - {$disable_meta} "); $mform->setHelpButton('nometacourse', array('metacourse', get_string('metacourse')), true); } //-------------------------------------------------------------------------------- $mform->addElement('header', 'enrolhdr', get_string('enrolments')); $choices = array(); $modules = explode(',', $CFG->enrol_plugins_enabled); foreach ($modules as $module) { $name = get_string('enrolname', "enrol_{$module}"); $plugin = enrolment_factory::factory($module); if (method_exists($plugin, 'print_entry')) { $choices[$name] = $module; } } asort($choices); $choices = array_flip($choices); $choices = array_merge(array('' => get_string('sitedefault') . ' (' . get_string('enrolname', "enrol_{$CFG->enrol}") . ')'), $choices); $mform->addElement('select', 'enrol', get_string('enrolmentplugins'), $choices); $mform->setHelpButton('enrol', array('courseenrolmentplugins', get_string('enrolmentplugins')), true); $mform->setDefault('enrol', $courseconfig->enrol); $roles = get_assignable_roles($context); if (!empty($course)) { // add current default role, so that it is selectable even when user can not assign it if ($current_role = $DB->get_record('role', array('id' => $course->defaultrole))) { $roles[$current_role->id] = strip_tags(format_string($current_role->name, true)); } } $choices = array(); if ($sitedefaultrole = $DB->get_record('role', array('id' => $CFG->defaultcourseroleid))) { $choices[0] = get_string('sitedefault') . ' (' . $sitedefaultrole->name . ')'; } else { $choices[0] = get_string('sitedefault'); } $choices = $choices + $roles; // fix for MDL-9197 foreach ($choices as $choiceid => $choice) { $choices[$choiceid] = format_string($choice); } $mform->addElement('select', 'defaultrole', get_string('defaultrole', 'role'), $choices); $mform->setDefault('defaultrole', 0); $radio = array(); $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('no'), 0); $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('yes'), 1); $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('enroldate'), 2); $mform->addGroup($radio, 'enrollable', get_string('enrollable'), ' ', false); $mform->setHelpButton('enrollable', array('courseenrollable2', get_string('enrollable')), true); $mform->setDefault('enrollable', $courseconfig->enrollable); $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate'), array('optional' => true)); $mform->setDefault('enrolstartdate', 0); $mform->disabledIf('enrolstartdate', 'enrollable', 'neq', 2); $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate'), array('optional' => true)); $mform->setDefault('enrolenddate', 0); $mform->disabledIf('enrolenddate', 'enrollable', 'neq', 2); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod'), array('optional' => true, 'defaultunit' => 86400)); $mform->setDefault('enrolperiod', $courseconfig->enrolperiod); //-------------------------------------------------------------------------------- $mform->addElement('header', 'expirynotifyhdr', get_string('expirynotify')); $choices = array(); $choices['0'] = get_string('no'); $choices['1'] = get_string('yes'); $mform->addElement('select', 'expirynotify', get_string('notify'), $choices); $mform->setHelpButton('expirynotify', array('expirynotify', get_string('expirynotify')), true); $mform->setDefault('expirynotify', $courseconfig->expirynotify); $mform->addElement('select', 'notifystudents', get_string('expirynotifystudents'), $choices); $mform->setHelpButton('notifystudents', array('expirynotifystudents', get_string('expirynotifystudents')), true); $mform->setDefault('notifystudents', $courseconfig->notifystudents); $thresholdmenu = array(); for ($i = 1; $i <= 30; $i++) { $seconds = $i * 86400; $thresholdmenu[$seconds] = get_string('numdays', '', $i); } $mform->addElement('select', 'expirythreshold', get_string('expirythreshold'), $thresholdmenu); $mform->setHelpButton('expirythreshold', array('expirythreshold', get_string('expirythreshold')), true); $mform->setDefault('expirythreshold', $courseconfig->expirythreshold); //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('groups', 'group')); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'groupmode', get_string('groupmode'), $choices); $mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')), true); $mform->setDefault('groupmode', $courseconfig->groupmode); $choices = array(); $choices['0'] = get_string('no'); $choices['1'] = get_string('yes'); $mform->addElement('select', 'groupmodeforce', get_string('force'), $choices); $mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true); $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); if (!empty($CFG->enablegroupings)) { //default groupings selector $options = array(); $options[0] = get_string('none'); $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); } //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('availability')); $choices = array(); $choices['0'] = get_string('courseavailablenot'); $choices['1'] = get_string('courseavailable'); $mform->addElement('select', 'visible', get_string('availability'), $choices); $mform->setHelpButton('visible', array('courseavailability', get_string('availability')), true); $mform->setDefault('visible', $courseconfig->visible); if ($course and !has_capability('moodle/course:visibility', $coursecontext)) { $mform->hardFreeze('visible'); $mform->setConstant('visible', $course->visible); } $mform->addElement('passwordunmask', 'enrolpassword', get_string('enrolmentkey'), 'size="25"'); $mform->setHelpButton('enrolpassword', array('enrolmentkey', get_string('enrolmentkey')), true); $mform->setDefault('enrolpassword', ''); $mform->setDefault('enrolpassword', $courseconfig->enrolpassword); $mform->setType('enrolpassword', PARAM_RAW); if (empty($course) or $course->password !== '' and $course->id != SITEID) { // do not require password in existing courses that do not have password yet - backwards compatibility ;-) if (!empty($CFG->enrol_manual_requirekey)) { $mform->addRule('enrolpassword', get_string('required'), 'required', null, 'client'); } } $choices = array(); $choices['0'] = get_string('guestsno'); $choices['1'] = get_string('guestsyes'); $choices['2'] = get_string('guestskey'); $mform->addElement('select', 'guest', get_string('opentoguests'), $choices); $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true); $mform->setDefault('guest', $courseconfig->guest); // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here $enrol_object = $CFG; if (!empty($course)) { $enrol_object = $course; } // If the print_entry method exists and the course enrol method isn't manual (both set or inherited from site), show cost if (method_exists(enrolment_factory::factory($enrol_object->enrol), 'print_entry') && !($enrol_object->enrol == 'manual' || empty($enrol_object->enrol) && $CFG->enrol == 'manual')) { $costgroup = array(); $currencies = get_list_of_currencies(); $costgroup[] =& MoodleQuickForm::createElement('text', 'cost', '', 'maxlength="6" size="6"'); $costgroup[] =& MoodleQuickForm::createElement('select', 'currency', '', $currencies); $mform->addGroup($costgroup, 'costgrp', get_string('cost'), ' ', false); //defining a rule for a form element within a group : $costgrprules = array(); //set the message to null to tell Moodle to use a default message //available for most rules, fetched from language pack (err_{rulename}). $costgrprules['cost'][] = array(null, 'numeric', null, 'client'); $mform->addGroupRule('costgrp', $costgrprules); $mform->setHelpButton('costgrp', array('cost', get_string('cost')), true); $mform->setDefault('cost', ''); $mform->setDefault('currency', empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency); } //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('language')); $languages = array(); $languages[''] = get_string('forceno'); $languages += get_list_of_languages(); $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); $mform->setDefault('lang', $courseconfig->lang); //-------------------------------------------------------------------------------- require_once $CFG->libdir . '/completionlib.php'; if (completion_info::is_enabled_for_site()) { $mform->addElement('header', '', get_string('progress', 'completion')); $mform->addElement('select', 'enablecompletion', get_string('completion', 'completion'), array(0 => get_string('completiondisabled', 'completion'), 1 => get_string('completionenabled', 'completion'))); $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); } else { $mform->addElement('hidden', 'enablecompletion'); $mform->setDefault('enablecompletion', 0); } //-------------------------------------------------------------------------------- if (has_capability('moodle/site:config', $systemcontext) && (!empty($course->requested) && $CFG->restrictmodulesfor == 'requested' || $CFG->restrictmodulesfor == 'all')) { $mform->addElement('header', '', get_string('restrictmodules')); $options = array(); $options['0'] = get_string('no'); $options['1'] = get_string('yes'); $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options); $mods = array(0 => get_string('allownone')); $mods += $DB->get_records_menu('modules', array(), 'name', 'id, name'); $mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple' => 'multiple', 'size' => '10')); $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0); } else { $mform->addElement('hidden', 'restrictmodules', null); } if ($CFG->restrictmodulesfor == 'all') { $mform->setDefault('allowedmods', explode(',', $CFG->defaultallowedmodules)); if (!empty($CFG->restrictbydefault)) { $mform->setDefault('restrictmodules', 1); } } $mform->setType('restrictmodules', PARAM_INT); /// customizable role names in this course //-------------------------------------------------------------------------------- $mform->addElement('header', 'rolerenaming', get_string('rolerenaming')); $mform->setHelpButton('rolerenaming', array('rolerenaming', get_string('rolerenaming')), true); if ($roles = get_all_roles()) { if ($coursecontext) { $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW); } $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE); foreach ($roles as $role) { $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->name)); if (isset($role->localname)) { $mform->setDefault('role_' . $role->id, $role->localname); } $mform->setType('role_' . $role->id, PARAM_TEXT); if (!in_array($role->id, $assignableroles)) { $mform->setAdvanced('role_' . $role->id); } } } //-------------------------------------------------------------------------------- $this->add_action_buttons(); //-------------------------------------------------------------------------------- $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes //$this->does_generate = ACTION_NONE; $this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting $result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($dirpath); /// Get the correct dir if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; if ($dbdir) { /// Only if the directory exists and it has been loaded if (!$dbdir->path_exists || !$dbdir->xml_loaded) { return false; } /// Check if the in-memory object exists and create it if (empty($XMLDB->editeddirs)) { $XMLDB->editeddirs = array(); } /// Check if the dir exists and copy it from dbdirs if (!isset($XMLDB->editeddirs[$dirpath])) { $XMLDB->editeddirs[$dirpath] = unserialize(serialize($dbdir)); } /// Get it $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); /// Add the main form $o = '<form id="form" action="index.php" method="post">'; $o .= '<div>'; $o .= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />'; $o .= ' <input type="hidden" name ="action" value="edit_xml_file_save" />'; $o .= ' <input type="hidden" name ="postaction" value="edit_xml_file" />'; $o .= ' <input type="hidden" name ="path" value="' . s($structure->getPath()) . '" />'; $o .= ' <input type="hidden" name ="version" value="' . s($structure->getVersion()) . '" />'; $o .= ' <table id="formelements" class="boxaligncenter">'; $o .= ' <tr valign="top"><td>Path:</td><td>' . s($structure->getPath()) . '</td></tr>'; $o .= ' <tr valign="top"><td>Version:</td><td>' . s($structure->getVersion()) . '</td></tr>'; $o .= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td><textarea name="comment" rows="3" cols="80" id="comment">' . $structure->getComment() . '</textarea></td></tr>'; $o .= ' <tr><td> </td><td><input type="submit" value="' . $this->str['change'] . '" /></td></tr>'; $o .= ' </table>'; $o .= '</div></form>'; /// Calculate the buttons $b = ' <p class="centerpara buttons">'; /// The view original XML button $b .= ' <a href="index.php?action=view_structure_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&select=original">[' . $this->str['vieworiginal'] . ']</a>'; /// The view edited XML button if ($structure->hasChanged()) { $b .= ' <a href="index.php?action=view_structure_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&select=edited">[' . $this->str['viewedited'] . ']</a>'; } else { $b .= ' [' . $this->str['viewedited'] . ']'; } /// The new table button $b .= ' <a href="index.php?action=new_table&postaction=edit_table&table=changeme&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newtable'] . ']</a>'; /// The new from MySQL button if ($CFG->dbfamily == 'mysql') { $b .= ' <a href="index.php?action=new_table_from_mysql&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newtablefrommysql'] . ']</a>'; } else { $b .= ' [' . $this->str['newtablefrommysql'] . ']'; } /// The new statement button $b .= ' <a href="index.php?action=new_statement&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['newstatement'] . ']</a>'; /// The back to main menu button $b .= ' <a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>'; $b .= '</p>'; $b .= ' <p class="centerpara buttons">'; /// The view sql code button $b .= '<a href="index.php?action=view_structure_sql&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['viewsqlcode'] . ']</a>'; /// The view php code button $b .= ' <a href="index.php?action=view_structure_php&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['viewphpcode'] . ']</a>'; $b .= '</p>'; $o .= $b; /// Join all the reserved words into one big array /// Calculate list of available SQL generators $plugins = get_list_of_plugins('lib/xmldb/classes/generators'); $reserved_words = array(); foreach ($plugins as $plugin) { $classname = 'XMLDB' . $plugin; $generator = new $classname(); $reserved_words = array_merge($reserved_words, $generator->getReservedWords()); } sort($reserved_words); $reserved_words = array_unique($reserved_words); /// Add the tables list $tables =& $structure->getTables(); if ($tables) { $o .= '<h3 class="main">' . $this->str['tables'] . '</h3>'; $o .= '<table id="listtables" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($tables as $table) { /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button $b .= '<a href="index.php?action=edit_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>'; $b .= '</td><td class="button cell">'; /// The up button if ($table->getPrevious()) { $b .= '<a href="index.php?action=move_updown_table&direction=up&table=' . $table->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= '</td><td class="button cell">'; /// The down button if ($table->getNext()) { $b .= '<a href="index.php?action=move_updown_table&direction=down&table=' . $table->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= '</td><td class="button cell">'; /// The delete button (if we have more than one and it isn't used) if (count($tables) > 1 && !$structure->getTableUses($table->getName())) { ///!$structure->getTableUses($table->getName())) { $b .= '<a href="index.php?action=delete_table&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>'; } else { $b .= '[' . $this->str['delete'] . ']'; } /// Detect if the table name is a reserved word if (in_array($table->getName(), $reserved_words)) { $b .= ' <a href="index.php?action=view_reserved_words"><span class="error">' . $this->str['reserved'] . '</span></a>'; } $b .= '</td>'; /// Print table row $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_table_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&table=' . $table->getName() . '&select=edited">' . $table->getName() . '</a>' . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; } ///Add the statements list $statements =& $structure->getStatements(); if ($statements) { $o .= '<h3 class="main">' . $this->str['statements'] . '</h3>'; $o .= '<table id="liststatements" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">'; $row = 0; foreach ($statements as $statement) { /// Calculate buttons $b = '</td><td class="button cell">'; /// The edit button $b .= '<a href="index.php?action=edit_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['edit'] . ']</a>'; $b .= '</td><td class="button cell">'; /// The up button if ($statement->getPrevious()) { $b .= '<a href="index.php?action=move_updown_statement&direction=up&statement=' . $statement->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['up'] . ']</a>'; } else { $b .= '[' . $this->str['up'] . ']'; } $b .= '</td><td class="button cell">'; /// The down button if ($statement->getNext()) { $b .= '<a href="index.php?action=move_updown_statement&direction=down&statement=' . $statement->getName() . '&postaction=edit_xml_file' . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['down'] . ']</a>'; } else { $b .= '[' . $this->str['down'] . ']'; } $b .= '</td><td class="button cell">'; /// The delete button $b .= '<a href="index.php?action=delete_statement&statement=' . $statement->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>'; $b .= '</td>'; /// Print statement row $o .= '<tr class="r' . $row . '"><td class="statement cell"><a href="index.php?action=view_statement_xml&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&statement=' . $statement->getName() . '&select=edited">' . $statement->getName() . '</a>' . $b . '</tr>'; $row = ($row + 1) % 2; } $o .= '</table>'; } ///Add the back to main $this->output = $o; } } /// Launch postaction if exists (leave this unmodified) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } return $result; }
/** * Get certificate types indexed and sorted by name for mod_form. * * @return array containing the certificate type */ function certificate_types() { $types = array(); $names = get_list_of_plugins('mod/certificate/type'); foreach ($names as $name) { $types[$name] = get_string('type' . $name, 'certificate'); } asort($types); return $types; }
/** * This function is used by the reset_course_userdata function in moodlelib. * This function will remove all posts from the specified assignment * and clean up any related data. * @param $data the data submitted from the reset course. * @return array status array */ function assignment_reset_userdata($data) { global $CFG; $status = array(); foreach (get_list_of_plugins('mod/assignment/type') as $type) { require_once "{$CFG->dirroot}/mod/assignment/type/{$type}/assignment.class.php"; $assignmentclass = "assignment_{$type}"; $ass = new $assignmentclass(); $status = array_merge($status, $ass->reset_userdata($data)); } return $status; }
} } } if ($gradeexports = get_list_of_plugins('grade/export')) { foreach ($gradeexports as $gradeexport) { if (file_exists($CFG->dirroot . '/grade/export/' . $gradeexport . '/lib.php')) { require_once $CFG->dirroot . '/grade/export/' . $gradeexport . '/lib.php'; $cron_function = 'grade_export_' . $gradeexport . '_cron'; if (function_exists($cron_function)) { mtrace("Processing gradebook export function {$cron_function} ...", ''); $cron_function; } } } } if ($gradereports = get_list_of_plugins('grade/report')) { foreach ($gradereports as $gradereport) { if (file_exists($CFG->dirroot . '/grade/report/' . $gradereport . '/lib.php')) { require_once $CFG->dirroot . '/grade/report/' . $gradereport . '/lib.php'; $cron_function = 'grade_report_' . $gradereport . '_cron'; if (function_exists($cron_function)) { mtrace("Processing gradebook report function {$cron_function} ...", ''); $cron_function; } } } } // run any customized cronjobs, if any // looking for functions in lib/local/cron.php if (file_exists($CFG->dirroot . '/local/cron.php')) { mtrace('Processing customized cron script ...', '');
$ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin'))); $ADMIN->add('qtypesettings', new admin_page_manageqtypes()); require_once $CFG->libdir . '/questionlib.php'; global $QTYPES; foreach ($QTYPES as $qtype) { $settingsfile = $qtype->plugin_dir() . '/settings.php'; if (file_exists($settingsfile)) { $settings = new admin_settingpage('qtypesetting' . $qtype->name(), $qtype->local_name(), 'moodle/question:config'); if ($ADMIN->fulltree) { include $settingsfile; } $ADMIN->add('qtypesettings', $settings); } } } /// Now add reports foreach (get_list_of_plugins($CFG->admin . '/report') as $plugin) { $settings_path = "{$CFG->dirroot}/{$CFG->admin}/report/{$plugin}/settings.php"; if (file_exists($settings_path)) { include $settings_path; continue; } $index_path = "{$CFG->dirroot}/{$CFG->admin}/report/{$plugin}/index.php"; if (!file_exists($index_path)) { continue; } // old style 3rd party plugin without settings.php $www_path = "{$CFG->dirroot}/{$CFG->admin}/report/{$plugin}/index.php"; $reportname = get_string($plugin, 'report_' . $plugin); $ADMIN->add('reports', new admin_externalpage('report' . $plugin, $reportname, $www_path, 'moodle/site:viewreports')); }
/** * Get the names of all the filters installed in this Moodle. * * @global object * @return array path => filter name from the appropriate lang file. e.g. * array('mod/glossary' => 'Glossary Auto-linking', 'filter/tex' => 'TeX Notation'); * sorted in alphabetical order of name. */ function filter_get_all_installed() { global $CFG; $filternames = array(); // TODO: deprecated since 2.2, will be out in 2.3, see MDL-29996 $filterlocations = array('mod', 'filter'); foreach ($filterlocations as $filterlocation) { // TODO: move get_list_of_plugins() to get_plugin_list() $filters = get_list_of_plugins($filterlocation); foreach ($filters as $filter) { // MDL-29994 - Ignore mod/data and mod/glossary filters forever, this will be out in 2.3 if ($filterlocation == 'mod' && ($filter == 'data' || $filter == 'glossary')) { continue; } $path = $filterlocation . '/' . $filter; if (is_readable($CFG->dirroot . '/' . $path . '/filter.php')) { $strfiltername = filter_get_name($path); $filternames[$path] = $strfiltername; } } } collatorlib::asort($filternames); return $filternames; }
/** * Initialises the navigation object. * * This causes the navigation object to look at the current state of the page * that it is associated with and then load the appropriate content. * * This should only occur the first time that the navigation structure is utilised * which will normally be either when the navbar is called to be displayed or * when a block makes use of it. * * @return bool */ public function initialise() { global $CFG, $SITE, $USER, $DB; // Check if it has alread been initialised if ($this->initialised || during_initial_install()) { return true; } $this->initialised = true; // Set up the five base root nodes. These are nodes where we will put our // content and are as follows: // site: Navigation for the front page. // myprofile: User profile information goes here. // mycourses: The users courses get added here. // courses: Additional courses are added here. // users: Other users information loaded here. $this->rootnodes = array(); if (get_home_page() == HOMEPAGE_SITE) { // The home element should be my moodle because the root element is the site if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in $this->rootnodes['home'] = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_SETTING, null, 'home'); } } else { // The home element should be the site because the root node is my moodle $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home'); if ($CFG->defaulthomepage == HOMEPAGE_MY) { // We need to stop automatic redirection $this->rootnodes['home']->action->param('redirect', '0'); } } $this->rootnodes['site'] = $this->add_course($SITE); $this->rootnodes['myprofile'] = $this->add(get_string('myprofile'), null, self::TYPE_USER, null, 'myprofile'); $this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), null, self::TYPE_ROOTNODE, null, 'mycourses'); $this->rootnodes['courses'] = $this->add(get_string('courses'), null, self::TYPE_ROOTNODE, null, 'courses'); $this->rootnodes['users'] = $this->add(get_string('users'), null, self::TYPE_ROOTNODE, null, 'users'); // Fetch all of the users courses. $limit = 20; if (!empty($CFG->navcourselimit)) { $limit = $CFG->navcourselimit; } $mycourses = enrol_get_my_courses(NULL, 'visible DESC,sortorder ASC', $limit); $showallcourses = count($mycourses) == 0 || !empty($CFG->navshowallcourses); $showcategories = $showallcourses && $this->show_categories(); $issite = $this->page->course->id != SITEID; $ismycourse = array_key_exists($this->page->course->id, $mycourses); // Check if any courses were returned. if (count($mycourses) > 0) { // Add all of the users courses to the navigation foreach ($mycourses as $course) { $course->coursenode = $this->add_course($course, false, true); } } if ($showallcourses) { // Load all courses $this->load_all_courses(); } // We always load the frontpage course to ensure it is available without // JavaScript enabled. $frontpagecourse = $this->load_course($SITE); $this->add_front_page_course_essentials($frontpagecourse, $SITE); $canviewcourseprofile = true; // Next load context specific content into the navigation switch ($this->page->context->contextlevel) { case CONTEXT_SYSTEM: // This has already been loaded we just need to map the variable $coursenode = $frontpagecourse; $this->load_all_categories(null, $showcategories); break; case CONTEXT_COURSECAT: // This has already been loaded we just need to map the variable $coursenode = $frontpagecourse; $this->load_all_categories($this->page->context->instanceid, $showcategories); break; case CONTEXT_BLOCK: case CONTEXT_COURSE: // Load the course associated with the page into the navigation $course = $this->page->course; if ($showcategories && !$issite && !$ismycourse) { $this->load_all_categories($course->category, $showcategories); } $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Not enrolled, can't view, and hasn't switched roles if (!can_access_course($coursecontext)) { // TODO: very ugly hack - do not force "parents" to enrol into course their child is enrolled in, // this hack has been propagated from user/view.php to display the navigation node. (MDL-25805) $isparent = false; if ($this->useridtouseforparentchecks) { if ($this->useridtouseforparentchecks != $USER->id) { $usercontext = get_context_instance(CONTEXT_USER, $this->useridtouseforparentchecks, MUST_EXIST); if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id)) and has_capability('moodle/user:viewdetails', $usercontext)) { $isparent = true; } } } if (!$isparent) { $coursenode->make_active(); $canviewcourseprofile = false; break; } } // Add the essentials such as reports etc... $this->add_course_essentials($coursenode, $course); if ($this->format_display_course_content($course->format)) { // Load the course sections $sections = $this->load_course_sections($course, $coursenode); } if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) { $coursenode->make_active(); } break; case CONTEXT_MODULE: $course = $this->page->course; $cm = $this->page->cm; if ($showcategories && !$issite && !$ismycourse) { $this->load_all_categories($course->category, $showcategories); } // Load the course associated with the page into the navigation $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); if (!can_access_course($coursecontext)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); // Load the course sections into the page $sections = $this->load_course_sections($course, $coursenode); if ($course->id != SITEID) { // Find the section for the $CM associated with the page and collect // its section number. if (isset($cm->sectionnum)) { $cm->sectionnumber = $cm->sectionnum; } else { foreach ($sections as $section) { if ($section->id == $cm->section) { $cm->sectionnumber = $section->section; break; } } } // Load all of the section activities for the section the cm belongs to. if (isset($cm->sectionnumber) and !empty($sections[$cm->sectionnumber])) { list($sectionarray, $activityarray) = $this->generate_sections_and_activities($course); $activities = $this->load_section_activities($sections[$cm->sectionnumber]->sectionnode, $cm->sectionnumber, $activityarray); } else { $activities = array(); if ($activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course))) { // "stealth" activity from unavailable section $activities[$cm->id] = $activity; } } } else { $activities = array(); $activities[$cm->id] = $coursenode->get($cm->id, navigation_node::TYPE_ACTIVITY); } if (!empty($activities[$cm->id])) { // Finally load the cm specific navigaton information $this->load_activity($cm, $course, $activities[$cm->id]); // Check if we have an active ndoe if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) { // And make the activity node active. $activities[$cm->id]->make_active(); } } else { //TODO: something is wrong, what to do? (Skodak) } break; case CONTEXT_USER: $course = $this->page->course; if ($course->id != SITEID) { if ($showcategories && !$issite && !$ismycourse) { $this->load_all_categories($course->category, $showcategories); } // Load the course associated with the user into the navigation $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); if (!can_access_course($coursecontext)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); $sections = $this->load_course_sections($course, $coursenode); } break; } $limit = 20; if (!empty($CFG->navcourselimit)) { $limit = $CFG->navcourselimit; } if ($showcategories) { $categories = $this->find_all_of_type(self::TYPE_CATEGORY); foreach ($categories as &$category) { if ($category->children->count() >= $limit) { $url = new moodle_url('/course/category.php', array('id' => $category->key)); $category->add(get_string('viewallcourses'), $url, self::TYPE_SETTING); } } } else { if ($this->rootnodes['courses']->children->count() >= $limit) { $this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING); } } // Load for the current user $this->load_for_user(); if ($this->page->context->contextlevel >= CONTEXT_COURSE && $this->page->context->instanceid != SITEID && $canviewcourseprofile) { $this->load_for_user(null, true); } // Load each extending user into the navigation. foreach ($this->extendforuser as $user) { if ($user->id != $USER->id) { $this->load_for_user($user); } } // Give the local plugins a chance to include some navigation if they want. foreach (get_list_of_plugins('local') as $plugin) { if (!file_exists($CFG->dirroot . '/local/' . $plugin . '/lib.php')) { continue; } require_once $CFG->dirroot . '/local/' . $plugin . '/lib.php'; $function = $plugin . '_extends_navigation'; if (function_exists($function)) { $function($this); } } // Remove any empty root nodes foreach ($this->rootnodes as $node) { // Dont remove the home node if ($node->key !== 'home' && !$node->has_children()) { $node->remove(); } } if (!$this->contains_active_node()) { $this->search_for_active_node(); } // If the user is not logged in modify the navigation structure as detailed // in {@link http://docs.moodle.org/dev/Navigation_2.0_structure} if (!isloggedin()) { $activities = clone $this->rootnodes['site']->children; $this->rootnodes['site']->remove(); $children = clone $this->children; $this->children = new navigation_node_collection(); foreach ($activities as $child) { $this->children->add($child); } foreach ($children as $child) { $this->children->add($child); } } return true; }
function assignment_get_types() { global $CFG; $types = array(); $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->type = "assignment_group_start"; $type->typestr = '--'.get_string('modulenameplural', 'assignment'); $types[] = $type; $standardassignments = array('upload','online','uploadsingle','offline'); foreach ($standardassignments as $assignmenttype) { $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->type = "assignment&type=$assignmenttype"; $type->typestr = get_string("type$assignmenttype", 'assignment'); $types[] = $type; } /// Drop-in extra assignment types $assignmenttypes = get_list_of_plugins('mod/assignment/type'); foreach ($assignmenttypes as $assignmenttype) { if (!empty($CFG->{'assignment_hide_'.$assignmenttype})) { // Not wanted continue; } if (!in_array($assignmenttype, $standardassignments)) { $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->type = "assignment&type=$assignmenttype"; $type->typestr = get_string("type$assignmenttype", 'assignment_'.$assignmenttype); $types[] = $type; } } $type = new stdClass(); $type->modclass = MOD_CLASS_ACTIVITY; $type->type = "assignment_group_end"; $type->typestr = '--'; $types[] = $type; return $types; }