MDL-11561 admin tree improvements and bugfixing
authorskodak <skodak>
Wed, 19 Dec 2007 17:35:20 +0000 (17:35 +0000)
committerskodak <skodak>
Wed, 19 Dec 2007 17:35:20 +0000 (17:35 +0000)
110 files changed:
admin/auth.php
admin/auth_config.php
admin/block.php
admin/blocks.php
admin/filter.php
admin/filters.php
admin/index.php
admin/lang.php
admin/mnet/access_control.php
admin/mnet/adminlib.php
admin/mnet/delete.html
admin/mnet/enr_courses.php
admin/mnet/enr_hosts.php
admin/mnet/mnet_themes.php
admin/module.php
admin/modules.php
admin/pagelib.php
admin/report/backups/index.php
admin/search.php
admin/settings.php
admin/settings/appearance.php
admin/settings/courses.php
admin/settings/grades.php
admin/settings/language.php
admin/settings/location.php
admin/settings/misc.php
admin/settings/mnet.php
admin/settings/plugins.php [new file with mode: 0644]
admin/settings/security.php
admin/settings/server.php
admin/settings/top.php
admin/settings/unsupported.php
admin/settings/users.php
admin/upgradesettings.php
backup/backup_scheduled.php
backup/lib.php
blocks/admin_bookmarks/block_admin_bookmarks.php
blocks/admin_bookmarks/create.php
blocks/admin_bookmarks/delete.php
blocks/admin_tree/block_admin_tree.php
blocks/course_list/config_global.html [deleted file]
blocks/course_list/settings.php [new file with mode: 0644]
blocks/online_users/config_global.html [deleted file]
blocks/online_users/settings.php [new file with mode: 0644]
blocks/rss_client/config_global.html [deleted file]
blocks/rss_client/settings.php [new file with mode: 0644]
course/lib.php
filter/algebra/algebradebug.php
filter/algebra/filter.php
filter/algebra/pix.php
filter/censor/filterconfig.html [deleted file]
filter/censor/filtersettings.php [new file with mode: 0644]
filter/mediaplugin/defaultsettings.php [deleted file]
filter/mediaplugin/filter.php
filter/mediaplugin/filterconfig.html [deleted file]
filter/mediaplugin/filtersettings.php [new file with mode: 0644]
filter/multilang/defaultsettings.php [deleted file]
filter/multilang/filterconfig.html [deleted file]
filter/multilang/filtersettings.php [new file with mode: 0644]
filter/tex/defaultsettings.php [deleted file]
filter/tex/displaytex.php
filter/tex/filter.php
filter/tex/filterconfig.html [deleted file]
filter/tex/filtersettings.php [new file with mode: 0644]
filter/tex/lib.php [new file with mode: 0644]
filter/tex/pix.php
filter/tex/texdebug.php
filter/tex/texed.php
grade/report/grader/preferences.php
index.php
lang/en_utf8/admin.php
lang/en_utf8/assignment.php
lang/en_utf8/auth.php
lang/en_utf8/block_course_list.php
lang/en_utf8/block_online_users.php
lang/en_utf8/block_rss_client.php
lang/en_utf8/chat.php
lang/en_utf8/error.php
lang/en_utf8/filters.php
lang/en_utf8/forum.php
lang/en_utf8/resource.php
lib/adminlib.php
lib/moodlelib.php
lib/setup.php
mod/assignment/config.html [deleted file]
mod/assignment/lib.php
mod/assignment/settings.php [new file with mode: 0644]
mod/chat/config.html [deleted file]
mod/chat/lib.php
mod/chat/settings.php [new file with mode: 0644]
mod/data/config.html [deleted file]
mod/data/settings.php [new file with mode: 0644]
mod/forum/config.html [deleted file]
mod/forum/lib.php
mod/forum/settings.php [new file with mode: 0644]
mod/glossary/config.html [deleted file]
mod/glossary/formats.php
mod/glossary/lib.php
mod/glossary/settings.php [new file with mode: 0644]
mod/hotpot/mediaplayers/moodle/filter.php
mod/resource/config.html [deleted file]
mod/resource/lib.php
mod/resource/settings.php [new file with mode: 0644]
mod/scorm/config.html [deleted file]
mod/scorm/settings.php [new file with mode: 0644]
theme/standard/styles_color.css
theme/standard/styles_fonts.css
theme/standard/styles_ie6.css
theme/standard/styles_layout.css
user/editadvanced.php

