Skip to content

Commit

Permalink
Admin page cleanup (Google soc 2006)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkmar committed Aug 18, 2006
1 parent a7c72af commit 90a73bb
Show file tree
Hide file tree
Showing 21 changed files with 1,618 additions and 357 deletions.
1,243 changes: 1,243 additions & 0 deletions admin/adminlib.php

Large diffs are not rendered by default.

28 changes: 12 additions & 16 deletions admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@

require_once('../config.php');

$auth = optional_param('auth', '', PARAM_SAFEDIR);
require_once($CFG->dirroot . '/admin/adminlib.php');

require_login();
admin_externalpage_setup('userauthentication');

if (!$site = get_site()) {
redirect("index.php");
}
$auth = optional_param('auth', '', PARAM_SAFEDIR);

if (!isadmin()) {
error("Only the admin can use this page");
}

if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}

$focus = '';

/// If data submitted, then process and store.

if ($config = data_submitted()) {

if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}

$config = (array)$config;

// extract and sanitize the auth key explicitly
Expand Down Expand Up @@ -126,17 +121,18 @@
$strsettings = get_string("settings");
$strusers = get_string("users");

print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strauthenticationoptions", "$focus");
admin_externalpage_print_header();

echo "<center><b>";
echo "<form target=\"{$CFG->framename}\" name=\"authmenu\" method=\"post\" action=\"auth.php\">";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
print_string("chooseauthmethod","auth");

echo '&nbsp;&nbsp;';

choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");

echo "</b></center>";
echo "</b></center><br />";

print_simple_box_start("center", "100%");
print_heading($options[$auth]);
Expand Down Expand Up @@ -235,7 +231,7 @@

print_simple_box_end();

print_footer();
admin_externalpage_print_footer();
exit;

/// Functions /////////////////////////////////////////////////////////////////
Expand Down
19 changes: 5 additions & 14 deletions admin/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
// block.php - allows admin to edit all local configuration variables for a block

require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('blockmanagement');
require_once($CFG->libdir.'/blocklib.php');

require_login();

if (!isadmin()) {
error('Only an admin can use this page');
}
if (!$site = get_site()) {
error("Site isn't defined!");
}

$blockid = required_param('block', PARAM_INT);

if(($blockrecord = blocks_get_record($blockid)) === false) {
Expand Down Expand Up @@ -62,10 +55,8 @@
// of the page. It is also used to generate the link to the Moodle Docs for this view.
$CFG->pagepath = 'block/' . $block->name() . '/config';

print_header($site->shortname.': '.$strblockname.": $strconfiguration", $site->fullname,
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> ".
"<a href=\"blocks.php\">$strmanageblocks</a> -> ".$strblockname);

admin_externalpage_print_header();

print_heading($strblockname);

Expand All @@ -80,6 +71,6 @@
echo '</p>';
$block->config_print();
echo '</form>';
print_footer();
admin_externalpage_print_footer();

?>
20 changes: 5 additions & 15 deletions admin/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Allows the admin to configure blocks (hide/show, delete and configure)

require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('blockmanagement');
require_once($CFG->libdir.'/blocklib.php');
require_once($CFG->libdir.'/tablelib.php');

Expand All @@ -12,16 +14,6 @@
$delete = optional_param('delete', 0, PARAM_INT);
$multiple = optional_param('multiple', 0, PARAM_INT);

require_login();

if (!isadmin()) {
error("Only administrators can use this page!");
}

if (!$site = get_site()) {
error("Site isn't defined!");
}


/// Print headings

Expand All @@ -37,9 +29,7 @@
$strname = get_string('name');
$strmultiple = get_string('blockmultiple', 'admin');

print_header("$site->shortname: $strmanageblocks", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanageblocks");
admin_externalpage_print_header();

print_heading($strmanageblocks);

Expand Down Expand Up @@ -85,7 +75,7 @@
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
'blocks.php?delete='.$block->id.'&amp;confirm=1&amp;sesskey='.$USER->sesskey,
'blocks.php');
print_footer();
admin_externalpage_print_footer();
exit;

} else {
Expand Down Expand Up @@ -241,6 +231,6 @@
$table->print_html();
}

print_footer();
admin_externalpage_print_footer();

?>
26 changes: 9 additions & 17 deletions admin/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,23 @@
// Yes, enrol is correct English spelling.

require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');

$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
$CFG->pagepath = 'enrol';

require_login();
admin_externalpage_setup('enrolment');

if (!$site = get_site()) {
redirect("index.php");
}

if (!isadmin()) {
error("Only the admin can use this page");
}

if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}

require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class

/// Save settings

if ($frm = data_submitted()) {
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if (empty($frm->enable)) {
$frm->enable = array();
}
Expand All @@ -39,16 +33,14 @@
$frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
set_config('enrol_plugins_enabled', implode(',', $frm->enable));
set_config('enrol', $frm->default);
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
redirect("enrol.php", get_string("changessaved"), 1);
}

