From: martin Date: Thu, 19 Sep 2002 12:01:55 +0000 (+0000) Subject: Most of the configuration variables have been moved out of the config.php X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=74944b734d66dfb4c4431916124c5fee75f2bf21;p=moodle.git Most of the configuration variables have been moved out of the config.php file and into a database, where they can be edited using a new admin form called "Configure variables". --- diff --git a/CHANGES b/CHANGES index 99034bf966..74a3df8104 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,119 @@ +2002-09-17 Tuesday 22:56 martin + + * error/index.php: + + Slight fix to error page to include site name properly + +2002-09-16 Monday 21:03 martin + + * index.php: + + Login link on home page + +2002-09-16 Monday 15:11 martin + + * UPGRADING.txt: + + eminder about saving themes in upgrades etc + +2002-09-16 Monday 15:08 martin + + * lib/htaccess: + + Typo + +2002-09-16 Monday 15:03 martin + + * lib/javascript.php: + + Fixed name in popup javascript window + +2002-09-16 Monday 14:33 martin + + * lib/htaccess: + + Sample .htaccess file + +2002-09-16 Monday 11:23 martin + + * doc/install.html: + + Fixed Id + +2002-09-16 Monday 11:20 martin + + * doc/install.html: + + Type on phpinfo + +2002-09-15 Sunday 14:09 martin + + * config-dist.php: + + Mentioned there's no need to use a trailing slash on the wwwroot + +2002-09-15 Sunday 14:06 martin + + * course/enrol.html, lib/moodlelib.php, login/index_form.html: + + Fixes to point directly to index.php wherever it was assumed. This + wasn't a problem on most servers, but was causing some problems on + IIS servers + +2002-09-14 Saturday 11:43 martin + + * version.php, lang/en/moodle.php, lib/moodlelib.php, + user/edit.html: + + Can now specify current language on a per-user basis + +2002-09-13 Friday 18:33 martin + + * mod/reading/view.php: + + Consistent display of text + +2002-09-13 Friday 18:22 martin + + * lang/en/help/html.html: + + New help file for editing html + +2002-09-13 Friday 18:21 martin + + * version.php, lang/en/moodle.php, lang/en/reading.php, + lang/en/help/reading/readingtype.html, mod/reading/details.php, + mod/reading/lib.php, mod/reading/mod.html, mod/reading/view.php: + + Added a new reading type "html text". It's similar to "plain text" + except none of the auto-formatting is done, and all HTML code is + accepted. + +2002-09-13 Friday 01:08 martin + + * lib/weblib.php: + + SUrprise icon is a bit wider than 16 pixels + +2002-09-12 Thursday 10:42 martin + + * course/lib.php: + + Fixed bug with category links on front page + +2002-09-11 Wednesday 22:02 martin + + * login/confirm.php: + + One more little buglet when confirming an email (added security + site value) + +2002-09-11 Wednesday 13:11 martin + + * CHANGES: + + CHANGES UP TO 1.0.4 (really, I mean it this time :-) ) + 2002-09-11 Wednesday 10:26 martin * course/lib.php: @@ -1180,13 +1296,13 @@ 2002-08-17 Saturday 11:03 martin - * README, README.txt, UPGRADING, UPGRADING.txt: + * .htaccess, README, README.txt, UPGRADING, UPGRADING.txt: Added .txt to these files to make them double-clickable 2002-08-17 Saturday 11:01 martin - * README: + * .htaccess, README: Better introduction to installation @@ -2729,7 +2845,8 @@ 2002-07-27 Saturday 21:09 martin - * README, UPGRADES, UPGRADING, version.php, admin/index.php: + * .htaccess, README, UPGRADES, UPGRADING, version.php, + admin/index.php: Moodle can now upgrade itself, just like the modules do @@ -4263,7 +4380,7 @@ 2002-05-18 Saturday 11:37 martin - * README: + * .htaccess, README: Added warning about unstable CVS tree @@ -4847,12 +4964,13 @@ 2001-11-22 Thursday 14:23 martin - * README, config.php, file.php, index.php, admin/cron.php, - admin/index.php, admin/log.php, admin/moodle-core.sql, - admin/site.html, admin/site.php, admin/teacher.php, - admin/user.html, admin/user.php, course/edit.html, course/edit.php, - course/editweek.html, course/editweek.php, course/email.html, - course/email.php, course/index.php, course/lib.php, course/log.php, + * .htaccess, README, config.php, file.php, index.php, + admin/cron.php, admin/index.php, admin/log.php, + admin/moodle-core.sql, admin/site.html, admin/site.php, + admin/teacher.php, admin/user.html, admin/user.php, + course/edit.html, course/edit.php, course/editweek.html, + course/editweek.php, course/email.html, course/email.php, + course/index.php, course/lib.php, course/log.php, course/login.html, course/login.php, course/loginas.php, course/loglive.php, course/mod.php, course/mod_delete.html, course/new.php, course/noweeks.php, course/user.php, @@ -4914,12 +5032,13 @@ 2001-11-22 Thursday 14:23 martin - * README, config.php, file.php, index.php, admin/cron.php, - admin/index.php, admin/log.php, admin/moodle-core.sql, - admin/site.html, admin/site.php, admin/teacher.php, - admin/user.html, admin/user.php, course/edit.html, course/edit.php, - course/editweek.html, course/editweek.php, course/email.html, - course/email.php, course/index.php, course/lib.php, course/log.php, + * .htaccess, README, config.php, file.php, index.php, + admin/cron.php, admin/index.php, admin/log.php, + admin/moodle-core.sql, admin/site.html, admin/site.php, + admin/teacher.php, admin/user.html, admin/user.php, + course/edit.html, course/edit.php, course/editweek.html, + course/editweek.php, course/email.html, course/email.php, + course/index.php, course/lib.php, course/log.php, course/login.html, course/login.php, course/loginas.php, course/loglive.php, course/mod.php, course/mod_delete.html, course/new.php, course/noweeks.php, course/user.php, diff --git a/admin/config.html b/admin/config.html new file mode 100644 index 0000000000..1a9b16a2ae --- /dev/null +++ b/admin/config.html @@ -0,0 +1,162 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