index b366551..61afb67 100644 (file)
@@ -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 = "<span>".$displayauths['manual']."</span>";
-$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&amp;auth=manual\">{$txt->settings}</a>";
-$table->add_data(array($displayname, '', '', $settings));
-$displayname = "<span>".$displayauths['nologin']."</span>";
-$settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&amp;auth=nologin\">{$txt->settings}</a>";
-$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 = "<a href=\"$url&amp;action=disable&amp;auth=$auth\">";
-        $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" /></a>";
-        // $hideshow = "<a href=\"$url&amp;action=disable&amp;auth=$auth\"><input type=\"checkbox\" checked /></a>";
-        $enabled = true;
-        $displayname = "<span>$name</span>";
-    }
-    else {
-        $hideshow = "<a href=\"$url&amp;action=enable&amp;auth=$auth\">";
-        $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" /></a>";
-        // $hideshow = "<a href=\"$url&amp;action=enable&amp;auth=$auth\"><input type=\"checkbox\" /></a>";
-        $enabled = false;
-        $displayname = "<span class=\"dimmed_text\">$name</span>";
-    }
-
-    // up/down link (only if auth is enabled)
-    $updown = '';
-    if ($enabled) {
-        if ($updowncount > 1) {
-            $updown .= "<a href=\"$url&amp;action=up&amp;auth=$auth\">";
-            $updown .= "<img src=\"{$CFG->pixpath}/t/up.gif\" alt=\"up\" /></a>&nbsp;";
-        }
-        else {
-            $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />&nbsp;";
-        }
-        if ($updowncount < $authcount) {
-            $updown .= "<a href=\"$url&amp;action=down&amp;auth=$auth\">";
-            $updown .= "<img src=\"{$CFG->pixpath}/t/down.gif\" alt=\"down\" /></a>";
-        }
-        else {
-            $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />";
-        }
-        ++ $updowncount;
-    }
-
-    // settings link
-    $settings = "<a href=\"auth_config.php?sesskey={$USER->sesskey}&amp;auth=$auth\">{$txt->settings}</a>";
-
-    // 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 '<hr />';
-
-echo '<form '.$CFG->frametarget.' id="adminsettings" method="post" action="auth.php">';
-echo '<div class="settingsform clearfix">';
-print_heading(get_string('auth_common_settings', 'auth'));
-echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-echo '<input type="hidden" name="action" value="save" />';
-echo '<fieldset>';
-##echo '<table cellspacing="0" cellpadding="5" border="0" style="margin-left:auto;margin-right:auto">';
-
-// User self registration
-echo '<div class="form-item" id="admin-register">';
-echo '<label for = "menuregister">' . get_string("selfregistration", "auth");
-echo '<span class="form-shortname">registerauth</span>';
-echo '</label>';
-choose_from_menu($registrationauths, "register", $CFG->registerauth, "");
-echo '<div class="description">' . get_string("selfregistration_help", "auth") . '</div>';
-echo '</div>';
-
-// Login as guest button enabled
-echo '<div class="form-item" id="admin-guestloginbutton">';
-echo '<label for = "menuguestloginbutton">' . get_string("guestloginbutton", "auth");
-echo '<span class="form-shortname">guestloginbutton</span>';
-echo '</label>';
-choose_from_menu($guestoptions, "guestloginbutton", $CFG->guestloginbutton, "");
-echo '<div class="description">' . get_string("showguestlogin", "auth") . '</div>';
-echo '</div>';
-
-/// An alternate url for the login form. It means we can use login forms that are integrated
-/// into non-moodle pages
-echo '<div class="form-item" id="admin-alternateloginurl">';
-echo '<label for = "alternateloginurl">' . get_string("alternateloginurl", "auth");
-echo '<span class="form-shortname">alternateloginurl</span>';
-echo '</label>';
-echo '<input type="text" size="60" name="alternateloginurl" id="alternateloginurl" value="'.s($CFG->alternateloginurl)."\" />\n";
-echo '<div class="description">' . get_string("alternatelogin", "auth", htmlspecialchars($CFG->wwwroot.'/login/index.php')) . '</div>';
-echo '</div>';
-
-/// An alternate url for lost passwords. It means we can use external lost password
-/// recovery for all users. Effectively disables built-in processes!!!
-echo '<div class="form-item" id="admin-forgottenpasswordurl">';
-echo '<label for = "forgottenpasswordurl">' . get_string("forgottenpasswordurl", "auth");
-echo '<span class="form-shortname">forgottenpasswordurl</span>';
-echo '</label>';
-echo '<input type="text" size="60" name="forgottenpasswordurl" id="forgottenpasswordurl" value="'.s($CFG->forgottenpasswordurl)."\" />\n";
-echo '<div class="description">' . get_string("forgottenpassword", "auth" ) . '</div>';
-echo '</div>';
-
-/// Instructions about login/password
-/// to be showed to users
-echo '<div class="form-item" id="admin-auth_instructions">';
-echo '<label for = "auth_instructions">' . get_string("instructions", "auth");
-echo '<span class="form-shortname">auth_instructions</span>';
-echo '</label>';
-echo '<textarea cols="30" rows="4" name="auth_instructions" id="auth_instructions">'.s($CFG->auth_instructions)."</textarea>\n";
-echo '<div class="description">' . get_string("authinstructions", "auth") . '</div>';
-echo '</div>';
-
-echo '</fieldset>';
-
-////////////////////////////////////////////////////////////////////////////////
-echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
-echo '</div>';
-echo '</form>';
-admin_externalpage_print_footer();
+redirect ($returnurl);
 
 ?>
index a9cb8fd..6848e7c 100644 (file)
@@ -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 {
index 49048f3..d21218f 100644 (file)
@@ -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');
     $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 '</p>';
     $block->config_print();
     echo '</form>';
-    admin_externalpage_print_footer();
+    print_footer();
 
 ?>
index 6b9a8b7..b9c6cc3 100644 (file)
     $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()) {
         }
         $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!");
         }
     }
 
+    admin_externalpage_print_header();
+    print_heading($strmanageblocks);
+
 /// Main display starts here
 
 /// Get and sort the existing blocks
     foreach ($blockbyname as $blockname => $blockid) {
 
         $blockobject = $blockobjects[$blockid];
+        $block       = $blocks[$blockid];
 
         $delete = '<a href="blocks.php?delete='.$blockid.'&amp;sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
 
         $settings = ''; // By default, no configuration
-        if($blockobject->has_config()) {
-            $settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
+        if ($blockobject->has_config()) {
+            if (file_exists($CFG->dirroot.'/blocks/'.$block->name.'/settings.php')) {
+                $settings = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=blocksetting'.$block->name.'">'.$strsettings.'</a>';
+            } else {
+                $settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
+            }
         }
 
         // 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\'');
 
index c372dda..b1c790a 100644 (file)
@@ -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;
     //======================
 
     // 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;
     }
 
     print_simple_box_start("center",'');
 
     ?>
-    <form action="filter.php?filter=<?php echo urlencode($param->filter); ?>" method="post">
+    <form action="filter.php?filter=<?php echo urlencode($filterfull); ?>" method="post">
     <div style="text-align: center">
     <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
 
-    <?php include "$CFG->dirroot/$param->filter/filterconfig.html"; ?>
+    <?php include "$CFG->dirroot/$filterfull/filterconfig.html"; ?>
 
         <input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
         <input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
index 978fdbe..02144fd 100644 (file)
 <?php // $Id$
-    // filters.php
-    // Edit list of available text filters
 
     require_once('../config.php');
-    require_once($CFG->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 {
             $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 {
             $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 = "<a href=\"$myurl&amp;action=hide&amp;filterpath=$upath\">";
-            $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"$txt->hide\" /></a>";
-            $hidden = false;
-            $displayname = "<span>$name</span>";
-        }
-        else {
-            $hideshow = "<a href=\"$myurl&amp;action=show&amp;filterpath=$upath\">";
-            $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"$txt->show\" /></a>";
-            $hidden = true;
-            $displayname = "<span class=\"dimmed_text\">$name</span>";
-        }
-
-        // get up/down link (only if not hidden)
-        $updown = '';
-        if (!$hidden) {
-            if ($updowncount>1) {
-                $updown .= "<a href=\"$myurl&amp;action=up&amp;filterpath=$upath\">";
-                $updown .= "<img src=\"$img/up.gif\" alt=\"$txt->up\" /></a>&nbsp;";
-            }
-            else {
-                $updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />&nbsp;";
-            }
-            if ($updowncount<$activefilterscount) {
-                $updown .= "<a href=\"$myurl&amp;action=down&amp;filterpath=$upath\">";
-                $updown .= "<img src=\"$img/down.gif\" alt=\"$txt->down\" /></a>";
-            }
-            else {
-                $updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />";
-            }
-            ++$updowncount;
-        }
-
-        // settings link (if defined)
-        $settings = '';
-        if (in_array($path, $filtersettings)) {
-            $settings = "<a href=\"filter.php?filter=" . urlencode($path) . "\">";
-            $settings .= "{$txt->settings}</a>";
-        }
-
-        // 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);
 
 ?>
index 7efddb7..d221a5e 100644 (file)
 
             // 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',
                     notify(get_string('environmentok', 'admin'), 'notifysuccess');
                     print_box_start('generalbox', 'notice'); // MDL-8330
                     print_string('langpackwillbeupdated', 'admin');
-                    print_box_end();  
+                    print_box_end();
                     echo '<form action="index.php"><div>';
                     echo '<input type="hidden" name="confirmupgrade" value="1" />';
                     echo '<input type="hidden" name="confirmrelease" value="1" />';
     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
         }
     }
 
-    $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');
     }
 