/// Print the form

$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));

print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
"<a href=\"index.php\">$str->administration</a> ->
<a href=\"users.php\">$str->users</a> -> $str->enrolmentplugins");
admin_externalpage_print_header();

$modules = get_list_of_plugins("enrol");
$options = array();
Expand Down Expand Up @@ -97,7 +89,7 @@
$default = '';
}
$table->data[$name] = array($name, $enable, $default,
'<a href="enrol_config.php?sesskey='.$USER->sesskey.'&amp;enrol='.$module.'">'.$str->edit.'</a>');
'<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>');
}
asort($table->data);

Expand All @@ -106,6 +98,6 @@
echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
echo "</form>";

print_footer();
admin_externalpage_print_footer();

?>
30 changes: 10 additions & 20 deletions admin/enrol_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@
// Yes, enrol is correct English spelling.

require_once("../config.php");
require_once($CFG->dirroot . '/admin/adminlib.php');

admin_externalpage_setup('enrolment');

$enrol = required_param('enrol', PARAM_ALPHA);
$CFG->pagepath = 'enrol/' . $enrol;

require_login();

if (!$site = get_site()) {
redirect("index.php");
}

if (!isadmin()) {
error("Only the admin can use this page");
}

if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}

require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class

Expand All @@ -28,6 +18,9 @@
/// If data submitted, then process and store.

if ($frm = data_submitted()) {
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if ($enrolment->process_config($frm)) {
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
}
Expand All @@ -40,18 +33,15 @@
/// get language strings
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));

unset($options);

$modules = get_list_of_plugins("enrol");
foreach ($modules as $module) {
$options[$module] = get_string("enrolname", "enrol_$module");
}
asort($options);

print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
"<a href=\"index.php\">$str->administration</a> ->
<a href=\"users.php\">$str->users</a> ->
<a href=\"enrol.php?sesskey=$USER->sesskey\">$str->enrolmentplugins</a> ->
$str->configuration");
admin_externalpage_print_header();

echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
Expand All @@ -61,7 +51,7 @@
/// Choose an enrolment method
echo get_string('chooseenrolmethod').': ';
choose_from_menu ($options, "enrol", $enrol, "",
"document.location='enrol_config.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
"document.location='enrol_config.php?enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");

echo "</b></p></div>";

Expand All @@ -82,7 +72,7 @@

print_simple_box_end();

print_footer();
admin_externalpage_print_footer();

exit;
?>
18 changes: 4 additions & 14 deletions admin/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,16 @@
// from moodle.org be able to check more and more versions.

require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/componentlib.class.php');

admin_externalpage_setup('environment');

/// Parameters
$action = optional_param('action', '', PARAM_ACTION);
$version = optional_param('version', '', PARAM_FILE); //

/// Security checks
require_login();

if (!isadmin()) {
error('You need to be admin to use this page');
}

if (!$site = get_site()) {
error("Site isn't defined!");
}

/// Get some strings
$stradmin = get_string('administration');
Expand All @@ -60,9 +52,7 @@
$strmisc = get_string('miscellaneous');

/// Print the header stuff
print_header("$SITE->shortname: $strenvironment", $SITE->fullname,
"<a href=\"index.php\">$stradmin</a> -> <a href=\"misc.php\">$strmisc</a> -> "
.$strenvironment);
admin_externalpage_print_header();

/// Print the component download link
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&amp;sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
Expand Down Expand Up @@ -147,5 +137,5 @@
echo '</div>';

/// Print footer
print_footer();
admin_externalpage_print_footer();
?>
19 changes: 5 additions & 14 deletions admin/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
// Edit text filter settings

require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');

// check for allowed access
require_login();
if (!isadmin()) {
error( 'Only administrators can use the filters administration page' );
}
if (!$site = get_site()) {
error( 'Site is not defined in filters administration page' );
}
admin_externalpage_setup('filtermanagement');

// get parameters
$param = new Object;
Expand Down Expand Up @@ -76,11 +70,8 @@
//==============================

$filtername = ucfirst($filtername);
print_header( "$site->shortname: $txt->managefilters", "$site->fullname",
"<a href=\"index.php\">$txt->administration</a> -> <a href=\"configure.php\">$txt->configuration</a> " .
"-> <a href=\"filters.php\">$txt->managefilters</a> -> $filtername" );

print_heading( $txt->managefilters );
admin_externalpage_print_header();
print_heading( $filtername );

print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
echo "<br />";
Expand All @@ -104,5 +95,5 @@

print_simple_box_end();

print_footer();
admin_externalpage_print_footer();
?>
Loading

0 comments on commit 90a73bb

Please sign in to comment.