lang:

+ lang, "", "", ""); + formerr($err["lang"]); + ?> + + +

locale:

+ + + + +

smtphosts:

+ + + + +

gdversion:

+ + + +

errorlevel:

+ errorlevel, "", "", ""); + unset($options); + ?> + + +

maxeditingtime:

+ maxeditingtime, "", "", ""); + unset($options); + ?> + + +

longtimenosee:

+ longtimenosee, "", "", ""); + unset($options); + ?> + + +

zip:

+ + + + +

unzip:

+ + + + +

slasharguments:

+ slasharguments, "", "", ""); + unset($options); + ?> + + +

proxyhost:

+ + + + +

proxyport:

+ + +
+ ">
+ +
diff --git a/admin/config.php b/admin/config.php new file mode 100644 index 0000000000..c8d6206e73 --- /dev/null +++ b/admin/config.php @@ -0,0 +1,94 @@ + $value) { + unset($conf); + $conf->name = $name; + $conf->value = $value; + if ($current = get_record("config", "name", $name)) { + $conf->id = $current->id; + if (! update_record("config", $conf)) { + notify("Could not update $name to $value"); + } + } else { + if (! insert_record("config", $conf)) { + notify("Error: could not add new variable $name !"); + } + } + } + redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"), 1); + exit; + + } else { + foreach ($err as $key => $value) { + $focus = "form.$key"; + } + } + } + +/// Otherwise fill and print the form. + + if (!isset($config)) { + $config = $CFG; + } + + $stradmin = get_string("administration"); + $strconfigvariables = get_string("configvariables"); + + if ($site) { + print_header("$site->fullname", "$site->fullname", + "wwwroot/admin/\">$stradmin -> $strconfigvariables", "$focus"); + print_heading($strconfigvariables); + } else { + print_header(); + print_heading($strconfigvariables); + print_simple_box(get_string("configintro"), "center"); + echo "
"; + } + + print_simple_box_start("center", "", "$THEME->cellheading"); + include("config.html"); + print_simple_box_end(); + print_footer(); + + exit; + +/// Functions ///////////////////////////////////////////////////////////////// + +function validate_form(&$form, &$err) { + + // if (empty($form->fullname)) + // $err["fullname"] = get_string("missingsitename"); + + return; +} + + +?> diff --git a/admin/index.php b/admin/index.php index ba1d561b4a..1ee50f1760 100644 --- a/admin/index.php +++ b/admin/index.php @@ -3,11 +3,21 @@ require("../config.php"); +/// Check that PHP is of a sufficient version + + if ( ! check_php_version("4.1.0") ) { + $version = phpversion(); + print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)"); + die; + } + +/// Check that config.php has been edited + if ($CFG->wwwroot == "http://example.com/moodle") { error("Moodle has not been configured yet. You need to to edit config.php first."); } - // Check databases and modules and install as needed. +/// Check databases and modules and install as needed. if (! $db->Metatables() ) { if (!$agreelicence) { @@ -43,21 +53,21 @@ die; } - // Check version of Moodle code on disk compared with database - // and upgrade if possible. +/// Check version of Moodle code on disk compared with database +/// and upgrade if possible. include_once("$CFG->dirroot/version.php"); # defines $version and upgrades - if ($dversion = get_field("config", "value", "name", "version")) { - if ($version > $dversion) { // upgrade - $a->oldversion = $dversion; + if ($CFG->version) { + if ($version > $CFG->version) { // upgrade + $a->oldversion = $CFG->version; $a->newversion = $version; $strdatabasechecking = get_string("databasechecking", "", $a); $strdatabasesuccess = get_string("databasesuccess"); print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades); notify($strdatabasechecking); $db->debug=true; - if (upgrade_moodle($dversion)) { + if (upgrade_moodle($CFG->version)) { $db->debug=false; if (set_field("config", "value", "$version", "name", "version")) { notify($strdatabasesuccess); @@ -70,7 +80,7 @@ $db->debug=false; notify("Upgrade failed! See /version.php"); } - } else if ($version < $dversion) { + } else if ($version < $CFG->version) { notify("WARNING!!! The code you are using is OLDER than the version that made these databases!"); } @@ -94,9 +104,9 @@ } } - // Updated human-readable release version if necessary +/// Updated human-readable release version if necessary - if ($drelease = get_field("config", "value", "name", "release")) { + if ($CFG->release) { if ($release <> $drelease) { // Update the release version set_field("config", "value", "$release", "name", "release"); } @@ -107,8 +117,7 @@ } - // Find and check all modules and load them up or upgrade them if necessary - +/// Find and check all modules and load them up or upgrade them if necessary if (!$mods = get_list_of_plugins("mod") ) { error("No modules installed!"); @@ -178,11 +187,34 @@ die; } - // Set up the overall site name etc. + +/// Insert default values for any important configuration variables + + include_once("$CFG->dirroot/lib/defaults.php"); + + $CFG = (array)$CFG; + foreach ($defaults as $name => $value) { + if (!isset($CFG[$name])) { + $config->name = $name; + $config->value = $CFG[$name] = $value; + insert_record("config", $config); + $configchange = true; + } + } + $CFG = (object)$CFG; + +/// If any new configurations were found then send to the config page to check + + if ($configchange) { + redirect("$CFG->wwwroot/admin/config.php"); + } + +/// Set up the overall site name etc. if (! $site = get_site()) { redirect("$CFG->wwwroot/admin/site.php"); } +/// Set up the admin user if (!isadmin()) { if (! record_exists_sql("SELECT * FROM user_admins")) { // No admin user yet redirect("$CFG->wwwroot/admin/user.php"); @@ -191,14 +223,15 @@ } - // At this point, the databases exist, and the user is an admin +/// At this point everything is set up and the user is an admin, so print menu $stradministration = get_string("administration"); print_header("$site->fullname: $stradministration","$site->fullname: $stradministration", "$stradministration"); $table->head = array (get_string("site"), get_string("courses"), get_string("users")); $table->align = array ("CENTER", "CENTER", "CENTER"); - $table->data[0][0] = "