index 31746ee..830c3e0 100644 (file)
@@ -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();
     }
     if (has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) {
         $firstrow[] = new tabobject('uselocal',
-            $CFG->wwwroot."/admin/lang.php?mode=$mode&amp;currentfile=$currentfile&amp;uselocal=1",
+            "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&amp;currentfile=$currentfile&amp;uselocal=1",
             $strlocalstringcustomization );
     }
     if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) {
         $firstrow[] = new tabobject('usemaster',
-            $CFG->wwwroot."/admin/lang.php?mode=$mode&amp;currentfile=$currentfile&amp;uselocal=0",
+            "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&amp;currentfile=$currentfile&amp;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);
 
index e810593..9b3a34c 100644 (file)
@@ -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');
index bd33b81..e4da39e 100644 (file)
@@ -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);
     }
 
index 973231e..cc2b67b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 $navlinks = array();
-$navlinks[] = array('name' => $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);
index 7e09e5f..8735ecc 100644 (file)
@@ -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}&amp;courseid={$course->id}&amp;sesskey={$USER->sesskey}";
         echo '<tr>'
                . "<td>$icon</td>"
index ec82c2c..085539b 100644 (file)
@@ -37,7 +37,7 @@
            . '</tr>';
     $hosts = $enrolment->list_remote_servers();
     foreach ($hosts as $host) {
-        $coursesurl = "{$CFG->wwwroot}/admin/mnet/enr_courses.php?host={$host->id}&amp;sesskey={$USER->sesskey}";
+        $coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&amp;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 @@
                . "<td align=\"center\" >$enrolcount</td>"
                . "<td align=\"center\" >$coursecount - <a href=\"{$coursesurl}\">".get_string('editenrolments', 'mnet')."</a></td>"
                // TODO: teach report/log/index.php to show per-host-logs
-               // . '<td align="center" ><a href="{$CFG->wwwroot}/admin/report/log/index.php?course_host={$host->id}">'
+               // . '<td align="center" ><a href="$CFG->wwwroot/$CFG->admin/report/log/index.php?course_host={$host->id}">'
                // . get_string('logs', 'mnet').'</a> </td>'
                . '</tr>';
     }
index b82c179..180d8c3 100644 (file)
@@ -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);
 
index 396cf85..d5a74ea 100644 (file)
@@ -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);
 
index 85be458..8471c74 100644 (file)
     $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()) {
                              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");
 
         }
     }
 
+    admin_externalpage_print_header();
+    print_heading($stractivities);
+
 /// Get and sort the existing modules
 
     if (!$modules = get_records("modules")) {
 
         $delete = "<a href=\"modules.php?delete=$module->name&amp;sesskey=$USER->sesskey\">$strdelete</a>";
 
-        if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
+        if (file_exists("$CFG->dirroot/mod/$module->name/settings.php")) {
+            $settings = "<a href=\"settings.php?section=modsetting$module->name\">$strsettings</a>";
+        } else if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
             $settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
         } else {
             $settings = "";
         }
 
         $table->add_data(array(
-            '<span'.$class.'>'.$icon.' '.$modulename.'</span>', 
-            $countlink, 
-            '<span'.$class.'>'.$module->version.'</span>', 
-            $visible, 
-            $delete, 
+            '<span'.$class.'>'.$icon.' '.$modulename.'</span>',
+            $countlink,
+            '<span'.$class.'>'.$module->version.'</span>',
+            $visible,
+            $delete,
             $settings
         ));
     }
index 8ff148e..7870020 100644 (file)
@@ -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() {
index d7fab79..a8a4925 100644 (file)
@@ -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);
 
         print_simple_box_end();
     }
 
-    admin_externalpage_print_footer($adminroot);
+    print_footer();
 
 ?>
index e94f8ef..c07f862 100644 (file)
 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') . ' <br />' . $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 '<form action="search.php" method="post" id="adminsettings">';
 echo '<div>';
-echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
-echo '<input type="hidden" name="query" value="' . s($query) . '" />';
+echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+echo '<input type="hidden" name="query" value="'.s($query).'" />';
 echo '</div>';
 echo '<fieldset>';
 echo '<div class="clearer"><!-- --></div>';
 if ($resultshtml != '') {
     echo $resultshtml;
-    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
+    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
 } else {
     echo get_string('noresults','admin');
 }
 echo '</fieldset>';
 echo '</form>';
 
-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').' - '. '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $node->name . '">' . $node->visiblename . '</a>', '', 2, 'main', true);
-            $return .= '<fieldset class="adminsettings">' . "\n";
-            foreach ($foundsettings as $foundsetting) {
-                $return .= '<div class="clearer"><!-- --></div>' . "\n";
-                $return .= highlight($query,$foundsetting->output_html());
-            }
-            $return .= '</fieldset>';
-        }
-        return $return;
-    }
-
-    return '';
-
-}
+print_footer();
 
 ?>
index 8837ddb..9ff2b4d 100644 (file)
@@ -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') . ' <br />' . $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 '<form action="settings.php" method="post" id="adminsettings">';
     echo '<div class="settingsform clearfix">';
-    echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
-    echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
-    echo '<input type="hidden" name="return" value="' . $return . '" />';
+    echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />';
+    echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
+    echo '<input type="hidden" name="return" value="'.$return.'" />';
 
-    echo $root->output_html();
+    echo $page->output_html();
 
-    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
+    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
 
     echo '</div>';
     echo '</form>';
-}
 
-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 '<table id="layout-table"><tr>';
     $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
     foreach ($lt as $column) {
         switch ($column) {
             case 'left':
-    echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
+    echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
     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 '<a name="startofcontent"></a>';
 
-    if ($statusmsg != '') {
-        notify ($statusmsg);
+    if ($errormsg !== '') {
+        notify ($errormsg);
+
+    } else if ($statusmsg !== '') {
+        notify ($statusmsg, 'notifysuccess');
     }
 
     // ---------------------------------------------------------------------------------------------------------------
 
     echo '<form action="settings.php" method="post" id="adminsettings">';
     echo '<div class="settingsform clearfix">';
-    echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
-    echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
-    echo '<input type="hidden" name="return" value="' . $return . '" />';
-    print_heading($root->visiblename);
+    echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />';
+    echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
+    echo '<input type="hidden" name="return" value="'.$return.'" />';
+    print_heading($page->visiblename);
 
-    echo $root->output_html();
+    echo $page->output_html();
 
-    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
+    echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
 
     echo '</div>';
     echo '</form>';
@@ -163,7 +150,7 @@ if (!empty($SITE->fullname)) {
             break;
             case 'right':
     if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
-        echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
+        echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
         print_container_start();
         blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
         print_container_end();
index a81b521..f656f8b 100644 (file)
 
 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
 ?>
index c83e87b..e8f33b7 100644 (file)
@@ -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
 
index 3489bd0..122d069 100644 (file)
 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
 
index 0eabf74..8c4055a 100644 (file)
@@ -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
 
index a054ca5..61fa071 100644 (file)
@@ -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
 
index bf2d04a..83861b0 100644 (file)
@@ -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
 
index 66cbc89..8db1cc0 100644 (file)
@@ -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 (file)
index 0000000..0614712
--- /dev/null
@@ -0,0 +1,140 @@
+<?php  //$Id$
+
+if ($hassiteconfig) {
+
+    $ADMIN->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)));
+            }
+        }
+    }
+}
+?>
index 9c91e16..7120396 100644 (file)
 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
 
