From 220a90c5a1b44065626d5cdeb99264b15d692112 Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 19 Dec 2007 17:35:20 +0000 Subject: [PATCH] MDL-11561 admin tree improvements and bugfixing --- admin/auth.php | 239 +- admin/auth_config.php | 15 +- admin/block.php | 13 +- admin/blocks.php | 29 +- admin/filter.php | 29 +- admin/filters.php | 255 +- admin/index.php | 18 +- admin/lang.php | 12 +- admin/mnet/access_control.php | 8 +- admin/mnet/adminlib.php | 2 +- admin/mnet/delete.html | 4 +- admin/mnet/enr_courses.php | 2 +- admin/mnet/enr_hosts.php | 4 +- admin/mnet/mnet_themes.php | 3 +- admin/module.php | 6 +- admin/modules.php | 25 +- admin/pagelib.php | 25 +- admin/report/backups/index.php | 8 +- admin/search.php | 147 +- admin/settings.php | 149 +- admin/settings/appearance.php | 200 +- admin/settings/courses.php | 94 +- admin/settings/grades.php | 347 +- admin/settings/language.php | 27 +- admin/settings/location.php | 39 +- admin/settings/misc.php | 29 +- admin/settings/mnet.php | 18 +- admin/settings/plugins.php | 140 + admin/settings/security.php | 196 +- admin/settings/server.php | 38 +- admin/settings/top.php | 9 +- admin/settings/unsupported.php | 8 +- admin/settings/users.php | 229 +- admin/upgradesettings.php | 134 +- backup/backup_scheduled.php | 2 +- backup/lib.php | 3 - .../admin_bookmarks/block_admin_bookmarks.php | 20 +- blocks/admin_bookmarks/create.php | 16 +- blocks/admin_bookmarks/delete.php | 11 +- blocks/admin_tree/block_admin_tree.php | 104 +- blocks/course_list/config_global.html | 47 - blocks/course_list/settings.php | 13 + blocks/online_users/config_global.html | 21 - blocks/online_users/settings.php | 6 + blocks/rss_client/config_global.html | 75 - blocks/rss_client/settings.php | 21 + course/lib.php | 10 +- filter/algebra/algebradebug.php | 155 +- filter/algebra/filter.php | 43 +- filter/algebra/pix.php | 53 +- filter/censor/filterconfig.html | 28 - filter/censor/filtersettings.php | 6 + filter/mediaplugin/defaultsettings.php | 99 - filter/mediaplugin/filter.php | 2 - filter/mediaplugin/filterconfig.html | 84 - filter/mediaplugin/filtersettings.php | 23 + filter/multilang/defaultsettings.php | 14 - filter/multilang/filterconfig.html | 14 - filter/multilang/filtersettings.php | 6 + filter/tex/defaultsettings.php | 53 - filter/tex/displaytex.php | 1 - filter/tex/filter.php | 21 +- filter/tex/filterconfig.html | 80 - filter/tex/filtersettings.php | 45 + filter/tex/lib.php | 70 + filter/tex/pix.php | 83 +- filter/tex/texdebug.php | 200 +- filter/tex/texed.php | 45 +- grade/report/grader/preferences.php | 2 +- index.php | 2 +- lang/en_utf8/admin.php | 16 +- lang/en_utf8/assignment.php | 1 + lang/en_utf8/auth.php | 1 + lang/en_utf8/block_course_list.php | 2 + lang/en_utf8/block_online_users.php | 1 + lang/en_utf8/block_rss_client.php | 3 + lang/en_utf8/chat.php | 9 + lang/en_utf8/error.php | 1 + lang/en_utf8/filters.php | 1 + lang/en_utf8/forum.php | 9 + lang/en_utf8/resource.php | 6 + lib/adminlib.php | 3207 +++++++++++------ lib/moodlelib.php | 17 +- lib/setup.php | 3 + mod/assignment/config.html | 38 - mod/assignment/lib.php | 7 - mod/assignment/settings.php | 13 + mod/chat/config.html | 130 - mod/chat/lib.php | 30 +- mod/chat/settings.php | 47 + mod/data/config.html | 44 - mod/data/settings.php | 14 + mod/forum/config.html | 196 - mod/forum/lib.php | 48 - mod/forum/settings.php | 63 + mod/glossary/config.html | 249 -- mod/glossary/formats.php | 29 +- mod/glossary/lib.php | 26 - mod/glossary/settings.php | 78 + mod/hotpot/mediaplayers/moodle/filter.php | 4 +- mod/resource/config.html | 122 - mod/resource/lib.php | 62 +- mod/resource/settings.php | 48 + mod/scorm/config.html | 40 - mod/scorm/settings.php | 9 + theme/standard/styles_color.css | 31 + theme/standard/styles_fonts.css | 4 + theme/standard/styles_ie6.css | 9 +- theme/standard/styles_layout.css | 139 +- user/editadvanced.php | 5 +- 110 files changed, 4027 insertions(+), 4714 deletions(-) create mode 100644 admin/settings/plugins.php delete mode 100644 blocks/course_list/config_global.html create mode 100644 blocks/course_list/settings.php delete mode 100644 blocks/online_users/config_global.html create mode 100644 blocks/online_users/settings.php delete mode 100644 blocks/rss_client/config_global.html create mode 100644 blocks/rss_client/settings.php delete mode 100644 filter/censor/filterconfig.html create mode 100644 filter/censor/filtersettings.php delete mode 100644 filter/mediaplugin/defaultsettings.php delete mode 100644 filter/mediaplugin/filterconfig.html create mode 100644 filter/mediaplugin/filtersettings.php delete mode 100644 filter/multilang/defaultsettings.php delete mode 100644 filter/multilang/filterconfig.html create mode 100644 filter/multilang/filtersettings.php delete mode 100644 filter/tex/defaultsettings.php delete mode 100644 filter/tex/filterconfig.html create mode 100644 filter/tex/filtersettings.php create mode 100644 filter/tex/lib.php delete mode 100644 mod/assignment/config.html create mode 100644 mod/assignment/settings.php delete mode 100644 mod/chat/config.html create mode 100644 mod/chat/settings.php delete mode 100644 mod/data/config.html create mode 100644 mod/data/settings.php delete mode 100644 mod/forum/config.html create mode 100644 mod/forum/settings.php delete mode 100644 mod/glossary/config.html create mode 100644 mod/glossary/settings.php delete mode 100644 mod/resource/config.html create mode 100644 mod/resource/settings.php delete mode 100755 mod/scorm/config.html create mode 100644 mod/scorm/settings.php diff --git a/admin/auth.php b/admin/auth.php index b36655180f..61afb67c19 100644 --- a/admin/auth.php +++ b/admin/auth.php @@ -11,7 +11,10 @@ require_once('../config.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/tablelib.php'); -admin_externalpage_setup('userauthentication'); +require_login(); +require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); + +$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths"; $action = optional_param('action', '', PARAM_ACTION); $auth = optional_param('auth', '', PARAM_SAFEDIR); @@ -19,13 +22,6 @@ $auth = optional_param('auth', '', PARAM_SAFEDIR); // get currently installed and enabled auth plugins $authsavailable = get_list_of_plugins('auth'); -//revert auth_plugins_enabled -if (isset($CFG->auth_plugins_enabled)) { - set_config('auth', $CFG->auth_plugins_enabled); - delete_records('config', 'name', 'auth_plugins_enabled'); - unset($CFG->auth_plugins_enabled); -} - get_enabled_auth_plugins(true); // fix the list of enabled auths if (empty($CFG->auth)) { $authsenabled = array(); @@ -33,45 +29,18 @@ if (empty($CFG->auth)) { $authsenabled = explode(',', $CFG->auth); } -if (!isset($CFG->registerauth)) { - set_config('registerauth', ''); -} - -if (!isset($CFG->auth_instructions)) { - set_config('auth_instructions', ''); -} - if (!empty($auth) and !exists_auth_plugin($auth)) { error(get_string('pluginnotinstalled', 'auth', $auth), $url); } - //////////////////////////////////////////////////////////////////////////////// // process actions -$status = ''; +if (!confirm_sesskey()) { + redirect($returnurl); +} switch ($action) { - - case 'save': - if (data_submitted() and confirm_sesskey()) { - - // save settings - set_config('guestloginbutton', required_param('guestloginbutton', PARAM_BOOL)); - set_config('alternateloginurl', stripslashes(trim(required_param('alternateloginurl', PARAM_RAW)))); - set_config('forgottenpasswordurl', stripslashes(trim(required_param('forgottenpasswordurl', PARAM_RAW)))); - set_config('registerauth', required_param('register', PARAM_SAFEDIR)); - set_config('auth_instructions', stripslashes(trim(required_param('auth_instructions', PARAM_RAW)))); - - // enable registerauth in $CFG->auth if needed - if (!empty($CFG->registerauth) and !in_array($CFG->registerauth, $authsenabled)) { - $authsenabled[] = $CFG->registerauth; - set_config('auth', implode(',', $authsenabled)); - } - $status = get_string('changessaved'); - } - break; - case 'disable': // remove from enabled list $key = array_search($auth, $authsenabled); @@ -128,198 +97,6 @@ switch ($action) { break; } -// display strings -$txt = get_strings(array('authenticationplugins', 'users', 'administration', - 'settings', 'edit', 'name', 'enable', 'disable', - 'up', 'down', 'none')); -$txt->updown = "$txt->up/$txt->down"; - -// construct the display array, with enabled auth plugins at the top, in order -$displayauths = array(); -$registrationauths = array(); -$registrationauths[''] = $txt->disable; -foreach ($authsenabled as $auth) { - $authplugin = get_auth_plugin($auth); -/// Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } -/// Apply titles - $displayauths[$auth] = $authtitle; - if ($authplugin->can_signup()) { - $registrationauths[$auth] = $authtitle; - } -} - -foreach ($authsavailable as $auth) { - if (array_key_exists($auth, $displayauths)) { - continue; //already in the list - } - $authplugin = get_auth_plugin($auth); -/// Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } -/// Apply titles - $displayauths[$auth] = $authtitle; - if ($authplugin->can_signup()) { - $registrationauths[$auth] = $authtitle; - } -} - -// build the display table -$table = new flexible_table('auth_admin_table'); -$table->define_columns(array('name', 'enable', 'order', 'settings')); -$table->define_headers(array($txt->name, $txt->enable, $txt->updown, $txt->settings)); -$table->define_baseurl("{$CFG->wwwroot}/{$CFG->admin}/auth.php"); -$table->set_attribute('id', 'blocks'); -$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide'); -$table->setup(); - -//add always enabled plugins first -$displayname = "".$displayauths['manual'].""; -$settings = "sesskey}&auth=manual\">{$txt->settings}"; -$table->add_data(array($displayname, '', '', $settings)); -$displayname = "".$displayauths['nologin'].""; -$settings = "sesskey}&auth=nologin\">{$txt->settings}"; -$table->add_data(array($displayname, '', '', $settings)); - - -// iterate through auth plugins and add to the display table -$updowncount = 1; -$authcount = count($authsenabled); -$url = "auth.php?sesskey=" . sesskey(); -foreach ($displayauths as $auth => $name) { - if ($auth == 'manual' or $auth == 'nologin') { - continue; - } - // hide/show link - if (in_array($auth, $authsenabled)) { - $hideshow = ""; - $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" />"; - // $hideshow = ""; - $enabled = true; - $displayname = "$name"; - } - else { - $hideshow = ""; - $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" />"; - // $hideshow = ""; - $enabled = false; - $displayname = "$name"; - } - - // up/down link (only if auth is enabled) - $updown = ''; - if ($enabled) { - if ($updowncount > 1) { - $updown .= ""; - $updown .= "pixpath}/t/up.gif\" alt=\"up\" /> "; - } - else { - $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> "; - } - if ($updowncount < $authcount) { - $updown .= ""; - $updown .= "pixpath}/t/down.gif\" alt=\"down\" />"; - } - else { - $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />"; - } - ++ $updowncount; - } - - // settings link - $settings = "sesskey}&auth=$auth\">{$txt->settings}"; - - // add a row to the table - $table->add_data(array($displayname, $hideshow, $updown, $settings)); -} - -// output form -admin_externalpage_print_header(); - -//print stus messages -if ($status !== '') { - notify($status, 'notifysuccess'); -} - -print_simple_box(get_string('configauthenticationplugins', 'admin'), 'center', '700'); - -$table->print_html(); - -//////////////////////////////////////////////////////////////////////////////// - -$guestoptions = array(); -$guestoptions[0] = get_string("hide"); -$guestoptions[1] = get_string("show"); - -echo '
'; - -echo '
frametarget.' id="adminsettings" method="post" action="auth.php">'; -echo '
'; -print_heading(get_string('auth_common_settings', 'auth')); -echo ''; -echo ''; -echo '
'; -##echo ''; - -// User self registration -echo '
'; -echo ''; -choose_from_menu($registrationauths, "register", $CFG->registerauth, ""); -echo '
' . get_string("selfregistration_help", "auth") . '
'; -echo '
'; - -// Login as guest button enabled -echo '
'; -echo ''; -choose_from_menu($guestoptions, "guestloginbutton", $CFG->guestloginbutton, ""); -echo '
' . get_string("showguestlogin", "auth") . '
'; -echo '
'; - -/// An alternate url for the login form. It means we can use login forms that are integrated -/// into non-moodle pages -echo '
'; -echo ''; -echo '\n"; -echo '
' . get_string("alternatelogin", "auth", htmlspecialchars($CFG->wwwroot.'/login/index.php')) . '
'; -echo '
'; - -/// An alternate url for lost passwords. It means we can use external lost password -/// recovery for all users. Effectively disables built-in processes!!! -echo '
'; -echo ''; -echo '\n"; -echo '
' . get_string("forgottenpassword", "auth" ) . '
'; -echo '
'; - -/// Instructions about login/password -/// to be showed to users -echo '
'; -echo ''; -echo '\n"; -echo '
' . get_string("authinstructions", "auth") . '
'; -echo '
'; - -echo ''; - -//////////////////////////////////////////////////////////////////////////////// -echo '
'; -echo ''; -echo ''; -admin_externalpage_print_footer(); +redirect ($returnurl); ?> diff --git a/admin/auth_config.php b/admin/auth_config.php index a9cb8fd18a..6848e7c551 100644 --- a/admin/auth_config.php +++ b/admin/auth_config.php @@ -6,18 +6,17 @@ require_once '../config.php'; require_once $CFG->libdir.'/adminlib.php'; -admin_externalpage_setup('userauthentication'); $auth = required_param('auth', PARAM_SAFEDIR); + +admin_externalpage_setup('authsetting'.$auth); + $authplugin = get_auth_plugin($auth); $err = array(); -// save configuration changes -if ($frm = data_submitted()) { - - if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); - } +$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths"; +// save configuration changes +if ($frm = data_submitted() and confirm_sesskey()) { $frm = stripslashes_recursive($frm); $authplugin->validate_form($frm, $err); @@ -37,7 +36,7 @@ if ($frm = data_submitted()) { } } } - redirect("auth.php"); + redirect($returnurl); exit; } } else { diff --git a/admin/block.php b/admin/block.php index 49048f3e2d..d21218f23c 100644 --- a/admin/block.php +++ b/admin/block.php @@ -6,14 +6,14 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/blocklib.php'); - admin_externalpage_setup('manageblocks'); - $blockid = required_param('block', PARAM_INT); - if(($blockrecord = blocks_get_record($blockid)) === false) { + if(!$blockrecord = blocks_get_record($blockid)) { error('This block does not exist'); } + admin_externalpage_setup('blocksetting'.$blockrecord->name); + $block = block_instance($blockrecord->name); if($block === false) { error('Problem in instantiating block object'); @@ -50,11 +50,6 @@ $strmanageblocks = get_string('manageblocks'); $strblockname = $block->get_title(); - // $CFG->pagepath is used to generate the body and id attributes for the body tag - // of the page. It is also used to generate the link to the Moodle Docs for this view. - $CFG->pagepath = 'block/' . $block->name() . '/config'; - - admin_externalpage_print_header(); print_heading($strblockname); @@ -70,6 +65,6 @@ echo '

'; $block->config_print(); echo ''; - admin_externalpage_print_footer(); + print_footer(); ?> diff --git a/admin/blocks.php b/admin/blocks.php index 6b9a8b7dbd..b9c6cc3f5a 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -29,10 +29,6 @@ $strmultiple = get_string('blockmultiple', 'admin'); $strshowblockcourse = get_string('showblockcourse'); - admin_externalpage_print_header(); - - print_heading($strmanageblocks); - /// If data submitted, then process and store. if (!empty($hide) && confirm_sesskey()) { @@ -40,6 +36,7 @@ error("Block doesn't exist!"); } set_field('block', 'visible', '0', 'id', $block->id); // Hide block + admin_get_root(true, false); // settings not required - only pages } if (!empty($show) && confirm_sesskey() ) { @@ -47,6 +44,7 @@ error("Block doesn't exist!"); } set_field('block', 'visible', '1', 'id', $block->id); // Show block + admin_get_root(true, false); // settings not required - only pages } if (!empty($multiple) && confirm_sesskey()) { @@ -55,9 +53,12 @@ } $block->multiple = !$block->multiple; update_record('block', $block); + admin_get_root(true, false); // settings not required - only pages } if (!empty($delete) && confirm_sesskey()) { + admin_externalpage_print_header(); + print_heading($strmanageblocks); if (!$block = blocks_get_record($delete)) { error("Block doesn't exist!"); @@ -130,6 +131,9 @@ } } + admin_externalpage_print_header(); + print_heading($strmanageblocks); + /// Main display starts here /// Get and sort the existing blocks @@ -174,21 +178,26 @@ foreach ($blockbyname as $blockname => $blockid) { $blockobject = $blockobjects[$blockid]; + $block = $blocks[$blockid]; $delete = ''.$strdelete.''; $settings = ''; // By default, no configuration - if($blockobject->has_config()) { - $settings = ''.$strsettings.''; + if ($blockobject->has_config()) { + if (file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) { + $settings = ''.$strsettings.''; + } else { + $settings = ''.$strsettings.''; + } } // MDL-11167, blocks can be placed on mymoodle, or the blogs page // and it should not show up on course search page - + $totalcount = count_records('block_instance', 'blockid', $blockid); - - $count = count_records_sql('SELECT COUNT(*) - FROM '.$CFG->prefix.'block_instance + + $count = count_records_sql('SELECT COUNT(*) + FROM '.$CFG->prefix.'block_instance WHERE blockid = '.$blockid.' AND pagetype = \'course-view\''); diff --git a/admin/filter.php b/admin/filter.php index c372dda28a..b1c790acce 100644 --- a/admin/filter.php +++ b/admin/filter.php @@ -6,20 +6,18 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/tablelib.php'); - admin_externalpage_setup('managefilters'); - // get parameters $param = new Object; - $param->filter = required_param('filter', PARAM_PATH); - $param->submit = optional_param('submit', 0, PARAM_BOOL); - $param->reset = optional_param('reset', 0, PARAM_BOOL); + $filterfull = required_param('filter', PARAM_PATH); + $forcereset = optional_param('reset', 0, PARAM_BOOL); + + $filtername = substr($filterfull, strpos( $filterfull, '/' )+1 ) ; - $filtername = substr($param->filter, strpos( $param->filter, '/' )+1 ) ; + admin_externalpage_setup('filtersetting'.str_replace('/', '', $filterfull)); + + $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters"; - // $CFG->pagepath is used to generate the body and id attributes for the body tag - // of the page. It is also used to generate the link to the Moodle Docs for this view. - $CFG->pagepath = 'filter/' . $filtername . '/config'; // get translated strings for use on page $txt = new Object; @@ -32,12 +30,7 @@ //====================== // if reset pressed let filter config page handle it - $forcereset = false; - if (!empty($param->reset)) { - $forcereset = true; - } - else - if ($config = data_submitted()) { + if ($config = data_submitted() and !$forcereset) { // check session key if (!confirm_sesskey()) { @@ -61,7 +54,7 @@ set_config($name, stripslashes($value)); } } - redirect("$CFG->wwwroot/$CFG->admin/filters.php"); + redirect($returnurl); exit; } @@ -79,11 +72,11 @@ print_simple_box_start("center",''); ?> - +
- dirroot/$param->filter/filterconfig.html"; ?> + dirroot/$filterfull/filterconfig.html"; ?> diff --git a/admin/filters.php b/admin/filters.php index 978fdbebee..02144fd65b 100644 --- a/admin/filters.php +++ b/admin/filters.php @@ -1,135 +1,73 @@ libdir.'/adminlib.php'); - require_once($CFG->libdir.'/tablelib.php'); - // defines - define('FILTER_TABLE','filter_administration_table'); + $action = optional_param('action', '', PARAM_ACTION); + $filterpath = optional_param('filterpath', '', PARAM_PATH); - admin_externalpage_setup('managefilters'); + require_login(); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); - // get values from page - $params = new object(); - $params->action = optional_param('action', '', PARAM_ACTION); - $params->filterpath = optional_param('filterpath', '', PARAM_PATH); - $params->cachetext = optional_param('cachetext', 0, PARAM_INT); - $params->filterall = optional_param('filterall', 0, PARAM_BOOL); - $params->filteruploadedfiles = optional_param('filteruploadedfiles', 0, PARAM_INT); - $params->filtermatchoneperpage = optional_param('filtermatchoneperpage', 0, PARAM_BOOL); - $params->filtermatchonepertext = optional_param('filtermatchonepertext', 0, PARAM_BOOL); + $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters"; - // some basic information - $url = 'filters.php'; - $myurl = "$url?sesskey=" . sesskey(); - $img = "$CFG->pixpath/t"; - - // get translated strings for use on page - $txt = new object(); - $txt->managefilters = get_string('managefilters'); - $txt->administration = get_string('administration'); - $txt->configuration = get_string('configuration'); - $txt->name = get_string('name'); - $txt->hide = get_string('hide'); - $txt->show = get_string('show'); - $txt->hideshow = "$txt->hide/$txt->show"; - $txt->settings = get_string('settings'); - $txt->up = get_string('up'); - $txt->down = get_string('down'); - $txt->updown = "$txt->up/$txt->down"; - $txt->cachetext = get_string('cachetext', 'admin'); - $txt->configcachetext = get_string('configcachetext', 'admin'); - $txt->filteruploadedfiles = get_string('filteruploadedfiles','admin'); - $txt->configfilteruploadedfiles = get_string('configfilteruploadedfiles','admin'); - $txt->filterall = get_string('filterall','admin'); - $txt->filtermatchoneperpage = get_string('filtermatchoneperpage','admin'); - $txt->filtermatchonepertext = get_string('filtermatchonepertext','admin'); - $txt->configfilterall = get_string('configfilterall','admin'); - $txt->configfiltermatchoneperpage = get_string('configfiltermatchoneperpage','admin'); - $txt->configfiltermatchonepertext = get_string('configfiltermatchonepertext','admin'); - $txt->cachecontrols = get_string('cachecontrols'); - $txt->yes = get_string('yes'); - $txt->no = get_string('no'); - $txt->none = get_string('none'); - $txt->allfiles = get_string('allfiles'); - $txt->htmlfilesonly = get_string('htmlfilesonly'); + if (!confirm_sesskey()) { + redirect($returnurl); + } - // get a list of possible filters (and translate name if possible) - // note filters can be in the dedicated filters area OR in their - // associated modules + // get a list of installed filters $installedfilters = array(); - $filtersettings = array(); $filterlocations = array('mod','filter'); foreach ($filterlocations as $filterlocation) { $plugins = get_list_of_plugins($filterlocation); foreach ($plugins as $plugin) { $pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php"; - $settingspath = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html"; if (is_readable($pluginpath)) { - $name = trim(get_string("filtername", $plugin)); - if (empty($name) or ($name == '[[filtername]]')) { - $name = ucfirst($plugin); - } - $installedfilters["$filterlocation/$plugin"] = $name; - if (is_readable($settingspath)) { - $filtersettings[] = "$filterlocation/$plugin"; - } + $installedfilters["$filterlocation/$plugin"] = "$filterlocation/$plugin"; } } } // get all the currently selected filters if (!empty($CFG->textfilters)) { - $oldactivefilters = explode(',', $CFG->textfilters); - $oldactivefilters = array_unique($oldactivefilters); + $activefilters = explode(',', $CFG->textfilters); } else { - $oldactivefilters = array(); - } - - // take this opportunity to clean up filters - $activefilters = array(); - foreach ($oldactivefilters as $oldactivefilter) { - if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) { - $activefilters[] = $oldactivefilter; - } + $activefilters = array(); } //====================== // Process Actions //====================== - if ($params->action=="") { - // store cleaned active filers in db - set_config('textfilters', implode(',', $activefilters)); - } elseif (($params->action=="hide") and confirm_sesskey()) { - $key=array_search($params->filterpath, $activefilters); + switch ($action) { + + case 'hide': + $key=array_search($filterpath, $activefilters); // check filterpath is valid if ($key===false) { - // ignore it - doubleclick?? - } else { - // just delete it - unset($activefilters[$key]); - set_config('textfilters', implode(',', $activefilters)); + break; } - } elseif (($params->action=="show") and confirm_sesskey()) { + // just delete it + unset($activefilters[$key]); + break; + + case 'show': // check filterpath is valid - if (!array_key_exists($params->filterpath, $installedfilters)) { - error("Filter $params->filterpath is not currently installed", $url); - } elseif (array_search($params->filterpath,$activefilters)) { + if (!array_key_exists($filterpath, $installedfilters)) { + error("Filter $filterpath is not currently installed", $url); + } elseif (array_search($filterpath,$activefilters)) { // filterpath is already active - doubleclick?? } else { // add it to installed filters - $activefilters[] = $params->filterpath; + $activefilters[] = $filterpath; $activefilters = array_unique($activefilters); - set_config('textfilters', implode(',', $activefilters)); } - } elseif (($params->action=="down") and confirm_sesskey()) { - $key=array_search($params->filterpath, $activefilters); + break; + + case 'down': + $key=array_search($filterpath, $activefilters); // check filterpath is valid if ($key===false) { - error("Filter $params->filterpath is not currently active", $url); + error("Filter $filterpath is not currently active", $url); } elseif ($key>=(count($activefilters)-1)) { // cannot be moved any further down - doubleclick?? } else { @@ -137,13 +75,14 @@ $fsave = $activefilters[$key]; $activefilters[$key] = $activefilters[$key+1]; $activefilters[$key+1] = $fsave; - set_config('textfilters', implode(',', $activefilters)); } - } elseif (($params->action=="up") and confirm_sesskey()) { - $key=array_search($params->filterpath, $activefilters); + break; + + case 'up': + $key=array_search($filterpath, $activefilters); // check filterpath is valid if ($key===false) { - error("Filter $params->filterpath is not currently active", $url); + error("Filter $filterpath is not currently active", $url); } elseif ($key<1) { //cannot be moved any further up - doubleclick?? } else { @@ -151,126 +90,12 @@ $fsave = $activefilters[$key]; $activefilters[$key] = $activefilters[$key-1]; $activefilters[$key-1] = $fsave; - set_config('textfilters', implode(',', $activefilters)); - } - } elseif (($params->action=="config") and confirm_sesskey()) { - set_config('cachetext', $params->cachetext); - set_config('filteruploadedfiles', $params->filteruploadedfiles); - set_config('filterall', $params->filterall); - set_config('filtermatchoneperpage', $params->filtermatchoneperpage); - set_config('filtermatchonepertext', $params->filtermatchonepertext); - } - - //====================== - // Build Display Objects - //====================== - - // construct the display array with installed filters - // at the top in the right order - $displayfilters = array(); - foreach ($activefilters as $activefilter) { - $name = $installedfilters[$activefilter]; - $displayfilters[$activefilter] = $name; - } - foreach ($installedfilters as $key => $filter) { - if (!array_key_exists($key, $displayfilters)) { - $displayfilters[$key] = $filter; } + break; } - // construct the flexible table ready to display - $table = new flexible_table(FILTER_TABLE); - $table->define_columns(array('name', 'hideshow', 'order', 'settings')); - $table->define_headers(array($txt->name, $txt->hideshow, $txt->updown, $txt->settings)); - $table->define_baseurl("$CFG->wwwroot/$CFG->admin/filters.php"); - $table->set_attribute('id', 'filters'); - $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide'); - $table->setup(); - - // iterate through filters adding to display table - $updowncount = 1; - $activefilterscount = count($activefilters); - foreach ($displayfilters as $path => $name) { - $upath = urlencode($path); - // get hide/show link - if (in_array($path, $activefilters)) { - $hideshow = ""; - $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"$txt->hide\" />"; - $hidden = false; - $displayname = "$name"; - } - else { - $hideshow = ""; - $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"$txt->show\" />"; - $hidden = true; - $displayname = "$name"; - } - - // get up/down link (only if not hidden) - $updown = ''; - if (!$hidden) { - if ($updowncount>1) { - $updown .= ""; - $updown .= "\"$txt-up\" /> "; - } - else { - $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> "; - } - if ($updowncount<$activefilterscount) { - $updown .= ""; - $updown .= "\"$txt-down\" />"; - } - else { - $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" />"; - } - ++$updowncount; - } - - // settings link (if defined) - $settings = ''; - if (in_array($path, $filtersettings)) { - $settings = ""; - $settings .= "{$txt->settings}"; - } - - // write data into the table object - $table->add_data(array($displayname, $hideshow, $updown, $settings)); - } - - // build options list for cache lifetime - $seconds = array(604800,86400,43200,10800,7200,3600,2700,1800,900,600,540,480,420,360,300,240,180,120,60,30,0); - unset($lifetimeoptions); - foreach ($seconds as $second) { - if ($second>=86400) { - $options[$second] = get_string('numdays','',$second/86400); - } - elseif ($second>=3600) { - $options[$second] = get_string('numhours','',$second/3600); - } - elseif ($second>=60) { - $options[$second] = get_string('numminutes','',$second/60); - } - elseif ($second>=1) { - $options[$second] = get_string('numseconds','',$second); - } - else { - $options[$second] = get_string('no'); - } - } - - //============================== - // Display logic - //============================== - - admin_externalpage_print_header(); - - print_heading_with_help($txt->managefilters, 'filters'); - - // print the table of all the filters - $table->print_html(); - - // cache control table has been removed - - admin_externalpage_print_footer(); + // save and return + set_config('textfilters', implode(',', $activefilters)); + redirect($returnurl); ?> diff --git a/admin/index.php b/admin/index.php index 7efddb78db..d221a5ea36 100644 --- a/admin/index.php +++ b/admin/index.php @@ -204,20 +204,14 @@ // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it) // (this should only have any effect during initial install). - $adminroot = admin_get_root(); - $adminroot->prune('backups'); // backup settings table not created yet - apply_default_settings($adminroot); + admin_apply_default_settings(NULL, true); /// This is used to handle any settings that must exist in $CFG but which do not exist in /// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions). - apply_default_exception_settings(array('alternateloginurl' => '', - 'auth' => 'email', + apply_default_exception_settings(array('auth' => 'email', 'auth_pop3mailbox' => 'INBOX', - 'changepassword' => '', 'enrol' => 'manual', 'enrol_plugins_enabled' => 'manual', - 'guestloginbutton' => 1, - 'registerauth' => 'email', 'style' => 'default', 'template' => 'default', 'theme' => 'standardwhite', @@ -297,7 +291,7 @@ notify(get_string('environmentok', 'admin'), 'notifysuccess'); print_box_start('generalbox', 'notice'); // MDL-8330 print_string('langpackwillbeupdated', 'admin'); - print_box_end(); + print_box_end(); echo '
'; echo ''; echo ''; @@ -430,7 +424,7 @@ upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards /// Check for changes to RPC functions - require_once($CFG->dirroot.'/admin/mnet/adminlib.php'); + require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php"); upgrade_RPC_functions("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards /// Upgrade all plugins for gradebook @@ -548,10 +542,10 @@ } } - $adminroot = admin_get_root(); + $adminroot =& admin_get_root(); /// Check if there are any new admin settings which have still yet to be set - if( any_new_admin_settings( $adminroot ) ){ + if (any_new_admin_settings($adminroot)){ redirect('upgradesettings.php'); } diff --git a/admin/lang.php b/admin/lang.php index 31746ee49a..830c3e0863 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -99,7 +99,7 @@ $title = $strlanguage; break; } - $navlinks[] = array('name' => $strlanguage, 'link' => "$CFG->wwwroot/admin/lang.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strlanguage, 'link' => "$CFG->wwwroot/$CFG->admin/lang.php", 'type' => 'misc'); $navigation = build_navigation($navlinks); admin_externalpage_print_header(); @@ -119,17 +119,17 @@ } if (has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) { $firstrow[] = new tabobject('uselocal', - $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1", + "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1", $strlocalstringcustomization ); } if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) { $firstrow[] = new tabobject('usemaster', - $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0", + "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0", $strlangpackmaintaining ); } - $secondrow[] = new tabobject('missing', $CFG->wwwroot.'/admin/lang.php?mode=missing', $strmissingstrings ); - $secondrow[] = new tabobject('compare', $CFG->wwwroot.'/admin/lang.php?mode=compare', $streditstrings ); - $secondrow[] = new tabobject('helpfiles', $CFG->wwwroot.'/admin/lang.php?mode=helpfiles', $stredithelpdocs ); + $secondrow[] = new tabobject('missing', "$CFG->wwwroot/$CFG->admin/lang.php?mode=missing", $strmissingstrings ); + $secondrow[] = new tabobject('compare', "$CFG->wwwroot/$CFG->admin/lang.php?mode=compare", $streditstrings ); + $secondrow[] = new tabobject('helpfiles', "$CFG->wwwroot/$CFG->admin/lang.php?mode=helpfiles", $stredithelpdocs ); $tabs = array($firstrow, $secondrow); print_tabs($tabs, $currenttab, $inactive, $activated); diff --git a/admin/mnet/access_control.php b/admin/mnet/access_control.php index e810593939..9b3a34cebe 100644 --- a/admin/mnet/access_control.php +++ b/admin/mnet/access_control.php @@ -45,7 +45,7 @@ if (!empty($action) and confirm_sesskey()) { // fetch the record in question $id = required_param('id', PARAM_INT); if (!$idrec = get_record('mnet_sso_access_control', 'id', $id)) { - error(get_string('recordnoexists','mnet'), '/admin/mnet/access_control.php'); + error(get_string('recordnoexists','mnet'), "$CFG->wwwroot/$CFG->admin/mnet/access_control.php"); } switch ($action) { @@ -60,7 +60,7 @@ if (!empty($action) and confirm_sesskey()) { // require the access parameter, and it must be 'allow' or 'deny' $accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA))); if ($accessctrl != 'allow' and $accessctrl != 'deny') { - error(get_string('invalidaccessparam', 'mnet') , '/admin/mnet/access_control.php'); + error(get_string('invalidaccessparam', 'mnet') , "$CFG->wwwroot/$CFG->admin/mnet/access_control.php"); } if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) { @@ -73,7 +73,7 @@ if (!empty($action) and confirm_sesskey()) { break; default: - print_error('invalidactionparam', 'mnet', '/admin/mnet/access_control.php'); + print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php"); } } @@ -84,7 +84,7 @@ if ($form = data_submitted() and confirm_sesskey()) { // check permissions and verify form input if (!has_capability('moodle/user:delete', $sitecontext)) { - error(get_string('nomodifyacl','mnet'), '/admin/mnet/access_control.php'); + error(get_string('nomodifyacl','mnet'), "$CFG->wwwroot/$CFG->admin/mnet/access_control.php"); } if (empty($form->username)) { $formerror['username'] = get_string('enterausername','mnet'); diff --git a/admin/mnet/adminlib.php b/admin/mnet/adminlib.php index bd33b816f6..e4da39eca0 100644 --- a/admin/mnet/adminlib.php +++ b/admin/mnet/adminlib.php @@ -72,7 +72,7 @@ function mnet_get_functions($type, $parentname) { if (!file_exists($filename)) return false; if (extension_loaded('tokenizer')) { - include_once $CFG->dirroot.'/admin/mnet/MethodTable.php'; + include_once "$CFG->dirroot/$CFG->admin/mnet/MethodTable.php"; $functions = (array)MethodTable::create($filename,false); } diff --git a/admin/mnet/delete.html b/admin/mnet/delete.html index 973231e4a5..cc2b67b2c2 100644 --- a/admin/mnet/delete.html +++ b/admin/mnet/delete.html @@ -1,7 +1,7 @@ $stradministration, 'link' => $CFG->wwwroot.'/admin/index.php', 'type' => 'misc'); -$navlinks[] = array('name' => get_string('mnetsettings', 'mnet'), 'link' => $CFG->wwwroot.'/admin/mnet/index.php', 'type' => 'misc'); +$navlinks[] = array('name' => $stradministration, 'link' => "$CFG->wwwroot/$CFG->admin/index.php", 'type' => 'misc'); +$navlinks[] = array('name' => get_string('mnetsettings', 'mnet'), 'link' => "$CFG->wwwroot/$CFG->admin/mnet/index.php", 'type' => 'misc'); $navlinks[] = array('name' => get_string('deletehost', 'mnet'), 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header("$site->shortname: $strmnetsettings", "$site->fullname", $navigation); diff --git a/admin/mnet/enr_courses.php b/admin/mnet/enr_courses.php index 7e09e5fba2..8735ecc9db 100644 --- a/admin/mnet/enr_courses.php +++ b/admin/mnet/enr_courses.php @@ -37,7 +37,7 @@ " class=\"icon\" alt=\"".get_string("course")."\" />"; foreach ($courses as $course) { - $link = $CFG->wwwroot . '/admin/mnet/enr_course_enrol.php?' + $link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?" . "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}"; echo '
' . "" diff --git a/admin/mnet/enr_hosts.php b/admin/mnet/enr_hosts.php index ec82c2cc43..085539bc74 100644 --- a/admin/mnet/enr_hosts.php +++ b/admin/mnet/enr_hosts.php @@ -37,7 +37,7 @@ . ''; $hosts = $enrolment->list_remote_servers(); foreach ($hosts as $host) { - $coursesurl = "{$CFG->wwwroot}/admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}"; + $coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}"; $coursecount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_course WHERE hostid={$host->id}"); if (empty($coursecount)) { $coursecount = '?'; @@ -49,7 +49,7 @@ . "" . "" // TODO: teach report/log/index.php to show per-host-logs - // . '' . ''; } diff --git a/admin/mnet/mnet_themes.php b/admin/mnet/mnet_themes.php index b82c1794f7..180d8c3343 100644 --- a/admin/mnet/mnet_themes.php +++ b/admin/mnet/mnet_themes.php @@ -7,8 +7,7 @@ error_reporting(E_ALL); ini_set('display_errors', true); require_login(); - $adminroot = admin_get_root(); - admin_externalpage_setup('mnetpeers', $adminroot); + admin_externalpage_setup('mnetpeers'); $context = get_context_instance(CONTEXT_SYSTEM); diff --git a/admin/module.php b/admin/module.php index 396cf85479..d5a74eaab1 100644 --- a/admin/module.php +++ b/admin/module.php @@ -4,8 +4,6 @@ require_once('../config.php'); require_once($CFG->libdir.'/adminlib.php'); - admin_externalpage_setup('managemodules'); - /// If data submitted, then process and store. if ($config = data_submitted()) { @@ -17,6 +15,7 @@ if ($module != '') { require_once("$CFG->dirroot/mod/$module/lib.php"); + admin_externalpage_setup('modsetting'.$module); // if the config.html contains a hidden form field giving // the module name then the form does not have to prefix all // its variable names, we will do it here. @@ -28,6 +27,8 @@ $moduleconfig($config); } } else { + admin_externalpage_setup('managemodules'); + $moduleprefix = ''; } @@ -44,6 +45,7 @@ /// Otherwise print the form. $module = required_param('module', PARAM_SAFEDIR); require_once("$CFG->dirroot/mod/$module/lib.php"); + admin_externalpage_setup('modsetting'.$module); $strmodulename = get_string("modulename", $module); diff --git a/admin/modules.php b/admin/modules.php index 85be458acb..8471c74181 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -29,10 +29,6 @@ $stractivitymodule = get_string("activitymodule"); $strshowmodulecourse = get_string('showmodulecourse'); - admin_externalpage_print_header(); - - print_heading($stractivities); - /// If data submitted, then process and store. if (!empty($hide) and confirm_sesskey()) { @@ -55,6 +51,7 @@ FROM {$CFG->prefix}course_modules WHERE visibleold=1 AND module={$module->id})"; execute_sql($sql, false); + admin_get_root(true, false); // settings not required - only pages } if (!empty($show) and confirm_sesskey()) { @@ -72,9 +69,12 @@ FROM {$CFG->prefix}course_modules WHERE visible=1 AND module={$module->id})"; execute_sql($sql, false); + admin_get_root(true, false); // settings not required - only pages } if (!empty($delete) and confirm_sesskey()) { + admin_externalpage_print_header(); + print_heading($stractivities); $strmodulename = get_string("modulename", "$delete"); @@ -173,6 +173,9 @@ } } + admin_externalpage_print_header(); + print_heading($stractivities); + /// Get and sort the existing modules if (!$modules = get_records("modules")) { @@ -206,7 +209,9 @@ $delete = "name&sesskey=$USER->sesskey\">$strdelete"; - if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) { + if (file_exists("$CFG->dirroot/mod/$module->name/settings.php")) { + $settings = "name\">$strsettings"; + } else if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) { $settings = "name\">$strsettings"; } else { $settings = ""; @@ -237,11 +242,11 @@ } $table->add_data(array( - ''.$icon.' '.$modulename.'', - $countlink, - ''.$module->version.'', - $visible, - $delete, + ''.$icon.' '.$modulename.'', + $countlink, + ''.$module->version.'', + $visible, + $delete, $settings )); } diff --git a/admin/pagelib.php b/admin/pagelib.php index 8ff148e197..7870020e6f 100644 --- a/admin/pagelib.php +++ b/admin/pagelib.php @@ -21,7 +21,6 @@ page_map_class(PAGE_ADMIN, 'page_admin'); class page_admin extends page_base { var $section; - var $pathtosection; var $visiblepathtosection; // hack alert! @@ -34,22 +33,12 @@ class page_admin extends page_base { return; } - $adminroot = admin_get_root(); + $adminroot =& admin_get_root(false, false); //settings not required - only pages // fetch the path parameter $this->section = $section; - - $this->visiblepathtosection = array(); - - // this part is (potentially) processor-intensive... there's gotta be a better way - // of handling this - if ($this->pathtosection = $adminroot->path($this->section)) { - foreach($this->pathtosection as $element) { - if ($pointer = $adminroot->locate($element)) { - array_push($this->visiblepathtosection, $pointer->visiblename); - } - } - } + $current =& $adminroot->locate($section, true); + $this->visiblepathtosection = array_reverse($current->visiblepath); // all done $this->full_init_done = true; @@ -74,9 +63,9 @@ class page_admin extends page_base { function url_get_path() { global $CFG; - $adminroot = admin_get_root(); + $adminroot =& admin_get_root(false, false); //settings not required - only pages - $root = $adminroot->locate($this->section); + $root =& $adminroot->locate($this->section); if (is_a($root, 'admin_externalpage')) { return $root->url; } else { @@ -110,7 +99,7 @@ class page_admin extends page_base { parent::init_quick($data); } - function print_header($section = '') { + function print_header($section = '', $focus='') { global $USER, $CFG, $SITE; $this->init_full($section); // we're trusting that init_full() has already been called by now; it should have. @@ -132,7 +121,7 @@ class page_admin extends page_base { } $navigation = build_navigation($navlinks); - print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation,'', '', true, $buttons, ''); + print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, ''); } function get_type() { diff --git a/admin/report/backups/index.php b/admin/report/backups/index.php index d7fab79915..a8a4925dee 100644 --- a/admin/report/backups/index.php +++ b/admin/report/backups/index.php @@ -5,11 +5,9 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->dirroot.'/backup/lib.php'); - $adminroot = admin_get_root(); + admin_externalpage_setup('reportbackups'); - admin_externalpage_setup('reportbackups', $adminroot); - - admin_externalpage_print_header($adminroot); + admin_externalpage_print_header(); $courseid = optional_param('courseid', 0, PARAM_INT); @@ -135,6 +133,6 @@ print_simple_box_end(); } - admin_externalpage_print_footer($adminroot); + print_footer(); ?> diff --git a/admin/search.php b/admin/search.php index e94f8ef694..c07f86241a 100644 --- a/admin/search.php +++ b/admin/search.php @@ -5,152 +5,59 @@ require_once('../config.php'); require_once($CFG->libdir.'/adminlib.php'); -$query = trim(stripslashes_safe(required_param('query', PARAM_NOTAGS))); // Search string - -admin_externalpage_setup('search'); // now hidden page - -$CFG->adminsearchquery = $query; // So we can reference it in search boxes later in this invocation - - -// now we'll deal with the case that the admin has submitted the form with changed settings +$query = trim(stripslashes(optional_param('query', '', PARAM_NOTAGS))); // Search string +$adminroot =& admin_get_root(); // need all settings here +$adminroot->search = $query; // So we can reference it in search boxes later in this invocation $statusmsg = ''; +$errormsg = ''; +$focus = ''; -if ($data = data_submitted()) { - $unslashed = (array)stripslashes_recursive($data); - if (confirm_sesskey()) { - $olddbsessions = !empty($CFG->dbsessions); - $changedsettings = search_settings(admin_get_root(), $query); - $errors = ''; - - foreach($changedsettings as $changedsetting) { - if (!isset($unslashed['s_' . $changedsetting->name])) { - $unslashed['s_' . $changedsetting->name] = ''; // needed for checkboxes - } - $errors .= $changedsetting->write_setting($unslashed['s_' . $changedsetting->name]); - } +admin_externalpage_setup('search'); // now hidden page - if ($olddbsessions != !empty($CFG->dbsessions)) { - require_logout(); - } +// now we'll deal with the case that the admin has submitted the form with changed settings +if ($data = data_submitted() and confirm_sesskey()) { + if (admin_write_settings($data)) { + $statusmsg = get_string('changessaved'); + } + $adminroot =& admin_get_root(true); //reload tree - if (empty($errors)) { - $statusmsg = get_string('changessaved'); - } else { - $statusmsg = get_string('errorwithsettings', 'admin') . '
' . $errors; - } - } else { - error(get_string('confirmsesskeybad', 'error')); + if (!empty($adminroot->errors)) { + $errormsg = get_string('errorwithsettings', 'admin'); + $firsterror = reset($adminroot->errors); + $focus = $firsterror->id; } - // now update $SITE - it might have been changed - $SITE = get_record('course', 'id', $SITE->id); - $COURSE = clone($SITE); } // and finally, if we get here, then there are matching settings and we have to print a form // to modify them -admin_externalpage_print_header(); +admin_externalpage_print_header($focus); -if ($statusmsg != '') { - notify ($statusmsg); +if ($errormsg !== '') { + notify ($errormsg); + +} else if ($statusmsg !== '') { + notify ($statusmsg, 'notifysuccess'); } -$resultshtml = search_settings_html(admin_get_root(), $query); +$resultshtml = admin_search_settings_html($query); // case insensitive search only echo ''; echo '
'; -echo ''; -echo ''; +echo ''; +echo ''; echo '
'; echo '
'; echo '
'; if ($resultshtml != '') { echo $resultshtml; - echo '
'; + echo '
'; } else { echo get_string('noresults','admin'); } echo '
'; echo ''; -admin_externalpage_print_footer(); - - -/** - * Find settings using a query. - * - * @param string &$node The node at which to start searching. Should be $ADMIN for all external calls to this function. - * @param string $query The search string. - * @return array An array containing admin_setting objects that match $query. - */ -function search_settings(&$node, $query) { - - if (is_a($node, 'admin_category')) { - $return = array(); - $entries = array_keys($node->children); - foreach ($entries as $entry) { - $return = array_merge($return, search_settings($node->children[$entry], $query)); - } - return $return; - } - - if (is_a($node, 'admin_settingpage')) { - $return = array(); - foreach ($node->settings as $setting) { - if (stristr($setting->name,$query) || stristr($setting->visiblename,$query) || stristr($setting->description,$query)) { - $return[] =& $setting; - } - unset($setting); // needed to prevent odd (imho) reference behaviour - // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 - } - return $return; - } - - return array(); - -} - -function search_settings_html(&$node, $query) { - - global $CFG; - - if ($query == ''){ - return ''; - } - - if (is_a($node, 'admin_category')) { - $entries = array_keys($node->children); - $return = ''; - foreach ($entries as $entry) { - $return .= search_settings_html($node->children[$entry], $query); - } - return $return; - } - - if (is_a($node, 'admin_settingpage')) { - $foundsettings = array(); - foreach ($node->settings as $setting) { - if (stristr($setting->name,$query) || stristr($setting->visiblename,$query) || stristr($setting->description,$query)) { - $foundsettings[] =& $setting; - } - unset($setting); // needed to prevent odd (imho) reference behaviour - // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 - } - $return = ''; - if (count($foundsettings) > 0) { - $return .= print_heading(get_string('searchresults','admin').' - '. '' . $node->visiblename . '', '', 2, 'main', true); - $return .= '
' . "\n"; - foreach ($foundsettings as $foundsetting) { - $return .= '
' . "\n"; - $return .= highlight($query,$foundsetting->output_html()); - } - $return .= '
'; - } - return $return; - } - - return ''; - -} +print_footer(); ?> diff --git a/admin/settings.php b/admin/settings.php index 8837ddb208..9ff2b4d3a5 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -5,114 +5,98 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/blocklib.php'); require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php'); -if ($site = get_site()) { - require_login(); -} - - -page_map_class(PAGE_ADMIN, 'page_admin'); - -$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number - -$section = optional_param('section', '', PARAM_ALPHAEXT); - -$PAGE->init_extra($section); // hack alert! - -$adminediting = optional_param('adminedit', -1, PARAM_BOOL); +$section = required_param('section', PARAM_SAFEDIR); $return = optional_param('return','', PARAM_ALPHA); +$adminediting = optional_param('adminedit', -1, PARAM_BOOL); -if (!isset($USER->adminediting)) { - $USER->adminediting = false; -} - -if ($PAGE->user_allowed_editing()) { - if ($adminediting == 1) { - $USER->adminediting = true; - } elseif ($adminediting == 0) { - $USER->adminediting = false; - } -} - -$adminroot = admin_get_root(); +require_login(); -$root = $adminroot->locate($PAGE->section); +$adminroot =& admin_get_root(); // need all settings +$page =& $adminroot->locate($section); -if (!is_a($root, 'admin_settingpage')) { - error(get_string('sectionerror', 'admin')); +if (empty($page) or !is_a($page, 'admin_settingpage')) { + error(get_string('sectionerror', 'admin'), "$CFG->wwwroot/$CFG->admin/"); die; } -if (!($root->check_access())) { +if (!($page->check_access())) { error(get_string('accessdenied', 'admin')); die; } -$CFG->pagepath = 'admin/setting/'.$section; - - - /// WRITING SUBMITTED DATA (IF ANY) ------------------------------------------------------------------------------- $statusmsg = ''; +$errormsg = ''; +$focus = ''; -if ($data = data_submitted()) { - if (confirm_sesskey()) { - $olddbsessions = !empty($CFG->dbsessions); - $unslashed = (array)stripslashes_recursive($data); - $errors = $root->write_settings($unslashed); - //force logout if dbsession setting changes - if ($olddbsessions != !empty($CFG->dbsessions)) { - require_logout(); - } - if (empty($errors)) { - switch ($return) { - case 'site': - redirect("$CFG->wwwroot/"); - case 'admin': - redirect("$CFG->wwwroot/$CFG->admin/"); - default: - $statusmsg = get_string('changessaved'); - } - } else { - $statusmsg = get_string('errorwithsettings', 'admin') . '
' . $errors; +if ($data = data_submitted() and confirm_sesskey()) { + if (admin_write_settings($data)) { + $statusmsg = get_string('changessaved'); + } + + if (empty($adminroot->errors)) { + switch ($return) { + case 'site': redirect("$CFG->wwwroot/"); + case 'admin': redirect("$CFG->wwwroot/$CFG->admin/"); } } else { - error(get_string('confirmsesskeybad', 'error')); + $errormsg = get_string('errorwithsettings', 'admin'); + $firsterror = reset($adminroot->errors); + $focus = $firsterror->id; + } + $adminroot =& admin_get_root(true); //reload tree + $page =& $adminroot->locate($section); +} + +/// very hacky page setup +page_map_class(PAGE_ADMIN, 'page_admin'); +$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number +$PAGE->init_extra($section); +$CFG->pagepath = 'admin/setting/'.$section; + +if (!isset($USER->adminediting)) { + $USER->adminediting = false; +} + +if ($PAGE->user_allowed_editing()) { + if ($adminediting == 1) { + $USER->adminediting = true; + } elseif ($adminediting == 0) { + $USER->adminediting = false; } - // now update $SITE - it might have been changed - $SITE = get_record('course', 'id', $SITE->id); - $COURSE = clone($SITE); } /// print header stuff ------------------------------------------------------------ -// header must be printed after the redirects and require_logout if (empty($SITE->fullname)) { - print_header($root->visiblename, $root->visiblename); + print_header($page->visiblename, $page->visiblename, '', $focus); print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%'); - if ($statusmsg != '') { - notify ($statusmsg); + if ($errormsg !== '') { + notify ($errormsg); + + } else if ($statusmsg !== '') { + notify ($statusmsg, 'notifysuccess'); } // --------------------------------------------------------------------------------------------------------------- echo '
'; echo '
'; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; - echo $root->output_html(); + echo $page->output_html(); - echo '
'; + echo '
'; echo '
'; echo ''; -} -if (!empty($SITE->fullname)) { +} else { $pageblocks = blocks_setup($PAGE); $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), @@ -120,14 +104,14 @@ if (!empty($SITE->fullname)) { $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH); - $PAGE->print_header(); + $PAGE->print_header('', $focus); echo '
$icon
$enrolcount$coursecount - ".get_string('editenrolments', 'mnet')."' + // . '' // . get_string('logs', 'mnet').'
'; $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable; foreach ($lt as $column) { switch ($column) { case 'left': - echo '
'; + echo ''; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); print_container_end(); @@ -138,22 +122,25 @@ if (!empty($SITE->fullname)) { print_container_start(); echo ''; - if ($statusmsg != '') { - notify ($statusmsg); + if ($errormsg !== '') { + notify ($errormsg); + + } else if ($statusmsg !== '') { + notify ($statusmsg, 'notifysuccess'); } // --------------------------------------------------------------------------------------------------------------- echo '
'; echo '
'; - echo ''; - echo ''; - echo ''; - print_heading($root->visiblename); + echo ''; + echo ''; + echo ''; + print_heading($page->visiblename); - echo $root->output_html(); + echo $page->output_html(); - echo '
'; + echo '
'; echo '
'; echo '
'; @@ -163,7 +150,7 @@ if (!empty($SITE->fullname)) { break; case 'right': if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) { - echo '
'; + echo ''; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end(); diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index a81b5219f7..f656f8b54f 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -4,125 +4,87 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page - -$ADMIN->add('appearance', new admin_category('themes', get_string('themes'))); -// "themesettings" settingpage -$temp = new admin_settingpage('themesettings', get_string('themesettings', 'admin')); -$temp->add(new admin_setting_configtext('themelist', get_string('themelist', 'admin'), get_string('configthemelist','admin'), '', PARAM_NOTAGS)); -$temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allowuserthemes', 'admin'), get_string('configallowuserthemes', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('allowcategorythemes', get_string('allowcategorythemes', 'admin'), get_string('configallowcategorythemes', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1)); -$temp->add(new admin_setting_configcheckbox('showblocksonmodpages', get_string('showblocksonmodpages', 'admin'), get_string('configshowblocksonmodpages', 'admin'), 0)); -$temp->add(new admin_setting_configselect('hideactivitytypenavlink', get_string('hideactivitytypenavlink', 'admin'), get_string('confighideactivitytypenavlink', 'admin'), 0, -array( - 0 => get_string('hidefromnone', 'admin'), - 1 => get_string('hidefromstudents', 'admin'), - 2 => get_string('hidefromall', 'admin') - ))); -$ADMIN->add('themes', $temp); -$ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php')); - -# for CALENDAR_TF_12 and CALENDAR_TF_24 ... -require_once($CFG->dirroot . '/calendar/lib.php'); - -// calendar -$temp = new admin_settingpage('calendar', get_string('calendarsettings','admin')); -$temp->add(new admin_setting_special_adminseesall()); -$temp->add(new admin_setting_configselect('calendar_site_timeformat', get_string('pref_timeformat', 'calendar'), get_string('explain_site_timeformat', 'calendar'), '0', -array( 0 => get_string('default', 'calendar'), - CALENDAR_TF_12 => get_string('timeformat_12', 'calendar'), - CALENDAR_TF_24 => get_string('timeformat_24', 'calendar') - ))); -$temp->add(new admin_setting_configselect('calendar_startwday', get_string('configstartwday', 'admin'), get_string('helpstartofweek', 'admin'), 0, -array( - 0 => get_string('sunday', 'calendar'), - 1 => get_string('monday', 'calendar'), - 2 => get_string('tuesday', 'calendar'), - 3 => get_string('wednesday', 'calendar'), - 4 => get_string('thursday', 'calendar'), - 5 => get_string('friday', 'calendar'), - 6 => get_string('saturday', 'calendar') - ))); -$temp->add(new admin_setting_special_calendar_weekend()); -$temp->add(new admin_setting_configtext('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,PARAM_INT)); -$temp->add(new admin_setting_configtext('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,PARAM_INT)); -$ADMIN->add('appearance', $temp); - -// "filtersettings" settingpage -$temp = new admin_settingpage('filtersettings', get_string('filtersettings', 'admin')); -$temp->add(new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, array(604800 => get_string('numdays','',7), - 86400 => get_string('numdays','',1), - 43200 => get_string('numhours','',12), - 10800 => get_string('numhours','',3), - 7200 => get_string('numhours','',2), - 3600 => get_string('numhours','',1), - 2700 => get_string('numminutes','',45), - 1800 => get_string('numminutes','',30), - 900 => get_string('numminutes','',15), - 600 => get_string('numminutes','',10), - 540 => get_string('numminutes','',9), - 480 => get_string('numminutes','',8), - 420 => get_string('numminutes','',7), - 360 => get_string('numminutes','',6), - 300 => get_string('numminutes','',5), - 240 => get_string('numminutes','',4), - 180 => get_string('numminutes','',3), - 120 => get_string('numminutes','',2), - 60 => get_string('numminutes','',1), - 30 => get_string('numseconds','',30), - 0 => get_string('no')))); -$temp->add(new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0, array('0' => get_string('none'), - '1' => get_string('allfiles'), - '2' => get_string('htmlfilesonly')))); -$temp->add(new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('filterall', get_string('filterall', 'admin'), get_string('configfilterall', 'admin'), 0)); -$ADMIN->add('appearance', $temp); - - - - - -// "htmleditor" settingpage -$temp = new admin_settingpage('htmleditor', get_string('htmleditor', 'admin')); -$temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1)); -$temp->add(new admin_setting_configtext('editorbackgroundcolor', get_string('editorbackgroundcolor', 'admin'), get_string('edhelpbgcolor'), '#ffffff', PARAM_NOTAGS)); -$temp->add(new admin_setting_configtext('editorfontfamily', get_string('editorfontfamily', 'admin'), get_string('edhelpfontfamily'), 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif', PARAM_NOTAGS)); -$temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS)); -$temp->add(new admin_setting_special_editorfontlist()); -$temp->add(new admin_setting_configcheckbox('editorkillword', get_string('editorkillword', 'admin'), get_string('edhelpcleanword'), 1)); -if (!empty($CFG->aspellpath)) { // make aspell settings disappear if path isn't set - $temp->add(new admin_setting_configcheckbox('editorspelling', get_string('editorspelling', 'admin'), get_string('editorspellinghelp', 'admin'), 0)); - $temp->add(new admin_setting_special_editordictionary()); -} -$temp->add(new admin_setting_special_editorhidebuttons()); -$temp->add(new admin_setting_emoticons()); -$ADMIN->add('appearance', $temp); - -// "documentation" settingpage -$temp = new admin_settingpage('documentation', get_string('moodledocs')); -$temp->add(new admin_setting_configtext('docroot', get_string('docroot', 'admin'), get_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL)); -$temp->add(new admin_setting_configcheckbox('doctonewwindow', get_string('doctonewwindow', 'admin'), get_string('configdoctonewwindow', 'admin'), 0)); -$ADMIN->add('appearance', $temp); - -$temp = new admin_settingpage('mymoodle', get_string('mymoodle', 'admin')); -$temp->add(new admin_setting_configcheckbox('mymoodleredirect', get_string('mymoodleredirect', 'admin'), get_string('configmymoodleredirect', 'admin'), 0)); -$ADMIN->add('appearance', $temp); - -// new CFG variable for coursemanager (what roles to display) -$temp = new admin_settingpage('coursemanager', get_string('coursemanager', 'admin')); -$temp->add(new admin_setting_special_coursemanager()); -$ADMIN->add('appearance', $temp); - -$ADMIN->add('appearance', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php")); - -$temp = new admin_settingpage('ajax', get_string('ajaxuse')); -$temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 0)); -$ADMIN->add('appearance', $temp); - -// link to tag management interface -$ADMIN->add('appearance', new admin_externalpage('managetags', get_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php")); + $ADMIN->add('appearance', new admin_category('themes', get_string('themes'))); + // "themesettings" settingpage + $temp = new admin_settingpage('themesettings', get_string('themesettings', 'admin')); + $temp->add(new admin_setting_configtext('themelist', get_string('themelist', 'admin'), get_string('configthemelist','admin'), '', PARAM_NOTAGS)); + $temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allowuserthemes', 'admin'), get_string('configallowuserthemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowcategorythemes', get_string('allowcategorythemes', 'admin'), get_string('configallowcategorythemes', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('showblocksonmodpages', get_string('showblocksonmodpages', 'admin'), get_string('configshowblocksonmodpages', 'admin'), 0)); + $temp->add(new admin_setting_configselect('hideactivitytypenavlink', get_string('hideactivitytypenavlink', 'admin'), get_string('confighideactivitytypenavlink', 'admin'), 0, + array( + 0 => get_string('hidefromnone', 'admin'), + 1 => get_string('hidefromstudents', 'admin'), + 2 => get_string('hidefromall', 'admin') + ))); + $ADMIN->add('themes', $temp); + $ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php')); + + // calendar + $temp = new admin_settingpage('calendar', get_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', get_string('pref_timeformat', 'calendar'), + get_string('explain_site_timeformat', 'calendar'), '0', + array('0' => get_string('default', 'calendar'), + '%I:%M %p' => get_string('timeformat_12', 'calendar'), + '%H:%M' => get_string('timeformat_24', 'calendar')))); + $temp->add(new admin_setting_configselect('calendar_startwday', get_string('configstartwday', 'admin'), get_string('helpstartofweek', 'admin'), 0, + array( + 0 => get_string('sunday', 'calendar'), + 1 => get_string('monday', 'calendar'), + 2 => get_string('tuesday', 'calendar'), + 3 => get_string('wednesday', 'calendar'), + 4 => get_string('thursday', 'calendar'), + 5 => get_string('friday', 'calendar'), + 6 => get_string('saturday', 'calendar') + ))); + $temp->add(new admin_setting_special_calendar_weekend()); + $temp->add(new admin_setting_configtext('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,PARAM_INT)); + $temp->add(new admin_setting_configtext('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,PARAM_INT)); + $ADMIN->add('appearance', $temp); + + // "htmleditor" settingpage + $temp = new admin_settingpage('htmleditor', get_string('htmleditor', 'admin')); + $temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1)); + $temp->add(new admin_setting_configtext('editorbackgroundcolor', get_string('editorbackgroundcolor', 'admin'), get_string('edhelpbgcolor'), '#ffffff', PARAM_NOTAGS)); + $temp->add(new admin_setting_configtext('editorfontfamily', get_string('editorfontfamily', 'admin'), get_string('edhelpfontfamily'), 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif', PARAM_NOTAGS)); + $temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS)); + $temp->add(new admin_setting_special_editorfontlist()); + $temp->add(new admin_setting_configcheckbox('editorkillword', get_string('editorkillword', 'admin'), get_string('edhelpcleanword'), 1)); + if (!empty($CFG->aspellpath)) { // make aspell settings disappear if path isn't set + $temp->add(new admin_setting_configcheckbox('editorspelling', get_string('editorspelling', 'admin'), get_string('editorspellinghelp', 'admin'), 0)); + $temp->add(new admin_setting_special_editordictionary()); + } + $temp->add(new admin_setting_special_editorhidebuttons()); + $temp->add(new admin_setting_emoticons()); + $ADMIN->add('appearance', $temp); + + // "documentation" settingpage + $temp = new admin_settingpage('documentation', get_string('moodledocs')); + $temp->add(new admin_setting_configtext('docroot', get_string('docroot', 'admin'), get_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL)); + $temp->add(new admin_setting_configcheckbox('doctonewwindow', get_string('doctonewwindow', 'admin'), get_string('configdoctonewwindow', 'admin'), 0)); + $ADMIN->add('appearance', $temp); + + $temp = new admin_settingpage('mymoodle', get_string('mymoodle', 'admin')); + $temp->add(new admin_setting_configcheckbox('mymoodleredirect', get_string('mymoodleredirect', 'admin'), get_string('configmymoodleredirect', 'admin'), 0)); + $ADMIN->add('appearance', $temp); + + // new CFG variable for coursemanager (what roles to display) + $temp = new admin_settingpage('coursemanager', get_string('coursemanager', 'admin')); + $temp->add(new admin_setting_special_coursemanager()); + $ADMIN->add('appearance', $temp); + + $ADMIN->add('appearance', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php")); + + $temp = new admin_settingpage('ajax', get_string('ajaxuse')); + $temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 0)); + $ADMIN->add('appearance', $temp); + + // link to tag management interface + $ADMIN->add('appearance', new admin_externalpage('managetags', get_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php")); } // end of speedup ?> diff --git a/admin/settings/courses.php b/admin/settings/courses.php index c83e87b306..e8f33b755f 100644 --- a/admin/settings/courses.php +++ b/admin/settings/courses.php @@ -7,50 +7,56 @@ if ($hassiteconfig or has_capability('moodle/category:update', $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','moodle/category:update')); - -$ADMIN->add('courses', new admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php')); - -// "courserequests" settingpage -$temp = new admin_settingpage('courserequest', get_string('courserequest')); -$temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0)); -require_once($CFG->dirroot.'/course/lib.php'); -$temp->add(new admin_setting_configselect('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1, make_categories_options())); -$ADMIN->add('courses', $temp); - - - -// "backups" settingpage -$temp = new admin_settingpage('backups', get_string('backups','admin'),'moodle/site:backup'); -$temp->add(new admin_setting_backupcheckbox('backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_metacourse', get_string('metacourse'), get_string('backupmetacoursehelp'), 0)); -$temp->add(new admin_setting_backupselect('backup_sche_users', get_string('users'), get_string('backupusershelp'), 0, array(0 => get_string('all'), - 1 => get_string('course')))); -$temp->add(new admin_setting_backupcheckbox('backup_sche_logs', get_string('logs'), get_string('backuplogshelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_userfiles', get_string('userfiles'), get_string('backupuserfileshelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_coursefiles', get_string('coursefiles'), get_string('backupcoursefileshelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_sitefiles', get_string('sitefiles'), get_string('backupsitefileshelp'), 0)); -$temp->add(new admin_setting_backupcheckbox('backup_sche_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0)); -$temp->add(new admin_setting_backupselect('backup_sche_keep', get_string('keep'), get_string('backupkeephelp'), 1, array(0 => get_string('all'), - 1 => '1', - 2 => '2', - 5 => '5', - 10 => '10', - 20 => '20', - 30 => '30', - 40 => '40', - 50 => '50', - 100 => '100', - 200 => '200', - 300 => '300', - 400 => '400', - 500 => '500'))); -$temp->add(new admin_setting_backupcheckbox('backup_sche_active', get_string('active'), get_string('backupactivehelp'), 0)); -$temp->add(new admin_setting_special_backupdays()); -$temp->add(new admin_setting_special_backuptime()); -$temp->add(new admin_setting_special_backupsaveto()); -$ADMIN->add('courses', $temp); + $ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on','moodle/category:update')); + + $ADMIN->add('courses', new admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php')); + + // "courserequests" settingpage + $temp = new admin_settingpage('courserequest', get_string('courserequest')); + $temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0)); + $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1)); + $ADMIN->add('courses', $temp); + + // "backups" settingpage + if (!empty($CFG->backup_version)) { + $bi = array(); + $bi[] = new admin_setting_configcheckbox('backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_metacourse', get_string('metacourse'), get_string('backupmetacoursehelp'), 0); + $bi[] = new admin_setting_configselect('backup_sche_users', get_string('users'), get_string('backupusershelp'), + 0, array(0 => get_string('all'), 1 => get_string('course'))); + $bi[] = new admin_setting_configcheckbox('backup_sche_logs', get_string('logs'), get_string('backuplogshelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_userfiles', get_string('userfiles'), get_string('backupuserfileshelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_coursefiles', get_string('coursefiles'), get_string('backupcoursefileshelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_sitefiles', get_string('sitefiles'), get_string('backupsitefileshelp'), 0); + $bi[] = new admin_setting_configcheckbox('backup_sche_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0); + $bi[] = new admin_setting_configselect('backup_sche_keep', get_string('keep'), + get_string('backupkeephelp'), 1, array(0 => get_string('all'), 1 => '1', + 2 => '2', + 5 => '5', + 10 => '10', + 20 => '20', + 30 => '30', + 40 => '40', + 50 => '50', + 100 => '100', + 200 => '200', + 300 => '300', + 400 => '400', + 500 => '500')); + $bi[] = new admin_setting_configcheckbox('backup_sche_active', get_string('active'), get_string('backupactivehelp'), 0); + $bi[] = new admin_setting_special_backupdays(); + $bi[] = new admin_setting_configtime('backup_sche_hour', 'backup_sche_minute', get_string('executeat'), + get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)); + $bi[] = new admin_setting_configdirectory('backup_sche_destination', get_string('saveto'), get_string('backupsavetohelp'), ''); + + $temp = new admin_settingpage('backups', get_string('backups','admin'), 'moodle/site:backup'); + foreach ($bi as $backupitem) { + $backupitem->plugin = 'backup'; + $temp->add($backupitem); + } + $ADMIN->add('courses', $temp); + } } // end of speedup diff --git a/admin/settings/grades.php b/admin/settings/grades.php index 3489bd0708..122d0690aa 100644 --- a/admin/settings/grades.php +++ b/admin/settings/grades.php @@ -5,200 +5,187 @@ if (has_capability('moodle/grade:manage', $systemcontext) or has_capability('moodle/grade:manageletters', $systemcontext)) { // speedup for non-admins, add all caps used on this page -// General settings + // General settings -require_once $CFG->libdir.'/grade/constants.php'; - -$temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage'); - -// new CFG variable for gradebook (what roles to display) -$temp->add(new admin_setting_special_gradebookroles()); - -// enable outcomes checkbox -$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT)); - -$temp->add(new admin_setting_grade_profilereport()); - -$temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'), - get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST, - array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'), - GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades')))); - -$temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0, PARAM_INT)); - -// enable publishing in exports/imports -$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT)); - -$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'), - get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL, - array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), - GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), - GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')))); - -$temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'), - get_string('configexportdecimalpoints', 'grades'), 2, - array( '0' => '0', - '1' => '1', - '2' => '2', - '3' => '3', - '4' => '4', - '5' => '5'))); - -$temp->add(new admin_setting_special_gradeexport()); -$ADMIN->add('grades', $temp); - -/// Grade category settings -$temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage'); - -$temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('confighideforcedsettings', 'grades'), 1, PARAM_INT)); - -$strnoforce = get_string('noforce', 'grades'); - -// Aggregation type -$options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'), - GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'), - GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'), - GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'), - GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'), - GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'), - GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'), - GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'), - GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades')); -$defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false); -$temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregationhelp', 'grades'), $defaults, $options)); - -$options = array(0 => get_string('no'), 1 => get_string('yes')); - -$defaults = array('value'=>1, 'forced'=>false, 'adv'=>true); -$temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'), - get_string('aggregateonlygradedhelp', 'grades'), $defaults, $options)); -$temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'), - get_string('aggregateoutcomeshelp', 'grades'), $defaults, $options)); -$temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'), - get_string('aggregatesubcatshelp', 'grades'), $defaults, $options)); - -$options = array(0 => get_string('none')); -for ($i=1; $i<=20; $i++) { - $options[$i] = $i; -} - -$defaults['value'] = 0; -$defaults['forced'] = true; -$temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'), - get_string('keephighhelp', 'grades'), $defaults, $options)); -$defaults['forced'] = false; -$temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'), - get_string('droplowhelp', 'grades'), $defaults, $options)); - -$ADMIN->add('grades', $temp); - - -/// Grade item settings -$temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage'); - - -$temp->add(new admin_setting_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'), - get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL, - array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), - GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), - GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')))); - -$temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'), - get_string('configdecimalpoints', 'grades'), 2, - array( '0' => '0', - '1' => '1', - '2' => '2', - '3' => '3', - '4' => '4', - '5' => '5'))); - -$temp->add(new admin_setting_configmultiselect('grade_item_advanced', get_string('gradeitemadvanced', 'grades'), get_string('configgradeitemadvanced', 'grades'), - array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'), - array('iteminfo' => get_string('iteminfo', 'grades'), - 'idnumber' => get_string('idnumber'), - 'gradetype' => get_string('gradetype', 'grades'), - 'scaleid' => get_string('scale'), - 'grademin' => get_string('grademin', 'grades'), - 'grademax' => get_string('grademax', 'grades'), - 'gradepass' => get_string('gradepass', 'grades'), - 'plusfactor' => get_string('plusfactor', 'grades'), - 'multfactor' => get_string('multfactor', 'grades'), - 'display' => get_string('gradedisplaytype', 'grades'), - 'decimals' => get_string('decimalpoints', 'grades'), - 'hidden' => get_string('hidden', 'grades'), - 'hiddenuntil' => get_string('hiddenuntil', 'grades'), - 'locked' => get_string('locked', 'grades'), - 'locktime' => get_string('locktime', 'grades'), - 'aggregationcoef' => get_string('aggregationcoef', 'grades'), - 'parentcategory' => get_string('parentcategory', 'grades')))); - -$ADMIN->add('grades', $temp); - - -/// Scales and outcomes - -$scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage'); -$ADMIN->add('grades', $scales); -$outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage'); -$ADMIN->add('grades', $outcomes); -$letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters'); -$ADMIN->add('grades', $letters); - -// The plugins must implement a settings.php file that adds their admin settings to the $settings object - -// Reports - -$first = true; -foreach (get_list_of_plugins('grade/report') as $plugin) { - // Include all the settings commands for this plugin if there are any - if ($first) { - $ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades'))); - $first = false; - } + $temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + require_once $CFG->libdir.'/grade/constants.php'; - if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) { + // new CFG variable for gradebook (what roles to display) + $temp->add(new admin_setting_special_gradebookroles()); - $settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage'); - include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php'); - $ADMIN->add('gradereports', $settings); - } -} + // enable outcomes checkbox + $temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT)); + + $temp->add(new admin_setting_grade_profilereport()); + + $temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'), + get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST, + array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'), + GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades')))); -// Imports + $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0, PARAM_INT)); -$first = true; -foreach (get_list_of_plugins('grade/import') as $plugin) { + // enable publishing in exports/imports + $temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT)); - // Include all the settings commands for this plugin if there are any - if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) { - if ($first) { - $ADMIN->add('grades', new admin_category('gradeimports', get_string('imports'))); - $first = false; + $temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'), + get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL, + array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), + GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), + GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')))); + + $temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'), + get_string('configexportdecimalpoints', 'grades'), 2, + array( '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5'))); + + $temp->add(new admin_setting_special_gradeexport()); + } + $ADMIN->add('grades', $temp); + + /// Grade category settings + $temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('confighideforcedsettings', 'grades'), '1')); + + $strnoforce = get_string('noforce', 'grades'); + + // Aggregation type + $options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'), + GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'), + GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'), + GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'), + GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'), + GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'), + GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'), + GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'), + GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades')); + $defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false); + $temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregationhelp', 'grades'), $defaults, $options)); + + $options = array(0 => get_string('no'), 1 => get_string('yes')); + + $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true); + $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'), + get_string('aggregateonlygradedhelp', 'grades'), $defaults, $options)); + $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'), + get_string('aggregateoutcomeshelp', 'grades'), $defaults, $options)); + $temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'), + get_string('aggregatesubcatshelp', 'grades'), $defaults, $options)); + + $options = array(0 => get_string('none')); + for ($i=1; $i<=20; $i++) { + $options[$i] = $i; } - $settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage'); - include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php'); - $ADMIN->add('gradeimports', $settings); + $defaults['value'] = 0; + $defaults['forced'] = true; + $temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'), + get_string('keephighhelp', 'grades'), $defaults, $options)); + $defaults['forced'] = false; + $temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'), + get_string('droplowhelp', 'grades'), $defaults, $options)); + } + $ADMIN->add('grades', $temp); + + + /// Grade item settings + $temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + $temp->add(new admin_setting_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'), + get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL, + array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), + GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), + GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')))); + + $temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'), + get_string('configdecimalpoints', 'grades'), 2, + array( '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5'))); + + $temp->add(new admin_setting_configmultiselect('grade_item_advanced', get_string('gradeitemadvanced', 'grades'), get_string('configgradeitemadvanced', 'grades'), + array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'), + array('iteminfo' => get_string('iteminfo', 'grades'), + 'idnumber' => get_string('idnumber'), + 'gradetype' => get_string('gradetype', 'grades'), + 'scaleid' => get_string('scale'), + 'grademin' => get_string('grademin', 'grades'), + 'grademax' => get_string('grademax', 'grades'), + 'gradepass' => get_string('gradepass', 'grades'), + 'plusfactor' => get_string('plusfactor', 'grades'), + 'multfactor' => get_string('multfactor', 'grades'), + 'display' => get_string('gradedisplaytype', 'grades'), + 'decimals' => get_string('decimalpoints', 'grades'), + 'hidden' => get_string('hidden', 'grades'), + 'hiddenuntil' => get_string('hiddenuntil', 'grades'), + 'locked' => get_string('locked', 'grades'), + 'locktime' => get_string('locktime', 'grades'), + 'aggregationcoef' => get_string('aggregationcoef', 'grades'), + 'parentcategory' => get_string('parentcategory', 'grades')))); + } + $ADMIN->add('grades', $temp); + + + /// Scales and outcomes + + $scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage'); + $ADMIN->add('grades', $scales); + $outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage'); + $ADMIN->add('grades', $outcomes); + $letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters'); + $ADMIN->add('grades', $letters); + + // The plugins must implement a settings.php file that adds their admin settings to the $settings object + + // Reports + $ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades'))); + foreach (get_list_of_plugins('grade/report') as $plugin) { + // Include all the settings commands for this plugin if there are any + if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) { + $settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php'); + } + $ADMIN->add('gradereports', $settings); + } } -} + // Imports + $ADMIN->add('grades', new admin_category('gradeimports', get_string('imports'))); + foreach (get_list_of_plugins('grade/import') as $plugin) { + + // Include all the settings commands for this plugin if there are any + if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) { + $settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php'); + } + $ADMIN->add('gradeimports', $settings); + } + } -// Exports -$first = true; -foreach (get_list_of_plugins('grade/export') as $plugin) { - // Include all the settings commands for this plugin if there are any - if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) { - if ($first) { - $ADMIN->add('grades', new admin_category('gradeexports', get_string('exports'))); - $first = false; + // Exports + $ADMIN->add('grades', new admin_category('gradeexports', get_string('exports'))); + foreach (get_list_of_plugins('grade/export') as $plugin) { + // Include all the settings commands for this plugin if there are any + if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) { + $settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage'); + if ($ADMIN->fulltree) { + include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php'); + } + $ADMIN->add('gradeexports', $settings); } - - $settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage'); - include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php'); - $ADMIN->add('gradeexports', $settings); } -} } // end of speedup diff --git a/admin/settings/language.php b/admin/settings/language.php index 0eabf7412d..8c4055a2ca 100644 --- a/admin/settings/language.php +++ b/admin/settings/language.php @@ -4,24 +4,23 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page + // "languageandlocation" settingpage + $temp = new admin_settingpage('langsettings', get_string('languagesettings', 'admin')); + $temp->add(new admin_setting_configcheckbox('autolang', get_string('autolang', 'admin'), get_string('configautolang', 'admin'), 1)); + $temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_list_of_languages())); // $CFG->lang might be set in installer already, default en or en_utf8 is in setup.php + $temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1)); + $temp->add(new admin_setting_langlist()); + $temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1)); + $temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE)); -// "languageandlocation" settingpage -$temp = new admin_settingpage('langsettings', get_string('languagesettings', 'admin')); -$temp->add(new admin_setting_configcheckbox('autolang', get_string('autolang', 'admin'), get_string('configautolang', 'admin'), 1)); -$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_list_of_languages())); // $CFG->lang might be set in installer already, default en or en_utf8 is in setup.php -$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1)); -$temp->add(new admin_setting_langlist()); -$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1)); -$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE)); + // new CFG variable for excel encoding + $temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin'))); -// new CFG variable for excel encoding -$temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin'))); + $ADMIN->add('language', $temp); -$ADMIN->add('language', $temp); - -$ADMIN->add('language', new admin_externalpage('langedit', get_string('langedit', 'admin'), "$CFG->wwwroot/$CFG->admin/lang.php")); -$ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php")); + $ADMIN->add('language', new admin_externalpage('langedit', get_string('langedit', 'admin'), "$CFG->wwwroot/$CFG->admin/lang.php")); + $ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php")); } // end of speedup diff --git a/admin/settings/location.php b/admin/settings/location.php index a054ca5342..61fa071208 100644 --- a/admin/settings/location.php +++ b/admin/settings/location.php @@ -2,30 +2,29 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page - -// "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; + // "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)); + $temp->add(new admin_setting_configselect('iplookup', get_string('iplookup', 'admin'), get_string('configiplookup', 'admin'), 'hostip', $iplookups)); -$ADMIN->add('location', $temp); + $ADMIN->add('location', $temp); -$ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "$CFG->wwwroot/$CFG->admin/timezoneimport.php")); + $ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "$CFG->wwwroot/$CFG->admin/timezoneimport.php")); } // end of speedup diff --git a/admin/settings/misc.php b/admin/settings/misc.php index bf2d04a719..83861b0a8d 100644 --- a/admin/settings/misc.php +++ b/admin/settings/misc.php @@ -4,25 +4,24 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page + // Experimental settings page + $temp = new admin_settingpage('experimental', get_string('experimental', 'admin')); + $temp->add(new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('smartpix', get_string('smartpix', 'admin'), get_string('configsmartpix', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('enablehtmlpurifier', get_string('enablehtmlpurifier', 'admin'), get_string('configenablehtmlpurifier', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0)); -// Experimental settings page -$temp = new admin_settingpage('experimental', get_string('experimental', 'admin')); -$temp->add(new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('smartpix', get_string('smartpix', 'admin'), get_string('configsmartpix', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('enablehtmlpurifier', get_string('enablehtmlpurifier', 'admin'), get_string('configenablehtmlpurifier', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0)); + $ADMIN->add('misc', $temp); -$ADMIN->add('misc', $temp); + // XMLDB editor + $ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbeditor'), "$CFG->wwwroot/$CFG->admin/xmldb/")); -// XMLDB editor -$ADMIN->add('misc', new admin_externalpage('xmldbeditor', get_string('xmldbeditor'), "$CFG->wwwroot/$CFG->admin/xmldb/")); - -// hidden scripts linked from elsewhere -$ADMIN->add('misc', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true)); -$ADMIN->add('misc', new admin_externalpage('upgradeforumread', 'Upgrade forum', $CFG->wwwroot.'/'.$CFG->admin.'/upgradeforumread.php', 'moodle/site:config', true)); -$ADMIN->add('misc', new admin_externalpage('upgradelogs', 'Upgrade logs', $CFG->wwwroot.'/'.$CFG->admin.'/upgradelogs.php', 'moodle/site:config', true)); -$ADMIN->add('misc', new admin_externalpage('multilangupgrade', get_string('multilangupgrade', 'admin'), $CFG->wwwroot.'/'.$CFG->admin.'/multilangupgrade.php', 'moodle/site:config', !empty($CFG->filter_multilang_converted))); + // hidden scripts linked from elsewhere + $ADMIN->add('misc', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true)); + $ADMIN->add('misc', new admin_externalpage('upgradeforumread', 'Upgrade forum', $CFG->wwwroot.'/'.$CFG->admin.'/upgradeforumread.php', 'moodle/site:config', true)); + $ADMIN->add('misc', new admin_externalpage('upgradelogs', 'Upgrade logs', $CFG->wwwroot.'/'.$CFG->admin.'/upgradelogs.php', 'moodle/site:config', true)); + $ADMIN->add('misc', new admin_externalpage('multilangupgrade', get_string('multilangupgrade', 'admin'), $CFG->wwwroot.'/'.$CFG->admin.'/multilangupgrade.php', 'moodle/site:config', !empty($CFG->filter_multilang_converted))); } // end of speedup diff --git a/admin/settings/mnet.php b/admin/settings/mnet.php index 66cbc8934b..8db1cc0249 100644 --- a/admin/settings/mnet.php +++ b/admin/settings/mnet.php @@ -5,21 +5,21 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page -$ADMIN->add('mnet', new admin_externalpage('net', get_string('settings', 'mnet'), - $CFG->wwwroot . '/admin/mnet/index.php', +$ADMIN->add('mnet', new admin_externalpage('net', get_string('settings', 'mnet'), + "$CFG->wwwroot/$CFG->admin/mnet/index.php", 'moodle/site:config')); -$ADMIN->add('mnet', new admin_externalpage('mnetpeers', get_string('mnetpeers', 'mnet'), - $CFG->wwwroot . '/admin/mnet/peers.php', +$ADMIN->add('mnet', new admin_externalpage('mnetpeers', get_string('mnetpeers', 'mnet'), + "$CFG->wwwroot/$CFG->admin/mnet/peers.php", 'moodle/site:config')); $ADMIN->add('mnet', new admin_externalpage('ssoaccesscontrol', get_string('ssoaccesscontrol', 'mnet'), - $CFG->wwwroot . '/admin/mnet/access_control.php', + "$CFG->wwwroot/$CFG->admin/mnet/access_control.php", 'moodle/site:config')); -$ADMIN->add('mnet', new admin_externalpage('mnetenrol', get_string('mnetenrol', 'mnet'), - $CFG->wwwroot . '/admin/mnet/enr_hosts.php', +$ADMIN->add('mnet', new admin_externalpage('mnetenrol', get_string('mnetenrol', 'mnet'), + "$CFG->wwwroot/$CFG->admin/mnet/enr_hosts.php", 'moodle/site:config')); -$ADMIN->add('mnet', new admin_externalpage('trustedhosts', get_string('trustedhosts', 'mnet'), - $CFG->wwwroot . '/admin/mnet/trustedhosts.php', +$ADMIN->add('mnet', new admin_externalpage('trustedhosts', get_string('trustedhosts', 'mnet'), + "$CFG->wwwroot/$CFG->admin/mnet/trustedhosts.php", 'moodle/site:config')); } // end of speedup diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php new file mode 100644 index 0000000000..061471217b --- /dev/null +++ b/admin/settings/plugins.php @@ -0,0 +1,140 @@ +add('modules', new admin_category('modsettings', get_string('activities'))); + $ADMIN->add('modsettings', new admin_page_managemods()); + if ($modules = get_records('modules')) { + $modulebyname = array(); + + foreach ($modules as $module) { + $strmodulename = get_string('modulename', $module->name); + // Deal with modules which are lacking the language string + if ($strmodulename == '[[modulename]]') { + $textlib = textlib_get_instance(); + $strmodulename = $textlib->strtotitle($module->name); + } + $modulebyname[$strmodulename] = $module; + } + ksort($modulebyname); + + foreach ($modulebyname as $strmodulename=>$module) { + $modulename = $module->name; + if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) { + // do not show disabled modules in tree, keep only settings link on manage page + $settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible); + if ($ADMIN->fulltree) { + include($CFG->dirroot.'/mod/'.$modulename.'/settings.php'); + } + $ADMIN->add('modsettings', $settings); + } else if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/config.html')) { + $ADMIN->add('modsettings', new admin_externalpage('modsetting'.$modulename, $strmodulename, "$CFG->wwwroot/$CFG->admin/module.php?module=$modulename", 'moodle/site:config', !$module->visible)); + } + } + } + + + $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks'))); + $ADMIN->add('blocksettings', new admin_page_manageblocks()); + if (!empty($CFG->blocks_version) and $blocks = get_records('block')) { + $blockbyname = array(); + + foreach ($blocks as $block) { + $strblockname = get_string('blockname', 'block_'.$block->name); + // Deal with blocks which are lacking the language string + if ($strblockname == '[[blockname]]') { + $textlib = textlib_get_instance(); + $strblockname = $textlib->strtotitle($block->name); + } + $blockbyname[$strblockname] = $block; + } + ksort($blockbyname); + + foreach ($blockbyname as $strblockname=>$block) { + $blockname = $block->name; + if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) { + $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible); + if ($ADMIN->fulltree) { + include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php'); + } + $ADMIN->add('blocksettings', $settings); + + } else if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/config_global.html')) { + $ADMIN->add('blocksettings', new admin_externalpage('blocksetting'.$blockname, $strblockname, "$CFG->wwwroot/$CFG->admin/block.php?block=$block->id", 'moodle/site:config', !$block->visible)); + } + } + } + + $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters'))); + // "filtersettings" settingpage + $temp = new admin_settingpage('managefilters', get_string('filtersettings', 'admin')); + if ($ADMIN->fulltree) { + $temp->add(new admin_setting_managefilters()); + $temp->add(new admin_setting_heading('managefilterscommonheading', get_string('commonsettings', 'admin'), '')); + $temp->add(new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, array(604800 => get_string('numdays','',7), + 86400 => get_string('numdays','',1), + 43200 => get_string('numhours','',12), + 10800 => get_string('numhours','',3), + 7200 => get_string('numhours','',2), + 3600 => get_string('numhours','',1), + 2700 => get_string('numminutes','',45), + 1800 => get_string('numminutes','',30), + 900 => get_string('numminutes','',15), + 600 => get_string('numminutes','',10), + 540 => get_string('numminutes','',9), + 480 => get_string('numminutes','',8), + 420 => get_string('numminutes','',7), + 360 => get_string('numminutes','',6), + 300 => get_string('numminutes','',5), + 240 => get_string('numminutes','',4), + 180 => get_string('numminutes','',3), + 120 => get_string('numminutes','',2), + 60 => get_string('numminutes','',1), + 30 => get_string('numseconds','',30), + 0 => get_string('no')))); + $temp->add(new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0, array('0' => get_string('none'), + '1' => get_string('allfiles'), + '2' => get_string('htmlfilesonly')))); + $temp->add(new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('filterall', get_string('filterall', 'admin'), get_string('configfilterall', 'admin'), 0)); + } + $ADMIN->add('filtersettings', $temp); + + if (empty($CFG->textfilters)) { + $activefilters = array(); + } else { + $activefilters = explode(',', $CFG->textfilters); + } + $filterlocations = array('mod','filter'); + foreach ($filterlocations as $filterlocation) { + $filters = get_list_of_plugins($filterlocation); + + $filterbyname = array(); + + foreach ($filters as $filter) { + $strfiltername = get_string('filtername', $filter); + // Deal with filters which are lacking the language string + if ($strfiltername == '[[filtername]]') { + $textlib = textlib_get_instance(); + $strfiltername = $textlib->strtotitle($filter); + } + $filterbyname[$strfiltername] = "$filterlocation/$filter"; + } + ksort($filterbyname); + + foreach ($filterbyname as $strfiltername=>$filterfull) { + if (file_exists("$CFG->dirroot/$filterfull/filtersettings.php")) { + $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterfull), $strfiltername, 'moodle/site:config', !in_array($filterfull, $activefilters)); + if ($ADMIN->fulltree) { + include("$CFG->dirroot/$filterfull/filtersettings.php"); + } + $ADMIN->add('filtersettings', $settings); + + } else if (file_exists("$CFG->dirroot/$filterfull/filterconfig.html")) { + $ADMIN->add('filtersettings', new admin_externalpage('filtersetting'.str_replace('/', '', $filterfull), $strfiltername, "$CFG->wwwroot/$CFG->admin/filter.php?filter=$filterfull", !in_array($filterfull, $activefilters))); + } + } + } +} +?> diff --git a/admin/settings/security.php b/admin/settings/security.php index 9c91e16d04..7120396a84 100644 --- a/admin/settings/security.php +++ b/admin/settings/security.php @@ -3,111 +3,111 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page -// "sitepolicies" settingpage -$temp = new admin_settingpage('sitepolicies', get_string('sitepolicies', 'admin')); -$temp->add(new admin_setting_configcheckbox('protectusernames', get_string('protectusernames', 'admin'), get_string('configprotectusernames', 'admin'), 1)); -$temp->add(new admin_setting_configcheckbox('forcelogin', get_string('forcelogin', 'admin'), get_string('configforcelogin', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('forceloginforprofiles', get_string('forceloginforprofiles', 'admin'), get_string('configforceloginforprofiles', 'admin'), 1)); -$temp->add(new admin_setting_configcheckbox('opentogoogle', get_string('opentogoogle', 'admin'), get_string('configopentogoogle', 'admin'), 0)); - -$max_upload_choices = get_max_upload_sizes(); -// maxbytes set to 0 will allow the maxium server lmit for uploads -$max_upload_choices[0] = get_string('serverlimit', 'admin'); -$temp->add(new admin_setting_configselect('maxbytes', get_string('maxbytes', 'admin'), get_string('configmaxbytes', 'admin'), 0, $max_upload_choices)); - -$temp->add(new admin_setting_configcheckbox('messaging', get_string('messaging', 'admin'), get_string('configmessaging','admin'), 1)); -$temp->add(new admin_setting_configcheckbox('allowobjectembed', get_string('allowobjectembed', 'admin'), get_string('configallowobjectembed', 'admin'), 0)); -$temp->add(new admin_setting_configcheckbox('enabletrusttext', get_string('enabletrusttext', 'admin'), get_string('configenabletrusttext', 'admin'), 0)); -$temp->add(new admin_setting_configselect('maxeditingtime', get_string('maxeditingtime','admin'), get_string('configmaxeditingtime','admin'), 1800, - array(60 => get_string('numminutes', '', 1), - 300 => get_string('numminutes', '', 5), - 900 => get_string('numminutes', '', 15), - 1800 => get_string('numminutes', '', 30), - 2700 => get_string('numminutes', '', 45), - 3600 => get_string('numminutes', '', 60)))); -$temp->add(new admin_setting_configselect('fullnamedisplay', get_string('fullnamedisplay', 'admin'), get_string('configfullnamedisplay', 'admin'), - 'firstname lastname', array('language' => get_string('language'), - 'firstname lastname' => get_string('firstname') . ' + ' . get_string('lastname'), - 'lastname firstname' => get_string('lastname') . ' + ' . get_string('firstname'), - 'firstname' => get_string('firstname')))); -$temp->add(new admin_setting_configcheckbox('extendedusernamechars', get_string('extendedusernamechars', 'admin'), get_string('configextendedusernamechars', 'admin'), 0)); -$temp->add(new admin_setting_configtext('sitepolicy', get_string('sitepolicy', 'admin'), get_string('configsitepolicy', 'admin'), '', PARAM_RAW)); -$temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'), - 4 => get_string('siteblogs','blog'), - 3 => get_string('courseblogs','blog'), - 2 => get_string('groupblogs','blog'), - 1 => get_string('personalblogs','blog'), - 0 => get_string('disableblogs','blog')))); -$temp->add(new admin_setting_configcheckbox('usetags', get_string('usetags','admin'),get_string('configusetags', 'admin'),'1')); -$temp->add(new admin_setting_configcheckbox('keeptagnamecase', get_string('keeptagnamecase','admin'),get_string('configkeeptagnamecase', 'admin'),'0')); -$temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0)); -$temp->add(new admin_setting_configpasswordunmask('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '', PARAM_RAW)); - -$temp->add(new admin_setting_configcheckbox('passwordpolicy', get_string('passwordpolicy', 'admin'), get_string('configpasswordpolicy', 'admin'), 0)); -$temp->add(new admin_setting_configtext('minpasswordlength', get_string('minpasswordlength', 'admin'), get_string('configminpasswordlength', 'admin'), 8, PARAM_INT)); -$temp->add(new admin_setting_configtext('minpassworddigits', get_string('minpassworddigits', 'admin'), get_string('configminpassworddigits', 'admin'), 1, PARAM_INT)); -$temp->add(new admin_setting_configtext('minpasswordlower', get_string('minpasswordlower', 'admin'), get_string('configminpasswordlower', 'admin'), 1, PARAM_INT)); -$temp->add(new admin_setting_configtext('minpasswordupper', get_string('minpasswordupper', 'admin'), get_string('configminpasswordupper', 'admin'), 1, PARAM_INT)); -$temp->add(new admin_setting_configtext('minpasswordnonalphanum', get_string('minpasswordnonalphanum', 'admin'), get_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT)); -$temp->add(new admin_setting_configcheckbox('disableuserimages', get_string('disableuserimages', 'admin'), get_string('configdisableuserimages', 'admin'), 0)); -$ADMIN->add('security', $temp); - - - - -// "httpsecurity" settingpage -$temp = new admin_settingpage('httpsecurity', get_string('httpsecurity', 'admin')); -$temp->add(new admin_setting_configcheckbox('loginhttps', get_string('loginhttps', 'admin'), get_string('configloginhttps', 'admin'), 0)); -$ADMIN->add('security', $temp); - - -// "modulesecurity" settingpage -$temp = new admin_settingpage('modulesecurity', get_string('modulesecurity', 'admin')); -$temp->add(new admin_setting_configselect('restrictmodulesfor', get_string('restrictmodulesfor', 'admin'), get_string('configrestrictmodulesfor', 'admin'), 'none', array('none' => 'No courses', - 'all' => 'All courses', - 'requested' => 'Requested courses'))); -$temp->add(new admin_setting_configcheckbox('restrictbydefault', get_string('restrictbydefault', 'admin'), get_string('configrestrictbydefault', 'admin'), 0)); -if (!$options = get_records("modules")) { + // "sitepolicies" settingpage + $temp = new admin_settingpage('sitepolicies', get_string('sitepolicies', 'admin')); + $temp->add(new admin_setting_configcheckbox('protectusernames', get_string('protectusernames', 'admin'), get_string('configprotectusernames', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('forcelogin', get_string('forcelogin', 'admin'), get_string('configforcelogin', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('forceloginforprofiles', get_string('forceloginforprofiles', 'admin'), get_string('configforceloginforprofiles', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('opentogoogle', get_string('opentogoogle', 'admin'), get_string('configopentogoogle', 'admin'), 0)); + + $max_upload_choices = get_max_upload_sizes(); + // maxbytes set to 0 will allow the maxium server lmit for uploads + $max_upload_choices[0] = get_string('serverlimit', 'admin'); + $temp->add(new admin_setting_configselect('maxbytes', get_string('maxbytes', 'admin'), get_string('configmaxbytes', 'admin'), 0, $max_upload_choices)); + + $temp->add(new admin_setting_configcheckbox('messaging', get_string('messaging', 'admin'), get_string('configmessaging','admin'), 1)); + $temp->add(new admin_setting_configcheckbox('allowobjectembed', get_string('allowobjectembed', 'admin'), get_string('configallowobjectembed', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('enabletrusttext', get_string('enabletrusttext', 'admin'), get_string('configenabletrusttext', 'admin'), 0)); + $temp->add(new admin_setting_configselect('maxeditingtime', get_string('maxeditingtime','admin'), get_string('configmaxeditingtime','admin'), 1800, + array(60 => get_string('numminutes', '', 1), + 300 => get_string('numminutes', '', 5), + 900 => get_string('numminutes', '', 15), + 1800 => get_string('numminutes', '', 30), + 2700 => get_string('numminutes', '', 45), + 3600 => get_string('numminutes', '', 60)))); + $temp->add(new admin_setting_configselect('fullnamedisplay', get_string('fullnamedisplay', 'admin'), get_string('configfullnamedisplay', 'admin'), + 'firstname lastname', array('language' => get_string('language'), + 'firstname lastname' => get_string('firstname').' + '.get_string('lastname'), + 'lastname firstname' => get_string('lastname').' + '.get_string('firstname'), + 'firstname' => get_string('firstname')))); + $temp->add(new admin_setting_configcheckbox('extendedusernamechars', get_string('extendedusernamechars', 'admin'), get_string('configextendedusernamechars', 'admin'), 0)); + $temp->add(new admin_setting_configtext('sitepolicy', get_string('sitepolicy', 'admin'), get_string('configsitepolicy', 'admin'), '', PARAM_RAW)); + $temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'), + 4 => get_string('siteblogs','blog'), + 3 => get_string('courseblogs','blog'), + 2 => get_string('groupblogs','blog'), + 1 => get_string('personalblogs','blog'), + 0 => get_string('disableblogs','blog')))); + $temp->add(new admin_setting_configcheckbox('usetags', get_string('usetags','admin'),get_string('configusetags', 'admin'),'1')); + $temp->add(new admin_setting_configcheckbox('keeptagnamecase', get_string('keeptagnamecase','admin'),get_string('configkeeptagnamecase', 'admin'),'0')); + $temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0)); + $temp->add(new admin_setting_configpasswordunmask('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '')); + + $temp->add(new admin_setting_configcheckbox('passwordpolicy', get_string('passwordpolicy', 'admin'), get_string('configpasswordpolicy', 'admin'), 0)); + $temp->add(new admin_setting_configtext('minpasswordlength', get_string('minpasswordlength', 'admin'), get_string('configminpasswordlength', 'admin'), 8, PARAM_INT)); + $temp->add(new admin_setting_configtext('minpassworddigits', get_string('minpassworddigits', 'admin'), get_string('configminpassworddigits', 'admin'), 1, PARAM_INT)); + $temp->add(new admin_setting_configtext('minpasswordlower', get_string('minpasswordlower', 'admin'), get_string('configminpasswordlower', 'admin'), 1, PARAM_INT)); + $temp->add(new admin_setting_configtext('minpasswordupper', get_string('minpasswordupper', 'admin'), get_string('configminpasswordupper', 'admin'), 1, PARAM_INT)); + $temp->add(new admin_setting_configtext('minpasswordnonalphanum', get_string('minpasswordnonalphanum', 'admin'), get_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT)); + $temp->add(new admin_setting_configcheckbox('disableuserimages', get_string('disableuserimages', 'admin'), get_string('configdisableuserimages', 'admin'), 0)); + $ADMIN->add('security', $temp); + + + + + // "httpsecurity" settingpage + $temp = new admin_settingpage('httpsecurity', get_string('httpsecurity', 'admin')); + $temp->add(new admin_setting_configcheckbox('loginhttps', get_string('loginhttps', 'admin'), get_string('configloginhttps', 'admin'), 0)); + $ADMIN->add('security', $temp); + + + // "modulesecurity" settingpage + $temp = new admin_settingpage('modulesecurity', get_string('modulesecurity', 'admin')); + $temp->add(new admin_setting_configselect('restrictmodulesfor', get_string('restrictmodulesfor', 'admin'), get_string('configrestrictmodulesfor', 'admin'), 'none', array('none' => 'No courses', + 'all' => 'All courses', + 'requested' => 'Requested courses'))); + $temp->add(new admin_setting_configcheckbox('restrictbydefault', get_string('restrictbydefault', 'admin'), get_string('configrestrictbydefault', 'admin'), 0)); + if (!$options = get_records("modules")) { + $options = array(); + } + $options2 = array(); + foreach ($options as $option) { + $options2[$option->id] = $option->name; + } + $temp->add(new admin_setting_configmultiselect('defaultallowedmodules', get_string('defaultallowedmodules', 'admin'), get_string('configdefaultallowedmodules', 'admin'), array(), $options2)); + $ADMIN->add('security', $temp); + + + + // "notifications" settingpage + $temp = new admin_settingpage('notifications', get_string('notifications', 'admin')); + $temp->add(new admin_setting_configselect('displayloginfailures', get_string('displayloginfailures', 'admin'), get_string('configdisplayloginfailures', 'admin'), '', array('' => get_string('nobody'), + 'admin' => get_string('administrators'), + 'teacher' => get_string('administratorsandteachers'), + 'everybody' => get_string('everybody')))); + $temp->add(new admin_setting_configselect('notifyloginfailures', get_string('notifyloginfailures', 'admin'), get_string('confignotifyloginfailures', 'admin'), '', array('' => get_string('nobody'), + 'mainadmin' => get_string('administrator'), + 'alladmins' => get_string('administratorsall')))); $options = array(); -} -$options2 = array(); -foreach ($options as $option) { - $options2[$option->id] = $option->name; -} -$temp->add(new admin_setting_configmultiselect('defaultallowedmodules', get_string('defaultallowedmodules', 'admin'), get_string('configdefaultallowedmodules', 'admin'), array(), $options2)); -$ADMIN->add('security', $temp); + for ($i = 1; $i <= 100; $i++) { + $options[$i] = $i; + } + $temp->add(new admin_setting_configselect('notifyloginthreshold', get_string('notifyloginthreshold', 'admin'), get_string('confignotifyloginthreshold', 'admin'), '10', $options)); + $ADMIN->add('security', $temp); -// "notifications" settingpage -$temp = new admin_settingpage('notifications', get_string('notifications', 'admin')); -$temp->add(new admin_setting_configselect('displayloginfailures', get_string('displayloginfailures', 'admin'), get_string('configdisplayloginfailures', 'admin'), '', array('' => get_string('nobody'), - 'admin' => get_string('administrators'), - 'teacher' => get_string('administratorsandteachers'), - 'everybody' => get_string('everybody')))); -$temp->add(new admin_setting_configselect('notifyloginfailures', get_string('notifyloginfailures', 'admin'), get_string('confignotifyloginfailures', 'admin'), '', array('' => get_string('nobody'), - 'mainadmin' => get_string('administrator'), - 'alladmins' => get_string('administratorsall')))); -$options = array(); -for ($i = 1; $i <= 100; $i++) { - $options[$i] = $i; -} -$temp->add(new admin_setting_configselect('notifyloginthreshold', get_string('notifyloginthreshold', 'admin'), get_string('confignotifyloginthreshold', 'admin'), '10', $options)); -$ADMIN->add('security', $temp); - - - -// "antivirus" settingpage -$temp = new admin_settingpage('antivirus', get_string('antivirus', 'admin')); -$temp->add(new admin_setting_configcheckbox('runclamonupload', get_string('runclamavonupload', 'admin'), get_string('configrunclamavonupload', 'admin'), 0)); -$temp->add(new admin_setting_configtext('pathtoclam', get_string('pathtoclam', 'admin'), get_string('configpathtoclam', 'admin'), '', PARAM_RAW)); // TODO: add path validation -$temp->add(new admin_setting_configtext('quarantinedir', get_string('quarantinedir', 'admin'), get_string('configquarantinedir', 'admin'), '', PARAM_RAW)); // TODO: add path validation -$temp->add(new admin_setting_configselect('clamfailureonupload', get_string('clamfailureonupload', 'admin'), get_string('configclamfailureonupload', 'admin'), 'donothing', array('donothing' => get_string('configclamdonothing', 'admin'), - 'actlikevirus' => get_string('configclamactlikevirus', 'admin')))); -$ADMIN->add('security', $temp); + // "antivirus" settingpage + $temp = new admin_settingpage('antivirus', get_string('antivirus', 'admin')); + $temp->add(new admin_setting_configcheckbox('runclamonupload', get_string('runclamavonupload', 'admin'), get_string('configrunclamavonupload', 'admin'), 0)); + $temp->add(new admin_setting_configexecutable('pathtoclam', get_string('pathtoclam', 'admin'), get_string('configpathtoclam', 'admin'), '')); + $temp->add(new admin_setting_configdirectory('quarantinedir', get_string('quarantinedir', 'admin'), get_string('configquarantinedir', 'admin'), '')); + $temp->add(new admin_setting_configselect('clamfailureonupload', get_string('clamfailureonupload', 'admin'), get_string('configclamfailureonupload', 'admin'), 'donothing', array('donothing' => get_string('configclamdonothing', 'admin'), + 'actlikevirus' => get_string('configclamactlikevirus', 'admin')))); + $ADMIN->add('security', $temp); } // end of speedup diff --git a/admin/settings/server.php b/admin/settings/server.php index 278596a801..f0bc9f0402 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -10,10 +10,10 @@ $temp = new admin_settingpage('systempaths', get_string('systempaths','admin')); $temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'), '1' => get_string('gd1'), '2' => get_string('gd2')))); -$temp->add(new admin_setting_configtext('zip', get_string('pathtozip','admin'), get_string('configzip', 'admin'), '', PARAM_RAW)); // TODO: add path validation -$temp->add(new admin_setting_configtext('unzip', get_string('pathtounzip','admin'), get_string('configunzip', 'admin'), '', PARAM_RAW)); // TODO: add path validation -$temp->add(new admin_setting_configtext('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), '', PARAM_RAW)); // TODO: add path validation -$temp->add(new admin_setting_configtext('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), '', PARAM_RAW)); // TODO: add path validation +$temp->add(new admin_setting_configexecutable('zip', get_string('pathtozip','admin'), get_string('configzip', 'admin'), '')); +$temp->add(new admin_setting_configexecutable('unzip', get_string('pathtounzip','admin'), get_string('configunzip', 'admin'), '')); +$temp->add(new admin_setting_configexecutable('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), '')); +$temp->add(new admin_setting_configexecutable('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), '')); $ADMIN->add('server', $temp, 0); @@ -22,10 +22,8 @@ $ADMIN->add('server', $temp, 0); $temp = new admin_settingpage('mail', get_string('mail','admin')); $temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_HOST)); $temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS)); -$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_RAW)); +$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), '')); $temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . $_SERVER['HTTP_HOST'], PARAM_NOTAGS)); -$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_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00', '01' => '01', '02' => '02', @@ -55,7 +53,7 @@ unset($charsets['UTF-8']); // not needed here $options = array(); $options['0'] = get_string('none'); $options = array_merge($options, $charsets); -$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '', $options)); +$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '0', $options)); $temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0)); $options = array('LF'=>'LF', 'CRLF'=>'CRLF'); $temp->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'admin'), get_string('configmailnewline','admin'), 'LF', $options)); @@ -63,7 +61,7 @@ if (isloggedin()) { global $USER; $primaryadminemail = $USER->email; $primaryadminname = fullname($USER, true); - + } else { // no defaults during installation - admin user must be created first $primaryadminemail = NULL; @@ -103,10 +101,10 @@ $ADMIN->add('server', $temp); // "debugging" settingpage $temp = new admin_settingpage('debugging', get_string('debugging', 'admin')); $temp->add(new admin_setting_special_debug()); -$temp->add(new admin_setting_special_debugdisplay()); +$temp->add(new admin_setting_configcheckbox('debugdisplay', get_string('debugdisplay', 'admin'), get_string('configdebugdisplay', 'admin'), ini_get('display_errors'))); $temp->add(new admin_setting_configcheckbox('xmlstrictheaders', get_string('xmlstrictheaders', 'admin'), get_string('configxmlstrictheaders', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0)); -$temp->add(new admin_setting_special_perfdebug()); +$temp->add(new admin_setting_configcheckbox('perfdebug', get_string('perfdebug', 'admin'), get_string('configperfdebug', 'admin'), '7', '15', '7')); $ADMIN->add('server', $temp); @@ -209,16 +207,16 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), " // "performance" settingpage $temp = new admin_settingpage('performance', get_string('performance', 'admin')); -$temp->add(new admin_setting_configselect('cachetype', get_string('cachetype', 'admin'), - get_string('configcachetype', 'admin'), '', - array( '' => get_string('none'), - 'internal' => 'internal', - 'memcached' => 'memcached', +$temp->add(new admin_setting_configselect('cachetype', get_string('cachetype', 'admin'), + get_string('configcachetype', 'admin'), '', + array( '' => get_string('none'), + 'internal' => 'internal', + 'memcached' => 'memcached', 'eaccelerator' => 'eaccelerator'))); // NOTE: $CFG->rcache is forced to bool in lib/setup.php $temp->add(new admin_setting_configselect('rcache', get_string('rcache', 'admin'), - get_string('configrcache', 'admin'), 0, - array( '0' => get_string('no'), + get_string('configrcache', 'admin'), 0, + array( '0' => get_string('no'), '1' => get_string('yes')))); $temp->add(new admin_setting_configtext('rcachettl', get_string('rcachettl', 'admin'), get_string('configrcachettl', 'admin'), 10)); @@ -227,8 +225,8 @@ $temp->add(new admin_setting_configtext('intcachemax', get_string('intcachemax', $temp->add(new admin_setting_configtext('memcachedhosts', get_string('memcachedhosts', 'admin'), get_string('configmemcachedhosts', 'admin'), '')); $temp->add(new admin_setting_configselect('memcachedpconn', get_string('memcachedpconn', 'admin'), - get_string('configmemcachedpconn', 'admin'), 0, - array( '0' => get_string('no'), + get_string('configmemcachedpconn', 'admin'), 0, + array( '0' => get_string('no'), '1' => get_string('yes')))); $ADMIN->add('server', $temp); diff --git a/admin/settings/top.php b/admin/settings/top.php index 5e72efdc5e..de1717b417 100644 --- a/admin/settings/top.php +++ b/admin/settings/top.php @@ -18,9 +18,6 @@ $ADMIN->add('root', new admin_externalpage('adminnotifications', get_string('not // hidden upgrade script $ADMIN->add('root', new admin_externalpage('upgradesettings', get_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true)); -// hidden search script -$ADMIN->add('root', new admin_externalpage('search', get_string('search', 'admin'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:config', true)); - $ADMIN->add('root', new admin_category('users', get_string('users','admin'))); $ADMIN->add('root', new admin_category('courses', get_string('courses','admin'))); $ADMIN->add('root', new admin_category('grades', get_string('grades'))); @@ -28,9 +25,6 @@ $ADMIN->add('root', new admin_category('location', get_string('location','admin' $ADMIN->add('root', new admin_category('language', get_string('language'))); $ADMIN->add('root', new admin_category('modules', get_string('plugins', 'admin'))); -$ADMIN->add('modules', new admin_externalpage('managemodules', get_string('activities'), "$CFG->wwwroot/$CFG->admin/modules.php")); -$ADMIN->add('modules', new admin_externalpage('manageblocks', get_string('blocks'), "$CFG->wwwroot/$CFG->admin/blocks.php")); -$ADMIN->add('modules', new admin_externalpage('managefilters', get_string('managefilters'), "$CFG->wwwroot/$CFG->admin/filters.php")); $ADMIN->add('root', new admin_category('security', get_string('security','admin'))); $ADMIN->add('root', new admin_category('appearance', get_string('appearance','admin'))); @@ -57,4 +51,7 @@ $ADMIN->add('root', new admin_category('misc', get_string('miscellaneous'))); // hidden unsupported category $ADMIN->add('root', new admin_category('unsupported', get_string('unsupported', 'admin'), true)); +// hidden search script +$ADMIN->add('root', new admin_externalpage('search', get_string('searchresults'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:config', true)); + ?> diff --git a/admin/settings/unsupported.php b/admin/settings/unsupported.php index f0170f15bb..5c037ab66f 100644 --- a/admin/settings/unsupported.php +++ b/admin/settings/unsupported.php @@ -4,10 +4,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page -$ADMIN->add('unsupported', new admin_externalpage('purgemoodledata', 'Purge moodledata', $CFG->wwwroot.'/'.$CFG->admin.'/delete.php')); -$ADMIN->add('unsupported', new admin_externalpage('healthcenter', get_string('healthcenter'), $CFG->wwwroot.'/'.$CFG->admin.'/health.php')); -$ADMIN->add('unsupported', new admin_externalpage('toinodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/innodb.php')); -$ADMIN->add('unsupported', new admin_externalpage('replace', 'Search and replace', $CFG->wwwroot.'/'.$CFG->admin.'/replace.php')); + $ADMIN->add('unsupported', new admin_externalpage('purgemoodledata', 'Purge moodledata', $CFG->wwwroot.'/'.$CFG->admin.'/delete.php')); + $ADMIN->add('unsupported', new admin_externalpage('healthcenter', get_string('healthcenter'), $CFG->wwwroot.'/'.$CFG->admin.'/health.php')); + $ADMIN->add('unsupported', new admin_externalpage('toinodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/innodb.php')); + $ADMIN->add('unsupported', new admin_externalpage('replace', 'Search and replace', $CFG->wwwroot.'/'.$CFG->admin.'/replace.php')); } // end of speedup diff --git a/admin/settings/users.php b/admin/settings/users.php index 5ad2d7daa5..cd3060dcf3 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -9,108 +9,151 @@ if ($hassiteconfig or has_capability('moodle/user:delete', $systemcontext)) { // speedup for non-admins, add all caps used on this page -$ADMIN->add('users', new admin_externalpage('userauthentication', get_string('authentication','admin'), "$CFG->wwwroot/$CFG->admin/auth.php")); - + $ADMIN->add('users', new admin_category('authsettings', get_string('authentication','admin'))); + + $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)); + + $ADMIN->add('authsettings', $temp); + + + if ($auths = get_list_of_plugins('auth')) { + $authsenabled = get_enabled_auth_plugins(); + $authbyname = array(); + + foreach ($auths as $auth) { + $strauthname = get_string("auth_{$auth}title", "auth"); + if ($strauthname == "[[auth_{$auth}title]]") { + $strauthname = get_string("auth_{$auth}title", "auth_{$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. + $ADMIN->add('authsettings', $settings); + + } else { + $ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !in_array($authname, $authsenabled))); + } + } + } -if(empty($CFG->loginhttps)) { - $securewwwroot = $CFG->wwwroot; -} else { - $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); -} -// stuff under the "accounts" subcategory -$ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin'))); -$ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete'))); -$ADMIN->add('accounts', new admin_externalpage('userbulk', get_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete'))); -$ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); -$ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers')); -$ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); + if(empty($CFG->loginhttps)) { + $securewwwroot = $CFG->wwwroot; + } else { + $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); + } + // stuff under the "accounts" subcategory + $ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin'))); + $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete'))); + $ADMIN->add('accounts', new admin_externalpage('userbulk', get_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete'))); + $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); + $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers')); + $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); + + + // stuff under the "roles" subcategory + $ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role'))); + $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php")); + $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id)); + + + // "userpolicies" settingpage + $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin')); + if ($ADMIN->fulltree) { + if (!empty($CFG->rolesactive)) { + $context = get_context_instance(CONTEXT_SYSTEM); + if (!$guestrole = get_guest_role()) { + $guestrole->id = 0; + } + if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { + $studentrole = array_shift($studentroles); /// Take the first one + } else { + $studentrole->id = 0; + } + if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW)) { + $userrole = array_shift($userroles); /// Take the first one + } else { + $userrole->id = 0; + } + if (empty($CFG->creatornewroleid)) { + if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, $context)) { + $teachereditrole = array_shift($teacherroles); + set_config('creatornewroleid', $teachereditrole->id); + } else { + set_config('creatornewroleid', 0); + } + } + // we must not use assignable roles here: + // 1/ unsetting roles as assignable for admin might bork the settings! + // 2/ default user role should not be assignable anyway + $allroles = array(); + if ($roles = get_all_roles()) { + foreach ($roles as $role) { + $allroles[$role->id] = strip_tags(format_string($role->name, true)); + } + } + + $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'), + get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $allroles )); + $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'), + get_string('configguestroleid', 'admin'), $guestrole->id, $allroles)); + $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'), + get_string('configdefaultuserroleid', 'admin'), $userrole->id, $allroles)); + } -// stuff under the "roles" subcategory -$ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role'))); -$ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php")); -$sitecontext = get_context_instance(CONTEXT_SYSTEM); -$ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $sitecontext->id)); + $temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0)); + if (!empty($CFG->rolesactive)) { + $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'), + get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles)); + $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'), + get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid, $allroles)); + } -// "userpolicies" settingpage -$temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin')); + $temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0)); -if (!empty($CFG->rolesactive)) { - $context = get_context_instance(CONTEXT_SYSTEM); - if (!$guestrole = get_guest_role()) { - $guestrole->id = 0; - } - if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { - $studentrole = array_shift($studentroles); /// Take the first one - } else { - $studentrole->id = 0; - } - if ($userroles = get_roles_with_capability('moodle/legacy:user', CAP_ALLOW)) { - $userrole = array_shift($userroles); /// Take the first one - } else { - $userrole->id = 0; - } - if (empty($CFG->creatornewroleid)) { - if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, $context)) { - $teachereditrole = array_shift($teacherroles); - set_config('creatornewroleid', $teachereditrole->id); - } else { - set_config('creatornewroleid', 0); - } - } - // we must not use assignable roles here: - // 1/ unsetting roles as assignable for admin might bork the settings! - // 2/ default user role should not be assignable anyway - $allroles = array(); - if ($roles = get_all_roles()) { - foreach ($roles as $role) { - $allroles[$role->id] = strip_tags(format_string($role->name, true)); + if (!empty($CFG->rolesactive)) { + $temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'), + get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles)); } + + $temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'), + get_string('confighiddenuserfields', 'admin'), array(), + array('description' => get_string('description'), + 'city' => get_string('city'), + 'country' => get_string('country'), + 'webpage' => get_string('webpage'), + 'icqnumber' => get_string('icqnumber'), + 'skypeid' => get_string('skypeid'), + 'yahooid' => get_string('yahooid'), + 'aimid' => get_string('aimid'), + 'msnid' => get_string('msnid'), + 'lastaccess' => get_string('lastaccess')))); } - $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'), - get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $allroles )); - $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'), - get_string('configguestroleid', 'admin'), $guestrole->id, $allroles)); - $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'), - get_string('configdefaultuserroleid', 'admin'), $userrole->id, $allroles)); -} - -$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0)); - -if (!empty($CFG->rolesactive)) { - $temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'), - get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles)); - $temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'), - get_string('configcreatornewroleid', 'admin'), $CFG->creatornewroleid, $allroles)); -} - -$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0)); - -if (!empty($CFG->rolesactive)) { - $temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'), - get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles)); -} - -//$temp->add(new admin_setting_configcheckbox('allusersaresitestudents', get_string('allusersaresitestudents', 'admin'), get_string('configallusersaresitestudents','admin'), 1)); -$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'), - get_string('confighiddenuserfields', 'admin'), array(), - array('none' => get_string('none'), - 'description' => get_string('description'), - 'city' => get_string('city'), - 'country' => get_string('country'), - 'webpage' => get_string('webpage'), - 'icqnumber' => get_string('icqnumber'), - 'skypeid' => get_string('skypeid'), - 'yahooid' => get_string('yahooid'), - 'aimid' => get_string('aimid'), - 'msnid' => get_string('msnid'), - 'lastaccess' => get_string('lastaccess')))); -//$temp->add(new admin_setting_special_adminseesall()); - - -$ADMIN->add('roles', $temp); + $ADMIN->add('roles', $temp); } // end of speedup diff --git a/admin/upgradesettings.php b/admin/upgradesettings.php index c011d20332..803c890c52 100644 --- a/admin/upgradesettings.php +++ b/admin/upgradesettings.php @@ -8,17 +8,20 @@ require_once($CFG->libdir.'/adminlib.php'); $return = optional_param('return', '', PARAM_ALPHA); +$adminroot =& admin_get_root(); // need all settings admin_externalpage_setup('upgradesettings'); // now hidden page -// a caveat: we're depending on only having one admin access this page at once. why? the following line -// (the function call to find_new_settings) must have the EXACT SAME RETURN VALUE both times that this -// page is loaded (i.e. both when we're displaying the form and then when we process the form's input). -// if the return values don't match, we could potentially lose changes that the admin is making. +// now we'll deal with the case that the admin has submitted the form with new settings +if ($data = data_submitted() and confirm_sesskey()) { + $count = admin_write_settings($data); + $adminroot =& admin_get_root(true); //reload tree +} -$newsettingshtml = output_new_settings_by_page(admin_get_root()); +$newsettingshtml = admin_output_new_settings_by_page($adminroot); +$focus = ''; -// first we deal with the case where there are no new settings to be set -if ($newsettingshtml == '') { +if (empty($adminroot->errors) and $newsettingshtml === '') { + // there must be either redirect without message or continue button or else upgrade would be sometimes broken if ($return == 'site') { redirect("$CFG->wwwroot/"); } else { @@ -26,128 +29,33 @@ if ($newsettingshtml == '') { } } -// now we'll deal with the case that the admin has submitted the form with new settings -if ($data = data_submitted()) { - $unslashed = (array)stripslashes_recursive($data); - if (confirm_sesskey()) { - $newsettings = find_new_settings(admin_get_root()); - $errors = ''; - - foreach($newsettings as $newsetting) { - if (isset($unslashed['s_' . $newsetting->name])) { - $errors .= $newsetting->write_setting($unslashed['s_' . $newsetting->name]); - } else { - $errors .= $newsetting->write_setting($newsetting->defaultsetting); - } - } - - if (empty($errors)) { - // there must be either redirect without message or continue button or else upgrade would be sometimes broken - if ($return == 'site') { - redirect("$CFG->wwwroot/"); - } else { - redirect("$CFG->wwwroot/$CFG->admin/index.php"); - } - } else { - $url = "$CFG->wwwroot/$CFG->admin/upgradesettings.php?return=$return"; - error(get_string('errorwithsettings', 'admin') . '
' . $errors, $url); - } - } else { - error(get_string('confirmsesskeybad', 'error')); - } - +if (!empty($adminroot->errors)) { + $firsterror = reset($adminroot->errors); + $focus = $firsterror->id; } // and finally, if we get here, then there are new settings and we have to print a form // to modify them -admin_externalpage_print_header(); +admin_externalpage_print_header($focus); -print_simple_box(get_string('upgradesettingsintro','admin'),'','100%','',5,'generalbox',''); +print_box(get_string('upgradesettingsintro','admin'), 'generalbox'); echo '
'; +echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo $newsettingshtml; echo '
'; -echo '
'; +echo '
'; +echo '
'; echo '
'; -admin_externalpage_print_footer(); - - -/** - * Find settings that have not been initialized (e.g. during initial install or an upgrade). - * - * Tests each setting's get_setting() method. If the result is NULL, we consider the setting - * to be uninitialized. - * - * @param string &$node The node at which to start searching. Should be $ADMIN for all external calls to this function. - * @return array An array containing admin_setting objects that haven't yet been initialized - */ -function find_new_settings(&$node) { - - if (is_a($node, 'admin_category')) { - $return = array(); - $entries = array_keys($node->children); - foreach ($entries as $entry) { - $return = array_merge($return, find_new_settings($node->children[$entry])); - } - return $return; - } - - if (is_a($node, 'admin_settingpage')) { - $return = array(); - foreach ($node->settings as $setting) { - if ($setting->get_setting() === NULL) { - $return[] =& $setting; - } - unset($setting); // needed to prevent odd (imho) reference behaviour - // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 - } - return $return; - } - - return array(); - +if (!empty($CFG->adminusehtmleditor)) { + use_html_editor(); } -function output_new_settings_by_page(&$node) { - - if (is_a($node, 'admin_category')) { - $entries = array_keys($node->children); - $return = ''; - foreach ($entries as $entry) { - $return .= output_new_settings_by_page($node->children[$entry]); - } - return $return; - } - - if (is_a($node, 'admin_settingpage')) { - $newsettings = array(); - foreach ($node->settings as $setting) { - if ($setting->get_setting() === NULL) { - $newsettings[] =& $setting; - } - unset($setting); // needed to prevent odd (imho) reference behaviour - // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 - } - $return = ''; - if (count($newsettings) > 0) { - $return .= print_heading(get_string('upgradesettings','admin').' - '.$node->visiblename, '', 2, 'main', true); - $return .= '
' . "\n"; - foreach ($newsettings as $newsetting) { - $return .= '
' . "\n"; - $return .= $newsetting->output_html(); - } - $return .= '
'; - } - return $return; - } - - return ''; - -} +print_footer(); ?> diff --git a/backup/backup_scheduled.php b/backup/backup_scheduled.php index be0e6f1a25..37def53d8f 100644 --- a/backup/backup_scheduled.php +++ b/backup/backup_scheduled.php @@ -177,7 +177,7 @@ function schedule_backup_cron() { //Reference if ($count_error != 0 || $count_unfinished != 0) { $message .= " ".get_string('backupfailed')."\n\n"; - $dest_url = $CFG->wwwroot.'/admin/report/backups/index.php'; + $dest_url = "$CFG->wwwroot/$CFG->admin/report/backups/index.php"; $message .= " ".get_string('backuptakealook','',$dest_url)."\n\n"; //Set message priority $admin->priority = 1; diff --git a/backup/lib.php b/backup/lib.php index 7706690c33..8a5bc505ad 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -355,9 +355,6 @@ $db->debug = false; if ($status) { if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) { - //initialize default backup settings now - $adminroot = admin_get_root(); - apply_default_settings($adminroot->locate('backups')); notify(get_string("databasesuccess"), "green"); notify(get_string("databaseupgradebackups", "", $backup_version), "green"); print_continue($continueto); diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php index 2b4fd5db53..3293bfd485 100644 --- a/blocks/admin_bookmarks/block_admin_bookmarks.php +++ b/blocks/admin_bookmarks/block_admin_bookmarks.php @@ -28,27 +28,27 @@ class block_admin_bookmarks extends block_base { } function get_content() { - + global $CFG, $USER, $PAGE; - + if ($this->content !== NULL) { return $this->content; } - + $this->content = new stdClass; $this->content->text = ''; if (get_user_preferences('admin_bookmarks')) { // this is expensive! Only require when bookmakrs exist.. require_once($CFG->libdir.'/adminlib.php'); - $adminroot = admin_get_root(); - - $bookmarks = explode(',',get_user_preferences('admin_bookmarks')); + $adminroot =& admin_get_root(false, false); // settings not required - only pages + + $bookmarks = explode(',', get_user_preferences('admin_bookmarks')); // hmm... just a liiitle (potentially) processor-intensive // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here - + /// Accessibility: markup as a list. $this->content->text .= '
    '."\n"; - + foreach($bookmarks as $bookmark) { $temp = $adminroot->locate($bookmark); if (is_a($temp, 'admin_settingpage')) { @@ -61,7 +61,7 @@ class block_admin_bookmarks extends block_base { } else { $bookmarks = array(); } - + if (isset($PAGE->section) and $PAGE->section == 'search'){ // the search page can't be properly bookmarked at present $this->content->footer = ''; @@ -72,7 +72,7 @@ class block_admin_bookmarks extends block_base { } else { $this->content->footer = ''; } - + return $this->content; } } diff --git a/blocks/admin_bookmarks/create.php b/blocks/admin_bookmarks/create.php index bea79e971c..a0e1969f2c 100644 --- a/blocks/admin_bookmarks/create.php +++ b/blocks/admin_bookmarks/create.php @@ -3,13 +3,13 @@ require('../../config.php'); require_once($CFG->libdir.'/adminlib.php'); -$adminroot = admin_get_root(); require_login(); +$adminroot =& admin_get_root(false, false); // settings not required - only pages -if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey()) { +if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) { if (get_user_preferences('admin_bookmarks')) { - $bookmarks = explode(',',get_user_preferences('admin_bookmarks')); + $bookmarks = explode(',', get_user_preferences('admin_bookmarks')); if (in_array($section, $bookmarks)) { error(get_string('bookmarkalreadyexists','admin')); @@ -23,28 +23,20 @@ if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey $temp = $adminroot->locate($section); if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) { - $bookmarks[] = $section; - - $bookmarks = implode(',',$bookmarks); - + $bookmarks = implode(',', $bookmarks); set_user_preference('admin_bookmarks', $bookmarks); } else { - error(get_string('invalidsection','admin')); die; - } if (is_a($temp, 'admin_settingpage')) { - redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section); } elseif (is_a($temp, 'admin_externalpage')) { - redirect($temp->url); - } } else { diff --git a/blocks/admin_bookmarks/delete.php b/blocks/admin_bookmarks/delete.php index a73a39aee1..1ad4f1519e 100644 --- a/blocks/admin_bookmarks/delete.php +++ b/blocks/admin_bookmarks/delete.php @@ -3,10 +3,11 @@ require('../../config.php'); require_once($CFG->libdir.'/adminlib.php'); -$adminroot = admin_get_root(); + require_login(); +$adminroot =& admin_get_root(false, false); // settings not required - only pages -if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey()) { +if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) { if (get_user_preferences('admin_bookmarks')) { @@ -15,12 +16,12 @@ if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey $key = array_search($section, $bookmarks); if ($key === false) { - error(get_string('nonexistentbookmark','admin')); + error(get_string('nonexistentbookmark','admin')); die; } unset($bookmarks[$key]); - $bookmarks = implode(',',$bookmarks); + $bookmarks = implode(',', $bookmarks); set_user_preference('admin_bookmarks', $bookmarks); $temp = $adminroot->locate($section); @@ -37,7 +38,7 @@ if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey } - error(get_string('nobookmarksforuser','admin')); + error(get_string('nobookmarksforuser','admin')); die; } else { diff --git a/blocks/admin_tree/block_admin_tree.php b/blocks/admin_tree/block_admin_tree.php index 228b75f0ed..6528b0b06c 100644 --- a/blocks/admin_tree/block_admin_tree.php +++ b/blocks/admin_tree/block_admin_tree.php @@ -3,7 +3,7 @@ class block_admin_tree extends block_base { var $currentdepth; - var $spancounter; + var $divcounter; var $tempcontent; var $pathtosection; var $expandjavascript; @@ -14,7 +14,7 @@ class block_admin_tree extends block_base { $this->title = get_string('administrationsite'); $this->version = 2006090300; $this->currentdepth = 0; - $this->spancounter = 1; + $this->divcounter = 1; $this->tempcontent = ''; $this->section = (isset($PAGE->section) ? $PAGE->section : ''); $this->pathtosection = array(); @@ -34,49 +34,51 @@ class block_admin_tree extends block_base { global $CFG; $strfolderopened = s(get_string('folderopened')); - for ($i = 0; $i < $this->currentdepth; $i++) { - $this->tempcontent .= "   "; - } - $this->tempcontent .= ''; - $this->tempcontent .= ''.$strfolderopened.' '; - $this->tempcontent .= $visiblename . '
    ' . "\n"; + $this->tempcontent .= '
    '."\n"; $this->currentdepth++; - $this->spancounter++; + $this->divcounter++; } function close_folder() { $this->currentdepth--; - $this->tempcontent .= "\n"; + $this->tempcontent .= "
    \n"; } function create_item($visiblename,$link,$icon,$class) { global $CFG; - for ($i = 0; $i < $this->currentdepth; $i++) { - $this->tempcontent .= "   "; - } - $this->tempcontent .= ''. - $visiblename.'
    '."\n"; + $this->tempcontent .= ''."\n"; } function build_tree (&$content) { global $CFG; if (is_a($content, 'admin_settingpage')) { - if ($content->check_access() and !$content->is_hidden()) { + // show hidden pages in tree if hidden page active + if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) { $class = ($content->name == $this->section) ? 'link current' : 'link'; - $this->create_item($content->visiblename,$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_tree/item.gif', $class); + if ($content->is_hidden()) { + $class .= ' hidden'; + } + $this->create_item($content->visiblename, $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section='.$content->name, $CFG->wwwroot.'/blocks/admin_tree/item.gif', $class); } } else if (is_a($content, 'admin_externalpage')) { - if ($content->check_access() and !$content->is_hidden()) { + // show hidden pages in tree if hidden page active + if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) { $class = ($content->name == $this->section) ? 'link current' : 'link'; - $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_tree/item.gif', $class); + if ($content->is_hidden()) { + $class .= ' hidden'; + } + $this->create_item($content->visiblename, $content->url, $CFG->wwwroot.'/blocks/admin_tree/item.gif', $class); } } else if (is_a($content, 'admin_category')) { if ($content->check_access() and !$content->is_hidden()) { // check if the category we're currently printing is a parent category for the current page; if it is, we // make a note (in the javascript) that it has to be expanded after the page has loaded - if ($this->pathtosection[count($this->pathtosection) - 1] == $content->name) { - $this->expandjavascript .= 'expand("vh_span' . ($this->spancounter) . '");' . "\n"; + if ($this->section != '' and $this->pathtosection[count($this->pathtosection) - 1] == $content->name) { + $this->expandjavascript .= 'expand("vh_div'.($this->divcounter).'");'."\n"; array_pop($this->pathtosection); } @@ -108,10 +110,10 @@ class block_admin_tree extends block_base { } require_once($CFG->libdir.'/adminlib.php'); - $adminroot = admin_get_root(); + $adminroot =& admin_get_root(false, false); // settings not required - only pages - if ($this->pathtosection = $adminroot->path($this->section)) { - $this->pathtosection = array_reverse($this->pathtosection); + if ($current = $adminroot->locate($this->section, true)) { + $this->pathtosection = $current->path; array_pop($this->pathtosection); } @@ -130,53 +132,53 @@ class block_admin_tree extends block_base { $strfolderopened = s(get_string('folderopened')); $strfolderclosed = s(get_string('folderclosed')); - $this->content = new stdClass; + $this->content = new object(); $this->content->text = '' . "\n"; - $searchcontent = isset($CFG->adminsearchquery) ? $CFG->adminsearchquery : ''; + $searchcontent = $adminroot->search; $this->content->footer = '
    '. - '
    '. + '
    '. ''. ''. '
    '. diff --git a/blocks/course_list/config_global.html b/blocks/course_list/config_global.html deleted file mode 100644 index 5e1b61406e..0000000000 --- a/blocks/course_list/config_global.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - -
    block_course_list_adminview: - - - - -
    block_course_list_hideallcourseslink: - - - -
    - " />
    diff --git a/blocks/course_list/settings.php b/blocks/course_list/settings.php new file mode 100644 index 0000000000..899af4a804 --- /dev/null +++ b/blocks/course_list/settings.php @@ -0,0 +1,13 @@ +get_string('allcourses', 'block_course_list'), 'own'=>get_string('owncourses', 'block_course_list')); + +$settings->add(new admin_setting_configselect('block_course_list_adminview', get_string('adminview', 'block_course_list'), + get_string('configadminview', 'block_course_list'), 'all', $options)); + +$settings->add(new admin_setting_configcheckbox('block_course_list_hideallcourseslink', get_string('hideallcourseslink', 'block_course_list'), + get_string('confighideallcourseslink', 'block_course_list'), 0)); + + +?> diff --git a/blocks/online_users/config_global.html b/blocks/online_users/config_global.html deleted file mode 100644 index 50ed5db122..0000000000 --- a/blocks/online_users/config_global.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - -
    block_online_users_timetosee: - - - - -
    -
    diff --git a/blocks/online_users/settings.php b/blocks/online_users/settings.php new file mode 100644 index 0000000000..0098fb67d5 --- /dev/null +++ b/blocks/online_users/settings.php @@ -0,0 +1,6 @@ +add(new admin_setting_configtext('block_online_users_timetosee', get_string('timetosee', 'block_online_users'), + get_string('configtimetosee', 'block_online_users'), 5, PARAM_INT)); + +?> diff --git a/blocks/rss_client/config_global.html b/blocks/rss_client/config_global.html deleted file mode 100644 index d793abc25f..0000000000 --- a/blocks/rss_client/config_global.html +++ /dev/null @@ -1,75 +0,0 @@ -libdir .'/rsslib.php'); -?> - - - - - - - - - - - - - - - - - - - - - - - - - -
    block_rss_client_num_entries: - - - - -
    block_rss_client_timeout: - - - -
    block_rss_client_submitters: - block_rss_client_submitters)) { - $selected = $CFG->block_rss_client_submitters; - } else { - $selected = '0'; - $CFG->block_rss_client_submitters = 0; - } - - // removed everybody option for 1.5 beta - // things are not quite working yet to allow this - revisit later - // also 'everybody' should be 'site members' or something clearer since - // it does not include guests - $options = array ( - SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody'), - SUBMITTERS_ADMIN_ONLY => get_string('administrators'), - SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') ); - - choose_from_menu ($options, 'block_rss_client_submitters', $selected); - ?> - - -
    -


    -
    diff --git a/blocks/rss_client/settings.php b/blocks/rss_client/settings.php new file mode 100644 index 0000000000..f18c8c232f --- /dev/null +++ b/blocks/rss_client/settings.php @@ -0,0 +1,21 @@ +libdir.'/rsslib.php'); + +$settings->add(new admin_setting_configtext('block_rss_client_num_entries', get_string('numentries', 'block_rss_client'), + get_string('clientnumentries', 'block_rss_client'), 5, PARAM_INT)); + +$settings->add(new admin_setting_configtext('block_rss_client_timeout', get_string('timeout2', 'block_rss_client'), + get_string('timeout', 'block_rss_client'), 30, PARAM_INT)); + +$options = array (SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody'), + SUBMITTERS_ADMIN_ONLY => get_string('administrators'), + SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers')); +$settings->add(new admin_setting_configselect('block_rss_client_submitters', get_string('submitters2', 'block_rss_client'), + get_string('submitters', 'block_rss_client'), SUBMITTERS_ADMIN_ONLY, $options)); + +$link =''.get_string('feedsaddedit', 'block_rss_client').''; +$settings->add(new admin_setting_heading('block_rss_addheading', '', $link)); + + +?> diff --git a/course/lib.php b/course/lib.php index 4ad44080f3..9c0af6626d 100644 --- a/course/lib.php +++ b/course/lib.php @@ -13,11 +13,11 @@ define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); // max courses in log dropdown before switching to optional define('COURSE_MAX_USERS_PER_DROPDOWN',1000); // max users in log dropdown before switching to optional -define('FRONTPAGENEWS', 0); -define('FRONTPAGECOURSELIST', 1); -define('FRONTPAGECATEGORYNAMES', 2); -define('FRONTPAGETOPICONLY', 3); -define('FRONTPAGECATEGORYCOMBO', 4); +define('FRONTPAGENEWS', '0'); +define('FRONTPAGECOURSELIST', '1'); +define('FRONTPAGECATEGORYNAMES', '2'); +define('FRONTPAGETOPICONLY', '3'); +define('FRONTPAGECATEGORYCOMBO', '4'); define('FRONTPAGECOURSELIMIT', 200); // maximum number of courses displayed on the frontpage define('EXCELROWS', 65535); define('FIRSTUSEDEXCELROW', 3); diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php index 467a22a627..96a919ef45 100644 --- a/filter/algebra/algebradebug.php +++ b/filter/algebra/algebradebug.php @@ -16,13 +16,8 @@ } } - $CFG->texfilterdir = "filter/tex"; - $CFG->algebrafilterdir = "filter/algebra"; - $CFG->algebraimagedir = "filter/algebra"; - if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) { - $CFG->algebrafilterdirwin = "filter\\algebra"; - } - + require_once($CFG->libdir.'/filelib.php'); + require_once($CFG->dirroot.'/filter/tex/lib.php'); $query = urldecode($_SERVER['QUERY_STRING']); error_reporting(E_ALL); @@ -77,7 +72,7 @@ } else { slasharguments($output, $md5); } - } else { + } else { outputText($output); } exit; @@ -102,35 +97,35 @@ function algebra2tex($algebra) { $algebra = escapeshellarg($algebra); if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) { - $cmd = "cd $CFG->dirroot\\$CFG->algebrafilterdirwin & algebra2tex.pl x/2"; + $cmd = "cd $CFG->dirroot\\filter\\algebra & algebra2tex.pl x/2"; $test = `$cmd`; if ($test != '\frac{x}{2}') { echo "There is a problem with either Perl or the script algebra2tex.pl
    "; $ecmd = $cmd . " 2>&1"; echo `$ecmd` . "
    \n"; echo "The shell command
    $cmd
    returned status = $status
    \n"; - $commandpath = "$CFG->dirroot\\$CFG->algebrafilterdirwin\\algebra2tex.pl"; + $commandpath = "$CFG->dirroot\\filter\\algebra\\algebra2tex.pl"; if (file_exists($commandpath)) { echo "The file permissions of algebra2tex.pl are: " . decoct(fileperms($commandpath)) . "
    "; } die; } - $cmd = "cd $CFG->dirroot\\$CFG->algebrafilterdirwin & algebra2tex.pl $algebra"; - } else { - $cmd = "cd $CFG->dirroot/$CFG->algebrafilterdir; ./algebra2tex.pl x/2"; + $cmd = "cd $CFG->dirroot\\filter\\algebra & algebra2tex.pl $algebra"; + } else { + $cmd = "cd $CFG->dirroot/filter/algebra; ./algebra2tex.pl x/2"; $test = `$cmd`; if ($test != '\frac{x}{2}') { echo "There is a problem with either Perl or the script algebra2tex.pl
    "; $ecmd = $cmd . " 2>&1"; echo `$ecmd` . "
    \n"; echo "The shell command
    $cmd
    returned status = $status
    \n"; - $commandpath = "$CFG->dirroot/$CFG->algebrafilterdir/algebra2tex.pl"; + $commandpath = "$CFG->dirroot/filter/algebra/algebra2tex.pl"; if (file_exists($commandpath)) { echo "The file permissions of algebra2tex.pl are: " . decoct(fileperms($commandpath)) . "
    "; } die; } - $cmd = "cd $CFG->dirroot/$CFG->algebrafilterdir; ./algebra2tex.pl $algebra"; + $cmd = "cd $CFG->dirroot/filter/algebra; ./algebra2tex.pl $algebra"; } $texexp = `$cmd`; return $texexp; @@ -206,109 +201,67 @@ function outputText($texexp) { function tex2image($texexp, $md5, $return=false) { global $CFG; - $error_message1 = "Your system is not configured to run mimeTeX. "; - $error_message1 .= "You need to download the appropriate
    executable "; - $error_message1 .= "from "; - $error_message1 .= "http://moodle.org/download/mimetex/, or obtain the "; - $error_message1 .= "C source
    from "; - $error_message1 .= "http://www.forkosh.com/mimetex.zip, compile it and "; - $error_message1 .= "put the executable into your
    moodle/filter/tex/ directory. "; - $error_message1 .= "You also need to edit your moodle/filter/algebra/pix.php file
    "; - $error_message1 .= ' by adding the line
           case "' . PHP_OS . "\":\n";
    -    $error_message1 .= "           \$cmd = \"\\\\\"\$CFG->dirroot/\$CFG->texfilterdir/";
    -    $error_message1 .= 'mimetex.' . strtolower(PHP_OS) . "\\\\\" -e \\\\\"\$pathname\\\\\" \". escapeshellarg(\$texexp);";
    -    $error_message1 .= "
    You also need to add this to your algebradebug.php file."; - if ($texexp) { - $texexp = '\Large ' . $texexp; - $lifetime = 86400; - $image = $md5 . ".gif"; - $filetype = 'image/gif'; - if (!file_exists("$CFG->dataroot/$CFG->algebraimagedir")) { - make_upload_directory($CFG->algebraimagedir); - } - $pathname = "$CFG->dataroot/$CFG->algebraimagedir/$image"; - if (file_exists($pathname)) { - unlink($pathname); - } - $commandpath = ""; - $cmd = ""; - $texexp = escapeshellarg($texexp); - switch (PHP_OS) { - case "Linux": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.linux"; - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" $texexp"; - break; - case "WINNT": - case "WIN32": - case "Windows": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$commandpath); - $cmd .= " ++ -e \"$pathname\" $texexp"; - break; - case "Darwin": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin"; - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" $texexp"; - break; - } - if (!$cmd) { - if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex"; - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname $texexp"; - } else { - error($error_message1); - } - } - system($cmd, $status); + if (!$texexp) { + echo 'No tex expresion specified'; + return; + } + + $texexp = '\Large ' . $texexp; + $image = $md5 . ".gif"; + $filetype = 'image/gif'; + if (!file_exists("$CFG->dataroot/filter/algebra")) { + make_upload_directory("filter/algebra"); + } + $pathname = "$CFG->dataroot/filter/algebra/$image"; + if (file_exists($pathname)) { + unlink($pathname); } + $commandpath = tex_filter_get_executable(true); + $cmd = tex_filter_get_cmd($pathname, $texexp); + system($cmd, $status); + if ($return) { return $image; } - if ($texexp && file_exists($pathname)) { - $lastmodified = filemtime($pathname); - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); - header("Cache-control: max_age = $lifetime"); // a day - header("Pragma: "); - header("Content-disposition: inline; filename=$image"); - header("Content-length: ".filesize($pathname)); - header("Content-type: $filetype"); - readfile("$pathname"); + if (file_exists($pathname)) { + send_file($pathname, $image); + } else { - $ecmd = "$cmd 2>&1"; - echo `$ecmd` . "
    \n"; - echo "The shell command
    $cmd
    returned status = $status
    \n"; - if ($status == 4) { - echo "Status corresponds to illegal instruction
    \n"; - } else if ($status == 11) { - echo "Status corresponds to bus error
    \n"; - } else if ($status == 22) { - echo "Status corresponds to abnormal termination
    \n"; - } - if (file_exists($commandpath)) { - echo "File size of mimetex executable $commandpath is " . filesize($commandpath) . "
    "; - echo "The file permissions are: " . decoct(fileperms($commandpath)) . "
    "; - if (function_exists("md5_file")) { + $ecmd = "$cmd 2>&1"; + echo `$ecmd` . "
    \n"; + echo "The shell command
    $cmd
    returned status = $status
    \n"; + if ($status == 4) { + echo "Status corresponds to illegal instruction
    \n"; + } else if ($status == 11) { + echo "Status corresponds to bus error
    \n"; + } else if ($status == 22) { + echo "Status corresponds to abnormal termination
    \n"; + } + if (file_exists($commandpath)) { + echo "File size of mimetex executable $commandpath is " . filesize($commandpath) . "
    "; + echo "The file permissions are: " . decoct(fileperms($commandpath)) . "
    "; + if (function_exists("md5_file")) { echo "The md5 checksum of the file is " . md5_file($commandpath) . "
    "; - } else { + } else { $handle = fopen($commandpath,"rb"); $contents = fread($handle,16384); fclose($handle); echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
    "; - } - } else { - echo "mimetex executable $commandpath not found!
    "; - } - echo "Image not found!"; + } + } else { + echo "mimetex executable $commandpath not found!
    "; + } + echo "Image not found!"; } } function slasharguments($texexp, $md5) { global $CFG; - $admin = $CFG->wwwroot . '/' . $CFG->admin . '/config.php'; + $admin = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=http'; $image = tex2image($texexp,$md5,true); echo "

    If the following image displays correctly, set your "; - echo "Administration->Configuration->Variables "; + echo "Administration->Server->HTTP "; echo "setting for slasharguments to file.php/1/pic.jpg: "; echo "

    \n"; echo "

    Otherwise set it to file.php?file=/1/pic.jpg "; @@ -316,7 +269,7 @@ function slasharguments($texexp, $md5) { echo "

    \n"; echo "

    If neither equation image displays correctly, please seek "; echo "further help at moodle.org at the "; - echo ""; + echo ""; echo "Mathematics Tools Forum

    "; } diff --git a/filter/algebra/filter.php b/filter/algebra/filter.php index 3bb480df46..eee12c34fd 100644 --- a/filter/algebra/filter.php +++ b/filter/algebra/filter.php @@ -30,22 +30,13 @@ // then converts the TeX to gif images using // mimetex.cgi obtained from http://www.forkosh.com/mimetex.html authored by // John Forkosh john@forkosh.com. The mimetex.cgi ELF binary compiled for Linux i386 -// as well as AlgParser.pm are included with this distribution. +// as well as AlgParser.pm are included with this distribution. // Note that there may be patent restrictions on the production of gif images // in Canada and some parts of Western Europe and Japan until July 2004. //------------------------------------------------------------------------- // You will then need to edit your moodle/config.php to invoke mathml_filter.php //------------------------------------------------------------------------- - -/// Edit these lines to correspond to your installation -// File path to the directory where mathml_filter.php resides - $CFG->algebrafilterdir = "filter/algebra"; - $CFG->texfilterdir = "filter/tex"; - if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) { - $CFG->algebrafilterdirwin = "filter\\algebra"; - } - function string_file_picture_algebra($imagefile, $tex= "", $height="", $width="", $align="middle") { // Given the path to a picture file in a course, or a URL, // this function includes the picture in the page. @@ -70,20 +61,20 @@ function string_file_picture_algebra($imagefile, $tex= "", $height="", $width="" } $style .= '"'; if ($imagefile) { - if (!file_exists("$CFG->dataroot/$CFG->algebrafilterdir/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - $output .= "wwwroot/$CFG->algebrafilterdir/algebradebug.php\">"; + if (!file_exists("$CFG->dataroot/filter/algebra/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + $output .= "wwwroot/filter/algebra/algebradebug.php\">"; } else { $output .= "wwwroot/$CFG->texfilterdir/displaytex.php?"; - $output .= urlencode($tex) . "\" onclick=\"return openpopup('/$CFG->texfilterdir/displaytex.php?"; + $output .= "\"$CFG->wwwroot/filter/algebra/displaytex.php?"; + $output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/algebra/displaytex.php?"; $output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,"; $output .= "resizable,width=300,height=240', 0);\">"; } $output .= "\"".s($origtex)."\"slasharguments) { // Use this method if possible for better caching - $output .= "$CFG->wwwroot/$CFG->algebrafilterdir/pix.php/$imagefile"; + $output .= "$CFG->wwwroot/filter/algebra/pix.php/$imagefile"; } else { - $output .= "$CFG->wwwroot/$CFG->algebrafilterdir/pix.php?file=$imagefile"; + $output .= "$CFG->wwwroot/filter/algebra/pix.php?file=$imagefile"; } $output .= "\" $style />"; $output .= ""; @@ -97,7 +88,7 @@ function string_file_picture_algebra($imagefile, $tex= "", $height="", $width="" function algebra_filter ($courseid, $text) { global $CFG; - + /// Do a quick check using stripos to avoid unnecessary wor if (!preg_match('/ some algebraic input expression // or @@ some algebraic input expression @@ - preg_match_all('/(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches); + preg_match_all('/(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches); for ($i=0; $i','',$algebra); @@ -166,9 +157,9 @@ function algebra_filter ($courseid, $text) { $algebra = preg_replace('!\r\n?!',' ',$algebra); $algebra = escapeshellarg($algebra); if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) { - $cmd = "cd $CFG->dirroot\\$CFG->algebrafilterdirwin & algebra2tex.pl $algebra"; - } else { - $cmd = "cd $CFG->dirroot/$CFG->algebrafilterdir; ./algebra2tex.pl $algebra"; + $cmd = "cd $CFG->dirroot\\filter\\algebra & algebra2tex.pl $algebra"; + } else { + $cmd = "cd $CFG->dirroot/filter/algebra; ./algebra2tex.pl $algebra"; } $texexp = `$cmd`; if (preg_match('/parsehilight/',$texexp)) { @@ -182,8 +173,8 @@ function algebra_filter ($courseid, $text) { $texexp = str_replace('\right}','}',$texexp); $texexp = str_replace('\fun',' ',$texexp); $texexp = str_replace('infty','\infty',$texexp); - $texexp = str_replace('alpha','\alpha',$texexp); - $texexp = str_replace('gamma','\gamma',$texexp); + $texexp = str_replace('alpha','\alpha',$texexp); + $texexp = str_replace('gamma','\gamma',$texexp); $texexp = str_replace('iota','\iota',$texexp); $texexp = str_replace('kappa','\kappa',$texexp); $texexp = str_replace('lambda','\lambda',$texexp); @@ -239,7 +230,7 @@ function algebra_filter ($courseid, $text) { $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text); } } - return $text; + return $text; } ?> diff --git a/filter/algebra/pix.php b/filter/algebra/pix.php index ee5eb9456a..5d51d76974 100644 --- a/filter/algebra/pix.php +++ b/filter/algebra/pix.php @@ -20,11 +20,7 @@ disable_debugging(); require_once($CFG->libdir.'/filelib.php'); - - $CFG->texfilterdir = 'filter/tex'; - $CFG->algebrafilterdir = 'filter/algebra'; - $CFG->algebraimagedir = 'filter/algebra'; - + require_once($CFG->dirroot.'/filter/tex/lib.php'); $cmd = ''; // Initialise these variables $status = ''; @@ -37,7 +33,7 @@ if (count($args) == 1) { $image = $args[0]; - $pathname = $CFG->dataroot.'/'.$CFG->algebraimagedir.'/'.$image; + $pathname = $CFG->dataroot.'/filter/algebra/'.$image; } else { error('No valid arguments supplied'); } @@ -45,8 +41,8 @@ if (!file_exists($pathname)) { $md5 = str_replace('.gif','',$image); if ($texcache = get_record('cache_filters', 'filter', 'algebra', 'md5key', $md5)) { - if (!file_exists($CFG->dataroot.'/'.$CFG->algebraimagedir)) { - make_upload_directory($CFG->algebraimagedir); + if (!file_exists($CFG->dataroot.'/filter/algebra')) { + make_upload_directory('filter/algebra'); } $texexp = $texcache->rawtext; @@ -54,42 +50,7 @@ $texexp = str_replace('>','>',$texexp); $texexp = preg_replace('!\r\n?!',' ',$texexp); $texexp = '\Large ' . $texexp; - $texexp = escapeshellarg($texexp); - - if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) { - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$cmd); - $cmd .= " ++ -e \"$pathname\" -- $texexp"; - } else if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary - - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname -- $texexp"; - - } else { /// Auto-detect the right TeX binary - switch (PHP_OS) { - - case "Linux": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" -- $texexp"; - break; - - case "Darwin": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" -- $texexp"; - break; - - default: /// Nothing was found, so tell them how to fix it. - if (debugging()) { - echo "Make sure you have an appropriate MimeTeX binary here:\n\n"; - echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n"; - echo "and that it has the right permissions set on it as executable program.\n\n"; - echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n"; - echo " http://moodle.org/download/mimetex/"; - } else { - echo "Mimetex executable was not found,\n"; - echo "Please turn on debug mode in site configuration to see more info here."; - } - die; - break; - } - } + $cmd = tex_filter_get_cmd($pathname, $texexp); system($cmd, $status); } } @@ -100,10 +61,10 @@ if (debugging()) { echo "The shell command
    $cmd
    returned status = $status
    \n"; echo "Image not found!
    "; - echo "Please try the wwwroot/$CFG->algebrafilterdir/algebradebug.php\">debugging script"; + echo "Please try the wwwroot/filter/algebra/algebradebug.php\">debugging script"; } else { echo "Image not found!
    "; - echo "Please try the wwwroot/$CFG->algebrafilterdir/algebradebug.php\">debugging script
    "; + echo "Please try the wwwroot/filter/algebra/algebradebug.php\">debugging script
    "; echo "Please turn on debug mode in site configuration to see more info here."; } } diff --git a/filter/censor/filterconfig.html b/filter/censor/filterconfig.html deleted file mode 100644 index df551f5651..0000000000 --- a/filter/censor/filterconfig.html +++ /dev/null @@ -1,28 +0,0 @@ -filter_censor_badwords) or $forcereset) { - set_config( 'filter_censor_badwords','' ); - } - - // get strings to use - $txt = new Object; - $txt->badwordslist = get_string( 'badwordslist','admin' ); - $txt->badwordsconfig = get_string( 'badwordsconfig','admin' ); - $txt->badwordsdefault = get_string( 'badwordsdefault','admin' ); -?> - - - - - - - - - - -
    badwordslist; ?>
     badwordsconfig; ?>
    - badwordsdefault; ?>
    diff --git a/filter/censor/filtersettings.php b/filter/censor/filtersettings.php new file mode 100644 index 0000000000..6effb9c30e --- /dev/null +++ b/filter/censor/filtersettings.php @@ -0,0 +1,6 @@ +add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'), + get_string('badwordsconfig', 'admin').'
    '.get_string('badwordsdefault', 'admin'), '')); + +?> diff --git a/filter/mediaplugin/defaultsettings.php b/filter/mediaplugin/defaultsettings.php deleted file mode 100644 index 4f4d4db4b2..0000000000 --- a/filter/mediaplugin/defaultsettings.php +++ /dev/null @@ -1,99 +0,0 @@ -filter_mediaplugin_enable_mp3) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_mp3)) { - set_config( 'filter_mediaplugin_enable_mp3', !$CFG->filter_mediaplugin_ignore_mp3 ); - set_config( 'filter_mediaplugin_ignore_mp3', '' ); - } - else { - set_config( 'filter_mediaplugin_enable_mp3', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_swf) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_swf)) { - set_config( 'filter_mediaplugin_enable_swf', !$CFG->filter_mediaplugin_ignore_swf ); - set_config( 'filter_mediaplugin_ignore_swf','' ); - } - else { - set_config( 'filter_mediaplugin_enable_swf', 0 ); //disable swf embedding by default for now - } - } - if (!isset($CFG->filter_mediaplugin_enable_mov) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_mov)) { - set_config( 'filter_mediaplugin_enable_mov', !$CFG->filter_mediaplugin_ignore_mov ); - set_config( 'filter_mediaplugin_ignore_mov', '' ); - } - else { - set_config( 'filter_mediaplugin_enable_mov', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_mpg) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_mpg)) { - set_config( 'filter_mediaplugin_enable_mpg', !$CFG->filter_mediaplugin_ignore_mpg ); - set_config( 'filter_mediaplugin_ignore_mpg', '' ); - } - else { - set_config( 'filter_mediaplugin_enable_mpg', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_wmv) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_wmv)) { - set_config( 'filter_mediaplugin_enable_wmv', !$CFG->filter_mediaplugin_ignore_wmv ); - set_config( 'filter_mediaplugin_ignore_wmv', '' ); - } - else { - set_config( 'filter_mediaplugin_enable_wmv', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_avi) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_avi)) { - set_config( 'filter_mediaplugin_enable_avi', !$CFG->filter_mediaplugin_ignore_avi ); - set_config( 'filter_mediaplugin_ignore_avi', '' ); - } - else { - set_config( 'filter_mediaplugin_enable_avi', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_flv) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_flv)) { - set_config( 'filter_mediaplugin_enable_flv', !$CFG->filter_mediaplugin_ignore_flv ); - set_config( 'filter_mediaplugin_ignore_flv','' ); - } - else { - set_config( 'filter_mediaplugin_enable_flv', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_ram) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_ram)) { - set_config( 'filter_mediaplugin_enable_ram', !$CFG->filter_mediaplugin_ignore_ram ); - set_config( 'filter_mediaplugin_ignore_ram','' ); - } - else { - set_config( 'filter_mediaplugin_enable_ram', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_rpm) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_rpm)) { - set_config( 'filter_mediaplugin_enable_rpm', !$CFG->filter_mediaplugin_ignore_rpm ); - set_config( 'filter_mediaplugin_ignore_rpm','' ); - } - else { - set_config( 'filter_mediaplugin_enable_rpm', 1 ); - } - } - if (!isset($CFG->filter_mediaplugin_enable_rm) or $forcereset) { - if (isset($CFG->filter_mediaplugin_ignore_rm)) { - set_config( 'filter_mediaplugin_enable_rm', !$CFG->filter_mediaplugin_ignore_rm ); - set_config( 'filter_mediaplugin_ignore_rm','' ); - } - else { - set_config( 'filter_mediaplugin_enable_rm', 1 ); - } - } -?> diff --git a/filter/mediaplugin/filter.php b/filter/mediaplugin/filter.php index e5f9117db5..ac747f9031 100644 --- a/filter/mediaplugin/filter.php +++ b/filter/mediaplugin/filter.php @@ -22,8 +22,6 @@ function mediaplugin_filter($courseid, $text) { global $CFG; static $eolas_fix_applied = false; - include 'defaultsettings.php'; - // You should never modify parameters passed to a method or function, it's BAD practice. Create a copy instead. // The reason is that you must always be able to refer to the original parameter that was passed. // For this reason, I changed $text = preg_replace(..,..,$text) into $newtext = preg.... (NICOLAS CONNAULT) diff --git a/filter/mediaplugin/filterconfig.html b/filter/mediaplugin/filterconfig.html deleted file mode 100644 index 3b3d938734..0000000000 --- a/filter/mediaplugin/filterconfig.html +++ /dev/null @@ -1,84 +0,0 @@ -mediapluginmp3 = get_string( 'mediapluginmp3','admin' ); - $txt->mediapluginswf = get_string( 'mediapluginswf','admin' ); - $txt->mediapluginswfnote = get_string( 'mediapluginswfnote','admin' ); - $txt->mediapluginmov = get_string( 'mediapluginmov','admin' ); - $txt->mediapluginwmv = get_string( 'mediapluginwmv','admin' ); - $txt->mediapluginmpg = get_string( 'mediapluginmpg','admin' ); - $txt->mediapluginavi = get_string( 'mediapluginavi','admin' ); - $txt->mediapluginflv = get_string( 'mediapluginflv','admin' ); - $txt->mediapluginram = get_string( 'mediapluginram','admin' ); - $txt->mediapluginrpm = get_string( 'mediapluginrpm','admin' ); - $txt->mediapluginrm = get_string( 'mediapluginrm','admin' ); - $txt->yes = get_string( 'yes' ); - $txt->no = get_string( 'no' ); - - $yesno = array( $txt->no, $txt->yes ); -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    mediapluginmp3 ?>filter_mediaplugin_enable_mp3 ); ?> -
    mediapluginswf?>filter_mediaplugin_enable_swf ); ?>mediapluginswfnote ?>
    mediapluginmov ?>filter_mediaplugin_enable_mov ); ?> -
    mediapluginwmv ?>filter_mediaplugin_enable_wmv ); ?> -
    mediapluginmpg ?>filter_mediaplugin_enable_mpg ); ?> -
    mediapluginavi ?>filter_mediaplugin_enable_avi ); ?> -
    mediapluginflv ?>filter_mediaplugin_enable_flv ); ?> -
    mediapluginram ?>filter_mediaplugin_enable_ram ); ?> -
    mediapluginrpm ?>filter_mediaplugin_enable_rpm ); ?>
    mediapluginrm ?>filter_mediaplugin_enable_rm ); ?> -
    diff --git a/filter/mediaplugin/filtersettings.php b/filter/mediaplugin/filtersettings.php new file mode 100644 index 0000000000..40d5fb07fb --- /dev/null +++ b/filter/mediaplugin/filtersettings.php @@ -0,0 +1,23 @@ +add(new admin_setting_configcheckbox('filter_mediaplugin_enable_mp3', get_string('mediapluginmp3','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_swf', get_string('mediapluginswf','admin'), get_string('mediapluginswfnote','admin'), 0)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_mov', get_string('mediapluginmov','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_wmv', get_string('mediapluginwmv','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_mpg', get_string('mediapluginmpg','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_avi', get_string('mediapluginavi','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_flv', get_string('mediapluginflv','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_ram', get_string('mediapluginram','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_rpm', get_string('mediapluginrpm','admin'), '', 1)); + +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_rm', get_string('mediapluginrm','admin'), '', 1)); + +?> diff --git a/filter/multilang/defaultsettings.php b/filter/multilang/defaultsettings.php deleted file mode 100644 index ae57b75cd0..0000000000 --- a/filter/multilang/defaultsettings.php +++ /dev/null @@ -1,14 +0,0 @@ -filter_multilang_force_old) or $forcereset) { - set_config('filter_multilang_force_old', 0); - } - -?> diff --git a/filter/multilang/filterconfig.html b/filter/multilang/filterconfig.html deleted file mode 100644 index 009ceb800a..0000000000 --- a/filter/multilang/filterconfig.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - -
    filter_multilang_force_old, ''); ?> -
    diff --git a/filter/multilang/filtersettings.php b/filter/multilang/filtersettings.php new file mode 100644 index 0000000000..895aa0ee91 --- /dev/null +++ b/filter/multilang/filtersettings.php @@ -0,0 +1,6 @@ +add(new admin_setting_configcheckbox('filter_multilang_force_old', 'filter_multilang_force_old', + get_string('multilangforceold', 'admin'), 0)); + +?> diff --git a/filter/tex/defaultsettings.php b/filter/tex/defaultsettings.php deleted file mode 100644 index 277fa717b4..0000000000 --- a/filter/tex/defaultsettings.php +++ /dev/null @@ -1,53 +0,0 @@ -filter_tex_latexpreamble) or $force) { - set_config( 'filter_tex_latexpreamble', " \\usepackage[latin1]{inputenc}\n \\usepackage{amsmath}\n \\usepackage{amsfonts}\n \\RequirePackage{amsmath,amssymb,latexsym}\n"); - } - - if (!isset($CFG->filter_tex_latexbackground) or $force) { - set_config( 'filter_tex_latexbackground', '#FFFFFF' ); - } - - if (!isset($CFG->filter_tex_density) or $force) { - set_config( 'filter_tex_density', '120' ); - } - - // defaults for paths - if one not set assume all not set - if (!isset($CFG->filter_tex_pathlatex) or $force) { - // load the paths for the appropriate OS - // it would be nice to expand this - if (PHP_OS=='Linux') { - $binpath = '/usr/bin/'; - set_config( 'filter_tex_pathlatex',"{$binpath}latex" ); - set_config( 'filter_tex_pathdvips',"{$binpath}dvips" ); - set_config( 'filter_tex_pathconvert',"{$binpath}convert" ); - } - elseif (PHP_OS=='Darwin') { - $binpath = '/sw/bin/'; // most likely needs a fink install (fink.sf.net) - set_config( 'filter_tex_pathlatex',"{$binpath}latex" ); - set_config( 'filter_tex_pathdvips',"{$binpath}dvips" ); - set_config( 'filter_tex_pathconvert',"{$binpath}convert" ); - } - elseif (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') { - // note: you need Ghostscript installed (standard), miktex (standard) - // and ImageMagick (install at c:\ImageMagick) - set_config( 'filter_tex_pathlatex',"\"c:\\texmf\\miktex\\bin\\latex.exe\" " ); - set_config( 'filter_tex_pathdvips',"\"c:\\texmf\\miktex\\bin\\dvips.exe\" " ); - set_config( 'filter_tex_pathconvert',"\"c:\\imagemagick\\convert.exe\" " ); - } - else { - set_config( 'filter_tex_pathlatex','' ); - set_config( 'filter_tex_pathdvips','' ); - set_config( 'filter_tex_pathconvert','' ); - } - } - - } -?> diff --git a/filter/tex/displaytex.php b/filter/tex/displaytex.php index 4200aa87dc..d352f853aa 100644 --- a/filter/tex/displaytex.php +++ b/filter/tex/displaytex.php @@ -2,7 +2,6 @@ // This script displays tex source code. require_once('../../config.php'); - require_once($CFG->libdir.'/moodlelib.php'); $texexp = urldecode($_SERVER['QUERY_STRING']); // entities are usually encoded twice, first in HTML editor then in tex/filter.php diff --git a/filter/tex/filter.php b/filter/tex/filter.php index 08857337ef..850ccfc1b4 100644 --- a/filter/tex/filter.php +++ b/filter/tex/filter.php @@ -24,8 +24,8 @@ // NOTE: This Moodle text filter converts TeX expressions delimited // by either $$...$$ or by ... tags to gif images using // mimetex.cgi obtained from http://www.forkosh.com/mimetex.html authored by -// John Forkosh john@forkosh.com. Several binaries of this areincluded with -// this distribution. +// John Forkosh john@forkosh.com. Several binaries of this areincluded with +// this distribution. // Note that there may be patent restrictions on the production of gif images // in Canada and some parts of Western Europe and Japan until July 2004. //------------------------------------------------------------------------- @@ -36,8 +36,6 @@ // filter/tex/filter.php // ///////////////////////////////////////////////////////////////////////////// -$CFG->texfilterdir = "filter/tex"; - function string_file_picture_tex($imagefile, $tex= "", $height="", $width="", $align="middle", $alt='') { if($alt==='') { $alt=s($tex); @@ -70,20 +68,20 @@ function string_file_picture_tex($imagefile, $tex= "", $height="", $width="", $a } $style .= '"'; if ($imagefile) { - if (!file_exists("$CFG->dataroot/$CFG->texfilterdir/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - $output .= "wwwroot/$CFG->texfilterdir/texdebug.php\">"; + if (!file_exists("$CFG->dataroot/filter/tex/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + $output .= "wwwroot/filter/tex/texdebug.php\">"; } else { $output .= "wwwroot/$CFG->texfilterdir/displaytex.php?"; - $output .= urlencode($tex) . "\" onclick=\"return openpopup('/$CFG->texfilterdir/displaytex.php?"; + $output .= "\"$CFG->wwwroot/filter/tex/displaytex.php?"; + $output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/tex/displaytex.php?"; $output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,"; $output .= "resizable,width=300,height=240', 0);\">"; } $output .= "\"$alt\"slasharguments) { // Use this method if possible for better caching - $output .= "$CFG->wwwroot/$CFG->texfilterdir/pix.php/$imagefile"; + $output .= "$CFG->wwwroot/filter/tex/pix.php/$imagefile"; } else { - $output .= "$CFG->wwwroot/$CFG->texfilterdir/pix.php?file=$imagefile"; + $output .= "$CFG->wwwroot/filter/tex/pix.php?file=$imagefile"; } $output .= "\" $style />"; $output .= ""; @@ -159,8 +157,7 @@ function tex_filter ($courseid, $text) { $filename = $md5 . ".gif"; $text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp, '', '', $align, $alt), $text); } - return $text; + return $text; } - ?> diff --git a/filter/tex/filterconfig.html b/filter/tex/filterconfig.html deleted file mode 100644 index 36bedf6465..0000000000 --- a/filter/tex/filterconfig.html +++ /dev/null @@ -1,80 +0,0 @@ -dataroot/filter/tex" )) { - remove_dir( "$CFG->dataroot/filter/tex", true ); - } - - // get strings - $txt = new Object; - $txt->latexsettings = get_string( 'latexsettings','admin' ); - $txt->latexpreamble = get_string( 'latexpreamble','admin' ); - $txt->backgroundcolour = get_string( 'backgroundcolour','admin' ); - $txt->density = get_string( 'density','admin' ); - $txt->pathlatex = get_string( 'pathlatex','admin' ); - $txt->pathdvips = get_string( 'pathdvips','admin' ); - $txt->pathconvert = get_string( 'pathconvert','admin' ); - $txt->tick = '✔'; - $txt->cross = '✘'; - - // check file exists & display tick or cross - function texbinaryconfirm( $path ) { - global $txt; - if (is_file($path)) { - echo "$txt->tick"; - } - else { - echo "$txt->cross"; - } - } -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    latexsettings; ?> 
    latexpreamble; ?>
    backgroundcolour; ?>
    density; ?>
    pathlatex; ?> - filter_tex_pathlatex ); ?> -
    pathdvips; ?> - filter_tex_pathdvips ); ?> -
    pathconvert; ?> - filter_tex_pathconvert ); ?> -
    diff --git a/filter/tex/filtersettings.php b/filter/tex/filtersettings.php new file mode 100644 index 0000000000..111e531322 --- /dev/null +++ b/filter/tex/filtersettings.php @@ -0,0 +1,45 @@ +dirroot.'/filter/tex/lib.php'); + +$items = array(); +$items[] = new admin_setting_heading('filter_tex_latexheading', get_string('latexsettings', 'admin'), ''); +$items[] = new admin_setting_configtextarea('filter_tex_latexpreamble', get_string('latexpreamble','admin'), + '', " \\usepackage[latin1]{inputenc}\n \\usepackage{amsmath}\n \\usepackage{amsfonts}\n \\RequirePackage{amsmath,amssymb,latexsym}\n"); +$items[] = new admin_setting_configtext('filter_tex_latexbackground', get_string('backgroundcolour', 'admin'), '', '#FFFFFF'); +$items[] = new admin_setting_configtext('filter_tex_density', get_string('density', 'admin'), '', '120', PARAM_INT); +$items[] = new admin_setting_configtext('filter_tex_density', get_string('density', 'admin'), '', '120', PARAM_INT); + +if (PHP_OS=='Linux') { + $default_filter_tex_pathlatex = "/usr/bin/latex"; + $default_filter_tex_pathdvips = "/usr/bin/dvips"; + $default_filter_tex_pathconvert = "/usr/bin/convert"; + +} else if (PHP_OS=='Darwin') { + // most likely needs a fink install (fink.sf.net) + $default_filter_tex_pathlatex = "/sw/bin/latex"; + $default_filter_tex_pathdvips = "/sw/bin/dvips"; + $default_filter_tex_pathconvert = "/sw/bin/convert"; + +} else if (PHP_OS=='WINNT' or PHP_OS=='WIN32' or PHP_OS=='Windows') { + // note: you need Ghostscript installed (standard), miktex (standard) + // and ImageMagick (install at c:\ImageMagick) + $default_filter_tex_pathlatex = "\"c:\\texmf\\miktex\\bin\\latex.exe\" "; + $default_filter_tex_pathdvips = "\"c:\\texmf\\miktex\\bin\\dvips.exe\" "; + $default_filter_tex_pathconvert = "\"c:\\imagemagick\\convert.exe\" "; + +} else { + $default_filter_tex_pathlatex = ''; + $default_filter_tex_pathdvips = ''; + $default_filter_tex_pathconvert = ''; +} + +$items[] = new admin_setting_configexecutable('filter_tex_pathlatex', get_string('pathlatex', 'admin'), '', $default_filter_tex_pathlatex); +$items[] = new admin_setting_configexecutable('filter_tex_pathdvips', get_string('pathdvips', 'admin'), '', $default_filter_tex_pathdvips); +$items[] = new admin_setting_configexecutable('filter_tex_pathconvert', get_string('pathconvert', 'admin'), '', $default_filter_tex_pathconvert); + +foreach ($items as $item) { + $item->set_updatedcallback('filter_tex_updatedcallback'); + $settings->add($item); +} +?> diff --git a/filter/tex/lib.php b/filter/tex/lib.php new file mode 100644 index 0000000000..9fbcf7e60c --- /dev/null +++ b/filter/tex/lib.php @@ -0,0 +1,70 @@ +" + ."executable for you ".PHP_OS." platform from " + ."http://moodle.org/download/mimetex/, or obtain the C source
    " + ."from " + ."http://www.forkosh.com/mimetex.zip, compile it and " + ."put the executable into your
    moodle/filter/tex/ directory."; + + $error_message2 = "Custom mimetex is not executable!

    "; + + if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) { + return "$CFG->dirroot/filter/tex/mimetex.exe"; + } + + $custom_commandpath = "$CFG->dirroot/filter/tex/mimetex"; + if (file_exists($custom_commandpath)) { + if (is_executable($custom_commandpath)) { + return $custom_commandpath; + } else { + error($error_message2.$error_message1); + } + } + + switch (PHP_OS) { + case "Linux": return "$CFG->dirroot/filter/tex/mimetex.linux"; + case "Darwin": return "$CFG->dirroot/filter/tex/mimetex.darwin"; + case "FreeBSD": return "$CFG->dirroot/filter/tex/mimetex.freebsd"; + } + + error($error_message1); +} + + +function tex_filter_get_cmd($pathname, $texexp) { + $texexp = escapeshellarg($texexp); + $executable = tex_filter_get_executable(false); + + if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) { + $cmd = str_replace(' ', '^ ', $executable); + return " ++ -e \"$pathname\" -- $texexp"; + + } else { + return "\"$executable\" -e \"$pathname\" -- $texexp"; + } +} + +/** + * Purge all caches when settings changed. + */ +function filter_tex_updatedcallback($name) { + global $CFG; + if (file_exists("$CFG->dataroot/filter/tex")) { + remove_dir("$CFG->dataroot/filter/tex"); + } + if (file_exists("$CFG->dataroot/filter/algebra")) { + remove_dir("$CFG->dataroot/filter/algebra"); + } + if (file_exists("$CFG->dataroot/temp/latex")) { + remove_dir("$CFG->dataroot/temp/latex"); + } + + delete_records('cache_filters', 'filter', 'tex'); + delete_records('cache_filters', 'filter', 'algebra'); +} + +?> diff --git a/filter/tex/pix.php b/filter/tex/pix.php index 64bb46c2e3..457703e54f 100644 --- a/filter/tex/pix.php +++ b/filter/tex/pix.php @@ -20,14 +20,8 @@ disable_debugging(); require_once($CFG->libdir.'/filelib.php'); - require_once('defaultsettings.php' ); - require_once('latex.php'); - - $CFG->texfilterdir = 'filter/tex'; - $CFG->teximagedir = 'filter/tex'; - - // check/initialise default configuration for filter (in defaultsettings.php) - tex_defaultsettings(); + require_once($CFG->dirroot.'/filter/tex/lib.php'); + require_once($CFG->dirroot.'/filter/tex/latex.php'); $cmd = ''; // Initialise these variables $status = ''; @@ -40,7 +34,7 @@ if (count($args) == 1) { $image = $args[0]; - $pathname = $CFG->dataroot.'/'.$CFG->teximagedir.'/'.$image; + $pathname = $CFG->dataroot.'/filter/tex/'.$image; } else { error('No valid arguments supplied'); } @@ -48,67 +42,28 @@ if (!file_exists($pathname)) { $md5 = str_replace('.gif','',$image); if ($texcache = get_record('cache_filters', 'filter', 'tex', 'md5key', $md5)) { - if (!file_exists($CFG->dataroot.'/'.$CFG->teximagedir)) { - make_upload_directory($CFG->teximagedir); + if (!file_exists($CFG->dataroot.'/filter/tex')) { + make_upload_directory('filter/tex'); } // try and render with latex first $latex = new latex(); $density = $CFG->filter_tex_density; $background = $CFG->filter_tex_latexbackground; - $texexp = html_entity_decode( $texcache->rawtext ); - $latex_path = $latex->render( $texexp, $md5, 12, $density, $background ); - if ($latex_path) { - copy( $latex_path, $pathname ); - $latex->clean_up( $md5 ); - } - else { + $texexp = html_entity_decode($texcache->rawtext); + $latex_path = $latex->render($texexp, $md5, 12, $density, $background); + if ($latex_path) { + copy($latex_path, $pathname); + $latex->clean_up($md5); + + } else { // failing that, use mimetex $texexp = $texcache->rawtext; - $texexp = str_replace('<','<',$texexp); - $texexp = str_replace('>','>',$texexp); - $texexp = preg_replace('!\r\n?!',' ',$texexp); - $texexp = '\Large ' . $texexp; - $texexp = escapeshellarg($texexp); - - if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) { - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$cmd); - $cmd .= " ++ -e \"$pathname\" -- $texexp"; - } else if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary - - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname -- $texexp"; - - } else { /// Auto-detect the right TeX binary - switch (PHP_OS) { - - case "Linux": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" -- $texexp"; - break; - - case "Darwin": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" -- $texexp"; - break; - - case "FreeBSD": - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.freebsd\" -e \"$pathname\" $texexp"; - break; - - default: /// Nothing was found, so tell them how to fix it. - if (debugging()) { - echo "Make sure you have an appropriate MimeTeX binary here:\n\n"; - echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n"; - echo "and that it has the right permissions set on it as executable program.\n\n"; - echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n"; - echo " http://moodle.org/download/mimetex/"; - } else { - echo "Mimetex executable was not found,\n"; - echo "Please turn on debug mode in site configuration to see more info here."; - } - die; - break; - } - } + $texexp = str_replace('<', '<', $texexp); + $texexp = str_replace('>', '>', $texexp); + $texexp = preg_replace('!\r\n?!', ' ', $texexp); + $texexp = '\Large '.$texexp; + $cmd = tex_filter_get_cmd($pathname, $texexp); system($cmd, $status); } } @@ -120,10 +75,10 @@ if (debugging()) { echo "The shell command
    $cmd
    returned status = $status
    \n"; echo "Image not found!
    "; - echo "Please try the wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script"; + echo "Please try the wwwroot/filter/tex/texdebug.php\">debugging script"; } else { echo "Image not found!
    "; - echo "Please try the wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script
    "; + echo "Please try the wwwroot/filter/tex/texdebug.php\">debugging script
    "; echo "Please turn on debug mode in site configuration to see more info here."; } } diff --git a/filter/tex/texdebug.php b/filter/tex/texdebug.php index ce54e08b29..b4426df9fe 100644 --- a/filter/tex/texdebug.php +++ b/filter/tex/texdebug.php @@ -6,7 +6,6 @@ $nomoodlecookie = true; // Because it interferes with caching require_once("../../config.php"); - require( 'latex.php' ); if (empty($CFG->textfilters)) { error ('Filter not enabled!'); @@ -17,27 +16,27 @@ } } - $CFG->texfilterdir = "filter/tex"; - $CFG->teximagedir = "filter/tex"; - - $param = null; - $param->action = optional_param( 'action','',PARAM_ALPHA ); - $param->tex = optional_param( 'tex','' ); + require_once($CFG->libdir.'/filelib.php'); + require_once($CFG->dirroot.'/filter/tex/lib.php'); + require_once($CFG->dirroot.'/filter/tex/latex.php'); + + $action = optional_param('action', '', PARAM_ALPHA); + $texexp = optional_param('tex', '', PARAM_RAW); $query = urldecode($_SERVER['QUERY_STRING']); error_reporting(E_ALL); $output = ''; // look up in cache if required - if ($param->action=='ShowDB' or $param->action=='DeleteDB') { - $md5 = md5($param->tex); + if ($action=='ShowDB' or $action=='DeleteDB') { + $md5 = md5($texexp); $texcache = get_record("cache_filters","filter","tex", "md5key", $md5); } // Action: Show DB Entry - if ($param->action=='ShowDB') { + if ($action=='ShowDB') { if ($texcache) { - $output = "DB cache_filters entry for $param->tex\n"; + $output = "DB cache_filters entry for $texexp\n"; $output .= "id = $texcache->id\n"; $output .= "filter = $texcache->filter\n"; $output .= "version = $texcache->version\n"; @@ -45,14 +44,14 @@ $output .= "rawtext = $texcache->rawtext\n"; $output .= "timemodified = $texcache->timemodified\n"; } else { - $output = "DB cache_filters entry for $param->tex not found\n"; + $output = "DB cache_filters entry for $texexp not found\n"; } } // Action: Delete DB Entry - if ($param->action=='DeleteDB') { + if ($action=='DeleteDB') { if ($texcache) { - $output = "Deleting DB cache_filters entry for $param->tex\n"; + $output = "Deleting DB cache_filters entry for $texexp\n"; $result = delete_records("cache_filters","id",$texcache->id); if ($result) { $result = 1; @@ -61,38 +60,38 @@ } $output .= "Number of records deleted = $result\n"; } else { - $output = "Could not delete DB cache_filters entry for $param->tex\nbecause it could not be found.\n"; + $output = "Could not delete DB cache_filters entry for $texexp\nbecause it could not be found.\n"; } } // Action: Show Image - if ($param->action=='ShowImageMimetex') { - tex2image($param->tex); + if ($action=='ShowImageMimetex') { + tex2image($texexp); } // Action: Check Slasharguments - if ($param->action=='SlashArguments') { - slasharguments($param->tex); + if ($action=='SlashArguments') { + slasharguments($texexp); } // Action: Show Tex command line output - if ($param->action=='ShowImageTex') { - TexOutput($param->tex, true); + if ($action=='ShowImageTex') { + TexOutput($texexp, true); exit; } // Action: Show Tex command line output - if ($param->action=='ShowOutputTex') { - TexOutput($param->tex); + if ($action=='ShowOutputTex') { + TexOutput($texexp); exit; } - if (!empty($param->action)) { + if (!empty($action)) { outputText($output); } // nothing more to do if there was any action - if (!empty($param->action)) { + if (!empty($action)) { exit; } @@ -101,9 +100,9 @@ header("Content-type: text/html"); echo "
    \n";
             if ($texexp) {
    -            $texexp = str_replace('<','<',$texexp);
    -            $texexp = str_replace('>','>',$texexp);
    -            $texexp = str_replace('"','"',$texexp);
    +            $texexp = str_replace('<', '<', $texexp);
    +            $texexp = str_replace('>', '>', $texexp);
    +            $texexp = str_replace('"', '"', $texexp);
                 echo "$texexp\n\n";
             } else {
                 echo "No text output available\n\n";
    @@ -113,74 +112,34 @@
     
         function tex2image($texexp, $return=false) {
             global $CFG;
    -        $error_message1 = "Your system is not configured to run mimeTeX. ";
    -        $error_message1 .= "You need to download the appropriate
    executable "; - $error_message1 .= "from "; - $error_message1 .= "http://moodle.org/download/mimetex/, or obtain the "; - $error_message1 .= "C source
    from "; - $error_message1 .= "http://www.forkosh.com/mimetex.zip, compile it and "; - $error_message1 .= "put the executable into your
    moodle/filter/tex/ directory. "; - $error_message1 .= "You also need to edit your moodle/filter/tex/pix.php file
    "; - $error_message1 .= ' by adding the line
           case "' . PHP_OS . "\":\n";
    -        $error_message1 .= "           \$cmd = \"\\\\\"\$CFG->dirroot/\$CFG->texfilterdir/";
    -        $error_message1 .= 'mimetex.' . strtolower(PHP_OS) . "\\\\\" -e \\\\\"\$pathname\\\\\" \". escapeshellarg(\$texexp);";
    -        $error_message1 .= "
    You also need to add this to your texdebug.php file."; - if ($texexp) { - $texexp = '\Large ' . $texexp; - $lifetime = 86400; - $image = md5($texexp) . ".gif"; - $filetype = 'image/gif'; - if (!file_exists("$CFG->dataroot/$CFG->teximagedir")) { - make_upload_directory($CFG->teximagedir); - } - $pathname = "$CFG->dataroot/$CFG->teximagedir/$image"; - if (file_exists($pathname)) { - unlink($pathname); - } - $commandpath = ""; - $cmd = ""; - $texexp = escapeshellarg($texexp); - switch (PHP_OS) { - case "Linux": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.linux"; - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" $texexp"; - break; - case "WINNT": - case "WIN32": - case "Windows": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $cmd = str_replace(' ','^ ',$commandpath); - $cmd .= " ++ -e \"$pathname\" $texexp"; - break; - case "Darwin": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin"; - $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" $texexp"; - break; - } - if (!$cmd) { - if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex"; - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname $texexp"; - } else { - error($error_message1); - } - } - system($cmd, $status); + if (!$texexp) { + echo 'No tex expresion specified'; + return; } + + $image = md5($texexp) . ".gif"; + $filetype = 'image/gif'; + if (!file_exists("$CFG->dataroot/filter/tex")) { + make_upload_directory("filter/tex"); + } + $pathname = "$CFG->dataroot/filter/tex/$image"; + if (file_exists($pathname)) { + unlink($pathname); + } + + $texexp = '\Large '.$texexp; + $commandpath = tex_filter_get_executable(true); + $cmd = tex_filter_get_cmd($pathname, $texexp); + system($cmd, $status); + if ($return) { return $image; } - if ($texexp && file_exists($pathname)) { - $lastmodified = filemtime($pathname); - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); - header("Cache-control: max_age = $lifetime"); // a day - header("Pragma: "); - header("Content-disposition: inline; filename=$image"); - header("Content-length: ".filesize($pathname)); - header("Content-type: $filetype"); - readfile("$pathname"); + + if (file_exists($pathname)) { + send_file($pathname, $image); + } else { $ecmd = "$cmd 2>&1"; echo `$ecmd` . "
    \n"; @@ -212,7 +171,7 @@ // test Tex/Ghostscript output - command execution only - function TexOutput( $expression, $graphic=false ) { + function TexOutput($expression, $graphic=false) { global $CFG; $output = ''; @@ -243,10 +202,10 @@ $output .= "Error: convert executable ($CFG->filter_tex_pathconvert) is not readable
    \n"; } - // knowing that it might work.. - $md5 = md5( $expression ); + // knowing that it might work.. + $md5 = md5($expression); $output .= "

    base filename for expression is '$md5'

    \n"; - + // temporary paths $tex = "$latex->temp_dir/$md5.tex"; $dvi = "$latex->temp_dir/$md5.dvi"; @@ -254,51 +213,40 @@ $gif = "$latex->temp_dir/$md5.gif"; // put the expression as a file into the temp area - $expression = stripslashes( $expression ); - $expression = html_entity_decode( $expression ); + $expression = stripslashes($expression); + $expression = html_entity_decode($expression); $output .= "

    Processing TeX expression:

    $expression
    \n"; - $doc = $latex->construct_latex_document( $expression ); - $fh = fopen( $tex, 'w' ); - fputs( $fh, $doc ); - fclose( $fh ); + $doc = $latex->construct_latex_document($expression); + $fh = fopen($tex, 'w'); + fputs($fh, $doc); + fclose($fh); // cd to temp dir - chdir( $latex->temp_dir ); + chdir($latex->temp_dir); // step 1: latex command $cmd = "$CFG->filter_tex_pathlatex --interaction=nonstopmode $tex"; - $output .= execute( $cmd ); + $output .= execute($cmd); // step 2: dvips command $cmd = "$CFG->filter_tex_pathdvips -E $dvi -o $ps"; - $output .= execute( $cmd ); + $output .= execute($cmd); // step 3: convert command $cmd = "$CFG->filter_tex_pathconvert -density 240 -trim $ps $gif "; - $output .= execute( $cmd ); + $output .= execute($cmd); if (!$graphic) { - echo( $output ); + echo($output); } else { - $lastmodified = filemtime($gif); - $lifetime = 86400; - $filetype = 'image/gif'; - $image = "$md5.gif"; - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); - header("Cache-control: max_age = $lifetime"); // a day - header("Pragma: "); - header("Content-disposition: inline; filename=$image"); - header("Content-length: ".filesize($gif)); - header("Content-type: $filetype"); - readfile("$gif"); + send_file($gif, "$md5.gif"); } } - function execute( $cmd ) { - exec( $cmd, $result, $code ); + function execute($cmd) { + exec($cmd, $result, $code); $output = "
    $ $cmd\n";
    -        $lines = implode( "\n", $result );
    +        $lines = implode("\n", $result);
             $output .= "OUTPUT: $lines\n";
             $output .= "RETURN CODE: $code\n
    \n"; return $output; @@ -306,18 +254,18 @@ function slasharguments($texexp) { global $CFG; - $admin = $CFG->wwwroot . '/' . $CFG->admin . '/config.php'; + $admin = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=http'; $image = tex2image($texexp,true); echo "

    If the following image displays correctly, set your "; - echo "Administration->Configuration->Variables "; + echo "Administration->Server->HTTP "; echo "setting for slasharguments to file.php/1/pic.jpg: "; - echo "

    \n"; + echo "wwwroot/filter/tex/pix.php/$image\" align=\"absmiddle\">

    \n"; echo "

    Otherwise set it to file.php?file=/1/pic.jpg "; echo "It should display correctly as "; - echo "

    \n"; + echo "wwwroot/filter/tex/pix.php?file=$image\" align=\"absmiddle\">

    \n"; echo "

    If neither equation image displays correctly, please seek "; echo "further help at moodle.org at the "; - echo ""; + echo ""; echo "Mathematics Tools Forum

    "; } diff --git a/filter/tex/texed.php b/filter/tex/texed.php index bbb3c0a46f..5ff4c0bd42 100644 --- a/filter/tex/texed.php +++ b/filter/tex/texed.php @@ -6,6 +6,7 @@ $nomoodlecookie = true; // Because it interferes with caching require_once("../../config.php"); + require_once($CFG->dirroot.'/filter/tex/lib.php'); if (empty($CFG->textfilters)) { error ('Filter not enabled!'); @@ -16,51 +17,31 @@ } } - $CFG->texfilterdir = "filter/tex"; - $CFG->teximagedir = "filter/tex"; - error_reporting(E_ALL); $texexp = urldecode($_SERVER['QUERY_STRING']); $texexp = str_replace('formdata=','',$texexp); if ($texexp) { - //$texexp = stripslashes($texexp); - $lifetime = 86400; $image = md5($texexp) . ".gif"; $filetype = 'image/gif'; - if (!file_exists("$CFG->dataroot/$CFG->teximagedir")) { - make_upload_directory($CFG->teximagedir); + if (!file_exists("$CFG->dataroot/filter/tex")) { + make_upload_directory("filter/tex"); } - $pathname = "$CFG->dataroot/$CFG->teximagedir/$image"; - $texexp = escapeshellarg($texexp); - switch (PHP_OS) { - case "Linux": - system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname -- $texexp" ); - break; - case "WINNT": - case "WIN32": - case "Windows": - system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname -- $texexp"); - break; - case "Darwin": - system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname -- $texexp" ); - break; - } + $texexp = str_replace('<','<',$texexp); + $texexp = str_replace('>','>',$texexp); + $texexp = preg_replace('!\r\n?!',' ',$texexp); + $cmd = tex_filter_get_cmd($pathname, $texexp); + system($cmd, $status); + if (file_exists($pathname)) { - $lastmodified = filemtime($pathname); - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); - header("Cache-control: max_age = $lifetime"); // a day - header("Pragma: "); - header("Content-disposition: inline; filename=$image"); - header("Content-length: ".filesize($pathname)); - header("Content-type: $filetype"); - readfile("$pathname"); + send_file($pathname, $image); } else { echo "Image not found!"; } exit; + } else { + echo "No tex expresion specified"; } ?> @@ -79,7 +60,7 @@


    diff --git a/grade/report/grader/preferences.php b/grade/report/grader/preferences.php index 4402087074..532f151794 100644 --- a/grade/report/grader/preferences.php +++ b/grade/report/grader/preferences.php @@ -84,7 +84,7 @@ include('tabs.php'); // If USER has admin capability, print a link to the site config page for this report if (has_capability('moodle/site:config', $systemcontext)) { - echo ''; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } - } -// this is a liiitle bit messy. we're using two selects, but we're returning them as an array named after $name (so we only use $name2 -// internally for the setting) -class admin_setting_configtime extends admin_setting { +/** + * Multiple checkboxes 2, value stored as string 00101011 + */ +class admin_setting_configmulticheckbox2 extends admin_setting_configmulticheckbox { + function get_setting() { + $result = $this->config_read($this->name); + if (is_null($result)) { + return NULL; + } + if (!$this->load_choices()) { + return NULL; + } + $result = str_pad($result, count($this->choices), '0'); + $result = preg_split('//', $result, -1, PREG_SPLIT_NO_EMPTY); + $setting = array(); + foreach ($this->choices as $key=>$unused) { + $value = array_shift($result); + if ($value) { + $setting[] = $key; + } + } + return $setting; + } - var $name2; + function write_setting($data) { + if (!is_array($data)) { + return ''; // ignore it + } + if (!$this->load_choices() or empty($this->choices)) { + return ''; + } + $result = ''; + foreach ($this->choices as $key=>$unused) { + if (!empty($data[$key])) { + $result .= '1'; + } else { + $result .= '0'; + } + } + return $this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin'); + } +} + +/** + * Select one value from list + */ +class admin_setting_configselect extends admin_setting { var $choices; - var $choices2; - function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) { - $this->name2 = $minutesname; - $this->choices = array(); - for ($i = 0; $i < 24; $i++) { - $this->choices[$i] = $i; - } - $this->choices2 = array(); - for ($i = 0; $i < 60; $i += 5) { - $this->choices2[$i] = $i; + /** + * Constructor + * @param string $name of setting + * @param string $visiblename localised + * @param string $description long localised info + * @param string $defaultsetting + * @param array $choices array of $value=>$label for each selection + */ + function admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices) { + $this->choices = $choices; + parent::admin_setting($name, $visiblename, $description, $defaultsetting); + } + + /** + * This function may be used in ancestors for lazy loading of choices + * @return true if loaded, false if error + */ + function load_choices() { + /* + if (is_array($this->choices)) { + return true; } - parent::admin_setting($hoursname, $visiblename, $description, $defaultsetting); + .... load choices here + */ + return true; } function get_setting() { - global $CFG; - return (isset($CFG->{$this->name}) && isset($CFG->{$this->name2}) ? array('h' => $CFG->{$this->name}, 'm' => $CFG->{$this->name2}) : NULL); + return $this->config_read($this->name); } function write_setting($data) { - // check that what we got was in the original choices - if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; - } + if (!$this->load_choices() or empty($this->choices)) { + return ''; + } + if (!array_key_exists($data, $this->choices)) { + return ''; // ignore it + } - return (set_config($this->name, $data['h']) && set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin')); } - function output_html() { - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; + function output_html($data) { + if (!$this->load_choices() or empty($this->choices)) { + return ''; + } + $default = $this->get_defaultsetting(); + + if (!is_null($default) and array_key_exists($default, $this->choices)) { + $defaultinfo = ''.get_string('defaultsettinginfo', 'admin', s($this->choices[$default])).''; } else { - $currentsetting = $this->get_setting(); + $defaultinfo = ''; } - $return = '
    '. - ''; foreach ($this->choices as $key => $value) { - $return .= ''; - } - $return .= ':
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + $return .= ''.$defaultinfo.'
    '; + + return format_admin_setting($this, $this->visiblename, $return, $this->description); } } +/** + * Select multiple items from list + */ class admin_setting_configmultiselect extends admin_setting_configselect { - + /** + * Constructor + * @param string $name of setting + * @param string $visiblename localised + * @param string $description long localised info + * @param array $defaultsetting array of selected items + * @param array $choices array of $value=>$label for each list item + */ function admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, $choices) { parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices); } function get_setting() { - global $CFG; - if (isset($CFG->{$this->name})) { - if ($CFG->{$this->name}) { - return explode(',', $CFG->{$this->name}); - } else { - return array(); - } - } else { + $result = $this->config_read($this->name); + if (is_null($result)) { return NULL; } + if ($result === '') { + return array(); + } + return explode(',', $result); } function write_setting($data) { - if (empty($data)) { + if (!is_array($data)) { + return ''; //ignore it + } + if (!$this->load_choices() or empty($this->choices)) { + return ''; + } + + $save = array(); + foreach ($data as $value) { + if (!array_key_exists($value, $this->choices)) { + continue; // ignore it + } + $save[] = $value; + } + + return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin')); + } + + /** + * Is setting related to query text - used when searching + * @param string $query + * @return bool + */ + function is_related($query) { + if (!$this->load_choices() or empty($this->choices)) { + return false; + } + if (parent::is_related($query)) { + return true; + } + + $textlib = textlib_get_instance(); + foreach ($this->choices as $desc) { + if (strpos($textlib->strtolower($desc), $query) !== false) { + return true; + } + } + return false; + } + + function output_html($data) { + if (!$this->load_choices() or empty($this->choices)) { + return ''; + } + $choices = $this->choices; + $default = $this->get_defaultsetting(); + if (is_null($default)) { + $default = array(); + } + if (is_null($data)) { $data = array(); } - foreach ($data as $datum) { - if (! in_array($datum, array_keys($this->choices))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + + $defaults = array(); + $return = '
    '.$defaultinfo.'
    '; + return format_admin_setting($this, $this->visiblename, $return, $this->description); } +} - function output_html() { - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - if (!$currentsetting) { - $currentsetting = array(); - } +/** + * Time selector + * this is a liiitle bit messy. we're using two selects, but we're returning + * them as an array named after $name (so we only use $name2 internally for the setting) + */ +class admin_setting_configtime extends admin_setting { + var $name2; + + /** + * Constructor + * @param string $hoursname setting for hours + * @param string $minutesname setting for hours + * @param string $visiblename localised + * @param string $description long localised info + * @param array $defaultsetting array representing default time 'h'=>hours, 'm'=>minutes + */ + function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) { + $this->name2 = $minutesname; + parent::admin_setting($hoursname, $visiblename, $description, $defaultsetting); + } + + function get_setting() { + $result1 = $this->config_read($this->name); + $result2 = $this->config_read($this->name2); + if (is_null($result1) or is_null($result2)) { + return NULL; + } + + return array('h' => $result1, 'm' => $result2); + } + + function write_setting($data) { + if (!is_array($data)) { + return ''; + } + + $result = $this->config_write($this->name, (int)$data['h']) && $this->config_write($this->name2, (int)$data['m']); + return ($result ? '' : get_string('errorsetting', 'admin')); + } + + function output_html($data) { + $default = $this->get_defaultsetting(); + + if (is_array($default)) { + $defaultinfo = ''.get_string('defaultsettinginfo', 'admin', $default['h'].':'.$default['m']).''; } else { - $currentsetting = $this->get_setting(); + $defaultinfo = ''; } - $return = ''; + for ($i = 0; $i < 24; $i++) { + $return .= ''; } - $return .= ''; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description); + $return .= ':'.$defaultinfo.'
    '; + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } } +/** + * Special checkbox for calendar - resets SESSION vars. + */ class admin_setting_special_adminseesall extends admin_setting_configcheckbox { - function admin_setting_special_adminseesall() { - $name = 'calendar_adminseesall'; - $visiblename = get_string('adminseesall', 'admin'); - $description = get_string('helpadminseesall', 'admin'); - parent::admin_setting($name, $visiblename, $description, 0); + parent::admin_setting_configcheckbox('calendar_adminseesall', get_string('adminseesall', 'admin'), + get_string('helpadminseesall', 'admin'), '0'); } function write_setting($data) { global $SESSION; unset($SESSION->cal_courses_shown); - parent::write_setting($data); + return parent::write_setting($data); } } +/** + * Special select for frontpage - stores data in course table + */ class admin_setting_sitesetselect extends admin_setting_configselect { - - var $id; - - function admin_setting_sitesetselect($name, $visiblename, $description, $defaultsetting, $choices) { - - $this->id = SITEID; - parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices); - - } - function get_setting() { $site = get_site(); - return (isset($site->{$this->name}) ? $site->{$this->name} : NULL); + return $site->{$this->name}; } function write_setting($data) { if (!in_array($data, array_keys($this->choices))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + return get_string('errorsetting', 'admin'); } $record = new stdClass(); - $record->id = $this->id; - $temp = $this->name; - $record->$temp = $data; + $record->id = SITEID; + $temp = $this->name; + $record->$temp = $data; $record->timemodified = time(); - return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin')); } } - -class admin_setting_courselist_frontpage extends admin_setting_configselect { +/** + * Special select - lists on the frontpage - hacky + */ +class admin_setting_courselist_frontpage extends admin_setting { + var $choices; function admin_setting_courselist_frontpage($loggedin) { global $CFG; - require_once($CFG->dirroot . '/course/lib.php'); - $name = 'frontpage' . ($loggedin ? 'loggedin' : ''); - $visiblename = get_string('frontpage' . ($loggedin ? 'loggedin' : ''),'admin'); - $description = get_string('configfrontpage' . ($loggedin ? 'loggedin' : ''),'admin'); - $choices = array(FRONTPAGENEWS => get_string('frontpagenews'), - FRONTPAGECOURSELIST => get_string('frontpagecourselist'), - FRONTPAGECATEGORYNAMES => get_string('frontpagecategorynames'), - FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'), - '' => get_string('none')); - if (!$loggedin and count_records("course") > FRONTPAGECOURSELIMIT) { - unset($choices[FRONTPAGECOURSELIST]); - } - $defaults = FRONTPAGECOURSELIST.',,,'; - parent::admin_setting_configselect($name, $visiblename, $description, $defaults, $choices); + require_once($CFG->dirroot.'/course/lib.php'); + $name = 'frontpage'.($loggedin ? 'loggedin' : ''); + $visiblename = get_string('frontpage'.($loggedin ? 'loggedin' : ''),'admin'); + $description = get_string('configfrontpage'.($loggedin ? 'loggedin' : ''),'admin'); + $defaults = array(FRONTPAGECOURSELIST); + parent::admin_setting($name, $visiblename, $description, $defaults); } + function load_choices() { + if (is_array($this->choices)) { + return true; + } + $this->choices = array(FRONTPAGENEWS => get_string('frontpagenews'), + FRONTPAGECOURSELIST => get_string('frontpagecourselist'), + FRONTPAGECATEGORYNAMES => get_string('frontpagecategorynames'), + FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'), + 'none' => get_string('none')); + if ($this->name == 'frontpage' and count_records('course') > FRONTPAGECOURSELIMIT) { + unset($this->choices[FRONTPAGECOURSELIST]); + } + return true; + } function get_setting() { - global $CFG; - return (isset($CFG->{$this->name}) ? explode(',', $CFG->{$this->name}) : ',1,,'); + $result = $this->config_read($this->name); + if (is_null($result)) { + return NULL; + } + if ($result === '') { + return array(); + } + return explode(',', $result); } function write_setting($data) { - if (empty($data)) { - $data = array(); - } if (!is_array($data)) { - $data = explode(',', $data); + if (!is_array($data)) { + return ''; } + $this->load_choices(); + $save = array(); foreach($data as $datum) { - if (! in_array($datum, array_keys($this->choices))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + if ($datum == 'none' or !array_key_exists($datum, $this->choices)) { + continue; } + $save[$datum] = $datum; // no duplicates } - return (set_config($this->name, implode(',', $data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin')); } - function output_html() { - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - for ($i = 0; $i < count($this->choices) - 1; $i++) { - if (!isset($currentsetting[$i])) { - $currentsetting[$i] = 0; + function output_html($data) { + $this->load_choices(); + $currentsetting = array(); + foreach ($data as $key) { + if ($key != 'none' and array_key_exists($key, $this->choices)) { + $currentsetting[] = $key; // already selected first } } + $return = '
    '; for ($i = 0; $i < count($this->choices) - 1; $i++) { - $return .=''; foreach ($this->choices as $key => $value) { - $return .= ''; + $return .= ''; } $return .= ''; if ($i !== count($this->choices) - 2) { @@ -1827,48 +2465,33 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect { } $return .= '
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } } +/** + * Special checkbox for frontpage - stores data in course table + */ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox { - - var $id; - - function admin_setting_sitesetcheckbox($name, $visiblename, $description, $defaultsetting) { - - $this->id = SITEID; - parent::admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting); - - } - function get_setting() { $site = get_site(); return $site->{$this->name}; } function write_setting($data) { - $record = new stdClass(); - $record->id = $this->id; - $temp = $this->name; - $record->$temp = ($data == '1' ? 1 : 0); - $record->timemodified = time(); - return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + $record = new object(); + $record->id = SITEID; + $record->{$this->name} = ($data == '1' ? 1 : 0); + $record->timemodified = time(); + return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin')); } - } +/** + * Special text for frontpage - stores data in course table. + * Empty string means not set here. Manual setting is required. + */ class admin_setting_sitesettext extends admin_setting_configtext { - - var $id; - - function admin_setting_sitesettext($name, $visiblename, $description, $defaultsetting) { - - $this->id = SITEID; - parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting); - - } - function get_setting() { $site = get_site(); return $site->{$this->name} != '' ? $site->{$this->name} : NULL; @@ -1879,43 +2502,29 @@ class admin_setting_sitesettext extends admin_setting_configtext { if ($cleaned == '') { return false; // can not be empty } - return ($data == $cleaned); // implicit conversion to string is needed to do exact comparison + return ($data == $cleaned); } function write_setting($data) { $data = trim($data); if (!$this->validate($data)) { - return get_string('validateerror', 'admin') . $this->visiblename . '
    '; + return get_string('required'); } - $record = new stdClass(); - $record->id = $this->id; + $record = new object(); + $record->id = SITEID; $record->{$this->name} = addslashes($data); - $record->timemodified = time(); - return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + $record->timemodified = time(); + return (update_record('course', $record) ? '' : get_string('dbupdatefailed', 'error')); } - } +/** + * Special text editor for site description. + */ class admin_setting_special_frontpagedesc extends admin_setting { - - var $id; - function admin_setting_special_frontpagedesc() { - $this->id = SITEID; - $name = 'summary'; - $visiblename = get_string('frontpagedescription'); - $description = get_string('frontpagedescriptionhelp'); - parent::admin_setting($name, $visiblename, $description, ''); - } - - function output_html() { - global $CFG; - - $CFG->adminusehtmleditor = can_use_html_editor(); - $return = print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, 's_' . $this->name, $this->get_setting(), 0, true); - - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + parent::admin_setting('summary', get_string('frontpagedescription'), get_string('frontpagedescriptionhelp'), NULL); } function get_setting() { @@ -1923,21 +2532,23 @@ class admin_setting_special_frontpagedesc extends admin_setting { return $site->{$this->name}; } - function get_defaultsetting() { - return NULL; - } - function write_setting($data) { $record = new object(); - $record->id = $this->id; + $record->id = SITEID; $record->{$this->name} = addslashes($data); $record->timemodified = time(); - - return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin')); } -} + function output_html($data) { + global $CFG; + $CFG->adminusehtmleditor = can_use_html_editor(); + $return = '
    '.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true).'
    '; + + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); + } +} class admin_setting_special_editorfontlist extends admin_setting { @@ -1971,20 +2582,20 @@ class admin_setting_special_editorfontlist extends admin_setting { function get_setting() { global $CFG; - if (isset($CFG->editorfontlist)) { - $i = 0; - $currentsetting = array(); - $items = explode(';', $CFG->editorfontlist); - foreach ($items as $item) { - $item = explode(':', $item); - $currentsetting['k' . $i] = $item[0]; - $currentsetting['v' . $i] = $item[1]; - $i++; - } - return $currentsetting; - } else { + $result = $this->config_read($this->name); + if (is_null($result)) { return NULL; } + $i = 0; + $currentsetting = array(); + $items = explode(';', $result); + foreach ($items as $item) { + $item = explode(':', $item); + $currentsetting['k'.$i] = $item[0]; + $currentsetting['v'.$i] = $item[1]; + $i++; + } + return $currentsetting; } function write_setting($data) { @@ -2004,41 +2615,33 @@ class admin_setting_special_editorfontlist extends admin_setting { } } - $result = ''; + $result = array(); for ($i = 0; $i < count($keys); $i++) { if (($keys[$i] !== '') && ($values[$i] !== '')) { - $result .= clean_param($keys[$i],PARAM_NOTAGS) . ':' . clean_param($values[$i], PARAM_NOTAGS) . ';'; + $result[] = clean_param($keys[$i],PARAM_NOTAGS).':'.clean_param($values[$i], PARAM_NOTAGS); } } - $result = substr($result, 0, -1); // trim the last semicolon - - return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, implode(';', $result)) ? '' : get_string('errorsetting', 'admin')); } - function output_html() { - - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - + function output_html($data) { + $fullname = $this->get_full_name(); $return = '
    '; - for ($i = 0; $i < count($currentsetting) / 2; $i++) { - $return .= ''; + for ($i = 0; $i < count($data) / 2; $i++) { + $return .= ''; $return .= '  '; - $return .= '
    '; + $return .= '
    '; } - $return .= ''; + $return .= ''; $return .= '  '; - $return .= '
    '; - $return .= ''; + $return .= '
    '; + $return .= ''; $return .= '  '; - $return .= ''; + $return .= ''; $return .= '
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } } @@ -2113,20 +2716,20 @@ class admin_setting_emoticons extends admin_setting { function get_setting() { global $CFG; - if (isset($CFG->emoticons)) { - $i = 0; - $currentsetting = array(); - $items = explode('{;}', $CFG->emoticons); - foreach ($items as $item) { - $item = explode('{:}', $item); - $currentsetting['k' . $i] = $item[0]; - $currentsetting['v' . $i] = $item[1]; - $i++; - } - return $currentsetting; - } else { + $result = $this->config_read($this->name); + if (is_null($result)) { return NULL; } + $i = 0; + $currentsetting = array(); + $items = explode('{;}', $result); + foreach ($items as $item) { + $item = explode('{:}', $item); + $currentsetting['k'.$i] = $item[0]; + $currentsetting['v'.$i] = $item[1]; + $i++; + } + return $currentsetting; } function write_setting($data) { @@ -2146,85 +2749,80 @@ class admin_setting_emoticons extends admin_setting { } } - $result = ''; + $result = array(); for ($i = 0; $i < count($keys); $i++) { if (($keys[$i] !== '') && ($values[$i] !== '')) { - $result .= clean_param($keys[$i],PARAM_NOTAGS) . '{:}' . clean_param($values[$i], PARAM_NOTAGS) . '{;}'; + $result[] = clean_param($keys[$i],PARAM_NOTAGS).'{:}'.clean_param($values[$i], PARAM_NOTAGS); } } - $result = substr($result, 0, -3); // trim the last separator - - return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, implode('{;}', $result)) ? '' : get_string('errorsetting', 'admin').$this->visiblename.'
    '); } - function output_html() { - - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - + function output_html($data) { + $fullname = $this->get_full_name(); $return = '
    '; - for ($i = 0; $i < count($currentsetting) / 2; $i++) { - $return .= ''; + for ($i = 0; $i < count($data) / 2; $i++) { + $return .= ''; $return .= '  '; - $return .= '
    '; + $return .= '
    '; } - $return .= ''; + $return .= ''; $return .= '  '; - $return .= '
    '; - $return .= ''; + $return .= '
    '; + $return .= ''; $return .= '  '; - $return .= ''; + $return .= ''; $return .= '
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } } +/** + * Setting for spellchecker language selection. + */ class admin_setting_special_editordictionary extends admin_setting_configselect { function admin_setting_special_editordictionary() { $name = 'editordictionary'; $visiblename = get_string('editordictionary','admin'); $description = get_string('configeditordictionary', 'admin'); - $choices = $this->editor_get_dictionaries(); - if (! is_array($choices)) { - $choices = array(''); - } - - parent::admin_setting_configselect($name, $visiblename, $description, '', $choices); + parent::admin_setting_configselect($name, $visiblename, $description, '', NULL); } - // function borrowed from the old moodle/admin/editor.php, slightly modified - function editor_get_dictionaries () { - /// Get all installed dictionaries in the system + function load_choices() { + // function borrowed from the old moodle/admin/editor.php, slightly modified + // Get all installed dictionaries in the system + if (is_array($this->choices)) { + return true; + } + + $this->choices = array(); global $CFG; -// error_reporting(E_ALL); // for debug, final version shouldn't have this... clearstatcache(); // If aspellpath isn't set don't even bother ;-) if (empty($CFG->aspellpath)) { - return 'Empty aspell path!'; + $this->choices['error'] = 'Empty aspell path!'; + return true; } // Do we have access to popen function? if (!function_exists('popen')) { - return 'Popen function disabled!'; + $this->choices['error'] = 'Popen function disabled!'; + return true; } $cmd = $CFG->aspellpath; $output = ''; $dictionaries = array(); - $dicts = array(); - if(!($handle = @popen(escapeshellarg($cmd) .' dump dicts', 'r'))) { - return 'Couldn\'t create handle!'; + if(!($handle = @popen(escapeshellarg($cmd).' dump dicts', 'r'))) { + $this->choices['error'] = 'Couldn\'t create handle!'; } while(!feof($handle)) { @@ -2233,43 +2831,27 @@ class admin_setting_special_editordictionary extends admin_setting_configselect @pclose($handle); $dictionaries = explode(chr(10), $output); - - // Get rid of possible empty values - if (is_array($dictionaries)) { - - $cnt = count($dictionaries); - - for ($i = 0; $i < $cnt; $i++) { - if (!empty($dictionaries[$i])) { - $dicts[$dictionaries[$i]] = $dictionaries[$i]; - } + foreach ($dictionaries as $dict) { + if (empty($dict)) { + continue; } + $this->choices[$dict] = $dict; } - if (count($dicts) >= 1) { - return $dicts; + if (empty($this->choices)) { + $this->choices['error'] = 'Error! Check your aspell installation!'; } - - return 'Error! Check your aspell installation!'; + return true; } - - - } class admin_setting_special_editorhidebuttons extends admin_setting { - - var $name; - var $visiblename; - var $description; var $items; function admin_setting_special_editorhidebuttons() { - $this->name = 'editorhidebuttons'; - $this->visiblename = get_string('editorhidebuttons', 'admin'); - $this->description = get_string('confeditorhidebuttons', 'admin'); - $this->defaultsetting = array(); + parent::admin_setting('editorhidebuttons', get_string('editorhidebuttons', 'admin'), + get_string('confeditorhidebuttons', 'admin'), array()); // weird array... buttonname => buttonimage (assume proper path appended). if you leave buttomimage blank, text will be printed instead $this->items = array('fontname' => '', 'fontsize' => '', @@ -2313,39 +2895,44 @@ class admin_setting_special_editorhidebuttons extends admin_setting { } function get_setting() { - global $CFG; - return (isset($CFG->{$this->name}) ? explode(' ', $CFG->{$this->name}) : NULL); + $result = $this->config_read($this->name); + if (is_null($result)) { + return NULL; + } + if ($result === '') { + return array(); + } + return explode(',', $result); } function write_setting($data) { + if (!is_array($data)) { + return ''; // ignore it + } + unset($data['xxxxx']); $result = array(); - if (empty($data)) { $data = array(); } + foreach ($data as $key => $value) { if (!in_array($key, array_keys($this->items))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + return get_string('errorsetting', 'admin'); } if ($value == '1') { $result[] = $key; } } - return (set_config($this->name, implode(' ',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, implode(' ', $result)) ? '' : get_string('errorsetting', 'admin')); } - function output_html() { + function output_html($data) { global $CFG; // checkboxes with input name="$this->name[$key]" value="1" // we do 15 fields per column - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - $return = '
    '; $return .= '
    '; + $return .= ''; // something must be submitted even if nothing selected $count = 0; @@ -2354,8 +2941,8 @@ class admin_setting_special_editorhidebuttons extends admin_setting { $return .= ''; } - $return .= ($value == '' ? get_string($key,'editor') : '' . get_string($key,'editor') . '') . ' '; - $return .= '       '; + $return .= ($value == '' ? get_string($key,'editor') : ''.get_string($key,'editor').'').' '; + $return .= '       '; $count++; if ($count % 15 != 0) { $return .= '

    '; @@ -2366,11 +2953,13 @@ class admin_setting_special_editorhidebuttons extends admin_setting { $return .= '
    '; $return .= '
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } - } +/** + * Special setting for limiting of the list of available languages. + */ class admin_setting_langlist extends admin_setting_configtext { function admin_setting_langlist() { parent::admin_setting_configtext('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS); @@ -2383,205 +2972,67 @@ class admin_setting_langlist extends admin_setting_configtext { } } -class admin_setting_backupselect extends admin_setting_configselect { - - function admin_setting_backupselect($name, $visiblename, $description, $default, $choices) { - parent::admin_setting_configselect($name, $visiblename, $description, $default, $choices); - } - - function get_setting() { - $backup_config = backup_get_config(); - return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL); - } - - function write_setting($data) { - // check that what we got was in the original choices - if (! in_array($data, array_keys($this->choices))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; - } - - return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } - -} - -class admin_setting_special_backupsaveto extends admin_setting_configtext { - - function admin_setting_special_backupsaveto() { - $name = 'backup_sche_destination'; - $visiblename = get_string('saveto'); - $description = get_string('backupsavetohelp'); - parent::admin_setting_configtext($name, $visiblename, $description, ''); - } - - function get_setting() { - $backup_config = backup_get_config(); - return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL); - } - - function write_setting($data) { - $data = trim($data); - if (!empty($data) and !is_dir($data)) { - return get_string('pathnotexists') . '
    '; - } - return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } - -} - -class admin_setting_backupcheckbox extends admin_setting_configcheckbox { - - function admin_setting_backupcheckbox($name, $visiblename, $description, $default) { - parent::admin_setting_configcheckbox($name, $visiblename, $description, $default); - } - - function write_setting($data) { - if ($data == '1') { - return (backup_set_config($this->name, 1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } else { - return (backup_set_config($this->name, 0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } - } - - function get_setting() { - $backup_config = backup_get_config(); - return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL); - } - -} - -class admin_setting_special_backuptime extends admin_setting_configtime { - - function admin_setting_special_backuptime() { - $name = 'backup_sche_hour'; - $name2 = 'backup_sche_minute'; - $visiblename = get_string('executeat'); - $description = get_string('backupexecuteathelp'); - $default = array('h' => 0, 'm' => 0); - parent::admin_setting_configtime($name, $name2, $visiblename, $description, $default); - } - - function get_setting() { - $backup_config = backup_get_config(); - return (isset($backup_config->{$this->name}) && isset($backup_config->{$this->name}) ? array('h'=>$backup_config->{$this->name}, 'm'=>$backup_config->{$this->name2}) : NULL); - } - - function write_setting($data) { - // check that what we got was in the original choices - if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; - } - - return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } - -} - -class admin_setting_special_backupdays extends admin_setting { - - function admin_setting_special_backupdays() { - $name = 'backup_sche_weekdays'; - $visiblename = get_string('schedule'); - $description = get_string('backupschedulehelp'); - $default = array('u' => 0, 'm' => 0, 't' => 0, 'w' => 0, 'r' => 0, 'f' => 0, 's' => 0); - parent::admin_setting($name, $visiblename, $description, $default); - } - - function get_setting() { - $backup_config = backup_get_config(); - if (isset($backup_config->{$this->name})) { - $currentsetting = $backup_config->{$this->name}; - return array('u' => substr($currentsetting, 0, 1), - 'm' => substr($currentsetting, 1, 1), - 't' => substr($currentsetting, 2, 1), - 'w' => substr($currentsetting, 3, 1), - 'r' => substr($currentsetting, 4, 1), - 'f' => substr($currentsetting, 5, 1), - 's' => substr($currentsetting, 6, 1)); - } else { - return NULL; - } - } - - function output_html() { - - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - - // rewrite for simplicity - $currentsetting = $currentsetting['u'] . $currentsetting['m'] . $currentsetting['t'] . $currentsetting['w'] . - $currentsetting['r'] . $currentsetting['f'] . $currentsetting['s']; - - $return = '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '
      ' . get_string('sunday', 'calendar') . '  
      ' . - get_string('monday', 'calendar') . '  
      ' . get_string('tuesday', 'calendar') . '  
      ' . - get_string('wednesday', 'calendar') . '  
      ' . get_string('thursday', 'calendar') . '  
      ' . - get_string('friday', 'calendar') . '  
      ' . get_string('saturday', 'calendar') . '  
    '; +/** + * Course category selection + */ +class admin_settings_coursecat_select extends admin_setting_configselect { + function admin_settings_coursecat_select($name, $visiblename, $description, $defaultsetting) { + parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, NULL); + } - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + function load_choices() { + global $CFG; + require_once($CFG->dirroot.'/course/lib.php'); + if (is_array($this->choices)) { + return true; + } + $this->choices = make_categories_options(); + return true; + } +} +class admin_setting_special_backupdays extends admin_setting_configmulticheckbox2 { + function admin_setting_special_backupdays() { + parent::admin_setting_configmulticheckbox2('backup_sche_weekdays', get_string('schedule'), get_string('backupschedulehelp'), array(), NULL); + $this->plugin = 'backup'; } - // we're using the array trick (see http://ca.php.net/manual/en/faq.html.php#faq.html.arrays) to get the data passed to use without having to modify - // admin_settingpage (note that admin_settingpage only calls write_setting with the data that matches $this->name... so if we have multiple form fields, - // they MUST go into an array named $this->name, or else we won't receive them here - function write_setting($data) { - $week = 'umtwrfs'; - $result = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0); - if (!empty($data)) { - foreach($data as $key => $value) { - if ($value == '1') { - $result[strpos($week, $key)] = 1; - } - } + function load_choices() { + if (is_array($this->choices)) { + return true; + } + $this->choices = array(); + $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); + foreach ($days as $day) { + $this->choices[$day] = get_string($day, 'calendar'); } - return (backup_set_config($this->name, implode('',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return true; } } +/** + * Special debug setting + */ class admin_setting_special_debug extends admin_setting_configselect { - function admin_setting_special_debug() { - $name = 'debug'; - $visiblename = get_string('debug', 'admin'); - $description = get_string('configdebug', 'admin'); - $choices = array( DEBUG_NONE => get_string('debugnone', 'admin'), - DEBUG_MINIMAL => get_string('debugminimal', 'admin'), - DEBUG_NORMAL => get_string('debugnormal', 'admin'), - DEBUG_ALL => get_string('debugall', 'admin'), - DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin') - ); - parent::admin_setting_configselect($name, $visiblename, $description, '', $choices); + parent::admin_setting_configselect('debug', get_string('debug', 'admin'), get_string('configdebug', 'admin'), DEBUG_NONE, NULL); } - function get_setting() { - global $CFG; - if (isset($CFG->debug)) { - return $CFG->debug; - } else { - return NULL; + function load_choices() { + if (is_array($this->choices)) { + return true; } + $this->choices = array(DEBUG_NONE => get_string('debugnone', 'admin'), + DEBUG_MINIMAL => get_string('debugminimal', 'admin'), + DEBUG_NORMAL => get_string('debugnormal', 'admin'), + DEBUG_ALL => get_string('debugall', 'admin'), + DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin')); + return true; } - - function write_setting($data) { - return (set_config($this->name,$data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } - } class admin_setting_special_calendar_weekend extends admin_setting { - function admin_setting_special_calendar_weekend() { $name = 'calendar_weekend'; $visiblename = get_string('calendar_weekend', 'admin'); @@ -2591,484 +3042,789 @@ class admin_setting_special_calendar_weekend extends admin_setting { } function get_setting() { - global $CFG; - return isset($CFG->{$this->name}) ? $CFG->{$this->name} : 0; + $result = $this->config_read($this->name); + if (is_null($result)) { + return NULL; + } + if ($result === '') { + return array(); + } + $settings = array(); + for ($i=0; $i<7; $i++) { + if ($result & (1 << $i)) { + $setting[] = $i; + } + } + return $setting; } function write_setting($data) { + if (!is_array($data)) { + return ''; + } + unset($data['xxxxx']); $result = 0; - if (!empty($data)) { - foreach($data as $index) { - $result |= 1 << $index; - } + foreach($data as $index) { + $result |= 1 << $index; } - return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + return ($this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin')); } - function output_html() { - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - + function output_html($data) { // The order matters very much because of the implied numeric keys $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); $return = ''; + $return .= ''; // something must be submitted even if nothing selected foreach($days as $index => $day) { - $return .= ''; + $return .= ''; } $return .= ''; foreach($days as $index => $day) { - $return .= ''; + $return .= ''; } $return .= '
    '; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return format_admin_setting($this, $this->visiblename, $return, $this->description, false); } - } + /** - * this is used in config->grades + * Graded roles in gradebook */ -class admin_setting_special_gradebookroles extends admin_setting { - +class admin_setting_special_gradebookroles extends admin_setting_configmulticheckbox { function admin_setting_special_gradebookroles() { - $name = 'gradebookroles'; - $visiblename = get_string('gradebookroles', 'admin'); - $description = get_string('configgradebookroles', 'admin'); - $default = array(5=>'1'); // The student role in a default install - parent::admin_setting($name, $visiblename, $description, $default); + parent::admin_setting_configmulticheckbox('gradebookroles', get_string('gradebookroles', 'admin'), + get_string('configgradebookroles', 'admin'), NULL, NULL); } - function get_setting() { + function load_choices() { global $CFG; - if (!empty($CFG->{$this->name})) { - $result = explode(',', $CFG->{$this->name}); - foreach ($result as $roleid) { - $array[$roleid] = 1; + if (empty($CFG->rolesactive)) { + return false; + } + if (is_array($this->choices)) { + return true; + } + if ($roles = get_records('role')) { + $this->choices = array(); + foreach($roles as $role) { + $this->choices[$role->id] = format_string($role->name); } - return $array; + return true; } else { - return null; + return false; } } - function write_setting($data) { - if (!empty($data)) { - $str = ''; - foreach ($data as $key => $value) { - if ($value) { - $str .= $key.','; - } + function get_defaultsetting() { + global $CFG; + if (empty($CFG->rolesactive)) { + return NULL; + } + $result = array(); + if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { + foreach ($studentroles as $studentrole) { + $result[$studentrole->id] = '1'; } - return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; - } else { - return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; } + return $result; } +} - function output_html() { +/** + * Which roles to show on course decription page + */ +class admin_setting_special_coursemanager extends admin_setting_configmulticheckbox { + function admin_setting_special_coursemanager() { + parent::admin_setting_configmulticheckbox('coursemanager', get_string('coursemanager', 'admin'), + get_string('configcoursemanager', 'admin'), NULL, NULL); + } - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); + function load_choices() { + if (is_array($this->choices)) { + return true; } - // from to process which roles to display if ($roles = get_records('role')) { - $return = '
    '; - $first = true; - foreach ($roles as $roleid=>$role) { - if (is_array($currentsetting) && in_array($roleid, array_keys($currentsetting))) { - $checked = ' checked="checked"'; - } else { - $checked = ''; - } - if ($first) { - $first = false; - } else { - $return .= '
    '; - } - $return .= ' '.format_string($role->name); + $this->choices = array(); + foreach($roles as $role) { + $this->choices[$role->id] = format_string($role->name); } - $return .= '
    '; + return true; } + return false; + } - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + function get_defaultsetting() { + global $CFG; + if (empty($CFG->rolesactive)) { + return NULL; + } + $result = array(); + if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { + foreach ($teacherroles as $teacherrole) { + $result[$teacherrole->id] = '1'; + } + } + return $result; + } +} +/** + * Primary grade export plugin - has state tracking. + */ +class admin_setting_special_gradeexport extends admin_setting_configmulticheckbox { + function admin_setting_special_gradeexport() { + parent::admin_setting_configmulticheckbox('gradeexport', get_string('gradeexport', 'admin'), + get_string('configgradeexport', 'admin'), array(), NULL); } + function load_choices() { + if (is_array($this->choices)) { + return true; + } + $this->choices = array(); + + if ($plugins = get_list_of_plugins('grade/export')) { + foreach($plugins as $plugin) { + $this->choices[$plugin] = get_string('modulename', 'gradeexport_'.$plugin); + } + } + return true; + } } -/* - * this is used in config->appearance->coursemanager - * (which roles to show on course decription page) +/** + * Grade category settings */ -class admin_setting_special_coursemanager extends admin_setting { +class admin_setting_gradecat_combo extends admin_setting { - function admin_setting_special_coursemanager() { - $name = 'coursemanager'; - $visiblename = get_string('coursemanager', 'admin'); - $description = get_string('configcoursemanager', 'admin'); - $default = array(3=>'1'); // The teahcer role in a default install - parent::admin_setting($name, $visiblename, $description, $default); + var $choices; + + function admin_setting_gradecat_combo($name, $visiblename, $description, $defaultsetting, $choices) { + $this->choices = $choices; + parent::admin_setting($name, $visiblename, $description, $defaultsetting); } function get_setting() { - global $CFG; - if (!empty($CFG->{$this->name})) { - $result = explode(',', $CFG->{$this->name}); - foreach ($result as $roleid) { - $array[$roleid] = 1; - } - return $array; - } else if (isset($CFG->{$this->name})) { - return array(); - } else { - return null; + + $value = $this->config_read($this->name); + $flag = $this->config_read($this->name.'_flag'); + + if (is_null($value) or is_null($flag)) { + return NULL; } + + $flag = (int)$flag; + $forced = (boolean)(1 & $flag); // first bit + $adv = (boolean)(2 & $flag); // second bit + + return array('value' => $value, 'forced' => $forced, 'adv' => $adv); } function write_setting($data) { + global $CFG; - if (!empty($data)) { - $str = ''; - foreach ($data as $key => $value) { - if ($value) { - $str .= $key.','; - } - } - return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + $value = $data['value']; + $forced = empty($data['forced']) ? 0 : 1; + $adv = empty($data['adv']) ? 0 : 2; + $flag = ($forced | $adv); //bitwise or + + if (!in_array($value, array_keys($this->choices))) { + return 'Error setting '; + } + + $oldvalue = $this->config_read($this->name); + $oldflag = (int)$this->config_read($this->name.'_flag'); + $oldforced = (1 & $oldflag); // first bit + + $result1 = $this->config_write($this->name, $value); + $result2 = $this->config_write($this->name.'_flag', $flag); + + // force regrade if needed + if ($oldforced != $forced or ($forced and $value != $oldvalue)) { + require_once($CFG->libdir.'/gradelib.php'); + grade_category::updated_forced_settings(); + } + + if ($result1 and $result2) { + return ''; } else { - return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + return get_string('errorsetting', 'admin'); } } - function output_html() { + function output_html($data) { + $value = $data['value']; + $forced = !empty($data['forced']); + $adv = !empty($data['adv']); - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - // from to process which roles to display - if ($roles = get_records_select('role', '', 'sortorder')) { - $return = '
    '; - $first = true; - foreach ($roles as $roleid=>$role) { - if (is_array($currentsetting) && in_array($roleid, array_keys($currentsetting))) { - $checked = 'checked="checked"'; - } else { - $checked = ''; - } - if ($first) { - $first = false; - } else { - $return .= '
    '; + $return = ''; + $return .= '' + .'' + .'
    '; } - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + return true; } } -/* - * this is used in config->courses->gradeexports - * (which roles to show on course decription page) +/** + * Special class for register auth selection */ -class admin_setting_special_gradeexport extends admin_setting { - - function admin_setting_special_gradeexport() { - $name = 'gradeexport'; - $visiblename = get_string('gradeexport', 'admin'); - $description = get_string('configgradeexport', 'admin'); - $default = array(3=>'1'); // The teahcer role in a default install - parent::admin_setting($name, $visiblename, $description, $default); +class admin_setting_special_registerauth extends admin_setting_configselect { + function admin_setting_special_registerauth() { + parent::admin_setting_configselect('registerauth', get_string('selfregistration', 'auth'), get_string('selfregistration_help', 'auth'), 'email', null); } - function get_setting() { + function get_defaultsettings() { + $this->load_choices(); + if (array_key_exists($this->defaultsetting, $this->choices)) { + return $this->defaultsetting; + } else { + return ''; + } + } + function load_choices() { global $CFG; - if (!empty($CFG->{$this->name})) { - $result = explode(',', $CFG->{$this->name}); - foreach ($result as $plugin) { - $array[$plugin] = 1; + + if (is_array($this->choices)) { + return true; + } + $this->choices = array(); + $this->choices[''] = get_string('disable'); + + $authsenabled = get_enabled_auth_plugins(true); + + foreach ($authsenabled as $auth) { + $authplugin = get_auth_plugin($auth); + if (!$authplugin->can_signup()) { + continue; } - return $array; - } else if (isset($CFG->{$this->name})) { - return array(); - } else { - return null; + // Get the auth title (from core or own auth lang files) + $authtitle = get_string("auth_{$auth}title", "auth"); + if ($authtitle == "[[auth_{$auth}title]]") { + $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); + } + $this->choices[$auth] = $authtitle; } + return true; } +} - function write_setting($data) { +/** + * Module manage page + */ +class admin_page_managemods extends admin_externalpage { + function admin_page_managemods() { + global $CFG; + parent::admin_externalpage('managemodules', get_string('modsettings', 'admin'), "$CFG->wwwroot/$CFG->admin/modules.php"); + } - if (!empty($data)) { - $str = ''; - foreach ($data as $key => $value) { - if ($value) { - $str .= $key.','; + function search($query) { + if (parent::search($query)) { + return true; + } + + $found = false; + if ($modules = get_records('modules')) { + $textlib = textlib_get_instance(); + foreach ($modules as $module) { + if (strpos($module->name, $query) !== false) { + $found = true; + break; + } + $strmodulename = get_string('modulename', $module->name); + if (strpos($textlib->strtolower($strmodulename), $query) !== false) { + $found = true; + break; } } - return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + } + if ($found) { + $result = new object(); + $result->page = $this; + $result->settings = array(); + return array($this->name => $result); } else { - return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '
    '; + return array(); } } +} - function output_html() { +/** + * Blocks manage page + */ +class admin_page_manageblocks extends admin_externalpage { + function admin_page_manageblocks() { + global $CFG; + parent::admin_externalpage('manageblocks', get_string('blocksettings', 'admin'), "$CFG->wwwroot/$CFG->admin/blocks.php"); + } - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); - } - // from to process which roles to display - if ($exports = get_list_of_plugins('grade/export')) { - $return = '
    '; - $first = true; - foreach ($exports as $export) { - if (is_array($currentsetting) && in_array($export, array_keys($currentsetting))) { - $checked = 'checked="checked"'; - } else { - $checked = ''; + function search($query) { + global $CFG; + if (parent::search($query)) { + return true; + } + + $found = false; + if (!empty($CFG->blocks_version) and $blocks = get_records('block')) { + $textlib = textlib_get_instance(); + foreach ($blocks as $block) { + if (strpos($block->name, $query) !== false) { + $found = true; + break; } - if ($first) { - $first = false; - } else { - $return .= '
    '; + $strblockname = get_string('blockname', 'block_'.$block->name); + if (strpos($textlib->strtolower($strblockname), $query) !== false) { + $found = true; + break; } - $return .= ' '.$export; } - $return .= '
    '; } - return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false); + if ($found) { + $result = new object(); + $result->page = $this; + $result->settings = array(); + return array($this->name => $result); + } else { + return array(); + } } } +/** + * Special class for authentication administration. + */ +class admin_setting_manageauths extends admin_setting { + function admin_setting_manageauths() { + parent::admin_setting('authsui', get_string('authsettings', 'admin'), '', ''); + } + function get_setting() { + return true; + } - -class admin_setting_special_perfdebug extends admin_setting_configcheckbox { - - function admin_setting_special_perfdebug() { - $name = 'perfdebug'; - $visiblename = get_string('perfdebug', 'admin'); - $description = get_string('configperfdebug', 'admin'); - parent::admin_setting_configcheckbox($name, $visiblename, $description, ''); + function get_defaultsetting() { + return true; } function write_setting($data) { - - if ($data == '1') { - return (set_config($this->name,15) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } else { - return (set_config($this->name,7) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); - } + // do not write any setting + return ''; } - function output_html() { + function is_related($query) { + if (parent::is_related($query)) { + return true; + } - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); + $textlib = textlib_get_instance(); + $authsavailable = get_list_of_plugins('auth'); + foreach ($authsavailable as $auth) { + if (strpos($auth, $query) !== false) { + return true; + } + $authtitle = get_string("auth_{$auth}title", "auth"); + if ($authtitle == "[[auth_{$auth}title]]") { + $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); + } + if (strpos($textlib->strtolower($authtitle), $query) !== false) { + return true; + } } - - $return = ''; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description); + return false; } -} - -class admin_setting_special_debugdisplay extends admin_setting_configcheckbox { + function output_html($data) { + global $CFG; - function admin_setting_special_debugdisplay() { - $name = 'debugdisplay'; - $visiblename = get_string('debugdisplay', 'admin'); - $description = get_string('configdebugdisplay', 'admin'); - $default = ini_get('display_errors'); - parent::admin_setting_configcheckbox($name, $visiblename, $description, $default); - } - function write_setting($data) { + // display strings + $txt = get_strings(array('authenticationplugins', 'users', 'administration', + 'settings', 'edit', 'name', 'enable', 'disable', + 'up', 'down', 'none')); + $txt->updown = "$txt->up/$txt->down"; - if ($data == '1') { - return (set_config($this->name,1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + $authsavailable = get_list_of_plugins('auth'); + get_enabled_auth_plugins(true); // fix the list of enabled auths + if (empty($CFG->auth)) { + $authsenabled = array(); } else { - return (set_config($this->name,0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
    '); + $authsenabled = explode(',', $CFG->auth); + } + + // construct the display array, with enabled auth plugins at the top, in order + $displayauths = array(); + $registrationauths = array(); + $registrationauths[''] = $txt->disable; + foreach ($authsenabled as $auth) { + $authplugin = get_auth_plugin($auth); + /// Get the auth title (from core or own auth lang files) + $authtitle = get_string("auth_{$auth}title", "auth"); + if ($authtitle == "[[auth_{$auth}title]]") { + $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); + } + /// Apply titles + $displayauths[$auth] = $authtitle; + if ($authplugin->can_signup()) { + $registrationauths[$auth] = $authtitle; + } } - } - - function output_html() { - if ($this->get_setting() === NULL) { - $currentsetting = $this->defaultsetting; - } else { - $currentsetting = $this->get_setting(); + foreach ($authsavailable as $auth) { + if (array_key_exists($auth, $displayauths)) { + continue; //already in the list + } + $authplugin = get_auth_plugin($auth); + /// Get the auth title (from core or own auth lang files) + $authtitle = get_string("auth_{$auth}title", "auth"); + if ($authtitle == "[[auth_{$auth}title]]") { + $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); + } + /// Apply titles + $displayauths[$auth] = $authtitle; + if ($authplugin->can_signup()) { + $registrationauths[$auth] = $authtitle; + } } - $return = ''; - return format_admin_setting($this->name, $this->visiblename, $return, $this->description); - } + $return = print_heading(get_string('actauthhdr', 'auth'), '', 3, 'main', true); + $return .= print_box_start('generalbox authsui', '', true); -} + $table = new object(); + $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings); + $table->align = array('left', 'center', 'center', 'center'); + $table->width = '90%'; + $table->data = array(); + //add always enabled plugins first + $displayname = "".$displayauths['manual'].""; + $settings = "{$txt->settings}"; + $table->data[] = array($displayname, '', '', $settings); + $displayname = "".$displayauths['nologin'].""; + $settings = "{$txt->settings}"; + $table->data[] = array($displayname, '', '', $settings); -class admin_setting_gradecat_combo extends admin_setting { - var $choices; + // iterate through auth plugins and add to the display table + $updowncount = 1; + $authcount = count($authsenabled); + $url = "auth.php?sesskey=" . sesskey(); + foreach ($displayauths as $auth => $name) { + if ($auth == 'manual' or $auth == 'nologin') { + continue; + } + // hide/show link + if (in_array($auth, $authsenabled)) { + $hideshow = ""; + $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" />"; + // $hideshow = ""; + $enabled = true; + $displayname = "$name"; + } + else { + $hideshow = ""; + $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" />"; + // $hideshow = ""; + $enabled = false; + $displayname = "$name"; + } - function admin_setting_gradecat_combo($name, $visiblename, $description, $defaultsetting, $choices) { - $this->choices = $choices; - parent::admin_setting($name, $visiblename, $description, $defaultsetting); - } + // up/down link (only if auth is enabled) + $updown = ''; + if ($enabled) { + if ($updowncount > 1) { + $updown .= ""; + $updown .= "pixpath}/t/up.gif\" alt=\"up\" /> "; + } + else { + $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> "; + } + if ($updowncount < $authcount) { + $updown .= ""; + $updown .= "pixpath}/t/down.gif\" alt=\"down\" />"; + } + else { + $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />"; + } + ++ $updowncount; + } - function get_setting() { - global $CFG; + // settings link + if (file_exists($CFG->dirroot.'/auth/'.$auth.'/settings.php')) { + $settings = "{$txt->settings}"; + } else { + $settings = "{$txt->settings}"; + } - if (!isset($CFG->{$this->name}) or !isset($CFG->{$this->name.'_flag'})) { - return NULL; + // add a row to the table + $table->data[] =array($displayname, $hideshow, $updown, $settings); } + $return .= print_table($table, true); + $return .= get_string('configauthenticationplugins', 'admin').'
    '.get_string('tablenosave', 'filters'); + $return .= print_box_end(true); + return $return; + } +} +/** + * Special class for filter administration. + */ +class admin_setting_managefilters extends admin_setting { + function admin_setting_managefilters() { + parent::admin_setting('filtersui', get_string('filtersettings', 'admin'), '', ''); + } - $flag = (int)$CFG->{$this->name.'_flag'}; - $forced = (boolean)(1 & $flag); // first bit - $adv = (boolean)(2 & $flag); // second bit - - return array('value' => $CFG->{$this->name}, 'forced' => $forced, 'adv' => $adv); + function get_setting() { + return true; + } + + function get_defaultsetting() { + return true; } function write_setting($data) { - global $CFG; + // do not write any setting + return ''; + } - $value = $data['value']; - $forced = empty($data['forced']) ? 0 : 1; - $adv = empty($data['adv']) ? 0 : 2; - $flag = ($forced | $adv); //bitwise or - - if (!in_array($value, array_keys($this->choices))) { - return 'Error setting ' . $this->visiblename . '
    '; + function is_related($query) { + if (parent::is_related($query)) { + return true; } - $oldvalue = get_config(NULL, $this->name); - $oldflag = (int)get_config(NULL, $this->name.'_flag'); - $oldforced = (1 & $oldflag); // first bit - - $result = (boolean)set_config($this->name, $value); - $result = $result && (boolean)set_config($this->name.'_flag', $flag); - - if ($result) { - // force regrade if needed - if ($oldforced != $forced or ($forced and $value != $oldvalue)) { - require_once($CFG->libdir.'/gradelib.php'); - grade_category::updated_forced_settings(); + $textlib = textlib_get_instance(); + $filterlocations = array('mod','filter'); + foreach ($filterlocations as $filterlocation) { + $plugins = get_list_of_plugins($filterlocation); + foreach ($plugins as $plugin) { + if (strpos($plugin, $query) !== false) { + return true; + } + $name = get_string('filtername', $plugin); + if (strpos($textlib->strtolower($name), $query) !== false) { + return true; + } } - - return ''; - } else { - return get_string('errorsetting', 'admin') . $this->visiblename . '
    '; } + return false; } - function output_html() { + function output_html($data) { + global $CFG; - if ($this->get_setting() === NULL) { - $current = $this->defaultsetting; - } else { - $current = $this->get_setting(); + $strname = get_string('name'); + $strhide = get_string('disable'); + $strshow = get_string('enable'); + $strhideshow = "$strhide/$strshow"; + $strsettings = get_string('settings'); + $strup = get_string('up'); + $strdown = get_string('down'); + $strupdown = "$strup/$strdown"; + + // get a list of possible filters (and translate name if possible) + // note filters can be in the dedicated filters area OR in their + // associated modules + $installedfilters = array(); + $filtersettings_new = array(); + $filtersettings_old = array(); + $filterlocations = array('mod','filter'); + foreach ($filterlocations as $filterlocation) { + $plugins = get_list_of_plugins($filterlocation); + foreach ($plugins as $plugin) { + $pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php"; + $settingspath_new = "$CFG->dirroot/$filterlocation/$plugin/filtersettings.php"; + $settingspath_old = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html"; + if (is_readable($pluginpath)) { + $name = trim(get_string("filtername", $plugin)); + if (empty($name) or ($name == '[[filtername]]')) { + $textlib = textlib_get_instance(); + $name = $textlib->strtotitle($plugin); + } + $installedfilters["$filterlocation/$plugin"] = $name; + if (is_readable($settingspath_new)) { + $filtersettings_new[] = "$filterlocation/$plugin"; + } else if (is_readable($settingspath_old)) { + $filtersettings_old[] = "$filterlocation/$plugin"; + } + } + } } - $value = $current['value']; - $forced = !empty($current['forced']); - $adv = !empty($current['adv']); - $return = ''; - $return .= ''; - $return .= ''; - - return format_admin_setting($this->name, $this->visiblename, $return, $this->description); - } -} + // take this opportunity to clean up filters + $activefilters = array(); + foreach ($oldactivefilters as $oldactivefilter) { + if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) { + $activefilters[] = $oldactivefilter; + } + } -/** - * Selection of grade report in user profile - */ -class admin_setting_grade_profilereport extends admin_setting_configselect { - function admin_setting_grade_profilereport() { - parent::admin_setting_configselect('grade_profilereport', get_string('profilereport', 'grades'), get_string('configprofilereport', 'grades'), 'user', null); - } - - function load_choices() { - if (!empty($this->choices)) { - return; + // construct the display array with installed filters + // at the top in the right order + $displayfilters = array(); + foreach ($activefilters as $activefilter) { + $name = $installedfilters[$activefilter]; + $displayfilters[$activefilter] = $name; + } + foreach ($installedfilters as $key => $filter) { + if (!array_key_exists($key, $displayfilters)) { + $displayfilters[$key] = $filter; + } } - $this->choices = array(); - global $CFG; - require_once($CFG->libdir.'/gradelib.php'); + $return = print_heading(get_string('actfilterhdr', 'filters'), '', 3, 'main', true); + $return .= print_box_start('generalbox filtersui', '', true); + + $table = new object(); + $table->head = array($strname, $strhideshow, $strupdown, $strsettings); + $table->align = array('left', 'center', 'center', 'center'); + $table->width = '90%'; + $table->data = array(); + + $filtersurl = "$CFG->wwwroot/$CFG->admin/filters.php?sesskey=".sesskey(); + $imgurl = "$CFG->pixpath/t"; + + // iterate through filters adding to display table + $updowncount = 1; + $activefilterscount = count($activefilters); + foreach ($displayfilters as $path => $name) { + $upath = urlencode($path); + // get hide/show link + if (in_array($path, $activefilters)) { + $hideshow = ""; + $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"$strhide\" />"; + $hidden = false; + $displayname = "$name"; + } + else { + $hideshow = ""; + $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"$strshow\" />"; + $hidden = true; + $displayname = "$name"; + } - foreach (get_list_of_plugins('grade/report') as $plugin) { - if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php')) { - require_once($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php'); - $functionname = 'grade_report_'.$plugin.'_profilereport'; - if (function_exists($functionname)) { - $this->choices[$plugin] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/'); + // get up/down link (only if not hidden) + $updown = ''; + if (!$hidden) { + if ($updowncount>1) { + $updown .= ""; + $updown .= "\"$strup\" "; + } + else { + $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> "; + } + if ($updowncount<$activefilterscount) { + $updown .= ""; + $updown .= "\"$strdown\""; + } + else { + $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" />"; } + ++$updowncount; } + + // settings link (if defined) + $settings = ''; + if (in_array($path, $filtersettings_new)) { + $settings = "$strsettings"; + } else if (in_array($path, $filtersettings_old)) { + $settings = "$strsettings"; + } + + // write data into the table object + $table->data[] = array($displayname, $hideshow, $updown, $settings); } - } + $return .= print_table($table, true); + $return .= get_string('tablenosave', 'filters'); + $return .= print_box_end(true); + return $return; + } } - -// Code for a function that helps externalpages print proper headers and footers -// N.B.: THIS FUNCTION HANDLES AUTHENTICATION +/** + * Initialise admin page - this function does require login and permission + * checks specified in page definition. + * This function must be called on each admin page before other code. + * @param string $section name of page + */ function admin_externalpage_setup($section) { global $CFG, $PAGE, $USER; - - $adminroot = admin_get_root(); - - require_once($CFG->libdir . '/blocklib.php'); - require_once($CFG->dirroot . '/'.$CFG->admin.'/pagelib.php'); - - page_map_class(PAGE_ADMIN, 'page_admin'); - - $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number - - $PAGE->init_extra($section); // hack alert! - - $root = $adminroot->locate($PAGE->section); + require_once($CFG->libdir.'/blocklib.php'); + require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php'); if ($site = get_site()) { require_login(); } else { - redirect($CFG->wwwroot . '/'.$CFG->admin.'/index.php'); + redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php'); die; } - if (!is_a($root, 'admin_externalpage')) { + $adminroot =& admin_get_root(false, false); // settings not required for external pages + $extpage =& $adminroot->locate($section); + + if (empty($extpage) or !is_a($extpage, 'admin_externalpage')) { error(get_string('sectionerror','admin')); die; } // this eliminates our need to authenticate on the actual pages - if (!($root->check_access())) { + if (!($extpage->check_access())) { error(get_string('accessdenied', 'admin')); die; } + page_map_class(PAGE_ADMIN, 'page_admin'); + $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number + $PAGE->init_extra($section); // hack alert! + $adminediting = optional_param('adminedit', -1, PARAM_BOOL); if (!isset($USER->adminediting)) { @@ -3082,13 +3838,17 @@ function admin_externalpage_setup($section) { $USER->adminediting = false; } } - } /** - * TODO document + * Print header for admin page + * @param string $focus focus element */ -function admin_externalpage_print_header() { +function admin_externalpage_print_header($focus='') { + + if (!is_string($focus)) { + $focus = ''; // BC compatibility, there used to be adminroot parameter + } global $CFG, $PAGE, $SITE, $THEME; @@ -3104,7 +3864,7 @@ function admin_externalpage_print_header() { blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH); - $PAGE->print_header(); + $PAGE->print_header('', $focus); echo ''; $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable; @@ -3144,6 +3904,9 @@ function admin_externalpage_print_header() { } } +/** + * Print footer on admin page - please use normal print_footer() instead + */ function admin_externalpage_print_footer() { global $CFG, $PAGE, $SITE, $THEME; @@ -3199,22 +3962,48 @@ function admin_externalpage_print_footer() { print_footer(); } -function admin_get_root() { +/** + * Returns the reference to admin tree root + * @return reference + */ +function &admin_get_root($reload=false, $requirefulltree=true) { global $CFG; - static $ADMIN; + static $ADMIN = NULL; + + if (!is_null($ADMIN)) { + $olderrors = $ADMIN->errors; + $oldsearch = $ADMIN->search; + $oldfulltree = $ADMIN->fulltree; + } else { + $olderrors = array(); + $oldsearch = ''; + $oldfulltree = false; + } + + if ($reload or ($requirefulltree and !$oldfulltree)) { + $ADMIN = NULL; + } - if (!isset($ADMIN)) { + if (is_null($ADMIN)) { // start the admin tree! - $ADMIN = new admin_category('root', get_string("administration")); - // we process this file first to get categories up and running - include($CFG->dirroot . '/'.$CFG->admin.'/settings/top.php'); + $ADMIN = new admin_root(); + // array of error messages and search query + $ADMIN->errors = $olderrors; + $ADMIN->search = $oldsearch; + if ($requirefulltree) { + $ADMIN->fulltree = true; + } else { + $ADMIN->fulltree = $oldfulltree; + } - // now we process all other files in admin/settings to build the - // admin tree - foreach (glob($CFG->dirroot . '/'.$CFG->admin.'/settings/*.php') as $file) { - if ($file != $CFG->dirroot . '/'.$CFG->admin.'/settings/top.php') { - include_once($file); + // we process this file first to create categories first and in correct order + require($CFG->dirroot.'/'.$CFG->admin.'/settings/top.php'); + + // now we process all other files in admin/settings to build the admin tree + foreach (glob($CFG->dirroot.'/'.$CFG->admin.'/settings/*.php') as $file) { + if ($file != $CFG->dirroot.'/'.$CFG->admin.'/settings/top.php') { + include($file); } } } @@ -3226,25 +4015,26 @@ function admin_get_root() { /** * This function applies default settings. - * @param object $node + * @param object $node, NULL means complete tree * @param bool $uncoditional if true overrides all values with defaults * @return void */ -function apply_default_settings(&$node, $unconditional=true) { - +function admin_apply_default_settings($node=NULL, $unconditional=true) { global $CFG; + if (is_null($node)) { + $node =& admin_get_root(); + } + if (is_a($node, 'admin_category')) { $entries = array_keys($node->children); foreach ($entries as $entry) { - apply_default_settings($node->children[$entry]); + admin_apply_default_settings($node->children[$entry], $unconditional); } - return; - } - if (is_a($node, 'admin_settingpage')) { + } else if (is_a($node, 'admin_settingpage')) { foreach ($node->settings as $setting) { - if (!$unconditional and !is_null($setting->get_setting)) { + if (!$unconditional and !is_null($setting->get_setting())) { //do not override existing defaults continue; } @@ -3253,53 +4043,241 @@ function apply_default_settings(&$node, $unconditional=true) { // no value yet - default maybe applied after admin user creation or in upgradesettings continue; } - $CFG->{$setting->name} = $defaultsetting; $setting->write_setting($defaultsetting); - unset($setting); // needed to prevent odd (imho) reference behaviour - // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399 } - return; + } +} + +/** + * Store changed settings, this function updates the errors variable in $ADMIN + * @param object $formdata from form (without magic quotes) + * @return int number of changed settings + */ +function admin_write_settings($formdata) { + global $CFG, $SITE, $COURSE; + + $olddbsessions = !empty($CFG->dbsessions); + $formdata = (array)stripslashes_recursive($formdata); + + $data = array(); + foreach ($formdata as $fullname=>$value) { + if (strpos($fullname, 's_') !== 0) { + continue; // not a config value + } + $data[$fullname] = $value; + } + + $adminroot =& admin_get_root(); + $settings = admin_find_write_settings($adminroot, $data); + + $count = 0; + foreach ($settings as $fullname=>$setting) { + $original = serialize($setting->get_setting()); // comparison must work for arrays too + $error = $setting->write_setting($data[$fullname]); + if ($error !== '') { + $adminroot->errors[$fullname] = new object(); + $adminroot->errors[$fullname]->data = $data[$fullname]; + $adminroot->errors[$fullname]->id = $setting->get_id(); + $adminroot->errors[$fullname]->error = $error; + } + if ($original !== serialize($setting->get_setting())) { + $count++; + $callbackfunction = $setting->updatedcallback; + if (function_exists($callbackfunction)) { + $callbackfunction($fullname); + } + } + } + + if ($olddbsessions != !empty($CFG->dbsessions)) { + require_logout(); } - return; + // now update $SITE - it might have been changed + $SITE = get_record('course', 'id', $SITE->id); + $COURSE = clone($SITE); + // now reload all settings - some of them might depend on the changed + admin_get_root(true); + return $count; } -// n.b. this function unconditionally applies default settings -function apply_default_exception_settings($defaults) { +/** + * Internal recursive function - finds all settings from submitted form + */ +function admin_find_write_settings($node, $data) { + $return = array(); + + if (empty($data)) { + return $return; + } + + if (is_a($node, 'admin_category')) { + $entries = array_keys($node->children); + foreach ($entries as $entry) { + $return = array_merge($return, admin_find_write_settings($node->children[$entry], $data)); + } + + } else if (is_a($node, 'admin_settingpage')) { + foreach ($node->settings as $setting) { + $fullname = $setting->get_full_name(); + if (array_key_exists($fullname, $data)) { + $return[$fullname] = $setting; + } + } + + } + + return $return; +} +/** + * Internal function - prints the search results + */ +function admin_search_settings_html($query) { global $CFG; - foreach($defaults as $key => $value) { - $CFG->$key = $value; - set_config($key, $value); + $textlib = textlib_get_instance(); + if ($textlib->strlen($query) < 2) { + return ''; + } + $query = $textlib->strtolower($query); + + $adminroot =& admin_get_root(); + $findings = $adminroot->search($query); + $return = ''; + + foreach ($findings as $found) { + $page = $found->page; + $settings = $found->settings; + if ($page->hidden) { + continue; + } + if (is_a($page, 'admin_externalpage')) { + $return .= print_heading(get_string('searchresults','admin').' - '.highlight($query, $page->visiblename).'', '', 2, 'main', true); + } else if (is_a($page, 'admin_settingpage')) { + $return .= print_heading(get_string('searchresults','admin').' - '.highlight($query, $page->visiblename).'', '', 2, 'main', true); + } else { + continue; + } + if (!empty($settings)) { + $return .= '
    '."\n"; + foreach ($settings as $setting) { + $return .= '
    '."\n"; + $fullname = $setting->get_full_name(); + if (array_key_exists($fullname, $adminroot->errors)) { + $data = $adminroot->errors[$fullname]->data; + } else { + $data = $setting->get_setting(); + if (is_null($data)) { + $data = $setting->get_defaultsetting(); + } + } + $return .= highlight($query, $setting->output_html($data)); + } + $return .= '
    '; + } + } + + return $return; +} + +/** + * Internal function - prints list of uninitialised settings + */ +function admin_output_new_settings_by_page($node) { + $return = ''; + + if (is_a($node, 'admin_category')) { + $entries = array_keys($node->children); + foreach ($entries as $entry) { + $return .= admin_output_new_settings_by_page($node->children[$entry]); + } + + } else if (is_a($node, 'admin_settingpage')) { + $newsettings = array(); + foreach ($node->settings as $setting) { + if (is_null($setting->get_setting())) { + $newsettings[] = $setting; + } + } + if (count($newsettings) > 0) { + $adminroot =& admin_get_root(); + $return .= print_heading(get_string('upgradesettings','admin').' - '.$node->visiblename, '', 2, 'main', true); + $return .= '
    '."\n"; + foreach ($newsettings as $setting) { + $fullname = $setting->get_full_name(); + if (array_key_exists($fullname, $adminroot->errors)) { + $data = $adminroot->errors[$fullname]->data; + } else { + $data = $setting->get_setting(); + if (is_null($data)) { + $data = $setting->get_defaultsetting(); + } + } + $return .= '
    '."\n"; + $return .= $setting->output_html($data); + } + $return .= '
    '; + } } + return $return; +} + +/** + * Unconditionally applies default admin settings in main config table + * @param array $defaults array of string values + */ +function apply_default_exception_settings($defaults) { + foreach($defaults as $key => $value) { + set_config($key, $value, NULL); + } } -function format_admin_setting($name, $title='', $form='', $description='', $label=true) { +/** + * Format admin settings + * @param string $object setting + * @param string $title label element + * @param string $form form fragment, html code + * @param string $description + * @param bool $label link label to id + */ +function format_admin_setting($setting, $title='', $form='', $description='', $label=true) { + global $CFG; + + $name = $setting->name; + $fullname = $setting->get_full_name(); // sometimes the id is not id_s_name, but id_s_name_m or something, and this does not validate if ($label) { - $labelfor = 'for = "id_s_'.$name.'"'; + $labelfor = 'for = "'.$setting->get_id().'"'; } else { $labelfor = ''; } - $str = "\n". - '
    '."\n". - ''."\n". - $form."\n". - '
    '.$description.'
    '."\n". - '
    '. - "\n\n"; + if (empty($setting->plugin) and array_key_exists($name, $CFG->config_php_settings)) { + $override = ''.get_string('configoverride', 'admin').''; + } else { + $override = ''; + } + + $str = ' +
    +
    +
    '.$form.'
    +
    '.$description.'
    +
    '; + + $adminroot =& admin_get_root(); + if (array_key_exists($fullname, $adminroot->errors)) { + $str = '
    '.$adminroot->errors[$fullname]->error.''.$str.'
    '; + } return $str; } -/* +/** * Try to upgrade the given language pack (or current language) * If it doesn't work, fail silently and return false */ @@ -3338,58 +4316,55 @@ function upgrade_language_pack($lang='') { * Based on find_new_settings{@link ()} in upgradesettings.php * Looks to find any admin settings that have not been initialized. Returns 1 if it finds any. * - * @param string &$node The node at which to start searching. - * @return int Returns 1 if any settings haven't been initialised, 0 if they all have + * @param string $node The node at which to start searching. + * @return boolen true if any settings haven't been initialised, false if they all have */ -function any_new_admin_settings(&$node) { +function any_new_admin_settings($node) { if (is_a($node, 'admin_category')) { $entries = array_keys($node->children); foreach ($entries as $entry) { - if( any_new_admin_settings($node->children[$entry]) ){ - return 1; + if (any_new_admin_settings($node->children[$entry])){ + return true; } } - } - if (is_a($node, 'admin_settingpage')) { + } else if (is_a($node, 'admin_settingpage')) { foreach ($node->settings as $setting) { if ($setting->get_setting() === NULL) { - return 1; + return true; } } } - - return 0; - + return false; } /** * Moved from admin/replace.php so that we can use this in cron - * @param string $search - string to look for - * @param string $replace - string to replace + * @param string $search - string to look for (with magic quotes) + * @param string $replace - string to replace (with magic quotes) * @return bool - success or fail */ function db_replace($search, $replace) { - + global $db, $CFG; - + /// Turn off time limits, sometimes upgrades can be slow. @set_time_limit(0); @ob_implicit_flush(true); while(@ob_end_flush()); - + if (!$tables = $db->Metatables() ) { // No tables yet at all. return false; } foreach ($tables as $table) { - + if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these continue; } - + if ($columns = $db->MetaColumns($table, false)) { foreach ($columns as $column => $data) { if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only @@ -3400,7 +4375,7 @@ function db_replace($search, $replace) { } } } - + return true; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 528b931f66..a5f4eac8b3 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -611,11 +611,17 @@ function set_config($name, $value, $plugin=NULL) { global $CFG; if (empty($plugin)) { - $CFG->$name = $value; // So it's defined for this invocation at least + if (!array_key_exists($name, $CFG->config_php_settings)) { + // So it's defined for this invocation at least + if (is_null($value)) { + unset($CFG->$name); + } else { + $CFG->$name = $value; + } + } if (get_field('config', 'name', 'name', $name)) { if ($value===null) { - unset($CFG->$name); return delete_records('config', 'name', $name); } else { return set_field('config', 'value', addslashes($value), 'name', $name); @@ -697,13 +703,8 @@ function get_config($plugin=NULL, $name=NULL) { foreach ($configs as $config) { if (!isset($localcfg[$config->name])) { $localcfg[$config->name] = $config->value; - } else { - if ($localcfg[$config->name] != $config->value ) { - // complain if the DB has a different - // value than config.php does - error_log("\$CFG->{$config->name} in config.php ({$localcfg[$config->name]}) overrides database setting ({$config->value})"); - } } + // do not complain anymore if config.php overrides settings from db } $localcfg = (object)$localcfg; diff --git a/lib/setup.php b/lib/setup.php index b3535cd07d..bd70cdadf1 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -89,6 +89,9 @@ global $HTTPSPAGEREQUIRED; die; } +/// store settings from config.php in array in $CFG - we can use it later to detect problems and overrides + $CFG->config_php_settings = (array)$CFG; + /// Set httpswwwroot default value (this variable will replace $CFG->wwwroot /// inside some URLs used in HTTPSPAGEREQUIRED pages. $CFG->httpswwwroot = $CFG->wwwroot; diff --git a/mod/assignment/config.html b/mod/assignment/config.html deleted file mode 100644 index 6eedcdff2d..0000000000 --- a/mod/assignment/config.html +++ /dev/null @@ -1,38 +0,0 @@ - -
    - - -
    - - - - - - - - - - - - - - - -
    assignment_maxbytes:maxbytes); - choose_from_menu ($choices, "assignment_maxbytes", $CFG->assignment_maxbytes, ""); - ?> - - -
    assignment_itemstocount:assignment_itemstocount, ""); - ?> - - -
    - " />
    - - diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 085ae937c1..853a97dfee 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -8,13 +8,6 @@ DEFINE ('ASSIGNMENT_COUNT_WORDS', 1); DEFINE ('ASSIGNMENT_COUNT_LETTERS', 2); -if (!isset($CFG->assignment_maxbytes)) { - set_config("assignment_maxbytes", 1024000); // Default maximum size for all assignments -} -if (!isset($CFG->assignment_itemstocount)) { - set_config("assignment_itemstocount", ASSIGNMENT_COUNT_WORDS); // Default item to count -} - /** * Standard base class for all assignment submodules (assignment types). */ diff --git a/mod/assignment/settings.php b/mod/assignment/settings.php new file mode 100644 index 0000000000..52c5ccae04 --- /dev/null +++ b/mod/assignment/settings.php @@ -0,0 +1,13 @@ +dirroot.'/mod/assignment/lib.php'); + +$settings->add(new admin_setting_configselect('assignment_maxbytes', get_string('maximumsize', 'assignment'), + get_string('configmaxbytes', 'assignment'), 1048576, get_max_upload_sizes($CFG->maxbytes))); + +$options = array(ASSIGNMENT_COUNT_WORDS => trim(get_string('numwords', '')), + ASSIGNMENT_COUNT_LETTERS => trim(get_string('numletters', ''))); +$settings->add(new admin_setting_configselect('assignment_itemstocount', get_string('itemstocount', 'assignment'), + get_string('configitemstocount', 'assignment'), ASSIGNMENT_COUNT_WORDS, $options)); + +?> diff --git a/mod/chat/config.html b/mod/chat/config.html deleted file mode 100644 index c3796c2f01..0000000000 --- a/mod/chat/config.html +++ /dev/null @@ -1,130 +0,0 @@ -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    ()
    -
    chat_method: - chat_method, "", "", ""); - ?> - - -
    chat_refresh_userlist: - - - -
    chat_old_ping: - - - -

    -
    -
    ()
    -
    chat_refresh_room: - - - -
    chat_normal_updatemode: -chat_normal_updatemode, "", "", ""); -?> - - -

    -
    -
    ()
    -
    chat_serverhost: - - - -
    chat_serverip: - - - -
    chat_serverport: - - - -
    chat_servermax: - - - -
    - " />
    -
    -
    diff --git a/mod/chat/lib.php b/mod/chat/lib.php index a2faa7b64c..03b570b402 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -1,36 +1,8 @@ libdir.'/pagelib.php'); -if (!isset($CFG->chat_refresh_room)) { - set_config("chat_refresh_room", 5); -} -if (!isset($CFG->chat_refresh_userlist)) { - set_config("chat_refresh_userlist", 10); -} -if (!isset($CFG->chat_old_ping)) { - set_config("chat_old_ping", 35); -} -if (!isset($CFG->chat_method)) { - set_config("chat_method", "header_js"); -} -if (!isset($CFG->chat_normal_updatemode)) { - set_config("chat_normal_updatemode", 'jsupdate'); -} -if (!isset($CFG->chat_serverhost)) { - set_config("chat_serverhost", $_SERVER['HTTP_HOST']); -} -if (!isset($CFG->chat_serverip)) { - set_config("chat_serverip", '127.0.0.1'); -} -if (!isset($CFG->chat_serverport)) { - set_config("chat_serverport", 9111); -} -if (!isset($CFG->chat_servermax)) { - set_config("chat_servermax", 100); -} // The HTML head for the message window to start with ( is used to get some browsers starting with output $CHAT_HTMLHEAD = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; @@ -366,7 +338,7 @@ function chat_get_latest_message($chatid, $groupid=0) { $result = rs_fetch_record($rs); - rs_close($rs); + rs_close($rs); return $result; } diff --git a/mod/chat/settings.php b/mod/chat/settings.php new file mode 100644 index 0000000000..7769d5af79 --- /dev/null +++ b/mod/chat/settings.php @@ -0,0 +1,47 @@ +add(new admin_setting_heading('chat_method_heading', get_string('generalconfig', 'chat'), + get_string('explaingeneralconfig', 'chat'))); + +$options = array(); +$options['header_js'] = get_string('methodnormal', 'chat'); +$options['sockets'] = get_string('methoddaemon', 'chat'); +$settings->add(new admin_setting_configselect('chat_method', get_string('method', 'chat'), + get_string('configmethod', 'chat'), 'header_js', $options)); + +$settings->add(new admin_setting_configtext('chat_refresh_userlist', get_string('refreshuserlist', 'chat'), + get_string('configrefreshuserlist', 'chat'), 10, PARAM_INT)); + +$settings->add(new admin_setting_configtext('chat_old_ping', get_string('oldping', 'chat'), + get_string('configoldping', 'chat'), 35, PARAM_INT)); + + +$settings->add(new admin_setting_heading('chat_normal_heading', get_string('methodnormal', 'chat'), + get_string('explainmethodnormal', 'chat'))); + +$settings->add(new admin_setting_configtext('chat_refresh_room', get_string('refreshroom', 'chat'), + get_string('configrefreshroom', 'chat'), 5, PARAM_INT)); + +$options = array(); +$options['jsupdate'] = get_string('normalkeepalive', 'chat'); +$options['jsupdated'] = get_string('normalstream', 'chat'); +$settings->add(new admin_setting_configselect('chat_normal_updatemode', get_string('updatemethod', 'chat'), + get_string('confignormalupdatemode', 'chat'), 'jsupdate', $options)); + + +$settings->add(new admin_setting_heading('chat_daemon_heading', get_string('methoddaemon', 'chat'), + get_string('explainmethoddaemon', 'chat'))); + +$settings->add(new admin_setting_configtext('chat_serverhost', get_string('serverhost', 'chat'), + get_string('configserverhost', 'chat'), $_SERVER['HTTP_HOST'])); + +$settings->add(new admin_setting_configtext('chat_serverip', get_string('serverip', 'chat'), + get_string('configserverip', 'chat'), '127.0.0.1')); + +$settings->add(new admin_setting_configtext('chat_serverport', get_string('serverport', 'chat'), + get_string('configserverport', 'chat'), 9111, PARAM_INT)); + +$settings->add(new admin_setting_configtext('chat_servermax', get_string('servermax', 'chat'), + get_string('configservermax', 'chat'), 100, PARAM_INT)); + +?> diff --git a/mod/data/config.html b/mod/data/config.html deleted file mode 100644 index 422f822d84..0000000000 --- a/mod/data/config.html +++ /dev/null @@ -1,44 +0,0 @@ -
    -
    - - - - - - - - - - - - - -
    data_enablerssfeeds: - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - echo get_string('rssglobaldisabled', 'data'); - } else { - unset($options); - $options[0] = get_string("no"); - $options[1] = get_string("yes"); - - $data_enablerssfeeds = false; - if (isset($CFG->data_enablerssfeeds) && $CFG->data_enablerssfeeds == 1) { - $data_enablerssfeeds = true; - } - - - choose_from_menu ($options, "data_enablerssfeeds", $data_enablerssfeeds, "", "", ""); - } - ?> - - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - print_string("configenablerssfeedsdisabled"); - } - ?> -
    - " />
    -
    -
    diff --git a/mod/data/settings.php b/mod/data/settings.php new file mode 100644 index 0000000000..8b2af4e06b --- /dev/null +++ b/mod/data/settings.php @@ -0,0 +1,14 @@ +enablerssfeeds)) { + $options = array(0 => get_string('rssglobaldisabled', 'admin')); + $str = get_string('configenablerssfeeds', 'data').'
    '.get_string('configenablerssfeedsdisabled2', 'admin'); + +} else { + $options = array(0=>get_string('no'), 1=>get_string('yes')); + $str = get_string('configenablerssfeeds', 'data'); +} +$settings->add(new admin_setting_configselect('data_enablerssfeeds', get_string('enablerssfeeds', 'admin'), + $str, 0, $options)); + +?> diff --git a/mod/forum/config.html b/mod/forum/config.html deleted file mode 100644 index e272eba0d6..0000000000 --- a/mod/forum/config.html +++ /dev/null @@ -1,196 +0,0 @@ -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    forum_displaymode: - forum_displaymode, "", "", ""); ?> - - -
    forum_replytouser: - forum_replytouser, "", "", ""); - ?> - - -
    forum_shortpost: - - - -
    forum_longpost: - - - -
    forum_manydiscussions: - - - -
    forum_maxbytes:maxbytes); - choose_from_menu ($choices, "forum_maxbytes", $CFG->forum_maxbytes, ""); - ?> - - -
    forum_trackreadposts: - forum_trackreadposts, "", "", ""); - ?> - - -
    forum_oldpostdays: - - - -
    forum_usermarksread: - forum_usermarksread, "", "", ""); - ?> - - -
    forum_cleanreadtime: - forum_cleanreadtime, "", "", ""); - ?> - - -
    forum_enablerssfeeds: - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - print_string("no"); - } else { - unset($options); - $options[0] = get_string("no"); - $options[1] = get_string("yes"); - - $forum_enablerssfeeds = false; - if (isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds == 1) { - $forum_enablerssfeeds = true; - } - - - choose_from_menu ($options, "forum_enablerssfeeds", $forum_enablerssfeeds, "", "", ""); - } - ?> - - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - print_string("configenablerssfeedsdisabled"); - } - ?> -
    forum_enabletimedposts: - forum_enabletimedposts, "", "", ""); - ?> - - -
    - " />
    -
    -
    diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 44ecbf6d54..b56c3cd57e 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -45,54 +45,6 @@ $FORUM_OPEN_MODES = array ('2' => get_string('openmode2', 'forum'), '1' => get_string('openmode1', 'forum'), '0' => get_string('openmode0', 'forum') ); -if (!isset($CFG->forum_displaymode)) { - set_config('forum_displaymode', FORUM_MODE_NESTED); -} - -if (!isset($CFG->forum_shortpost)) { - set_config('forum_shortpost', 300); // Less non-HTML characters than this is short -} - -if (!isset($CFG->forum_longpost)) { - set_config('forum_longpost', 600); // More non-HTML characters than this is long -} - -if (!isset($CFG->forum_manydiscussions)) { - set_config('forum_manydiscussions', 100); // Number of discussions on a page -} - -if (!isset($CFG->forum_maxbytes)) { - set_config('forum_maxbytes', 512000); // Default maximum size for all forums -} - -if (!isset($CFG->forum_trackreadposts)) { - set_config('forum_trackreadposts', true); // Default whether user needs to mark a post as read -} - -if (!isset($CFG->forum_oldpostdays)) { - set_config('forum_oldpostdays', 14); // Default number of days that a post is considered old -} - -if (!isset($CFG->forum_usermarksread)) { - set_config('forum_usermarksread', false); // Default whether user needs to mark a post as read -} - -if (!isset($CFG->forum_cleanreadtime)) { - set_config('forum_cleanreadtime', 2); // Default time (hour) to execute 'clean_read_records' cron -} - -if (!isset($CFG->forum_replytouser)) { - set_config('forum_replytouser', true); // Default maximum size for all forums -} - -if (empty($USER->id) or isguest()) { - $CFG->forum_trackreadposts = false; // This feature never works when a user isn't logged in -} - -if (!isset($CFG->forum_enabletimedposts)) { // Newish feature that is not quite ready for production in 1.6 - $CFG->forum_enabletimedposts = false; -} - /// STANDARD FUNCTIONS /////////////////////////////////////////////////////////// diff --git a/mod/forum/settings.php b/mod/forum/settings.php new file mode 100644 index 0000000000..d285fe2c70 --- /dev/null +++ b/mod/forum/settings.php @@ -0,0 +1,63 @@ +dirroot.'/mod/forum/lib.php'); + +global $FORUM_LAYOUT_MODES; // make sure we have the pesky global + +$settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'), + get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, $FORUM_LAYOUT_MODES)); + +$settings->add(new admin_setting_configcheckbox('forum_replytouser', get_string('replytouser', 'forum'), + get_string('configreplytouser', 'forum'), 1)); + +// Less non-HTML characters than this is short +$settings->add(new admin_setting_configtext('forum_shortpost', get_string('shortpost', 'forum'), + get_string('configshortpost', 'forum'), 300, PARAM_INT)); + +// More non-HTML characters than this is long +$settings->add(new admin_setting_configtext('forum_longpost', get_string('longpost', 'forum'), + get_string('configlongpost', 'forum'), 600, PARAM_INT)); + +// Number of discussions on a page +$settings->add(new admin_setting_configtext('forum_manydiscussions', get_string('manydiscussions', 'forum'), + get_string('configmanydiscussions', 'forum'), 100, PARAM_INT)); + +$settings->add(new admin_setting_configselect('forum_maxbytes', get_string('maxattachmentsize', 'forum'), + get_string('configmaxbytes', 'forum'), 512000, get_max_upload_sizes($CFG->maxbytes))); + +// Default whether user needs to mark a post as read +$settings->add(new admin_setting_configcheckbox('forum_trackreadposts', get_string('trackforum', 'forum'), + get_string('configtrackreadposts', 'forum'), 1)); + +// Default number of days that a post is considered old +$settings->add(new admin_setting_configtext('forum_oldpostdays', get_string('oldpostdays', 'forum'), + get_string('configoldpostdays', 'forum'), 14, PARAM_INT)); + +// Default whether user needs to mark a post as read +$settings->add(new admin_setting_configcheckbox('forum_usermarksread', get_string('usermarksread', 'forum'), + get_string('configusermarksread', 'forum'), 0)); + +// Default time (hour) to execute 'clean_read_records' cron +$options = array(); +for ($i=0; $i<24; $i++) { + $options[$i] = $i; +} +$settings->add(new admin_setting_configselect('forum_cleanreadtime', get_string('cleanreadtime', 'forum'), + get_string('configcleanreadtime', 'forum'), 2, $options)); + + +if (empty($CFG->enablerssfeeds)) { + $options = array(0 => get_string('rssglobaldisabled', 'admin')); + $str = get_string('configenablerssfeeds', 'forum').'
    '.get_string('configenablerssfeedsdisabled2', 'admin'); + +} else { + $options = array(0=>get_string('no'), 1=>get_string('yes')); + $str = get_string('configenablerssfeeds', 'forum'); +} +$settings->add(new admin_setting_configselect('forum_enablerssfeeds', get_string('enablerssfeeds', 'admin'), + $str, 0, $options)); + +$settings->add(new admin_setting_configcheckbox('forum_enabletimedposts', get_string('timedposts', 'forum'), + get_string('configenabletimedposts', 'forum'), 0)); + +?> diff --git a/mod/glossary/config.html b/mod/glossary/config.html deleted file mode 100644 index 5180488fb2..0000000000 --- a/mod/glossary/config.html +++ /dev/null @@ -1,249 +0,0 @@ - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - '; - echo ''; - $eicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\">\"".get_string("edit")."\""; - if ( $recformat->visible ) { - $vtitle = get_string("hide"); - $vicon = "hide.gif"; - } else { - $vtitle = get_string("show"); - $vicon = "show.gif"; - } - $vicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\">\"$vtitle\""; - - echo ''; - echo ''; - } - print_simple_box_end(); - -?> - - - - - - -
    glossary_entbypage: - - - -
    glossary_dupentries: - - - -
    glossary_allowcomments: - - - -
    glossary_linkbydefault: - - - -
    glossary_defaultapproval: - - - -
    glossary_enablerssfeeds: - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - print_string("no"); - } else { - unset($options); - $options[0] = get_string("no"); - $options[1] = get_string("yes"); - - $glossary_enablerssfeeds = false; - if (isset($CFG->glossary_enablerssfeeds) && $CFG->glossary_enablerssfeeds == 1) { - $glossary_enablerssfeeds = true; - } - - choose_from_menu ($options, "glossary_enablerssfeeds", $glossary_enablerssfeeds, "", "", ""); - } - ?> - - enablerssfeeds) || $CFG->enablerssfeeds == 0) { - print_string("configenablerssfeedsdisabled"); - } - ?> -
    glossary_linkentries: - - - -
    glossary_casesensitive: - - - -
    glossary_fullmatch: - - - -
    -id] = get_string("displayformat$format->name", "glossary"); - } - asort($formats); - - print_simple_box_start('center'); - foreach ($formats as $formatid=>$formatname) { - $recformat = get_record('glossary_formats','id',$formatid); - echo '
    ' . $formatname . '' . $eicon . '  ' . $vicon . '
    - " />
    -
    -
    diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php index 2ae1104efb..e8e22839bb 100644 --- a/mod/glossary/formats.php +++ b/mod/glossary/formats.php @@ -2,18 +2,13 @@ /// This file allows to manage the default behaviour of the display formats require_once("../../config.php"); + require_once($CFG->libdir.'/adminlib.php'); require_once("lib.php"); - global $CFG; - $id = required_param('id', PARAM_INT); + $id = required_param('id', PARAM_INT); $mode = optional_param('mode'); - require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); - - if (!$site = get_site()) { - error("Site isn't defined!"); - } + admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it if ( !$displayformat = get_record("glossary_formats","id",$id) ) { error ("Invalid Glossary Format"); @@ -29,7 +24,7 @@ } update_record("glossary_formats",$displayformat); } - redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats"); + redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header"); die; } elseif ( $mode == 'edit' and $form) { @@ -41,26 +36,14 @@ $displayformat->sortorder = $form->sortorder; update_record("glossary_formats",$displayformat); - redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats"); + redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header"); die; } - $stradmin = get_string("administration"); - $strconfiguration = get_string("configuration"); - $strmanagemodules = get_string("managemodules"); $strmodulename = get_string("modulename", "glossary"); $strdisplayformats = get_string("displayformats","glossary"); - $navlinks = array(); - $navlinks[] = array('name' => $stradmin, 'link' => "../../$CFG->admin/index.php", 'type' => 'core'); - $navlinks[] = array('name' => $strconfiguration, 'link' => "../../$CFG->admin/configure.php", 'type' => 'core'); - $navlinks[] = array('name' => $strmanagemodules, 'link' => "../../$CFG->admin/modules.php", 'type' => 'core'); - $navlinks[] = array('name' => $strmodulename, 'link' => "../../$CFG->admin/module.php?module=glossary&sesskey=$USER->sesskey", 'type' => 'core'); - $navlinks[] = array('name' => $strdisplayformats, 'link' => '', 'type' => 'core'); - - $navigation = build_navigation($navlinks); - - print_header("$strmodulename: $strconfiguration", $site->fullname, $navigation); + admin_externalpage_print_header(); print_heading($strmodulename . ': ' . get_string("displayformats","glossary")); diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index f3058c9fff..a57f80ce72 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -18,32 +18,6 @@ define("GLOSSARY_IMPORT_VIEW", 5); define("GLOSSARY_EXPORT_VIEW", 6); define("GLOSSARY_APPROVAL_VIEW", 7); -//Check for global configure default variables - -if (!isset($CFG->glossary_studentspost)) { - set_config("glossary_studentspost", 1); // Students can post entries. -} - -if (!isset($CFG->glossary_dupentries)) { - set_config("glossary_dupentries", 0); // Duplicate entries are not allowed. -} - -if (!isset($CFG->glossary_allowcomments)) { - set_config("glossary_allowcomments", 0); // Comments are not allowed. -} - -if (!isset($CFG->glossary_linkbydefault)) { - set_config("glossary_linkbydefault", 1); // Linking entries is enabled. -} - -if (!isset($CFG->glossary_defaultapproval)) { - set_config("glossary_defaultapproval", 1); // Entries are approved. -} - -if (!isset($CFG->glossary_entbypage)) { - set_config("glossary_entbypage", 10); // 10 entries are showed. -} - /// STANDARD FUNCTIONS /////////////////////////////////////////////////////////// function glossary_add_instance($glossary) { diff --git a/mod/glossary/settings.php b/mod/glossary/settings.php new file mode 100644 index 0000000000..ac23640c3e --- /dev/null +++ b/mod/glossary/settings.php @@ -0,0 +1,78 @@ +dirroot.'/mod/glossary/lib.php'); + +$settings->add(new admin_setting_heading('glossary_normal_header', get_string('glossaryleveldefaultsettings', 'glossary'), '')); + +$settings->add(new admin_setting_configtext('glossary_entbypage', get_string('entbypage', 'glossary'), + get_string('entbypage', 'glossary'), 10, PARAM_INT)); + + +$settings->add(new admin_setting_configcheckbox('glossary_dupentries', get_string('allowduplicatedentries', 'glossary'), + get_string('cnfallowdupentries', 'glossary'), 0)); + +$settings->add(new admin_setting_configcheckbox('glossary_allowcomments', get_string('allowcomments', 'glossary'), + get_string('cnfallowcomments', 'glossary'), 0)); + +$settings->add(new admin_setting_configcheckbox('glossary_linkbydefault', get_string('usedynalink', 'glossary'), + get_string('cnflinkglossaries', 'glossary'), 1)); + +$settings->add(new admin_setting_configcheckbox('glossary_defaultapproval', get_string('defaultapproval', 'glossary'), + get_string('cnfapprovalstatus', 'glossary'), 1)); + + +if (empty($CFG->enablerssfeeds)) { + $options = array(0 => get_string('rssglobaldisabled', 'admin')); + $str = get_string('configenablerssfeeds', 'glossary').'
    '.get_string('configenablerssfeedsdisabled2', 'admin'); + +} else { + $options = array(0=>get_string('no'), 1=>get_string('yes')); + $str = get_string('configenablerssfeeds', 'glossary'); +} +$settings->add(new admin_setting_configselect('glossary_enablerssfeeds', get_string('enablerssfeeds', 'admin'), + $str, 0, $options)); + + +$settings->add(new admin_setting_heading('glossary_levdev_header', get_string('entryleveldefaultsettings', 'glossary'), '')); + +$settings->add(new admin_setting_configcheckbox('glossary_linkentries', get_string('usedynalink', 'glossary'), + get_string('cnflinkentry', 'glossary'), 0)); + +$settings->add(new admin_setting_configcheckbox('glossary_casesensitive', get_string('casesensitive', 'glossary'), + get_string('cnfcasesensitive', 'glossary'), 0)); + +$settings->add(new admin_setting_configcheckbox('glossary_fullmatch', get_string('fullmatch', 'glossary'), + get_string('cnffullmatch', 'glossary'), 0)); + + +//Update and get available formats +$recformats = glossary_get_available_formats(); +$formats = array(); +//Take names +foreach ($recformats as $format) { + $formats[$format->id] = get_string("displayformat$format->name", "glossary"); +} +asort($formats); + +$str = ''; +foreach ($formats as $formatid=>$formatname) { + $recformat = get_record('glossary_formats','id',$formatid); + $str .= ''; + $str .= ''; + $eicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\">\"".get_string("edit")."\""; + if ( $recformat->visible ) { + $vtitle = get_string("hide"); + $vicon = "hide.gif"; + } else { + $vtitle = get_string("show"); + $vicon = "show.gif"; + } + $vicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\">\"$vtitle\""; + + $str .= ''; + $str .= ''; +} +$str .= '
    ' . $formatname . ''.$eicon.'  '.$vicon.'
    '; + +$settings->add(new admin_setting_heading('glossary_formats_header', get_string('displayformatssetup', 'glossary'), $str)); + diff --git a/mod/hotpot/mediaplayers/moodle/filter.php b/mod/hotpot/mediaplayers/moodle/filter.php index ab77fb2b66..e83716097b 100644 --- a/mod/hotpot/mediaplayers/moodle/filter.php +++ b/mod/hotpot/mediaplayers/moodle/filter.php @@ -13,8 +13,6 @@ function hotpot_mediaplayer_moodle(&$hotpot, $text) { global $CFG, $THEME; - include $CFG->dirroot.'/filter/mediaplugin/defaultsettings.php'; - if ($CFG->filter_mediaplugin_enable_mp3) { static $c; @@ -130,7 +128,7 @@ function hotpot_mediaplayer_moodle(&$hotpot, $text) { $replace = '\\0

    "; $replace .= ''; diff --git a/mod/resource/config.html b/mod/resource/config.html deleted file mode 100644 index 62c7080cd2..0000000000 --- a/mod/resource/config.html +++ /dev/null @@ -1,122 +0,0 @@ -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; - echo ""; - echo ""; - echo ""; - echo ""; - } -?> - - - - - - - - - - - - - -
    resource_framesize: - - - -
    resource_websearch: - - - -
    resource_defaulturl: - - - -
    resource_secretphrase: - - - -
    resource_allowlocalfiles: - resource_allowlocalfiles, ""); - ?> - - -
    resource_popup: - resource_popup, ""); - ?> - - -
    $defaultvalue:"; - if ($optionname == "height" or $optionname == "width") { - echo "$defaultvalue."\" />"; - } else { - choose_from_menu ($choices, $defaultvalue, $CFG->$defaultvalue, ""); - } - echo ""; - print_string("configpopup$optionname", "resource"); - echo "
    resource_autofilerename: - resource_autofilerename, ""); - ?> - - -
    resource_blockdeletingfile: - resource_blockdeletingfile, ""); - ?> - - -
    - " />
    - -
    diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 73631dd87f..8c7f049808 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -1,69 +1,13 @@ resource_framesize)) { - set_config("resource_framesize", 130); -} - -if (!isset($CFG->resource_websearch)) { - set_config("resource_websearch", "http://google.com/"); -} - -if (!isset($CFG->resource_defaulturl)) { - set_config("resource_defaulturl", "http://"); -} - -if (!isset($CFG->resource_filterexternalpages)) { - set_config("resource_filterexternalpages", false); -} - -if (!isset($CFG->resource_secretphrase)) { - set_config("resource_secretphrase", random_string(20)); -} - -if (!isset($CFG->resource_popup)) { - set_config("resource_popup", ""); -} - -if (!isset($CFG->resource_windowsettings)) { - set_config("resource_windowsettings", "0"); -} - -if (!isset($CFG->resource_parametersettings)) { - set_config("resource_parametersettings", "0"); -} - -if (!isset($CFG->resource_allowlocalfiles)) { - set_config("resource_allowlocalfiles", "0"); -} - -if (!isset($CFG->resource_hide_repository)) { - set_config("resource_hide_repository", "1"); -} - -if (!isset($CFG->resource_autofilerename)) { - set_config("resource_autofilerename", "1"); -} - -if (!isset($CFG->resource_blockdeletingfile)) { - set_config("resource_blockdeletingfile", "1"); -} - define('RESOURCE_LOCALPATH', 'LOCALPATH'); +global $RESOURCE_WINDOW_OPTIONS; // must be global because it might be included from a function! $RESOURCE_WINDOW_OPTIONS = array('resizable', 'scrollbars', 'directories', 'location', 'menubar', 'toolbar', 'status', 'width', 'height'); -foreach ($RESOURCE_WINDOW_OPTIONS as $popupoption) { - $popupoption = "resource_popup$popupoption"; - if (!isset($CFG->$popupoption)) { - if ($popupoption == 'resource_popupheight') { - set_config($popupoption, 450); - } else if ($popupoption == 'resource_popupwidth') { - set_config($popupoption, 620); - } else { - set_config($popupoption, 'checked'); - } - } +if (!isset($CFG->resource_hide_repository)) { + set_config("resource_hide_repository", "1"); } /** diff --git a/mod/resource/settings.php b/mod/resource/settings.php new file mode 100644 index 0000000000..ff2e2ffcd6 --- /dev/null +++ b/mod/resource/settings.php @@ -0,0 +1,48 @@ +dirroot.'/mod/resource/lib.php'); + +global $RESOURCE_WINDOW_OPTIONS; // make sure we have the pesky global + +$checkedyesno = array(''=>get_string('no'), 'checked'=>get_string('yes')); // not nice at all + +$settings->add(new admin_setting_configtext('resource_framesize', get_string('framesize', 'resource'), + get_string('configframesize', 'resource'), 130, PARAM_INT)); + +$settings->add(new admin_setting_configtext('resource_websearch', get_string('websearchdefault', 'resource'), + get_string('configwebsearch', 'resource'), 'http://google.com/')); + +$settings->add(new admin_setting_configtext('resource_defaulturl', get_string('resourcedefaulturl', 'resource'), + get_string('configdefaulturl', 'resource'), 'http://')); + +$settings->add(new admin_setting_configpasswordunmask('resource_secretphrase', get_string('password'), + get_string('configsecretphrase', 'resource'), random_string(20))); + +$settings->add(new admin_setting_configcheckbox('resource_allowlocalfiles', get_string('allowlocalfiles', 'resource'), + get_string('configallowlocalfiles', 'resource'), 0)); + +$woptions = array(0 => get_string('pagewindow', 'resource'), 1 => get_string('newwindow', 'resource')); +$settings->add(new admin_setting_configselect('resource_popup', get_string('display', 'resource'), + get_string('configpopup', 'resource'), 0, $woptions)); + +foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) { + $popupoption = "resource_popup$optionname"; + if ($popupoption == 'resource_popupheight') { + $settings->add(new admin_setting_configtext('resource_popupheight', get_string('newheight', 'resource'), + get_string('configpopupheight', 'resource'), 450, PARAM_INT)); + } else if ($popupoption == 'resource_popupwidth') { + $settings->add(new admin_setting_configtext('resource_popupwidth', get_string('newwidth', 'resource'), + get_string('configpopupwidth', 'resource'), 620, PARAM_INT)); + } else { + $settings->add(new admin_setting_configselect($popupoption, get_string('new'.$optionname, 'resource'), + get_string('configpopup'.$optionname, 'resource'), 'checked', $checkedyesno)); + } +} + +$settings->add(new admin_setting_configcheckbox('resource_autofilerename', get_string('autofilerename', 'resource'), + get_string('configautofilerenamesettings', 'resource'), 1)); + +$settings->add(new admin_setting_configcheckbox('resource_blockdeletingfile', get_string('blockdeletingfile', 'resource'), + get_string('configblockdeletingfilesettings', 'resource'), 1)); + +?> diff --git a/mod/scorm/config.html b/mod/scorm/config.html deleted file mode 100755 index 8418bbe055..0000000000 --- a/mod/scorm/config.html +++ /dev/null @@ -1,40 +0,0 @@ -scorm_frameheight)) { - $CFG->scorm_frameheight = '500'; - } - if (!isset($CFG->scorm_framewidth)) { - $CFG->scorm_framewidth = '100%'; - } -?> - -
    -
    - - - - - - - - - - - - - - - - -
    scorm_framewidth: - - - -
    scorm_frameheight: - - - -
    - " /> -
    -
    -
    diff --git a/mod/scorm/settings.php b/mod/scorm/settings.php new file mode 100644 index 0000000000..4d99e25cd9 --- /dev/null +++ b/mod/scorm/settings.php @@ -0,0 +1,9 @@ +add(new admin_setting_configtext('scorm_framewidth', get_string('width', 'scorm'), + get_string('framewidth', 'scorm'), '100%')); + +$settings->add(new admin_setting_configtext('scorm_frameheight', get_string('height', 'scorm'), + get_string('frameheight', 'scorm'), 500)); + +?> diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index d85666d8d9..08625e48f1 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -318,20 +318,51 @@ table.flexible .r1 { background-color: green; } +/* Admin settings */ + #adminsettings fieldset { background-color: #EEE; border-color: #BBB; color: #000; } +#adminsettings fieldset.error { + border: 1px solid red; +} + +#adminsettings fieldset.error legend { + color: red; +} + #adminsettings .form-shortname { color: #888; } +#adminsettings .form-overridden { + background-color: #fbb; +} + +#adminsettings .form-item .defaultinfo { + color: #888; +} + +#adminsettings .form-item .pathok { + color: green; +} + +#adminsettings .form-item .patherror { + color: red; +} + .block_admin_tree.sideblock .link.current { background-color:#EEEEEE; } +.block_admin_tree.sideblock .link.hidden { + color:#999999; +} + + #admin-lang .translator { border-color: #dddddd; } diff --git a/theme/standard/styles_fonts.css b/theme/standard/styles_fonts.css index 196ae1a6c8..dc998742b8 100644 --- a/theme/standard/styles_fonts.css +++ b/theme/standard/styles_fonts.css @@ -250,6 +250,10 @@ body#admin-index .copyright { font-size: 0.75em; } +#adminsettings .form-item .defaultinfo { + font-size: 0.8em; +} + #admin-roles-override .cell.c1, #admin-roles-assign .cell.c3, #admin-roles-assign .cell.c1 { diff --git a/theme/standard/styles_ie6.css b/theme/standard/styles_ie6.css index e82ad90c10..4db1022f38 100755 --- a/theme/standard/styles_ie6.css +++ b/theme/standard/styles_ie6.css @@ -51,4 +51,11 @@ form.mform textarea { .que .info { margin-left: 0.6em; -} \ No newline at end of file +} + +#adminsettings .form-setting, +#adminsettings .form-description { + display:inline-block; padding-left:2px; +} + + diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 0688f8e906..4934a2fe8f 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -585,11 +585,6 @@ fieldset.fdate_selector label { margin-right:3px; } -form#adminsettings div.htmlarea { - clear: left; - padding-top: 5px; -} - .mform label .req, .mform label .adv { cursor: help; } @@ -989,100 +984,100 @@ body#admin-modules table.generaltable td.c0 margin:20px; } -#adminsettings fieldset { - margin-top: 1em; - padding: 1em 0.5em; -} - -#adminsettings legend { - display: none; +/* Admin settings */ +#adminsettings div.form-item { + clear: both; + margin: 1em 0 2em 0; } -#adminsettings .form-group { +#adminsettings .form-label { + display: block; float: left; + width: 12.5em; + text-align: right; } -#adminsettings .form-item { - margin: 0; +#adminsettings .form-shortname { + display: block; } -#adminsettings label { +#adminsettings .form-setting { display: block; - float: left; - width: 150px; - text-align: right; + margin-left: 13em; + text-align: left; } -#adminsettings .form-shortname { +#adminsettings .form-description { display: block; + margin: 0.5em 0 0em 13em; + text-align: left; } -#adminsettings select, -#adminsettings input { - float: left; - margin: 0 0 0 10px; +#adminsettings span.defaultinfo { + margin-left: 0.5em; } -#adminsettings textarea { - float: left; - margin: 0 0 0 10px; - width: 65%; +#adminsettings div.defaultinfo { + margin-left: 3px; } -#adminsettings .form-group select, -#adminsettings .form-group input { - display: inline; - float: none; +#adminsettings fieldset { + margin-top: 1em; + padding: 1em 0.5em; } +#adminsettings legend { + display: none; +} -/* #adminsettings .admin-configtime .form-select { - display: inline; - float: none; +#adminsettings fieldset.error { + margin: 0.2em 0 0.5em 0; + padding: 0.5em 0 0 0; } -#adminsettings div.admin-frontpage div.form-group select.form-select { - display: inline; - float: none; -} */ +#adminsettings fieldset.error legend { + display: block; +} -#adminsettings .description { - clear: both; - margin: 0 1em 0 160px; - padding: 0.3em 0 1.5em 0; +#adminsettings .form-multicheckbox li { + list-style: none; } -#adminsettings .form-item .unmask input { - margin-left:5px; - margin-right:3px; +#adminsettings .form-multicheckbox ul { + padding:0; + margin:0; } -#adminsettings .form-item .unmask label { - width: auto; - text-align: left; +#adminsettings .form-text input { + width: 20em; } -.environmentbox { - margin-top: 1em; +#adminsettings .form-password input[type="text"], +#adminsettings .form-password input[type="password"] { + width: 20em; } -.form-buttons { - margin: 10px 0 0 160px; +#adminsettings .form-text input.number { + width: 5em; } -.form-text { - width: 20em; +#adminsettings .form-executable input, +#adminsettings .form-directory input { + width: 30em; } -.form-textarea { } -.form-select { } -.form-checkbox { } -.form-radio { } -.form-submit { } -.form-reset { } -.admin-frontpagedesc .htmlarea { - margin: 0 auto 10px auto; - width : 600px; +#adminsettings .form-item .pathok, +#adminsettings .form-item .patherror { + margin-left: 0.5em; +} + + +.environmentbox { + margin-top: 1em; +} + +.form-buttons { + margin: 10px 0 0 13em; } .adminsearchform { @@ -1093,6 +1088,22 @@ body#admin-modules table.generaltable td.c0 text-align:left; } +.block_admin_tree .admintree .depth1 { + padding-left: 16px; +} + +.block_admin_tree .admintree .depth2 { + padding-left: 32px; +} + +.block_admin_tree .admintree .depth3 { + padding-left: 48px; +} + +.block_admin_tree .admintree .depth4 { + padding-left: 64px; +} + #admin-lang .translator { border-width: 1px; border-style: solid; diff --git a/user/editadvanced.php b/user/editadvanced.php index 40dbd5d7bf..a03d52ed67 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -141,9 +141,8 @@ } if (!empty($USER->newadminuser)) { unset($USER->newadminuser); - // try to apply defaults again - some of them might depend on admin user info - $adminroot = admin_get_root(); - apply_default_settings($adminroot, false); + // apply defaults again - some of them might depend on admin user info, backup, roles, etc. + admin_apply_default_settings(NULL , false); // redirect to admin/ to continue with installation redirect("$CFG->wwwroot/$CFG->admin/"); } else { -- 2.39.5