deglobalization of $ADMIN; merged admin/adminlib.php into lib/adminlib.php; fixed includes and some other minor fixes

This commit is contained in:
skodak
2006-09-02 13:14:57 +00:00
parent 5b7e05d646
commit 6e4dc10f54
34 changed files with 1819 additions and 1786 deletions
-1657
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -3,9 +3,10 @@
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('userauthentication');
$adminroot = admin_get_root();
admin_externalpage_setup('userauthentication', $adminroot);
$auth = optional_param('auth', '', PARAM_SAFEDIR);
@@ -121,7 +122,7 @@
$strsettings = get_string("settings");
$strusers = get_string("users");
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
echo "<center><b>";
echo "<form target=\"{$CFG->framename}\" name=\"authmenu\" method=\"post\" action=\"auth.php\">";
@@ -231,7 +232,7 @@
print_simple_box_end();
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
/// Functions /////////////////////////////////////////////////////////////////
+5 -4
View File
@@ -3,8 +3,9 @@
// 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.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('blockmanagement', $adminroot);
require_once($CFG->libdir.'/blocklib.php');
$blockid = required_param('block', PARAM_INT);
@@ -56,7 +57,7 @@
$CFG->pagepath = 'block/' . $block->name() . '/config';
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strblockname);
@@ -71,6 +72,6 @@
echo '</p>';
$block->config_print();
echo '</form>';
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+6 -5
View File
@@ -3,8 +3,9 @@
// 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.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('blockmanagement', $adminroot);
require_once($CFG->libdir.'/blocklib.php');
require_once($CFG->libdir.'/tablelib.php');
@@ -29,7 +30,7 @@
$strname = get_string('name');
$strmultiple = get_string('blockmultiple', 'admin');
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strmanageblocks);
@@ -75,7 +76,7 @@
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
'blocks.php?delete='.$block->id.'&amp;confirm=1&amp;sesskey='.$USER->sesskey,
'blocks.php');
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
} else {
@@ -231,6 +232,6 @@
$table->print_html();
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+1 -1
View File
@@ -27,7 +27,7 @@
}
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot.'/lib/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
if (!$alreadyadmin = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
unset($_SESSION['USER']);
+5 -4
View File
@@ -3,12 +3,13 @@
// Yes, enrol is correct English spelling.
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
$CFG->pagepath = 'enrol';
admin_externalpage_setup('enrolment');
$adminroot = admin_get_root();
admin_externalpage_setup('enrolment', $adminroot);
@@ -40,7 +41,7 @@
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
$modules = get_list_of_plugins("enrol");
$options = array();
@@ -98,6 +99,6 @@
echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
echo "</form>";
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+5 -4
View File
@@ -3,9 +3,10 @@
// Yes, enrol is correct English spelling.
require_once("../config.php");
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('enrolment');
$adminroot = admin_get_root();
admin_externalpage_setup('enrolment', $adminroot);
$enrol = required_param('enrol', PARAM_ALPHA);
$CFG->pagepath = 'enrol/' . $enrol;
@@ -41,7 +42,7 @@
}
asort($options);
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
@@ -72,7 +73,7 @@
print_simple_box_end();
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
?>
+5 -4
View File
@@ -30,11 +30,12 @@
// 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.'/adminlib.php');
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
admin_externalpage_setup('environment');
$adminroot = admin_get_root();
admin_externalpage_setup('environment', $adminroot);
/// Parameters
$action = optional_param('action', '', PARAM_ACTION);
@@ -52,7 +53,7 @@
$strmisc = get_string('miscellaneous');
/// Print the header stuff
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
/// Print the component download link
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&amp;sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
@@ -137,5 +138,5 @@
echo '</div>';
/// Print footer
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+5 -4
View File
@@ -3,10 +3,11 @@
// Edit text filter settings
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
admin_externalpage_setup('filtermanagement');
$adminroot = admin_get_root();
admin_externalpage_setup('filtermanagement', $adminroot);
// get parameters
$param = new Object;
@@ -70,7 +71,7 @@
//==============================
$filtername = ucfirst($filtername);
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading( $filtername );
print_simple_box("<center>".get_string("configwarning", "admin")."</center>", "center", "50%");
@@ -95,5 +96,5 @@
print_simple_box_end();
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+5 -4
View File
@@ -3,13 +3,14 @@
// Edit list of available text filters
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
// defines
define('FILTER_TABLE','filter_administration_table');
admin_externalpage_setup('filtermanagement');
$adminroot = admin_get_root();
admin_externalpage_setup('filtermanagement', $adminroot);
// get values from page
$params = new object();
@@ -267,7 +268,7 @@
// Display logic
//==============================
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading_with_help($txt->managefilters, 'filters');
@@ -276,6 +277,6 @@
// cache control table has been removed
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+10 -9
View File
@@ -22,8 +22,8 @@
require_once('../config.php');
include_once($CFG->dirroot.'/lib/adminlib.php'); // Contains various admin-only functions
include_once($CFG->dirroot.'/lib/ddllib.php'); // Install/upgrade related db functions
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
$id = optional_param('id', '', PARAM_ALPHANUM);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
@@ -152,11 +152,11 @@
// Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
// (this should only have any effect during initial install).
require_once($CFG->dirroot . '/admin/adminlib.php');
apply_default_settings($ADMIN);
$adminroot = admin_get_root();
apply_default_settings($adminroot);
/// This is used to handle any settings that must exist in $CFG but which do not exist in
/// $ADMIN as admin_setting objects (there are some exceptions).
/// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions).
apply_default_exception_settings(array('alternateloginurl' => '',
'auth' => 'email',
'auth_pop3mailbox' => 'INBOX',
@@ -373,9 +373,10 @@
/// Print default admin page with notifications.
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
admin_externalpage_setup('adminnotifications');
admin_externalpage_print_header();
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('adminnotifications', $adminroot);
admin_externalpage_print_header($adminroot);
/// Deprecated database! Warning!!
if (!empty($CFG->migrated_to_new_db)) {
@@ -569,7 +570,7 @@
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
+6 -5
View File
@@ -33,8 +33,9 @@
*/
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('langedit');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('langedit', $adminroot);
define('LANG_SUBMIT_REPEAT', 1); // repeat displaying submit button?
define('LANG_SUBMIT_REPEAT_EVERY', 20); // if so, after how many lines?
@@ -110,7 +111,7 @@
}
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
if (!$mode) {
print_simple_box_start('center','80%');
@@ -128,7 +129,7 @@
print_heading("<a href=\"langdoc.php\">$stredithelpdocs</a>");
echo '</div>';
print_simple_box_end();
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
}
@@ -499,7 +500,7 @@
}
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
//////////////////////////////////////////////////////////////////////
+5 -4
View File
@@ -10,8 +10,9 @@
* for intensive testing of this my first contribution
*/
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('langedit');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('langedit', $adminroot);
//
// Some local configuration
@@ -33,7 +34,7 @@
$strthislanguage = get_string("thislanguage");
$stredithelpdocs = get_string('edithelpdocs', 'admin');
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
$currentlang = current_language();
$langdir = "$CFG->dataroot/lang/$currentlang";
@@ -195,7 +196,7 @@ $langdir/$currentfile")."</font></p>";
error_reporting($CFG->debug);
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
//////////////////////////////////////////////////////////////////////
+5 -4
View File
@@ -5,8 +5,9 @@
///This helps to avoid confusion.
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('langimport');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('langimport', $adminroot);
$mode = optional_param('mode', 0, PARAM_INT); //phase
$pack = optional_param('pack', '', PARAM_FILE); //pack to install
@@ -28,7 +29,7 @@
$strthislanguage = get_string("thislanguage");
$title = $strlang;
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
switch ($mode){
@@ -343,7 +344,7 @@
} //close of main switch
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
/* returns a list of available language packs from a
* local copy shipped with standard moodle distro
+5 -4
View File
@@ -2,11 +2,12 @@
// Enables/disables maintenance mode
require('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
$action = optional_param('action', '', PARAM_ALPHA);
admin_externalpage_setup('maintenancemode');
$adminroot = admin_get_root();
admin_externalpage_setup('maintenancemode', $adminroot);
//Check folder exists
if (! make_upload_directory(SITEID)) { // Site folder
@@ -31,7 +32,7 @@
/// Print the header stuff
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
/// Print the appropriate form
@@ -63,5 +64,5 @@
}
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+5 -4
View File
@@ -2,8 +2,9 @@
// module.php - allows admin to edit all local configuration variables for a module
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('modulemanagement');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('modulemanagement', $adminroot);
/// If data submitted, then process and store.
@@ -53,7 +54,7 @@
// of the page. It is also used to generate the link to the Moodle Docs for this view.
$CFG->pagepath = 'mod/' . $module . '/config';
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strmodulename);
@@ -64,6 +65,6 @@
include("$CFG->dirroot/mod/$module/config.html");
print_simple_box_end();
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+6 -5
View File
@@ -2,8 +2,9 @@
// Allows the admin to manage activity modules
require_once('../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('modulemanagement');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('modulemanagement', $adminroot);
require_once('../course/lib.php');
$show = optional_param('show', '', PARAM_SAFEDIR);
@@ -29,7 +30,7 @@
// "<a href=\"index.php\">$stradministration</a> -> ".
// "<a href=\"configure.php\">$strconfiguration</a> -> $strmanagemodules");
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strmanagemodules);
@@ -66,7 +67,7 @@
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
"modules.php?delete=$delete&amp;confirm=1&amp;sesskey=$USER->sesskey",
"modules.php");
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
} else { // Delete everything!!
@@ -195,6 +196,6 @@
echo "<br /><br />";
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+10 -5
View File
@@ -13,12 +13,14 @@ class page_admin extends page_base {
var $visiblepathtosection;
function init_full($section) {
global $CFG, $ADMIN;
global $CFG;
if($this->full_init_done) {
return;
}
$adminroot = admin_get_root();
// fetch the path parameter
$this->section = $section;
@@ -26,9 +28,9 @@ class page_admin extends page_base {
// this part is (potentially) processor-intensive... there's gotta be a better way
// of handling this
if ($this->pathtosection = $ADMIN->path($this->section)) {
if ($this->pathtosection = $adminroot->path($this->section)) {
foreach($this->pathtosection as $element) {
if ($pointer = $ADMIN->locate($element)) {
if ($pointer = $adminroot->locate($element)) {
array_push($this->visiblepathtosection, $pointer->visiblename);
}
}
@@ -55,8 +57,11 @@ class page_admin extends page_base {
}
function url_get_path() {
global $ADMIN, $CFG;
$root = $ADMIN->locate($this->section);
global $CFG;
$adminroot = admin_get_root();
$root = $adminroot->locate($this->section);
if (is_a($root, 'admin_externalpage')) {
return $root->url;
} else {
+6 -5
View File
@@ -3,8 +3,9 @@
//testing
require_once('../../config.php');
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('manageroles');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('manageroles', $adminroot);
// require_login();
$roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role
@@ -26,7 +27,7 @@
$editingstr ='';
}
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
// print_header("$site->shortname: $strmanageroles",
// "$site->fullname",
// "<a href=\"../index.php\">$stradministration</a> -> <a href=\"manage.php\">$strmanageroles</a>
@@ -126,7 +127,7 @@
echo ('<input type="hidden" name="confirm" value="1">');
echo ('are you sure?');
echo ('<input type="submit" value="yes">');
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
// print_footer($course);
exit;
@@ -204,6 +205,6 @@
}
use_html_editor("description");
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
// print_footer($course);
?>
+4 -4
View File
@@ -1,9 +1,9 @@
<?php // $Id$
require_once('../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir . '/blocklib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php');
require_once($CFG->dirroot . '/admin/pagelib.php');
if ($site = get_site()) {
require_login();
@@ -38,9 +38,9 @@ if ($PAGE->user_allowed_editing()) {
}
}
unset($root);
$adminroot = admin_get_root();
$root = $ADMIN->locate($PAGE->section);
$root = $adminroot->locate($PAGE->section);
if (!is_a($root, 'admin_settingpage')) {
error(get_string('sectionerror', 'admin'));
+1 -1
View File
@@ -20,7 +20,7 @@ $ADMIN->add('plugins', new admin_externalpage('filtermanagement', get_string('fi
$ADMIN->add('plugins', new admin_externalpage('blockmanagement', get_string('blockmanagement', 'admin'), $CFG->wwwroot . '/admin/blocks.php'));
$ADMIN->add('plugins', new admin_externalpage('modulemanagement', get_string('modulemanagement', 'admin'), $CFG->wwwroot . '/admin/modules.php'));
if (file_exists($CFG->dirroot . '/' . $CFG->admin . '/mysql/frame.php')) {
if (file_exists($CFG->dirroot . '/admin/mysql/frame.php')) {
$ADMIN->add('root', new admin_externalpage('database', get_string('managedatabase'), $CFG->wwwroot . '/' . $CFG->admin . '/mysql/frame.php'));
}
+5 -4
View File
@@ -7,7 +7,8 @@
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/olson.php');
admin_externalpage_setup('timezoneimport');
$adminroot = admin_get_root();
admin_externalpage_setup('timezoneimport', $adminroot);
$ok = optional_param('ok', 0, PARAM_BOOL);
@@ -19,7 +20,7 @@
$strcalendarsettings = get_string('calendarsettings', 'admin');
$strimporttimezones = get_string('importtimezones', 'admin');
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strimporttimezones);
@@ -35,7 +36,7 @@
notice_yesno($message, 'timezoneimport.php?ok=1&sesskey='.sesskey(), 'index.php');
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
}
@@ -125,6 +126,6 @@
print_continue('index.php');
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>
+7 -5
View File
@@ -4,15 +4,17 @@
// modify them, and then processes modifications
require_once('../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('adminnotifications'); // we pretend to be the adminnotifications page... don't wanna show up in the menu :)
$adminroot = admin_get_root();
admin_externalpage_setup('adminnotifications', $adminroot); // we pretend to be the adminnotifications page... don't wanna show up in the menu :)
// 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.
$newsettings = find_new_settings($ADMIN);
$newsettings = find_new_settings(admin_get_root());
// first we deal with the case where there are no new settings to be set
if (count($newsettings) === 0) {
@@ -50,7 +52,7 @@ if ($data = data_submitted()) {
// 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($adminroot);
echo '<form action="upgradesettings.php" method="post" name="mainform">';
@@ -67,7 +69,7 @@ echo '<center><input type="submit" value="Save Changes" /></center>';
print_simple_box_end();
echo '</form>';
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
+3 -3
View File
@@ -319,7 +319,7 @@
/// This function upgrades the backup tables, if necessary
/// It's called from admin/index.php, also backup.php and restore.php
global $CFG, $db, $ADMIN;
global $CFG, $db;
require_once ("$CFG->dirroot/backup/version.php"); // Get code versions
@@ -346,8 +346,8 @@
if ($status) {
if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
//initialize default backup settings now
require_once($CFG->dirroot . '/admin/adminlib.php');
apply_default_settings($ADMIN->locate('backups'));
$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);
+1 -1
View File
@@ -70,7 +70,7 @@ class block_admin extends block_list {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" alt="" />';
if (file_exists($CFG->dirroot.'/'.$CFG->admin.'/'.$CFG->dbtype)) {
if (file_exists($CFG->dirroot.'/admin/'.$CFG->dbtype)) {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/db.gif" alt="" />';
}
+6 -8
View File
@@ -89,31 +89,29 @@ class block_admin_2 extends block_base {
global $CFG, $ADMIN;
// better place to require this?
if (!$ADMIN) {
require_once($CFG->dirroot . '/admin/adminlib.php');
}
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if ($this->content !== NULL) {
return $this->content;
}
if ($this->pathtosection = $ADMIN->path($this->section)) {
if ($this->pathtosection = $adminroot->path($this->section)) {
$this->pathtosection = array_reverse($this->pathtosection);
array_pop($this->pathtosection);
}
// we need to do this instead of $this->build_tree($ADMIN) because the top-level folder
// we need to do this instead of $this->build_tree($adminroot) because the top-level folder
// is redundant (and ideally ignored). (the top-level folder is "administration".)
unset($entries);
$entries = array_keys($ADMIN->children);
$entries = array_keys($adminroot->children);
asort($entries);
foreach ($entries as $entry) {
$this->build_tree($ADMIN->children[$entry]);
$this->build_tree($adminroot->children[$entry]);
}
if ($this->tempcontent !== '') {
@@ -21,11 +21,10 @@ class block_admin_bookmarks extends block_base {
function get_content() {
global $CFG, $USER, $ADMIN, $PAGE;
global $CFG, $USER, $PAGE;
if (!$ADMIN) {
require_once($CFG->dirroot . '/admin/adminlib.php');
}
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if ($this->content !== NULL) {
return $this->content;
@@ -36,9 +35,9 @@ class block_admin_bookmarks extends block_base {
if (isset($USER->preference['admin_bookmarks'])) {
$bookmarks = explode(',',$USER->preference['admin_bookmarks']);
// hmm... just a liiitle (potentially) processor-intensive
// (recall that $ADMIN->locate is a huge recursive call... and we're calling it repeatedly here
// (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
foreach($bookmarks as $bookmark) {
$temp = $ADMIN->locate($bookmark);
$temp = $adminroot->locate($bookmark);
if (is_a($temp, 'admin_settingpage')) {
$this->content->text .= '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . '</a>' . '<br />';
} elseif (is_a($temp, 'admin_externalpage')) {
+3 -2
View File
@@ -2,7 +2,8 @@
require('../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
@@ -18,7 +19,7 @@ if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
$bookmarks = array();
}
$temp = $ADMIN->locate($section);
$temp = $adminroot->locate($section);
if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) {
+3 -2
View File
@@ -2,7 +2,8 @@
require('../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
@@ -21,7 +22,7 @@ if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
$bookmarks = implode(',',$bookmarks);
set_user_preference('admin_bookmarks', $bookmarks);
$temp = $ADMIN->locate($section);
$temp = $adminroot->locate($section);
if (is_a($temp, 'admin_externalpage')) {
redirect($temp->url, 'Bookmark deleted.',1);
+5 -4
View File
@@ -91,9 +91,10 @@
if ($adminediting) {
// modify this to treat this as an admin page
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('coursemgmt');
admin_externalpage_print_header();
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('coursemgmt', $adminroot);
admin_externalpage_print_header($adminroot);
} else {
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
"<a href=\"index.php\">$strcategories</a> -> $category->name", "", "", true, $navbaritem);
@@ -444,7 +445,7 @@
echo "</center>";
if ($adminediting) {
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
} else {
print_footer();
}
+5 -4
View File
@@ -75,8 +75,9 @@
/// From now on is all the admin functions
require_once($CFG->dirroot . '/admin/adminlib.php');
admin_externalpage_setup('coursemgmt');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
admin_externalpage_setup('coursemgmt', $adminroot);
/// Print headings
@@ -92,7 +93,7 @@
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading($strcategories);
@@ -323,7 +324,7 @@
echo "<br />";
echo "</center>";
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
+1664
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -279,7 +279,7 @@ function load_environment_xml() {
$file = $CFG->dataroot.'/environment/environment.xml';
if (!is_file($file) || !is_readable($file) || !$contents = file_get_contents($file)) {
/// Fallback to fixed $CFG->admin/environment.xml
$file = $CFG->dirroot.'/'.$CFG->admin.'/environment.xml';
$file = $CFG->dirroot.'/admin/environment.xml';
if (!is_file($file) || !is_readable($file) || !$contents = file_get_contents($file)) {
return false;
}
+6 -5
View File
@@ -1,11 +1,12 @@
<?php // $Id$
require_once("../config.php");
require_once($CFG->dirroot . '/admin/adminlib.php');
require_once($CFG->libdir.'/adminlib.php');
$choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
admin_externalpage_setup('themeselector');
$adminroot = admin_get_root();
admin_externalpage_setup('themeselector', $adminroot);
unset($SESSION->theme);
@@ -27,7 +28,7 @@
}
if (set_config("theme", $choose)) {
theme_setup($choose);
admin_externalpage_print_header();
admin_externalpage_print_header($adminroot);
print_heading(get_string("themesaved"));
print_continue("$CFG->wwwroot/");
@@ -42,7 +43,7 @@
echo format_text(implode('', $file), FORMAT_MOODLE);
print_simple_box_end();
}
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
exit;
} else {
error("Could not set the theme!");
@@ -131,7 +132,7 @@
$options["sub"] = "themes";
print_single_button("$CFG->wwwroot/doc/index.php", $options, get_string("howtomakethemes"));
echo "</div>";
admin_externalpage_print_footer();
admin_externalpage_print_footer($adminroot);
?>