index 278596a..f0bc9f0 100644 (file)
@@ -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);
 
index 5e72efd..de1717b 100644 (file)
@@ -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));
+
 ?>
index f0170f1..5c037ab 100644 (file)
@@ -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
 
index 5ad2d7d..cd3060d 100644 (file)
@@ -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
 
index c011d20..803c890 100644 (file)
@@ -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') . ' <br />' . $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 '<form action="upgradesettings.php" method="post" id="adminsettings">';
+echo '<div>';
 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
 echo '<input type="hidden" name="return" value="'.$return.'" />';
 echo '<fieldset>';
 echo '<div class="clearer"><!-- --></div>';
 echo $newsettingshtml;
 echo '</fieldset>';
-echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
+echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
+echo '</div>';
 echo '</form>';
 
-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 .= '<fieldset class="adminsettings">' . "\n";
-            foreach ($newsettings as $newsetting) {
-                $return .= '<div class="clearer"><!-- --></div>' . "\n";
-                $return .= $newsetting->output_html();
-            }
-            $return .= '</fieldset>';
-        }
-        return $return;
-    }
-
-    return '';
-
-}
+print_footer();
 
 ?>
index be0e6f1..37def53 100644 (file)
@@ -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;
index 7706690..8a5bc50 100644 (file)
             $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);
index 2b4fd5d..3293bfd 100644 (file)
@@ -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 .= '<ol class="list">'."\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;
     }
 }