".get_string("sitesettings")."

". + $table->data[0][0] = "

".get_string("configvariables")."

". + "

".get_string("sitesettings")."

". "

id\">".get_string("sitelogs")."

". "

".get_string("choosetheme")."

". "

".get_string("checklanguage")."

"; @@ -215,6 +248,7 @@ print_table($table); print_footer(); + ?> diff --git a/admin/site.php b/admin/site.php index b0f774798c..f9b6021795 100644 --- a/admin/site.php +++ b/admin/site.php @@ -64,8 +64,8 @@ print_header("$site->fullname", "$site->fullname", "wwwroot/admin/\">$stradmin -> $strsitesettings", "$focus"); - print_simple_box_start("center", "", "$THEME->cellheading"); print_heading($strsitesettings); + print_simple_box_start("center", "", "$THEME->cellheading"); include("site.html"); print_simple_box_end(); print_footer(); diff --git a/config-dist.php b/config-dist.php index 47fa157d8d..50ae1ed603 100644 --- a/config-dist.php +++ b/config-dist.php @@ -1,130 +1,76 @@ dbtype = "mysql"; // eg mysql (postgres7, oracle, access etc coming soon) -$CFG->dbhost = "localhost"; // eg localhost -$CFG->dbname = "moodle"; // eg moodle +// // +// NOTICE OF COPYRIGHT // +// // +// Moodle - Modular Object-Oriented Dynamic Learning Environment // +// http://moodle.com // +// // +// Copyright (C) 2001-2002 Martin Dougiamas http://dougiamas.com // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details: // +// // +// http://www.gnu.org/copyleft/gpl.html // +// // +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// First, you need to configure the database where all Moodle data // +// will be stored. This database must already have been created // +// and a username/password created to access it. If you specify mysql // +// then Moodle can set up all your tables for you. If you try to use // +// a different database you will need to set up all your tables by hand // +// which could be a big job. See doc/install.html // + +$CFG->dbtype = "mysql"; // eg mysql (postgres7, oracle, access etc) +$CFG->dbhost = "localhost"; // eg localhost +$CFG->dbname = "moodle"; // eg moodle $CFG->dbuser = "username"; $CFG->dbpass = "password"; -// Next you need to tell Moodle where it is located. -// Specify the full URL where moodle has been installed (without a trailing slash): +/////////////////////////////////////////////////////////////////////////// +// Now you need to tell Moodle where it is located. Specify the full +// web address where moodle has been installed (without trailing slash) $CFG->wwwroot = "http://example.com/moodle"; -// and now the full OS directory path to this same location: +/////////////////////////////////////////////////////////////////////////// +// Next, specify the full OS directory path to this same location +// For Windows this might be something like "C:\apache\htdocs\moodle" $CFG->dirroot = "/web/moodle"; -// Now you need a place where Moodle can save uploaded files. This directory -// should be writeable by the web server user (usually 'nobody' or 'apache'), -// but it should not be accessible directly via the web. +/////////////////////////////////////////////////////////////////////////// +// Now you need a place where Moodle can save uploaded files. This +// directory should be writeable by the web server user (usually 'nobody' +// or 'apache'), but it should not be accessible directly via the web. $CFG->dataroot = "/home/moodledata"; -// Choose a sitewide language - this will affect text, buttons etc -// See lib/languages.php for a full list of standard language codes. - -$CFG->lang = "en"; // Currently the only option - - -// Choose a sitewide locale - this will affect the display of dates -// You need to have this locale data installed on your operating -// system. If you don't know what to choose try using the same -// string as the language. - -$CFG->locale = "en"; - - -// Give the full names of local SMTP servers that Moodle should use to -// send mail (eg "mail.a.com" or "mail.a.com;mail.b.com"). -// If this is left empty (eg "") then Moodle will attempt to use PHP mail. - -$CFG->smtphosts = ""; - - -// There is no way, currently, for PHP to automatically tell whether the -// graphic library GD is version 1.* or 2.*. Specify here (either 1 or 2). - -$CFG->gdversion = 1; - - -// If students haven't logged in for a very long time, then they are -// automatically unsubscribed from courses. This parameter specifies -// that time limit, in DAYS. - -$CFG->longtimenosee = 100; - - -// These programs are used by the file management code to zip and unzip -// uploaded files. This only works on Unix systems right now. - -$CFG->zip = "/usr/bin/zip"; -$CFG->unzip = "/usr/bin/unzip"; - - -// Files (images, uploads etc) are provided via a script which -// is called like this example: file.php/1/myfiles/mymusic.mp3 -// Using this form of argument allows files to be more easily -// cached in web browsers, proxy servers etc, but they don't -// work in all PHP servers. If you have trouble viewing -// uploaded files or images, then set the following to false - -$CFG->slasharguments = true; - -// If this server needs to use a proxy computer (eg a firewall) -// to access the Internet, then provide the proxy details here. -// This will only affect a few minor features such as the ability -// to see user locations plotted on a graph. -// Otherwise, leave these blank - -$CFG->proxyhost = ""; -$CFG->proxyport = ""; - - -// You should not need to change anything else. To continue setting up -// Moodle, use your web browser to go to the moodle/admin web page. +/////////////////////////////////////////////////////////////////////////// +// To continue the setup, use your web browser to go to your Moodle page // /////////////////////////////////////////////////////////////////////////// -$CFG->libdir = "$CFG->dirroot/lib"; - -require("$CFG->libdir/setup.php"); // Sets up all libraries, sessions etc +$CFG->libdir = "$CFG->dirroot/lib"; // Do not change this +require("$CFG->libdir/setup.php"); // Do not change this ?> diff --git a/course/lib.php b/course/lib.php index cde060d76e..f69d2d0932 100644 --- a/course/lib.php +++ b/course/lib.php @@ -536,14 +536,18 @@ function print_admin_links ($siteid, $width=180) { print_simple_box(get_string("administration"), $align="CENTER", $width, $color="$THEME->cellheading"); $icon = "wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; - $moddata[]="wwwroot/course/log.php?id=$siteid\">".get_string("sitelogs").""; + $moddata[]="wwwroot/admin/config.php\">".get_string("configvariables").""; $modicon[]=$icon; $moddata[]="wwwroot/admin/site.php\">".get_string("sitesettings").""; $modicon[]=$icon; + $moddata[]="wwwroot/course/log.php?id=$siteid\">".get_string("sitelogs").""; + $modicon[]=$icon; $moddata[]="wwwroot/theme/index.php\">".get_string("choosetheme").""; $modicon[]=$icon; $moddata[]="wwwroot/admin/lang.php\">".get_string("checklanguage").""; $modicon[]=$icon; + $moddata[]="
"; + $modicon[]=""; $moddata[]="wwwroot/course/edit.php\">".get_string("addnewcourse").""; $modicon[]=$icon; $moddata[]="wwwroot/course/categories.php\">".get_string("categories").""; @@ -552,6 +556,8 @@ function print_admin_links ($siteid, $width=180) { $modicon[]=$icon; $moddata[]="wwwroot/course/delete.php\">".get_string("deletecourse").""; $modicon[]=$icon; + $moddata[]="
"; + $modicon[]=""; $moddata[]="wwwroot/admin/user.php?newuser=true\">".get_string("addnewuser").""; $modicon[]=$icon; $moddata[]="wwwroot/admin/user.php\">".get_string("edituser").""; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index e8b7caaafc..496d780612 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -17,6 +17,7 @@ $string[addteacher] = "Add teacher"; $string[admin] = "Admin"; $string[administration] = "Administration"; $string[again] = "again"; +$string[all] = "All"; $string[alldays] = "All days"; $string[allfieldsrequired] = "All fields are required"; $string[alllogs] = "All logs"; @@ -44,6 +45,19 @@ $string[choosetheme] = "Choose theme"; $string[chooseuser] = "Choose a user"; $string[city] = "City/town"; $string[comparelanguage] = "Compare language to English"; +$string[configvariables] = "Configure variables"; +$string[configgdversion] = "Indicate the version of GD that is installed. The version shown by default is the one that has been auto-detected. Don't change this unless you really know what you're doing."; +$string[configerrorlevel] = "Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice."; +$string[configintro] = "On this page you can specify a number of configuration variables that help make Moodle work properly on your server. Don't worry too much about it - the defaults will usually work fine and you can always come back to this page later and change these settings."; +$string[configlang] = "Choose a default language for the whole site. Users can override this setting later."; +$string[configlocale] = "Choose a sitewide locale - this will affect the display of dates. You need to have this locale data installed on your operating system. If you don't know what to choose leave it blank."; +$string[configlongtimenosee] = "If students haven't logged in for a very long time, then they are automatically unsubscribed from courses. This parameter specifies that time limit."; +$string[configmaxeditingtime] = "This specifies the amount of time people have to re-edit forum postings, journal feedback etc. Usually 30 minutes is a good value."; +$string[configproxyhost] = "If this server needs to use a proxy computer (eg a firewall) to access the Internet, then provide the proxy hostname and port here. Otherwise leave it blank."; +$string[configslasharguments] = "Files (images, uploads etc) are provided via a script using 'slash arguments' (the second option here). This method allows files to be more easily cached in web browsers, proxy servers etc. Unfortunately, some PHP servers don't allow this method, so if you have trouble viewing uploaded files or images (eg user pictures), set this variable to the first option"; +$string[configsmtphosts] = "Give the full name of one or more local SMTP servers that Moodle should use to send mail (eg 'mail.a.com' or 'mail.a.com;mail.b.com'). If you leave it blank, Moodle will use the PHP default method of sending mail."; +$string[configunzip] = "Indicate the location of your unzip program (Unix only). This is needed to unpack zip archives on the server."; +$string[configzip] = "Indicate the location of your zip program (Unix only). This is needed to create zip archives on the server."; $string[confirmed] = "Your registration has been confirmed"; $string[courseupdates] = "Course updates"; $string[cookiesenabled] = "Cookies must be enabled in your browser"; @@ -147,6 +161,9 @@ $string[fulllistofcourses] = "All courses"; $string[fullprofile] = "Full profile"; $string[fullname] = "Full name"; $string[fullsitename] = "Full site name"; +$string[gd1] = "GD 1.x is installed"; +$string[gd2] = "GD 2.x is installed"; +$string[gdnot] = "GD is not installed"; $string[gpl] = "Copyright (C) 2001-2002 Martin Dougiamas (http://dougiamas.com) This program is free software; you can redistribute it and/or modify @@ -292,7 +309,9 @@ $string[no] = "No"; $string[nocoursesyet] = "No courses in this category"; $string[noexistingteachers] = "No existing teachers"; $string[nograde] = "No grade"; +$string[none] = "None"; $string[nopotentialteachers] = "No potential teachers"; +$string[normal] = "Normal"; $string[nostudentsyet] = "No students enrolled in this course yet"; $string[nosuchemail] = "No such email address"; $string[noteachersyet] = "No teachers in this course yet"; @@ -302,10 +321,11 @@ $string[nousersyet] = "There are no users yet"; $string[now] = "now"; $string[numberweeks] = "Number of weeks/topics"; $string[numdays] = "\$a days"; +$string[numminutes] = "\$a minutes"; +$string[numviews] = "\$a views"; $string[numweeks] = "\$a weeks"; -$string[numyears] = "\$a years"; $string[numwords] = "\$a words"; -$string[numviews] = "\$a views"; +$string[numyears] = "\$a years"; $string[ok] = "OK"; $string[opentoguests] = "Guest access"; $string[optional] = "optional"; diff --git a/lib/defaults.php b/lib/defaults.php new file mode 100644 index 0000000000..00cc53efdb --- /dev/null +++ b/lib/defaults.php @@ -0,0 +1,22 @@ + "standard", + "lang" => "en", + "locale" => "en", + "smtphosts" => "", + "gdversion" => 1, + "longtimenosee" => 100, + "zip" => "/usr/bin/zip", + "unzip" => "/usr/bin/unzip", + "slasharguments" => true, + "proxyhost" => "", + "proxyport" => "", + "maxeditingtime" => 1800, + "errorlevel" => 7 + ); + +?> diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c2084e309c..509153c9ef 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1725,14 +1725,6 @@ function get_list_of_plugins($plugin="mod") { } -function iswindows() { -// True if this is Windows, False if not. - - global $WINDIR; - - return isset($WINDIR); -} - function check_php_version($version="4.1.0") { // Returns true is the current version of PHP is greater that the specified one $minversion = intval(str_replace(".", "", $version)); @@ -1741,5 +1733,27 @@ function check_php_version($version="4.1.0") { } +function check_gd_version() { + ob_start(); + phpinfo(); + $phpinfo = ob_get_contents(); + ob_end_clean(); + + $phpinfo = explode("\n",$phpinfo); + + $gdversion = 0; + + foreach ($phpinfo as $text) { + $parts = explode('',$text); + foreach ($parts as $key => $val) { + $parts[$key] = strip_tags($val); + } + if ($parts[0]=="GD Version") { + $gdversion = intval($parts[1]); + } + } + + return $gdversion; // 1, 2 or 0 +} ?> diff --git a/lib/setup.php b/lib/setup.php index 344c8ece4e..49d766929a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -10,39 +10,44 @@ // ////////////////////////////////////////////////////////////// -// Error reporting and bug hunting +/// If there are any errors in the standard libraries we want to know! + error_reporting(15); // use 0=none 7=normal 15=all - error_reporting(7); // use 0=none 7=normal 15=all - -// Load up standard libraries +/// Load up standard libraries require("$CFG->libdir/weblib.php"); // Standard web page functions require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions require("$CFG->libdir/moodlelib.php"); // Various Moodle functions -// Connect to the database using adodb +/// Connect to the database using adodb ADOLoadCode($CFG->dbtype); $db = &ADONewConnection(); $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname); -// Default editing time for posts and the like (in seconds) +/// Load up any configuration from the config table + + if ($configs = get_records_sql("SELECT * FROM config")) { + $CFG = (array)$CFG; + foreach ($configs as $config) { + $CFG[$config->name] = $config->value; + } + $CFG = (object)$CFG; + unset($configs); + unset($config); + } - $CFG->maxeditingtime = 1800; +/// Set error reporting to whatever the admin has said they want -// Load up any configuration from the config table - - if (!$CFG->theme = get_field("config", "value", "name", "theme")) { - $theme->name = "theme"; - $theme->value = $CFG->theme = "standard"; - insert_record("config", $theme); + if (isset($CFG->errorlevel)) { + error_reporting((int)$CFG->errorlevel); + } else { + error_reporting(7); } -// Location of standard files +/// Location of standard files - $CFG->templatedir = "$CFG->dirroot/templates"; - $CFG->imagedir = "$CFG->wwwroot/images"; $CFG->wordlist = "$CFG->libdir/wordlist.txt"; $CFG->javascript = "$CFG->libdir/javascript.php"; $CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.css"; @@ -50,38 +55,31 @@ $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html"; $CFG->moddata = "moddata"; -// Load up theme variables (colours etc) +/// Load up theme variables (colours etc) + if (!isset($CFG->theme)) { + $CFG->theme = "standard"; + } require("$CFG->dirroot/theme/$CFG->theme/config.php"); -// Set language/locale of printed times (must be supported by OS) +/// Set language/locale of printed times (must be supported by OS) - if ($CFG->locale) { - setlocale ("LC_TIME", $CFG->locale); - } else { - setlocale ("LC_TIME", $CFG->lang); + if (! setlocale ("LC_TIME", $CFG->locale)) { + setlocale ("LC_TIME", $CFG->lang); // Might work } -// Check that PHP is of a sufficient version +/// The following is a hack to get around the problem of PHP installations +/// that have "register_globals" turned off (default since PHP 4.1.0). +/// Eventually I'll go through and upgrade all the code to make this unnecessary - if ( ! check_php_version("4.1.0") ) { - $version = phpversion(); - print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)"); - die; + if (isset($_REQUEST)) { + extract($_REQUEST); + } + if (isset($_SERVER)) { + extract($_SERVER); } - -// The following is a big hack to get around the problem of PHP installations -// that have "register_globals" turned off (default since PHP 4.1.0). -// Eventually I'll go through and upgrade all the code to make this unnecessary - - if (isset($_REQUEST)) { - extract($_REQUEST); - } - if (isset($_SERVER)) { - extract($_SERVER); - } -// Load up global environment variables +/// Load up global environment variables class object {}; diff --git a/version.php b/version.php index 493908fb7f..e544f0dbce 100644 --- a/version.php +++ b/version.php @@ -18,7 +18,7 @@ // If there's something it cannot do itself, it // will tell you what you need to do. -$version = 2002091400; // The current version is a date (YYYYMMDDXX) where +$version = 2002091900; // The current version is a date (YYYYMMDDXX) where // XX is a number that increments during the day $release = "1.0.5 dev"; // For humans only, not used for the upgrade process @@ -36,37 +36,30 @@ function upgrade_moodle($oldversion=0) { ) COMMENT='Moodle configuration variables';"); notify("Created a new table 'config' to hold configuration data"); } - if ($oldversion < 2002073100) { execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' "); } - if ($oldversion < 2002080200) { execute_sql(" ALTER TABLE `modules` DROP `fullname` "); execute_sql(" ALTER TABLE `modules` DROP `search` "); } - if ($oldversion < 2002080300) { execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL "); execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL "); } - if ($oldversion < 2002082100) { execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL "); } - if ($oldversion < 2002082101) { execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` "); } if ($oldversion < 2002090100) { execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL "); } - if ($oldversion < 2002090701) { execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL "); execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` "); } - if ($oldversion < 2002090800) { execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` "); execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` "); @@ -77,6 +70,10 @@ function upgrade_moodle($oldversion=0) { if ($oldversion < 2002091400) { execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country` "); } + if ($oldversion < 2002091900) { + notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page."); + notify("Although it is not vital that you do so, you might want to edit config.php and remove all the unused settings (except the database, URL and directory definitions). See config-dist.php for an example of how your new slim config.php should look."); + } return true; }