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);
// 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();
$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);
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}&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}&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&action=disable&auth=$auth\">";
- $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" /></a>";
- // $hideshow = "<a href=\"$url&action=disable&auth=$auth\"><input type=\"checkbox\" checked /></a>";
- $enabled = true;
- $displayname = "<span>$name</span>";
- }
- else {
- $hideshow = "<a href=\"$url&action=enable&auth=$auth\">";
- $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" /></a>";
- // $hideshow = "<a href=\"$url&action=enable&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&action=up&auth=$auth\">";
- $updown .= "<img src=\"{$CFG->pixpath}/t/up.gif\" alt=\"up\" /></a> ";
- }
- else {
- $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> ";
- }
- if ($updowncount < $authcount) {
- $updown .= "<a href=\"$url&action=down&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}&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);
?>
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);
}
}
}
- redirect("auth.php");
+ redirect($returnurl);
exit;
}
} else {
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);
echo '</p>';
$block->config_print();
echo '</form>';
- admin_externalpage_print_footer();
+ print_footer();
?>
$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()) {
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() ) {
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.'&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\'');
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()) {
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'); ?>" />
<?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&action=hide&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&action=show&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&action=up&filterpath=$upath\">";
- $updown .= "<img src=\"$img/up.gif\" alt=\"$txt->up\" /></a> ";
- }
- else {
- $updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> ";
- }
- if ($updowncount<$activefilterscount) {
- $updown .= "<a href=\"$myurl&action=down&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);
?>
// 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');
}
$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&currentfile=$currentfile&uselocal=1",
+ "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1",
$strlocalstringcustomization );
}
if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) {
$firstrow[] = new tabobject('usemaster',
- $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0",
+ "$CFG->wwwroot/$CFG->admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0",
$strlangpackmaintaining );
}
- $secondrow[] = new tabobject('missing', $CFG->wwwroot.'/admin/lang.php?mode=missing', $strmissingstrings );
- $secondrow[] = new tabobject('compare', $CFG->wwwroot.'/admin/lang.php?mode=compare', $streditstrings );
- $secondrow[] = new tabobject('helpfiles', $CFG->wwwroot.'/admin/lang.php?mode=helpfiles', $stredithelpdocs );
+ $secondrow[] = new tabobject('missing', "$CFG->wwwroot/$CFG->admin/lang.php?mode=missing", $strmissingstrings );
+ $secondrow[] = new tabobject('compare', "$CFG->wwwroot/$CFG->admin/lang.php?mode=compare", $streditstrings );
+ $secondrow[] = new tabobject('helpfiles', "$CFG->wwwroot/$CFG->admin/lang.php?mode=helpfiles", $stredithelpdocs );
$tabs = array($firstrow, $secondrow);
print_tabs($tabs, $currenttab, $inactive, $activated);
// 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) {
// 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)) {
break;
default:
- print_error('invalidactionparam', 'mnet', '/admin/mnet/access_control.php');
+ print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
}
}
// 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');
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);
}
<?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);
" class=\"icon\" alt=\"".get_string("course")."\" />";
foreach ($courses as $course) {
- $link = $CFG->wwwroot . '/admin/mnet/enr_course_enrol.php?'
+ $link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?"
. "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}";
echo '<tr>'
. "<td>$icon</td>"
. '</tr>';
$hosts = $enrolment->list_remote_servers();
foreach ($hosts as $host) {
- $coursesurl = "{$CFG->wwwroot}/admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}";
+ $coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&sesskey={$USER->sesskey}";
$coursecount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_course WHERE hostid={$host->id}");
if (empty($coursecount)) {
$coursecount = '?';
. "<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>';
}
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);
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()) {
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.
$moduleconfig($config);
}
} else {
+ admin_externalpage_setup('managemodules');
+
$moduleprefix = '';
}
/// 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);
$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()) {
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&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
));
}
class page_admin extends page_base {
var $section;
- var $pathtosection;
var $visiblepathtosection;
// hack alert!
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;
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 {
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.
}
$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() {
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();
?>
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();
?>
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]),
$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();
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>';
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();
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
?>
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
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
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
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
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
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
--- /dev/null
+<?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)));
+ }
+ }
+ }
+}
+?>
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
$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);
$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',
$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));
global $USER;
$primaryadminemail = $USER->email;
$primaryadminname = fullname($USER, true);
-
+
} else {
// no defaults during installation - admin user must be created first
$primaryadminemail = NULL;
// "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);
// "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));
$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);
// 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')));
$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')));
// 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));
+
?>
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
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
$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 {
}
}
-// 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();
?>
//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;
$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);
}
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')) {
} else {
$bookmarks = array();
}
-
+
if (isset($PAGE->section) and $PAGE->section == 'search'){
// the search page can't be properly bookmarked at present
$this->content->footer = '';
} else {
$this->content->footer = '';
}
-
+
return $this->content;
}
}
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'));
$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 {
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')) {
$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);
}
- error(get_string('nobookmarksforuser','admin'));
+ error(get_string('nobookmarksforuser','admin'));
die;
} else {
class block_admin_tree extends block_base {
var $currentdepth;
- var $spancounter;
+ var $divcounter;
var $tempcontent;
var $pathtosection;
var $expandjavascript;
$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();
global $CFG;
$strfolderopened = s(get_string('folderopened'));
- for ($i = 0; $i < $this->currentdepth; $i++) {
- $this->tempcontent .= " ";
- }
- $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 .= " ";
- }
- $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);
}
}
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);
}
$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";
$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>'.
+++ /dev/null
-<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>
--- /dev/null
+<?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));
+
+
+?>
+++ /dev/null
-<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>
--- /dev/null
+<?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));
+
+?>
+++ /dev/null
-<?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>
--- /dev/null
+<?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));
+
+
+?>
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);
}
}
- $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);
} else {
slasharguments($output, $md5);
}
- } else {
+ } else {
outputText($output);
}
exit;
$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;
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 ";
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>";
}
// 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.
}
$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>";
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;
# return $text;
# }
-
+
$text .= ' ';
preg_match_all('/@(@@+)([^@])/',$text,$matches);
$replacement = str_replace('@','@',$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);
$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)) {
$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);
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text);
}
}
- return $text;
+ return $text;
}
?>
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 = '';
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');
}
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('>','>',$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.";
}
}
+++ /dev/null
-<?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> </td>
- <td align="center"><?php echo $txt->badwordsconfig; ?><br />
- <i><?php echo $txt->badwordsdefault; ?></i></td>
- </tr>
-</table>
--- /dev/null
+<?php //$Id$
+
+$settings->add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'),
+ get_string('badwordsconfig', 'admin').'<br />'.get_string('badwordsdefault', 'admin'), ''));
+
+?>
+++ /dev/null
-<?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 );
- }
- }
-?>
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)
+++ /dev/null
-<?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>
--- /dev/null
+<?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));
+
+?>
+++ /dev/null
-<?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);
- }
-
-?>
+++ /dev/null
-<?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>
--- /dev/null
+<?php //$Id$
+
+$settings->add(new admin_setting_configcheckbox('filter_multilang_force_old', 'filter_multilang_force_old',
+ get_string('multilangforceold', 'admin'), 0));
+
+?>
+++ /dev/null
-<?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','' );
- }
- }
-
- }
-?>
// 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
// 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.
//-------------------------------------------------------------------------
// 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);
}
$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>";
$filename = $md5 . ".gif";
$text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp, '', '', $align, $alt), $text);
}
- return $text;
+ return $text;
}
-
?>
+++ /dev/null
-<?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 = '✔';
- $txt->cross = '✘';
-
- // 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> </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>
--- /dev/null
+<?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);
+}
+?>
--- /dev/null
+<?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');
+}
+
+?>
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 = '';
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('<','<',$texexp);
- $texexp = str_replace('>','>',$texexp);
- $texexp = preg_replace('!\r\n?!',' ',$texexp);
- $texexp = '\Large ' . $texexp;
- $texexp = escapeshellarg($texexp);
-
- if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) {
- $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe";
- $cmd = str_replace(' ','^ ',$cmd);
- $cmd .= " ++ -e \"$pathname\" -- $texexp";
- } else if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary
-
- $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname -- $texexp";
-
- } else { /// Auto-detect the right TeX binary
- switch (PHP_OS) {
-
- case "Linux":
- $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.linux\" -e \"$pathname\" -- $texexp";
- break;
-
- case "Darwin":
- $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" -- $texexp";
- break;
-
- case "FreeBSD":
- $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.freebsd\" -e \"$pathname\" $texexp";
- break;
-
- default: /// Nothing was found, so tell them how to fix it.
- if (debugging()) {
- echo "Make sure you have an appropriate MimeTeX binary here:\n\n";
- echo " $CFG->dirroot/$CFG->texfilterdir/mimetex\n\n";
- echo "and that it has the right permissions set on it as executable program.\n\n";
- echo "You can get the latest binaries for your ".PHP_OS." platform from: \n\n";
- echo " http://moodle.org/download/mimetex/";
- } else {
- echo "Mimetex executable was not found,\n";
- echo "Please turn on debug mode in site configuration to see more info here.";
- }
- die;
- break;
- }
- }
+ $texexp = str_replace('<', '<', $texexp);
+ $texexp = str_replace('>', '>', $texexp);
+ $texexp = preg_replace('!\r\n?!', ' ', $texexp);
+ $texexp = '\Large '.$texexp;
+ $cmd = tex_filter_get_cmd($pathname, $texexp);
system($cmd, $status);
}
}
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.";
}
}
$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('<','<',$texexp);
- $texexp = str_replace('>','>',$texexp);
- $texexp = str_replace('"','"',$texexp);
+ $texexp = str_replace('<', '<', $texexp);
+ $texexp = str_replace('>', '>', $texexp);
+ $texexp = str_replace('"', '"', $texexp);
echo "$texexp\n\n";
} else {
echo "No text output available\n\n";
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 );
- fclose( $fh );
+ $doc = $latex->construct_latex_document($expression);
+ $fh = fopen($tex, 'w');
+ fputs($fh, $doc);
+ fclose($fh);
// cd to temp dir
- chdir( $latex->temp_dir );
+ chdir($latex->temp_dir);
// step 1: latex command
$cmd = "$CFG->filter_tex_pathlatex --interaction=nonstopmode $tex";
- $output .= execute( $cmd );
+ $output .= execute($cmd);
// step 2: dvips command
$cmd = "$CFG->filter_tex_pathdvips -E $dvi -o $ps";
- $output .= execute( $cmd );
+ $output .= execute($cmd);
// step 3: convert command
$cmd = "$CFG->filter_tex_pathconvert -density 240 -trim $ps $gif ";
- $output .= execute( $cmd );
+ $output .= execute($cmd);
if (!$graphic) {
- echo( $output );
+ echo($output);
} else {
- $lastmodified = filemtime($gif);
- $lifetime = 86400;
- $filetype = 'image/gif';
- $image = "$md5.gif";
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
- header("Cache-control: max_age = $lifetime"); // a day
- header("Pragma: ");
- header("Content-disposition: inline; filename=$image");
- header("Content-length: ".filesize($gif));
- header("Content-type: $filetype");
- readfile("$gif");
+ send_file($gif, "$md5.gif");
}
}
- function execute( $cmd ) {
- exec( $cmd, $result, $code );
+ function execute($cmd) {
+ exec($cmd, $result, $code);
$output = "<pre>$ $cmd\n";
- $lines = implode( "\n", $result );
+ $lines = implode("\n", $result);
$output .= "OUTPUT: $lines\n";
$output .= "RETURN CODE: $code\n</pre>\n";
return $output;
function slasharguments($texexp) {
global $CFG;
- $admin = $CFG->wwwroot . '/' . $CFG->admin . '/config.php';
+ $admin = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=http';
$image = tex2image($texexp,true);
echo "<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 "<img src=\"$CFG->wwwroot/filter/tex/pix.php/$image\" align=\"absmiddle\"></p>\n";
echo "<p>Otherwise set it to file.php?file=/1/pic.jpg ";
echo "It should display correctly as ";
- echo "<img src=\"pix.php?file=$image\" align=\"absmiddle\"></p>\n";
+ echo "<img src=\"$CFG->wwwroot/filter/tex/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>";
}
$nomoodlecookie = true; // Because it interferes with caching
require_once("../../config.php");
+ require_once($CFG->dirroot.'/filter/tex/lib.php');
if (empty($CFG->textfilters)) {
error ('Filter not enabled!');
}
}
- $CFG->texfilterdir = "filter/tex";
- $CFG->teximagedir = "filter/tex";
-
error_reporting(E_ALL);
$texexp = urldecode($_SERVER['QUERY_STRING']);
$texexp = str_replace('formdata=','',$texexp);
if ($texexp) {
- //$texexp = stripslashes($texexp);
- $lifetime = 86400;
$image = md5($texexp) . ".gif";
$filetype = 'image/gif';
- if (!file_exists("$CFG->dataroot/$CFG->teximagedir")) {
- make_upload_directory($CFG->teximagedir);
+ if (!file_exists("$CFG->dataroot/filter/tex")) {
+ make_upload_directory("filter/tex");
}
- $pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
- $texexp = escapeshellarg($texexp);
- switch (PHP_OS) {
- case "Linux":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname -- $texexp" );
- break;
- case "WINNT":
- case "WIN32":
- case "Windows":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname -- $texexp");
- break;
- case "Darwin":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname -- $texexp" );
- break;
- }
+ $texexp = str_replace('<','<',$texexp);
+ $texexp = str_replace('>','>',$texexp);
+ $texexp = preg_replace('!\r\n?!',' ',$texexp);
+ $cmd = tex_filter_get_cmd($pathname, $texexp);
+ system($cmd, $status);
+
if (file_exists($pathname)) {
- $lastmodified = filemtime($pathname);
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
- header("Cache-control: max_age = $lifetime"); // a day
- header("Pragma: ");
- header("Content-disposition: inline; filename=$image");
- header("Content-length: ".filesize($pathname));
- header("Content-type: $filetype");
- readfile("$pathname");
+ send_file($pathname, $image);
} else {
echo "Image not found!";
}
exit;
+ } else {
+ echo "No tex expresion specified";
}
?>
<input type="submit" />
</form> <br /> <br />
<iframe name="inlineframe" align="middle" width="80%" height="100">
- <p>Something is wrong...</p>
+ <p>Something is wrong...</p>
</iframe>
</center> <br />
</body>
// If USER has admin capability, print a link to the site config page for this report
if (has_capability('moodle/site:config', $systemcontext)) {
- echo '<div id="siteconfiglink"><a href="' . $CFG->wwwroot . '/admin/settings.php?section=gradereportgrader">';
+ echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">';
echo get_string('changereportdefaults', 'grades');
echo "</a></div>\n";
}
foreach (explode(',',$frontpagelayout) as $v) {
switch ($v) { /// Display the main part of the front page.
- case strval(FRONTPAGENEWS):
+ case FRONTPAGENEWS:
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
$string['appearance'] = 'Appearance';
$string['aspellpath'] = 'Path to aspell';
$string['authentication'] = 'Authentication';
+$string['authsettings'] = 'Manage authentication';
$string['autolang'] = 'Language autodetect';
$string['autologinguests'] = 'Auto-login guests';
$string['availablelangs'] = 'Available language packs';
$string['badwordslist'] = 'Custom bad words list';
$string['blockinstances'] = 'Instances';
$string['blockmultiple'] = 'Multiple';
+$string['blocksettings'] = 'Manage blocks';
$string['bloglevel'] = 'Blog Visibility';
$string['bookmarkadded'] = 'Bookmark added.';
$string['bookmarkalreadyexists'] = 'You have already bookmarked this page.';
$string['cfgwwwrootslashwarning'] = 'You have defined $CFG->wwwroot incorrectly in your config.php file. You have included a \'/\' character at the end. Please remove it, or you will experience strange bugs like <a href=\'http://tracker.moodle.org/browse/MDL-11061\'>MDL-11061</a>.';
$string['change'] = 'change';
$string['changesitelang'] = 'Change site language';
+$string['checkboxyes'] = 'Yes';
+$string['checkboxno'] = 'No';
$string['choosefiletoedit'] = 'Choose file to edit';
$string['clamfailureonupload'] = 'On clam AV failure';
$string['cleanup'] = 'Cleanup';
+$string['commonsettings'] = 'Common settings';
$string['componentinstalled'] = 'Component Installed';
$string['confeditorhidebuttons'] = 'Select the buttons that should be hidden in the HTML editor.';
$string['configallowassign'] = 'You can allow people who have the roles on the left side to assign some of the column roles to other people';
$string['configenablehtmlpurifier'] = 'Use HTML Purifier instead of KSES for cleaning of untrusted text. HTML Purifier is actively developed and is believed to be more secure, but it is more resource intensive. Expect minor visual differences in the resulting html code. Please note that embed and object tags can not be enabled, MathML tags and old lang tags are not supported. ';
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
$string['configenablerssfeedsdisabled'] = 'It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
+$string['configenablerssfeedsdisabled2'] = 'RSS feeds are disabled at the server level. You need to enable them first in Server/RSS.';
$string['configenablestats'] = 'If you choose \'yes\' here, Moodle\'s cronjob will process the logs and gather some statistics. Depending on the amount of traffic on your site, this can take awhile. If you enable this, you will be able to see some interesting graphs and statistics about each of your courses, or on a sitewide basis.';
$string['configenabletrusttext'] = 'By default Moodle will always thoroughly clean text that comes from users to remove any possible bad scripts, media etc that could be a security risk. The Trusted Content system is a way of giving partcular users that you trust the ability to include these advanced features in their content without interference. To enable this system, you need to first enable this setting, and then grant the Trusted Content permission to a specific Moodle role. Texts created or uploaded by such users will be marked as trusted and will not be cleaned before display.';
$string['configenrolmentplugins'] = 'Please choose the enrolment plugins you wish to use. Don\'t forget to configure the settings properly.<br /><br />You have to indicate which plugins are enabled, and <strong>one</strong> plugin can be set as the default plugin for <em>interactive</em> enrolment. To disable interactive enrolment, set \"enrollable\" to \"No\" in required courses.';
$string['confignotloggedinroleid'] = 'Users who are not logged in to the site will be treated as if they have this role granted to them at the site context. Guest is almost always what you want here, but you might want to create roles that are less or more restrictive. Things like creating posts still require the user to log in properly.';
$string['configpasswordpolicy'] = 'Turning this on will make Moodle check user passwords against a valid password policy. Use the settings below to specify your policy (they will be ignored if you set this to \'No\').';
$string['configopentogoogle'] = 'If you enable this setting, then Google will be allowed to enter your site as a Guest. In addition, people coming in to your site via a Google search will automatically be logged in as a Guest. Note that this only provides transparent access to courses that already allow guest access.';
+$string['configoverride'] = 'Defined in config.php';
$string['configpathtoclam'] = 'Path to clam AV. Probably something like /usr/bin/clamscan or /usr/bin/clamdscan. You need this in order for clam AV to run.';
$string['configpathtodu'] = 'Path to du. Probably something like /usr/bin/du. If you enter this, pages that display directory contents will run much faster for directories with a lot of files.';
$string['configperfdebug'] = 'If you turn this on, performance info will be printed in the footer of the standard theme';
$string['defaultallowedmodules'] = 'Default allowed modules';
$string['defaultcourseroleid'] = 'Default role for users in a course';
$string['defaultrequestcategory'] = 'Default category for course requests';
+$string['defaultsettinginfo'] = 'Default: $a';
$string['defaultuserroleid'] = 'Default role for all users';
$string['defaultvalues'] = 'Default values';
$string['deleteerrors'] = 'Delete errors';
$string['editorspelling'] = 'Editor spelling';
$string['editstrings'] = 'Edit words or phrases';
$string['emoticons'] = 'Emoticons';
+$string['emptysettingvalue'] = 'Empty';
$string['enableajax'] = 'Enable AJAX';
$string['enablecourserequests'] = 'Enable course requests';
$string['enableglobalsearch'] = 'Enable global search';
$string['environmentxmlerror'] = 'Error reading environment data ($a->error_code)';
$string['errors'] = 'Errors';
$string['errorsetting'] = 'Could not save setting:';
-$string['errorwithsettings'] = 'Some settings were not changed due to an error:';
+$string['errorwithsettings'] = 'Some settings were not changed due to an error.';
$string['experimental'] = 'Experimental';
$string['extendedusernamechars'] = 'Allow extended characters in usernames';
$string['filecreated'] = 'New file created';
$string['filterall'] = 'Filter all strings';
$string['filtermatchoneperpage'] = 'Filter match once per page';
$string['filtermatchonepertext'] = 'Filter match once per text';
-$string['filtersettings'] = 'Filter settings';
+$string['filtersettings'] = 'Manage filters';
+$string['filtersettingsgeneral'] = 'General filter settings';
$string['filteruploadedfiles'] = 'Filter uploaded files';
$string['forcelogin'] = 'Force users to login';
$string['forceloginforprofiles'] = 'Force users to login for profiles';
$string['misc'] = 'Miscellaneous';
$string['mnetrestore_extusers'] = '<strong>Note:</strong> This backup file contains remote Moodle Network user accounts which will be restored as part of the process.';
$string['mnetrestore_extusers_mismatch'] = '<strong>Note:</strong> This backup file apparently originates from a different Moodle installation and contains remote Moodle Network user accounts that may fail to restore. This operation is unsupported. If you are certain that it was created on this Moodle installation, or you can ensure that all the needed Moodle Network Hosts are configured, you may want to still try the restore.';
+$string['modsettings'] = 'Manage activities';
$string['modulesecurity'] = 'Module security';
$string['multilangforceold'] = 'Force old multilang syntax: <span> without the class=\"multilang\" and <lang>';
$string['multilangupgrade'] = 'Multilang upgrade';
$string['riskxss'] = 'Users could add files and texts that allow cross-site scripting (XSS)';
$string['riskxssshort'] = 'XSS risk';
$string['rowpreviewnum'] = 'Preview rows';
+$string['rssglobaldisabled'] = 'Disabled at server level';
$string['runclamavonupload'] = 'Use clam AV on uploaded files';
$string['savechanges'] = 'Save Changes';
$string['search'] = 'Search';
single file, of any type.</p> <p>This might be a Word processor document, an image,
a zipped web site, or anything you ask them to submit.</p>';
$string['hideintro'] = 'Hide description before available date';
+$string['itemstocount'] = 'Count';
$string['late'] = '$a late';
$string['maximumgrade'] = 'Maximum grade';
$string['maximumsize'] = 'Maximum size';
// auth.php - created with Moodle 1.5 UNSTABLE DEVELOPMENT (2005010100)
+$string['actauthhdr'] = 'Active authentication plugins';
$string['alternatelogin'] = 'If you enter a URL here, it will be used as the login page for this site. The page should contain a form which has the action property set to <strong>\'$a\'</strong> and return fields <strong>username</strong> and <strong>password</strong>.<br />Be careful not to enter an incorrect URL as you may lock yourself out of this site.<br />Leave this setting blank to use the default login page.';
$string['alternateloginurl'] = 'Alternate Login URL';
$string['forgottenpassword'] = 'If you enter a URL here, it will be used as the lost password recovery page for this site. This is intended for sites where passwords are handled entirely outside of Moodle. Leave this blank to use the default password recovery.';
// block_course_list.php - created with Moodle 1.7 beta + (2006101003)
+$string['adminview'] = 'Admin view';
$string['allcourses'] = 'Admin user sees all courses';
$string['blockname'] = 'Course List';
$string['configadminview'] = 'What should the admin see in the course list block?';
$string['confighideallcourseslink'] = 'Hide \"All courses\" link at the bottom of the block. Link hiding does not affects Admin\'s view';
+$string['hideallcourseslink'] = 'Hide All courses link';
$string['owncourses'] = 'Admin user sees own courses';
?>
$string['blockname'] = 'Online Users';
$string['configtimetosee'] = 'Number of minutes determining the period of inactivity after which a user is no longer considered to be online.';
$string['periodnminutes'] = 'last $a minutes';
+$string['timetosee'] = 'Remove after inactivity (minutes)';
?>
$string['feedupdated'] = 'News feed updated';
$string['findmorefeeds'] = 'Find more rss feeds';
$string['managefeeds'] = 'Manage all my feeds';
+$string['numentries'] = 'Entries per feed';
$string['nofeeds'] = 'There are no RSS feeds defined for this site.';
$string['pickfeed'] = 'Pick a news feed';
$string['remotenewsfeed'] = 'Remote News Feed';
$string['sharedfeed'] = 'Shared feed';
$string['shownumentrieslabel'] = 'Max number entries to show per block.';
$string['submitters'] = 'Who will be allowed to define new rss feeds? Defined feeds are available for any page on your site.';
+$string['submitters2'] = 'Submitters';
$string['timeout'] = 'Time in minutes before an RSS feed expires in cache. Note that this time defines the minimum time before expiry; the feed will be refreshed in cache on the next cron execution after expiry. Recommended values are 30 mins or greater.';
+$string['timeout2'] = 'Timeout';
$string['timeoutdesc'] = 'Time in minutes for an RSS feed to live in cache.';
$string['updatefeed'] = 'Update a news feed URL:';
$string['validatefeed'] = 'Validate feed';
$string['messageenter'] = '$a has just entered this chat';
$string['messageexit'] = '$a has left this chat';
$string['messages'] = 'Messages';
+$string['method'] = 'Chat method';
$string['methoddaemon'] = 'Chat server daemon';
$string['methodnormal'] = 'Normal method';
$string['modulename'] = 'Chat';
$string['normalkeepalive'] = 'KeepAlive';
$string['normalstream'] = 'Stream';
$string['noscheduledsession'] = 'No scheduled session';
+$string['oldping'] = 'Disconnect timeout';
+$string['refreshroom'] = 'Refresh room';
+$string['refreshuserlist'] = 'Refresh user list';
$string['removemessages'] = 'Remove all messages';
$string['repeatdaily'] = 'At the same time every day';
$string['repeatnone'] = 'No repeats - publish the specified time only';
$string['repeattimes'] = 'Repeat sessions';
$string['repeatweekly'] = 'At the same time every week';
+$string['serverhost'] = 'Server name';
+$string['serverip'] = 'Server ip';
+$string['servermax'] = 'Max users';
+$string['serverport'] = 'Server port';
$string['savemessages'] = 'Save past sessions';
$string['seesession'] = 'See this session';
$string['sessions'] = 'Chat sessions';
$string['strftimemessage'] = '%%H:%%M';
$string['studentseereports'] = 'Everyone can view past sessions';
+$string['updatemethod'] = 'Update method';
$string['viewreport'] = 'View past chat sessions';
?>
$string['csvcolumnduplicates'] = 'Duplicate columns detected.';
$string['csvfewcolumns'] = 'Not enough columns, please verify the delimiter setting.';
$string['csvweirdcolumns'] = 'Invalid CSV file format - number of columns is not constant!';
+$string['dbupdatefailed'] = 'Database update failed.';
$string['downloadedfilecheckfailed'] = 'Downloaded file check failed.';
$string['duplicateusername'] = 'Duplicate username - skiping record';
$string['errorcleaningdirectory'] = 'Error cleaning directory \"$a\"';
$string['anyrole'] = 'any role';
$string['anyvalue'] = 'any value';
$string['categoryrole'] = 'Category role';
+$string['tablenosave'] = 'Changes in table above are saved automatically.';
$string['contains'] = 'contains';
$string['courserole'] = 'Course role';
$string['courserolelabel'] = '$a->label is $a->rolename in $a->coursename from $a->categoryname';
$string['bynameondate'] = 'by $a->name - $a->date';
$string['cannotviewpostyet'] = 'You cannot read other students questions in this discussion yet because you haven\'t posted';
$string['cannotadddiscussion'] = 'Adding discussions to this forum requires group membership.';
+$string['cleanreadtime'] = 'Mark old posts as read hour';
$string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.';
$string['configdisplaymode'] = 'The default display mode for discussions if one isn\'t set.';
$string['configenablerssfeeds'] = 'This switch will enable the possibility of RSS feeds for all forums. You will still need to turn feeds on manually in the settings for each forum.';
$string['discussionsstartedbyrecent'] = 'Discussions recently started by $a';
$string['discussthistopic'] = 'Discuss this topic';
$string['displayend'] = 'Display end';
+$string['displaymode'] = 'Display mode';
$string['displayperiod'] = 'Display Period';
$string['displaystart'] = 'Display start';
$string['eachuserforum'] = 'Each person posts one discussion';
$string['introteacher'] = 'A forum for teacher-only notes and discussion';
$string['lastpost'] = 'Last post';
$string['learningforums'] = 'Learning forums';
+$string['longpost'] = 'Long post';
$string['mailnow'] = 'Mail now';
+$string['manydiscussions'] = 'Discussions per page';
$string['markalldread'] = 'Mark all posts in this discussion read.';
$string['markallread'] = 'Mark all posts in this forum read.';
$string['markread'] = 'Mark read';
$string['numposts'] = '$a posts';
$string['olderdiscussions'] = 'Older discussions';
$string['oldertopics'] = 'Older topics';
+$string['oldpostdays'] = 'Read after days';
$string['openmode0'] = 'No discussions, no replies';
$string['openmode1'] = 'No discussions, but replies are allowed';
$string['openmode2'] = 'Discussions and replies are allowed';
$string['repliesone'] = '$a reply so far';
$string['reply'] = 'Reply';
$string['replyforum'] = 'Reply to forum';
+$string['replytouser'] = 'Use email address in reply';
$string['resetforumsall'] = 'Delete all posts';
$string['resetforums'] = 'Delete posts from';
$string['resetsubscriptions'] = 'Delete all forum subscriptions';
$string['searchwords'] = 'These words can appear anywhere in the post';
$string['seeallposts'] = 'See all posts made by this user';
$string['sendinratings'] = 'Send in my latest ratings';
+$string['shortpost'] = 'Short post';
$string['showsubscribers'] = 'Show/edit current subscribers';
$string['singleforum'] = 'A single simple discussion';
$string['startedby'] = 'Started by';
$string['subscription'] = 'Subscription';
$string['subscriptions'] = 'Subscriptions';
$string['thisforumisthrottled'] = 'This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at $a->blockafter posting(s) in $a->blockperiod';
+$string['timedposts'] = 'Timed posts';
$string['timestartenderror'] = 'Display end date cannot be earlier than the start date';
$string['trackforum'] = 'Track unread posts';
$string['tracking'] = 'Track';
$string['unsubscribe'] = 'Unsubscribe from this forum';
$string['unsubscribed'] = 'Unsubscribed';
$string['unsubscribeshort'] = 'Unsubscribe';
+$string['usermarksread'] = 'Manual message read marking';
$string['warnafter'] = 'Post threshold for warning';
$string['yesforever'] = 'Yes, forever';
$string['yesinitially'] = 'Yes, initially';
$string['addresource'] = 'Add a resource';
$string['affectedresources'] = 'Affected resources';
+$string['allowlocalfiles'] = 'Allow local files';
+$string['autofilerename'] = 'Update link if file renamed';
$string['back'] = 'Back';
+$string['blockdeletingfile'] = 'BLock deleting of referenced files';
$string['browserepository'] = 'Browse repository';
$string['choose'] = 'Choose';
$string['chooseafile'] = 'Choose or upload a file';
$string['filename'] = 'File name';
$string['filtername'] = 'Resource Names Auto-linking';
$string['frameifpossible'] = 'Put resource in a frame to keep site navigation visible';
+$string['framesize'] = 'Frame size';
$string['fulltext'] = 'Full text';
$string['htmlfragment'] = 'HTML fragment';
$string['imspackageloaded'] = 'Package loaded';
$string['redeploy'] = 'Deploy again';
$string['repository'] = 'IMS repository';
$string['resource:view'] = 'View resource';
+$string['resourcedefaulturl'] = 'Default URL';
$string['resourcetype'] = 'Type of resource';
$string['resourcetype1'] = 'Reference';
$string['resourcetype2'] = 'Web Page';
$string['vol'] = 'Vol';
$string['warningblockingdelete'] = 'Warning: Delete operation is blocked by existing resource. Either update your resources first or ask administartor to disable this safety mechanism in global Resource configuration.';
$string['warningdisabledrename'] = 'Warning: The automatic renaming of references in resources is disabled. Please update affected resources manually if needed. Administrator can also enable automatic renaming in global Resource configuration.';
+$string['websearchdefault'] = 'Websearch default';
?>
if ($result) {
if ($CFG->version >= $version) {
// something really wrong is going on in main upgrade script
- error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version.");
+ error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version.");
}
set_config('version', $version);
} else {
$oldupgrade_status = $oldupgrade_function($currmodule->version, $module);
if (!$oldupgrade_status) {
notify ('Upgrade function ' . $oldupgrade_function .
- ' did not complete successfully.');
+ ' did not complete successfully.');
}
} else if ($oldupgrade) {
notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' .
if ( is_readable($fullmod .'/defaults.php')) {
// Insert default values for any important configuration variables
unset($defaults);
- include_once($fullmod .'/defaults.php');
+ include($fullmod .'/defaults.php'); // include here means execute, not library include
if (!empty($defaults)) {
foreach ($defaults as $name => $value) {
if (!isset($CFG->$name)) {
/// admin_settingpage's, admin_externalpage's, and admin_category's all inherit
/// from part_of_admin_tree (a pseudointerface). This interface insists that
/// a class has a check_access method for access permissions, a locate method
-/// used to find a specific node in the admin tree, and a path method used
-/// to determine the path to a specific node in the $ADMIN tree.
+/// used to find a specific node in the admin tree and find parent path.
/// admin_category's inherit from parentable_part_of_admin_tree. This pseudo-
/// interface ensures that the class implements a recursive add function which
/// used.
-/// MISCELLANEOUS STUFF (used by classes defined below) ///////////////////////
-include_once($CFG->dirroot . '/backup/lib.php');
-
/// CLASS DEFINITIONS /////////////////////////////////////////////////////////
/**
return;
}
+ /**
+ * Search using query
+ * @param strin query
+ * @return mixed array-object structure of found settings and pages
+ */
+ function search($query) {
+ trigger_error('Admin class does not implement method <strong>search()</strong>', E_USER_WARNING);
+ return;
+ }
+
/**
* Verifies current user's access to this part_of_admin_tree.
*
trigger_error('Admin class does not implement method <strong>is_hidden()</strong>', E_USER_WARNING);
return;
}
-
- /**
- * Determines the path to $name in the admin tree.
- *
- * Used to determine the path to $name in the admin tree. If a class inherits only
- * part_of_admin_tree and not parentable_part_of_admin_tree, then this method should
- * check if $this->name matches $name. If it does, $name is pushed onto the $path
- * array (at the end), and $path should be returned. If it doesn't, NULL should be
- * returned.
- *
- * If a class inherits parentable_part_of_admin_tree, it should do the above, but not
- * return NULL on failure. Instead, it pushes $this->name onto $path, and then
- * recursively calls path() on its child objects. If any are non-NULL, it should
- * return $path (being certain that the last element of $path is equal to $name).
- * If they are all NULL, it returns NULL.
- *
- * @param string $name The internal name of the part_of_admin_tree we're searching for.
- * @param array $path Not used on external calls. Defaults to empty array.
- * @return mixed If found, an array containing the internal names of each part_of_admin_tree that leads to $name. If not found, NULL.
- */
- function path($name, $path = array()) {
- trigger_error('Admin class does not implement method <strong>path()</strong>', E_USER_WARNING);
- return;
- }
}
/**
* @param part_of_admin_tree &$something The object to be added.
* @return bool True on success, false on failure.
*/
- function add($destinationname, &$something) {
+ function add($destinationname, $something) {
trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING);
return;
}
*/
var $hidden;
- // constructor for an empty admin category
- // $name is the internal name of the category. it MUST be unique in the entire hierarchy
- // $visiblename is the displayed name of the category. use a get_string for this
+ /**
+ * paths
+ */
+ var $path;
+ var $visiblepath;
/**
* Constructor for an empty admin category
* @param string $name The internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
* @param string $visiblename The displayed named for this category. Usually obtained through get_string()
* @param bool $hidden hide category in admin tree block
- * @return mixed Returns the new object.
*/
- function admin_category($name, $visiblename, $hidden = false) {
- $this->children = array();
- $this->name = $name;
+ function admin_category($name, $visiblename, $hidden=false) {
+ $this->children = array();
+ $this->name = $name;
$this->visiblename = $visiblename;
- $this->hidden = $hidden;
+ $this->hidden = $hidden;
}
/**
- * Finds the path to the part_of_admin_tree called $name.
+ * Returns a reference to the part_of_admin_tree object with internal name $name.
*
- * @param string $name The internal name that we're searching for.
- * @param array $path Used internally for recursive calls. Do not specify on external calls. Defaults to array().
- * @return mixed An array of internal names that leads to $name, or NULL if not found.
+ * @param string $name The internal name of the object we want.
+ * @param bool $findpath initialize path and visiblepath arrays
+ * @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
*/
- function path($name, $path = array()) {
-
- $path[count($path)] = $this->name;
-
+ function &locate($name, $findpath=false) {
if ($this->name == $name) {
- return $path;
+ if ($findpath) {
+ $this->visiblepath[] = $this->visiblename;
+ $this->path[] = $this->name;
+ }
+ return $this;
}
- foreach($this->children as $child) {
- if ($return = $child->path($name, $path)) {
- return $return;
+ $return = NULL;
+ foreach($this->children as $childid=>$unused) {
+ if ($return =& $this->children[$childid]->locate($name, $findpath)) {
+ break;
}
}
- return NULL;
+ if (!is_null($return) and $findpath) {
+ $return->visiblepath[] = $this->visiblename;
+ $return->path[] = $this->name;
+ }
+ return $return;
}
/**
- * Returns a reference to the part_of_admin_tree object with internal name $name.
- *
- * @param string $name The internal name of the object we want.
- * @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
+ * Search using query
+ * @param strin query
+ * @return mixed array-object structure of found settings and pages
*/
- function &locate($name) {
-
- if ($this->name == $name) {
- return $this;
- }
-
- foreach($this->children as $child) {
- if ($return =& $child->locate($name)) {
- return $return;
- }
+ function search($query) {
+ $result = array();
+ foreach ($this->children as $child) {
+ $result = array_merge($result, $child->search($query));
}
- $return = NULL;
- return $return;
+ return $result;
}
/**
/**
* Adds a part_of_admin_tree to a child or grandchild (or great-grandchild, and so forth) of this object.
*
- * @param string $destinationame The internal name of the immediate parent that we want for &$something.
- * @param mixed &$something A part_of_admin_tree object to be added.
- * @param int $precedence The precedence of &$something when displayed. Smaller numbers mean it'll be displayed higher up in the admin menu. Defaults to '', meaning "next available position".
- * @return bool True if successfully added, false if &$something is not a part_of_admin_tree or if $name is not found.
+ * @param string $destinationame The internal name of the immediate parent that we want for $something.
+ * @param mixed $something A part_of_admin_tree or setting instanceto be added.
+ * @return bool True if successfully added, false if $something can not be added.
*/
- function add($destinationname, &$something, $precedence = '') {
-
- if (!is_a($something, 'part_of_admin_tree')) {
+ function add($parentname, $something) {
+ $parent =& $this->locate($parentname);
+ if (is_null($parent)) {
+ debugging('parent does not exist!');
return false;
}
- if ($destinationname == $this->name) {
- if ($precedence === '') {
- $this->children[] = $something;
- } else {
- if (isset($this->children[$precedence])) { // this should never, ever be triggered in a release version of moodle.
- echo ('<font style="color: red;">There is a precedence conflict in the category ' . $this->name . '. The object named ' . $something->name . ' is overwriting the object named ' . $this->children[$precedence]->name . '.</font><br />');
- }
- $this->children[$precedence] = $something;
+ if (is_a($something, 'part_of_admin_tree')) {
+ if (!is_a($parent, 'parentable_part_of_admin_tree')) {
+ debugging('error - parts of tree can be inserted only into parentable parts');
+ return false;
}
+ $parent->children[] = $something;
return true;
- }
- unset($entries);
-
- $entries = array_keys($this->children);
-
- foreach($entries as $entry) {
- $child =& $this->children[$entry];
- if (is_a($child, 'parentable_part_of_admin_tree')) {
- if ($child->add($destinationname, $something, $precedence)) {
- return true;
- }
- }
+ } else {
+ debugging('error - can not add this element');
+ return false;
}
- return false;
-
}
/**
* @return bool True if the user has access to atleast one child in this category, false otherwise.
*/
function check_access() {
-
- $return = false;
foreach ($this->children as $child) {
- $return = $return || $child->check_access();
+ if ($child->check_access()) {
+ return true;
+ }
}
-
- return $return;
-
+ return false;
}
/**
}
}
+class admin_root extends admin_category {
+ /**
+ * list of errors
+ */
+ var $errors;
+
+ /**
+ * search query
+ */
+ var $search;
+
+ /**
+ * full tree flag - true means all settings required, false onlypages required
+ */
+ var $fulltree;
+
+
+ function admin_root() {
+ parent::admin_category('root', get_string('administration'), false);
+ $this->errors = array();
+ $this->search = '';
+ $this->fulltree = true;
+ }
+}
+
/**
* Links external PHP pages into the admin tree.
*
*/
var $hidden;
+ /**
+ * visible path
+ */
+ var $path;
+ var $visiblepath;
+
/**
* Constructor for adding an external page into the admin tree.
*
* @param string $url The external URL that we should link to when someone requests this external page.
* @param mixed $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'.
*/
- function admin_externalpage($name, $visiblename, $url, $req_capability = 'moodle/site:config', $hidden=false, $context=NULL) {
- $this->name = $name;
+ function admin_externalpage($name, $visiblename, $url, $req_capability='moodle/site:config', $hidden=false, $context=NULL) {
+ $this->name = $name;
$this->visiblename = $visiblename;
- $this->url = $url;
+ $this->url = $url;
if (is_array($req_capability)) {
$this->req_capability = $req_capability;
} else {
$this->req_capability = array($req_capability);
}
- $this->hidden = $hidden;
+ $this->hidden = $hidden;
$this->context = $context;
}
- /**
- * Finds the path to the part_of_admin_tree called $name.
- *
- * @param string $name The internal name that we're searching for.
- * @param array $path Used internally for recursive calls. Do not specify on external calls. Defaults to array().
- * @return mixed An array of internal names that leads to $name, or NULL if not found.
- */
- function path($name, $path = array()) {
- if ($name == $this->name) {
- array_push($path, $this->name);
- return $path;
- } else {
- return NULL;
- }
- }
-
/**
* Returns a reference to the part_of_admin_tree object with internal name $name.
*
* @param string $name The internal name of the object we want.
* @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
*/
- function &locate($name) {
- $return = ($this->name == $name ? $this : NULL);
- return $return;
+ function &locate($name, $findpath=false) {
+ if ($this->name == $name) {
+ if ($findpath) {
+ $this->visiblepath = array($this->visiblename);
+ $this->path = array($this->name);
+ }
+ return $this;
+ } else {
+ $return = NULL;
+ return $return;
+ }
}
function prune($name) {
return false;
}
+ /**
+ * Search using query
+ * @param strin query
+ * @return mixed array-object structure of found settings and pages
+ */
+ function search($query) {
+ $textlib = textlib_get_instance();
+
+ $found = false;
+ if (strpos(strtolower($this->name), $query) !== false) {
+ $found = true;
+ } else if (strpos($textlib->strtolower($this->visiblename), $query) !== false) {
+ $found = true;
+ }
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = array();
+ return array($this->name => $result);
+ } else {
+ return array();
+ }
+ }
+
/**
* Determines if the current user has access to this external page based on $this->req_capability.
- *
- * @uses CONTEXT_SYSTEM
- * @uses SITEID
* @return bool True if user has access, false otherwise.
*/
function check_access() {
*/
var $hidden;
- // see admin_category
- function path($name, $path = array()) {
- if ($name == $this->name) {
- array_push($path, $this->name);
- return $path;
+ /**
+ * paths
+ */
+ var $path;
+ var $visiblepath;
+
+ // see admin_externalpage
+ function admin_settingpage($name, $visiblename, $req_capability='moodle/site:config', $hidden=false, $context=NULL) {
+ $this->settings = new object();
+ $this->name = $name;
+ $this->visiblename = $visiblename;
+ if (is_array($req_capability)) {
+ $this->req_capability = $req_capability;
} else {
- return NULL;
+ $this->req_capability = array($req_capability);
}
+ $this->hidden = $hidden;
+ $this->context = $context;
}
// see admin_category
- function &locate($name) {
- $return = ($this->name == $name ? $this : NULL);
- return $return;
+ function &locate($name, $findpath=false) {
+ if ($this->name == $name) {
+ if ($findpath) {
+ $this->visiblepath = array($this->visiblename);
+ $this->path = array($this->name);
+ }
+ return $this;
+ } else {
+ $return = NULL;
+ return $return;
+ }
}
- function prune($name) {
- return false;
- }
+ function search($query) {
+ $found = array();
- // see admin_externalpage
- function admin_settingpage($name, $visiblename, $req_capability = 'moodle/site:config', $hidden=false, $context=NULL) {
- global $CFG;
- $this->settings = new stdClass();
- $this->name = $name;
- $this->visiblename = $visiblename;
- if (is_array($req_capability)) {
- $this->req_capability = $req_capability;
+ foreach ($this->settings as $setting) {
+ if ($setting->is_related($query)) {
+ $found[] = $setting;
+ }
+ }
+
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = $found;
+ return array($this->name => $result);
+ }
+
+ $textlib = textlib_get_instance();
+
+ $found = false;
+ if (strpos(strtolower($this->name), $query) !== false) {
+ $found = true;
+ } else if (strpos($textlib->strtolower($this->visiblename), $query) !== false) {
+ $found = true;
+ }
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = array();
+ return array($this->name => $result);
} else {
- $this->req_capability = array($req_capability);
+ return array();
}
- $this->hidden = false;
- $this->context = $context;
}
- // not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
- // n.b. each admin_setting in an admin_settingpage must have a unique internal name
- // &$setting is the admin_setting object you want to add
- // returns true if successful, false if not (will fail if &$setting is an admin_setting or child thereof)
- function add(&$setting) {
- if (is_a($setting, 'admin_setting')) {
- $this->settings->{$setting->name} =& $setting;
- return true;
- }
+ function prune($name) {
return false;
}
+ /**
+ * not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
+ * n.b. each admin_setting in an admin_settingpage must have a unique internal name
+ * @param object $setting is the admin_setting object you want to add
+ * @return true if successful, false if not
+ */
+ function add($setting) {
+ if (!is_a($setting, 'admin_setting')) {
+ debugging('error - not a setting instance');
+ return false;
+ }
+
+ $this->settings->{$setting->name} = $setting;
+ return true;
+ }
+
// see admin_externalpage
function check_access() {
if (!get_site()) {
return false;
}
- // outputs this page as html in a table (suitable for inclusion in an admin pagetype)
- // returns a string of the html
+ /**
+ * outputs this page as html in a table (suitable for inclusion in an admin pagetype)
+ * returns a string of the html
+ */
function output_html() {
- $return = '<fieldset>' . "\n";
- $return .= '<div class="clearer"><!-- --></div>' . "\n";
- foreach($this->settings as $setting) {
- $return .= $setting->output_html();
- }
- $return .= '</fieldset>';
- return $return;
- }
-
- // writes settings (the ones that have been added to this admin_settingpage) to the database, or wherever else they're supposed to be written to
- // -- calls write_setting() to each child setting, sending it only the data that matches each setting's internal name
- // $data should be the result from data_submitted()
- // returns an empty string if everything went well, otherwise returns a printable error string (that's language-specific)
- function write_settings($data) {
- $return = '';
+ $adminroot =& admin_get_root();
+ $return = '<fieldset>'."\n".'<div class="clearer"><!-- --></div>'."\n";
foreach($this->settings as $setting) {
- if (isset($data['s_' . $setting->name])) {
- $return .= $setting->write_setting($data['s_' . $setting->name]);
+ $fullname = $setting->get_full_name();
+ if (array_key_exists($fullname, $adminroot->errors)) {
+ $data = $adminroot->errors[$fullname]->data;
} else {
- $return .= $setting->write_setting('');
+ $data = $setting->get_setting();
+ if (is_null($data)) {
+ $data = $setting->get_defaultsetting();
+ }
}
+ $return .= $setting->output_html($data);
}
+ $return .= '</fieldset>';
return $return;
}
}
-// read & write happens at this level; no authentication
+/**
+ * Admin settings class. Only exists on setting pages.
+ * Read & write happens at this level; no authentication.
+ */
class admin_setting {
var $name;
var $visiblename;
var $description;
var $defaultsetting;
+ var $updatedcallback;
+ var $plugin; // null means main config table
+ /**
+ * Constructor
+ * @param $name string unique ascii name
+ * @param $visiblename string localised name
+ * @param strin $description localised long description
+ * @param mixed $defaultsetting string or array depending on implementation
+ */
function admin_setting($name, $visiblename, $description, $defaultsetting) {
- $this->name = $name;
- $this->visiblename = $visiblename;
- $this->description = $description;
+ $this->name = $name;
+ $this->visiblename = $visiblename;
+ $this->description = $description;
$this->defaultsetting = $defaultsetting;
}
+ function get_full_name() {
+ return 's_'.$this->plugin.'_'.$this->name;
+ }
+
+ function get_id() {
+ return 'id_s_'.$this->plugin.'_'.$this->name;
+ }
+
+ function config_read($name) {
+ global $CFG;
+ if ($this->plugin === 'backup') {
+ require_once($CFG->dirroot.'/backup/lib.php');
+ $backupconfig = backup_get_config();
+ if (isset($backupconfig->$name)) {
+ return $backupconfig->$name;
+ } else {
+ return NULL;
+ }
+
+ } else if (!empty($this->plugin)) {
+ $value = get_config($this->plugin, $name);
+ return $value === false ? NULL : $value;
+
+ } else {
+ if (isset($CFG->$name)) {
+ return $CFG->$name;
+ } else {
+ return NULL;
+ }
+ }
+ }
+
+ function config_write($name, $value) {
+ global $CFG;
+ if ($this->plugin === 'backup') {
+ require_once($CFG->dirroot.'/backup/lib.php');
+ return (boolean)backup_set_config($name, $value);
+ } else {
+ return (boolean)set_config($name, $value, $this->plugin);
+ }
+ }
+
+ /**
+ * Returns current value of this setting
+ * @return mixed array or string depending on instance, NULL means not set yet
+ */
function get_setting() {
- return NULL; // has to be overridden
+ // has to be overridden
+ return NULL;
}
+ /**
+ * Returns default setting if exists
+ * @return mixed array or string depending on instance; NULL means no default, user must supply
+ */
function get_defaultsetting() {
return $this->defaultsetting;
}
+ /**
+ * Store new setting
+ * @param mixed string or array, must not be NULL
+ * @return '' if ok, string error message otherwise
+ */
function write_setting($data) {
- return; // has to be overridden
+ // should be overridden
+ return '';
}
- function output_html() {
- return; // has to be overridden
+ /**
+ * Return part of form with setting
+ * @param mixed data array or string depending on setting
+ * @return string
+ */
+ function output_html($data) {
+ // should be overridden
+ return;
+ }
+
+ /**
+ * function called if setting updated - cleanup, cache reset, etc.
+ */
+ function set_updatedcallback($functionname) {
+ $this->updatedcallback = $functionname;
+ }
+
+ /**
+ * Is setting related to query text - used when searching
+ * @param string $query
+ * @return bool
+ */
+ function is_related($query) {
+ if (strpos(strtolower($this->name), $query) !== false) {
+ return true;
+ }
+ $textlib = textlib_get_instance();
+ if (strpos($textlib->strtolower($this->visiblename), $query) !== false) {
+ return true;
+ }
+ if (strpos($textlib->strtolower($this->description), $query) !== false) {
+ return true;
+ }
+ return false;
}
+}
+/**
+ * Dummy settings class - workaround for keeping empty categories visible
+ */
+class admin_setting_dummy extends admin_setting {
+ function admin_setting_dummy() {
+ parent::admin_setting('dummy', 'dummy', 'dummy', NULL);
+ }
}
+/**
+ * No setting - just heading and text.
+ */
+class admin_setting_heading extends admin_setting {
+ /**
+ * not a setting, just text
+ * @param string $name of setting
+ * @param string $heading heading
+ * @param string $information text in box
+ */
+ function admin_setting_heading($name, $heading, $information) {
+ parent::admin_setting($name, $heading, $information, '');
+ }
+
+ function get_setting() {
+ return true;
+ }
+
+ function get_defaultsetting() {
+ return true;
+ }
+
+ function write_setting($data) {
+ // do not write any setting
+ return '';
+ }
+
+ function output_html($data) {
+ $return = '';
+ if ($this->visiblename != '') {
+ $return .= print_heading('<a name="'.$this->name.'">'.$this->visiblename.'</a>', '', 3, 'main', true);
+ }
+ if ($this->description != '') {
+ $return .= print_box($this->description, 'generalbox formsettingheading', '', true);
+ }
+ return $return;
+ }
+}
+/**
+ * The most flexibly setting, user is typing text
+ */
class admin_setting_configtext extends admin_setting {
var $paramtype;
+ /**
+ * config text contructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defaultsetting
+ * @param mixed $paramtype int means PARAM_XXX type, string is a allowed format in regex
+ */
function admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype=PARAM_RAW) {
$this->paramtype = $paramtype;
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
- // returns a string or NULL
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
+ return $this->config_read($this->name);
}
- // $data is a string
function write_setting($data) {
+ // $data is a string
if (!$this->validate($data)) {
- return get_string('validateerror', 'admin') . $this->visiblename . '<br />';
+ return get_string('validateerror', 'admin');
}
- return (set_config($this->name,$data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
}
function validate($data) {
}
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $current = $this->defaultsetting;
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default)) {
+ if ($default === '') {
+ $default = get_string('emptysettingvalue', 'admin');
+ }
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', s($default)).'</span>';
+ } else {
+ $defaultinfo = '';
+ }
+
+ if ($this->paramtype === PARAM_INT) {
+ $paramclass = 'class="number"';
} else {
- $current = $this->get_setting();
+ $paramclass = '';
}
- return format_admin_setting($this->name, $this->visiblename,
- '<input type="text" class="form-text" id="id_s_'.$this->name.'" name="s_'.$this->name.'" value="'.s($current).'" />',
+
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-text">'
+ .'<input type="text" '.$paramclass.' id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'
+ .$defaultinfo.'</div>',
$this->description);
}
-
}
-class admin_setting_configpasswordunmask extends admin_setting_configtext {
+/**
+ * General text area without html editor.
+ */
+class admin_setting_configtextarea extends admin_setting_configtext {
+ var $rows;
+ var $cols;
- function admin_setting_configpasswordunmask($name, $visiblename, $description, $defaultsetting, $paramtype=PARAM_RAW) {
+ function admin_setting_configtextarea($name, $visiblename, $description, $defaultsetting, $paramtype=PARAM_RAW, $cols='80', $rows='8') {
+ $this->rows = $rows;
+ $this->cols = $cols;
parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype);
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $current = $this->defaultsetting;
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default)) {
+ if ($default === '') {
+ $default = get_string('emptysettingvalue', 'admin');
+ }
+ $defaultinfo = '<div class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', '<br />'.format_text($default, FORMAT_PLAIN)).'</div>';
} else {
- $current = $this->get_setting();
+ $defaultinfo = '';
}
- $id = 'id_s_'.$this->name;
- $unmask = get_string('unmaskpassword', 'form');
- $unmaskjs = '<script type="text/javascript">
+
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-textarea" ><textarea rows="'.$this->rows.'" cols="'.$this->cols.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'">'.s($data).'</textarea>'.$defaultinfo.'</div>',
+ $this->description);
+ }
+}
+
+/**
+ * Password field, allows unmasking of password
+ */
+class admin_setting_configpasswordunmask extends admin_setting_configtext {
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defaultsetting default password
+ */
+ function admin_setting_configpasswordunmask($name, $visiblename, $description, $defaultsetting) {
+ parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting, PARAM_RAW);
+ }
+
+ function output_html($data) {
+ $id = $this->get_id();
+ $unmask = get_string('unmaskpassword', 'form');
+ $unmaskjs = '<script type="text/javascript">
//<![CDATA[
-document.write(\'<div class="unmask"><input id="'.$id.'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\''.$id.'\\\')"/><label for="'.$id.'unmask">'.addslashes_js($unmask).'<\/label><\/div>\');
+document.write(\'<span class="unmask"><input id="'.$id.'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\''.$id.'\\\')"/><label for="'.$id.'unmask">'.addslashes_js($unmask).'<\/label><\/span>\');
//]]>
</script>';
- return format_admin_setting($this->name, $this->visiblename,
- '<input type="password" class="form-text" id="id_s_'.$this->name.'" name="s_'.$this->name.'" value="'.s($current).'" />'.$unmaskjs,
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-password"><input type="password" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$unmaskjs.'</div>',
+ $this->description);
+ }
+}
+
+/**
+ * Path to executable file
+ */
+class admin_setting_configexecutable extends admin_setting_configtext {
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defautpath default path
+ */
+ function admin_setting_configexecutable($name, $visiblename, $description, $defaultpath) {
+ parent::admin_setting_configtext($name, $visiblename, $description, $defaultpath, PARAM_RAW);
+ }
+
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default)) {
+ if ($default === '') {
+ $default = get_string('emptysettingvalue', 'admin');
+ }
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', s($default)).'</span>';
+ } else {
+ $defaultinfo = '';
+ }
+
+ if ($data) {
+ if (file_exists($data) and is_executable($data)) {
+ $executable = '<span class="pathok">✔</span>';
+ } else {
+ $executable = '<span class="patherror">✘</span>';
+ }
+ } else {
+ $executable = '';
+ }
+
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-executable">'
+ .'<input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable
+ .$defaultinfo.'</div>',
$this->description);
}
+}
+
+/**
+ * Path to directory
+ */
+class admin_setting_configdirectory extends admin_setting_configtext {
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defaultdirectory default directory location
+ */
+ function admin_setting_configdirectory($name, $visiblename, $description, $defaultdirectory) {
+ parent::admin_setting_configtext($name, $visiblename, $description, $defaultdirectory, PARAM_RAW);
+ }
+
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default)) {
+ if ($default === '') {
+ $default = get_string('emptysettingvalue', 'admin');
+ }
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', s($default)).'</span>';
+ } else {
+ $defaultinfo = '';
+ }
+
+ if ($data) {
+ if (file_exists($data) and is_dir($data)) {
+ $executable = '<span class="pathok">✔</span>';
+ } else {
+ $executable = '<span class="patherror">✘</span>';
+ }
+ } else {
+ $executable = '';
+ }
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-directory">'
+ .'<input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable
+ .$defaultinfo.'</div>',
+ $this->description);
+ }
}
+/**
+ * Checkbox
+ */
class admin_setting_configcheckbox extends admin_setting {
+ var $yes;
+ var $no;
- function admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting) {
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defaultsetting
+ * @param string $yes value used when checked
+ * @param string $no value used when not checked
+ */
+ function admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting, $yes='1', $no='0') {
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
+ $this->yes = (string)$yes;
+ $this->no = (string)$no;
}
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
+ return $this->config_read($this->name);
}
function write_setting($data) {
- if ($data == '1') {
- return (set_config($this->name,1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ if ((string)$data === $this->yes) { // convert to strings before comparison
+ $data = $this->yes;
} else {
- return (set_config($this->name,0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $data = $this->no;
}
+ return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $current = $this->defaultsetting;
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default)) {
+ if ((string)$default === $this->yes) {
+ $str = get_string('checkboxyes', 'admin');
+ } else {
+ $str = get_string('checkboxno', 'admin');
+ }
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', $str).'</span>';
} else {
- $current = $this->get_setting();
+ $defaultinfo = '';
}
- return format_admin_setting($this->name, $this->visiblename,
- '<input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'" name="s_'. $this->name .'" value="1" ' . ($current == true ? 'checked="checked"' : '') . ' />',
+
+ if ((string)$data === $this->yes) { // convert to strings before comparison
+ $checked = 'checked="checked"';
+ } else {
+ $checked = '';
+ }
+
+ return format_admin_setting($this, $this->visiblename,
+ '<div class="form-checkbox" ><input type="hidden" name="'.$this->get_full_name().'" value="'.s($this->no).'" /> '
+ .'<input type="checkbox" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($this->yes).'" '.$checked.' />'
+ .$defaultinfo.'</div>',
$this->description);
}
-
}
-class admin_setting_configselect extends admin_setting {
-
+/**
+ * Multiple checkboxes, each represents different value, stored in csv format
+ */
+class admin_setting_configmulticheckbox extends admin_setting {
var $choices;
- function admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices) {
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param array $defaultsetting array of selected
+ * @param array $choices array of $value=>$label for each checkbox
+ */
+ function admin_setting_configmulticheckbox($name, $visiblename, $description, $defaultsetting, $choices) {
$this->choices = $choices;
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
/**
* This function may be used in ancestors for lazy loading of choices
+ * @return true if loaded, false if error
*/
function load_choices() {
/*
- if (!empty($this->choices)) {
- return;
+ if (is_array($this->choices)) {
+ return true;
}
.... load choices here
*/
+ return true;
+ }
+
+ /**
+ * Is setting related to query text - used when searching
+ * @param string $query
+ * @return bool
+ */
+ function is_related($query) {
+ if (!$this->load_choices() or empty($this->choices)) {
+ return false;
+ }
+ if (parent::is_related($query)) {
+ return true;
+ }
+
+ $textlib = textlib_get_instance();
+ foreach ($this->choices as $desc) {
+ if (strpos($textlib->strtolower($desc), $query) !== false) {
+ return true;
+ }
+ }
+ return false;
}
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
+ return NULL;
+ }
+ if ($result === '') {
+ return array();
+ }
+ return explode(',', $result);
}
function write_setting($data) {
- $this->load_choices();
- // check that what we got was in the original choices
- // or that the data is the default setting - needed during install when choices can not be constructed yet
- if ($data != $this->defaultsetting and ! in_array($data, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
- }
-
- return (set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ if (!is_array($data)) {
+ return ''; // ignore it
+ }
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ unset($data['xxxxx']);
+ $result = array();
+ foreach ($data as $key => $value) {
+ if ($value and array_key_exists($key, $this->choices)) {
+ $result[] = $key;
+ }
+ }
+ return $this->config_write($this->name, implode(',', $result)) ? '' : get_string('errorsetting', 'admin');
}
- function output_html() {
- $this->load_choices();
- if ($this->get_setting() === NULL) {
- $current = $this->defaultsetting;
+ function output_html($data) {
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ $default = $this->get_defaultsetting();
+ if (is_null($default)) {
+ $default = array();
+ }
+ if (is_null($data)) {
+ foreach ($default as $key=>$value) {
+ if ($value) {
+ $current[] = $value;
+ }
+ }
+ }
+
+ $options = array();
+ $defaults = array();
+ foreach($this->choices as $key=>$description) {
+ if (in_array($key, $data)) {
+ $checked = 'checked="checked"';
+ } else {
+ $checked = '';
+ }
+ if (!empty($default[$key])) {
+ $defaults[] = $description;
+ }
+
+ $options[] = '<input type="checkbox" id="'.$this->get_id().'_'.$key.'" name="'.$this->get_full_name().'['.$key.']" value="1" '.$checked.' />'
+ .'<label for="'.$this->get_id().'_'.$key.'">'.$description.'</label>';
+ }
+
+ if (!empty($defaults)) {
+ $defaultinfo = '<div class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', implode(', ', $defaults)).'</div>';
} else {
- $current = $this->get_setting();
+ $defaultinfo = '';
}
- $return = '<select class="form-select" id="id_s_'.$this->name.'" name="s_' . $this->name .'">';
- foreach ($this->choices as $key => $value) {
- // the string cast is needed because key may be integer - 0 is equal to most strings!
- $return .= '<option value="'.$key.'"'.((string)$key==$current ? ' selected="selected"' : '').'>'.$value.'</option>';
+
+ $return = '<div class="form-multicheckbox">';
+ $return .= '<input type="hidden" name="'.$this->get_full_name().'[xxxxx]" value="1" />'; // something must be submitted even if nothing selected
+ if ($options) {
+ $return .= '<ul>';
+ foreach ($options as $option) {
+ $return .= '<li>'.$option.'</li>';
+ }
+ $return .= '</ul>';
}
- $return .= '</select>';
+ $return .= $defaultinfo.'</div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
-
}
-// this is a liiitle bit messy. we're using two selects, but we're returning them as an array named after $name (so we only use $name2
-// internally for the setting)
-class admin_setting_configtime extends admin_setting {
+/**
+ * Multiple checkboxes 2, value stored as string 00101011
+ */
+class admin_setting_configmulticheckbox2 extends admin_setting_configmulticheckbox {
+ function get_setting() {
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
+ return NULL;
+ }
+ if (!$this->load_choices()) {
+ return NULL;
+ }
+ $result = str_pad($result, count($this->choices), '0');
+ $result = preg_split('//', $result, -1, PREG_SPLIT_NO_EMPTY);
+ $setting = array();
+ foreach ($this->choices as $key=>$unused) {
+ $value = array_shift($result);
+ if ($value) {
+ $setting[] = $key;
+ }
+ }
+ return $setting;
+ }
- var $name2;
+ function write_setting($data) {
+ if (!is_array($data)) {
+ return ''; // ignore it
+ }
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ $result = '';
+ foreach ($this->choices as $key=>$unused) {
+ if (!empty($data[$key])) {
+ $result .= '1';
+ } else {
+ $result .= '0';
+ }
+ }
+ return $this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin');
+ }
+}
+
+/**
+ * Select one value from list
+ */
+class admin_setting_configselect extends admin_setting {
var $choices;
- var $choices2;
- function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) {
- $this->name2 = $minutesname;
- $this->choices = array();
- for ($i = 0; $i < 24; $i++) {
- $this->choices[$i] = $i;
- }
- $this->choices2 = array();
- for ($i = 0; $i < 60; $i += 5) {
- $this->choices2[$i] = $i;
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param string $defaultsetting
+ * @param array $choices array of $value=>$label for each selection
+ */
+ function admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices) {
+ $this->choices = $choices;
+ parent::admin_setting($name, $visiblename, $description, $defaultsetting);
+ }
+
+ /**
+ * This function may be used in ancestors for lazy loading of choices
+ * @return true if loaded, false if error
+ */
+ function load_choices() {
+ /*
+ if (is_array($this->choices)) {
+ return true;
}
- parent::admin_setting($hoursname, $visiblename, $description, $defaultsetting);
+ .... load choices here
+ */
+ return true;
}
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) && isset($CFG->{$this->name2}) ? array('h' => $CFG->{$this->name}, 'm' => $CFG->{$this->name2}) : NULL);
+ return $this->config_read($this->name);
}
function write_setting($data) {
- // check that what we got was in the original choices
- if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
- }
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ if (!array_key_exists($data, $this->choices)) {
+ return ''; // ignore it
+ }
- return (set_config($this->name, $data['h']) && set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
+ function output_html($data) {
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ $default = $this->get_defaultsetting();
+
+ if (!is_null($default) and array_key_exists($default, $this->choices)) {
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', s($this->choices[$default])).'</span>';
} else {
- $currentsetting = $this->get_setting();
+ $defaultinfo = '';
}
- $return = '<div class="form-group">'.
- '<select class="form-select" id="id_s_'.$this->name.'h" name="s_' . $this->name .'[h]">';
+
+ $return = '<div class="form-select"><select id="'.$this->get_id().'" name="'.$this->get_full_name().'">';
foreach ($this->choices as $key => $value) {
- $return .= '<option value="' . $key . '"' . ($key == $currentsetting['h'] ? ' selected="selected"' : '') . '>' . $value . '</option>';
- }
- $return .= '</select>:<select class="form-select" id="id_s_'.$this->name.'m" name="s_' . $this->name . '[m]">';
- foreach ($this->choices2 as $key => $value) {
- $return .= '<option value="' . $key . '"' . ($key == $currentsetting['m'] ? ' selected="selected"' : '') . '>' . $value . '</option>';
+ // the string cast is needed because key may be integer - 0 is equal to most strings!
+ $return .= '<option value="'.$key.'"'.((string)$key==$data ? ' selected="selected"' : '').'>'.$value.'</option>';
}
- $return .= '</select></div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ $return .= '</select>'.$defaultinfo.'</div>';
+
+ return format_admin_setting($this, $this->visiblename, $return, $this->description);
}
}
+/**
+ * Select multiple items from list
+ */
class admin_setting_configmultiselect extends admin_setting_configselect {
-
+ /**
+ * Constructor
+ * @param string $name of setting
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param array $defaultsetting array of selected items
+ * @param array $choices array of $value=>$label for each list item
+ */
function admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, $choices) {
parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices);
}
function get_setting() {
- global $CFG;
- if (isset($CFG->{$this->name})) {
- if ($CFG->{$this->name}) {
- return explode(',', $CFG->{$this->name});
- } else {
- return array();
- }
- } else {
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
return NULL;
}
+ if ($result === '') {
+ return array();
+ }
+ return explode(',', $result);
}
function write_setting($data) {
- if (empty($data)) {
+ if (!is_array($data)) {
+ return ''; //ignore it
+ }
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+
+ $save = array();
+ foreach ($data as $value) {
+ if (!array_key_exists($value, $this->choices)) {
+ continue; // ignore it
+ }
+ $save[] = $value;
+ }
+
+ return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin'));
+ }
+
+ /**
+ * Is setting related to query text - used when searching
+ * @param string $query
+ * @return bool
+ */
+ function is_related($query) {
+ if (!$this->load_choices() or empty($this->choices)) {
+ return false;
+ }
+ if (parent::is_related($query)) {
+ return true;
+ }
+
+ $textlib = textlib_get_instance();
+ foreach ($this->choices as $desc) {
+ if (strpos($textlib->strtolower($desc), $query) !== false) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function output_html($data) {
+ if (!$this->load_choices() or empty($this->choices)) {
+ return '';
+ }
+ $choices = $this->choices;
+ $default = $this->get_defaultsetting();
+ if (is_null($default)) {
+ $default = array();
+ }
+ if (is_null($data)) {
$data = array();
}
- foreach ($data as $datum) {
- if (! in_array($datum, array_keys($this->choices))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+
+ $defaults = array();
+ $return = '<div class="form-select"><select id="'.$this->get_id().'" name="'.$this->get_full_name().'[]" size="10" multiple="multiple">';
+ foreach ($this->choices as $key => $description) {
+ if (in_array($key, $data)) {
+ $selected = 'selected="selected"';
+ } else {
+ $selected = '';
+ }
+ if (in_array($key, $default)) {
+ $defaults[] = $description;
}
+
+ $return .= '<option value="'.s($key).'" '.$selected.'>'.$description.'</option>';
+ }
+
+ if (!empty($defaults)) {
+ $defaultinfo = '<div class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', implode(', ', $defaults)).'</div>';
+ } else {
+ $defaultinfo = '';
}
- return (set_config($this->name, implode(',',$data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $return .= '</select>'.$defaultinfo.'</div>';
+ return format_admin_setting($this, $this->visiblename, $return, $this->description);
}
+}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- if (!$currentsetting) {
- $currentsetting = array();
- }
+/**
+ * Time selector
+ * this is a liiitle bit messy. we're using two selects, but we're returning
+ * them as an array named after $name (so we only use $name2 internally for the setting)
+ */
+class admin_setting_configtime extends admin_setting {
+ var $name2;
+
+ /**
+ * Constructor
+ * @param string $hoursname setting for hours
+ * @param string $minutesname setting for hours
+ * @param string $visiblename localised
+ * @param string $description long localised info
+ * @param array $defaultsetting array representing default time 'h'=>hours, 'm'=>minutes
+ */
+ function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) {
+ $this->name2 = $minutesname;
+ parent::admin_setting($hoursname, $visiblename, $description, $defaultsetting);
+ }
+
+ function get_setting() {
+ $result1 = $this->config_read($this->name);
+ $result2 = $this->config_read($this->name2);
+ if (is_null($result1) or is_null($result2)) {
+ return NULL;
+ }
+
+ return array('h' => $result1, 'm' => $result2);
+ }
+
+ function write_setting($data) {
+ if (!is_array($data)) {
+ return '';
+ }
+
+ $result = $this->config_write($this->name, (int)$data['h']) && $this->config_write($this->name2, (int)$data['m']);
+ return ($result ? '' : get_string('errorsetting', 'admin'));
+ }
+
+ function output_html($data) {
+ $default = $this->get_defaultsetting();
+
+ if (is_array($default)) {
+ $defaultinfo = '<span class="defaultinfo">'.get_string('defaultsettinginfo', 'admin', $default['h'].':'.$default['m']).'</span>';
} else {
- $currentsetting = $this->get_setting();
+ $defaultinfo = '';
}
- $return = '<select class="form-select" id="id_s_'.$this->name.'" name="s_' . $this->name .'[]" size="10" multiple="multiple">';
- foreach ($this->choices as $key => $value) {
- $return .= '<option value="' . $key . '"' . (in_array($key,$currentsetting) ? ' selected="selected"' : '') . '>' . $value . '</option>';
+
+ $return = '<div class="form-time">'.
+ '<select id="'.$this->get_id().'h" name="'.$this->get_full_name().'[h]">';
+ for ($i = 0; $i < 24; $i++) {
+ $return .= '<option value="'.$i.'"'.($i == $data['h'] ? ' selected="selected"' : '').'>'.$i.'</option>';
}
- $return .= '</select>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
+ $return .= '</select>:<select id="'.$this->get_id().'m" name="'.$this->get_full_name().'[m]">';
+ for ($i = 0; $i < 60; $i += 5) {
+ $return .= '<option value="'.$i.'"'.($i == $data['m'] ? ' selected="selected"' : '').'>'.$i.'</option>';
+ }
+ $return .= '</select>'.$defaultinfo.'</div>';
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
}
+/**
+ * Special checkbox for calendar - resets SESSION vars.
+ */
class admin_setting_special_adminseesall extends admin_setting_configcheckbox {
-
function admin_setting_special_adminseesall() {
- $name = 'calendar_adminseesall';
- $visiblename = get_string('adminseesall', 'admin');
- $description = get_string('helpadminseesall', 'admin');
- parent::admin_setting($name, $visiblename, $description, 0);
+ parent::admin_setting_configcheckbox('calendar_adminseesall', get_string('adminseesall', 'admin'),
+ get_string('helpadminseesall', 'admin'), '0');
}
function write_setting($data) {
global $SESSION;
unset($SESSION->cal_courses_shown);
- parent::write_setting($data);
+ return parent::write_setting($data);
}
}
+/**
+ * Special select for frontpage - stores data in course table
+ */
class admin_setting_sitesetselect extends admin_setting_configselect {
-
- var $id;
-
- function admin_setting_sitesetselect($name, $visiblename, $description, $defaultsetting, $choices) {
-
- $this->id = SITEID;
- parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices);
-
- }
-
function get_setting() {
$site = get_site();
- return (isset($site->{$this->name}) ? $site->{$this->name} : NULL);
+ return $site->{$this->name};
}
function write_setting($data) {
if (!in_array($data, array_keys($this->choices))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin');
}
$record = new stdClass();
- $record->id = $this->id;
- $temp = $this->name;
- $record->$temp = $data;
+ $record->id = SITEID;
+ $temp = $this->name;
+ $record->$temp = $data;
$record->timemodified = time();
- return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
}
-
-class admin_setting_courselist_frontpage extends admin_setting_configselect {
+/**
+ * Special select - lists on the frontpage - hacky
+ */
+class admin_setting_courselist_frontpage extends admin_setting {
+ var $choices;
function admin_setting_courselist_frontpage($loggedin) {
global $CFG;
- require_once($CFG->dirroot . '/course/lib.php');
- $name = 'frontpage' . ($loggedin ? 'loggedin' : '');
- $visiblename = get_string('frontpage' . ($loggedin ? 'loggedin' : ''),'admin');
- $description = get_string('configfrontpage' . ($loggedin ? 'loggedin' : ''),'admin');
- $choices = array(FRONTPAGENEWS => get_string('frontpagenews'),
- FRONTPAGECOURSELIST => get_string('frontpagecourselist'),
- FRONTPAGECATEGORYNAMES => get_string('frontpagecategorynames'),
- FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'),
- '' => get_string('none'));
- if (!$loggedin and count_records("course") > FRONTPAGECOURSELIMIT) {
- unset($choices[FRONTPAGECOURSELIST]);
- }
- $defaults = FRONTPAGECOURSELIST.',,,';
- parent::admin_setting_configselect($name, $visiblename, $description, $defaults, $choices);
+ require_once($CFG->dirroot.'/course/lib.php');
+ $name = 'frontpage'.($loggedin ? 'loggedin' : '');
+ $visiblename = get_string('frontpage'.($loggedin ? 'loggedin' : ''),'admin');
+ $description = get_string('configfrontpage'.($loggedin ? 'loggedin' : ''),'admin');
+ $defaults = array(FRONTPAGECOURSELIST);
+ parent::admin_setting($name, $visiblename, $description, $defaults);
}
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = array(FRONTPAGENEWS => get_string('frontpagenews'),
+ FRONTPAGECOURSELIST => get_string('frontpagecourselist'),
+ FRONTPAGECATEGORYNAMES => get_string('frontpagecategorynames'),
+ FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'),
+ 'none' => get_string('none'));
+ if ($this->name == 'frontpage' and count_records('course') > FRONTPAGECOURSELIMIT) {
+ unset($this->choices[FRONTPAGECOURSELIST]);
+ }
+ return true;
+ }
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) ? explode(',', $CFG->{$this->name}) : ',1,,');
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
+ return NULL;
+ }
+ if ($result === '') {
+ return array();
+ }
+ return explode(',', $result);
}
function write_setting($data) {
- if (empty($data)) {
- $data = array();
- } if (!is_array($data)) {
- $data = explode(',', $data);
+ if (!is_array($data)) {
+ return '';
}
+ $this->load_choices();
+ $save = array();
foreach($data as $datum) {
- if (! in_array($datum, array_keys($this->choices))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ if ($datum == 'none' or !array_key_exists($datum, $this->choices)) {
+ continue;
}
+ $save[$datum] = $datum; // no duplicates
}
- return (set_config($this->name, implode(',', $data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
- for ($i = 0; $i < count($this->choices) - 1; $i++) {
- if (!isset($currentsetting[$i])) {
- $currentsetting[$i] = 0;
+ function output_html($data) {
+ $this->load_choices();
+ $currentsetting = array();
+ foreach ($data as $key) {
+ if ($key != 'none' and array_key_exists($key, $this->choices)) {
+ $currentsetting[] = $key; // already selected first
}
}
+
$return = '<div class="form-group">';
for ($i = 0; $i < count($this->choices) - 1; $i++) {
- $return .='<select class="form-select" id="id_s_'.$this->name.$i.'" name="s_' . $this->name .'[]">';
+ if (!array_key_exists($i, $currentsetting)) {
+ $currentsetting[$i] = 'none'; //none
+ }
+ $return .='<select class="form-select" id="'.$this->get_id().$i.'" name="'.$this->get_full_name().'[]">';
foreach ($this->choices as $key => $value) {
- $return .= '<option value="' . $key . '"' . ($key == $currentsetting[$i] ? ' selected="selected"' : '') . '>' . $value . '</option>';
+ $return .= '<option value="'.$key.'"'.("$key" == $currentsetting[$i] ? ' selected="selected"' : '').'>'.$value.'</option>';
}
$return .= '</select>';
if ($i !== count($this->choices) - 2) {
}
$return .= '</div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
}
+/**
+ * Special checkbox for frontpage - stores data in course table
+ */
class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
-
- var $id;
-
- function admin_setting_sitesetcheckbox($name, $visiblename, $description, $defaultsetting) {
-
- $this->id = SITEID;
- parent::admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting);
-
- }
-
function get_setting() {
$site = get_site();
return $site->{$this->name};
}
function write_setting($data) {
- $record = new stdClass();
- $record->id = $this->id;
- $temp = $this->name;
- $record->$temp = ($data == '1' ? 1 : 0);
- $record->timemodified = time();
- return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $record = new object();
+ $record->id = SITEID;
+ $record->{$this->name} = ($data == '1' ? 1 : 0);
+ $record->timemodified = time();
+ return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
-
}
+/**
+ * Special text for frontpage - stores data in course table.
+ * Empty string means not set here. Manual setting is required.
+ */
class admin_setting_sitesettext extends admin_setting_configtext {
-
- var $id;
-
- function admin_setting_sitesettext($name, $visiblename, $description, $defaultsetting) {
-
- $this->id = SITEID;
- parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting);
-
- }
-
function get_setting() {
$site = get_site();
return $site->{$this->name} != '' ? $site->{$this->name} : NULL;
if ($cleaned == '') {
return false; // can not be empty
}
- return ($data == $cleaned); // implicit conversion to string is needed to do exact comparison
+ return ($data == $cleaned);
}
function write_setting($data) {
$data = trim($data);
if (!$this->validate($data)) {
- return get_string('validateerror', 'admin') . $this->visiblename . '<br />';
+ return get_string('required');
}
- $record = new stdClass();
- $record->id = $this->id;
+ $record = new object();
+ $record->id = SITEID;
$record->{$this->name} = addslashes($data);
- $record->timemodified = time();
- return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $record->timemodified = time();
+ return (update_record('course', $record) ? '' : get_string('dbupdatefailed', 'error'));
}
-
}
+/**
+ * Special text editor for site description.
+ */
class admin_setting_special_frontpagedesc extends admin_setting {
-
- var $id;
-
function admin_setting_special_frontpagedesc() {
- $this->id = SITEID;
- $name = 'summary';
- $visiblename = get_string('frontpagedescription');
- $description = get_string('frontpagedescriptionhelp');
- parent::admin_setting($name, $visiblename, $description, '');
- }
-
- function output_html() {
- global $CFG;
-
- $CFG->adminusehtmleditor = can_use_html_editor();
- $return = print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, 's_' . $this->name, $this->get_setting(), 0, true);
-
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ parent::admin_setting('summary', get_string('frontpagedescription'), get_string('frontpagedescriptionhelp'), NULL);
}
function get_setting() {
return $site->{$this->name};
}
- function get_defaultsetting() {
- return NULL;
- }
-
function write_setting($data) {
$record = new object();
- $record->id = $this->id;
+ $record->id = SITEID;
$record->{$this->name} = addslashes($data);
$record->timemodified = time();
-
- return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
-}
+ function output_html($data) {
+ global $CFG;
+ $CFG->adminusehtmleditor = can_use_html_editor();
+ $return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true).'</div>';
+
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
+ }
+}
class admin_setting_special_editorfontlist extends admin_setting {
function get_setting() {
global $CFG;
- if (isset($CFG->editorfontlist)) {
- $i = 0;
- $currentsetting = array();
- $items = explode(';', $CFG->editorfontlist);
- foreach ($items as $item) {
- $item = explode(':', $item);
- $currentsetting['k' . $i] = $item[0];
- $currentsetting['v' . $i] = $item[1];
- $i++;
- }
- return $currentsetting;
- } else {
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
return NULL;
}
+ $i = 0;
+ $currentsetting = array();
+ $items = explode(';', $result);
+ foreach ($items as $item) {
+ $item = explode(':', $item);
+ $currentsetting['k'.$i] = $item[0];
+ $currentsetting['v'.$i] = $item[1];
+ $i++;
+ }
+ return $currentsetting;
}
function write_setting($data) {
}
}
- $result = '';
+ $result = array();
for ($i = 0; $i < count($keys); $i++) {
if (($keys[$i] !== '') && ($values[$i] !== '')) {
- $result .= clean_param($keys[$i],PARAM_NOTAGS) . ':' . clean_param($values[$i], PARAM_NOTAGS) . ';';
+ $result[] = clean_param($keys[$i],PARAM_NOTAGS).':'.clean_param($values[$i], PARAM_NOTAGS);
}
}
- $result = substr($result, 0, -1); // trim the last semicolon
-
- return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, implode(';', $result)) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
-
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
-
+ function output_html($data) {
+ $fullname = $this->get_full_name();
$return = '<div class="form-group">';
- for ($i = 0; $i < count($currentsetting) / 2; $i++) {
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[k' . $i . ']" value="' . $currentsetting['k' . $i] . '" />';
+ for ($i = 0; $i < count($data) / 2; $i++) {
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="'.$data['k'.$i].'" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[v' . $i . ']" value="' . $currentsetting['v' . $i] . '" /><br />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="'.$data['v'.$i].'" /><br />';
}
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[k' . $i . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[v' . $i . ']" value="" /><br />';
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[k' . ($i + 1) . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="" /><br />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.($i + 1).']" value="" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_editorfontlist[v' . ($i + 1) . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.($i + 1).']" value="" />';
$return .= '</div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
}
function get_setting() {
global $CFG;
- if (isset($CFG->emoticons)) {
- $i = 0;
- $currentsetting = array();
- $items = explode('{;}', $CFG->emoticons);
- foreach ($items as $item) {
- $item = explode('{:}', $item);
- $currentsetting['k' . $i] = $item[0];
- $currentsetting['v' . $i] = $item[1];
- $i++;
- }
- return $currentsetting;
- } else {
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
return NULL;
}
+ $i = 0;
+ $currentsetting = array();
+ $items = explode('{;}', $result);
+ foreach ($items as $item) {
+ $item = explode('{:}', $item);
+ $currentsetting['k'.$i] = $item[0];
+ $currentsetting['v'.$i] = $item[1];
+ $i++;
+ }
+ return $currentsetting;
}
function write_setting($data) {
}
}
- $result = '';
+ $result = array();
for ($i = 0; $i < count($keys); $i++) {
if (($keys[$i] !== '') && ($values[$i] !== '')) {
- $result .= clean_param($keys[$i],PARAM_NOTAGS) . '{:}' . clean_param($values[$i], PARAM_NOTAGS) . '{;}';
+ $result[] = clean_param($keys[$i],PARAM_NOTAGS).'{:}'.clean_param($values[$i], PARAM_NOTAGS);
}
}
- $result = substr($result, 0, -3); // trim the last separator
-
- return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, implode('{;}', $result)) ? '' : get_string('errorsetting', 'admin').$this->visiblename.'<br />');
}
- function output_html() {
-
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
-
+ function output_html($data) {
+ $fullname = $this->get_full_name();
$return = '<div class="form-group">';
- for ($i = 0; $i < count($currentsetting) / 2; $i++) {
- $return .= '<input type="text" class="form-text" name="s_emoticons[k' . $i . ']" value="' . $currentsetting['k' . $i] . '" />';
+ for ($i = 0; $i < count($data) / 2; $i++) {
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="'.$data['k'.$i].'" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_emoticons[v' . $i . ']" value="' . $currentsetting['v' . $i] . '" /><br />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="'.$data['v'.$i].'" /><br />';
}
- $return .= '<input type="text" class="form-text" name="s_emoticons[k' . $i . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_emoticons[v' . $i . ']" value="" /><br />';
- $return .= '<input type="text" class="form-text" name="s_emoticons[k' . ($i + 1) . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="" /><br />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.($i + 1).']" value="" />';
$return .= ' ';
- $return .= '<input type="text" class="form-text" name="s_emoticons[v' . ($i + 1) . ']" value="" />';
+ $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.($i + 1).']" value="" />';
$return .= '</div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
}
+/**
+ * Setting for spellchecker language selection.
+ */
class admin_setting_special_editordictionary extends admin_setting_configselect {
function admin_setting_special_editordictionary() {
$name = 'editordictionary';
$visiblename = get_string('editordictionary','admin');
$description = get_string('configeditordictionary', 'admin');
- $choices = $this->editor_get_dictionaries();
- if (! is_array($choices)) {
- $choices = array('');
- }
-
- parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
+ parent::admin_setting_configselect($name, $visiblename, $description, '', NULL);
}
- // function borrowed from the old moodle/admin/editor.php, slightly modified
- function editor_get_dictionaries () {
- /// Get all installed dictionaries in the system
+ function load_choices() {
+ // function borrowed from the old moodle/admin/editor.php, slightly modified
+ // Get all installed dictionaries in the system
+ if (is_array($this->choices)) {
+ return true;
+ }
+
+ $this->choices = array();
global $CFG;
-// error_reporting(E_ALL); // for debug, final version shouldn't have this...
clearstatcache();
// If aspellpath isn't set don't even bother ;-)
if (empty($CFG->aspellpath)) {
- return 'Empty aspell path!';
+ $this->choices['error'] = 'Empty aspell path!';
+ return true;
}
// Do we have access to popen function?
if (!function_exists('popen')) {
- return 'Popen function disabled!';
+ $this->choices['error'] = 'Popen function disabled!';
+ return true;
}
$cmd = $CFG->aspellpath;
$output = '';
$dictionaries = array();
- $dicts = array();
- if(!($handle = @popen(escapeshellarg($cmd) .' dump dicts', 'r'))) {
- return 'Couldn\'t create handle!';
+ if(!($handle = @popen(escapeshellarg($cmd).' dump dicts', 'r'))) {
+ $this->choices['error'] = 'Couldn\'t create handle!';
}
while(!feof($handle)) {
@pclose($handle);
$dictionaries = explode(chr(10), $output);
-
- // Get rid of possible empty values
- if (is_array($dictionaries)) {
-
- $cnt = count($dictionaries);
-
- for ($i = 0; $i < $cnt; $i++) {
- if (!empty($dictionaries[$i])) {
- $dicts[$dictionaries[$i]] = $dictionaries[$i];
- }
+ foreach ($dictionaries as $dict) {
+ if (empty($dict)) {
+ continue;
}
+ $this->choices[$dict] = $dict;
}
- if (count($dicts) >= 1) {
- return $dicts;
+ if (empty($this->choices)) {
+ $this->choices['error'] = 'Error! Check your aspell installation!';
}
-
- return 'Error! Check your aspell installation!';
+ return true;
}
-
-
-
}
class admin_setting_special_editorhidebuttons extends admin_setting {
-
- var $name;
- var $visiblename;
- var $description;
var $items;
function admin_setting_special_editorhidebuttons() {
- $this->name = 'editorhidebuttons';
- $this->visiblename = get_string('editorhidebuttons', 'admin');
- $this->description = get_string('confeditorhidebuttons', 'admin');
- $this->defaultsetting = array();
+ parent::admin_setting('editorhidebuttons', get_string('editorhidebuttons', 'admin'),
+ get_string('confeditorhidebuttons', 'admin'), array());
// weird array... buttonname => buttonimage (assume proper path appended). if you leave buttomimage blank, text will be printed instead
$this->items = array('fontname' => '',
'fontsize' => '',
}
function get_setting() {
- global $CFG;
- return (isset($CFG->{$this->name}) ? explode(' ', $CFG->{$this->name}) : NULL);
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
+ return NULL;
+ }
+ if ($result === '') {
+ return array();
+ }
+ return explode(',', $result);
}
function write_setting($data) {
+ if (!is_array($data)) {
+ return ''; // ignore it
+ }
+ unset($data['xxxxx']);
$result = array();
- if (empty($data)) { $data = array(); }
+
foreach ($data as $key => $value) {
if (!in_array($key, array_keys($this->items))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin');
}
if ($value == '1') {
$result[] = $key;
}
}
- return (set_config($this->name, implode(' ',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, implode(' ', $result)) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
+ function output_html($data) {
global $CFG;
// checkboxes with input name="$this->name[$key]" value="1"
// we do 15 fields per column
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
-
$return = '<div class="form-group">';
$return .= '<table><tr><td valign="top" align="right">';
+ $return .= '<input type="hidden" name="'.$this->get_full_name().'[xxxxx]" value="1" />'; // something must be submitted even if nothing selected
$count = 0;
$return .= '</td><td valign="top" align="right">';
}
- $return .= ($value == '' ? get_string($key,'editor') : '<img width="18" height="18" src="' . $CFG->wwwroot . '/lib/editor/htmlarea/images/' . $value . '" alt="' . get_string($key,'editor') . '" title="' . get_string($key,'editor') . '" />') . ' ';
- $return .= '<input type="checkbox" class="form-checkbox" value="1" id="id_s_'.$this->name.$key.'" name="s_' . $this->name . '[' . $key . ']"' . (in_array($key,$currentsetting) ? ' checked="checked"' : '') . ' /> ';
+ $return .= ($value == '' ? get_string($key,'editor') : '<img width="18" height="18" src="'.$CFG->wwwroot.'/lib/editor/htmlarea/images/'.$value.'" alt="'.get_string($key,'editor').'" title="'.get_string($key,'editor').'" />').' ';
+ $return .= '<input type="checkbox" class="form-checkbox" value="1" id="'.$this->get_id().$key.'" name="'.$this->get_full_name().'['.$key.']"'.(in_array($key,$data) ? ' checked="checked"' : '').' /> ';
$count++;
if ($count % 15 != 0) {
$return .= '<br /><br />';
$return .= '</table>';
$return .= '</div>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
-
}
+/**
+ * Special setting for limiting of the list of available languages.
+ */
class admin_setting_langlist extends admin_setting_configtext {
function admin_setting_langlist() {
parent::admin_setting_configtext('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS);
}
}
-class admin_setting_backupselect extends admin_setting_configselect {
-
- function admin_setting_backupselect($name, $visiblename, $description, $default, $choices) {
- parent::admin_setting_configselect($name, $visiblename, $description, $default, $choices);
- }
-
- function get_setting() {
- $backup_config = backup_get_config();
- return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
- }
-
- function write_setting($data) {
- // check that what we got was in the original choices
- if (! in_array($data, array_keys($this->choices))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
- }
-
- return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
-
-}
-
-class admin_setting_special_backupsaveto extends admin_setting_configtext {
-
- function admin_setting_special_backupsaveto() {
- $name = 'backup_sche_destination';
- $visiblename = get_string('saveto');
- $description = get_string('backupsavetohelp');
- parent::admin_setting_configtext($name, $visiblename, $description, '');
- }
-
- function get_setting() {
- $backup_config = backup_get_config();
- return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
- }
-
- function write_setting($data) {
- $data = trim($data);
- if (!empty($data) and !is_dir($data)) {
- return get_string('pathnotexists') . '<br />';
- }
- return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
-
-}
-
-class admin_setting_backupcheckbox extends admin_setting_configcheckbox {
-
- function admin_setting_backupcheckbox($name, $visiblename, $description, $default) {
- parent::admin_setting_configcheckbox($name, $visiblename, $description, $default);
- }
-
- function write_setting($data) {
- if ($data == '1') {
- return (backup_set_config($this->name, 1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- } else {
- return (backup_set_config($this->name, 0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
- }
-
- function get_setting() {
- $backup_config = backup_get_config();
- return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
- }
-
-}
-
-class admin_setting_special_backuptime extends admin_setting_configtime {
-
- function admin_setting_special_backuptime() {
- $name = 'backup_sche_hour';
- $name2 = 'backup_sche_minute';
- $visiblename = get_string('executeat');
- $description = get_string('backupexecuteathelp');
- $default = array('h' => 0, 'm' => 0);
- parent::admin_setting_configtime($name, $name2, $visiblename, $description, $default);
- }
-
- function get_setting() {
- $backup_config = backup_get_config();
- return (isset($backup_config->{$this->name}) && isset($backup_config->{$this->name}) ? array('h'=>$backup_config->{$this->name}, 'm'=>$backup_config->{$this->name2}) : NULL);
- }
-
- function write_setting($data) {
- // check that what we got was in the original choices
- if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
- }
-
- return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
-
-}
-
-class admin_setting_special_backupdays extends admin_setting {
-
- function admin_setting_special_backupdays() {
- $name = 'backup_sche_weekdays';
- $visiblename = get_string('schedule');
- $description = get_string('backupschedulehelp');
- $default = array('u' => 0, 'm' => 0, 't' => 0, 'w' => 0, 'r' => 0, 'f' => 0, 's' => 0);
- parent::admin_setting($name, $visiblename, $description, $default);
- }
-
- function get_setting() {
- $backup_config = backup_get_config();
- if (isset($backup_config->{$this->name})) {
- $currentsetting = $backup_config->{$this->name};
- return array('u' => substr($currentsetting, 0, 1),
- 'm' => substr($currentsetting, 1, 1),
- 't' => substr($currentsetting, 2, 1),
- 'w' => substr($currentsetting, 3, 1),
- 'r' => substr($currentsetting, 4, 1),
- 'f' => substr($currentsetting, 5, 1),
- 's' => substr($currentsetting, 6, 1));
- } else {
- return NULL;
- }
- }
-
- function output_html() {
-
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
-
- // rewrite for simplicity
- $currentsetting = $currentsetting['u'] . $currentsetting['m'] . $currentsetting['t'] . $currentsetting['w'] .
- $currentsetting['r'] . $currentsetting['f'] . $currentsetting['s'];
-
- $return = '<table><tr><td><div style="text-align:center"> ' . get_string('sunday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' .
- get_string('monday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' . get_string('tuesday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' .
- get_string('wednesday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' . get_string('thursday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' .
- get_string('friday', 'calendar') . ' </div></td><td><div style="text-align:center"> ' . get_string('saturday', 'calendar') . ' </div></td></tr><tr>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'u" name="s_'. $this->name .'[u]" value="1" ' . (substr($currentsetting,0,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'m" name="s_'. $this->name .'[m]" value="1" ' . (substr($currentsetting,1,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'t" name="s_'. $this->name .'[t]" value="1" ' . (substr($currentsetting,2,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'w" name="s_'. $this->name .'[w]" value="1" ' . (substr($currentsetting,3,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'r" name="s_'. $this->name .'[r]" value="1" ' . (substr($currentsetting,4,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'f" name="s_'. $this->name .'[f]" value="1" ' . (substr($currentsetting,5,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '<td><div style="text-align:center"><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'s" name="s_'. $this->name .'[s]" value="1" ' . (substr($currentsetting,6,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
- '</tr></table>';
+/**
+ * Course category selection
+ */
+class admin_settings_coursecat_select extends admin_setting_configselect {
+ function admin_settings_coursecat_select($name, $visiblename, $description, $defaultsetting) {
+ parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, NULL);
+ }
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ function load_choices() {
+ global $CFG;
+ require_once($CFG->dirroot.'/course/lib.php');
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = make_categories_options();
+ return true;
+ }
+}
+class admin_setting_special_backupdays extends admin_setting_configmulticheckbox2 {
+ function admin_setting_special_backupdays() {
+ parent::admin_setting_configmulticheckbox2('backup_sche_weekdays', get_string('schedule'), get_string('backupschedulehelp'), array(), NULL);
+ $this->plugin = 'backup';
}
- // we're using the array trick (see http://ca.php.net/manual/en/faq.html.php#faq.html.arrays) to get the data passed to use without having to modify
- // admin_settingpage (note that admin_settingpage only calls write_setting with the data that matches $this->name... so if we have multiple form fields,
- // they MUST go into an array named $this->name, or else we won't receive them here
- function write_setting($data) {
- $week = 'umtwrfs';
- $result = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0);
- if (!empty($data)) {
- foreach($data as $key => $value) {
- if ($value == '1') {
- $result[strpos($week, $key)] = 1;
- }
- }
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = array();
+ $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+ foreach ($days as $day) {
+ $this->choices[$day] = get_string($day, 'calendar');
}
- return (backup_set_config($this->name, implode('',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return true;
}
}
+/**
+ * Special debug setting
+ */
class admin_setting_special_debug extends admin_setting_configselect {
-
function admin_setting_special_debug() {
- $name = 'debug';
- $visiblename = get_string('debug', 'admin');
- $description = get_string('configdebug', 'admin');
- $choices = array( DEBUG_NONE => get_string('debugnone', 'admin'),
- DEBUG_MINIMAL => get_string('debugminimal', 'admin'),
- DEBUG_NORMAL => get_string('debugnormal', 'admin'),
- DEBUG_ALL => get_string('debugall', 'admin'),
- DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin')
- );
- parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
+ parent::admin_setting_configselect('debug', get_string('debug', 'admin'), get_string('configdebug', 'admin'), DEBUG_NONE, NULL);
}
- function get_setting() {
- global $CFG;
- if (isset($CFG->debug)) {
- return $CFG->debug;
- } else {
- return NULL;
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
}
+ $this->choices = array(DEBUG_NONE => get_string('debugnone', 'admin'),
+ DEBUG_MINIMAL => get_string('debugminimal', 'admin'),
+ DEBUG_NORMAL => get_string('debugnormal', 'admin'),
+ DEBUG_ALL => get_string('debugall', 'admin'),
+ DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin'));
+ return true;
}
-
- function write_setting($data) {
- return (set_config($this->name,$data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
-
}
class admin_setting_special_calendar_weekend extends admin_setting {
-
function admin_setting_special_calendar_weekend() {
$name = 'calendar_weekend';
$visiblename = get_string('calendar_weekend', 'admin');
}
function get_setting() {
- global $CFG;
- return isset($CFG->{$this->name}) ? $CFG->{$this->name} : 0;
+ $result = $this->config_read($this->name);
+ if (is_null($result)) {
+ return NULL;
+ }
+ if ($result === '') {
+ return array();
+ }
+ $settings = array();
+ for ($i=0; $i<7; $i++) {
+ if ($result & (1 << $i)) {
+ $setting[] = $i;
+ }
+ }
+ return $setting;
}
function write_setting($data) {
+ if (!is_array($data)) {
+ return '';
+ }
+ unset($data['xxxxx']);
$result = 0;
- if (!empty($data)) {
- foreach($data as $index) {
- $result |= 1 << $index;
- }
+ foreach($data as $index) {
+ $result |= 1 << $index;
}
- return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ return ($this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin'));
}
- function output_html() {
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
-
+ function output_html($data) {
// The order matters very much because of the implied numeric keys
$days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
$return = '<table><thead><tr>';
+ $return .= '<input type="hidden" name="'.$this->get_full_name().'[xxxxx]" value="1" />'; // something must be submitted even if nothing selected
foreach($days as $index => $day) {
- $return .= '<td><label for="id_s_'.$this->name.$index.'">'.get_string($day, 'calendar').'</label></td>';
+ $return .= '<td><label for="'.$this->get_id().$index.'">'.get_string($day, 'calendar').'</label></td>';
}
$return .= '</tr></thead><tbody><tr>';
foreach($days as $index => $day) {
- $return .= '<td><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.$index.'" name="s_'.$this->name.'[]" value="'.$index.'" '.($currentsetting & (1 << $index) ? 'checked="checked"' : '') . ' /></td>';
+ $return .= '<td><input type="checkbox" class="form-checkbox" id="'.$this->get_id().$index.'" name="'.$this->get_full_name().'[]" value="'.$index.'" '.(in_array("$index", $data) ? 'checked="checked"' : '').' /></td>';
}
$return .= '</tr></tbody></table>';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return format_admin_setting($this, $this->visiblename, $return, $this->description, false);
}
-
}
+
/**
- * this is used in config->grades
+ * Graded roles in gradebook
*/
-class admin_setting_special_gradebookroles extends admin_setting {
-
+class admin_setting_special_gradebookroles extends admin_setting_configmulticheckbox {
function admin_setting_special_gradebookroles() {
- $name = 'gradebookroles';
- $visiblename = get_string('gradebookroles', 'admin');
- $description = get_string('configgradebookroles', 'admin');
- $default = array(5=>'1'); // The student role in a default install
- parent::admin_setting($name, $visiblename, $description, $default);
+ parent::admin_setting_configmulticheckbox('gradebookroles', get_string('gradebookroles', 'admin'),
+ get_string('configgradebookroles', 'admin'), NULL, NULL);
}
- function get_setting() {
+ function load_choices() {
global $CFG;
- if (!empty($CFG->{$this->name})) {
- $result = explode(',', $CFG->{$this->name});
- foreach ($result as $roleid) {
- $array[$roleid] = 1;
+ if (empty($CFG->rolesactive)) {
+ return false;
+ }
+ if (is_array($this->choices)) {
+ return true;
+ }
+ if ($roles = get_records('role')) {
+ $this->choices = array();
+ foreach($roles as $role) {
+ $this->choices[$role->id] = format_string($role->name);
}
- return $array;
+ return true;
} else {
- return null;
+ return false;
}
}
- function write_setting($data) {
- if (!empty($data)) {
- $str = '';
- foreach ($data as $key => $value) {
- if ($value) {
- $str .= $key.',';
- }
+ function get_defaultsetting() {
+ global $CFG;
+ if (empty($CFG->rolesactive)) {
+ return NULL;
+ }
+ $result = array();
+ if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
+ foreach ($studentroles as $studentrole) {
+ $result[$studentrole->id] = '1';
}
- return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
- } else {
- return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
+ return $result;
}
+}
- function output_html() {
+/**
+ * Which roles to show on course decription page
+ */
+class admin_setting_special_coursemanager extends admin_setting_configmulticheckbox {
+ function admin_setting_special_coursemanager() {
+ parent::admin_setting_configmulticheckbox('coursemanager', get_string('coursemanager', 'admin'),
+ get_string('configcoursemanager', 'admin'), NULL, NULL);
+ }
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
}
- // from to process which roles to display
if ($roles = get_records('role')) {
- $return = '<div class="form-group">';
- $first = true;
- foreach ($roles as $roleid=>$role) {
- if (is_array($currentsetting) && in_array($roleid, array_keys($currentsetting))) {
- $checked = ' checked="checked"';
- } else {
- $checked = '';
- }
- if ($first) {
- $first = false;
- } else {
- $return .= '<br />';
- }
- $return .= '<input type="checkbox" name="s_'.$this->name.'['.$roleid.']" value="1"'.$checked.' /> '.format_string($role->name);
+ $this->choices = array();
+ foreach($roles as $role) {
+ $this->choices[$role->id] = format_string($role->name);
}
- $return .= '</div>';
+ return true;
}
+ return false;
+ }
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ function get_defaultsetting() {
+ global $CFG;
+ if (empty($CFG->rolesactive)) {
+ return NULL;
+ }
+ $result = array();
+ if ($teacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) {
+ foreach ($teacherroles as $teacherrole) {
+ $result[$teacherrole->id] = '1';
+ }
+ }
+ return $result;
+ }
+}
+/**
+ * Primary grade export plugin - has state tracking.
+ */
+class admin_setting_special_gradeexport extends admin_setting_configmulticheckbox {
+ function admin_setting_special_gradeexport() {
+ parent::admin_setting_configmulticheckbox('gradeexport', get_string('gradeexport', 'admin'),
+ get_string('configgradeexport', 'admin'), array(), NULL);
}
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = array();
+
+ if ($plugins = get_list_of_plugins('grade/export')) {
+ foreach($plugins as $plugin) {
+ $this->choices[$plugin] = get_string('modulename', 'gradeexport_'.$plugin);
+ }
+ }
+ return true;
+ }
}
-/*
- * this is used in config->appearance->coursemanager
- * (which roles to show on course decription page)
+/**
+ * Grade category settings
*/
-class admin_setting_special_coursemanager extends admin_setting {
+class admin_setting_gradecat_combo extends admin_setting {
- function admin_setting_special_coursemanager() {
- $name = 'coursemanager';
- $visiblename = get_string('coursemanager', 'admin');
- $description = get_string('configcoursemanager', 'admin');
- $default = array(3=>'1'); // The teahcer role in a default install
- parent::admin_setting($name, $visiblename, $description, $default);
+ var $choices;
+
+ function admin_setting_gradecat_combo($name, $visiblename, $description, $defaultsetting, $choices) {
+ $this->choices = $choices;
+ parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
function get_setting() {
-
global $CFG;
- if (!empty($CFG->{$this->name})) {
- $result = explode(',', $CFG->{$this->name});
- foreach ($result as $roleid) {
- $array[$roleid] = 1;
- }
- return $array;
- } else if (isset($CFG->{$this->name})) {
- return array();
- } else {
- return null;
+
+ $value = $this->config_read($this->name);
+ $flag = $this->config_read($this->name.'_flag');
+
+ if (is_null($value) or is_null($flag)) {
+ return NULL;
}
+
+ $flag = (int)$flag;
+ $forced = (boolean)(1 & $flag); // first bit
+ $adv = (boolean)(2 & $flag); // second bit
+
+ return array('value' => $value, 'forced' => $forced, 'adv' => $adv);
}
function write_setting($data) {
+ global $CFG;
- if (!empty($data)) {
- $str = '';
- foreach ($data as $key => $value) {
- if ($value) {
- $str .= $key.',';
- }
- }
- return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ $value = $data['value'];
+ $forced = empty($data['forced']) ? 0 : 1;
+ $adv = empty($data['adv']) ? 0 : 2;
+ $flag = ($forced | $adv); //bitwise or
+
+ if (!in_array($value, array_keys($this->choices))) {
+ return 'Error setting ';
+ }
+
+ $oldvalue = $this->config_read($this->name);
+ $oldflag = (int)$this->config_read($this->name.'_flag');
+ $oldforced = (1 & $oldflag); // first bit
+
+ $result1 = $this->config_write($this->name, $value);
+ $result2 = $this->config_write($this->name.'_flag', $flag);
+
+ // force regrade if needed
+ if ($oldforced != $forced or ($forced and $value != $oldvalue)) {
+ require_once($CFG->libdir.'/gradelib.php');
+ grade_category::updated_forced_settings();
+ }
+
+ if ($result1 and $result2) {
+ return '';
} else {
- return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin');
}
}
- function output_html() {
+ function output_html($data) {
+ $value = $data['value'];
+ $forced = !empty($data['forced']);
+ $adv = !empty($data['adv']);
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
- // from to process which roles to display
- if ($roles = get_records_select('role', '', 'sortorder')) {
- $return = '<div class="form-group">';
- $first = true;
- foreach ($roles as $roleid=>$role) {
- if (is_array($currentsetting) && in_array($roleid, array_keys($currentsetting))) {
- $checked = 'checked="checked"';
- } else {
- $checked = '';
- }
- if ($first) {
- $first = false;
- } else {
- $return .= '<br />';
+ $return = '<select class="form-select" id="'.$this->get_id().'" name="'.$this->get_full_name().'[value]">';
+ foreach ($this->choices as $key => $val) {
+ // the string cast is needed because key may be integer - 0 is equal to most strings!
+ $return .= '<option value="'.$key.'"'.((string)$key==$value ? ' selected="selected"' : '').'>'.$val.'</option>';
+ }
+ $return .= '</select>';
+ $return .= '</label><input type="checkbox" class="form-checkbox" id="'.$this->get_id().'force" name="'.$this->get_full_name().'[forced]" value="1" '.($forced ? 'checked="checked"' : '').' />'
+ .'<label for="'.$this->get_id().'force">'.get_string('force');
+ $return .= '</label><input type="checkbox" class="form-checkbox" id="'.$this->get_id().'adv" name="'.$this->get_full_name().'[adv]" value="1" '.($adv ? 'checked="checked"' : '').' />'
+ .'<label for="'.$this->get_id().'adv">'.get_string('advanced');
+
+ return format_admin_setting($this, $this->visiblename, $return, $this->description);
+ }
+}
+
+
+/**
+ * Selection of grade report in user profiles
+ */
+class admin_setting_grade_profilereport extends admin_setting_configselect {
+ function admin_setting_grade_profilereport() {
+ parent::admin_setting_configselect('grade_profilereport', get_string('profilereport', 'grades'), get_string('configprofilereport', 'grades'), 'user', null);
+ }
+
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = array();
+
+ global $CFG;
+ require_once($CFG->libdir.'/gradelib.php');
+
+ foreach (get_list_of_plugins('grade/report') as $plugin) {
+ if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php')) {
+ require_once($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php');
+ $functionname = 'grade_report_'.$plugin.'_profilereport';
+ if (function_exists($functionname)) {
+ $this->choices[$plugin] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/');
}
- $return .= '<input type="checkbox" name="s_'.$this->name.'['.$roleid.']" value="1" '.$checked.' /> '.$role->name;
}
- $return .= '</div>';
}
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ return true;
}
}
-/*
- * this is used in config->courses->gradeexports
- * (which roles to show on course decription page)
+/**
+ * Special class for register auth selection
*/
-class admin_setting_special_gradeexport extends admin_setting {
-
- function admin_setting_special_gradeexport() {
- $name = 'gradeexport';
- $visiblename = get_string('gradeexport', 'admin');
- $description = get_string('configgradeexport', 'admin');
- $default = array(3=>'1'); // The teahcer role in a default install
- parent::admin_setting($name, $visiblename, $description, $default);
+class admin_setting_special_registerauth extends admin_setting_configselect {
+ function admin_setting_special_registerauth() {
+ parent::admin_setting_configselect('registerauth', get_string('selfregistration', 'auth'), get_string('selfregistration_help', 'auth'), 'email', null);
}
- function get_setting() {
+ function get_defaultsettings() {
+ $this->load_choices();
+ if (array_key_exists($this->defaultsetting, $this->choices)) {
+ return $this->defaultsetting;
+ } else {
+ return '';
+ }
+ }
+ function load_choices() {
global $CFG;
- if (!empty($CFG->{$this->name})) {
- $result = explode(',', $CFG->{$this->name});
- foreach ($result as $plugin) {
- $array[$plugin] = 1;
+
+ if (is_array($this->choices)) {
+ return true;
+ }
+ $this->choices = array();
+ $this->choices[''] = get_string('disable');
+
+ $authsenabled = get_enabled_auth_plugins(true);
+
+ foreach ($authsenabled as $auth) {
+ $authplugin = get_auth_plugin($auth);
+ if (!$authplugin->can_signup()) {
+ continue;
}
- return $array;
- } else if (isset($CFG->{$this->name})) {
- return array();
- } else {
- return null;
+ // Get the auth title (from core or own auth lang files)
+ $authtitle = get_string("auth_{$auth}title", "auth");
+ if ($authtitle == "[[auth_{$auth}title]]") {
+ $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
+ }
+ $this->choices[$auth] = $authtitle;
}
+ return true;
}
+}
- function write_setting($data) {
+/**
+ * Module manage page
+ */
+class admin_page_managemods extends admin_externalpage {
+ function admin_page_managemods() {
+ global $CFG;
+ parent::admin_externalpage('managemodules', get_string('modsettings', 'admin'), "$CFG->wwwroot/$CFG->admin/modules.php");
+ }
- if (!empty($data)) {
- $str = '';
- foreach ($data as $key => $value) {
- if ($value) {
- $str .= $key.',';
+ function search($query) {
+ if (parent::search($query)) {
+ return true;
+ }
+
+ $found = false;
+ if ($modules = get_records('modules')) {
+ $textlib = textlib_get_instance();
+ foreach ($modules as $module) {
+ if (strpos($module->name, $query) !== false) {
+ $found = true;
+ break;
+ }
+ $strmodulename = get_string('modulename', $module->name);
+ if (strpos($textlib->strtolower($strmodulename), $query) !== false) {
+ $found = true;
+ break;
}
}
- return set_config($this->name, rtrim($str, ","))?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ }
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = array();
+ return array($this->name => $result);
} else {
- return set_config($this->name, '')?'':get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
+ return array();
}
}
+}
- function output_html() {
+/**
+ * Blocks manage page
+ */
+class admin_page_manageblocks extends admin_externalpage {
+ function admin_page_manageblocks() {
+ global $CFG;
+ parent::admin_externalpage('manageblocks', get_string('blocksettings', 'admin'), "$CFG->wwwroot/$CFG->admin/blocks.php");
+ }
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
- }
- // from to process which roles to display
- if ($exports = get_list_of_plugins('grade/export')) {
- $return = '<div class="form-group">';
- $first = true;
- foreach ($exports as $export) {
- if (is_array($currentsetting) && in_array($export, array_keys($currentsetting))) {
- $checked = 'checked="checked"';
- } else {
- $checked = '';
+ function search($query) {
+ global $CFG;
+ if (parent::search($query)) {
+ return true;
+ }
+
+ $found = false;
+ if (!empty($CFG->blocks_version) and $blocks = get_records('block')) {
+ $textlib = textlib_get_instance();
+ foreach ($blocks as $block) {
+ if (strpos($block->name, $query) !== false) {
+ $found = true;
+ break;
}
- if ($first) {
- $first = false;
- } else {
- $return .= '<br />';
+ $strblockname = get_string('blockname', 'block_'.$block->name);
+ if (strpos($textlib->strtolower($strblockname), $query) !== false) {
+ $found = true;
+ break;
}
- $return .= '<input type="checkbox" name="s_'.$this->name.'['.$export.']" value="1" '.$checked.' /> '.$export;
}
- $return .= '</div>';
}
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description, false);
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = array();
+ return array($this->name => $result);
+ } else {
+ return array();
+ }
}
}
+/**
+ * Special class for authentication administration.
+ */
+class admin_setting_manageauths extends admin_setting {
+ function admin_setting_manageauths() {
+ parent::admin_setting('authsui', get_string('authsettings', 'admin'), '', '');
+ }
+ function get_setting() {
+ return true;
+ }
-
-class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
-
- function admin_setting_special_perfdebug() {
- $name = 'perfdebug';
- $visiblename = get_string('perfdebug', 'admin');
- $description = get_string('configperfdebug', 'admin');
- parent::admin_setting_configcheckbox($name, $visiblename, $description, '');
+ function get_defaultsetting() {
+ return true;
}
function write_setting($data) {
-
- if ($data == '1') {
- return (set_config($this->name,15) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- } else {
- return (set_config($this->name,7) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
- }
+ // do not write any setting
+ return '';
}
- function output_html() {
+ function is_related($query) {
+ if (parent::is_related($query)) {
+ return true;
+ }
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
+ $textlib = textlib_get_instance();
+ $authsavailable = get_list_of_plugins('auth');
+ foreach ($authsavailable as $auth) {
+ if (strpos($auth, $query) !== false) {
+ return true;
+ }
+ $authtitle = get_string("auth_{$auth}title", "auth");
+ if ($authtitle == "[[auth_{$auth}title]]") {
+ $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
+ }
+ if (strpos($textlib->strtolower($authtitle), $query) !== false) {
+ return true;
+ }
}
-
- $return = '<input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'" name="s_'. $this->name .'" value="1" ' . ($currentsetting == 15 ? 'checked="checked"' : '') . ' />';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
+ return false;
}
-}
-
-class admin_setting_special_debugdisplay extends admin_setting_configcheckbox {
+ function output_html($data) {
+ global $CFG;
- function admin_setting_special_debugdisplay() {
- $name = 'debugdisplay';
- $visiblename = get_string('debugdisplay', 'admin');
- $description = get_string('configdebugdisplay', 'admin');
- $default = ini_get('display_errors');
- parent::admin_setting_configcheckbox($name, $visiblename, $description, $default);
- }
- function write_setting($data) {
+ // display strings
+ $txt = get_strings(array('authenticationplugins', 'users', 'administration',
+ 'settings', 'edit', 'name', 'enable', 'disable',
+ 'up', 'down', 'none'));
+ $txt->updown = "$txt->up/$txt->down";
- if ($data == '1') {
- return (set_config($this->name,1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $authsavailable = get_list_of_plugins('auth');
+ get_enabled_auth_plugins(true); // fix the list of enabled auths
+ if (empty($CFG->auth)) {
+ $authsenabled = array();
} else {
- return (set_config($this->name,0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
+ $authsenabled = explode(',', $CFG->auth);
+ }
+
+ // construct the display array, with enabled auth plugins at the top, in order
+ $displayauths = array();
+ $registrationauths = array();
+ $registrationauths[''] = $txt->disable;
+ foreach ($authsenabled as $auth) {
+ $authplugin = get_auth_plugin($auth);
+ /// Get the auth title (from core or own auth lang files)
+ $authtitle = get_string("auth_{$auth}title", "auth");
+ if ($authtitle == "[[auth_{$auth}title]]") {
+ $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
+ }
+ /// Apply titles
+ $displayauths[$auth] = $authtitle;
+ if ($authplugin->can_signup()) {
+ $registrationauths[$auth] = $authtitle;
+ }
}
- }
-
- function output_html() {
- if ($this->get_setting() === NULL) {
- $currentsetting = $this->defaultsetting;
- } else {
- $currentsetting = $this->get_setting();
+ foreach ($authsavailable as $auth) {
+ if (array_key_exists($auth, $displayauths)) {
+ continue; //already in the list
+ }
+ $authplugin = get_auth_plugin($auth);
+ /// Get the auth title (from core or own auth lang files)
+ $authtitle = get_string("auth_{$auth}title", "auth");
+ if ($authtitle == "[[auth_{$auth}title]]") {
+ $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
+ }
+ /// Apply titles
+ $displayauths[$auth] = $authtitle;
+ if ($authplugin->can_signup()) {
+ $registrationauths[$auth] = $authtitle;
+ }
}
- $return = '<input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'" name="s_'. $this->name .'" value="1" ' . ($currentsetting == 1 ? 'checked="checked"' : '') . ' />';
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
- }
+ $return = print_heading(get_string('actauthhdr', 'auth'), '', 3, 'main', true);
+ $return .= print_box_start('generalbox authsui', '', true);
-}
+ $table = new object();
+ $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
+ $table->align = array('left', 'center', 'center', 'center');
+ $table->width = '90%';
+ $table->data = array();
+ //add always enabled plugins first
+ $displayname = "<span>".$displayauths['manual']."</span>";
+ $settings = "<a href=\"settings.php?section=authsettingmanual\">{$txt->settings}</a>";
+ $table->data[] = array($displayname, '', '', $settings);
+ $displayname = "<span>".$displayauths['nologin']."</span>";
+ $settings = "<a href=\"auth_config.php?auth=nologin\">{$txt->settings}</a>";
+ $table->data[] = array($displayname, '', '', $settings);
-class admin_setting_gradecat_combo extends admin_setting {
- var $choices;
+ // iterate through auth plugins and add to the display table
+ $updowncount = 1;
+ $authcount = count($authsenabled);
+ $url = "auth.php?sesskey=" . sesskey();
+ foreach ($displayauths as $auth => $name) {
+ if ($auth == 'manual' or $auth == 'nologin') {
+ continue;
+ }
+ // hide/show link
+ if (in_array($auth, $authsenabled)) {
+ $hideshow = "<a href=\"$url&action=disable&auth=$auth\">";
+ $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" /></a>";
+ // $hideshow = "<a href=\"$url&action=disable&auth=$auth\"><input type=\"checkbox\" checked /></a>";
+ $enabled = true;
+ $displayname = "<span>$name</span>";
+ }
+ else {
+ $hideshow = "<a href=\"$url&action=enable&auth=$auth\">";
+ $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" /></a>";
+ // $hideshow = "<a href=\"$url&action=enable&auth=$auth\"><input type=\"checkbox\" /></a>";
+ $enabled = false;
+ $displayname = "<span class=\"dimmed_text\">$name</span>";
+ }
- function admin_setting_gradecat_combo($name, $visiblename, $description, $defaultsetting, $choices) {
- $this->choices = $choices;
- parent::admin_setting($name, $visiblename, $description, $defaultsetting);
- }
+ // up/down link (only if auth is enabled)
+ $updown = '';
+ if ($enabled) {
+ if ($updowncount > 1) {
+ $updown .= "<a href=\"$url&action=up&auth=$auth\">";
+ $updown .= "<img src=\"{$CFG->pixpath}/t/up.gif\" alt=\"up\" /></a> ";
+ }
+ else {
+ $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> ";
+ }
+ if ($updowncount < $authcount) {
+ $updown .= "<a href=\"$url&action=down&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;
+ }
- function get_setting() {
- global $CFG;
+ // settings link
+ if (file_exists($CFG->dirroot.'/auth/'.$auth.'/settings.php')) {
+ $settings = "<a href=\"settings.php?section=authsetting$auth\">{$txt->settings}</a>";
+ } else {
+ $settings = "<a href=\"auth_config.php?auth=$auth\">{$txt->settings}</a>";
+ }
- if (!isset($CFG->{$this->name}) or !isset($CFG->{$this->name.'_flag'})) {
- return NULL;
+ // add a row to the table
+ $table->data[] =array($displayname, $hideshow, $updown, $settings);
}
+ $return .= print_table($table, true);
+ $return .= get_string('configauthenticationplugins', 'admin').'<br />'.get_string('tablenosave', 'filters');
+ $return .= print_box_end(true);
+ return $return;
+ }
+}
+/**
+ * Special class for filter administration.
+ */
+class admin_setting_managefilters extends admin_setting {
+ function admin_setting_managefilters() {
+ parent::admin_setting('filtersui', get_string('filtersettings', 'admin'), '', '');
+ }
- $flag = (int)$CFG->{$this->name.'_flag'};
- $forced = (boolean)(1 & $flag); // first bit
- $adv = (boolean)(2 & $flag); // second bit
-
- return array('value' => $CFG->{$this->name}, 'forced' => $forced, 'adv' => $adv);
+ function get_setting() {
+ return true;
+ }
+
+ function get_defaultsetting() {
+ return true;
}
function write_setting($data) {
- global $CFG;
+ // do not write any setting
+ return '';
+ }
- $value = $data['value'];
- $forced = empty($data['forced']) ? 0 : 1;
- $adv = empty($data['adv']) ? 0 : 2;
- $flag = ($forced | $adv); //bitwise or
-
- if (!in_array($value, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ function is_related($query) {
+ if (parent::is_related($query)) {
+ return true;
}
- $oldvalue = get_config(NULL, $this->name);
- $oldflag = (int)get_config(NULL, $this->name.'_flag');
- $oldforced = (1 & $oldflag); // first bit
-
- $result = (boolean)set_config($this->name, $value);
- $result = $result && (boolean)set_config($this->name.'_flag', $flag);
-
- if ($result) {
- // force regrade if needed
- if ($oldforced != $forced or ($forced and $value != $oldvalue)) {
- require_once($CFG->libdir.'/gradelib.php');
- grade_category::updated_forced_settings();
+ $textlib = textlib_get_instance();
+ $filterlocations = array('mod','filter');
+ foreach ($filterlocations as $filterlocation) {
+ $plugins = get_list_of_plugins($filterlocation);
+ foreach ($plugins as $plugin) {
+ if (strpos($plugin, $query) !== false) {
+ return true;
+ }
+ $name = get_string('filtername', $plugin);
+ if (strpos($textlib->strtolower($name), $query) !== false) {
+ return true;
+ }
}
-
- return '';
- } else {
- return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
+ return false;
}
- function output_html() {
+ function output_html($data) {
+ global $CFG;
- if ($this->get_setting() === NULL) {
- $current = $this->defaultsetting;
- } else {
- $current = $this->get_setting();
+ $strname = get_string('name');
+ $strhide = get_string('disable');
+ $strshow = get_string('enable');
+ $strhideshow = "$strhide/$strshow";
+ $strsettings = get_string('settings');
+ $strup = get_string('up');
+ $strdown = get_string('down');
+ $strupdown = "$strup/$strdown";
+
+ // get a list of possible filters (and translate name if possible)
+ // note filters can be in the dedicated filters area OR in their
+ // associated modules
+ $installedfilters = array();
+ $filtersettings_new = array();
+ $filtersettings_old = array();
+ $filterlocations = array('mod','filter');
+ foreach ($filterlocations as $filterlocation) {
+ $plugins = get_list_of_plugins($filterlocation);
+ foreach ($plugins as $plugin) {
+ $pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
+ $settingspath_new = "$CFG->dirroot/$filterlocation/$plugin/filtersettings.php";
+ $settingspath_old = "$CFG->dirroot/$filterlocation/$plugin/filterconfig.html";
+ if (is_readable($pluginpath)) {
+ $name = trim(get_string("filtername", $plugin));
+ if (empty($name) or ($name == '[[filtername]]')) {
+ $textlib = textlib_get_instance();
+ $name = $textlib->strtotitle($plugin);
+ }
+ $installedfilters["$filterlocation/$plugin"] = $name;
+ if (is_readable($settingspath_new)) {
+ $filtersettings_new[] = "$filterlocation/$plugin";
+ } else if (is_readable($settingspath_old)) {
+ $filtersettings_old[] = "$filterlocation/$plugin";
+ }
+ }
+ }
}
- $value = $current['value'];
- $forced = !empty($current['forced']);
- $adv = !empty($current['adv']);
- $return = '<select class="form-select" id="id_s_'.$this->name.'" name="s_' . $this->name .'[value]">';
- foreach ($this->choices as $key => $val) {
- // the string cast is needed because key may be integer - 0 is equal to most strings!
- $return .= '<option value="'.$key.'"'.((string)$key==$value ? ' selected="selected"' : '').'>'.$val.'</option>';
+ // get all the currently selected filters
+ if (!empty($CFG->textfilters)) {
+ $oldactivefilters = explode(',', $CFG->textfilters);
+ $oldactivefilters = array_unique($oldactivefilters);
+ } else {
+ $oldactivefilters = array();
}
- $return .= '</select>';
- $return .= '<label for="id_s_'.$this->name.'force">'.get_string('force').'</label><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'force" name="s_'.$this->name.'[forced]" value="1" ' . ($forced ? 'checked="checked"' : '') . ' />';
- $return .= '<label for="id_s_'.$this->name.'adv">'.get_string('advanced').'</label><input type="checkbox" class="form-checkbox" id="id_s_'.$this->name.'adv" name="s_'.$this->name.'[adv]" value="1" ' . ($adv ? 'checked="checked"' : '') . ' />';
-
- return format_admin_setting($this->name, $this->visiblename, $return, $this->description);
- }
-}
+ // take this opportunity to clean up filters
+ $activefilters = array();
+ foreach ($oldactivefilters as $oldactivefilter) {
+ if (!empty($oldactivefilter) and array_key_exists($oldactivefilter, $installedfilters)) {
+ $activefilters[] = $oldactivefilter;
+ }
+ }
-/**
- * Selection of grade report in user profile
- */
-class admin_setting_grade_profilereport extends admin_setting_configselect {
- function admin_setting_grade_profilereport() {
- parent::admin_setting_configselect('grade_profilereport', get_string('profilereport', 'grades'), get_string('configprofilereport', 'grades'), 'user', null);
- }
-
- function load_choices() {
- if (!empty($this->choices)) {
- return;
+ // construct the display array with installed filters
+ // at the top in the right order
+ $displayfilters = array();
+ foreach ($activefilters as $activefilter) {
+ $name = $installedfilters[$activefilter];
+ $displayfilters[$activefilter] = $name;
+ }
+ foreach ($installedfilters as $key => $filter) {
+ if (!array_key_exists($key, $displayfilters)) {
+ $displayfilters[$key] = $filter;
+ }
}
- $this->choices = array();
- global $CFG;
- require_once($CFG->libdir.'/gradelib.php');
+ $return = print_heading(get_string('actfilterhdr', 'filters'), '', 3, 'main', true);
+ $return .= print_box_start('generalbox filtersui', '', true);
+
+ $table = new object();
+ $table->head = array($strname, $strhideshow, $strupdown, $strsettings);
+ $table->align = array('left', 'center', 'center', 'center');
+ $table->width = '90%';
+ $table->data = array();
+
+ $filtersurl = "$CFG->wwwroot/$CFG->admin/filters.php?sesskey=".sesskey();
+ $imgurl = "$CFG->pixpath/t";
+
+ // iterate through filters adding to display table
+ $updowncount = 1;
+ $activefilterscount = count($activefilters);
+ foreach ($displayfilters as $path => $name) {
+ $upath = urlencode($path);
+ // get hide/show link
+ if (in_array($path, $activefilters)) {
+ $hideshow = "<a href=\"$filtersurl&action=hide&filterpath=$upath\">";
+ $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"$strhide\" /></a>";
+ $hidden = false;
+ $displayname = "<span>$name</span>";
+ }
+ else {
+ $hideshow = "<a href=\"$filtersurl&action=show&filterpath=$upath\">";
+ $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
+ $hidden = true;
+ $displayname = "<span class=\"dimmed_text\">$name</span>";
+ }
- foreach (get_list_of_plugins('grade/report') as $plugin) {
- if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php')) {
- require_once($CFG->dirroot.'/grade/report/'.$plugin.'/lib.php');
- $functionname = 'grade_report_'.$plugin.'_profilereport';
- if (function_exists($functionname)) {
- $this->choices[$plugin] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/');
+ // get up/down link (only if not hidden)
+ $updown = '';
+ if (!$hidden) {
+ if ($updowncount>1) {
+ $updown .= "<a href=\"$filtersurl&action=up&filterpath=$upath\">";
+ $updown .= "<img src=\"$imgurl/up.gif\" alt=\"$strup\" /></a> ";
+ }
+ else {
+ $updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> ";
+ }
+ if ($updowncount<$activefilterscount) {
+ $updown .= "<a href=\"$filtersurl&action=down&filterpath=$upath\">";
+ $updown .= "<img src=\"$imgurl/down.gif\" alt=\"$strdown\" /></a>";
+ }
+ else {
+ $updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />";
}
+ ++$updowncount;
}
+
+ // settings link (if defined)
+ $settings = '';
+ if (in_array($path, $filtersettings_new)) {
+ $settings = "<a href=\"settings.php?section=filtersetting".str_replace('/', '',$path)."\">$strsettings</a>";
+ } else if (in_array($path, $filtersettings_old)) {
+ $settings = "<a href=\"filter.php?filter=".urlencode($path)."\">$strsettings</a>";
+ }
+
+ // write data into the table object
+ $table->data[] = array($displayname, $hideshow, $updown, $settings);
}
- }
+ $return .= print_table($table, true);
+ $return .= get_string('tablenosave', 'filters');
+ $return .= print_box_end(true);
+ return $return;
+ }
}
-
-// Code for a function that helps externalpages print proper headers and footers
-// N.B.: THIS FUNCTION HANDLES AUTHENTICATION
+/**
+ * Initialise admin page - this function does require login and permission
+ * checks specified in page definition.
+ * This function must be called on each admin page before other code.
+ * @param string $section name of page
+ */
function admin_externalpage_setup($section) {
global $CFG, $PAGE, $USER;
-
- $adminroot = admin_get_root();
-
- require_once($CFG->libdir . '/blocklib.php');
- require_once($CFG->dirroot . '/'.$CFG->admin.'/pagelib.php');
-
- page_map_class(PAGE_ADMIN, 'page_admin');
-
- $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
-
- $PAGE->init_extra($section); // hack alert!
-
- $root = $adminroot->locate($PAGE->section);
+ require_once($CFG->libdir.'/blocklib.php');
+ require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
if ($site = get_site()) {
require_login();
} else {
- redirect($CFG->wwwroot . '/'.$CFG->admin.'/index.php');
+ redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
die;
}
- if (!is_a($root, 'admin_externalpage')) {
+ $adminroot =& admin_get_root(false, false); // settings not required for external pages
+ $extpage =& $adminroot->locate($section);
+
+ if (empty($extpage) or !is_a($extpage, 'admin_externalpage')) {
error(get_string('sectionerror','admin'));
die;
}
// this eliminates our need to authenticate on the actual pages
- if (!($root->check_access())) {
+ if (!($extpage->check_access())) {
error(get_string('accessdenied', 'admin'));
die;
}
+ page_map_class(PAGE_ADMIN, 'page_admin');
+ $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
+ $PAGE->init_extra($section); // hack alert!
+
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = false;
}
}
-
}
/**
- * TODO document
+ * Print header for admin page
+ * @param string $focus focus element
*/
-function admin_externalpage_print_header() {
+function admin_externalpage_print_header($focus='') {
+
+ if (!is_string($focus)) {
+ $focus = ''; // BC compatibility, there used to be adminroot parameter
+ }
global $CFG, $PAGE, $SITE, $THEME;
blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
BLOCK_R_MAX_WIDTH);
- $PAGE->print_header();
+ $PAGE->print_header('', $focus);
echo '<table id="layout-table" summary=""><tr>';
$lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
}
}
+/**
+ * Print footer on admin page - please use normal print_footer() instead
+ */
function admin_externalpage_print_footer() {
global $CFG, $PAGE, $SITE, $THEME;
print_footer();
}
-function admin_get_root() {
+/**
+ * Returns the reference to admin tree root
+ * @return reference
+ */
+function &admin_get_root($reload=false, $requirefulltree=true) {
global $CFG;
- static $ADMIN;
+ static $ADMIN = NULL;
+
+ if (!is_null($ADMIN)) {
+ $olderrors = $ADMIN->errors;
+ $oldsearch = $ADMIN->search;
+ $oldfulltree = $ADMIN->fulltree;
+ } else {
+ $olderrors = array();
+ $oldsearch = '';
+ $oldfulltree = false;
+ }
+
+ if ($reload or ($requirefulltree and !$oldfulltree)) {
+ $ADMIN = NULL;
+ }
- if (!isset($ADMIN)) {
+ if (is_null($ADMIN)) {
// start the admin tree!
- $ADMIN = new admin_category('root', get_string("administration"));
- // we process this file first to get categories up and running
- include($CFG->dirroot . '/'.$CFG->admin.'/settings/top.php');
+ $ADMIN = new admin_root();
+ // array of error messages and search query
+ $ADMIN->errors = $olderrors;
+ $ADMIN->search = $oldsearch;
+ if ($requirefulltree) {
+ $ADMIN->fulltree = true;
+ } else {
+ $ADMIN->fulltree = $oldfulltree;
+ }
- // now we process all other files in admin/settings to build the
- // admin tree
- foreach (glob($CFG->dirroot . '/'.$CFG->admin.'/settings/*.php') as $file) {
- if ($file != $CFG->dirroot . '/'.$CFG->admin.'/settings/top.php') {
- include_once($file);
+ // we process this file first to create categories first and in correct order
+ require($CFG->dirroot.'/'.$CFG->admin.'/settings/top.php');
+
+ // now we process all other files in admin/settings to build the admin tree
+ foreach (glob($CFG->dirroot.'/'.$CFG->admin.'/settings/*.php') as $file) {
+ if ($file != $CFG->dirroot.'/'.$CFG->admin.'/settings/top.php') {
+ include($file);
}
}
}
/**
* This function applies default settings.
- * @param object $node
+ * @param object $node, NULL means complete tree
* @param bool $uncoditional if true overrides all values with defaults
* @return void
*/
-function apply_default_settings(&$node, $unconditional=true) {
-
+function admin_apply_default_settings($node=NULL, $unconditional=true) {
global $CFG;
+ if (is_null($node)) {
+ $node =& admin_get_root();
+ }
+
if (is_a($node, 'admin_category')) {
$entries = array_keys($node->children);
foreach ($entries as $entry) {
- apply_default_settings($node->children[$entry]);
+ admin_apply_default_settings($node->children[$entry], $unconditional);
}
- return;
- }
- if (is_a($node, 'admin_settingpage')) {
+ } else if (is_a($node, 'admin_settingpage')) {
foreach ($node->settings as $setting) {
- if (!$unconditional and !is_null($setting->get_setting)) {
+ if (!$unconditional and !is_null($setting->get_setting())) {
//do not override existing defaults
continue;
}
// no value yet - default maybe applied after admin user creation or in upgradesettings
continue;
}
- $CFG->{$setting->name} = $defaultsetting;
$setting->write_setting($defaultsetting);
- unset($setting); // needed to prevent odd (imho) reference behaviour
- // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399
}
- return;
+ }
+}
+
+/**
+ * Store changed settings, this function updates the errors variable in $ADMIN
+ * @param object $formdata from form (without magic quotes)
+ * @return int number of changed settings
+ */
+function admin_write_settings($formdata) {
+ global $CFG, $SITE, $COURSE;
+
+ $olddbsessions = !empty($CFG->dbsessions);
+ $formdata = (array)stripslashes_recursive($formdata);
+
+ $data = array();
+ foreach ($formdata as $fullname=>$value) {
+ if (strpos($fullname, 's_') !== 0) {
+ continue; // not a config value
+ }
+ $data[$fullname] = $value;
+ }
+
+ $adminroot =& admin_get_root();
+ $settings = admin_find_write_settings($adminroot, $data);
+
+ $count = 0;
+ foreach ($settings as $fullname=>$setting) {
+ $original = serialize($setting->get_setting()); // comparison must work for arrays too
+ $error = $setting->write_setting($data[$fullname]);
+ if ($error !== '') {
+ $adminroot->errors[$fullname] = new object();
+ $adminroot->errors[$fullname]->data = $data[$fullname];
+ $adminroot->errors[$fullname]->id = $setting->get_id();
+ $adminroot->errors[$fullname]->error = $error;
+ }
+ if ($original !== serialize($setting->get_setting())) {
+ $count++;
+ $callbackfunction = $setting->updatedcallback;
+ if (function_exists($callbackfunction)) {
+ $callbackfunction($fullname);
+ }
+ }
+ }
+
+ if ($olddbsessions != !empty($CFG->dbsessions)) {
+ require_logout();
}
- return;
+ // now update $SITE - it might have been changed
+ $SITE = get_record('course', 'id', $SITE->id);
+ $COURSE = clone($SITE);
+ // now reload all settings - some of them might depend on the changed
+ admin_get_root(true);
+ return $count;
}
-// n.b. this function unconditionally applies default settings
-function apply_default_exception_settings($defaults) {
+/**
+ * Internal recursive function - finds all settings from submitted form
+ */
+function admin_find_write_settings($node, $data) {
+ $return = array();
+
+ if (empty($data)) {
+ return $return;
+ }
+
+ if (is_a($node, 'admin_category')) {
+ $entries = array_keys($node->children);
+ foreach ($entries as $entry) {
+ $return = array_merge($return, admin_find_write_settings($node->children[$entry], $data));
+ }
+
+ } else if (is_a($node, 'admin_settingpage')) {
+ foreach ($node->settings as $setting) {
+ $fullname = $setting->get_full_name();
+ if (array_key_exists($fullname, $data)) {
+ $return[$fullname] = $setting;
+ }
+ }
+
+ }
+
+ return $return;
+}
+/**
+ * Internal function - prints the search results
+ */
+function admin_search_settings_html($query) {
global $CFG;
- foreach($defaults as $key => $value) {
- $CFG->$key = $value;
- set_config($key, $value);
+ $textlib = textlib_get_instance();
+ if ($textlib->strlen($query) < 2) {
+ return '';
+ }
+ $query = $textlib->strtolower($query);
+
+ $adminroot =& admin_get_root();
+ $findings = $adminroot->search($query);
+ $return = '';
+
+ foreach ($findings as $found) {
+ $page = $found->page;
+ $settings = $found->settings;
+ if ($page->hidden) {
+ continue;
+ }
+ if (is_a($page, 'admin_externalpage')) {
+ $return .= print_heading(get_string('searchresults','admin').' - <a href="'.$page->url.'">'.highlight($query, $page->visiblename).'</a>', '', 2, 'main', true);
+ } else if (is_a($page, 'admin_settingpage')) {
+ $return .= print_heading(get_string('searchresults','admin').' - <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section='.$page->name.'">'.highlight($query, $page->visiblename).'</a>', '', 2, 'main', true);
+ } else {
+ continue;
+ }
+ if (!empty($settings)) {
+ $return .= '<fieldset class="adminsettings">'."\n";
+ foreach ($settings as $setting) {
+ $return .= '<div class="clearer"><!-- --></div>'."\n";
+ $fullname = $setting->get_full_name();
+ if (array_key_exists($fullname, $adminroot->errors)) {
+ $data = $adminroot->errors[$fullname]->data;
+ } else {
+ $data = $setting->get_setting();
+ if (is_null($data)) {
+ $data = $setting->get_defaultsetting();
+ }
+ }
+ $return .= highlight($query, $setting->output_html($data));
+ }
+ $return .= '</fieldset>';
+ }
+ }
+
+ return $return;
+}
+
+/**
+ * Internal function - prints list of uninitialised settings
+ */
+function admin_output_new_settings_by_page($node) {
+ $return = '';
+
+ if (is_a($node, 'admin_category')) {
+ $entries = array_keys($node->children);
+ foreach ($entries as $entry) {
+ $return .= admin_output_new_settings_by_page($node->children[$entry]);
+ }
+
+ } else if (is_a($node, 'admin_settingpage')) {
+ $newsettings = array();
+ foreach ($node->settings as $setting) {
+ if (is_null($setting->get_setting())) {
+ $newsettings[] = $setting;
+ }
+ }
+ if (count($newsettings) > 0) {
+ $adminroot =& admin_get_root();
+ $return .= print_heading(get_string('upgradesettings','admin').' - '.$node->visiblename, '', 2, 'main', true);
+ $return .= '<fieldset class="adminsettings">'."\n";
+ foreach ($newsettings as $setting) {
+ $fullname = $setting->get_full_name();
+ if (array_key_exists($fullname, $adminroot->errors)) {
+ $data = $adminroot->errors[$fullname]->data;
+ } else {
+ $data = $setting->get_setting();
+ if (is_null($data)) {
+ $data = $setting->get_defaultsetting();
+ }
+ }
+ $return .= '<div class="clearer"><!-- --></div>'."\n";
+ $return .= $setting->output_html($data);
+ }
+ $return .= '</fieldset>';
+ }
}
+ return $return;
+}
+
+/**
+ * Unconditionally applies default admin settings in main config table
+ * @param array $defaults array of string values
+ */
+function apply_default_exception_settings($defaults) {
+ foreach($defaults as $key => $value) {
+ set_config($key, $value, NULL);
+ }
}
-function format_admin_setting($name, $title='', $form='', $description='', $label=true) {
+/**
+ * Format admin settings
+ * @param string $object setting
+ * @param string $title label element
+ * @param string $form form fragment, html code
+ * @param string $description
+ * @param bool $label link label to id
+ */
+function format_admin_setting($setting, $title='', $form='', $description='', $label=true) {
+ global $CFG;
+
+ $name = $setting->name;
+ $fullname = $setting->get_full_name();
// sometimes the id is not id_s_name, but id_s_name_m or something, and this does not validate
if ($label) {
- $labelfor = 'for = "id_s_'.$name.'"';
+ $labelfor = 'for = "'.$setting->get_id().'"';
} else {
$labelfor = '';
}
- $str = "\n".
- '<div class="form-item" id="admin-'.$name.'">'."\n".
- '<label '.$labelfor.'>'.$title."\n".
- ' <span class="form-shortname">'.$name.'</span>'."\n".
- '</label>'."\n".
- $form."\n".
- '<div class="description">'.$description.'</div>'."\n".
- '</div>'.
- "\n\n";
+ if (empty($setting->plugin) and array_key_exists($name, $CFG->config_php_settings)) {
+ $override = '<span class="form-overridden">'.get_string('configoverride', 'admin').'</span>';
+ } else {
+ $override = '';
+ }
+
+ $str = '
+<div class="form-item" id="admin-'.$setting->name.'">
+<div class="form-label"><label '.$labelfor.'>'.$title.'<span class="form-shortname">'.$name.'</span>'.$override.'</label></div>
+<div class="form-setting">'.$form.'</div>
+<div class="form-description">'.$description.'</div>
+</div>';
+
+ $adminroot =& admin_get_root();
+ if (array_key_exists($fullname, $adminroot->errors)) {
+ $str = '<fieldset class="error"><legend>'.$adminroot->errors[$fullname]->error.'</legend>'.$str.'</fieldset>';
+ }
return $str;
}
-/*
+/**
* Try to upgrade the given language pack (or current language)
* If it doesn't work, fail silently and return false
*/
* Based on find_new_settings{@link ()} in upgradesettings.php
* Looks to find any admin settings that have not been initialized. Returns 1 if it finds any.
*
- * @param string &$node The node at which to start searching.
- * @return int Returns 1 if any settings haven't been initialised, 0 if they all have
+ * @param string $node The node at which to start searching.
+ * @return boolen true if any settings haven't been initialised, false if they all have
*/
-function any_new_admin_settings(&$node) {
+function any_new_admin_settings($node) {
if (is_a($node, 'admin_category')) {
$entries = array_keys($node->children);
foreach ($entries as $entry) {
- if( any_new_admin_settings($node->children[$entry]) ){
- return 1;
+ if (any_new_admin_settings($node->children[$entry])){
+ return true;
}
}
- }
- if (is_a($node, 'admin_settingpage')) {
+ } else if (is_a($node, 'admin_settingpage')) {
foreach ($node->settings as $setting) {
if ($setting->get_setting() === NULL) {
- return 1;
+ return true;
}
}
}
-
- return 0;
-
+ return false;
}
/**
* Moved from admin/replace.php so that we can use this in cron
- * @param string $search - string to look for
- * @param string $replace - string to replace
+ * @param string $search - string to look for (with magic quotes)
+ * @param string $replace - string to replace (with magic quotes)
* @return bool - success or fail
*/
function db_replace($search, $replace) {
-
+
global $db, $CFG;
-
+
/// Turn off time limits, sometimes upgrades can be slow.
@set_time_limit(0);
@ob_implicit_flush(true);
while(@ob_end_flush());
-
+
if (!$tables = $db->Metatables() ) { // No tables yet at all.
return false;
}
foreach ($tables as $table) {
-
+
if (in_array($table, array($CFG->prefix.'config'))) { // Don't process these
continue;
}
-
+
if ($columns = $db->MetaColumns($table, false)) {
foreach ($columns as $column => $data) {
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
}
}
}
-
+
return true;
}
global $CFG;
if (empty($plugin)) {
- $CFG->$name = $value; // So it's defined for this invocation at least
+ if (!array_key_exists($name, $CFG->config_php_settings)) {
+ // So it's defined for this invocation at least
+ if (is_null($value)) {
+ unset($CFG->$name);
+ } else {
+ $CFG->$name = $value;
+ }
+ }
if (get_field('config', 'name', 'name', $name)) {
if ($value===null) {
- unset($CFG->$name);
return delete_records('config', 'name', $name);
} else {
return set_field('config', 'value', addslashes($value), 'name', $name);
foreach ($configs as $config) {
if (!isset($localcfg[$config->name])) {
$localcfg[$config->name] = $config->value;
- } else {
- if ($localcfg[$config->name] != $config->value ) {
- // complain if the DB has a different
- // value than config.php does
- error_log("\$CFG->{$config->name} in config.php ({$localcfg[$config->name]}) overrides database setting ({$config->value})");
- }
}
+ // do not complain anymore if config.php overrides settings from db
}
$localcfg = (object)$localcfg;
die;
}
+/// store settings from config.php in array in $CFG - we can use it later to detect problems and overrides
+ $CFG->config_php_settings = (array)$CFG;
+
/// Set httpswwwroot default value (this variable will replace $CFG->wwwroot
/// inside some URLs used in HTTPSPAGEREQUIRED pages.
$CFG->httpswwwroot = $CFG->wwwroot;
+++ /dev/null
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-<tr valign="top">
- <td align="right">assignment_maxbytes:</td>
- <td><?php
- $choices = get_max_upload_sizes($CFG->maxbytes);
- choose_from_menu ($choices, "assignment_maxbytes", $CFG->assignment_maxbytes, "");
- ?>
- </td>
- <td>
- <?php print_string("configmaxbytes", "assignment") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">assignment_itemstocount:</td>
- <td><?php
- unset($options);
- $options[ASSIGNMENT_COUNT_WORDS] = trim(get_string('numwords', ''));
- $options[ASSIGNMENT_COUNT_LETTERS] = trim(get_string('numletters', ''));
- choose_from_menu ($options, 'assignment_itemstocount', $CFG->assignment_itemstocount, "");
- ?>
- </td>
- <td>
- <?php print_string("configitemstocount", "assignment") ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-</div>
-</form>
DEFINE ('ASSIGNMENT_COUNT_WORDS', 1);
DEFINE ('ASSIGNMENT_COUNT_LETTERS', 2);
-if (!isset($CFG->assignment_maxbytes)) {
- set_config("assignment_maxbytes", 1024000); // Default maximum size for all assignments
-}
-if (!isset($CFG->assignment_itemstocount)) {
- set_config("assignment_itemstocount", ASSIGNMENT_COUNT_WORDS); // Default item to count
-}
-
/**
* Standard base class for all assignment submodules (assignment types).
*/
--- /dev/null
+<?php //$Id$
+
+require_once($CFG->dirroot.'/mod/assignment/lib.php');
+
+$settings->add(new admin_setting_configselect('assignment_maxbytes', get_string('maximumsize', 'assignment'),
+ get_string('configmaxbytes', 'assignment'), 1048576, get_max_upload_sizes($CFG->maxbytes)));
+
+$options = array(ASSIGNMENT_COUNT_WORDS => trim(get_string('numwords', '')),
+ ASSIGNMENT_COUNT_LETTERS => trim(get_string('numletters', '')));
+$settings->add(new admin_setting_configselect('assignment_itemstocount', get_string('itemstocount', 'assignment'),
+ get_string('configitemstocount', 'assignment'), ASSIGNMENT_COUNT_WORDS, $options));
+
+?>
+++ /dev/null
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-
-<tr>
- <td colspan="3" align="center">
- <div><b><?php print_string('generalconfig', 'chat')?></b></div>
- <div style="font-size: 0.8em;">(<?php print_string('explaingeneralconfig', 'chat')?>)</div>
- </td>
-</tr>
-
-
-<tr valign="top">
- <td align="right">chat_method:</td>
- <td>
- <?php
- unset($options);
- $options['header_js'] = get_string('methodnormal', 'chat');
- $options['sockets'] = get_string('methoddaemon', 'chat');
- choose_from_menu ($options, "chat_method", $CFG->chat_method, "", "", "");
- ?>
- </td>
- <td>
- <?php print_string("configmethod", "chat") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">chat_refresh_userlist:</td>
- <td>
- <input name="chat_refresh_userlist" type="text" size="5" value="<?php p($CFG->chat_refresh_userlist) ?>" />
- </td>
- <td>
- <?php print_string("configrefreshuserlist", "chat") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">chat_old_ping:</td>
- <td>
- <input name="chat_old_ping" type="text" size="5" value="<?php p($CFG->chat_old_ping) ?>" />
- </td>
- <td>
- <?php print_string("configoldping", "chat") ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center"><hr />
- <div><b><?php print_string('methodnormal', 'chat')?></b></div>
- <div style="font-size: 0.8em;">(<?php print_string('explainmethodnormal', 'chat')?>)</div>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">chat_refresh_room:</td>
- <td>
- <input name="chat_refresh_room" type="text" size="5" value="<?php p($CFG->chat_refresh_room) ?>" />
- </td>
- <td>
- <?php print_string("configrefreshroom", "chat") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">chat_normal_updatemode:</td>
- <td>
-<?php
- unset($options);
- $options['jsupdate'] = get_string('normalkeepalive', 'chat');
- $options['jsupdated'] = get_string('normalstream', 'chat');
- choose_from_menu ($options, "chat_normal_updatemode", $CFG->chat_normal_updatemode, "", "", "");
-?>
- </td>
- <td>
- <?php print_string("confignormalupdatemode", "chat") ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center"><hr />
- <div><b><?php print_string('methoddaemon', 'chat')?></b></div>
- <div style="font-size: 0.8em;">(<?php print_string('explainmethoddaemon', 'chat')?>)</div>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">chat_serverhost:</td>
- <td>
- <input name="chat_serverhost" type="text" size="20" value="<?php p($CFG->chat_serverhost) ?>" />
- </td>
- <td>
- <?php print_string("configserverhost", "chat") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">chat_serverip:</td>
- <td>
- <input name="chat_serverip" type="text" size="16" value="<?php p($CFG->chat_serverip) ?>" />
- </td>
- <td>
- <?php print_string("configserverip", "chat") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">chat_serverport:</td>
- <td>
- <input name="chat_serverport" type="text" size="5" value="<?php p($CFG->chat_serverport) ?>" />
- </td>
- <td>
- <?php print_string("configserverport", "chat") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">chat_servermax:</td>
- <td>
- <input name="chat_servermax" type="text" size="5" value="<?php p($CFG->chat_servermax) ?>" />
- </td>
- <td>
- <?php print_string("configservermax", "chat") ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-</div>
-</form>
<?php // $Id$
/// Library of functions and constants for module chat
-
require_once($CFG->libdir.'/pagelib.php');
-if (!isset($CFG->chat_refresh_room)) {
- set_config("chat_refresh_room", 5);
-}
-if (!isset($CFG->chat_refresh_userlist)) {
- set_config("chat_refresh_userlist", 10);
-}
-if (!isset($CFG->chat_old_ping)) {
- set_config("chat_old_ping", 35);
-}
-if (!isset($CFG->chat_method)) {
- set_config("chat_method", "header_js");
-}
-if (!isset($CFG->chat_normal_updatemode)) {
- set_config("chat_normal_updatemode", 'jsupdate');
-}
-if (!isset($CFG->chat_serverhost)) {
- set_config("chat_serverhost", $_SERVER['HTTP_HOST']);
-}
-if (!isset($CFG->chat_serverip)) {
- set_config("chat_serverip", '127.0.0.1');
-}
-if (!isset($CFG->chat_serverport)) {
- set_config("chat_serverport", 9111);
-}
-if (!isset($CFG->chat_servermax)) {
- set_config("chat_servermax", 100);
-}
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body bgcolor=\"#FFFFFF\">\n\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n<!-- nix -->\n";
$result = rs_fetch_record($rs);
- rs_close($rs);
+ rs_close($rs);
return $result;
}
--- /dev/null
+<?php //$Id$
+
+$settings->add(new admin_setting_heading('chat_method_heading', get_string('generalconfig', 'chat'),
+ get_string('explaingeneralconfig', 'chat')));
+
+$options = array();
+$options['header_js'] = get_string('methodnormal', 'chat');
+$options['sockets'] = get_string('methoddaemon', 'chat');
+$settings->add(new admin_setting_configselect('chat_method', get_string('method', 'chat'),
+ get_string('configmethod', 'chat'), 'header_js', $options));
+
+$settings->add(new admin_setting_configtext('chat_refresh_userlist', get_string('refreshuserlist', 'chat'),
+ get_string('configrefreshuserlist', 'chat'), 10, PARAM_INT));
+
+$settings->add(new admin_setting_configtext('chat_old_ping', get_string('oldping', 'chat'),
+ get_string('configoldping', 'chat'), 35, PARAM_INT));
+
+
+$settings->add(new admin_setting_heading('chat_normal_heading', get_string('methodnormal', 'chat'),
+ get_string('explainmethodnormal', 'chat')));
+
+$settings->add(new admin_setting_configtext('chat_refresh_room', get_string('refreshroom', 'chat'),
+ get_string('configrefreshroom', 'chat'), 5, PARAM_INT));
+
+$options = array();
+$options['jsupdate'] = get_string('normalkeepalive', 'chat');
+$options['jsupdated'] = get_string('normalstream', 'chat');
+$settings->add(new admin_setting_configselect('chat_normal_updatemode', get_string('updatemethod', 'chat'),
+ get_string('confignormalupdatemode', 'chat'), 'jsupdate', $options));
+
+
+$settings->add(new admin_setting_heading('chat_daemon_heading', get_string('methoddaemon', 'chat'),
+ get_string('explainmethoddaemon', 'chat')));
+
+$settings->add(new admin_setting_configtext('chat_serverhost', get_string('serverhost', 'chat'),
+ get_string('configserverhost', 'chat'), $_SERVER['HTTP_HOST']));
+
+$settings->add(new admin_setting_configtext('chat_serverip', get_string('serverip', 'chat'),
+ get_string('configserverip', 'chat'), '127.0.0.1'));
+
+$settings->add(new admin_setting_configtext('chat_serverport', get_string('serverport', 'chat'),
+ get_string('configserverport', 'chat'), 9111, PARAM_INT));
+
+$settings->add(new admin_setting_configtext('chat_servermax', get_string('servermax', 'chat'),
+ get_string('configservermax', 'chat'), 100, PARAM_INT));
+
+?>
+++ /dev/null
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-
-<tr valign="top">
- <td align="right">data_enablerssfeeds:</td>
- <td>
- <?php
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- echo get_string('rssglobaldisabled', 'data');
- } else {
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
-
- $data_enablerssfeeds = false;
- if (isset($CFG->data_enablerssfeeds) && $CFG->data_enablerssfeeds == 1) {
- $data_enablerssfeeds = true;
- }
-
-
- choose_from_menu ($options, "data_enablerssfeeds", $data_enablerssfeeds, "", "", "");
- }
- ?>
- </td>
- <td>
- <?php
- print_string("configenablerssfeeds","data");
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- print_string("configenablerssfeedsdisabled");
- }
- ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-</div>
-</form>
--- /dev/null
+<?php //$Id$
+
+if (empty($CFG->enablerssfeeds)) {
+ $options = array(0 => get_string('rssglobaldisabled', 'admin'));
+ $str = get_string('configenablerssfeeds', 'data').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin');
+
+} else {
+ $options = array(0=>get_string('no'), 1=>get_string('yes'));
+ $str = get_string('configenablerssfeeds', 'data');
+}
+$settings->add(new admin_setting_configselect('data_enablerssfeeds', get_string('enablerssfeeds', 'admin'),
+ $str, 0, $options));
+
+?>
+++ /dev/null
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-<tr valign="top">
- <td align="right">forum_displaymode:</td>
- <td>
- <?php choose_from_menu ($FORUM_LAYOUT_MODES, "forum_displaymode", $CFG->forum_displaymode, "", "", ""); ?>
- </td>
- <td>
- <?php print_string("configdisplaymode", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_replytouser:</td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
- choose_from_menu ($options, "forum_replytouser", $CFG->forum_replytouser, "", "", "");
- ?>
- </td>
- <td>
- <?php print_string("configreplytouser", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_shortpost:</td>
- <td>
- <input name="forum_shortpost" type="text" size="5" value="<?php p($CFG->forum_shortpost) ?>" />
- </td>
- <td>
- <?php print_string("configshortpost", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_longpost:</td>
- <td>
- <input name="forum_longpost" type="text" size="5" value="<?php p($CFG->forum_longpost) ?>" />
- </td>
- <td>
- <?php print_string("configlongpost", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_manydiscussions:</td>
- <td>
- <input name="forum_manydiscussions" type="text" size="5" value="<?php p($CFG->forum_manydiscussions) ?>" />
- </td>
- <td>
- <?php print_string("configmanydiscussions", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_maxbytes:</td>
- <td><?php
- $choices = get_max_upload_sizes($CFG->maxbytes);
- choose_from_menu ($choices, "forum_maxbytes", $CFG->forum_maxbytes, "");
- ?>
- </td>
- <td>
- <?php print_string("configmaxbytes", "forum") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">forum_trackreadposts:</td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
- choose_from_menu ($options, "forum_trackreadposts", $CFG->forum_trackreadposts, "", "", "");
- ?>
- </td>
- <td>
- <?php print_string("configtrackreadposts", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_oldpostdays:</td>
- <td>
- <input name="forum_oldpostdays" type="text" size="5" value="<?php p($CFG->forum_oldpostdays) ?>" />
- </td>
- <td>
- <?php print_string("configoldpostdays", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_usermarksread:</td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
- choose_from_menu ($options, "forum_usermarksread", $CFG->forum_usermarksread, "", "", "");
- ?>
- </td>
- <td>
- <?php print_string("configusermarksread", "forum") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">forum_cleanreadtime:</td>
- <td>
- <?php
- unset($options);
- $options[0] = '0';
- $options[1] = '1';
- $options[2] = '2';
- $options[3] = '3';
- $options[4] = '4';
- $options[5] = '5';
- $options[6] = '6';
- $options[7] = '7';
- $options[8] = '8';
- $options[9] = '9';
- $options[10] = '10';
- $options[11] = '11';
- $options[12] = '12';
- $options[13] = '13';
- $options[14] = '14';
- $options[15] = '15';
- $options[16] = '16';
- $options[17] = '17';
- $options[18] = '18';
- $options[19] = '19';
- $options[20] = '20';
- $options[21] = '21';
- $options[22] = '22';
- $options[23] = '23';
- choose_from_menu ($options, "forum_cleanreadtime", $CFG->forum_cleanreadtime, "", "", "");
- ?>
- </td>
- <td>
- <?php print_string("configcleanreadtime", "forum") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">forum_enablerssfeeds:</td>
- <td>
- <?php
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- print_string("no");
- } else {
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
-
- $forum_enablerssfeeds = false;
- if (isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds == 1) {
- $forum_enablerssfeeds = true;
- }
-
-
- choose_from_menu ($options, "forum_enablerssfeeds", $forum_enablerssfeeds, "", "", "");
- }
- ?>
- </td>
- <td>
- <?php
- print_string("configenablerssfeeds","forum");
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- print_string("configenablerssfeedsdisabled");
- }
- ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">forum_enabletimedposts:</td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
- choose_from_menu ($options, "forum_enabletimedposts", $CFG->forum_enabletimedposts, "", "", "");
- ?>
- </td>
- <td>
- <?php
- print_string("configenabletimedposts","forum");
- ?>
- </td>
-</tr>
-
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-</div>
-</form>
'1' => get_string('openmode1', 'forum'),
'0' => get_string('openmode0', 'forum') );
-if (!isset($CFG->forum_displaymode)) {
- set_config('forum_displaymode', FORUM_MODE_NESTED);
-}
-
-if (!isset($CFG->forum_shortpost)) {
- set_config('forum_shortpost', 300); // Less non-HTML characters than this is short
-}
-
-if (!isset($CFG->forum_longpost)) {
- set_config('forum_longpost', 600); // More non-HTML characters than this is long
-}
-
-if (!isset($CFG->forum_manydiscussions)) {
- set_config('forum_manydiscussions', 100); // Number of discussions on a page
-}
-
-if (!isset($CFG->forum_maxbytes)) {
- set_config('forum_maxbytes', 512000); // Default maximum size for all forums
-}
-
-if (!isset($CFG->forum_trackreadposts)) {
- set_config('forum_trackreadposts', true); // Default whether user needs to mark a post as read
-}
-
-if (!isset($CFG->forum_oldpostdays)) {
- set_config('forum_oldpostdays', 14); // Default number of days that a post is considered old
-}
-
-if (!isset($CFG->forum_usermarksread)) {
- set_config('forum_usermarksread', false); // Default whether user needs to mark a post as read
-}
-
-if (!isset($CFG->forum_cleanreadtime)) {
- set_config('forum_cleanreadtime', 2); // Default time (hour) to execute 'clean_read_records' cron
-}
-
-if (!isset($CFG->forum_replytouser)) {
- set_config('forum_replytouser', true); // Default maximum size for all forums
-}
-
-if (empty($USER->id) or isguest()) {
- $CFG->forum_trackreadposts = false; // This feature never works when a user isn't logged in
-}
-
-if (!isset($CFG->forum_enabletimedposts)) { // Newish feature that is not quite ready for production in 1.6
- $CFG->forum_enabletimedposts = false;
-}
-
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
--- /dev/null
+<?php //$Id$
+
+require_once($CFG->dirroot.'/mod/forum/lib.php');
+
+global $FORUM_LAYOUT_MODES; // make sure we have the pesky global
+
+$settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'),
+ get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, $FORUM_LAYOUT_MODES));
+
+$settings->add(new admin_setting_configcheckbox('forum_replytouser', get_string('replytouser', 'forum'),
+ get_string('configreplytouser', 'forum'), 1));
+
+// Less non-HTML characters than this is short
+$settings->add(new admin_setting_configtext('forum_shortpost', get_string('shortpost', 'forum'),
+ get_string('configshortpost', 'forum'), 300, PARAM_INT));
+
+// More non-HTML characters than this is long
+$settings->add(new admin_setting_configtext('forum_longpost', get_string('longpost', 'forum'),
+ get_string('configlongpost', 'forum'), 600, PARAM_INT));
+
+// Number of discussions on a page
+$settings->add(new admin_setting_configtext('forum_manydiscussions', get_string('manydiscussions', 'forum'),
+ get_string('configmanydiscussions', 'forum'), 100, PARAM_INT));
+
+$settings->add(new admin_setting_configselect('forum_maxbytes', get_string('maxattachmentsize', 'forum'),
+ get_string('configmaxbytes', 'forum'), 512000, get_max_upload_sizes($CFG->maxbytes)));
+
+// Default whether user needs to mark a post as read
+$settings->add(new admin_setting_configcheckbox('forum_trackreadposts', get_string('trackforum', 'forum'),
+ get_string('configtrackreadposts', 'forum'), 1));
+
+// Default number of days that a post is considered old
+$settings->add(new admin_setting_configtext('forum_oldpostdays', get_string('oldpostdays', 'forum'),
+ get_string('configoldpostdays', 'forum'), 14, PARAM_INT));
+
+// Default whether user needs to mark a post as read
+$settings->add(new admin_setting_configcheckbox('forum_usermarksread', get_string('usermarksread', 'forum'),
+ get_string('configusermarksread', 'forum'), 0));
+
+// Default time (hour) to execute 'clean_read_records' cron
+$options = array();
+for ($i=0; $i<24; $i++) {
+ $options[$i] = $i;
+}
+$settings->add(new admin_setting_configselect('forum_cleanreadtime', get_string('cleanreadtime', 'forum'),
+ get_string('configcleanreadtime', 'forum'), 2, $options));
+
+
+if (empty($CFG->enablerssfeeds)) {
+ $options = array(0 => get_string('rssglobaldisabled', 'admin'));
+ $str = get_string('configenablerssfeeds', 'forum').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin');
+
+} else {
+ $options = array(0=>get_string('no'), 1=>get_string('yes'));
+ $str = get_string('configenablerssfeeds', 'forum');
+}
+$settings->add(new admin_setting_configselect('forum_enablerssfeeds', get_string('enablerssfeeds', 'admin'),
+ $str, 0, $options));
+
+$settings->add(new admin_setting_configcheckbox('forum_enabletimedposts', get_string('timedposts', 'forum'),
+ get_string('configenabletimedposts', 'forum'), 0));
+
+?>
+++ /dev/null
-<?php
- $yes = get_string("yes");
- $no = get_string("no");
-?>
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-<tr valign="top">
- <td colspan="3" align="center"><strong><?php print_string("glossaryleveldefaultsettings","glossary") ?></strong></td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_entbypage:</td>
- <td>
- <input name="glossary_entbypage" type="text" size="3" value="<?php p(isset($CFG->glossary_entbypage) ? $CFG->glossary_entbypage : 10) ?>" />
- </td>
- <td>
- <?php print_string("entbypage", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_dupentries:</td>
- <td>
- <select size="1" name="glossary_dupentries">
-<?php
- $yselected = "";
- $nselected = "";
- if ($CFG->glossary_dupentries) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnfallowdupentries", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_allowcomments:</td>
- <td>
- <select size="1" name="glossary_allowcomments">
-<?php
- $yselected = "";
- $nselected = "";
- if ($CFG->glossary_allowcomments) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnfallowcomments", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_linkbydefault:</td>
- <td>
- <select size="1" name="glossary_linkbydefault">
-<?php
- $yselected = "";
- $nselected = "";
- if ($CFG->glossary_linkbydefault) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnflinkglossaries", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_defaultapproval:</td>
- <td>
- <select size="1" name="glossary_defaultapproval">
-<?php
- $yselected = "";
- $nselected = "";
- if ($CFG->glossary_defaultapproval) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnfapprovalstatus", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_enablerssfeeds:</td>
- <td>
- <?php
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- print_string("no");
- } else {
- unset($options);
- $options[0] = get_string("no");
- $options[1] = get_string("yes");
-
- $glossary_enablerssfeeds = false;
- if (isset($CFG->glossary_enablerssfeeds) && $CFG->glossary_enablerssfeeds == 1) {
- $glossary_enablerssfeeds = true;
- }
-
- choose_from_menu ($options, "glossary_enablerssfeeds", $glossary_enablerssfeeds, "", "", "");
- }
- ?>
- </td>
- <td>
- <?php
- print_string("configenablerssfeeds","glossary");
- if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
- print_string("configenablerssfeedsdisabled");
- }
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td colspan ="3" align="center"><strong><?php print_string("entryleveldefaultsettings","glossary") ?></strong></td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_linkentries:</td>
- <td>
- <select size="1" name="glossary_linkentries">
-<?php
- $yselected = "";
- $nselected = "";
- if (isset($CFG->glossary_linkentries) && $CFG->glossary_linkentries) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnflinkentry", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_casesensitive:</td>
- <td>
- <select size="1" name="glossary_casesensitive">
-<?php
- $yselected = "";
- $nselected = "";
- if (isset($CFG->glossary_casesensitive) && $CFG->glossary_casesensitive) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnfcasesensitive", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">glossary_fullmatch:</td>
- <td>
- <select size="1" name="glossary_fullmatch">
-<?php
- $yselected = "";
- $nselected = "";
- if (isset($CFG->glossary_fullmatch) && $CFG->glossary_fullmatch) {
- $yselected = " selected=\"selected\" ";
- } else {
- $nselected = " selected=\"selected\" ";
- }
-?>
- <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
- <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
- </select>
- </td>
- <td>
- <?php print_string("cnffullmatch", "glossary") ?>
- </td>
-</tr>
-<tr valign="top">
- <td colspan ="3" align="center"><a name="formats"><strong><?php print_string("displayformatssetup","glossary") ?></strong></a></td>
-</tr>
-<tr>
- <td colspan="3" align="center">
-<?php
-
- //Update and get available formats
- $recformats = glossary_get_available_formats();
-
- $formats = array();
-
- //Take names
- foreach ($recformats as $format) {
- $formats[$format->id] = get_string("displayformat$format->name", "glossary");
- }
- asort($formats);
-
- print_simple_box_start('center');
- foreach ($formats as $formatid=>$formatname) {
- $recformat = get_record('glossary_formats','id',$formatid);
- echo '<tr>';
- echo '<td>' . $formatname . '</td>';
- $eicon = "<a title=\"" . get_string("edit") . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\"><img class=\"iconsmall\" src=\"../pix/t/edit.gif\" alt=\"".get_string("edit")."\" /></a>";
- if ( $recformat->visible ) {
- $vtitle = get_string("hide");
- $vicon = "hide.gif";
- } else {
- $vtitle = get_string("show");
- $vicon = "show.gif";
- }
- $vicon = "<a title=\"" . $vtitle . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\"><img class=\"iconsmall\" src=\"../pix/t/" . $vicon . "\" alt=\"$vtitle\" /></a>";
-
- echo '<td align="center">' . $eicon . ' ' . $vicon . '</td>';
- echo '</tr>';
- }
- print_simple_box_end();
-
-?>
-
- </td>
-</tr>
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-</div>
-</form>
/// This file allows to manage the default behaviour of the display formats
require_once("../../config.php");
+ require_once($CFG->libdir.'/adminlib.php');
require_once("lib.php");
- global $CFG;
- $id = required_param('id', PARAM_INT);
+ $id = required_param('id', PARAM_INT);
$mode = optional_param('mode');
- require_login();
- require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
-
- if (!$site = get_site()) {
- error("Site isn't defined!");
- }
+ admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
if ( !$displayformat = get_record("glossary_formats","id",$id) ) {
error ("Invalid Glossary Format");
}
update_record("glossary_formats",$displayformat);
}
- redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
+ redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
die;
} elseif ( $mode == 'edit' and $form) {
$displayformat->sortorder = $form->sortorder;
update_record("glossary_formats",$displayformat);
- redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
+ redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
die;
}
- $stradmin = get_string("administration");
- $strconfiguration = get_string("configuration");
- $strmanagemodules = get_string("managemodules");
$strmodulename = get_string("modulename", "glossary");
$strdisplayformats = get_string("displayformats","glossary");
- $navlinks = array();
- $navlinks[] = array('name' => $stradmin, 'link' => "../../$CFG->admin/index.php", 'type' => 'core');
- $navlinks[] = array('name' => $strconfiguration, 'link' => "../../$CFG->admin/configure.php", 'type' => 'core');
- $navlinks[] = array('name' => $strmanagemodules, 'link' => "../../$CFG->admin/modules.php", 'type' => 'core');
- $navlinks[] = array('name' => $strmodulename, 'link' => "../../$CFG->admin/module.php?module=glossary&sesskey=$USER->sesskey", 'type' => 'core');
- $navlinks[] = array('name' => $strdisplayformats, 'link' => '', 'type' => 'core');
-
- $navigation = build_navigation($navlinks);
-
- print_header("$strmodulename: $strconfiguration", $site->fullname, $navigation);
+ admin_externalpage_print_header();
print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
define("GLOSSARY_EXPORT_VIEW", 6);
define("GLOSSARY_APPROVAL_VIEW", 7);
-//Check for global configure default variables
-
-if (!isset($CFG->glossary_studentspost)) {
- set_config("glossary_studentspost", 1); // Students can post entries.
-}
-
-if (!isset($CFG->glossary_dupentries)) {
- set_config("glossary_dupentries", 0); // Duplicate entries are not allowed.
-}
-
-if (!isset($CFG->glossary_allowcomments)) {
- set_config("glossary_allowcomments", 0); // Comments are not allowed.
-}
-
-if (!isset($CFG->glossary_linkbydefault)) {
- set_config("glossary_linkbydefault", 1); // Linking entries is enabled.
-}
-
-if (!isset($CFG->glossary_defaultapproval)) {
- set_config("glossary_defaultapproval", 1); // Entries are approved.
-}
-
-if (!isset($CFG->glossary_entbypage)) {
- set_config("glossary_entbypage", 10); // 10 entries are showed.
-}
-
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
function glossary_add_instance($glossary) {
--- /dev/null
+<?php //$Id$
+
+require_once($CFG->dirroot.'/mod/glossary/lib.php');
+
+$settings->add(new admin_setting_heading('glossary_normal_header', get_string('glossaryleveldefaultsettings', 'glossary'), ''));
+
+$settings->add(new admin_setting_configtext('glossary_entbypage', get_string('entbypage', 'glossary'),
+ get_string('entbypage', 'glossary'), 10, PARAM_INT));
+
+
+$settings->add(new admin_setting_configcheckbox('glossary_dupentries', get_string('allowduplicatedentries', 'glossary'),
+ get_string('cnfallowdupentries', 'glossary'), 0));
+
+$settings->add(new admin_setting_configcheckbox('glossary_allowcomments', get_string('allowcomments', 'glossary'),
+ get_string('cnfallowcomments', 'glossary'), 0));
+
+$settings->add(new admin_setting_configcheckbox('glossary_linkbydefault', get_string('usedynalink', 'glossary'),
+ get_string('cnflinkglossaries', 'glossary'), 1));
+
+$settings->add(new admin_setting_configcheckbox('glossary_defaultapproval', get_string('defaultapproval', 'glossary'),
+ get_string('cnfapprovalstatus', 'glossary'), 1));
+
+
+if (empty($CFG->enablerssfeeds)) {
+ $options = array(0 => get_string('rssglobaldisabled', 'admin'));
+ $str = get_string('configenablerssfeeds', 'glossary').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin');
+
+} else {
+ $options = array(0=>get_string('no'), 1=>get_string('yes'));
+ $str = get_string('configenablerssfeeds', 'glossary');
+}
+$settings->add(new admin_setting_configselect('glossary_enablerssfeeds', get_string('enablerssfeeds', 'admin'),
+ $str, 0, $options));
+
+
+$settings->add(new admin_setting_heading('glossary_levdev_header', get_string('entryleveldefaultsettings', 'glossary'), ''));
+
+$settings->add(new admin_setting_configcheckbox('glossary_linkentries', get_string('usedynalink', 'glossary'),
+ get_string('cnflinkentry', 'glossary'), 0));
+
+$settings->add(new admin_setting_configcheckbox('glossary_casesensitive', get_string('casesensitive', 'glossary'),
+ get_string('cnfcasesensitive', 'glossary'), 0));
+
+$settings->add(new admin_setting_configcheckbox('glossary_fullmatch', get_string('fullmatch', 'glossary'),
+ get_string('cnffullmatch', 'glossary'), 0));
+
+
+//Update and get available formats
+$recformats = glossary_get_available_formats();
+$formats = array();
+//Take names
+foreach ($recformats as $format) {
+ $formats[$format->id] = get_string("displayformat$format->name", "glossary");
+}
+asort($formats);
+
+$str = '<table>';
+foreach ($formats as $formatid=>$formatname) {
+ $recformat = get_record('glossary_formats','id',$formatid);
+ $str .= '<tr>';
+ $str .= '<td>' . $formatname . '</td>';
+ $eicon = "<a title=\"".get_string("edit")."\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\"><img class=\"iconsmall\" src=\"../pix/t/edit.gif\" alt=\"".get_string("edit")."\" /></a>";
+ if ( $recformat->visible ) {
+ $vtitle = get_string("hide");
+ $vicon = "hide.gif";
+ } else {
+ $vtitle = get_string("show");
+ $vicon = "show.gif";
+ }
+ $vicon = "<a title=\"".$vtitle."\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\"><img class=\"iconsmall\" src=\"../pix/t/".$vicon."\" alt=\"$vtitle\" /></a>";
+
+ $str .= '<td align="center">'.$eicon.' '.$vicon.'</td>';
+ $str .= '</tr>';
+}
+$str .= '</table>';
+
+$settings->add(new admin_setting_heading('glossary_formats_header', get_string('displayformatssetup', 'glossary'), $str));
+
function hotpot_mediaplayer_moodle(&$hotpot, $text) {
global $CFG, $THEME;
- include $CFG->dirroot.'/filter/mediaplugin/defaultsettings.php';
-
if ($CFG->filter_mediaplugin_enable_mp3) {
static $c;
$replace = '\\0<p class="mediaplugin wmv"><object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
$replace .= ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
- $replace .= ' standby="Loading Microsoft® Windows® Media Player components..." ';
+ $replace .= ' standby="Loading Microsoft� Windows� Media Player components..." ';
$replace .= ' id="msplayer" type="application/x-oleobject">';
$replace .= "<param name=\"Filename\" value=\"\\2.wmv\" />";
$replace .= '<param name="ShowControls" value="true" />';
+++ /dev/null
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-</div>
-
-<table cellpadding="9" cellspacing="0" >
-<tr valign="top">
- <td align="right">resource_framesize:</td>
- <td>
- <input name="resource_framesize" type="text" size="5" value="<?php p($CFG->resource_framesize) ?>" />
- </td>
- <td>
- <?php print_string("configframesize", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_websearch:</td>
- <td>
- <input name="resource_websearch" type="text" size="30" value="<?php p($CFG->resource_websearch) ?>" />
- </td>
- <td>
- <?php print_string("configwebsearch", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_defaulturl:</td>
- <td>
- <input name="resource_defaulturl" type="text" size="30" value="<?php p($CFG->resource_defaulturl) ?>" />
- </td>
- <td>
- <?php print_string("configdefaulturl", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_secretphrase:</td>
- <td>
- <input name="resource_secretphrase" type="text" size="30" value="<?php p($CFG->resource_secretphrase) ?>" />
- </td>
- <td>
- <?php print_string("configsecretphrase", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_allowlocalfiles:</td>
- <td>
- <?php
- unset($choices);
- $choices["0"] = get_string("no");
- $choices["1"] = get_string("yes");
- choose_from_menu ($choices, "resource_allowlocalfiles", $CFG->resource_allowlocalfiles, "");
- ?>
- </td>
- <td>
- <?php print_string("configallowlocalfiles", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_popup:</td>
- <td>
- <?php
- unset($choices);
- $choices[""] = get_string("no");
- $choices["checked"] = get_string("yes");
- choose_from_menu ($choices, "resource_popup", $CFG->resource_popup, "");
- ?>
- </td>
- <td>
- <?php print_string("configpopup", "resource") ?>
- </td>
-</tr>
-<?php foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
- $defaultvalue = "resource_popup$optionname";
- echo "<tr valign=\"top\">";
- echo "<td align=\"right\">$defaultvalue:</td>";
- echo "<td>";
- if ($optionname == "height" or $optionname == "width") {
- echo "<input name=\"$defaultvalue\" type=\"text\" size=\"5\" value=\"".$CFG->$defaultvalue."\" />";
- } else {
- choose_from_menu ($choices, $defaultvalue, $CFG->$defaultvalue, "");
- }
- echo "</td>";
- echo "<td>";
- print_string("configpopup$optionname", "resource");
- echo "</td>";
- echo "</tr>";
- }
-?>
-<tr valign="top">
- <td align="right">resource_autofilerename:</td>
- <td>
- <?php
- unset($choices);
- $choices["0"] = get_string("no");
- $choices["1"] = get_string("yes");
- choose_from_menu ($choices, "resource_autofilerename", $CFG->resource_autofilerename, "");
- ?>
- </td>
- <td>
- <?php print_string("configautofilerenamesettings", "resource") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">resource_blockdeletingfile:</td>
- <td>
- <?php
- unset($choices);
- $choices["0"] = get_string("no");
- $choices["1"] = get_string("yes");
- choose_from_menu ($choices, "resource_blockdeletingfile", $CFG->resource_blockdeletingfile, "");
- ?>
- </td>
- <td>
- <?php print_string("configblockdeletingfilesettings", "resource") ?>
- </td>
-</tr>
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-</table>
-
-</form>
<?php // $Id$
-if (!isset($CFG->resource_framesize)) {
- set_config("resource_framesize", 130);
-}
-
-if (!isset($CFG->resource_websearch)) {
- set_config("resource_websearch", "http://google.com/");
-}
-
-if (!isset($CFG->resource_defaulturl)) {
- set_config("resource_defaulturl", "http://");
-}
-
-if (!isset($CFG->resource_filterexternalpages)) {
- set_config("resource_filterexternalpages", false);
-}
-
-if (!isset($CFG->resource_secretphrase)) {
- set_config("resource_secretphrase", random_string(20));
-}
-
-if (!isset($CFG->resource_popup)) {
- set_config("resource_popup", "");
-}
-
-if (!isset($CFG->resource_windowsettings)) {
- set_config("resource_windowsettings", "0");
-}
-
-if (!isset($CFG->resource_parametersettings)) {
- set_config("resource_parametersettings", "0");
-}
-
-if (!isset($CFG->resource_allowlocalfiles)) {
- set_config("resource_allowlocalfiles", "0");
-}
-
-if (!isset($CFG->resource_hide_repository)) {
- set_config("resource_hide_repository", "1");
-}
-
-if (!isset($CFG->resource_autofilerename)) {
- set_config("resource_autofilerename", "1");
-}
-
-if (!isset($CFG->resource_blockdeletingfile)) {
- set_config("resource_blockdeletingfile", "1");
-}
-
define('RESOURCE_LOCALPATH', 'LOCALPATH');
+global $RESOURCE_WINDOW_OPTIONS; // must be global because it might be included from a function!
$RESOURCE_WINDOW_OPTIONS = array('resizable', 'scrollbars', 'directories', 'location',
'menubar', 'toolbar', 'status', 'width', 'height');
-foreach ($RESOURCE_WINDOW_OPTIONS as $popupoption) {
- $popupoption = "resource_popup$popupoption";
- if (!isset($CFG->$popupoption)) {
- if ($popupoption == 'resource_popupheight') {
- set_config($popupoption, 450);
- } else if ($popupoption == 'resource_popupwidth') {
- set_config($popupoption, 620);
- } else {
- set_config($popupoption, 'checked');
- }
- }
+if (!isset($CFG->resource_hide_repository)) {
+ set_config("resource_hide_repository", "1");
}
/**
--- /dev/null
+<?php //$Id$
+
+require_once($CFG->dirroot.'/mod/resource/lib.php');
+
+global $RESOURCE_WINDOW_OPTIONS; // make sure we have the pesky global
+
+$checkedyesno = array(''=>get_string('no'), 'checked'=>get_string('yes')); // not nice at all
+
+$settings->add(new admin_setting_configtext('resource_framesize', get_string('framesize', 'resource'),
+ get_string('configframesize', 'resource'), 130, PARAM_INT));
+
+$settings->add(new admin_setting_configtext('resource_websearch', get_string('websearchdefault', 'resource'),
+ get_string('configwebsearch', 'resource'), 'http://google.com/'));
+
+$settings->add(new admin_setting_configtext('resource_defaulturl', get_string('resourcedefaulturl', 'resource'),
+ get_string('configdefaulturl', 'resource'), 'http://'));
+
+$settings->add(new admin_setting_configpasswordunmask('resource_secretphrase', get_string('password'),
+ get_string('configsecretphrase', 'resource'), random_string(20)));
+
+$settings->add(new admin_setting_configcheckbox('resource_allowlocalfiles', get_string('allowlocalfiles', 'resource'),
+ get_string('configallowlocalfiles', 'resource'), 0));
+
+$woptions = array(0 => get_string('pagewindow', 'resource'), 1 => get_string('newwindow', 'resource'));
+$settings->add(new admin_setting_configselect('resource_popup', get_string('display', 'resource'),
+ get_string('configpopup', 'resource'), 0, $woptions));
+
+foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
+ $popupoption = "resource_popup$optionname";
+ if ($popupoption == 'resource_popupheight') {
+ $settings->add(new admin_setting_configtext('resource_popupheight', get_string('newheight', 'resource'),
+ get_string('configpopupheight', 'resource'), 450, PARAM_INT));
+ } else if ($popupoption == 'resource_popupwidth') {
+ $settings->add(new admin_setting_configtext('resource_popupwidth', get_string('newwidth', 'resource'),
+ get_string('configpopupwidth', 'resource'), 620, PARAM_INT));
+ } else {
+ $settings->add(new admin_setting_configselect($popupoption, get_string('new'.$optionname, 'resource'),
+ get_string('configpopup'.$optionname, 'resource'), 'checked', $checkedyesno));
+ }
+}
+
+$settings->add(new admin_setting_configcheckbox('resource_autofilerename', get_string('autofilerename', 'resource'),
+ get_string('configautofilerenamesettings', 'resource'), 1));
+
+$settings->add(new admin_setting_configcheckbox('resource_blockdeletingfile', get_string('blockdeletingfile', 'resource'),
+ get_string('configblockdeletingfilesettings', 'resource'), 1));
+
+?>
+++ /dev/null
-<?php
- if (!isset($CFG->scorm_frameheight)) {
- $CFG->scorm_frameheight = '500';
- }
- if (!isset($CFG->scorm_framewidth)) {
- $CFG->scorm_framewidth = '100%';
- }
-?>
-
-<form method="post" action="module.php" id="form">
-<div>
-<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
-
-<table cellpadding="9" cellspacing="0" >
-<tr valign="top">
- <td align="right">scorm_framewidth:</td>
- <td>
- <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="5" />
- </td>
- <td>
- <?php print_string("framewidth", "scorm") ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right">scorm_frameheight:</td>
- <td>
- <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="5" />
- </td>
- <td>
- <?php print_string("frameheight", "scorm") ?>
- </td>
-</tr>
-<tr>
- <td colspan="3" align="center">
- <input type="submit" value="<?php print_string("savechanges") ?>" />
- </td>
-</tr>
-</table>
-</div>
-</form>
--- /dev/null
+<?php //$Id$
+
+$settings->add(new admin_setting_configtext('scorm_framewidth', get_string('width', 'scorm'),
+ get_string('framewidth', 'scorm'), '100%'));
+
+$settings->add(new admin_setting_configtext('scorm_frameheight', get_string('height', 'scorm'),
+ get_string('frameheight', 'scorm'), 500));
+
+?>
background-color: green;
}
+/* Admin settings */
+
#adminsettings fieldset {
background-color: #EEE;
border-color: #BBB;
color: #000;
}
+#adminsettings fieldset.error {
+ border: 1px solid red;
+}
+
+#adminsettings fieldset.error legend {
+ color: red;
+}
+
#adminsettings .form-shortname {
color: #888;
}
+#adminsettings .form-overridden {
+ background-color: #fbb;
+}
+
+#adminsettings .form-item .defaultinfo {
+ color: #888;
+}
+
+#adminsettings .form-item .pathok {
+ color: green;
+}
+
+#adminsettings .form-item .patherror {
+ color: red;
+}
+
.block_admin_tree.sideblock .link.current {
background-color:#EEEEEE;
}
+.block_admin_tree.sideblock .link.hidden {
+ color:#999999;
+}
+
+
#admin-lang .translator {
border-color: #dddddd;
}
font-size: 0.75em;
}
+#adminsettings .form-item .defaultinfo {
+ font-size: 0.8em;
+}
+
#admin-roles-override .cell.c1,
#admin-roles-assign .cell.c3,
#admin-roles-assign .cell.c1 {
.que .info {
margin-left: 0.6em;
-}
\ No newline at end of file
+}
+
+#adminsettings .form-setting,
+#adminsettings .form-description {
+ display:inline-block; padding-left:2px;
+}
+
+
margin-right:3px;
}
-form#adminsettings div.htmlarea {
- clear: left;
- padding-top: 5px;
-}
-
.mform label .req, .mform label .adv {
cursor: help;
}
margin:20px;
}
-#adminsettings fieldset {
- margin-top: 1em;
- padding: 1em 0.5em;
-}
-
-#adminsettings legend {
- display: none;
+/* Admin settings */
+#adminsettings div.form-item {
+ clear: both;
+ margin: 1em 0 2em 0;
}
-#adminsettings .form-group {
+#adminsettings .form-label {
+ display: block;
float: left;
+ width: 12.5em;
+ text-align: right;
}
-#adminsettings .form-item {
- margin: 0;
+#adminsettings .form-shortname {
+ display: block;
}
-#adminsettings label {
+#adminsettings .form-setting {
display: block;
- float: left;
- width: 150px;
- text-align: right;
+ margin-left: 13em;
+ text-align: left;
}
-#adminsettings .form-shortname {
+#adminsettings .form-description {
display: block;
+ margin: 0.5em 0 0em 13em;
+ text-align: left;
}
-#adminsettings select,
-#adminsettings input {
- float: left;
- margin: 0 0 0 10px;
+#adminsettings span.defaultinfo {
+ margin-left: 0.5em;
}
-#adminsettings textarea {
- float: left;
- margin: 0 0 0 10px;
- width: 65%;
+#adminsettings div.defaultinfo {
+ margin-left: 3px;
}
-#adminsettings .form-group select,
-#adminsettings .form-group input {
- display: inline;
- float: none;
+#adminsettings fieldset {
+ margin-top: 1em;
+ padding: 1em 0.5em;
}
+#adminsettings legend {
+ display: none;
+}
-/* #adminsettings .admin-configtime .form-select {
- display: inline;
- float: none;
+#adminsettings fieldset.error {
+ margin: 0.2em 0 0.5em 0;
+ padding: 0.5em 0 0 0;
}
-#adminsettings div.admin-frontpage div.form-group select.form-select {
- display: inline;
- float: none;
-} */
+#adminsettings fieldset.error legend {
+ display: block;
+}
-#adminsettings .description {
- clear: both;
- margin: 0 1em 0 160px;
- padding: 0.3em 0 1.5em 0;
+#adminsettings .form-multicheckbox li {
+ list-style: none;
}
-#adminsettings .form-item .unmask input {
- margin-left:5px;
- margin-right:3px;
+#adminsettings .form-multicheckbox ul {
+ padding:0;
+ margin:0;
}
-#adminsettings .form-item .unmask label {
- width: auto;
- text-align: left;
+#adminsettings .form-text input {
+ width: 20em;
}
-.environmentbox {
- margin-top: 1em;
+#adminsettings .form-password input[type="text"],
+#adminsettings .form-password input[type="password"] {
+ width: 20em;
}
-.form-buttons {
- margin: 10px 0 0 160px;
+#adminsettings .form-text input.number {
+ width: 5em;
}
-.form-text {
- width: 20em;
+#adminsettings .form-executable input,
+#adminsettings .form-directory input {
+ width: 30em;
}
-.form-textarea { }
-.form-select { }
-.form-checkbox { }
-.form-radio { }
-.form-submit { }
-.form-reset { }
-.admin-frontpagedesc .htmlarea {
- margin: 0 auto 10px auto;
- width : 600px;
+#adminsettings .form-item .pathok,
+#adminsettings .form-item .patherror {
+ margin-left: 0.5em;
+}
+
+
+.environmentbox {
+ margin-top: 1em;
+}
+
+.form-buttons {
+ margin: 10px 0 0 13em;
}
.adminsearchform {
text-align:left;
}
+.block_admin_tree .admintree .depth1 {
+ padding-left: 16px;
+}
+
+.block_admin_tree .admintree .depth2 {
+ padding-left: 32px;
+}
+
+.block_admin_tree .admintree .depth3 {
+ padding-left: 48px;
+}
+
+.block_admin_tree .admintree .depth4 {
+ padding-left: 64px;
+}
+
#admin-lang .translator {
border-width: 1px;
border-style: solid;
}
if (!empty($USER->newadminuser)) {
unset($USER->newadminuser);
- // try to apply defaults again - some of them might depend on admin user info
- $adminroot = admin_get_root();
- apply_default_settings($adminroot, false);
+ // apply defaults again - some of them might depend on admin user info, backup, roles, etc.
+ admin_apply_default_settings(NULL , false);
// redirect to admin/ to continue with installation
redirect("$CFG->wwwroot/$CFG->admin/");
} else {