index bea79e9..a0e1969 100644 (file)
@@ -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 {
index a73a39a..1ad4f15 100644 (file)
@@ -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 {
index 228b75f..6528b0b 100644 (file)
@@ -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 .= "&nbsp; &nbsp;";
-        }
-        $this->tempcontent .= '<a href="#" onclick="toggle(\'vh_span' . $this->spancounter . '\');return false">';
-        $this->tempcontent .= '<span id="vh_span' . $this->spancounter . 'indicator"><img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" /></span> ';
-        $this->tempcontent .= $visiblename . '</a><br /><span id="vh_span' . $this->spancounter . '">' . "\n";
+        $this->tempcontent .= '<div class="depth'.$this->currentdepth.'"><a href="#" onclick="toggle(\'vh_div'.$this->divcounter.'\');return false">';
+        $this->tempcontent .= '<span id="vh_div'.$this->divcounter.'indicator"><img src="'.$CFG->wwwroot.'/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" /></span> ';
+        $this->tempcontent .= $visiblename.'</a></div><div id="vh_div'.$this->divcounter.'">'."\n";
         $this->currentdepth++;
-        $this->spancounter++;
+        $this->divcounter++;
     }
 
     function close_folder() {
         $this->currentdepth--;
-        $this->tempcontent .= "</span>\n";
+        $this->tempcontent .= "</div>\n";
     }
 
     function create_item($visiblename,$link,$icon,$class) {
         global $CFG;
-        for ($i = 0; $i < $this->currentdepth; $i++) {
-            $this->tempcontent .= "&nbsp; &nbsp;";
-        }
-        $this->tempcontent .= '<a class="'.$class.'" href="'.$link.'"><img src="'.$icon.'" alt="" />'.
-                               $visiblename.'</a><br />'."\n";
+        $this->tempcontent .= '<div class="depth'.$this->currentdepth.'"><a class="'.$class.'" href="'.$link.'"><img src="'.$icon.'" alt="" />'.
+                               $visiblename.'</a></div>'."\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  = '<script type="text/javascript">'."\n";
             $this->content->text .= '//<![CDATA[' . "\n";
-            $this->content->text .= 'var vh_numspans = ' . ($this->spancounter - 1) . ';' . "\n";
+            $this->content->text .= 'var vh_numdivs = ' . ($this->divcounter - 1) . ';' . "\n";
             $this->content->text .= 'var vh_content = new Array();' . "\n";
-            $this->content->text .= 'function getspan(spanid) {' . "\n";
+            $this->content->text .= 'function getdiv(divid) {' . "\n";
             $this->content->text .= '  if (document.getElementById) {' . "\n";
-            $this->content->text .= '    return document.getElementById(spanid);' . "\n";
-            $this->content->text .= '  } else if (window[spanid]) {' . "\n";
-            $this->content->text .= '    return window[spanid];' . "\n";
+            $this->content->text .= '    return document.getElementById(divid);' . "\n";
+            $this->content->text .= '  } else if (window[divid]) {' . "\n";
+            $this->content->text .= '    return window[divid];' . "\n";
             $this->content->text .= '  }' . "\n";
             $this->content->text .= '  return null;' . "\n";
             $this->content->text .= '}' . "\n";
 
-            $this->content->text .= 'function toggle(spanid) {' . "\n";
-            $this->content->text .= '  if (getspan(spanid).innerHTML == "") {' . "\n";
-            $this->content->text .= '    getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
-            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" />\';' . "\n";
+            $this->content->text .= 'function toggle(divid) {' . "\n";
+            $this->content->text .= '  if (getdiv(divid).innerHTML == "") {' . "\n";
+            $this->content->text .= '    getdiv(divid).innerHTML = vh_content[divid];' . "\n";
+            $this->content->text .= '    getdiv(divid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" />\';' . "\n";
             $this->content->text .= '  } else {' . "\n";
-            $this->content->text .= '    vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
-            $this->content->text .= '    getspan(spanid).innerHTML = "";' . "\n";
-            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif" alt="'.$strfolderclosed.'" />\';' . "\n";
+            $this->content->text .= '    vh_content[divid] = getdiv(divid).innerHTML;' . "\n";
+            $this->content->text .= '    getdiv(divid).innerHTML = "";' . "\n";
+            $this->content->text .= '    getdiv(divid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif" alt="'.$strfolderclosed.'" />\';' . "\n";
             $this->content->text .= '  }' . "\n";
             $this->content->text .= '}' . "\n";
 
-            $this->content->text .= 'function collapse(spanid) {' . "\n";
-            $this->content->text .= '  if (getspan(spanid).innerHTML !== "") {' . "\n";
-            $this->content->text .= '    vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
-            $this->content->text .= '    getspan(spanid).innerHTML = "";' . "\n";
-            $this->content->text .= '    getspan(spanid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif" alt="'.$strfolderclosed.'" />\';' . "\n";
+            $this->content->text .= 'function collapse(divid) {' . "\n";
+            $this->content->text .= '  if (getdiv(divid).innerHTML !== "") {' . "\n";
+            $this->content->text .= '    vh_content[divid] = getdiv(divid).innerHTML;' . "\n";
+            $this->content->text .= '    getdiv(divid).innerHTML = "";' . "\n";
+            $this->content->text .= '    getdiv(divid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif" alt="'.$strfolderclosed.'" />\';' . "\n";
             $this->content->text .= '  }' . "\n";
             $this->content->text .= '}' . "\n";
 
-            $this->content->text .= 'function expand(spanid) {' . "\n";
-            $this->content->text .= '  getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
-            $this->content->text .= '  getspan(spanid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" />\';' . "\n";
+            $this->content->text .= 'function expand(divid) {' . "\n";
+            $this->content->text .= '  getdiv(divid).innerHTML = vh_content[divid];' . "\n";
+            $this->content->text .= '  getdiv(divid + "indicator").innerHTML = \'<img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" alt="'.$strfolderopened.'" />\';' . "\n";
             $this->content->text .= '}' . "\n";
 
             $this->content->text .= 'function expandall() {' . "\n";
-            $this->content->text .= '  for (i = 1; i <= vh_numspans; i++) {' . "\n";
-            $this->content->text .= '    expand("vh_span" + String(i));' . "\n";
+            $this->content->text .= '  for (i = 1; i <= vh_numdivs; i++) {' . "\n";
+            $this->content->text .= '    expand("vh_div" + String(i));' . "\n";
             $this->content->text .= '  }' . "\n";
             $this->content->text .= '}' . "\n";
 
             $this->content->text .= 'function collapseall() {' . "\n";
-            $this->content->text .= '  for (i = vh_numspans; i > 0; i--) {' . "\n";
-            $this->content->text .= '    collapse("vh_span" + String(i));' . "\n";
+            $this->content->text .= '  for (i = vh_numdivs; i > 0; i--) {' . "\n";
+            $this->content->text .= '    collapse("vh_div" + String(i));' . "\n";
             $this->content->text .= '  }' . "\n";
             $this->content->text .= '}' . "\n";
 
@@ -195,10 +197,10 @@ class block_admin_tree extends block_base {
             $this->content->text .= '//]]>' . "\n";
             $this->content->text .= '</script>' . "\n";
 
-            $searchcontent = isset($CFG->adminsearchquery) ? $CFG->adminsearchquery : '';
+            $searchcontent = $adminroot->search;
 
             $this->content->footer = '<div class="adminsearchform">'.
-                                     '<form action="'.$CFG->wwwroot.'/admin/search.php" method="get"><div>'.
+                                     '<form action="'.$CFG->wwwroot.'/'.$CFG->admin.'/search.php" method="get"><div>'.
                                      '<label for="query" class="accesshide">'.get_string('searchinsettings', 'admin').'</label>'.
                                      '<input type="text" name="query" id="query" size="8" value="'.s($searchcontent).'" />'.
                                      '<input type="submit" value="'.get_string('search').'" /></div>'.
diff --git a/blocks/course_list/config_global.html b/blocks/course_list/config_global.html
deleted file mode 100644 (file)
index 5e1b614..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<table cellpadding="9" cellspacing="0">
-<tr valign="top">
-    <td align="right">block_course_list_adminview:</td>
-    <td>
-    <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
-    <select name="block_course_list_adminview">
-     <option value="all" <?php if(isset($CFG->block_course_list_adminview)){ 
-     if($CFG->block_course_list_adminview == "all"){ echo "selected=\"selected\"";}
-     }else{
-         echo "selected=\"selected\"";
-     }?>     
-     ><?php p(get_string('allcourses', 'block_course_list')) ?></option>
-     <option value="own" <?php if(isset($CFG->block_course_list_adminview)){ 
-         if($CFG->block_course_list_adminview == "own"){ echo "selected=\"selected\""; }
-     }?>
-     ><?php p(get_string('owncourses', 'block_course_list')) ?></option>
-    </select>
-    </td>
-    <td>
-    <?php print_string("configadminview", "block_course_list") ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right">block_course_list_hideallcourseslink:</td>
-    <td>
-    <select name="block_course_list_hideallcourseslink">
-     <option value="1" <?php if(isset($CFG->block_course_list_allcourseslink)){ 
-     if($CFG->block_course_list_hideallcourseslink){ echo "selected=\"selected\"";}
-     }?>     
-     ><?php p(get_string('yes')) ?></option>
-     <option value="0" <?php if(isset($CFG->block_course_list_hideallcourseslink)){ 
-         if(!$CFG->block_course_list_hideallcourseslink){ echo "selected=\"selected\""; }
-     }else{
-         echo "selected=\"selected\"";
-     }?>
-     ><?php p(get_string('no')) ?></option>
-    </select>
-    </td>
-    <td>
-    <?php print_string("confighideallcourseslink", "block_course_list") ?>
-    </td>
-</tr>
-<tr>
-    <td colspan="3" align="center">
-    <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
diff --git a/blocks/course_list/settings.php b/blocks/course_list/settings.php
new file mode 100644 (file)
index 0000000..899af4a
--- /dev/null
@@ -0,0 +1,13 @@
+<?php  //$Id$
+
+
+$options = array('all'=>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 (file)
index 50ed5db..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<table cellpadding="9" cellspacing="0">
-<tr valign="top">
-    <td align="right">block_online_users_timetosee:</td>
-    <td>
-    <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
-    <input name="block_online_users_timetosee" type="text" size="5" value="<?php 
-    if(isset($CFG->block_online_users_timetosee)) {
-        p($CFG->block_online_users_timetosee);
-    } else {
-        p(5);
-    } ?>" />
-    </td>
-    <td>
-    <?php print_string('configtimetosee', 'block_online_users') ?>
-    </td>
-</tr>
-<tr>
-    <td colspan="3" align="center">
-    <input type="submit" value="<?php print_string('savechanges') ?>" /></td>
-</tr>
-</table>
diff --git a/blocks/online_users/settings.php b/blocks/online_users/settings.php
new file mode 100644 (file)
index 0000000..0098fb6
--- /dev/null
@@ -0,0 +1,6 @@
+<?php  //$Id$
+
+$settings->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 (file)
index d793abc..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php //$Id$
-    require_once($CFG->libdir .'/rsslib.php');
-?>
-<table cellpadding="9" cellspacing="0">
-<tr valign="top">
-    <td align="right">block_rss_client_num_entries:</td>
-    <td>
-    <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
-    <input name="block_rss_client_num_entries" type="text" size="5" value="<?php
-        if(isset($CFG->block_rss_client_num_entries)) {
-            p($CFG->block_rss_client_num_entries);
-        } else {
-            p(5);
-        } ?>" />
-    </td>
-    <td>
-        <?php print_string('clientnumentries', 'block_rss_client') ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right">block_rss_client_timeout:</td>
-    <td>
-    <input name="block_rss_client_timeout" type="text" size="5" value="<?php
-        if(isset($CFG->block_rss_client_timeout)) {
-            p($CFG->block_rss_client_timeout);
-        } else {
-            p(30);
-        } ?>" />
-    </td>
-    <td>
-        <?php print_string('timeout', 'block_rss_client') ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right">block_rss_client_submitters:</td>
-    <td>
-        <?php if (!empty($CFG->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);
-        ?>
-    </td>
-    <td>
-        <?php print_string('submitters', 'block_rss_client') ?>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="3" align="center">
-    <input type="submit" value="<?php print_string('savechanges') ?>" /></td>
-</tr>
-<tr>
-    <td colspan="3" align="center"><a href="<?php echo $CFG->wwwroot ?>/blocks/rss_client/block_rss_client_action.php?id=<?php
-    if (!isset($id)) {
-        $id = '';
-    }
-    echo $id; ?>"><?php print_string('feedsaddedit', 'block_rss_client')?></a><br /><br />
-    </td>
-    </tr>
-</table>
diff --git a/blocks/rss_client/settings.php b/blocks/rss_client/settings.php
new file mode 100644 (file)
index 0000000..f18c8c2
--- /dev/null
@@ -0,0 +1,21 @@
+<?php  //$Id$
+
+require_once($CFG->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 ='<a href="'.$CFG->wwwroot.'/blocks/rss_client/block_rss_client_action.php">'.get_string('feedsaddedit', 'block_rss_client').'</a>';
+$settings->add(new admin_setting_heading('block_rss_addheading', '', $link));
+
+
+?>
index 4ad4408..9c0af66 100644 (file)
@@ -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);
index 467a22a..96a919e 100644 (file)
         }
     }
 
-    $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<br/>";
       $ecmd = $cmd . " 2>&1";
       echo `$ecmd` . "<br/>\n";
       echo "The shell command<br/>$cmd<br/>returned status = $status<br/>\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)) . "<br/>";
       }
       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<br/>";
       $ecmd = $cmd . " 2>&1";
       echo `$ecmd` . "<br/>\n";
       echo "The shell command<br/>$cmd<br/>returned status = $status<br/>\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)) . "<br/>";
       }
       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<br /> executable ";
-    $error_message1 .= "from <a href=\"http://moodle.org/download/mimetex/\">";
-    $error_message1 .= "http://moodle.org/download/mimetex/</a>, or obtain the ";
-    $error_message1 .= "C source<br /> from <a href=\"http://www.forkosh.com/mimetex.zip\">";
-    $error_message1 .= "http://www.forkosh.com/mimetex.zip</a>, compile it and ";
-    $error_message1 .= "put the executable into your<br /> moodle/filter/tex/ directory. ";
-    $error_message1 .= "You also need to edit your moodle/filter/algebra/pix.php file<br />";
-    $error_message1 .= ' by adding the line<br /><pre>       case "' . PHP_OS . "\":\n";
-    $error_message1 .= "           \$cmd = \"\\\\\"\$CFG->dirroot/\$CFG->texfilterdir/";
-    $error_message1 .= 'mimetex.' . strtolower(PHP_OS) . "\\\\\" -e \\\\\"\$pathname\\\\\" \". escapeshellarg(\$texexp);";
-    $error_message1 .= "</pre>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` . "<br />\n";
-           echo "The shell command<br />$cmd<br />returned status = $status<br />\n";
-           if ($status == 4) {
-             echo "Status corresponds to illegal instruction<br />\n";
-           } else if ($status == 11) {
-             echo "Status corresponds to bus error<br />\n";
-           } else if ($status == 22) {
-             echo "Status corresponds to abnormal termination<br />\n";
-           }
-           if (file_exists($commandpath)) {
-              echo "File size of mimetex executable  $commandpath is " . filesize($commandpath) . "<br />";
-              echo "The file permissions are: " . decoct(fileperms($commandpath)) . "<br />";
-              if (function_exists("md5_file")) {
+        $ecmd = "$cmd 2>&1";
+        echo `$ecmd` . "<br />\n";
+        echo "The shell command<br />$cmd<br />returned status = $status<br />\n";
+        if ($status == 4) {
+            echo "Status corresponds to illegal instruction<br />\n";
+        } else if ($status == 11) {
+            echo "Status corresponds to bus error<br />\n";
+        } else if ($status == 22) {
+            echo "Status corresponds to abnormal termination<br />\n";
+        }
+        if (file_exists($commandpath)) {
+            echo "File size of mimetex executable  $commandpath is " . filesize($commandpath) . "<br />";
+            echo "The file permissions are: " . decoct(fileperms($commandpath)) . "<br />";
+            if (function_exists("md5_file")) {
                 echo "The md5 checksum of the file is " . md5_file($commandpath) . "<br />";
-              } else {
+            } else {
                 $handle = fopen($commandpath,"rb");
                 $contents = fread($handle,16384);
                 fclose($handle);
                 echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "<br />";
-              }
-           } else {
-              echo "mimetex executable $commandpath not found!<br />";
-           }
-           echo "Image not found!";
+            }
+        } else {
+            echo "mimetex executable $commandpath not found!<br />";
+        }
+        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 "<p>If the following image displays correctly, set your ";
-  echo "<a href=\"$admin\" target=\"_blank\">Administration->Configuration->Variables</a> ";
+  echo "<a href=\"$admin\" target=\"_blank\">Administration->Server->HTTP</a> ";
   echo "setting for slasharguments to file.php/1/pic.jpg: ";
   echo "<img src=\"pix.php/$image\" align=\"absmiddle\"></p>\n";
   echo "<p>Otherwise set it to file.php?file=/1/pic.jpg ";
@@ -316,7 +269,7 @@ function slasharguments($texexp, $md5) {
   echo "<img src=\"pix.php?file=$image\" align=\"absmiddle\"></p>\n";
   echo "<p>If neither equation image displays correctly, please seek ";
   echo "further help at moodle.org at the ";
-  echo "<a href=\"http://moodle.org/mod/forum/view.php?id=752&username=guest\" target=\"_blank\">";
+  echo "<a href=\"http://moodle.org/mod/forum/view.php?id=752&loginguest=true\" target=\"_blank\">";
   echo "Mathematics Tools Forum</a></p>";
 }
 
index 3bb480d..eee12c3 100644 (file)
 // 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 .= "<a href=\"$CFG->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 .= "<a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">";
     } else {
       $output .= "<a target=\"popup\" title=\"TeX\" href=";
-      $output .= "\"$CFG->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 .= "<img $title alt=\"".s($origtex)."\" src=\"";
     if ($CFG->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 .= "</a>";
@@ -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('/<algebra/i',$text) && !strstr($text,'@@')) {
         return $text;
@@ -120,7 +111,7 @@ function algebra_filter ($courseid, $text) {
 #        return $text;
 #    }
 
-    
+
     $text .= ' ';
 
     preg_match_all('/@(@@+)([^@])/',$text,$matches);
@@ -128,11 +119,11 @@ function algebra_filter ($courseid, $text) {
         $replacement = str_replace('@','&#x00040;',$matches[1][$i]).$matches[2][$i];
         $text = str_replace($matches[0][$i],$replacement,$text);
     }
-     
+
     // <algebra> some algebraic input expression </algebra>
     // or @@ some algebraic input expression @@
 
-    preg_match_all('/<algebra>(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches);  
+    preg_match_all('/<algebra>(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches);
     for ($i=0; $i<count($matches[0]); $i++) {
         $algebra = $matches[1][$i] . $matches[2][$i];
         $algebra = str_replace('<nolink>','',$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;
 }
 
 ?>
index ee5eb94..5d51d76 100644 (file)
     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;
             $texexp = str_replace('&gt;','>',$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);
         }
     }
         if (debugging()) {
             echo "The shell command<br />$cmd<br />returned status = $status<br />\n";
             echo "Image not found!<br />";
-            echo "Please try the <a href=\"$CFG->wwwroot/$CFG->algebrafilterdir/algebradebug.php\">debugging script</a>";
+            echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
         } else {
             echo "Image not found!<br />";
-            echo "Please try the <a href=\"$CFG->wwwroot/$CFG->algebrafilterdir/algebradebug.php\">debugging script</a><br />";
+            echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a><br />";
             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 (file)
index df551f5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-    // check the default settings
-    // $forcereset is set in calling routine
-    if (!isset($forcereset)) {
-        $forcereset = false;
-    }
-    if (!isset($CFG->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' );
-?>
-
-<table cellpadding="9" cellspacing="0">
-    <tr valign="top">
-        <td align="right"><?php echo $txt->badwordslist; ?></td>
-        <td><textarea name="filter_censor_badwords" cols="60" rows="10"><?php echo "$CFG->filter_censor_badwords"; ?></textarea></td>
-    </tr>
-    <tr>
-        <td>&nbsp;</td>
-        <td align="center"><?php echo $txt->badwordsconfig; ?><br />
-            <i><?php echo $txt->badwordsdefault; ?></i></td>
-    </tr>
-</table>
diff --git a/filter/censor/filtersettings.php b/filter/censor/filtersettings.php
new file mode 100644 (file)
index 0000000..6effb9c
--- /dev/null
@@ -0,0 +1,6 @@
+<?php  //$Id$
+
+$settings->add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'),
+               get_string('badwordsconfig', 'admin').'<br />'.get_string('badwordsdefault', 'admin'), ''));
+
+?>
diff --git a/filter/mediaplugin/defaultsettings.php b/filter/mediaplugin/defaultsettings.php
deleted file mode 100644 (file)
index 4f4d4db..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-    // check/set default config settings for media plugin
-    // $forcereset is set in calling routine
-    
-    if (!isset($forcereset)) {
-        $forcereset = false;
-    }
-    
-    if (!isset($CFG->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 );
-        }
-    }
-?>
index e5f9117..ac747f9 100644 (file)
@@ -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 (file)
index 3b3d938..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-    // check the default settings
-    require_once "defaultsettings.php";
-
-    // get strings
-    $txt = new Object;
-    $txt->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 );
-?>
-
-<table cellpadding="9" cellspacing="0">
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginmp3 ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_mp3',
-             $CFG->filter_mediaplugin_enable_mp3 ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginswf?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_swf',
-             $CFG->filter_mediaplugin_enable_swf ); ?></td> 
-        <td><?php echo $txt->mediapluginswfnote ?></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginmov ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_mov',
-             $CFG->filter_mediaplugin_enable_mov ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginwmv ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_wmv',
-             $CFG->filter_mediaplugin_enable_wmv ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginmpg ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_mpg',
-             $CFG->filter_mediaplugin_enable_mpg ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginavi ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_avi',
-             $CFG->filter_mediaplugin_enable_avi ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginflv ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_flv',
-             $CFG->filter_mediaplugin_enable_flv ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginram ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_ram',
-             $CFG->filter_mediaplugin_enable_ram ); ?></td> 
-        <td />
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginrpm ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_rpm',
-             $CFG->filter_mediaplugin_enable_rpm ); ?></td> 
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->mediapluginrm ?></td>
-        <td><?php choose_from_menu( $yesno,'filter_mediaplugin_enable_rm',
-             $CFG->filter_mediaplugin_enable_rm ); ?></td> 
-        <td />
-    </tr>
-</table>
diff --git a/filter/mediaplugin/filtersettings.php b/filter/mediaplugin/filtersettings.php
new file mode 100644 (file)
index 0000000..40d5fb0
--- /dev/null
@@ -0,0 +1,23 @@
+<?php  //$Id$
+
+$settings->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 (file)
index ae57b75..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-    // defaultsettings.php
-    // deafault settings are done here, saves doing all this twice in
-    // both the rendering routine and the config screen
-
-    if (!isset($forcereset)) {
-        $forcereset = false;
-    }
-
-    if (!isset($CFG->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 (file)
index 009ceb8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-    // check the default settings
-    require_once "defaultsettings.php";
-
-?>
-
-<table cellpadding="9" cellspacing="0">
-    <tr valign="top">
-        <td align="right"><?php print_string('multilangforceold', 'admin'); ?></td>
-        <td><?php choose_from_menu(array(get_String('no'), get_String('yes')), 'filter_multilang_force_old',
-             $CFG->filter_multilang_force_old, ''); ?></td> 
-        <td />
-    </tr>
-</table>
diff --git a/filter/multilang/filtersettings.php b/filter/multilang/filtersettings.php
new file mode 100644 (file)
index 0000000..895aa0e
--- /dev/null
@@ -0,0 +1,6 @@
+<?php  //$Id$
+
+$settings->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 (file)
index 277fa71..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-    // defaultsettings.php
-    // deafault settings are done here, saves doing all this twice in
-    // both the rendering routine and the config screen
-
-    function tex_defaultsettings( $force=false  ) {
-
-    global $CFG;
-
-        if (!isset($CFG->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','' );
-            }
-        }
-
-    } 
-?>
index 4200aa8..d352f85 100644 (file)
@@ -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
index 0885733..850ccfc 100644 (file)
@@ -24,8 +24,8 @@
 // NOTE: This Moodle text filter converts TeX expressions delimited
 // by either $$...$$ or by <tex...>...</tex> 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 .= "<a href=\"$CFG->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 .= "<a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">";
         } else {
           $output .= "<a target=\"popup\" title=\"TeX\" href=";
-          $output .= "\"$CFG->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 .= "<img class=\"texrender\" $title alt=\"$alt\" src=\"";
         if ($CFG->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 .= "</a>";
@@ -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 (file)
index 36bedf6..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-    // check the default settings
-    // $forcerest to be set in calling page
-    if (!isset($forcereset)) {
-        $forcereset = false;
-    }
-    require_once "defaultsettings.php";
-    tex_defaultsettings( $forcereset );
-
-    // bit of a bodge - clear the tex cache area
-    // so that any changes will display
-    if (file_exists( "$CFG->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 = '&#x2714;';
-    $txt->cross = '&#x2718;';
-
-    // check file exists & display tick or cross 
-    function texbinaryconfirm( $path ) {
-        global $txt;
-        if (is_file($path)) {
-            echo "<span style=\"color:green;\">$txt->tick</span>";
-        }
-        else {
-            echo "<span style=\"color:red;\">$txt->cross</span>";
-        }        
-    }
-?>
-
-<table cellpadding="9" cellspacing="0">
-    <tr valign="top">
-        <th align="right" scope="col"><?php echo $txt->latexsettings; ?></th>
-        <th>&nbsp;</th>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->latexpreamble; ?></td>
-        <td><textarea type="text" name="filter_tex_latexpreamble" cols="60" rows="5"><?php p($CFG->filter_tex_latexpreamble); ?></textarea></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->backgroundcolour; ?></td>
-        <td><input type="text" name="filter_tex_latexbackground" 
-            value="<?php p($CFG->filter_tex_latexbackground) ?>" /></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->density; ?></td>
-        <td><input type="text" name="filter_tex_density"
-            value="<?php p($CFG->filter_tex_density); ?>" /></td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->pathlatex; ?></td>
-        <td><input type="text" name="filter_tex_pathlatex" size="50"
-            value="<?php p($CFG->filter_tex_pathlatex); ?>" />
-            <?php texbinaryconfirm( $CFG->filter_tex_pathlatex ); ?>
-        </td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->pathdvips; ?></td>
-        <td><input type="text" name="filter_tex_pathdvips" size="50"
-            value="<?php p($CFG->filter_tex_pathdvips); ?>" />
-            <?php texbinaryconfirm( $CFG->filter_tex_pathdvips ); ?>
-        </td>
-    </tr>
-    <tr valign="top">
-        <td align="right"><?php echo $txt->pathconvert; ?></td>
-        <td><input type="text" name="filter_tex_pathconvert" size="50"
-            value="<?php p($CFG->filter_tex_pathconvert); ?>" />
-            <?php texbinaryconfirm( $CFG->filter_tex_pathconvert ); ?>
-        </td>
-    </tr>
-</table>
diff --git a/filter/tex/filtersettings.php b/filter/tex/filtersettings.php
new file mode 100644 (file)
index 0000000..111e531
--- /dev/null
@@ -0,0 +1,45 @@
+<?php  //$Id$
+
+require_once($CFG->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 (file)
index 0000000..9fbcf7e
--- /dev/null
@@ -0,0 +1,70 @@
+<?php  //$Id$
+
+function tex_filter_get_executable($debug=false) {
+    global $CFG;
+
+    $error_message1 = "Your system is not configured to run mimeTeX. You need to download the appropriate<br />"
+                     ."executable for you ".PHP_OS." platform from <a href=\"http://moodle.org/download/mimetex/\">"
+                     ."http://moodle.org/download/mimetex/</a>, or obtain the C source<br /> "
+                     ."from <a href=\"http://www.forkosh.com/mimetex.zip\">"
+                     ."http://www.forkosh.com/mimetex.zip</a>, compile it and "
+                     ."put the executable into your<br /> moodle/filter/tex/ directory.";
+
+    $error_message2 = "Custom mimetex is not executable!<br /><br />";
+
+    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');
+}
+
+?>
index 64bb46c..457703e 100644 (file)
     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');
     }
     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('&lt;','<',$texexp);
-                $texexp = str_replace('&gt;','>',$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('&lt;', '<', $texexp);
+                $texexp = str_replace('&gt;', '>', $texexp);
+                $texexp = preg_replace('!\r\n?!', ' ', $texexp);
+                $texexp = '\Large '.$texexp;
+                $cmd = tex_filter_get_cmd($pathname, $texexp);
                 system($cmd, $status);
             }
         }
         if (debugging()) {
             echo "The shell command<br />$cmd<br />returned status = $status<br />\n";
             echo "Image not found!<br />";
-            echo "Please try the <a href=\"$CFG->wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script</a>";
+            echo "Please try the <a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">debugging script</a>";
         } else {
             echo "Image not found!<br />";
-            echo "Please try the <a href=\"$CFG->wwwroot/$CFG->texfilterdir/texdebug.php\">debugging script</a><br />";
+            echo "Please try the <a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">debugging script</a><br />";
             echo "Please turn on debug mode in site configuration to see more info here.";
         }
     }
index ce54e08..b4426df 100644 (file)
@@ -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!');
         }
     }
 
-    $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";
             $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;
             }
             $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;
     }
 
         header("Content-type: text/html");
         echo "<html><body><pre>\n";
         if ($texexp) {
-            $texexp = str_replace('<','&lt;',$texexp);
-            $texexp = str_replace('>','&gt;',$texexp);
-            $texexp = str_replace('"','&quot;',$texexp);
+            $texexp = str_replace('<', '&lt;', $texexp);
+            $texexp = str_replace('>', '&gt;', $texexp);
+            $texexp = str_replace('"', '&quot;', $texexp);
             echo "$texexp\n\n";
         } else {
             echo "No text output available\n\n";
 
     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<br /> executable ";
-        $error_message1 .= "from <a href=\"http://moodle.org/download/mimetex/\">";
-        $error_message1 .= "http://moodle.org/download/mimetex/</a>, or obtain the ";
-        $error_message1 .= "C source<br /> from <a href=\"http://www.forkosh.com/mimetex.zip\">";
-        $error_message1 .= "http://www.forkosh.com/mimetex.zip</a>, compile it and ";
-        $error_message1 .= "put the executable into your<br /> moodle/filter/tex/ directory. ";
-        $error_message1 .= "You also need to edit your moodle/filter/tex/pix.php file<br />";
-        $error_message1 .= ' by adding the line<br /><pre>       case "' . PHP_OS . "\":\n";
-        $error_message1 .= "           \$cmd = \"\\\\\"\$CFG->dirroot/\$CFG->texfilterdir/";
-        $error_message1 .= 'mimetex.' . strtolower(PHP_OS) . "\\\\\" -e \\\\\"\$pathname\\\\\" \". escapeshellarg(\$texexp);";
-        $error_message1 .= "</pre>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` . "<br />\n";
 
 
     // test Tex/Ghostscript output - command execution only
-    function TexOutput( $expression, $graphic=false ) {
+    function TexOutput($expression, $graphic=false) {
         global $CFG;
         $output = '';
 
             $output .= "<b>Error:</b> convert executable ($CFG->filter_tex_pathconvert) is not readable<br />\n";
         }
 
-        // knowing that it might work.. 
-        $md5 = md5( $expression );
+        // knowing that it might work..
+        $md5 = md5($expression);
         $output .= "<p>base filename for expression is '$md5'</p>\n";
-  
+
         // temporary paths
         $tex = "$latex->temp_dir/$md5.tex";
         $dvi = "$latex->temp_dir/$md5.dvi";
         $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 .= "<p>Processing TeX expression:</p><pre>$expression</pre>\n";
-        $doc = $latex->construct_latex_document( $expression );
-        $fh = fopen( $tex, 'w' );
-        fputs( $fh, $doc );</