Compare commits
95 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90b592bfaa | |||
| 09754fa2b7 | |||
| 4422bbfb20 | |||
| 816b5fe4bf | |||
| b315384965 | |||
| d678b11b8c | |||
| 03eca369af | |||
| 2ca880899c | |||
| 3ce0b09497 | |||
| 19ca7ac3b6 | |||
| 812a8400fb | |||
| 7e406f7840 | |||
| cc03ed4016 | |||
| b435823477 | |||
| 4ecd9d91e2 | |||
| 9770e27ece | |||
| 744950fa72 | |||
| 903c6f92b0 | |||
| ecf8f76345 | |||
| 67fc04383e | |||
| 2f4cf6638f | |||
| 1a559cb799 | |||
| bfd94e69c5 | |||
| af1cb63f72 | |||
| 9da3e73c1c | |||
| 3f1919774a | |||
| 91b08feca8 | |||
| 761be4c9f0 | |||
| 5cae766f70 | |||
| 0dd066c6c6 | |||
| 71ae822c8a | |||
| 575eba292a | |||
| 0a2294525c | |||
| 4b685ab2a3 | |||
| 00231a7498 | |||
| ad6c367583 | |||
| 7ffa4254e2 | |||
| 86fb51fe69 | |||
| bc05b1544d | |||
| e2d3d77173 | |||
| 6b63e94a29 | |||
| 350e44bf21 | |||
| f97355847a | |||
| ee84cd6c76 | |||
| 14824286cb | |||
| 3f4e0d9d6a | |||
| 2b8fb55a4d | |||
| aa55bb6666 | |||
| 90c644a587 | |||
| 30772a2aaf | |||
| 4287e72159 | |||
| 79b71ea0cd | |||
| 5180efaa90 | |||
| 1a55aa43a2 | |||
| eb34e77f15 | |||
| 935ba6ed19 | |||
| ea944efe7f | |||
| 4f8442c56d | |||
| fe544ceab4 | |||
| b65fdd3b54 | |||
| 6478428784 | |||
| 660381d2b0 | |||
| 65aede08b6 | |||
| cc1ec30e2d | |||
| 5f90f9fad6 | |||
| 60d17e47a0 | |||
| 94826e8e57 | |||
| ae39746289 | |||
| 49fe4f99e1 | |||
| 4997042474 | |||
| 1194026729 | |||
| 20761eb71d | |||
| 734bdb63bf | |||
| e0dd8f3260 | |||
| 578ba7762e | |||
| e044b5a536 | |||
| 63f6422df2 | |||
| 8097f8d7c7 | |||
| ac90c4a264 | |||
| 345692a64d | |||
| 86a8e9070b | |||
| 6555eabb0c | |||
| dcc6326eb9 | |||
| e8fb94a3cd | |||
| 79dd6106dd | |||
| 031dd5f017 | |||
| 507ee65e59 | |||
| 56b19c309e | |||
| 99dac04aeb | |||
| 12f18ea1ab | |||
| 1626376373 | |||
| 7729acff90 | |||
| b35cd9c592 | |||
| a69a278684 | |||
| 61cc70ae45 |
+51
-36
@@ -1,36 +1,51 @@
|
||||
README $Id$
|
||||
------
|
||||
|
||||
QUICK INSTALL
|
||||
=============
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
you through creating a config.php file and then
|
||||
setting up Moodle, creating an admin account etc.
|
||||
|
||||
4) Set up a cron task to call the file admin/cron.php
|
||||
every five minutes or so.
|
||||
|
||||
|
||||
For more information, see the INSTALL DOCUMENTATION:
|
||||
|
||||
http://docs.moodle.org/en/Installing_Moodle
|
||||
|
||||
A local copy can also be found in
|
||||
|
||||
lang/en_utf8/help/install.html (or your language)
|
||||
|
||||
|
||||
Good luck and have fun!
|
||||
Martin Dougiamas, Lead Developer
|
||||
|
||||
README $Id$
|
||||
------
|
||||
|
||||
If you are installing the first time, then you
|
||||
should read the installation guide which is
|
||||
part of the Moodle documentation (along with
|
||||
information about upgrading etc):
|
||||
|
||||
http://moodle.com/doc/
|
||||
|
||||
There is a copy of all this documentation as part of
|
||||
this Moodle distribution. You can access your local
|
||||
copy of the installation guide here:
|
||||
|
||||
lang/en/docs/install.html
|
||||
|
||||
Once Moodle is installed on your machine, then
|
||||
you can also access a local copy of all this
|
||||
documentation (localised to your language) at:
|
||||
|
||||
http://yourmoodlesite.com/doc/
|
||||
|
||||
|
||||
For the impatient, here is a basic outline of the
|
||||
installation process, which normally takes me only
|
||||
a few minutes:
|
||||
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create an empty directory somewhere to store
|
||||
uploaded files (NOT accessible via the web).
|
||||
This directory must be writeable by the web server
|
||||
process.
|
||||
|
||||
3) Create a single database for Moodle to store all
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
4) Copy the file config-dist.php to config.php, and
|
||||
edit it with all your own settings.
|
||||
|
||||
5) Visit your new home page with a web browser. Moodle
|
||||
will lead you through the rest of the setup,
|
||||
creating an admin account and so on.
|
||||
|
||||
6) Set up a cron task to call the file admin/cron.php
|
||||
every five minutes or so.
|
||||
|
||||
|
||||
Cheers!
|
||||
Martin Dougiamas
|
||||
|
||||
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign administrative rights to users
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
optional_variable($search, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// If you want any administrator to have the ability to assign admin
|
||||
/// rights, then comment out the following if statement
|
||||
if ($primaryadmin->id != $USER->id) {
|
||||
error("You must be the primary administrator to use this page.");
|
||||
}
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assignadmins",
|
||||
"administration",
|
||||
"existingadmins",
|
||||
"noexistingadmins",
|
||||
"potentialadmins",
|
||||
"nopotentialadmins",
|
||||
"addadmin",
|
||||
"removeadmin",
|
||||
"search",
|
||||
"searchagain",
|
||||
"toomanytoshow",
|
||||
"users",
|
||||
"searchresults"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "");
|
||||
|
||||
/// Add an admin if one is specified
|
||||
if (!empty($_GET['add'])) {
|
||||
if (! add_admin($add)) {
|
||||
error("Could not add that admin!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove an admin if one is specified.
|
||||
if (!empty($_GET['remove'])) {
|
||||
if (! remove_admin($remove)) {
|
||||
error("Could not remove that admin!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a help notice about this page
|
||||
if (empty($add) and empty($remove) and empty($search)) {
|
||||
print_simple_box("<center>".get_string("adminhelpassignadmins")."</center>", "center", "50%");
|
||||
}
|
||||
|
||||
/// Get all existing admins
|
||||
$admins = get_admins();
|
||||
|
||||
/// Print the lists of existing and potential admins
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingadmins</th><th width=50%>$strpotentialadmins</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing admins
|
||||
|
||||
if (! $admins) {
|
||||
echo "<p align=center>$strnoexistingadmins</p>";
|
||||
$adminlist = "";
|
||||
|
||||
} else {
|
||||
$adminarray = array();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
echo "<p align=right>".fullname($admin, true).",
|
||||
$admin->email ";
|
||||
if ($primaryadmin->id == $admin->id){
|
||||
print_spacer(10, 9, false);
|
||||
} else {
|
||||
echo "<a href=\"admin.php?remove=$admin->id\"
|
||||
title=\"$strremoveadmin\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></A>";
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
|
||||
$adminlist = implode(",",$adminarray);
|
||||
unset($adminarray);
|
||||
}
|
||||
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential admins
|
||||
|
||||
$usercount = get_users(false, $search, true, $adminlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialadmins</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow ($usercount) </p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $adminlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"admin.php?add=$user->id\"".
|
||||
"title=\"$straddadmin\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> ".fullname($user).", $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action=admin.php method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+164
-91
@@ -1,102 +1,175 @@
|
||||
<?php
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
/**
|
||||
* Allows admin to edit all auth plugin settings.
|
||||
*
|
||||
* JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
|
||||
*
|
||||
*/
|
||||
include("../config.php");
|
||||
require_login();
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$authsavailable = get_list_of_plugins('auth');
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
$authsenabled = array();
|
||||
} else {
|
||||
$authsenabled = explode(',', $CFG->auth);
|
||||
$config = (array)$config;
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
if (! set_config($name, $value)) {
|
||||
notify("Problem saving config $name as $value");
|
||||
}
|
||||
}
|
||||
redirect("auth.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
}
|
||||
|
||||
$modules = get_list_of_plugins("auth");
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("auth_$module"."title", "auth");
|
||||
}
|
||||
asort($options);
|
||||
if (isset($_GET['auth'])) {
|
||||
$auth = $_GET['auth'];
|
||||
} else {
|
||||
$auth = $config->auth;
|
||||
}
|
||||
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
|
||||
if (! isset($config->guestloginbutton)) {
|
||||
$config->guestloginbutton = 1;
|
||||
}
|
||||
if (! isset($config->auth_instructions)) {
|
||||
$config->auth_instructions = "";
|
||||
}
|
||||
if (! isset($config->changepassword)) {
|
||||
$config->changepassword = "";
|
||||
}
|
||||
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
foreach ($user_fields as $user_field) {
|
||||
$user_field = "auth_user_$user_field";
|
||||
if (! isset($config->$user_field)) {
|
||||
$config->$user_field = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$guestoptions[0] = get_string("hide");
|
||||
$guestoptions[1] = get_string("show");
|
||||
|
||||
$createoptions[0] = get_string("no");
|
||||
$createoptions[1] = get_string("yes");
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strauthentication = get_string("authentication");
|
||||
$strauthenticationoptions = get_string("authenticationoptions","auth");
|
||||
$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");
|
||||
|
||||
echo "<CENTER><P><B>";
|
||||
echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
print_string("chooseauthmethod","auth");
|
||||
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
|
||||
echo "</B></P></CENTER>";
|
||||
|
||||
print_simple_box_start("center", "100%", "$THEME->cellheading");
|
||||
print_heading($options[$auth]);
|
||||
|
||||
print_simple_box_start("center", "60%", "$THEME->cellcontent");
|
||||
print_string("auth_$auth"."description", "auth");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
print_heading($strsettings);
|
||||
|
||||
echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
|
||||
|
||||
require_once("$CFG->dirroot/auth/$auth/config.html");
|
||||
|
||||
if ($auth != "email" and $auth != "none" and $auth != "manual") {
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("changepassword", "auth");
|
||||
echo ":</p></td>";
|
||||
echo "<td>";
|
||||
echo "<input type=\"text\" name=\"changepassword\" size=40 value=\"$config->changepassword\">";
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("changepasswordhelp","auth");
|
||||
echo "</td></tr>";
|
||||
|
||||
}
|
||||
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("guestloginbutton", "auth");
|
||||
echo ":</p></td>";
|
||||
echo "<td>";
|
||||
choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("showguestlogin","auth");
|
||||
echo "</td></tr>";
|
||||
|
||||
if (function_exists('auth_user_create')){
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=right nowrap><p>";
|
||||
print_string("auth_user_create", "auth");
|
||||
echo ":</p></td>";
|
||||
echo "<td>";
|
||||
choose_from_menu($createoptions, "auth_user_create", $config->auth_user_create, "");
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
print_string("auth_user_creation","auth");
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
echo "</table><center><p><input type=\"submit\" value=\"";
|
||||
print_string("savechanges");
|
||||
echo "\"></p></center></form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
function validate_form(&$form, &$err) {
|
||||
|
||||
// if (empty($form->fullname))
|
||||
// $err["fullname"] = get_string("missingsitename");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
print_error('pluginnotinstalled', 'auth', $url, $auth);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
// remove from enabled list
|
||||
$key = array_search($auth, $authsenabled);
|
||||
if ($key !== false) {
|
||||
unset($authsenabled[$key]);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
|
||||
if ($auth == $CFG->registerauth) {
|
||||
set_config('registerauth', '');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
// add to enabled list
|
||||
if (!in_array($auth, $authsenabled)) {
|
||||
$authsenabled[] = $auth;
|
||||
$authsenabled = array_unique($authsenabled);
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $url, $auth);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key + 1];
|
||||
$authsenabled[$key + 1] = $fsave;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $url, $auth);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
$fsave = $authsenabled[$key];
|
||||
$authsenabled[$key] = $authsenabled[$key - 1];
|
||||
$authsenabled[$key - 1] = $fsave;
|
||||
set_config('auth', implode(',', $authsenabled));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
redirect ($returnurl);
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Edit configuration for an individual auth plugin
|
||||
*/
|
||||
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$auth = required_param('auth', PARAM_SAFEDIR);
|
||||
|
||||
$CFG->pagepath = 'auth/' . $auth;
|
||||
|
||||
admin_externalpage_setup('authsetting'.$auth);
|
||||
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
$err = array();
|
||||
|
||||
$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);
|
||||
|
||||
if (count($err) == 0) {
|
||||
|
||||
// save plugin config
|
||||
if ($authplugin->process_config($frm)) {
|
||||
|
||||
// save field lock configuration
|
||||
foreach ($frm as $name => $value) {
|
||||
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
|
||||
$plugin = "auth/$auth";
|
||||
$name = $matches[1];
|
||||
if (!set_config($name, $value, $plugin)) {
|
||||
error("Problem saving config $name as $value for plugin $plugin");
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect($returnurl);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$frm = get_config("auth/$auth");
|
||||
}
|
||||
|
||||
$user_fields = $authplugin->userfields;
|
||||
//$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "institution", "department", "address", "city", "country", "description", "idnumber", "lang");
|
||||
|
||||
/// Get the auth title (from core or own auth lang files)
|
||||
$authtitle = $authplugin->get_title();
|
||||
/// Get the auth descriptions (from core or own auth lang files)
|
||||
$authdescription = $authplugin->get_description();
|
||||
|
||||
// output configuration form
|
||||
admin_externalpage_print_header();
|
||||
|
||||
// choose an authentication method
|
||||
echo "<form $CFG->frametarget id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
|
||||
echo "<div>\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
|
||||
|
||||
// auth plugin description
|
||||
print_simple_box_start('center', '80%');
|
||||
print_heading($authtitle);
|
||||
print_simple_box_start('center', '80%', '', 5, 'informationbox');
|
||||
echo $authdescription;
|
||||
print_simple_box_end();
|
||||
echo "<hr />\n";
|
||||
$authplugin->config_form($frm, $err, $user_fields);
|
||||
print_simple_box_end();
|
||||
echo '<p style="text-align: center"><input type="submit" value="' . get_string("savechanges") . "\" /></p>\n";
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
// Good enough for most auth plugins
|
||||
// but some may want a custom one if they are offering
|
||||
// other options
|
||||
// Note: lockconfig_ fields have special handling.
|
||||
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
|
||||
|
||||
echo '<tr><td colspan="3">';
|
||||
if ($retrieveopts) {
|
||||
print_heading(get_string('auth_data_mapping', 'auth'));
|
||||
} else {
|
||||
print_heading(get_string('auth_fieldlocks', 'auth'));
|
||||
}
|
||||
echo '</td></tr>';
|
||||
|
||||
$lockoptions = array ('unlocked' => get_string('unlocked', 'auth'),
|
||||
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
|
||||
'locked' => get_string('locked', 'auth'));
|
||||
$updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'),
|
||||
'onlogin' => get_string('update_onlogin', 'auth'));
|
||||
$updateextoptions = array('0' => get_string('update_never', 'auth'),
|
||||
'1' => get_string('update_onupdate', 'auth'));
|
||||
|
||||
$pluginconfig = get_config("auth/$auth");
|
||||
|
||||
// helptext is on a field with rowspan
|
||||
if (empty($helptext)) {
|
||||
$helptext = ' ';
|
||||
}
|
||||
|
||||
foreach ($user_fields as $field) {
|
||||
|
||||
// Define some vars we'll work with
|
||||
if (!isset($pluginconfig->{"field_map_$field"})) {
|
||||
$pluginconfig->{"field_map_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_updatelocal_$field"})) {
|
||||
$pluginconfig->{"field_updatelocal_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_updateremote_$field"})) {
|
||||
$pluginconfig->{"field_updateremote_$field"} = '';
|
||||
}
|
||||
if (!isset($pluginconfig->{"field_lock_$field"})) {
|
||||
$pluginconfig->{"field_lock_$field"} = '';
|
||||
}
|
||||
|
||||
// define the fieldname we display to the user
|
||||
$fieldname = $field;
|
||||
if ($fieldname === 'lang') {
|
||||
$fieldname = get_string('language');
|
||||
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
|
||||
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
|
||||
} elseif ($fieldname == 'url') {
|
||||
$fieldname = get_string('webpage');
|
||||
} else {
|
||||
$fieldname = get_string($fieldname);
|
||||
}
|
||||
if ($retrieveopts) {
|
||||
$varname = 'field_map_' . $field;
|
||||
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="lockconfig_'.$varname.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
|
||||
echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
|
||||
echo '<div style="text-align: right">';
|
||||
echo '<label for="menulockconfig_field_updatelocal_'.$field.'">'.get_string('auth_updatelocal', 'auth') . '</label> ';
|
||||
choose_from_menu($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
|
||||
echo '<br />';
|
||||
if ($updateopts) {
|
||||
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label> ';
|
||||
choose_from_menu($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
|
||||
echo '<br />';
|
||||
|
||||
|
||||
}
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label> ';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<tr valign="top"><td align="right">';
|
||||
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
|
||||
echo '</td><td>';
|
||||
choose_from_menu($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
|
||||
}
|
||||
echo '</td>';
|
||||
if (!empty($helptext)) {
|
||||
echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
|
||||
$helptext = '';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?PHP // $Id$
|
||||
// backup.php - allows admin to edit all configuration variables for scheduled backups
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../backup/lib.php");
|
||||
require_once("../backup/backup_scheduled.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only an admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
//Initialise error variables
|
||||
$error = false;
|
||||
$sche_destination_error = "";
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
//First of all we check that everything is correct
|
||||
//Check for trailing slash and backslash in backup_sche_destination
|
||||
if (!empty($backup_sche_destination) and
|
||||
(substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) {
|
||||
$error = true;
|
||||
$sche_destination_error = get_string("pathslasherror");
|
||||
//Now check that backup_sche_destination dir exists
|
||||
} else if (!empty($backup_sche_destination) and
|
||||
!is_dir($backup_sche_destination)) {
|
||||
$error = true;
|
||||
$sche_destination_error = get_string("pathnotexists");
|
||||
}
|
||||
|
||||
//We need to do some weekdays conversions prior to continue
|
||||
$i = 0;
|
||||
$temp = "";
|
||||
$a_config = (array)$config;
|
||||
while ($i<7) {
|
||||
$tocheck = "dayofweek_".$i;
|
||||
if (isset($a_config[$tocheck])) {
|
||||
$temp .= "1";
|
||||
} else {
|
||||
$temp .= "0";
|
||||
}
|
||||
unset($a_config[$tocheck]);
|
||||
$i++;
|
||||
}
|
||||
$a_config['backup_sche_weekdays'] = $temp;
|
||||
$config = (object)$a_config;
|
||||
//weekdays conversions done. Continue
|
||||
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
backup_set_config($name, $value);
|
||||
}
|
||||
|
||||
//And now, we execute schedule_backup_next_execution() for each course in the server to have the next
|
||||
//execution time updated automatically everytime it's changed.
|
||||
$status = true;
|
||||
//get admin
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
$status = false;
|
||||
}
|
||||
//get backup config
|
||||
if (! $backup_config = backup_get_config()) {
|
||||
$status = false;
|
||||
}
|
||||
if ($status) {
|
||||
//get courses
|
||||
if ($courses = get_records("course")) {
|
||||
//For each course, we check (insert, update) the backup_course table
|
||||
//with needed data
|
||||
foreach ($courses as $course) {
|
||||
//We check if the course exists in backup_course
|
||||
$backup_course = get_record("backup_courses","courseid",$course->id);
|
||||
//If it doesn't exist, create
|
||||
if (!$backup_course) {
|
||||
$temp_backup_course->courseid = $course->id;
|
||||
$newid = insert_record("backup_courses",$temp_backup_course);
|
||||
//And get it from db
|
||||
$backup_course = get_record("backup_courses","id",$newid);
|
||||
}
|
||||
//Now, calculate next execution of the course
|
||||
$nextstarttime = schedule_backup_next_execution ($backup_course,$backup_config,time(),$admin->timezone);
|
||||
//Save it to db
|
||||
set_field("backup_courses","nextstarttime",$nextstarttime,"courseid",$backup_course->courseid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strbackup = get_string("backup");
|
||||
|
||||
print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
$strbackup);
|
||||
|
||||
echo "<p align=right><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
|
||||
|
||||
print_heading($strbackup);
|
||||
|
||||
print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
//Check for required functions...
|
||||
if(!function_exists('utf8_encode')) {
|
||||
print_simple_box("<font color=\"red\">You need to add XML support to your PHP installation</font>", "center", "70%", "$THEME->cellheading", "20", "noticebox");
|
||||
}
|
||||
include ("$CFG->dirroot/backup/config.html");
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+29
-39
@@ -3,68 +3,58 @@
|
||||
// block.php - allows admin to edit all local configuration variables for a block
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
$blockid = required_param('block', PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if(!$blockrecord = blocks_get_record($blockid)) {
|
||||
if (!isadmin()) {
|
||||
error('Only an admin can use this page');
|
||||
}
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
require_variable($_REQUEST['block']);
|
||||
$blockid = intval($_REQUEST['block']);
|
||||
|
||||
if(($blockrecord = get_record('blocks', 'id', $blockid)) === false) {
|
||||
error('This block does not exist');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
||||
|
||||
$block = block_instance($blockrecord->name);
|
||||
$block = block_instance($blockrecord->name, NULL);
|
||||
if($block === false) {
|
||||
error('Problem in instantiating block object');
|
||||
}
|
||||
|
||||
// Define the data we're going to silently include in the instance config form here,
|
||||
// so we can strip them from the submitted data BEFORE handling it.
|
||||
$hiddendata = array(
|
||||
'block' => $blockid,
|
||||
'sesskey' => $USER->sesskey
|
||||
);
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if(!$block->has_config()) {
|
||||
error('This block does not support global configuration');
|
||||
}
|
||||
$remove = array_keys($hiddendata);
|
||||
foreach($remove as $item) {
|
||||
unset($config->$item);
|
||||
}
|
||||
$block->config_save($config);
|
||||
if ($config = data_submitted()) {
|
||||
unset($config['block']); // This will always be set if we have reached this point
|
||||
$block->handle_config($config);
|
||||
print_header();
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
/// Otherwise print the form.
|
||||
|
||||
$stradmin = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strblockname = $block->get_title();
|
||||
|
||||
admin_externalpage_print_header();
|
||||
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);
|
||||
|
||||
print_heading($strblockname);
|
||||
|
||||
print_simple_box(get_string('configwarning', 'admin'), 'center', '50%');
|
||||
print_simple_box('<center>'.get_string('configwarning').'</center>', 'center', '50%');
|
||||
echo '<br />';
|
||||
|
||||
echo '<form method="post" action="block.php">';
|
||||
echo '<p>';
|
||||
foreach($hiddendata as $name => $val) {
|
||||
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
|
||||
}
|
||||
echo '</p>';
|
||||
$block->config_print();
|
||||
echo '</form>';
|
||||
$block->print_config();
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+82
-165
@@ -3,111 +3,97 @@
|
||||
// Allows the admin to configure blocks (hide/show, delete and configure)
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
|
||||
admin_externalpage_setup('manageblocks');
|
||||
optional_variable($_GET['hide']);
|
||||
optional_variable($_GET['show']);
|
||||
optional_variable($_GET['delete']);
|
||||
optional_variable($_GET['confirm'], 0);
|
||||
$delete = $_GET['delete']; // Dependency remover
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmanageblocks = get_string('manageblocks');
|
||||
$strdelete = get_string('delete');
|
||||
$strversion = get_string('version');
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
$strsettings = get_string('settings');
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strcourses = get_string('courses');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
|
||||
print_header("$site->shortname: $strmanageblocks", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanageblocks");
|
||||
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
if (!$block = get_record('block', 'id', $hide)) {
|
||||
if (!empty($_GET['hide'])) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['hide'])) {
|
||||
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
|
||||
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block
|
||||
}
|
||||
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
if (!$block = get_record('block', 'id', $show)) {
|
||||
if (!empty($_GET['show'])) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['show'])) {
|
||||
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
|
||||
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block
|
||||
}
|
||||
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
if (!empty($delete)) {
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
if (!$block = get_record('blocks', 'id', $delete)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
|
||||
if (!block_is_compatible($block->name)) {
|
||||
$strblockname = $block->name;
|
||||
}
|
||||
else {
|
||||
$blockobject = block_instance($block->name);
|
||||
$strblockname = $blockobject->get_title();
|
||||
}
|
||||
$blockobject = block_instance($block->name, $site);
|
||||
$strblockname = $blockobject->get_title();
|
||||
|
||||
if (!$confirm) {
|
||||
if (!$_GET['confirm']) {
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php?delete='.$block->id.'&confirm=1',
|
||||
'blocks.php');
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// Inform block it's about to be deleted
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
|
||||
// First delete instances and then block
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
blocks_delete_instance($instance, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete block
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
if (!delete_records('blocks', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
drop_plugin_tables($block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false); // old obsoleted table names
|
||||
drop_plugin_tables('block_'.$block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false);
|
||||
blocks_update_every_block_by_id($block->id, 'delete'); // Delete blocks in all courses by id
|
||||
|
||||
// Delete the capabilities that were defined by this block
|
||||
capabilities_cleanup('block/'.$block->name);
|
||||
// Then the tables themselves
|
||||
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('block/'.$block->name);
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$block->name;
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table, $prefix) === 0) {
|
||||
if (!execute_sql("DROP TABLE $table", false)) {
|
||||
notify("ERROR: while trying to drop table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$a->block = $strblockname;
|
||||
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
|
||||
@@ -115,141 +101,72 @@
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading($strmanageblocks);
|
||||
|
||||
/// Main display starts here
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (false === ($blocks = get_records('block'))) {
|
||||
if (!$blocks = get_records('blocks')) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
$incompatible = array();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(!block_is_compatible($block->name)) {
|
||||
notify('Block '. $block->name .' is not compatible with the current version of Moodle and needs to be updated by a programmer.');
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
if(($blockobject = block_instance($block->name, NULL)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
$blockbyname[$blockobject->get_title()] = $block->id;
|
||||
$blockobjects[$block->id] = $blockobject;
|
||||
}
|
||||
|
||||
if(empty($blockbyname)) {
|
||||
error('One or more blocks are registered in the database, but they all failed to load!');
|
||||
}
|
||||
|
||||
ksort($blockbyname);
|
||||
|
||||
/// Print the table of all blocks
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = '../pix';
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$modpixpath = '../mod';
|
||||
} else {
|
||||
$pixpath = '../theme/'.$CFG->theme.'/pix';
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$modpixpath = '../theme/'.$CFG->theme.'/pix/mod';
|
||||
}
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'multiple', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
$table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings);
|
||||
$table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER');
|
||||
$table->wrap = array ("NOWRAP", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
// [pj] This is not used anywhere, but I'm leaving it in for the future
|
||||
//$icon = "<img src=\"$modpixpath/$block->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
$block = $blocks[$blockid];
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
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>';
|
||||
}
|
||||
if($blockobject->has_config()) {
|
||||
$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
|
||||
WHERE blockid = '.$blockid.' AND
|
||||
pagetype = \'course-view\'');
|
||||
|
||||
if ($count>0) {
|
||||
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&sesskey={$USER->sesskey}\" ";
|
||||
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";
|
||||
}
|
||||
else {
|
||||
$blocklist = "$totalcount";
|
||||
}
|
||||
$count = blocks_get_courses_using_block_by_id($blockid);
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon" alt="'.$strhide.'" /></a>';
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$pixpath.'/i/hide.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon" alt="'.$strshow.'" /></a>';
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
if ($blockobject->instance_allow_multiple()) {
|
||||
if($blocks[$blockid]->multiple) {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
else {
|
||||
$multiple = '<span style="white-space: nowrap;">'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</span>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$multiple = '';
|
||||
}
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$blockobject->get_title().'</span>',
|
||||
$blocklist,
|
||||
'<span'.$class.'>'.$blockobject->get_version().'</span>',
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
$table->data[] = array ('<p'.$class.'>'.$blockobject->get_title().'</p>', $count, $blockobject->get_version(), $visible, $delete, $settings);
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
if(!empty($incompatible)) {
|
||||
print_heading(get_string('incompatibleblocks', 'admin'));
|
||||
|
||||
$table = new flexible_table('admin-blocks-incompatible');
|
||||
|
||||
$table->define_columns(array('block', 'delete'));
|
||||
$table->define_headers(array($strname, $strdelete));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
|
||||
$table->set_attribute('id', 'incompatible');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
$table->setup();
|
||||
|
||||
foreach ($incompatible as $block) {
|
||||
$table->add_data(array(
|
||||
$block->name,
|
||||
'<a href="blocks.php?delete='.$block->id.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>',
|
||||
));
|
||||
}
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
echo '<p>';
|
||||
print_table($table);
|
||||
echo '</p>';
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
<form method="post" action="config.php" name="form">
|
||||
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><p>lang:</td>
|
||||
<td>
|
||||
<?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlang") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langmenu:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "langmenu", $config->langmenu, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlangmenu") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langlist:</td>
|
||||
<td>
|
||||
<input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlanglist") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>locale:</td>
|
||||
<td>
|
||||
<input name=locale type=text size=10 value="<?php p($config->locale) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlocale") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>timezone:</td>
|
||||
<td><?php
|
||||
if (abs($config->timezone) > 13) {
|
||||
$config->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
choose_from_menu ($timezones, "timezone", $config->timezone, get_string("serverlocaltime"), "", "99");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configtimezone") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>country:</td>
|
||||
<td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configcountry") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtphosts:</td>
|
||||
<td>
|
||||
<input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsmtphosts") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtpuser:</td>
|
||||
<td>
|
||||
<input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configsmtpuser") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtppass:</td>
|
||||
<td>
|
||||
<input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
|
||||
</td>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>gdversion:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("gdnot");
|
||||
$options[1] = get_string("gd1");
|
||||
$options[2] = get_string("gd2");
|
||||
|
||||
$installed = check_gd_version();
|
||||
|
||||
choose_from_menu ($options, "gdversion", $installed, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configgdversion") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>htmleditor:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
$options[1] = get_string("allow");
|
||||
choose_from_menu ($options, "htmleditor", $config->htmleditor, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confightmleditor") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxeditingtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[3600] = get_string("numminutes", "", 60);
|
||||
$options[2700] = get_string("numminutes", "", 45);
|
||||
$options[1800] = get_string("numminutes", "", 30);
|
||||
$options[900] = get_string("numminutes", "", 15);
|
||||
$options[300] = get_string("numminutes", "", 5);
|
||||
$options[60] = get_string("numminutes", "", 1);
|
||||
|
||||
choose_from_menu ($options, "maxeditingtime", $config->maxeditingtime, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configmaxeditingtime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>longtimenosee:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
$options[365] = get_string("numdays", "", 365);
|
||||
$options[180] = get_string("numdays", "", 180);
|
||||
$options[150] = get_string("numdays", "", 150);
|
||||
$options[120] = get_string("numdays", "", 120);
|
||||
$options[90] = get_string("numdays", "", 90);
|
||||
$options[60] = get_string("numdays", "", 60);
|
||||
$options[30] = get_string("numdays", "", 30);
|
||||
$options[21] = get_string("numdays", "", 21);
|
||||
$options[14] = get_string("numdays", "", 14);
|
||||
$options[7] = get_string("numdays", "", 7);
|
||||
|
||||
choose_from_menu ($options, "longtimenosee", $config->longtimenosee, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configlongtimenosee") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>deleteunconfirmed:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("never");
|
||||
$options[168] = get_string("numdays", "", 7);
|
||||
$options[144] = get_string("numdays", "", 6);
|
||||
$options[120] = get_string("numdays", "", 5);
|
||||
$options[96] = get_string("numdays", "", 4);
|
||||
$options[72] = get_string("numdays", "", 3);
|
||||
$options[48] = get_string("numdays", "", 2);
|
||||
$options[24] = get_string("numdays", "", 1);
|
||||
$options[12] = get_string("numhours", "", 12);
|
||||
$options[6] = get_string("numhours", "", 6);
|
||||
$options[1] = get_string("numhours", "", 1);
|
||||
|
||||
choose_from_menu ($options, "deleteunconfirmed", $config->deleteunconfirmed, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdeleteunconfirmed") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>loglifetime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("neverdeletelogs");
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
$options[365] = get_string("numdays", "", 365);
|
||||
$options[180] = get_string("numdays", "", 180);
|
||||
$options[150] = get_string("numdays", "", 150);
|
||||
$options[120] = get_string("numdays", "", 120);
|
||||
$options[90] = get_string("numdays", "", 90);
|
||||
$options[60] = get_string("numdays", "", 60);
|
||||
$options[30] = get_string("numdays", "", 30);
|
||||
|
||||
choose_from_menu ($options, "loglifetime", $config->loglifetime, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configloglifetime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessiontimeout:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[14400] = get_string("numhours", "", 4);
|
||||
$options[10800] = get_string("numhours", "", 3);
|
||||
$options[7200] = get_string("numhours", "", 2);
|
||||
$options[5400] = get_string("numhours", "", "1.5");
|
||||
$options[3600] = get_string("numminutes", "", 60);
|
||||
$options[2700] = get_string("numminutes", "", 45);
|
||||
$options[1800] = get_string("numminutes", "", 30);
|
||||
$options[900] = get_string("numminutes", "", 15);
|
||||
$options[300] = get_string("numminutes", "", 5);
|
||||
|
||||
choose_from_menu ($options, "sessiontimeout", $config->sessiontimeout, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsessiontimeout") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessioncookie:</td>
|
||||
<td>
|
||||
<input name=sessioncookie type=text size=10 value="<?php p($config->sessioncookie)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsessioncookie") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>zip:</td>
|
||||
<td>
|
||||
<input name=zip type=text size=30 value="<?php p($config->zip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>unzip:</td>
|
||||
<td>
|
||||
<input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configunzip") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>slasharguments:</td>
|
||||
<td>
|
||||
<?php unset($options);
|
||||
$options[0] = "file.php?file=/pic.jpg";
|
||||
$options[1] = "file.php/pic.jpg";
|
||||
|
||||
choose_from_menu ($options, "slasharguments", $config->slasharguments, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configslasharguments") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyhost:</td>
|
||||
<td>
|
||||
<input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
<?php print_string("configproxyhost") ?>
|
||||
</td>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyport:</td>
|
||||
<td>
|
||||
<input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>debug:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[7] = get_string("no");
|
||||
$options[15] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "debug", $config->debug, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdebug") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>framename:</td>
|
||||
<td>
|
||||
<?php
|
||||
if (empty($config->framename)) {
|
||||
$config->framename = "_top";
|
||||
}
|
||||
?>
|
||||
<input name=framename type=text size=15 value="<?php p($config->framename)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configframename") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>secureforms:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "secureforms", $config->secureforms, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configsecureforms") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>teacherassignteachers:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "teacherassignteachers", $config->teacherassignteachers, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configteacherassignteachers") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>allowunenroll:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "allowunenroll", $config->allowunenroll, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configallowunenroll") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxbytes:</td>
|
||||
<td>
|
||||
<?php
|
||||
$options = get_max_upload_sizes();
|
||||
choose_from_menu ($options, "maxbytes", $config->maxbytes, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configmaxbytes") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>fullnamedisplay:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options['language'] = get_string('language');
|
||||
$options['firstname lastname'] = get_string('firstname') . ' + ' . get_string('lastname');
|
||||
$options['lastname firstname'] = get_string('lastname') . ' + ' . get_string('firstname');
|
||||
$options['firstname'] = get_string('firstname');
|
||||
|
||||
choose_from_menu ($options, "fullnamedisplay", $config->fullnamedisplay, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configfullnamedisplay") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>extendedusernamechars:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "extendedusernamechars", $config->extendedusernamechars, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configextendedusernamechars") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forcelogin:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "forcelogin", $config->forcelogin, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configforcelogin") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forceloginforprofiles:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "forceloginforprofiles", $config->forceloginforprofiles, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configforceloginforprofiles") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>opentogoogle:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "opentogoogle", $config->opentogoogle, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configopentogoogle") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>enablerssfeeds:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "enablerssfeeds", $config->enablerssfeeds, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
print_string("configenablerssfeeds");
|
||||
//Check for required functions...
|
||||
if(!function_exists('utf8_encode')) {
|
||||
echo "<font color=\"red\"> You need to add XML support to your PHP installation.</font>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=3 align=center>
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?PHP // $Id$
|
||||
// config.php - allows admin to edit all configuration variables
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
}
|
||||
|
||||
/// This is to overcome the "insecure forms paradox"
|
||||
if (isset($secureforms) and $secureforms == 0) {
|
||||
$match = "nomatch";
|
||||
} else {
|
||||
$match = "";
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted($match)) {
|
||||
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
if ($name == "sessioncookie") {
|
||||
$value = eregi_replace("[^a-zA-Z]", "", $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("index.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if (empty($config)) {
|
||||
$config = $CFG;
|
||||
if (!$config->locale = get_field("config", "value", "name", "locale")) {
|
||||
$config->locale = $CFG->lang;
|
||||
}
|
||||
}
|
||||
if (empty($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strconfigvariables = get_string("configvariables");
|
||||
|
||||
if ($site) {
|
||||
print_header("$site->shortname: $strconfigvariables", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strconfigvariables", $focus);
|
||||
print_heading($strconfigvariables);
|
||||
} else {
|
||||
print_header();
|
||||
print_heading($strconfigvariables);
|
||||
print_simple_box(get_string("configintro"), "center", "50%");
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
if ($site) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
function validate_form(&$form, &$err) {
|
||||
|
||||
// if (empty($form->fullname))
|
||||
// $err["fullname"] = get_string("missingsitename");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
|
||||
print_header("$site->shortname: $stradministration: $strconfiguration", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strconfiguration");
|
||||
|
||||
print_heading($strconfiguration);
|
||||
|
||||
$table->align = array ("right", "left");
|
||||
|
||||
$table->data[] = array("<b><a href=\"config.php\">".get_string("configvariables")."</a></b>",
|
||||
get_string("adminhelpconfigvariables"));
|
||||
$table->data[] = array("<b><a href=\"site.php\">".get_string("sitesettings")."</a></b>",
|
||||
get_string("adminhelpsitesettings"));
|
||||
$table->data[] = array("<b><a href=\"../theme/index.php\">".get_string("themes")."</a></b>",
|
||||
get_string("adminhelpthemes"));
|
||||
$table->data[] = array("<b><a href=\"lang.php\">".get_string("language")."</a></b>",
|
||||
get_string("adminhelplanguage"));
|
||||
$table->data[] = array("<b><a href=\"modules.php\">".get_string("managemodules")."</a></b>",
|
||||
get_string("adminhelpmanagemodules"));
|
||||
$table->data[] = array("<b><a href=\"blocks.php\">".get_string("manageblocks")."</a></b>",
|
||||
get_string("adminhelpmanageblocks"));
|
||||
$table->data[] = array("<b><a href=\"filters.php\">".get_string("managefilters")."</a></b>",
|
||||
get_string("adminhelpmanagefilters"));
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$table->data[] = array("<b><a href=\"backup.php\">".get_string("backup")."</a></b>",
|
||||
get_string("adminhelpbackup"));
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
<?PHP // $Id$
|
||||
// Admin only script to assign course creator rights to users
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 50);
|
||||
|
||||
optional_variable($search, "");
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
$stringstoload = array (
|
||||
"assigncreators",
|
||||
"administration",
|
||||
"existingcreators",
|
||||
"noexistingcreators",
|
||||
"potentialcreators",
|
||||
"nopotentialcreators",
|
||||
"addcreator",
|
||||
"removecreator",
|
||||
"search",
|
||||
"searchagain",
|
||||
"users",
|
||||
"toomanytoshow",
|
||||
"searchresults"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
$strstringtoload = "str" . $stringtoload;
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
|
||||
$strassigncreators", "");
|
||||
|
||||
/// Add a creator if one is specified
|
||||
|
||||
if (!empty($_GET['add'])) {
|
||||
if (! add_creator($add)) {
|
||||
error("Could not add that creator!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove a creator if one is specified.
|
||||
|
||||
if (!empty($_GET['remove'])) {
|
||||
if (! remove_creator($remove)) {
|
||||
error("Could not remove that creator!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a help notice about this page
|
||||
if (empty($add) and empty($remove) and empty($search)) {
|
||||
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
|
||||
}
|
||||
|
||||
/// Get all existing creators
|
||||
$creators = get_creators();
|
||||
|
||||
/// Print the lists of existing and potential creators
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingcreators</th><th width=50%>$strpotentialcreators</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing creators
|
||||
|
||||
if (! $creators) {
|
||||
echo "<p align=center>$strnoexistingcreators</a>";
|
||||
|
||||
$creatorlist = "";
|
||||
|
||||
} else {
|
||||
$creatorarray = array();
|
||||
foreach ($creators as $creator) {
|
||||
$creatorarray[] = $creator->id;
|
||||
echo "<p align=right>".fullname($creator, true).", $creator->email ";
|
||||
echo "<a href=\"creators.php?remove=$creator->id\"
|
||||
title=\"$strremovecreator\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></a>";
|
||||
echo "</p>";
|
||||
}
|
||||
$creatorlist = implode(",",$creatorarray);
|
||||
unset($creatorarray);
|
||||
}
|
||||
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential creators
|
||||
|
||||
$usercount = get_users(false, $search, true, $creatorlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialcreators</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow ($usercount) </p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $creatorlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, TRUE);
|
||||
echo "<p align=left><a href=\"creators.php?add=$user->id\"".
|
||||
"title=\"$straddcreator\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $fullname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action=creators.php method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
+64
-435
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
/// This script looks through all the module directories for cron.php files
|
||||
/// and runs them. These files can contain cleanup functions, email functions
|
||||
@@ -10,18 +10,11 @@
|
||||
///
|
||||
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
/// or php /web/moodle/admin/cron.php
|
||||
set_time_limit(0);
|
||||
|
||||
$FULLME = "cron";
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
/// The following is a hack necessary to allow this script to work well
|
||||
/// from the command line.
|
||||
|
||||
define('FULLME', 'cron');
|
||||
|
||||
|
||||
/// Do not set moodle cookie because we do not need it here, it is better to emulate session
|
||||
$nomoodlecookie = true;
|
||||
|
||||
|
||||
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
/// directory of the script when run from the command line. The require_once()
|
||||
/// would fail, so we'll have to chdir()
|
||||
@@ -30,199 +23,39 @@
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
/// Extra debugging (set in config.php)
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$db->debug = true;
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
$CFG->debug = DEBUG_DEVELOPER;
|
||||
$CFG->displaydebug = true;
|
||||
if (!$alreadyadmin = isadmin()) {
|
||||
unset($_SESSION['USER']);
|
||||
unset($USER);
|
||||
unset($_SESSION['SESSION']);
|
||||
unset($SESSION);
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
}
|
||||
|
||||
/// extra safety
|
||||
@session_write_close();
|
||||
|
||||
/// check if execution allowed
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) { // if the script is accessed via the web.
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
// This script can only be run via the cli.
|
||||
print_error('cronerrorclionly', 'admin');
|
||||
exit;
|
||||
}
|
||||
// This script is being called via the web, so check the password if there is one.
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$pass = optional_param('password', '', PARAM_RAW);
|
||||
if($pass != $CFG->cronremotepassword) {
|
||||
// wrong password.
|
||||
print_error('cronerrorpassword', 'admin');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// emulate normal session
|
||||
$SESSION = new object();
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
|
||||
/// ignore admins timezone, language and locale - use site deafult instead!
|
||||
$USER->timezone = $CFG->timezone;
|
||||
$USER->lang = '';
|
||||
$USER->theme = '';
|
||||
course_setup(SITEID);
|
||||
|
||||
/// send mime type and encoding
|
||||
if (check_browser_version('MSIE')) {
|
||||
//ugly IE hack to work around downloading instead of viewing
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<xmp>"; //<pre> is not good enough for us here
|
||||
} else {
|
||||
//send proper plaintext header
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
/// no more headers and buffers
|
||||
while(@ob_end_flush());
|
||||
|
||||
/// increase memory limit (PHP 5.2 does different calculation, we need more memory now)
|
||||
@raise_memory_limit('128M');
|
||||
|
||||
/// Start output log
|
||||
echo "<pre>\n";
|
||||
|
||||
$timenow = time();
|
||||
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
echo "Server Time: ".date('r',$timenow)."\n\n";
|
||||
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
mtrace("Starting activity modules");
|
||||
get_mailer('buffer');
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1 ")) {
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
foreach ($mods as $mod) {
|
||||
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
|
||||
if (file_exists($libfile)) {
|
||||
include_once($libfile);
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(1);
|
||||
}
|
||||
if ($cron_function()) {
|
||||
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
|
||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
||||
echo "Error: could not update timestamp for $mod->fullname\n";
|
||||
}
|
||||
}
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
|
||||
}
|
||||
/// Reset possible changes by modules to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace("done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get_mailer('close');
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
mtrace("Starting blocks");
|
||||
if ($blocks = get_records_select("block", "cron > 0 AND (($timenow - lastcron) > cron) AND visible = 1")) {
|
||||
// we will need the base class.
|
||||
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
||||
foreach ($blocks as $block) {
|
||||
$blockfile = $CFG->dirroot.'/blocks/'.$block->name.'/block_'.$block->name.'.php';
|
||||
if (file_exists($blockfile)) {
|
||||
require_once($blockfile);
|
||||
$classname = 'block_'.$block->name;
|
||||
$blockobj = new $classname;
|
||||
if (method_exists($blockobj,'cron')) {
|
||||
mtrace("Processing cron function for ".$block->name.'....','');
|
||||
if ($blockobj->cron()) {
|
||||
if (!set_field('block','lastcron',$timenow,'id',$block->id)) {
|
||||
mtrace('Error: could not update timestamp for '.$block->name);
|
||||
}
|
||||
}
|
||||
/// Reset possible changes by blocks to time_limit. MDL-11597
|
||||
@set_time_limit(0);
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
mtrace('Finished blocks');
|
||||
|
||||
mtrace('Starting admin reports');
|
||||
// Admin reports do not have a database table that lists them. Instead a
|
||||
// report includes cron.php with function report_reportname_cron() if it wishes
|
||||
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
|
||||
// actually do anything occasionally.
|
||||
$reports = get_list_of_plugins($CFG->admin.'/report');
|
||||
foreach($reports as $report) {
|
||||
$cronfile = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$report.'/cron.php';
|
||||
if (file_exists($cronfile)) {
|
||||
require_once($cronfile);
|
||||
$cronfunction = 'report_'.$report.'_cron';
|
||||
mtrace('Processing cron function for '.$report.'...', '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(true);
|
||||
}
|
||||
$cronfunction();
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
mtrace('Finished admin reports');
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages(true);
|
||||
}
|
||||
|
||||
mtrace('Removing expired enrolments ...', ''); // See MDL-8785
|
||||
$timenow = time();
|
||||
$somefound = false;
|
||||
// The preferred way saves memory, dmllib.php
|
||||
// find courses where limited enrolment is enabled
|
||||
global $CFG;
|
||||
$rs_enrol = get_recordset_sql("SELECT ra.roleid, ra.userid, ra.contextid
|
||||
FROM {$CFG->prefix}course c
|
||||
INNER JOIN {$CFG->prefix}context cx ON cx.instanceid = c.id
|
||||
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.contextid = cx.id
|
||||
WHERE cx.contextlevel = '".CONTEXT_COURSE."'
|
||||
AND ra.timeend > 0
|
||||
AND ra.timeend < '$timenow'
|
||||
AND c.enrolperiod > 0
|
||||
");
|
||||
while ($oldenrolment = rs_fetch_next_record($rs_enrol)) {
|
||||
role_unassign($oldenrolment->roleid, $oldenrolment->userid, 0, $oldenrolment->contextid);
|
||||
$somefound = true;
|
||||
}
|
||||
rs_close($rs_enrol);
|
||||
if($somefound) {
|
||||
mtrace('Done');
|
||||
} else {
|
||||
mtrace('none found');
|
||||
}
|
||||
|
||||
|
||||
mtrace('Starting main gradebook job ...');
|
||||
grade_cron();
|
||||
mtrace('done.');
|
||||
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
@@ -232,170 +65,69 @@
|
||||
$random100 = rand(0,100);
|
||||
|
||||
if ($random100 < 20) { // Approximately 20% of the time.
|
||||
mtrace("Running clean-up tasks...");
|
||||
echo "Running clean-up tasks...\n";
|
||||
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$cuttime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (role_unassign(0, $assign->userid, 0, $context->id)) {
|
||||
mtrace("Deleted assignment for user $assign->userid from course $assign->courseid");
|
||||
$longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
if ($students = get_users_longtimenosee($longtime)) {
|
||||
foreach ($students as $student) {
|
||||
if (unenrol_student($student->userid, $student->course)) {
|
||||
echo "Deleted student enrolment for user $student->userid from course $student->course\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
/// Execute the same query again, looking for remaining records and deleting them
|
||||
/// if the user hasn't moodle/course:view in the CONTEXT_COURSE context (orphan records)
|
||||
$rs = get_recordset_sql ("SELECT id, userid, courseid
|
||||
FROM {$CFG->prefix}user_lastaccess
|
||||
WHERE courseid != ".SITEID."
|
||||
AND timeaccess < $cuttime ");
|
||||
while ($assign = rs_fetch_next_record($rs)) {
|
||||
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
|
||||
if (!has_capability('moodle/course:view', $context, $assign->userid)) {
|
||||
delete_records('user_lastaccess', 'userid', $assign->userid, 'courseid', $assign->courseid);
|
||||
mtrace("Deleted orphan user_lastaccess for user $assign->userid from course $assign->courseid");
|
||||
}
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
|
||||
/// Delete users who haven't confirmed within required period
|
||||
|
||||
if (!empty($CFG->deleteunconfirmed)) {
|
||||
$cuttime = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, firstname, lastname
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 0
|
||||
AND firstaccess > 0
|
||||
AND firstaccess < $cuttime");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_records('user', 'id', $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
|
||||
if ($users = get_users_unconfirmed($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records("user", "id", $user->id)) {
|
||||
echo "Deleted unconfirmed user for ".fullname($user, true)." ($user->id)\n";
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete users who haven't completed profile within required period
|
||||
|
||||
if (!empty($CFG->deleteincompleteusers)) {
|
||||
$cuttime = $timenow - ($CFG->deleteincompleteusers * 3600);
|
||||
$rs = get_recordset_sql ("SELECT id, username
|
||||
FROM {$CFG->prefix}user
|
||||
WHERE confirmed = 1
|
||||
AND lastaccess > 0
|
||||
AND lastaccess < $cuttime
|
||||
AND deleted = 0
|
||||
AND (lastname = '' OR firstname = '' OR email = '')");
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (delete_user($user)) {
|
||||
mtrace("Deleted not fully setup user $user->username ($user->id)");
|
||||
}
|
||||
|
||||
|
||||
/// Delete duplicate enrolments (don't know what causes these yet - expired sessions?)
|
||||
|
||||
if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
|
||||
"HAVING count(*) > 1", "", "*,count(*)")) {
|
||||
foreach ($users as $user) {
|
||||
delete_records_select("user_students", "userid = '$user->userid' ".
|
||||
"AND course = '$user->course' AND id <> '$user->id'");
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
|
||||
|
||||
/// Delete old logs to save space (this might need a timer to slow it down...)
|
||||
|
||||
|
||||
if (!empty($CFG->loglifetime)) { // value in days
|
||||
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
|
||||
if (delete_records_select("log", "time < '$loglifetime'")) {
|
||||
mtrace("Deleted old log records");
|
||||
}
|
||||
delete_records_select("log", "time < '$loglifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete old cached texts
|
||||
|
||||
if (!empty($CFG->cachetext)) { // Defined in config.php
|
||||
$cachelifetime = time() - $CFG->cachetext - 60; // Add an extra minute to allow for really heavy sites
|
||||
if (delete_records_select('cache_text', "timemodified < '$cachelifetime'")) {
|
||||
mtrace("Deleted old cache_text records");
|
||||
}
|
||||
$cachelifetime = time() - $CFG->cachetext;
|
||||
delete_records_select("cache_text", "timemodified < '$cachelifetime'");
|
||||
}
|
||||
flush();
|
||||
}
|
||||
|
||||
if (!empty($CFG->notifyloginfailures)) {
|
||||
notify_login_failures();
|
||||
mtrace('Notified login failured');
|
||||
}
|
||||
flush();
|
||||
if (file_exists("$CFG->dataroot/cronextra.php")) {
|
||||
include("$CFG->dataroot/cronextra.php");
|
||||
}
|
||||
|
||||
sync_metacourses();
|
||||
mtrace('Synchronised metacourses');
|
||||
|
||||
//
|
||||
// generate new password emails for users
|
||||
//
|
||||
mtrace('checking for create_password');
|
||||
if (count_records('user_preferences', 'name', 'create_password', 'value', '1')) {
|
||||
mtrace('creating passwords for new users');
|
||||
$newusers = get_records_sql("SELECT u.id as id, u.email, u.firstname,
|
||||
u.lastname, u.username,
|
||||
p.id as prefid
|
||||
FROM {$CFG->prefix}user u
|
||||
JOIN {$CFG->prefix}user_preferences p ON u.id=p.userid
|
||||
WHERE p.name='create_password' AND p.value=1 AND u.email !='' ");
|
||||
|
||||
foreach ($newusers as $newuserid => $newuser) {
|
||||
$newuser->emailstop = 0; // send email regardless
|
||||
// email user
|
||||
if (setnew_password_and_mail($newuser)) {
|
||||
// remove user pref
|
||||
delete_records('user_preferences', 'id', $newuser->prefid);
|
||||
} else {
|
||||
trigger_error("Could not create and mail new user password!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->usetags)) {
|
||||
require_once($CFG->dirroot.'/tag/lib.php');
|
||||
tag_cron();
|
||||
mtrace ('Executed tag cron');
|
||||
}
|
||||
|
||||
// Accesslib stuff
|
||||
cleanup_contexts();
|
||||
mtrace ('Cleaned up contexts');
|
||||
gc_cache_flags();
|
||||
mtrace ('Cleaned cache flags');
|
||||
// If you suspect that the context paths are somehow corrupt
|
||||
// replace the line below with: build_context_path(true);
|
||||
build_context_path();
|
||||
mtrace ('Built context paths');
|
||||
|
||||
mtrace("Finished clean-up tasks...");
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
|
||||
|
||||
if (empty($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
if (!isset($CFG->disablescheduledbackups)) { // Defined in config.php
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("192M");
|
||||
if (function_exists('apache_child_terminate')) {
|
||||
// if we are running from Apache, give httpd a hint that
|
||||
// it can recycle the process after it's done. Apache's
|
||||
// memory management is truly awful but we can help it.
|
||||
@apache_child_terminate();
|
||||
}
|
||||
ini_set("memory_limit","56M");
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
@@ -404,141 +136,38 @@
|
||||
include_once("$CFG->dirroot/backup/backuplib.php");
|
||||
include_once("$CFG->dirroot/backup/lib.php");
|
||||
require_once ("$CFG->libdir/blocklib.php");
|
||||
mtrace("Running backups if required...");
|
||||
echo "Running backups if required...\n";
|
||||
flush();
|
||||
|
||||
if (! schedule_backup_cron()) {
|
||||
mtrace("ERROR: Something went wrong while performing backup tasks!!!");
|
||||
echo "Something went wrong while performing backup tasks!!!\n";
|
||||
} else {
|
||||
mtrace("Backup tasks finished.");
|
||||
echo "Backup tasks finished\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
|
||||
include_once("$CFG->libdir/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
if (file_exists("$CFG->dirroot/rss/rsslib.php")) {
|
||||
include_once("$CFG->dirroot/rss/rsslib.php");
|
||||
echo "Running rssfeeds if required...\n";
|
||||
flush();
|
||||
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the enrolment cron, if any
|
||||
if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
|
||||
$plugins = array($CFG->enrol);
|
||||
}
|
||||
require_once($CFG->dirroot .'/enrol/enrol.class.php');
|
||||
foreach ($plugins as $p) {
|
||||
$enrol = enrolment_factory::factory($p);
|
||||
if (method_exists($enrol, 'cron')) {
|
||||
$enrol->cron();
|
||||
}
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
unset($enrol);
|
||||
}
|
||||
|
||||
/// Run the auth cron, if any
|
||||
$auths = get_enabled_auth_plugins();
|
||||
|
||||
mtrace("Running auth crons if required...");
|
||||
foreach ($auths as $auth) {
|
||||
$authplugin = get_auth_plugin($auth);
|
||||
if (method_exists($authplugin, 'cron')) {
|
||||
mtrace("Running cron for auth/$auth...");
|
||||
$authplugin->cron();
|
||||
if (!empty($authplugin->log)) {
|
||||
mtrace($authplugin->log);
|
||||
}
|
||||
}
|
||||
unset($authplugin);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
// check we're not before our runtime
|
||||
$timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour*60*60 + $CFG->statsruntimestartminute*60;
|
||||
|
||||
if (time() > $timetocheck) {
|
||||
// process configured number of days as max (defaulting to 31)
|
||||
$maxdays = empty($CFG->statsruntimedays) ? 31 : abs($CFG->statsruntimedays);
|
||||
if (stats_cron_daily($maxdays)) {
|
||||
if (stats_cron_weekly()) {
|
||||
if (stats_cron_monthly()) {
|
||||
stats_clean_old();
|
||||
}
|
||||
}
|
||||
}
|
||||
@set_time_limit(0);
|
||||
} else {
|
||||
mtrace('Next stats run after:'. userdate($timetocheck));
|
||||
}
|
||||
}
|
||||
|
||||
// run gradebook import/export/report cron
|
||||
if ($gradeimports = get_list_of_plugins('grade/import')) {
|
||||
foreach ($gradeimports as $gradeimport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/import/'.$gradeimport.'/lib.php');
|
||||
$cron_function = 'grade_import_'.$gradeimport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook import function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradeexports = get_list_of_plugins('grade/export')) {
|
||||
foreach ($gradeexports as $gradeexport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/export/'.$gradeexport.'/lib.php');
|
||||
$cron_function = 'grade_export_'.$gradeexport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook export function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
if ( ! cron_rss_feeds()) {
|
||||
echo "Something went wrong while generating rssfeeds!!!\n";
|
||||
} else {
|
||||
echo "Rssfeeds finished\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($gradereports = get_list_of_plugins('grade/report')) {
|
||||
foreach ($gradereports as $gradereport) {
|
||||
if (file_exists($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php')) {
|
||||
require_once($CFG->dirroot.'/grade/report/'.$gradereport.'/lib.php');
|
||||
$cron_function = 'grade_report_'.$gradereport.'_cron';
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing gradebook report function $cron_function ...", '');
|
||||
$cron_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// run any customized cronjobs, if any
|
||||
// looking for functions in lib/local/cron.php
|
||||
if (file_exists($CFG->dirroot.'/local/cron.php')) {
|
||||
mtrace('Processing customized cron script ...', '');
|
||||
include_once($CFG->dirroot.'/local/cron.php');
|
||||
mtrace('done.');
|
||||
}
|
||||
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
|
||||
mtrace("Cron script completed correctly");
|
||||
echo "Cron script completed correctly\n";
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
|
||||
/// finish the IE hack
|
||||
if (check_browser_version('MSIE')) {
|
||||
echo "</xmp>";
|
||||
}
|
||||
echo "Execution took ".$difftime." seconds\n";
|
||||
|
||||
?>
|
||||
|
||||
+8
-15
@@ -1,32 +1,25 @@
|
||||
<?PHP // $Id$
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
// disable moodle specific debug messages that would be breaking the frames
|
||||
disable_debugging();
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
$do = optional_param('do', '', PARAM_ALPHA);
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
$strdatabaseperformance = get_string("databaseperformance");
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
$navigation = build_navigation(array(
|
||||
array('name'=>$stradministration, 'link'=>'index.php', 'type'=>'misc'),
|
||||
array('name'=>$strdatabaseperformance, 'link'=>null, 'type'=>'misc')));
|
||||
if (!empty($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname", $navigation);
|
||||
if (isset($topframe)) {
|
||||
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($bottomframe) or !empty($do)) {
|
||||
if (isset($bottomframe) or isset($_GET['do'])) {
|
||||
$perf =&NewPerfMonitor($db);
|
||||
$perf->UI($pollsecs=5);
|
||||
exit;
|
||||
|
||||
+21
-39
@@ -3,50 +3,32 @@
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('purgemoodledata');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
$reallysure = optional_param('reallysure', 0, PARAM_BOOL);
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("You must be admin to use this script!");
|
||||
}
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Purge moodledata');
|
||||
|
||||
if (empty($sure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?',
|
||||
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
if (!$sure) {
|
||||
notice_yesno ("Are you completely sure you want to delete everything inside the directory $deletedir ?", "delete.php?sure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!data_submitted() or empty($reallysure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
|
||||
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?',
|
||||
'delete.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
if (!$reallysure) {
|
||||
notice_yesno ("Are you REALLY REALLY completely sure you want to delete everything inside the directory $deletedir (this includes all user images, and any other course files that have been created) ?", "delete.php?sure=yes&reallysure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error('This script was called wrongly');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
echo "<H1 align=center>Done!</H1>";
|
||||
print_continue($CFG->wwwroot);
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
|
||||
|
||||
@@ -54,28 +36,28 @@ function delete_subdirectories($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != "." and $file != "..") {
|
||||
$fullfile = "$rootdir/$file";
|
||||
if (filetype($fullfile) == "dir") {
|
||||
delete_subdirectories($fullfile);
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (rmdir($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
} else {
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (unlink($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (unlink("$fullfile")) {
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
-144
@@ -1,144 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
|
||||
$savesettings = optional_param('savesettings', 0, PARAM_BOOL);
|
||||
|
||||
$CFG->pagepath = 'enrol';
|
||||
|
||||
admin_externalpage_setup('enrolment');
|
||||
|
||||
if (!isset($CFG->sendcoursewelcomemessage)) {
|
||||
set_config('sendcoursewelcomemessage', 1);
|
||||
}
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
/// Save settings
|
||||
|
||||
if ($frm = data_submitted() and !$savesettings) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if (empty($frm->enable)) {
|
||||
$frm->enable = array();
|
||||
}
|
||||
if (empty($frm->default)) {
|
||||
$frm->default = '';
|
||||
}
|
||||
if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
|
||||
$frm->enable[] = $frm->default;
|
||||
}
|
||||
asort($frm->enable);
|
||||
$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", get_string("changessaved"), 1);
|
||||
|
||||
} else if ($frm = data_submitted() and $savesettings) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL));
|
||||
}
|
||||
|
||||
/// Print the form
|
||||
|
||||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$options = array();
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
|
||||
|
||||
echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
|
||||
$table = new stdClass();
|
||||
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
|
||||
$table->align = array('left', 'center', 'center', 'center');
|
||||
$table->size = array('60%', '', '', '15%');
|
||||
$table->width = '700';
|
||||
$table->data = array();
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
foreach ($modules as $module) {
|
||||
|
||||
// skip if directory is empty
|
||||
if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = get_string("enrolname", "enrol_$module");
|
||||
$plugin = enrolment_factory::factory($module);
|
||||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
|
||||
if (in_array($module, $enabledplugins)) {
|
||||
$enable .= ' checked="checked"';
|
||||
}
|
||||
if ($module == 'manual') {
|
||||
$enable .= ' disabled="disabled"';
|
||||
}
|
||||
$enable .= ' />';
|
||||
if (method_exists($plugin, 'print_entry')) {
|
||||
$default = '<input type="radio" name="default" value="'.$module.'"';
|
||||
if ($CFG->enrol == $module) {
|
||||
$default .= ' checked="checked"';
|
||||
}
|
||||
$default .= ' />';
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
$table->data[$name] = array($name, $enable, $default,
|
||||
'<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>');
|
||||
}
|
||||
asort($table->data);
|
||||
|
||||
print_table($table);
|
||||
|
||||
echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$yesnooptions = array(0=>get_string('no'), 1=>get_string('yes'));
|
||||
|
||||
echo '<form '.$CFG->frametarget.' id="adminsettings" method="post" action="enrol.php">';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
print_heading(get_string('commonsettings', 'admin'));
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="savesettings" value="1" />';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="form-item clearfix" id="admin-sendcoursewelcomemessage">';
|
||||
|
||||
echo '<div class="form-label"><label for = "menusendcoursewelcomemessage">' . get_string('sendcoursewelcomemessage', 'admin');
|
||||
echo '<span class="form-shortname">sendcoursewelcomemessage</span>';
|
||||
echo '</label></div>';
|
||||
echo '<div class="form-setting"><div class="form-checkbox defaultsnext">';
|
||||
choose_from_menu($yesnooptions, 'sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, '');
|
||||
echo '</div><div class="form-defaultinfo">'.get_string('defaultsettinginfo', 'admin', get_string('yes')).'</div></div>';
|
||||
echo '<div class="form-description">' . get_string('configsendcoursewelcomemessage', 'admin') . '</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();
|
||||
|
||||
?>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('enrolment');
|
||||
|
||||
$enrol = required_param('enrol', PARAM_ALPHA);
|
||||
$CFG->pagepath = 'enrol/' . $enrol;
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory($enrol);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
if ($enrolment->process_config($frm)) {
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// 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);
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
|
||||
echo "<div>";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
|
||||
echo "<input type=\"hidden\" name=\"enrol\" value=\"".$enrol."\" />";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
print_simple_box_start("center", "60%", '', 5, 'informationbox');
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<p class=\"centerpara\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></p>\n";
|
||||
print_simple_box_end();
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
@@ -1,136 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
||||
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is the admin frontend to execute all the checks available
|
||||
// in the environment.xml file. It includes database, php and
|
||||
// php_extensions. Also, it's possible to update the xml file
|
||||
// from moodle.org be able to check more and more versions.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/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); //
|
||||
|
||||
|
||||
/// Get some strings
|
||||
$stradmin = get_string('administration');
|
||||
$stradminhelpenvironment = get_string("adminhelpenvironment");
|
||||
$strenvironment = get_string('environment', 'admin');
|
||||
$strerror = get_string('error');
|
||||
$strmoodleversion = get_string('moodleversion');
|
||||
$strupdate = get_string('updatecomponent', 'admin');
|
||||
$strupwards = get_string('upwards', 'admin');
|
||||
$strmisc = get_string('miscellaneous');
|
||||
|
||||
/// Print the header stuff
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.$USER->sesskey.'">'.$strupdate.'</a></div>';
|
||||
|
||||
print_heading($strenvironment);
|
||||
|
||||
/// Handle the 'updatecomponent' action
|
||||
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
/// Create component installer and execute it
|
||||
if ($cd = new component_installer('http://download.moodle.org',
|
||||
'environment',
|
||||
'environment.zip')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
||||
$a->dest= $CFG->dataroot.'/';
|
||||
print_simple_box(get_string($cd->get_error(), 'error', $a), 'center', '', '', 5, 'errorbox');
|
||||
} else {
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
print_simple_box(get_string($cd->get_error(), 'error'), 'center');
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start of main box
|
||||
print_simple_box_start('center');
|
||||
|
||||
echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
|
||||
|
||||
/// Get current Moodle version
|
||||
$current_version = $CFG->release;
|
||||
|
||||
/// Calculate list of versions
|
||||
$versions = array();
|
||||
if ($contents = load_environment_xml()) {
|
||||
if ($env_versions = get_list_of_environment_versions($contents)) {
|
||||
/// Set the current version at the beginning
|
||||
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
||||
$versions[$env_version] = $current_version;
|
||||
/// If no version has been previously selected, default to $current_version
|
||||
if (empty($version)) {
|
||||
$version = $env_version;
|
||||
}
|
||||
///Iterate over each version, adding bigged than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
}
|
||||
}
|
||||
/// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.$strupwards;
|
||||
} else {
|
||||
$versions = array('error' => $strerror);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print form and popup menu
|
||||
echo '<div style="text-align:center">'.$strmoodleversion.' ';
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/environment.php?version=",
|
||||
$versions, 'selectversion', $version, '');
|
||||
echo '</div>';
|
||||
|
||||
/// End of main box
|
||||
print_simple_box_end();
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Print footer
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,282 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<COMPATIBILITY_MATRIX>
|
||||
<MOODLE version="1.5">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="3.23" />
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
</DATABASE>
|
||||
<PHP version="4.1.0" level="required" />
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="mbstring" level="optional" />
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.6">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required" />
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.7">
|
||||
<UNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unicoderecommended" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.8">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required">
|
||||
<RESTRICT function="restrict_php50_version" message="php50restricted" />
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ctyperecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="qtyperqpwillberemovedanyway" />
|
||||
<ON_OK message="qtyperqpwillberemoved" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/upgrade.php" function="question_random_check" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_OK message="questioncwqpfsok" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.0" requires="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.0" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.2.4" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php // $Id$
|
||||
// filter.php
|
||||
// Edit text filter settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$filterfull = required_param('filter', PARAM_PATH);
|
||||
$forcereset = optional_param('reset', 0, PARAM_BOOL);
|
||||
|
||||
$filtername = substr($filterfull, strpos( $filterfull, '/' )+1 ) ;
|
||||
|
||||
admin_externalpage_setup('filtersetting'.str_replace('/', '', $filterfull));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
|
||||
|
||||
// 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' );
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
|
||||
// if reset pressed let filter config page handle it
|
||||
if ($config = data_submitted() and !$forcereset) {
|
||||
|
||||
// check session key
|
||||
if (!confirm_sesskey()) {
|
||||
error( get_string('confirmsesskeybad', 'error' ) );
|
||||
}
|
||||
|
||||
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
|
||||
if (file_exists($configpath)) {
|
||||
require_once($configpath);
|
||||
$functionname = $filtername.'_process_config';
|
||||
if (function_exists($functionname)) {
|
||||
$functionname($config);
|
||||
$saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($saved)) {
|
||||
// run through submitted data
|
||||
// reject if does not start with filter_
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, stripslashes($value));
|
||||
}
|
||||
}
|
||||
|
||||
reset_text_filters_cache();
|
||||
|
||||
redirect($returnurl);
|
||||
exit;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Display logic
|
||||
//==============================
|
||||
|
||||
$filtername = ucfirst($filtername);
|
||||
admin_externalpage_print_header();
|
||||
print_heading( $filtername );
|
||||
|
||||
print_simple_box(get_string("configwarning", "admin"), "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center",'');
|
||||
|
||||
?>
|
||||
<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/$filterfull/filterconfig.html"; ?>
|
||||
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
<input type="submit" name="reset" value="<?php echo print_string('resettodefaults'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="filters" id="filters" method="post" action="filters.php">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><div align="right">
|
||||
<br />
|
||||
<input name="up" type="submit" id="up" value="↑" />
|
||||
<br />
|
||||
<input name="down" type="submit" id="down" value="↓" />
|
||||
<br />
|
||||
</div></td>
|
||||
<td valign="top">
|
||||
<?php p($stractive) ?>
|
||||
<br />
|
||||
|
||||
<select name="iselect" size="20" id="iselect"
|
||||
onclick="document.filters.add.disabled=true;
|
||||
document.filters.remove.disabled=false;
|
||||
document.filters.uselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$runscript = "";
|
||||
foreach ($installedfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=true\");
|
||||
eval(\"document.filters.remove.disabled=false\");
|
||||
eval(\"document.filters.uselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<?php p($strinactive) ?>
|
||||
<br />
|
||||
<select name="uselect" size="20" id="select"
|
||||
onclick="document.filters.add.disabled=false;
|
||||
document.filters.remove.disabled=true;
|
||||
document.filters.iselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($uninstalledfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=false\");
|
||||
eval(\"document.filters.remove.disabled=true\");
|
||||
eval(\"document.filters.iselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script language="Javascript">
|
||||
<!--
|
||||
<?php echo $runscript ?>
|
||||
|
||||
-->
|
||||
</script>
|
||||
<?php print_simple_box_end(); ?>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="options" id="options" method="post" action="filters.php">
|
||||
<input type="hidden" name="options" value="1">
|
||||
<table cellpadding="20">
|
||||
<tr valign=top>
|
||||
<td nowrap="nowrap" align="right"><?php p($strcachetext) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[10800] = get_string('numhours', '', 3);
|
||||
$options[7200] = get_string('numhours', '', 2);
|
||||
$options[3600] = get_string('numhours', '', 1);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[600] = get_string('numminutes', '', 10);
|
||||
$options[540] = get_string('numminutes', '', 9);
|
||||
$options[480] = get_string('numminutes', '', 8);
|
||||
$options[420] = get_string('numminutes', '', 7);
|
||||
$options[360] = get_string('numminutes', '', 6);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
$options[240] = get_string('numminutes', '', 4);
|
||||
$options[180] = get_string('numminutes', '', 3);
|
||||
$options[120] = get_string('numminutes', '', 2);
|
||||
$options[60] = get_string('numminutes', '', 1);
|
||||
$options[30] = get_string('numseconds', '', 30);
|
||||
$options[0] = get_string('no');
|
||||
|
||||
choose_from_menu ($options, "cachetext", $CFG->cachetext, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigcachetext) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td nowrap="nowrap" align="right"><?php p($strfilteruploadedfiles) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "filteruploadedfiles", $CFG->filteruploadedfiles, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigfilteruploadedfiles) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php print_simple_box_end(); ?>
|
||||
+147
-79
@@ -1,102 +1,170 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
optional_variable($iselect);
|
||||
optional_variable($uselect);
|
||||
optional_variable($add);
|
||||
optional_variable($remove);
|
||||
optional_variable($up);
|
||||
optional_variable($down);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managefilters";
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
// get a list of installed filters
|
||||
$installedfilters = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagefilters = get_string("managefilters");
|
||||
$strversion = get_string("version");
|
||||
$strsettings = get_string("settings");
|
||||
$strup = get_string("up");
|
||||
$strdown = get_string("down");
|
||||
$stractive = get_string("active");
|
||||
$strinactive = get_string("inactive");
|
||||
$strcachetext = get_string("cachetext", "admin");
|
||||
$strconfigcachetext = get_string("configcachetext");
|
||||
$strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
|
||||
$strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles");
|
||||
|
||||
print_header("$site->shortname: $strmanagefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagefilters");
|
||||
|
||||
print_heading($strmanagefilters);
|
||||
|
||||
|
||||
/// Make a list of all available filters and the best names for them we can find
|
||||
$allfilters = 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";
|
||||
if (is_readable($pluginpath)) {
|
||||
$installedfilters["$filterlocation/$plugin"] = "$filterlocation/$plugin";
|
||||
foreach ($plugins as $key => $plugin) {
|
||||
if (is_readable("$CFG->dirroot/$filterlocation/$plugin/filter.php")) {
|
||||
$name = trim(get_string("filtername", $plugin));
|
||||
if (empty($name) or $name == "[[filtername]]") {
|
||||
$name = $plugin;
|
||||
}
|
||||
$allfilters["$filterlocation/$plugin"] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all the currently selected filters
|
||||
|
||||
/// Make an array of all the currently installed filters
|
||||
|
||||
$installedfilters = array();
|
||||
if (!empty($CFG->textfilters)) {
|
||||
$activefilters = explode(',', $CFG->textfilters);
|
||||
} else {
|
||||
$activefilters = array();
|
||||
$installedfilters = explode(',',$CFG->textfilters);
|
||||
|
||||
// Do a little cleanup for robustness
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if (empty($installedfilter)) {
|
||||
unset($installedfilters[$key]);
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//======================
|
||||
// Process Actions
|
||||
//======================
|
||||
$selectedfilter = "none";
|
||||
|
||||
switch ($action) {
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
case 'hide':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
break;
|
||||
if (!empty($options)) {
|
||||
if ($config = data_submitted()) {
|
||||
unset($config->options);
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
}
|
||||
// just delete it
|
||||
unset($activefilters[$key]);
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
// check filterpath is valid
|
||||
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[] = $filterpath;
|
||||
$activefilters = array_unique($activefilters);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
} elseif ($key>=(count($activefilters)-1)) {
|
||||
// cannot be moved any further down - doubleclick??
|
||||
} else {
|
||||
// swap with $key+1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key+1];
|
||||
$activefilters[$key+1] = $fsave;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
$key=array_search($filterpath, $activefilters);
|
||||
// check filterpath is valid
|
||||
if ($key===false) {
|
||||
error("Filter $filterpath is not currently active", $url);
|
||||
} elseif ($key<1) {
|
||||
//cannot be moved any further up - doubleclick??
|
||||
} else {
|
||||
// swap with $key-1
|
||||
$fsave = $activefilters[$key];
|
||||
$activefilters[$key] = $activefilters[$key-1];
|
||||
$activefilters[$key-1] = $fsave;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// save, reset cache and return
|
||||
set_config('textfilters', implode(',', $activefilters));
|
||||
reset_text_filters_cache();
|
||||
redirect($returnurl);
|
||||
if (!empty($add) and !empty($uselect)) {
|
||||
$selectedfilter = $uselect;
|
||||
if (!in_array($selectedfilter, $installedfilters)) {
|
||||
$installedfilters[] = $selectedfilter;
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
|
||||
} else if (!empty($remove) and !empty($iselect)) {
|
||||
$selectedfilter = $iselect;
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($installedfilter == $selectedfilter) {
|
||||
unset($installedfilters[$key]);
|
||||
}
|
||||
}
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
|
||||
} else if ((!empty($up) or !empty($down)) and !empty($iselect)) {
|
||||
|
||||
if (!empty($up)) {
|
||||
if ($allfilters[$iselect]) {
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($installedfilter == $iselect) {
|
||||
$movefilter = $key;
|
||||
break;
|
||||
}
|
||||
$swapfilter = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($down)) {
|
||||
if ($allfilters[$iselect]) {
|
||||
$choosenext = false;
|
||||
foreach ($installedfilters as $key => $installedfilter) {
|
||||
if ($choosenext) {
|
||||
$swapfilter = $key;
|
||||
break;
|
||||
}
|
||||
if ($installedfilter == $iselect) {
|
||||
$movefilter = $key;
|
||||
$choosenext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($swapfilter) and isset($movefilter)) {
|
||||
$tempfilter = $installedfilters[$swapfilter];
|
||||
$installedfilters[$swapfilter] = $installedfilters[$movefilter];
|
||||
$installedfilters[$movefilter] = $tempfilter;
|
||||
set_config("textfilters", implode(',', $installedfilters));
|
||||
}
|
||||
$selectedfilter = $iselect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Make an array of all the currently uninstalled filters
|
||||
|
||||
$uninstalledfilters = array();
|
||||
foreach ($allfilters as $filter => $name) {
|
||||
$installed = false;
|
||||
foreach ($installedfilters as $installedfilter) {
|
||||
if ($installedfilter == $filter) {
|
||||
$installed = true;
|
||||
}
|
||||
}
|
||||
if (!$installed) {
|
||||
$uninstalledfilters[] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the current form
|
||||
|
||||
include("filters.html");
|
||||
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php // $Id$
|
||||
/** This expects the output from a command like
|
||||
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
|
||||
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
|
||||
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
|
||||
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
|
||||
*/
|
||||
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$FULLME='cron';
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
|
||||
|
||||
$site = get_site();
|
||||
|
||||
while(!feof($fd)) {
|
||||
$entry = fgets($fd);
|
||||
if (strlen(trim($entry)) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!$file = validate_line($entry)) {
|
||||
continue;
|
||||
}
|
||||
$bits = explode('/',$file);
|
||||
$a->filename = $bits[count($bits)-1];
|
||||
|
||||
if (!$log = get_record("log","module","upload","info",$file,"action","upload")) {
|
||||
$a->action = clam_handle_infected_file($file,0,false);
|
||||
clam_replace_infected_file($file);
|
||||
notify_admins_unknown($file,$a);
|
||||
continue;
|
||||
}
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
$user = get_record("user","id",$log->userid);
|
||||
$course = get_record("course","id",$log->course);
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = $course->fullname;
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
notify_admins($user,$subject,$a);
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
|
||||
function notify_user($user,$subject,$a) {
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
$body = get_string('virusfoundlater','moodle',$a);
|
||||
email_to_user($user,get_admin(),$subject,$body);
|
||||
}
|
||||
|
||||
|
||||
function notify_admins($user,$subject,$a) {
|
||||
|
||||
$admins = get_admins();
|
||||
|
||||
$body = get_string('virusfoundlateradmin','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function notify_admins_unknown($file,$a) {
|
||||
|
||||
global $site;
|
||||
|
||||
$admins = get_admins();
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('virusfoundlateradminnolog','moodle',$a);
|
||||
foreach ($admins as $admin) {
|
||||
email_to_user($admin,$admin,$subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_line($line) {
|
||||
global $CFG;
|
||||
if (strpos($line,"FOUND") === false) {
|
||||
return false;
|
||||
}
|
||||
$index = strpos($line,":");
|
||||
$file = substr($line,0,$index);
|
||||
if (!(strpos($file,$CFG->dataroot) === false)) {
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($file{0} == "/") {
|
||||
$file = $CFG->dataroot.$file;
|
||||
}
|
||||
else {
|
||||
$file = $CFG->dataroot."/".$file;
|
||||
}
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// clean up
|
||||
$file = preg_replace('/\.\//','/',$file);
|
||||
$file = preg_replace('/\/\//','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,851 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
ob_start(); //for whitespace test
|
||||
require_once('../config.php');
|
||||
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
while (true) {
|
||||
$extraws .= ob_get_contents();
|
||||
if (!@ob_end_clean()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('healthcenter');
|
||||
|
||||
define('SEVERITY_NOTICE', 'notice');
|
||||
define('SEVERITY_ANNOYANCE', 'annoyance');
|
||||
define('SEVERITY_SIGNIFICANT', 'significant');
|
||||
define('SEVERITY_CRITICAL', 'critical');
|
||||
|
||||
$solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$site = get_site();
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
echo <<<STYLES
|
||||
<style type="text/css">
|
||||
div#healthnoproblemsfound {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
-moz-border-radius: 6px;
|
||||
}
|
||||
dl.healthissues {
|
||||
width: 60%;
|
||||
margin: auto;
|
||||
}
|
||||
dl.critical dt, dl.critical dd {
|
||||
background-color: #a71501;
|
||||
}
|
||||
dl.significant dt, dl.significant dd {
|
||||
background-color: #d36707;
|
||||
}
|
||||
dl.annoyance dt, dl.annoyance dd {
|
||||
background-color: #dba707;
|
||||
}
|
||||
dl.notice dt, dl.notice dd {
|
||||
background-color: #e5db36;
|
||||
}
|
||||
dt.solution, dd.solution, div#healthnoproblemsfound {
|
||||
background-color: #5BB83E !important;
|
||||
}
|
||||
dl.healthissues dt, dl.healthissues dd {
|
||||
margin: 0px;
|
||||
padding: 1em;
|
||||
border: 1px black solid;
|
||||
}
|
||||
dl.healthissues dt {
|
||||
font-weight: bold;
|
||||
border-bottom: none;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
dl.healthissues dd {
|
||||
border-top: none;
|
||||
padding-top: 0.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
dl.healthissues dd form {
|
||||
margin-top: 0.5em;
|
||||
text-align: right;
|
||||
}
|
||||
form#healthformreturn {
|
||||
text-align: center;
|
||||
margin: 2em;
|
||||
}
|
||||
dd.solution p {
|
||||
padding: 0px;
|
||||
margin: 1em 0px;
|
||||
}
|
||||
dd.solution li {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
STYLES;
|
||||
|
||||
if(strpos($solution, 'problem_') === 0 && class_exists($solution)) {
|
||||
health_print_solution($solution);
|
||||
}
|
||||
else {
|
||||
health_find_problems();
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
|
||||
$issues = array(
|
||||
SEVERITY_CRITICAL => array(),
|
||||
SEVERITY_SIGNIFICANT => array(),
|
||||
SEVERITY_ANNOYANCE => array(),
|
||||
SEVERITY_NOTICE => array(),
|
||||
);
|
||||
$problems = 0;
|
||||
|
||||
for($i = 1; $i < 1000000; ++$i) {
|
||||
$classname = sprintf('problem_%06d', $i);
|
||||
if(!class_exists($classname)) {
|
||||
break;
|
||||
}
|
||||
$problem = new $classname;
|
||||
if($problem->exists()) {
|
||||
$severity = $problem->severity();
|
||||
$issues[$severity][$classname] = array(
|
||||
'severity' => $severity,
|
||||
'description' => $problem->description(),
|
||||
'title' => $problem->title()
|
||||
);
|
||||
++$problems;
|
||||
}
|
||||
unset($problem);
|
||||
}
|
||||
|
||||
if($problems == 0) {
|
||||
echo '<div id="healthnoproblemsfound">';
|
||||
echo get_string('healthnoproblemsfound');
|
||||
echo '</div>';
|
||||
}
|
||||
else {
|
||||
print_heading(get_string('healthproblemsdetected'));
|
||||
$severities = array(SEVERITY_CRITICAL, SEVERITY_SIGNIFICANT, SEVERITY_ANNOYANCE, SEVERITY_NOTICE);
|
||||
foreach($severities as $severity) {
|
||||
if(!empty($issues[$severity])) {
|
||||
echo '<dl class="healthissues '.$severity.'">';
|
||||
foreach($issues[$severity] as $classname => $data) {
|
||||
echo '<dt id="'.$classname.'">'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'];
|
||||
echo '<form action="health.php#solution" method="get">';
|
||||
echo '<input type="hidden" name="solution" value="'.$classname.'" /><input type="submit" value="'.get_string('viewsolution').'" />';
|
||||
echo '</form></dd>';
|
||||
}
|
||||
echo '</dl>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function health_print_solution($classname) {
|
||||
$problem = new $classname;
|
||||
$data = array(
|
||||
'title' => $problem->title(),
|
||||
'severity' => $problem->severity(),
|
||||
'description' => $problem->description(),
|
||||
'solution' => $problem->solution()
|
||||
);
|
||||
|
||||
print_heading(get_string('healthcenter'));
|
||||
print_heading(get_string('healthproblemsolution'));
|
||||
echo '<dl class="healthissues '.$data['severity'].'">';
|
||||
echo '<dt>'.$data['title'].'</dt>';
|
||||
echo '<dd>'.$data['description'].'</dd>';
|
||||
echo '<dt id="solution" class="solution">'.get_string('healthsolution').'</dt>';
|
||||
echo '<dd class="solution">'.$data['solution'].'</dd></dl>';
|
||||
echo '<form id="healthformreturn" action="health.php#'.$classname.'" method="get">';
|
||||
echo '<input type="submit" value="'.get_string('healthreturntomain').'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
class problem_base {
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function title() {
|
||||
return '???';
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_NOTICE;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000001 extends problem_base {
|
||||
function title() {
|
||||
return 'Invalid value for $CFG->dirroot';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
if (!empty($dirroot) && $dirroot != $CFG->dirroot) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> file contains the setting <strong>$CFG->dirroot = "'.$CFG->dirroot.'"</strong>, which is incorrect. Unless you correct this problem, Moodle will not function correctly, if at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$dirroot = dirname(realpath('../index.php'));
|
||||
return 'You need to edit your <strong>config.php</strong> file. Find the line which reads <pre>$CFG->dirroot = \''.$CFG->dirroot.'\';</pre> and change it to read <pre>$CFG->dirroot = \''.$dirroot.'\'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000002 extends problem_base {
|
||||
function title() {
|
||||
return 'Extra characters at the end of config.php or other library function';
|
||||
}
|
||||
function exists() {
|
||||
global $extraws;
|
||||
|
||||
if($extraws === '') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your Moodle configuration file config.php or another library file, contains some characters after the closing PHP tag (?>). This causes Moodle to exhibit several kinds of problems (such as broken downloaded files) and must be fixed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You need to edit <strong>'.$CFG->dirroot.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file. The extra trailing whitespace may be also present in other PHP files that are included from lib/setup.php.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000003 extends problem_base {
|
||||
function title() {
|
||||
return '$CFG->dataroot does not exist or does not have write permissions';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
if(!is_dir($CFG->dataroot) || !is_writable($CFG->dataroot)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'Your <strong>config.php</strong> says that your "data root" directory is <strong>'.$CFG->dataroot.'</strong>. However, this directory either does not exist or cannot be written to by Moodle. This means that a variety of problems will be present, such as users not being able to log in and not being able to upload any files. It is imperative that you address this problem for Moodle to work correctly.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'First of all, make sure that the directory <strong>'.$CFG->dataroot.'</strong> exists. If the directory does exist, then you must make sure that Moodle is able to write to it. Contact your web server administrator and request that he gives write permissions for that directory to the user that the web server process is running as.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000004 extends problem_base {
|
||||
function title() {
|
||||
return 'cron.php is not set up to run automatically';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM '.$CFG->prefix.'modules');
|
||||
return (time() - $lastcron > 3600 * 24);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'The cron.php mainenance script has not been run in the past 24 hours. This probably means that your server is not configured to automatically run this script in regular time intervals. If this is the case, then Moodle will mostly work as it should but some operations (notably sending email to users) will not be carried out at all.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'For detailed instructions on how to enable cron, see <a href="'.$CFG->wwwroot.'/doc/?file=install.html#cron">this section</a> of the installation manual.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000005 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: session.auto_start is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return ini_get_bool('session.auto_start');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, session.auto_start, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include fatal errors and/or blank pages when trying to log in.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>session.auto_start = 1</pre> and change it to <pre>session.auto_start = 0</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value session.auto_start "0"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000006 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: magic_quotes_runtime is enabled';
|
||||
}
|
||||
function exists() {
|
||||
return (ini_get_bool('magic_quotes_runtime'));
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes an enabled setting, magic_quotes_runtime, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include strange display errors whenever a text field that includes single or double quotes is processed.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>magic_quotes_runtime = On</pre> and change it to <pre>magic_quotes_runtime = Off</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value magic_quotes_runtime "Off"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000007 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: file_uploads is disabled';
|
||||
}
|
||||
function exists() {
|
||||
return !ini_get_bool('file_uploads');
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return 'Your PHP configuration includes a disabled setting, file_uploads, that <strong>must be enabled</strong> to let Moodle offer its full functionality. Until this setting is enabled, it will not be possible to upload any files into Moodle. This includes, for example, course content and user pictures.';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>file_uploads = Off</pre> and change it to <pre>file_uploads = On</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot.'/.htaccess</strong> to contain this line: <pre>php_value file_uploads "On"</pre></li></ol>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000008 extends problem_base {
|
||||
function title() {
|
||||
return 'PHP: memory_limit cannot be controlled by Moodle';
|
||||
}
|
||||
function exists() {
|
||||
$oldmemlimit = @ini_get('memory_limit');
|
||||
if(empty($oldmemlimit)) {
|
||||
// PHP not compiled with memory limits, this means that it's
|
||||
// probably limited to 8M or in case of Windows not at all.
|
||||
// We can ignore it for now - there is not much to test anyway
|
||||
// TODO: add manual test that fills memory??
|
||||
return false;
|
||||
}
|
||||
$oldmemlimit = get_real_size($oldmemlimit);
|
||||
//now lets change the memory limit to something unique below 128M==134217728
|
||||
@ini_set('memory_limit', 134217720);
|
||||
$testmemlimit = get_real_size(@ini_get('memory_limit'));
|
||||
//verify the change had any effect at all
|
||||
if ($oldmemlimit == $testmemlimit) {
|
||||
//memory limit can not be changed - is it big enough then?
|
||||
if ($oldmemlimit < get_real_size('128M')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ini_set('memory_limit', $oldmemlimit);
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_NOTICE;
|
||||
}
|
||||
function description() {
|
||||
return 'The settings for PHP on your server do not allow a script to request more memory during its execution. '.
|
||||
'This means that there is a hard limit of '.@ini_get('memory_limit').' for each script. '.
|
||||
'It is possible that certain operations within Moodle will require more than this amount in order '.
|
||||
'to complete successfully, especially if there are lots of data to be processed.';
|
||||
}
|
||||
function solution() {
|
||||
return 'It is recommended that you contact your web server administrator to address this issue.';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000009 extends problem_base {
|
||||
function title() {
|
||||
return 'SQL: using account without password';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return empty($CFG->dbpass);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_CRITICAL;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
return 'The user account your are connecting to the database server with is set up without a password. This is a very big security risk and is only somewhat lessened if your database is configured to not accept connections from any hosts other than the server Moodle is running on. Unless you use a strong password to connect to the database, you risk unauthorized access to and manipulation of your data.'.($CFG->dbuser != 'root'?'':' <strong>This is especially alarming because such access to the database would be as the superuser (root)!</strong>');
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return 'You should change the password of the user <strong>'.$CFG->dbuser.'</strong> both in your database and in your Moodle <strong>config.php</strong> immediately!'.($CFG->dbuser != 'root'?'':' It would also be a good idea to change the user account from root to something else, because this would lessen the impact in the event that your database is compromised anyway.');
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000010 extends problem_base {
|
||||
function title() {
|
||||
return 'Uploaded files: slasharguments disabled or not working';
|
||||
}
|
||||
function exists() {
|
||||
if (!$this->is_enabled()) {
|
||||
return true;
|
||||
}
|
||||
if ($this->status() < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
if ($this->is_enabled() and $this->status() == 0) {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
} else {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
$desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
|
||||
if (!$this->is_enabled()) {
|
||||
$desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
|
||||
}
|
||||
if ($this->status() == -1) {
|
||||
$desc .= '<li>can not run automatic test, you can verify it <a href="'.$CFG->wwwroot.'/file.php/testslasharguments" target="_blank">here</a> manually</li>';
|
||||
} else if ($this->status() == 0) {
|
||||
$desc .= '<li>slashargument test <strong>failed</strong>, please check server configuration</li>';
|
||||
} else {
|
||||
$desc .= '<li>slashargument test passed</li>';
|
||||
}
|
||||
$desc .= '</ul>';
|
||||
return $desc;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
$enabled = $this->is_enabled();
|
||||
$status = $this->status();
|
||||
$solution = '';
|
||||
if ($enabled and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are enabled, but the test failed. Please disable slasharguments in Moodle configuration or fix the server configuration.<hr />';
|
||||
} else if ((!$enabled) and ($status == 0)) {
|
||||
$solution .= 'Slasharguments are disabled and the test failed. You may try to fix the server configuration.<hr />';
|
||||
} else if ($enabled and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are enabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status == -1)) {
|
||||
$solution .= 'Slasharguments are disabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
|
||||
} else if ((!$enabled) and ($status > 0)) {
|
||||
$solution .= 'Slasharguments are disabled though the iternal test is OK. You should enable slasharguments in Moodle configuration.';
|
||||
} else if ($enabled and ($status > 0)) {
|
||||
$solution .= 'Congratulations - everything seems OK now :-D';
|
||||
}
|
||||
if ($status < 1) {
|
||||
$solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
|
||||
$solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
$solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
|
||||
}
|
||||
return $solution;
|
||||
}
|
||||
function is_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->slasharguments);
|
||||
}
|
||||
function status() {
|
||||
global $CFG;
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php?file=/testslasharguments', "r");
|
||||
$contents = @trim(fread($handle, 10));
|
||||
@fclose($handle);
|
||||
if ($contents != 'test -1') {
|
||||
return -1;
|
||||
}
|
||||
$handle = @fopen($CFG->wwwroot.'/file.php/testslasharguments', "r");
|
||||
$contents = trim(@fread($handle, 10));
|
||||
@fclose($handle);
|
||||
switch ($contents) {
|
||||
case 'test 1': return 1;
|
||||
case 'test 2': return 2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000011 extends problem_base {
|
||||
function title() {
|
||||
return 'Session errors detected';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return isset($CFG->session_error_counter);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
if (isset($CFG->session_error_counter)) {
|
||||
return 'Session problems were detected. Total count: '.$CFG->session_error_counter;
|
||||
} else {
|
||||
return 'No session errors detected.';
|
||||
}
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
if (optional_param('resetsesserrorcounter', 0, PARAM_BOOL)) {
|
||||
if (get_field('config', 'name', 'name', 'session_error_counter')) {
|
||||
delete_records('config', 'name', 'session_error_counter');
|
||||
}
|
||||
return 'Error counter was cleared.';
|
||||
} else {
|
||||
return '<p>Session errors can be caused by:</p><ul>' .
|
||||
'<li>unresolved problem in server software (aka random switching of users),</li>' .
|
||||
'<li>blocked or modified cookies,</li>' .
|
||||
'<li>deleting of active session files.</li>' .
|
||||
'</ul><p><a href="'.me().'&resetsesserrorcounter=1">Reset counter</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000012 extends problem_base {
|
||||
function title() {
|
||||
return 'Random questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
return record_exists_select('question', "qtype = 'random' AND parent <> id");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For random questions, question.parent should equal question.id. ' .
|
||||
'There are some questions in your database for which this is not true. ' .
|
||||
'One way that this could have happened is for random questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-5482">MDL-5482</a> was fixed.</p>';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the SQL</p>' .
|
||||
'<pre>UPDATE ' . $CFG->prefix . 'question SET parent = id WHERE qtype = \'random\' and parent <> id;</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000013 extends problem_base {
|
||||
function title() {
|
||||
return 'Multi-answer questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
$positionexpr = sql_position(sql_concat("','", "q.id", "','"),
|
||||
sql_concat("','", "qma.sequence", "','"));
|
||||
return record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question_multianswer qma ON $positionexpr > 0
|
||||
WHERE qma.question <> q.parent") ||
|
||||
record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question parent_q ON parent_q.id = q.parent
|
||||
WHERE q.category <> parent_q.category");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>For each sub-question whose id is listed in ' .
|
||||
'question_multianswer.sequence, its question.parent field should equal ' .
|
||||
'question_multianswer.question; and each sub-question should be in the same ' .
|
||||
'category as its parent. There are questions in your database for ' .
|
||||
'which this is not the case. One way that this could have happened is ' .
|
||||
'for multi-answer questions restored from backup before ' .
|
||||
'<a href="http://tracker.moodle.org/browse/MDL-14750">MDL-14750</a> was fixed.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the ' .
|
||||
'code in question_multianswer_fix_subquestion_parents_and_categories in ' .
|
||||
'<a href="http://cvs.moodle.org/moodle/question/type/multianswer/db/upgrade.php?revision=1.1.10.2&view=markup">/question/type/multianswer/db/upgrade.php' .
|
||||
'from the 1.9 stable branch</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000014 extends problem_base {
|
||||
function title() {
|
||||
return 'Only multianswer and random questions should be the parent of another question';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return record_exists_sql("
|
||||
SELECT * FROM {$CFG->prefix}question q
|
||||
JOIN {$CFG->prefix}question parent_q ON parent_q.id = q.parent
|
||||
WHERE parent_q.qtype NOT IN ('random', 'multianswer')");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
return '<p>You have questions that violate this in your databse. ' .
|
||||
'You will need to investigate to determine how this happened.</p>';
|
||||
}
|
||||
function solution() {
|
||||
return '<p>It is impossible to give a solution without knowing more about ' .
|
||||
' how the problem was caused. You may be able to get help from the ' .
|
||||
'<a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a>.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000015 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories should belong to a valid context';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return record_exists_sql("
|
||||
SELECT qc.*, (SELECT COUNT(1) FROM {$CFG->prefix}question q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {$CFG->prefix}question_categories qc
|
||||
LEFT JOIN {$CFG->prefix}context con ON qc.contextid = con.id
|
||||
WHERE con.id IS NULL");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
$problemcategories = get_records_sql("
|
||||
SELECT qc.id, qc.name, qc.contextid, (SELECT COUNT(1) FROM {$CFG->prefix}question q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {$CFG->prefix}question_categories qc
|
||||
LEFT JOIN {$CFG->prefix}context con ON qc.contextid = con.id
|
||||
WHERE con.id IS NULL
|
||||
ORDER BY numquestions DESC, qc.name");
|
||||
$table = '<table><thead><tr><th>Cat id</th><th>Category name</th>' .
|
||||
"<th>Context id</th><th>Num Questions</th></tr></thead><tbody>\n";
|
||||
if ($problemcategories) {
|
||||
foreach ($problemcategories as $cat) {
|
||||
$table .= "<tr><td>$cat->id</td><td>" . s($cat->name) . "</td><td>" .
|
||||
$cat->contextid ."</td><td>$cat->numquestions</td></tr>\n";
|
||||
}
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
return '<p>All question categories are linked to a context id, and, ' .
|
||||
'the context they are linked to must exist. The following categories ' .
|
||||
'belong to a non-existant category:</p>' . $table . '<p>Any of these ' .
|
||||
'categories that contain no questions can just be deleted form the database. ' .
|
||||
'Other categories will require more thought.</p>';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '<p>You can delete the empty categories by executing the following SQL:</p><pre>
|
||||
DELETE FROM ' . $CFG->prefix . 'question_categories qc
|
||||
WHERE
|
||||
NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'question q WHERE q.category = qc.id)
|
||||
AND NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'context con WHERE qc.contextid = con.id)
|
||||
</pre><p>Any remaining categories that contain questions will require more thought. ' .
|
||||
'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000016 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories should belong to the same context as their parent';
|
||||
}
|
||||
function exists() {
|
||||
global $CFG;
|
||||
return record_exists_sql("
|
||||
SELECT parent_qc.id AS parent, child_qc.id AS child, child_qc.contextid
|
||||
FROM {$CFG->prefix}question_categories child_qc
|
||||
JOIN {$CFG->prefix}question_categories parent_qc ON child_qc.parent = parent_qc.id
|
||||
WHERE child_qc.contextid <> parent_qc.contextid");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $CFG;
|
||||
$problemcategories = get_records_sql("
|
||||
SELECT
|
||||
parent_qc.id AS parentid, parent_qc.name AS parentname, parent_qc.contextid AS parentcon,
|
||||
child_qc.id AS childid, child_qc.name AS childname, child_qc.contextid AS childcon
|
||||
FROM {$CFG->prefix}question_categories child_qc
|
||||
JOIN {$CFG->prefix}question_categories parent_qc ON child_qc.parent = parent_qc.id
|
||||
WHERE child_qc.contextid <> parent_qc.contextid");
|
||||
$table = '<table><thead><tr><th colspan="3">Child category</th><th colspan="3">Parent category</th></tr><tr>' .
|
||||
'<th>Id</th><th>Name</th><th>Context id</th>' .
|
||||
'<th>Id</th><th>Name</th><th>Context id</th>' .
|
||||
"</tr></thead><tbody>\n";
|
||||
if ($problemcategories) {
|
||||
foreach ($problemcategories as $cat) {
|
||||
$table .= "<tr><td>$cat->childid</td><td>" . s($cat->childname) .
|
||||
"</td><td>$cat->childcon</td><td>$cat->parentid</td><td>" . s($cat->parentname) .
|
||||
"</td><td>$cat->parentcon</td></tr>\n";
|
||||
}
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
return '<p>When one question category is the parent of another, then they ' .
|
||||
'should both belong to the same context. This is not true for the following categories:</p>' .
|
||||
$table;
|
||||
}
|
||||
function solution() {
|
||||
return '<p>An automated solution is difficult. It depends whether the ' .
|
||||
'parent or child category is in the wrong pace.' .
|
||||
'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
class problem_000017 extends problem_base {
|
||||
function title() {
|
||||
return 'Question categories tree structure';
|
||||
}
|
||||
function find_problems() {
|
||||
static $answer = null;
|
||||
|
||||
if (is_null($answer)) {
|
||||
$categories = get_records('question_categories', '', '', 'id');
|
||||
|
||||
// Look for missing parents.
|
||||
$missingparent = array();
|
||||
foreach ($categories as $category) {
|
||||
if ($category->parent != 0 && !array_key_exists($category->parent, $categories)) {
|
||||
$missingparent[$category->id] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for loops.
|
||||
$loops = array();
|
||||
while (!empty($categories)) {
|
||||
$current = array_pop($categories);
|
||||
$thisloop = array($current->id => $current);
|
||||
while (true) {
|
||||
if (isset($thisloop[$current->parent])) {
|
||||
// Loop detected
|
||||
$loops[$current->id] = $thisloop;
|
||||
break;
|
||||
} else if (!isset($categories[$current->parent])) {
|
||||
// Got to the top level, or a category we already know is OK.
|
||||
break;
|
||||
} else {
|
||||
// Continue following the path.
|
||||
$current = $categories[$current->parent];
|
||||
$thisloop[$current->id] = $current;
|
||||
unset($categories[$current->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$answer = array($missingparent, $loops);
|
||||
}
|
||||
|
||||
return $answer;
|
||||
}
|
||||
function exists() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
return !empty($missingparent) || !empty($loops);
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$description = '<p>The question categories should be arranged into tree ' .
|
||||
' structures by the question_categories.parent field. Sometimes ' .
|
||||
' this tree structure gets messed up.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$description .= '<p>The following categories are missing their parents:</p><ul>';
|
||||
foreach ($missingparent as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . "</li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$description .= '<p>The following categories form a loop of parents:</p><ul>';
|
||||
foreach ($loops as $loop) {
|
||||
$description .= "<li><ul>\n";
|
||||
foreach ($loop as $cat) {
|
||||
$description .= "<li>Category $cat->id: " . s($cat->name) . " has parent $cat->parent</li>\n";
|
||||
}
|
||||
$description .= "</ul></li>\n";
|
||||
}
|
||||
$description .= "</ul>\n";
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
list($missingparent, $loops) = $this->find_problems();
|
||||
|
||||
$solution = '<p>Consider executing the following SQL queries. These fix ' .
|
||||
'the problem by moving some categories to the top level.</p>';
|
||||
|
||||
if (!empty($missingparent)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
if (!empty($loops)) {
|
||||
$solution .= "<pre>UPDATE " . $CFG->prefix . "question_categories\n" .
|
||||
" SET parent = 0\n" .
|
||||
" WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
|
||||
}
|
||||
|
||||
return $solution;
|
||||
}
|
||||
}
|
||||
|
||||
class problem_00000x extends problem_base {
|
||||
function title() {
|
||||
return '';
|
||||
}
|
||||
function exists() {
|
||||
return false;
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_SIGNIFICANT;
|
||||
}
|
||||
function description() {
|
||||
return '';
|
||||
}
|
||||
function solution() {
|
||||
global $CFG;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
||||
session.save_path -- it doesn't really matter because we are already IN a session, right?
|
||||
detect unsupported characters in $CFG->wwwroot - see bug Bug #6091 - relative vs absolute path during backup/restore process
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
+324
-543
@@ -1,53 +1,27 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
|
||||
/// Check that config.php exists, if not then call the install script
|
||||
if (!file_exists('../config.php')) {
|
||||
header('Location: ../install.php');
|
||||
/// Check that config.php exists
|
||||
if (!file_exists("../config.php")) {
|
||||
echo "<H2 align=center>You need to create a config.php.<BR>
|
||||
See the <A HREF=\"http://moodle.com/doc/?frame=install.html\">installation instructions</A>.</H2>";
|
||||
die;
|
||||
}
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
|
||||
/// Check that PHP is of a sufficient version
|
||||
/// Moved here because older versions do not allow while(@ob_end_clean());
|
||||
if (version_compare(phpversion(), "4.3.0") < 0) {
|
||||
$phpversion = phpversion();
|
||||
echo "Sorry, Moodle requires PHP 4.3.0 or later (currently using version $phpversion)";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// Turn off time limits and try to flush everything all the time, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
while(@ob_end_clean()); // ob_end_flush prevents sending of headers
|
||||
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
|
||||
require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
|
||||
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$autopilot = optional_param('autopilot', 0, PARAM_BOOL);
|
||||
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
|
||||
$confirmplugincheck = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
|
||||
/// check upgrade status first
|
||||
if ($ignoreupgradewarning and !empty($_SESSION['upgraderunning'])) {
|
||||
$_SESSION['upgraderunning'] = 0;
|
||||
}
|
||||
upgrade_check_running("Upgrade already running in this session, please wait!<br />Click on the exclamation marks to ignore this warning (<a href=\"index.php?ignoreupgradewarning=1\">!!!</a>).", 10);
|
||||
|
||||
/// set install/upgrade autocontinue session flag
|
||||
if ($autopilot) {
|
||||
$_SESSION['installautopilot'] = $autopilot;
|
||||
}
|
||||
|
||||
/// Check some PHP server settings
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
$documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
|
||||
@@ -61,18 +35,11 @@
|
||||
error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
|
||||
}
|
||||
|
||||
if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql
|
||||
error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
|
||||
}
|
||||
|
||||
if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
|
||||
error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
|
||||
}
|
||||
|
||||
/// Check that config.php has been edited
|
||||
|
||||
if ($CFG->wwwroot == "http://example.com/moodle") {
|
||||
error("Moodle has not been configured yet. You need to edit config.php first.");
|
||||
error("Moodle has not been configured yet. You need to to edit config.php first.");
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +48,10 @@
|
||||
$dirroot = dirname(realpath("../index.php"));
|
||||
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
|
||||
error("Please fix your settings in config.php:
|
||||
<p>You have:
|
||||
<p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
|
||||
<p>but it should be:
|
||||
<p>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
|
||||
<P>You have:
|
||||
<P>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
|
||||
<P>but it should be:
|
||||
<P>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
|
||||
"./");
|
||||
}
|
||||
|
||||
@@ -99,13 +66,9 @@
|
||||
$CFG->version = "";
|
||||
}
|
||||
|
||||
if (is_readable("$CFG->dirroot/version.php")) {
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
}
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
if (!$version or !$release) {
|
||||
error('Main version.php was not readable or specified');# without version, stop
|
||||
}
|
||||
@set_time_limit(0);
|
||||
|
||||
/// Check if the main tables have been installed yet or not.
|
||||
|
||||
@@ -114,569 +77,387 @@
|
||||
|
||||
} else { // Check for missing main tables
|
||||
$maintables = true;
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
"user");
|
||||
$mtables = array("config", "course", "course_categories", "course_modules",
|
||||
"course_sections", "log", "log_display", "modules",
|
||||
"user", "user_admins", "user_students", "user_teachers");
|
||||
foreach ($mtables as $mtable) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
if (!in_array($CFG->prefix.$mtable, $tables)) {
|
||||
$maintables = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $maintables) {
|
||||
/// hide errors from headers in case debug enabled in config.php
|
||||
$origdebug = $CFG->debug;
|
||||
$CFG->debug = DEBUG_MINIMAL;
|
||||
error_reporting($CFG->debug);
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
$navigation = build_navigation(array(array('name'=>$strlicense, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strlicense, $strlicense, $navigation, "", "", false, " ", " ");
|
||||
print_heading("<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string('copyrightnotice'));
|
||||
print_box(text_to_html(get_string('gpl')), 'copyrightnotice');
|
||||
if (empty($agreelicence)) {
|
||||
$strlicense = get_string("license");
|
||||
print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
|
||||
print_heading("<A HREF=\"http://moodle.org\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string("copyrightnotice"));
|
||||
print_simple_box_start("center");
|
||||
echo text_to_html(get_string("gpl"));
|
||||
print_simple_box_end();
|
||||
echo "<br />";
|
||||
notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
|
||||
"http://docs.moodle.org/en/License");
|
||||
print_footer('none');
|
||||
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
|
||||
"http://moodle.org/doc/?frame=licence.html");
|
||||
exit;
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
$navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'generalbox boxaligncenter boxwidthwide');
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="agreelicense" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
$strdatabasesetup = get_string("databasesetup");
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $navigation,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
upgrade_log_start();
|
||||
$db->debug = true;
|
||||
|
||||
/// Both old .sql files and new install.xml are supported
|
||||
/// But we prioritise install.xml (XMLDB) if present
|
||||
|
||||
change_db_encoding(); // first try to change db encoding to utf8
|
||||
if (!setup_is_unicodedb()) {
|
||||
// If could not convert successfully, throw error, and prevent installation
|
||||
print_error('unicoderequired', 'admin');
|
||||
}
|
||||
|
||||
$status = false;
|
||||
if (file_exists("$CFG->libdir/db/install.xml")) {
|
||||
$status = install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
|
||||
} else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, " ", " ");
|
||||
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = true;
|
||||
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
notify($strdatabasesuccess, "green");
|
||||
} else {
|
||||
$db->debug = false;
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
}
|
||||
} else {
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
|
||||
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory.");
|
||||
}
|
||||
|
||||
// all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
|
||||
set_config('unicodedb', 1);
|
||||
|
||||
/// Continue with the instalation
|
||||
$db->debug = false;
|
||||
if ($status) {
|
||||
|
||||
/// Groups install is now in core above.
|
||||
|
||||
// Install the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('statsrolesupgraded',time());
|
||||
|
||||
// install core event handlers
|
||||
events_update_definition();
|
||||
|
||||
/// 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('auth' => 'email',
|
||||
'auth_pop3mailbox' => 'INBOX',
|
||||
'enrol' => 'manual',
|
||||
'enrol_plugins_enabled' => 'manual',
|
||||
'style' => 'default',
|
||||
'template' => 'default',
|
||||
'theme' => 'standardwhite',
|
||||
'filter_multilang_converted' => 1));
|
||||
|
||||
// Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
|
||||
// (this should only have any effect during initial install).
|
||||
admin_apply_default_settings(NULL, true);
|
||||
|
||||
notify($strdatabasesuccess, "green");
|
||||
require_once $CFG->dirroot.'/mnet/lib.php';
|
||||
} else {
|
||||
error("Error: Main databases NOT set up successfully");
|
||||
}
|
||||
print_continue('index.php');
|
||||
print_footer('none');
|
||||
print_continue("index.php");
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/// Check version of Moodle code on disk compared with database
|
||||
/// and upgrade if possible.
|
||||
|
||||
if (file_exists("$CFG->dirroot/lib/db/$CFG->dbtype.php")) {
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines old upgrades
|
||||
}
|
||||
if (file_exists("$CFG->dirroot/lib/db/upgrade.php")) {
|
||||
include_once("$CFG->dirroot/lib/db/upgrade.php"); # defines new upgrades
|
||||
}
|
||||
include_once("$CFG->dirroot/version.php"); # defines $version
|
||||
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
|
||||
if ($CFG->version) {
|
||||
if ($CFG->version) {
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
|
||||
/// If the database is not already Unicode then we do not allow upgrading!
|
||||
/// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
|
||||
if (empty($CFG->unicodedb)) {
|
||||
print_error('unicodeupgradeerror', 'error', '', $version);
|
||||
}
|
||||
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$a->oldversion = $CFG->version;
|
||||
$a->newversion = $version;
|
||||
$strdatabasechecking = get_string("databasechecking", "", $a);
|
||||
|
||||
// hide errors from headers in case debug is enabled
|
||||
$origdebug = $CFG->debug;
|
||||
$CFG->debug = DEBUG_MINIMAL;
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
// logo ut in case we are upgrading from pre 1.9 version in order to prevent
|
||||
// weird session/role problems caused by incorrect data in USER and SESSION
|
||||
if ($CFG->version < 2007101500) {
|
||||
require_logout();
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasechecking, $stradministration, $navigation,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
|
||||
print_footer('none');
|
||||
exit;
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
$navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
print_heading(get_string('environment', 'admin'));
|
||||
if (!check_moodle_environment($release, $environment_results, true)) {
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
print_box_end();
|
||||
notice_yesno(get_string('environmenterrorupgrade', 'admin'),
|
||||
'index.php?confirmupgrade=1&confirmrelease=1', 'index.php');
|
||||
} else {
|
||||
notify(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
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" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton">';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
print_footer('none');
|
||||
die;
|
||||
} elseif (empty($confirmplugincheck)) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
$navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, " ", " ");
|
||||
print_heading($strplugincheck);
|
||||
print_box_start('generalbox', 'notice'); // MDL-8330
|
||||
print_string('pluginchecknotice');
|
||||
print_box_end();
|
||||
print_plugin_tables();
|
||||
echo "<br />";
|
||||
echo '<div class="continuebutton">';
|
||||
print_single_button('index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1), get_string('reload'), 'get');
|
||||
echo '</div><br />';
|
||||
echo '<form action="index.php"><div>';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '<input type="hidden" name="confirmplugincheck" value="1" />';
|
||||
echo '</div>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die();
|
||||
|
||||
} else {
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
$navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
|
||||
print_header($strdatabasechecking, $stradministration, $navigation,
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
upgrade_log_start();
|
||||
|
||||
/// Upgrade current language pack if we can
|
||||
upgrade_language_pack();
|
||||
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
/// Launch the old main upgrade (if exists)
|
||||
$status = true;
|
||||
if (function_exists('main_upgrade')) {
|
||||
$status = main_upgrade($CFG->version);
|
||||
}
|
||||
/// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
|
||||
if ($status && function_exists('xmldb_main_upgrade')) {
|
||||
$status = xmldb_main_upgrade($CFG->version);
|
||||
}
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
print_heading($strdatabasechecking);
|
||||
$db->debug=true;
|
||||
if (main_upgrade($CFG->version)) {
|
||||
$db->debug=false;
|
||||
/// If successful, continue upgrading roles and setting everything properly
|
||||
if ($status) {
|
||||
if (empty($CFG->rolesactive)) {
|
||||
|
||||
/// Groups upgrade is now in core above.
|
||||
|
||||
// Upgrade to the roles system.
|
||||
moodle_install_roles();
|
||||
set_config('rolesactive', 1);
|
||||
} else if (!update_capabilities()) {
|
||||
error('Had trouble upgrading the core capabilities for the Roles System');
|
||||
}
|
||||
// update core events
|
||||
events_update_definition();
|
||||
|
||||
require_once($CFG->libdir.'/statslib.php');
|
||||
if (!stats_upgrade_for_roles_wrapper()) {
|
||||
notify('Couldn\'t upgrade the stats tables to use the new roles system');
|
||||
}
|
||||
if (set_config("version", $version)) {
|
||||
remove_dir($CFG->dataroot . '/cache', true); // flush cache
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("upgradesettings.php");
|
||||
print_footer('none');
|
||||
exit;
|
||||
} else {
|
||||
error('Upgrade failed! (Could not update version in config table)');
|
||||
}
|
||||
/// Main upgrade not success
|
||||
} else {
|
||||
notify('Main Upgrade failed! See lib/db/upgrade.php');
|
||||
print_continue('index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1');
|
||||
print_footer('none');
|
||||
if (set_config("version", $version)) {
|
||||
notify($strdatabasesuccess, "green");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
notify("Upgrade failed! (Could not update version in config table)");
|
||||
}
|
||||
upgrade_log_finish();
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrade failed! See /version.php");
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
upgrade_log_start();
|
||||
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
|
||||
upgrade_log_finish();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!set_config("version", $version)) {
|
||||
error("A problem occurred inserting current version into databases");
|
||||
$strcurrentversion = get_string("currentversion");
|
||||
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
if (set_config("version", $version)) {
|
||||
print_heading("You are currently using Moodle version $version (Release $release)");
|
||||
print_continue("index.php");
|
||||
die;
|
||||
} else {
|
||||
$db->debug=true;
|
||||
if (main_upgrade(0)) {
|
||||
print_continue("index.php");
|
||||
} else {
|
||||
error("A problem occurred inserting current version into databases");
|
||||
}
|
||||
$db->debug=false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updated human-readable release version if necessary
|
||||
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
if (!set_config("release", $release)) {
|
||||
error("ERROR: Could not update release version in database!!");
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
print_continue("index.php");
|
||||
print_simple_box_start("CENTER");
|
||||
include("$CFG->dirroot/lang/en/docs/release.html");
|
||||
print_simple_box_end();
|
||||
print_continue("index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
/// Groups install/upgrade is now in core above.
|
||||
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all questiontype plugins and upgrade if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
/// It is important that this is done AFTER the quiz module has been upgraded
|
||||
upgrade_plugins('qtype', 'question/type', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade backup/restore system if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/backup/lib.php");
|
||||
upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Upgrade blocks system if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/lib/blocklib.php");
|
||||
upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all blocks and load (or upgrade them if necessary)
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Find and check all modules and load them up or upgrade them if necessary
|
||||
|
||||
/// Check all enrolment plugins and upgrade if necessary
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
upgrade_plugins('enrol', 'enrol', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all auth plugins and upgrade if necessary
|
||||
upgrade_plugins('auth','auth',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all course formats and upgrade if necessary
|
||||
upgrade_plugins('format','course/format',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check for local database customisations
|
||||
/// first old *.php update and then the new upgrade.php script
|
||||
require_once("$CFG->dirroot/lib/locallib.php");
|
||||
upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check for changes to RPC functions
|
||||
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
|
||||
upgrade_plugins('gradeexport', 'grade/export', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
upgrade_plugins('gradeimport', 'grade/import', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
upgrade_plugins('gradereport', 'grade/report', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all message output plugins and upgrade if necessary
|
||||
upgrade_plugins('message','message/output',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all admin report plugins and upgrade if necessary
|
||||
upgrade_plugins('report', $CFG->admin.'/report', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
|
||||
/// just make sure upgrade logging is properly terminated
|
||||
upgrade_log_finish();
|
||||
|
||||
unset($_SESSION['installautopilot']);
|
||||
|
||||
/// Set up the blank site - to be customized later at the end of install.
|
||||
if (! $site = get_site()) {
|
||||
// We are about to create the site "course"
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
$newsite = new object();
|
||||
$newsite->fullname = "";
|
||||
$newsite->shortname = "";
|
||||
$newsite->summary = NULL;
|
||||
$newsite->newsitems = 3;
|
||||
$newsite->numsections = 0;
|
||||
$newsite->category = 0;
|
||||
$newsite->format = 'site'; // Only for this course
|
||||
$newsite->teacher = get_string("defaultcourseteacher");
|
||||
$newsite->teachers = get_string("defaultcourseteachers");
|
||||
$newsite->student = get_string("defaultcoursestudent");
|
||||
$newsite->students = get_string("defaultcoursestudents");
|
||||
$newsite->timemodified = time();
|
||||
|
||||
if (!$newid = insert_record('course', $newsite)) {
|
||||
error("Serious Error! Could not set up the site!");
|
||||
}
|
||||
// make sure course context exists
|
||||
get_context_instance(CONTEXT_COURSE, $newid);
|
||||
|
||||
// Site created, add blocks for it
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $newid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
$cat = new object();
|
||||
$cat->name = get_string('miscellaneous');
|
||||
$cat->depth = 1;
|
||||
if (!$catid = insert_record('course_categories', $cat)) {
|
||||
error("Serious Error! Could not set up a default course category!");
|
||||
}
|
||||
// make sure category context exists
|
||||
get_context_instance(CONTEXT_COURSECAT, $catid);
|
||||
mark_context_dirty('/'.SYSCONTEXTID);
|
||||
|
||||
redirect('index.php');
|
||||
if (!$mods = get_list_of_plugins("mod") ) {
|
||||
error("No modules installed!");
|
||||
}
|
||||
|
||||
// initialise default blocks on admin and site page if needed
|
||||
if (empty($CFG->adminblocks_initialised)) {
|
||||
require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
$page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
|
||||
blocks_repopulate_page($page);
|
||||
foreach ($mods as $mod) {
|
||||
|
||||
//add admin_tree block to site if not already present
|
||||
if ($admintree = get_record('block', 'name', 'admin_tree')) {
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, SITEID);
|
||||
$pageblocks=blocks_get_by_page($page);
|
||||
blocks_execute_action($page, $pageblocks, 'add', (int)$admintree->id, false, false);
|
||||
if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
|
||||
$pageblocks=blocks_get_by_page($page); // Needs to be re-got, since has just changed
|
||||
blocks_execute_action($page, $pageblocks, 'moveleft', $admintreeinstance, false, false);
|
||||
if ($mod == "NEWMODULE") { // Someone has unzipped the template, ignore it
|
||||
continue;
|
||||
}
|
||||
|
||||
$fullmod = "$CFG->dirroot/mod/$mod";
|
||||
|
||||
unset($module);
|
||||
|
||||
if ( is_readable("$fullmod/version.php")) {
|
||||
include_once("$fullmod/version.php"); # defines $module with version etc
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/version.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
|
||||
include_once("$fullmod/db/$CFG->dbtype.php"); # defines upgrading function
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/db/$CFG->dbtype.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($module)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($module->requires)) {
|
||||
if ($module->requires > $CFG->version) {
|
||||
$info->modulename = $mod;
|
||||
$info->moduleversion = $module->version;
|
||||
$info->currentmoodle = $CFG->version;
|
||||
$info->requiremoodle = $module->requires;
|
||||
notify(get_string('modulerequirementsnotmet', 'error', $info));
|
||||
unset($info);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
set_config('adminblocks_initialised', 1);
|
||||
}
|
||||
|
||||
/// Define the unique site ID code if it isn't already
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
/// Check if the guest user exists. If not, create one.
|
||||
if (! record_exists("user", "username", "guest")) {
|
||||
if (! $guest = create_guest_record()) {
|
||||
notify("Could not create guest user record !!!");
|
||||
$module->name = $mod; // The name MUST match the directory
|
||||
|
||||
if ($currmodule = get_record("modules", "name", $module->name)) {
|
||||
if ($currmodule->version == $module->version) {
|
||||
// do nothing
|
||||
} else if ($currmodule->version < $module->version) {
|
||||
if (empty($updated_modules)) {
|
||||
$strmodulesetup = get_string("modulesetup");
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, " ", " ");
|
||||
}
|
||||
print_heading("$module->name module needs upgrading");
|
||||
$upgrade_function = $module->name."_upgrade";
|
||||
if (function_exists($upgrade_function)) {
|
||||
$db->debug=true;
|
||||
if ($upgrade_function($currmodule->version, $module)) {
|
||||
$db->debug=false;
|
||||
// OK so far, now update the modules record
|
||||
$module->id = $currmodule->id;
|
||||
if (! update_record("modules", $module)) {
|
||||
error("Could not update $module->name record in modules table!");
|
||||
}
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!");
|
||||
}
|
||||
}
|
||||
$updated_modules = true;
|
||||
} else {
|
||||
error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !");
|
||||
}
|
||||
|
||||
} else { // module not installed yet, so install it
|
||||
if (empty($updated_modules)) {
|
||||
$strmodulesetup = get_string("modulesetup");
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, " ", " ");
|
||||
}
|
||||
print_heading($module->name);
|
||||
$updated_modules = true;
|
||||
$db->debug = true;
|
||||
@set_time_limit(0); // To allow slow databases to complete the long SQL
|
||||
if (modify_database("$fullmod/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
if ($module->id = insert_record("modules", $module)) {
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
error("$module->name module could not be added to the module list!");
|
||||
}
|
||||
} else {
|
||||
error("$module->name tables could NOT be set up successfully!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($updated_modules)) {
|
||||
print_continue("index.php");
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
/// Set up the overall site name etc.
|
||||
if (! $site = get_site()) {
|
||||
redirect("site.php");
|
||||
}
|
||||
|
||||
/// Set up the admin user
|
||||
if (empty($CFG->rolesactive)) {
|
||||
build_context_path(); // just in case - should not be needed
|
||||
create_admin_user();
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
redirect("user.php");
|
||||
}
|
||||
|
||||
/// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
/// Check for valid admin user
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
/// check that site is properly customized
|
||||
if (empty($site->shortname)) {
|
||||
// probably new installation - lets return to frontpage after this step
|
||||
// remove settings that we want uninitialised
|
||||
unset_config('registerauth');
|
||||
redirect('upgradesettings.php?return=site');
|
||||
}
|
||||
|
||||
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
|
||||
|
||||
if (!empty($id)) {
|
||||
if ($id == $CFG->siteidentifier) {
|
||||
set_config('registered', time());
|
||||
}
|
||||
}
|
||||
|
||||
/// setup critical warnings before printing admin tree block
|
||||
$insecuredataroot = is_dataroot_insecure(true);
|
||||
$register_globals_enabled = ini_get_bool('register_globals');
|
||||
|
||||
$SESSION->admin_critical_warning = ($register_globals_enabled || $insecuredataroot==INSECURE_DATAROOT_ERROR);
|
||||
|
||||
$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)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
/// Everything should now be set up, and the user is an admin
|
||||
|
||||
/// Print default admin page with notifications.
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/// Deprecated database! Warning!!
|
||||
if (!empty($CFG->migrated_to_new_db)) {
|
||||
print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Check for any special upgrades that might need to be run
|
||||
if (!empty($CFG->upgrade)) {
|
||||
print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
|
||||
}
|
||||
|
||||
if ($register_globals_enabled) {
|
||||
print_box(get_string('globalswarning', 'admin'), 'generalbox adminerror');
|
||||
}
|
||||
|
||||
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
|
||||
print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
|
||||
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
|
||||
print_box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
|
||||
|
||||
}
|
||||
|
||||
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
|
||||
print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
if (substr($CFG->wwwroot, -1) == '/') {
|
||||
print_box(get_string('cfgwwwrootslashwarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
if (strpos($ME, $CFG->httpswwwroot.'/') === false) {
|
||||
print_box(get_string('cfgwwwrootwarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// If no recently cron run
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
$strinstallation = get_string('installation', 'install');
|
||||
$helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
|
||||
print_box(get_string('cronwarning', 'admin')." ".$helpbutton, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Print multilang upgrade notice if needed
|
||||
if (empty($CFG->filter_multilang_converted)) {
|
||||
print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
/// Alert if we are currently in maintenance mode
|
||||
if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
|
||||
print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
|
||||
/// Print slightly annoying registration button
|
||||
$options = array();
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_box_start('generalbox adminwarning');
|
||||
if(!isset($CFG->registered)) {
|
||||
print_string('pleaseregister', 'admin');
|
||||
/// At this point everything is set up and the user is an admin, so print menu
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
print_header("$site->shortname: $stradministration","$site->fullname", "$stradministration");
|
||||
print_simple_box_start("center", "100%", "$THEME->cellcontent2", 20);
|
||||
print_heading($stradministration);
|
||||
|
||||
if (!empty($CFG->upgrade)) { // Print notice about extra upgrading that needs to be done
|
||||
print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
|
||||
"$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center");
|
||||
print_spacer(10,10);
|
||||
}
|
||||
else { /* if (isset($CFG->registered) && $CFG->registered < (time() - 3600*24*30*6)) { */
|
||||
print_string('pleaserefreshregistration', 'admin', userdate($CFG->registered));
|
||||
|
||||
$table->tablealign = "right";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 3;
|
||||
$table->width = "40%";
|
||||
|
||||
$configdata = "<font size=+1> </font><a href=\"config.php\">".get_string("configvariables")."</a> - <font size=1>".
|
||||
get_string("adminhelpconfigvariables")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"site.php\">".get_string("sitesettings")."</a> - <font size=1>".
|
||||
get_string("adminhelpsitesettings")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"../theme/index.php\">".get_string("themes")."</a> - <font size=1>".
|
||||
get_string("adminhelpthemes")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"lang.php\">".get_string("language")."</a> - <font size=1>".
|
||||
get_string("adminhelplanguage")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagemodules")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"blocks.php\">".get_string("manageblocks")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanageblocks")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"filters.php\">".get_string("managefilters")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagefilters")."</font><br />";
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$configdata .= "<font size=+1> </font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
|
||||
get_string("adminhelpbackup")."</font><br />";
|
||||
}
|
||||
print_single_button('register.php', $options, get_string('registration'));
|
||||
print_box_end();
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
|
||||
$configdata);
|
||||
|
||||
|
||||
$userdata = "<font size=+1> </font><a href=\"auth.php\">".get_string("authentication")."</a> - <font size=1>".
|
||||
get_string("adminhelpauthentication")."</font><br />";
|
||||
|
||||
if (is_internal_auth()) {
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true\">".
|
||||
get_string("addnewuser")."</a> - <font size=1>".
|
||||
get_string("adminhelpaddnewuser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php\">".
|
||||
get_string("uploadusers")."</a> - <font size=1>".
|
||||
get_string("adminhelpuploadusers")."</font><br />";
|
||||
}
|
||||
$userdata .= "<font size=+1> </font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
|
||||
get_string("adminhelpedituser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"admin.php\">".get_string("assignadmins")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignadmins")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"creators.php\">".get_string("assigncreators")."</a> - <font size=1>".
|
||||
get_string("adminhelpassigncreators")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=on\">".get_string("assignteachers")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignteachers").
|
||||
" <img src=\"../pix/t/user.gif\" height=11 width=11></font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignstudents")."</font>";
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"users.php\">".get_string("users")."</a></b>", $userdata);
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on\">".get_string("courses")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpcourses"));
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/log.php?id=$site->id\">".get_string("logs")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelplogs"));
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../files/index.php?id=$site->id\">".get_string("sitefiles")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpsitefiles"));
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
|
||||
$table->data[] = array("<font size=+1><b><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpmanagedatabase"));
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
|
||||
'<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
|
||||
'Copyright © 1999 onwards, Martin Dougiamas<br />'.
|
||||
'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'.
|
||||
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
|
||||
print_box($copyrighttext, 'copyright');
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO REMOVE OR MODIFY THE COPYRIGHT NOTICE BELOW ////
|
||||
$copyrighttext = "<a href=\"http://moodle.org/\">Moodle</a> ".
|
||||
"<a href=\"../doc/?frame=release.html\">$CFG->release</a> ($CFG->version)<br />".
|
||||
"Copyright © 1999-2004 Martin Dougiamas<br />".
|
||||
"<a href=\"../doc/?frame=licence.html\">GNU Public License</a>";
|
||||
echo "<center><p><font size=1>$copyrighttext</font></p></center>";
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
echo "<table border=0 align=center width=100%><tr>";
|
||||
echo "<td align=center width=33%>";
|
||||
print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation"));
|
||||
echo "</td>";
|
||||
|
||||
echo "<td align=center width=33%>";
|
||||
print_single_button("phpinfo.php", NULL, get_string("phpinfo"));
|
||||
echo "</td>";
|
||||
|
||||
echo "<td align=center width=33%>";
|
||||
print_single_button("register.php", NULL, get_string("registration"));
|
||||
echo "</td>";
|
||||
echo "<tr></table>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toinodb');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
|
||||
if ($CFG->dbfamily != 'mysql') {
|
||||
notice('This function is for MySQL databases only!', 'index.php');
|
||||
}
|
||||
|
||||
if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
|
||||
notify('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
|
||||
if ($tables = $db->MetaTables()) {
|
||||
$db->debug = true;
|
||||
foreach ($tables as $table) {
|
||||
execute_sql("ALTER TABLE $table TYPE=INNODB; ");
|
||||
}
|
||||
$db->debug = false;
|
||||
}
|
||||
notify('... done.', 'notifysuccess');
|
||||
print_continue('index.php');
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
} else {
|
||||
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
|
||||
notice_yesno('Are you sure you want convert all your tables to the InnoDB format?',
|
||||
'innodb.php', 'index.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
}
|
||||
|
||||
?>
|
||||
+176
-1250
File diff suppressed because it is too large
Load Diff
@@ -1,259 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* This script enables Moodle translators to edit /docs and /help language
|
||||
* files directly via WWW interface.
|
||||
*
|
||||
* Author: mudrd8mz@uxit.pedf.cuni.cz (http://moodle.cz)
|
||||
* Based on: lang.php in 1.4.3+ release
|
||||
* Thanks: Jaime Villate for important bug fixing, koen roggemans for his job and all moodlers
|
||||
* for intensive testing of this my first contribution
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('langedit');
|
||||
|
||||
//
|
||||
// Some local configuration
|
||||
//
|
||||
$fileeditorrows = 12; // number of textareas' rows
|
||||
$fileeditorcols = 100; // dtto cols
|
||||
$fileeditorinline = 1; // shall be textareas put in one row?
|
||||
$filemissingmark = ' (***)'; // mark to add to non-existing filenames in selection form
|
||||
$fileoldmark = ' (old?)'; // mark to add to filenames in selection form id english version is newer
|
||||
// or to filenames with filesize() == 0
|
||||
$filetemplate = ''; // template for new files, i.e. '$Id$';
|
||||
|
||||
$currentfile = optional_param('currentfile', 'docs/README.txt', PARAM_PATH);
|
||||
|
||||
$strlanguage = get_string("language");
|
||||
$strcurrentlanguage = get_string("currentlanguage");
|
||||
$strthislanguage = get_string("thislanguage");
|
||||
$stredithelpdocs = get_string('edithelpdocs', 'admin');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
notify('NOTICE: This interface is obsolete now and will be removed. You should use
|
||||
improved <a href="lang.php?mode=helpfiles">lang.php</a> interface.');
|
||||
|
||||
$currentlang = current_language();
|
||||
$langdir = "$CFG->dataroot/lang/$currentlang";
|
||||
$enlangdir = "$CFG->dirroot/lang/en_utf8";
|
||||
|
||||
|
||||
if (!file_exists($langdir)) {
|
||||
error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang');
|
||||
}
|
||||
// Shall I save POSTed data?
|
||||
|
||||
if (isset($_POST['currentfile'])) {
|
||||
if (confirm_sesskey()) {
|
||||
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0); // Error reporting turned off due to non-existing files
|
||||
|
||||
// Generate selection for all help and documentation files
|
||||
|
||||
// Get all files from /docs directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
|
||||
error("Could not find English language docs files!");
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the docs files.
|
||||
$options["docs/$file"] = "docs/$file";
|
||||
// add mark if file doesn't exist or is empty
|
||||
if (( !file_exists("$langdir/docs/$file")) || (filesize("$langdir/docs/$file") == 0)) {
|
||||
$options["docs/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/docs/$file") < filemtime("$CFG->dirroot/lang/en_utf8/docs/$file")) {
|
||||
$options["docs/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all files from /help directory
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
|
||||
foreach ($files as $filekey => $file) { // check all the help files.
|
||||
$options["help/$file"] = "help/$file";
|
||||
if (( !file_exists("$langdir/help/$file")) || (filesize("$CFG->dirroot/lang/en_utf8/help/$file") == 0)) {
|
||||
$options["help/$file"] .= "$filemissingmark";
|
||||
} else {
|
||||
if (filemtime("$langdir/help/$file") < filemtime("$langdir/help/$file")) {
|
||||
$options["help/$file"] .= "$fileoldmark";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr><td align=\"center\">";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=", $options, "choosefile", $currentfile, "", "", "", true);
|
||||
echo "</td></tr></table>";
|
||||
|
||||
// Generate textareas
|
||||
|
||||
if (!empty($currentfile)) {
|
||||
|
||||
if (!file_exists("$langdir/$currentfile")) {
|
||||
//check if directory exist
|
||||
$pathparts = explode('/',$currentfile);
|
||||
$checkpath = $langdir;
|
||||
for ($a=0; $a < count($pathparts)-1 ; $a++) {
|
||||
$checkpath .= "/".$pathparts[$a];
|
||||
if(!file_exists($checkpath)){
|
||||
if(!mkdir($checkpath)){
|
||||
echo ("Cannot create directory: $checkpath");
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// file doesn't exist - let's check webserver's permission to create it
|
||||
//
|
||||
if (!touch("$langdir/$currentfile")) {
|
||||
//
|
||||
// webserver is unable to create new file
|
||||
//
|
||||
echo "<p align=\"center\"><font color=red>".get_string("filemissing", "", "
|
||||
$langdir/$currentfile")."</font></p>";
|
||||
$editable = false;
|
||||
} else {
|
||||
//
|
||||
// webserver can create new file - we can delete it now and let
|
||||
// the langdoc_save_file() create it again if its filesize() > 0
|
||||
//
|
||||
$editable = true;
|
||||
unlink("$langdir/$currentfile");
|
||||
}
|
||||
} elseif ($f = fopen("$langdir/$currentfile","r+")) {
|
||||
//
|
||||
// file exists and is writeable - good for you, translator ;-)
|
||||
//
|
||||
$editable = true;
|
||||
fclose($f);
|
||||
} else {
|
||||
//
|
||||
// file exists but it is not writeable by web server process :-(
|
||||
//
|
||||
$editable = false;
|
||||
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")
|
||||
."</font></p>";
|
||||
}
|
||||
|
||||
//en_utf8 in dataroot is not editable
|
||||
if ($currentlang == 'en_utf8') {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
echo "<table align=\"center\"><tr valign=\"center\"><td align=\"center\">\n";
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"\">\n";
|
||||
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
|
||||
echo "</textarea>\n";
|
||||
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url.'&forcelang=en_utf8', 'popup', get_string('preview'));
|
||||
}
|
||||
echo "</td>\n";
|
||||
if ($fileeditorinline == 1) {
|
||||
echo "</tr>\n<tr valign=\"center\">\n";
|
||||
}
|
||||
echo "<td align=\"center\">\n";
|
||||
|
||||
if ($editable) {
|
||||
echo "<form id=\"$currentfile\" action=\"langdoc.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo '<input type="hidden" name="currentfile" value="'.$currentfile.'" />';
|
||||
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"filedata\">\n";
|
||||
if (file_exists("$langdir/$currentfile")) {
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
} else {
|
||||
echo ($filetemplate);
|
||||
}
|
||||
echo "</textarea>\n";
|
||||
$preview_url = langdoc_preview_url($currentfile);
|
||||
if ($preview_url) {
|
||||
link_to_popup_window($preview_url, 'popup', get_string('preview'));
|
||||
}
|
||||
echo '<div align="center"><input type="submit" value="'.get_string('savechanges').': lang/'.$currentlang.'/'.$currentfile.'" /></div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
echo "</td>\n</tr>\n</table>";
|
||||
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
function langdoc_save_file($path, $file, $content) {
|
||||
|
||||
// $path is a full pathname to the file
|
||||
// $file is the file to overwrite.
|
||||
// $content are data to write
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
if (!$f = fopen("$path/$file","w")) {
|
||||
error_reporting($CFG->debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
$content = str_replace("\r", "",$content); // Remove linefeed characters
|
||||
$content = preg_replace("/\n{3,}/", "\n\n", $content); // Collapse runs of blank lines
|
||||
$content = trim($content); // Delete leading/trailing whitespace
|
||||
|
||||
fwrite($f, stripslashes($content));
|
||||
|
||||
fclose($f);
|
||||
|
||||
// Remove file if its empty
|
||||
|
||||
if (filesize("$path/$file") == 0) {
|
||||
unlink("$path/$file");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a preview URL for the file, if available.
|
||||
*
|
||||
* Documentation will be moved into moodle.org wiki and current version 1.6 does not
|
||||
* seem to be able to display local documentation. Thus, return empty URL for doc files.
|
||||
* See lib/moodlelib.php document_file() - it still relies on old pre-UTF8 lang/ location.
|
||||
*/
|
||||
function langdoc_preview_url($currentfile) {
|
||||
if (substr($currentfile, 0, 5) == 'help/') {
|
||||
$currentfile = substr($currentfile, 5);
|
||||
$currentpathexp = explode('/', $currentfile);
|
||||
if (count($currentpathexp) > 1) {
|
||||
$url = '/help.php?module='.implode('/',array_slice($currentpathexp,0,count($currentpathexp)-1)).'&file='.end($currentpathexp);
|
||||
} else {
|
||||
$url = '/help.php?module=moodle&file='.$currentfile;
|
||||
}
|
||||
} else {
|
||||
$url = '';
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,439 +0,0 @@
|
||||
<?php //$Id$
|
||||
///This file only manages the installation of 1.6 lang packs.
|
||||
///in downloads.moodle.org, they are store in separate directory /lang16
|
||||
///in local server, they are stored in $CFG->dataroot/lang
|
||||
///This helps to avoid confusion.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
admin_externalpage_setup('langimport');
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); //phase
|
||||
$pack = optional_param('pack', array(), PARAM_FILE); //pack to install
|
||||
$displaylang = $pack;
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_FILE);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$sitelang = optional_param('sitelangconfig', '', PARAM_FILE);
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
$strlang = get_string('langimport','admin');
|
||||
$strlanguage = get_string('language');
|
||||
$strthislanguage = get_string('thislanguage');
|
||||
$title = $strlang;
|
||||
|
||||
//reset and diagnose lang cache permissions
|
||||
@unlink($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
|
||||
$notice_ok = array();
|
||||
$notice_error = array();
|
||||
|
||||
switch ($mode){
|
||||
|
||||
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
|
||||
|
||||
if (confirm_sesskey() and !empty($pack)) {
|
||||
set_time_limit(0);
|
||||
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
|
||||
if (is_array($pack)) {
|
||||
$packs = $pack;
|
||||
} else {
|
||||
$packs = array($pack);
|
||||
}
|
||||
|
||||
foreach ($packs as $pack) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new object();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', 'langimport.php', $a);
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', 'langimport.php');
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
|
||||
break;
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
notify('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
|
||||
|
||||
if ($uninstalllang == 'en_utf8') {
|
||||
$notice_error[] = 'en_utf8 can not be uninstalled!';
|
||||
|
||||
} else if (!$confirm && confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode='.DELETION_OF_SELECTED_LANG.'&uninstalllang='.$uninstalllang.'&confirm=1&sesskey='.sesskey(),
|
||||
'langimport.php');
|
||||
print_footer();
|
||||
die;
|
||||
|
||||
} else if (confirm_sesskey()) {
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$uninstalllang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$uninstalllang;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)){
|
||||
$rm1 = remove_dir($dest1);
|
||||
}
|
||||
if (file_exists($dest2)){
|
||||
$rm2 = remove_dir($dest2);
|
||||
}
|
||||
get_list_of_languages(true); //refresh lang cache
|
||||
//delete the direcotries
|
||||
if ($rm1 or $rm2) {
|
||||
$notice_ok[] = get_string('langpackremoved','admin');
|
||||
} else { //nothing deleted, possibly due to permission error
|
||||
$notice_error[] = 'An error has occurred, language pack is not completely uninstalled, please check file permissions';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case UPDATE_ALL_LANG: //1 click update for all updatable language packs
|
||||
set_time_limit(0);
|
||||
|
||||
//0th pull a list from download.moodle.org,
|
||||
//key = langname, value = md5
|
||||
$md5array = array();
|
||||
$updated = 0; //any packs updated?
|
||||
$alllangs = array_keys(get_list_of_languages(false, true)); //get all available langs
|
||||
$lang16 = array(); //all the Moodle 1.6 unicode lang packs (updated and not updated)
|
||||
$packs = array(); //all the packs that needs updating
|
||||
|
||||
|
||||
if (!$availablelangs = get_remote_list_of_languages()) {
|
||||
print_error('cannotdownloadlanguageupdatelist');
|
||||
}
|
||||
|
||||
//and build an associative array
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
//filtering out non-16 and unofficial packs
|
||||
foreach ($alllangs as $clang) {
|
||||
if (!array_key_exists($clang, $md5array)) {
|
||||
$notice_ok[] = get_string('langpackupdateskipped', 'admin', $clang);
|
||||
continue;
|
||||
}
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$clang;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$clang;
|
||||
|
||||
if (file_exists($dest1.'/langconfig.php') || file_exists($dest2.'/langconfig.php')){
|
||||
$lang16[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
//then filter out packs that have the same md5 key
|
||||
foreach ($lang16 as $clang) {
|
||||
if (!is_installed_lang($clang, $md5array[$clang])){
|
||||
$packs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
@mkdir ($CFG->dataroot.'/temp/');
|
||||
@mkdir ($CFG->dataroot.'/lang/');
|
||||
foreach ($packs as $pack){ //for each of the remaining in the list, we
|
||||
if ($pack == 'en_utf8') { // no update for en_utf8
|
||||
continue;
|
||||
}
|
||||
|
||||
//1. delete old director(ies)
|
||||
|
||||
$dest1 = $CFG->dataroot.'/lang/'.$pack;
|
||||
$dest2 = $CFG->dirroot.'/lang/'.$pack;
|
||||
$rm1 = false;
|
||||
$rm2 = false;
|
||||
if (file_exists($dest1)) {
|
||||
if (!remove_dir($dest1)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest1.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (file_exists($dest2)) {
|
||||
if (!remove_dir($dest2)) {
|
||||
$notice_error[] = 'Could not delete old directory '.$dest2.', update of '.$pack.' failed, please check permissions.';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//2. copy & unzip into new
|
||||
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
|
||||
$pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/lang16/'.$pack.'.zip';
|
||||
$a->dest= $CFG->dataroot.'/lang';
|
||||
print_error($cd->get_error(), 'error', "", $a); // not probable
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error'); // not probable
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
//Print error string or whatever you want to do
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackupdated', 'admin', $pack);
|
||||
$updated = true;
|
||||
//Print/do whatever you want
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
$notice_ok[] = get_string('langupdatecomplete','admin');
|
||||
} else {
|
||||
$notice_ok[] = get_string('nolangupdateneeded','admin');
|
||||
}
|
||||
|
||||
break;
|
||||
} //close of main switch
|
||||
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$installedlangs = get_list_of_languages(true, true);
|
||||
|
||||
$missingparents = array();
|
||||
$oldlang = isset($SESSION->lang) ? $SESSION->lang : null; // override current lang
|
||||
|
||||
foreach($installedlangs as $l=>$unused) {
|
||||
$SESSION->lang = $l;
|
||||
$parent = get_string('parentlanguage');
|
||||
if ($parent == 'en_utf8') {
|
||||
continue;
|
||||
}
|
||||
if (strpos($parent, '[[') !== false) {
|
||||
continue; // no parent
|
||||
}
|
||||
if (!isset($installedlangs[$parent])) {
|
||||
$missingparents[$l] = $parent;
|
||||
}
|
||||
}
|
||||
if (isset($oldlang)) {
|
||||
$SESSION->lang = $oldlang;
|
||||
} else {
|
||||
unset($SESSION->lang);
|
||||
}
|
||||
|
||||
if ($availablelangs = get_remote_list_of_languages()) {
|
||||
$remote = 1;
|
||||
} else {
|
||||
$remote = 0; //flag for reading from remote or local
|
||||
$availablelangs = get_local_list_of_languages();
|
||||
}
|
||||
|
||||
if (!$remote) {
|
||||
print_box_start();
|
||||
print_string('remotelangnotavailable', 'admin', $CFG->dataroot.'/lang/');
|
||||
print_box_end();
|
||||
}
|
||||
|
||||
if ($notice_ok) {
|
||||
$info = implode('<br />', $notice_ok);
|
||||
notify($info, 'notifysuccess');
|
||||
}
|
||||
|
||||
if ($notice_error) {
|
||||
$info = implode('<br />', $notice_error);
|
||||
notify($info, 'notifyproblem');
|
||||
}
|
||||
|
||||
if ($missingparents) {
|
||||
foreach ($missingparents as $l=>$parent) {
|
||||
$a = new object();
|
||||
$a->lang = $installedlangs[$l];
|
||||
$a->parent = $parent;
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == $parent) {
|
||||
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
|
||||
$shortlang = substr($alang[0], 0, -5);
|
||||
} else {
|
||||
$shortlang = $alang[0];
|
||||
}
|
||||
$a->parent = $alang[2].' ('.$shortlang.')';
|
||||
}
|
||||
}
|
||||
$info = get_string('missinglangparent', 'admin', $a);
|
||||
notify($info, 'notifyproblem');
|
||||
}
|
||||
}
|
||||
|
||||
print_box_start();
|
||||
echo '<table summary="">';
|
||||
echo '<tr><td align="center" valign="top">';
|
||||
echo '<form id="uninstallform" action="langimport.php?mode='.DELETION_OF_SELECTED_LANG.'" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
|
||||
/// display installed langs here
|
||||
|
||||
echo '<label for="uninstalllang">'.get_string('installedlangs','admin')."</label><br />\n";
|
||||
echo '<select name="uninstalllang" id="uninstalllang" size="15">';
|
||||
foreach ($installedlangs as $clang =>$ilang){
|
||||
echo '<option value="'.$clang.'">'.$ilang.'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.get_string('uninstall','admin').'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($remote) {
|
||||
echo '<form id="updateform" action="langimport.php?mode='.UPDATE_ALL_LANG.'" method="post">';
|
||||
echo '<div>';
|
||||
echo '<br /><input type="submit" value="'.get_string('updatelangs','admin').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/// Display option to change site language
|
||||
|
||||
/// display to be installed langs here
|
||||
|
||||
echo '</td><td align="center" valign="top">';
|
||||
//availabe langs table
|
||||
$empty = 1; //something to pring
|
||||
|
||||
/// if this language pack is not already installed, then we allow installation
|
||||
|
||||
echo '<form id="installform" method="post" action="langimport.php?mode='.INSTALLATION_OF_SELECTED_LANG.'">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
|
||||
echo '<label for="pack">'.get_string('availablelangs','admin')."</label><br />\n";
|
||||
if ($remote) {
|
||||
echo '<select name="pack[]" id="pack" size="15" multiple="multiple">';
|
||||
}
|
||||
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (trim($alang[0]) != "en_utf8") {
|
||||
if ($remote) {
|
||||
if (substr($alang[0], -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
|
||||
$shortlang = substr($alang[0], 0, -5);
|
||||
} else {
|
||||
$shortlang = $alang[0];
|
||||
}
|
||||
if (!is_installed_lang($alang[0], $alang[1])){ //if not already installed
|
||||
echo '<option value="'.$alang[0].'">'.$alang[2].' ('.$shortlang.')</option>';
|
||||
}
|
||||
} else { //print list in local format, and instruction to install
|
||||
echo '<tr><td>'.$alang[2].'</td><td><a href="http://download.moodle.org/lang16/'.$alang[0].'.zip">'.get_string('download','admin').'</a></td></tr>';
|
||||
}
|
||||
$empty = 0;
|
||||
}
|
||||
}
|
||||
if ($remote) {
|
||||
echo '</select>';
|
||||
echo '<br /><input type="submit" value="'.$THEME->larrow.' '.get_string('install','admin').'" />';
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
if ($empty) {
|
||||
echo '<br />';
|
||||
print_string('nolanguagetodownload','admin');
|
||||
}
|
||||
|
||||
//close available langs table
|
||||
echo '</td></tr></table>';
|
||||
print_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
/**
|
||||
* Returns a list of available language packs from a
|
||||
* local copy shipped with standard moodle distro
|
||||
* this is for site that can't download components.
|
||||
* @return array
|
||||
*/
|
||||
function get_local_list_of_languages() {
|
||||
global $CFG;
|
||||
$source = $CFG->dirroot.'/lib/languages.md5';
|
||||
$availablelangs = array();
|
||||
if ($fp = fopen($source, 'r')) {
|
||||
while(!feof ($fp)) {
|
||||
$availablelangs[] = split(',', fgets($fp,1024));
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks the md5 of the zip file, grabbed from download.moodle.org,
|
||||
* against the md5 of the local language file from last update
|
||||
* @param string $lang
|
||||
* @param string $md5check
|
||||
* @return bool
|
||||
*/
|
||||
function is_installed_lang($lang, $md5check) {
|
||||
global $CFG;
|
||||
$md5file = $CFG->dataroot.'/lang/'.$lang.'/'.$lang.'.md5';
|
||||
if (file_exists($md5file)){
|
||||
return (file_get_contents($md5file) == $md5check);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest list of available language packs from
|
||||
* moodle.org
|
||||
* @return array or false if can not download
|
||||
*/
|
||||
function get_remote_list_of_languages() {
|
||||
$source = 'http://download.moodle.org/lang16/languages.md5';
|
||||
$availablelangs = array();
|
||||
|
||||
if ($content = download_file_content($source)) {
|
||||
$alllines = split("\n", $content);
|
||||
foreach($alllines as $line) {
|
||||
if (!empty($line)){
|
||||
$availablelangs[] = split(',', $line);
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*
|
||||
* Utility to debug mailouts - will save the content of emails to a
|
||||
* logfile instead of sending them out. Use it as a sendmail
|
||||
* "stand-in" when testing mailouts.
|
||||
*
|
||||
* It is not Moodle specific - use it anywhere by setting the php
|
||||
* "sendmail_path" setting to this file with a logfile parameter.
|
||||
*
|
||||
* - Set in php.ini (not settable in config.php):
|
||||
* sendmail_path=/path-to-moodle/admin/mailout-debugger.php');
|
||||
* Or from the commandline
|
||||
* php -d sendmail_path='/path-to-moodle/admin/mailout-debugger.php' /path/to/cron.php
|
||||
*
|
||||
* - Create a file in admin called mailout-debugger.enable
|
||||
* (this is a security check to prevent execution in prod environments)
|
||||
* touch /path/to/moodle/admin/mailout-debugger.enable
|
||||
*
|
||||
* - Mark as executable: chmod ugo+rx mailout-debugger.php
|
||||
*
|
||||
* - Run your admin/cron.php
|
||||
*
|
||||
* - Read /tmp/moodle-mailout.log
|
||||
*
|
||||
*
|
||||
* This script will create logfiles in /tmp/ or in $TMPDIR if set.
|
||||
* On windows, use php -r 'print sys_get_temp_dir()' to see where the file is saved.
|
||||
*/
|
||||
|
||||
// Security check.
|
||||
if (!file_exists(dirname(__FILE__).'/mailout-debugger.enable')) {
|
||||
mdie("Disabled.");
|
||||
}
|
||||
$tmpdir=sys_get_temp_dir(); // default
|
||||
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
mdie("should not be called from web server!");
|
||||
}
|
||||
|
||||
if (isset($_ENV['TMPDIR']) && is_dir($_ENV['TMPDIR'])) {
|
||||
$tmpdir = $_ENV['TMPDIR'];
|
||||
}
|
||||
|
||||
$tmpfile = $tmpdir . '/moodle-mailout.log';
|
||||
$fh = fopen($tmpfile, 'a+', false)
|
||||
or mdie("Error openning $tmpfile on append\n");
|
||||
fwrite($fh, "==== ".strftime("%a %b %e %H:%M:%S %Y", time())." ====\n");
|
||||
fwrite($fh, "==== Commandline: " . implode(' ',$argv) . "\n");
|
||||
|
||||
$stdin = fopen('php://stdin', 'r');
|
||||
|
||||
while ($line = fgets($stdin)) {
|
||||
fwrite($fh, $line);
|
||||
}
|
||||
fwrite($fh, "\n");
|
||||
fclose($fh);
|
||||
fclose($stdin);
|
||||
|
||||
/**
|
||||
* Print an error to STDOUT and exit with a non-zero code. For commandline scripts.
|
||||
* Default errorcode is 1.
|
||||
*
|
||||
* Very useful for perl-like error-handling:
|
||||
*
|
||||
* do_somethting() or mdie("Something went wrong");
|
||||
*
|
||||
* @param string $msg Error message
|
||||
* @param integer $errorcode Error code to emit
|
||||
*
|
||||
*/
|
||||
function mdie($msg='', $errorcode=1) {
|
||||
trigger_error($msg);
|
||||
exit($errorcode);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Enables/disables maintenance mode
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('maintenancemode');
|
||||
|
||||
//Check folder exists
|
||||
if (! make_upload_directory(SITEID)) { // Site folder
|
||||
error("Could not create site folder. The site administrator needs to fix the file permissions");
|
||||
}
|
||||
|
||||
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($form->action == "disable") {
|
||||
unlink($filename);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
|
||||
} else {
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, stripslashes($form->text));
|
||||
fclose($file);
|
||||
redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print the header stuff
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/// Print the appropriate form
|
||||
|
||||
if (file_exists($filename)) { // We are in maintenance mode
|
||||
echo '<div style="margin-left:auto;margin-right:auto">';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<input type="hidden" name="action" value="disable" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<p><input type="submit" value="'.get_string('disable').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
} else { // We are not in maintenance mode
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
echo '<div style="text-align:center;margin-left:auto;margin-right:auto">';
|
||||
echo '<form action="maintenance.php" method="post">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="action" value="enable" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<p><input type="submit" value="'.get_string('enable').'" /></p>';
|
||||
echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
|
||||
echo '<table><tr><td>';
|
||||
print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
|
||||
echo '</td></tr></table>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,583 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Adapted for Moodle from the AMFPHP Project at http://www.amfphp.org/
|
||||
* Creates the methodTable for a service class.
|
||||
*
|
||||
* @usage $this->methodTable = MethodTable::create($this);
|
||||
* @author Christophe Herreman
|
||||
* @since 05/01/2005
|
||||
* @version $id$
|
||||
*
|
||||
* Special contributions by Allessandro Crugnola and Ted Milker
|
||||
*/
|
||||
|
||||
if (!defined('T_ML_COMMENT')) {
|
||||
define('T_ML_COMMENT', T_COMMENT);
|
||||
} else {
|
||||
define('T_DOC_COMMENT', T_ML_COMMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string from start of haystack to first occurance of needle, or whole
|
||||
* haystack, if needle does not occur
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strrstr($haystack, $needle)
|
||||
{
|
||||
return substr($haystack, 0, strpos($haystack.$needle,$needle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return substring of haystack from end of needle onwards, or FALSE
|
||||
*
|
||||
* @access public
|
||||
* @param $haystack(String) Haystack to search in
|
||||
* @param $needle(String) Needle to look for
|
||||
*/
|
||||
function strstrafter($haystack, $needle)
|
||||
{
|
||||
return substr(strstr($haystack, $needle), strlen($needle));
|
||||
}
|
||||
|
||||
class MethodTable
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Since this class should only be accessed through the static create() method
|
||||
* this constructor should be made private. Unfortunately, this is not possible
|
||||
* in PHP4.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function MethodTable(){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the methodTable for a passed class.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param $sourcePath(String) The path to the file you want to parse
|
||||
* @param $containsClass(Bool) True if the file is a class definition (optional)
|
||||
*/
|
||||
function create($sourcePath, $containsClass = false){
|
||||
|
||||
$methodTable = array();
|
||||
if(!file_exists($sourcePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = file_get_contents($sourcePath);
|
||||
$tokens = (array)token_get_all($source);
|
||||
|
||||
$waitingForOpenParenthesis = false;
|
||||
$waitingForFunction = false;
|
||||
$waitingForClassName = false;
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
$lastComment = "";
|
||||
$classMethods = array();
|
||||
$realClassName = "";
|
||||
|
||||
if($containsClass) {
|
||||
$openBraces = -10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
$openBraces = 1;
|
||||
}
|
||||
|
||||
$waitingForEndEncapsedString = false;
|
||||
foreach($tokens as $token)
|
||||
{
|
||||
if (is_string($token)) {
|
||||
if($token == '{')
|
||||
{
|
||||
$openBraces++;
|
||||
}
|
||||
if($token == '}')
|
||||
{
|
||||
if($waitingForEndEncapsedString)
|
||||
{
|
||||
$waitingForEndEncapsedString = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastComment = '';
|
||||
$openBraces--;
|
||||
|
||||
if($openBraces == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($waitingForOpenParenthesis && $token == '(')
|
||||
{
|
||||
$bufferingArgs = true;
|
||||
$argBuffer = "";
|
||||
$waitingForOpenParenthesis = false;
|
||||
}
|
||||
elseif($bufferingArgs)
|
||||
{
|
||||
if($token != ')')
|
||||
{
|
||||
$argBuffer .= $token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($lastFunction != $realClassName)
|
||||
{
|
||||
$classMethods[] = array("name" => $lastFunction,
|
||||
"comment" => $lastFunctionComment,
|
||||
"args" => $argBuffer);
|
||||
|
||||
$bufferingArgs = false;
|
||||
$argBuffer = "";
|
||||
$lastFunction = "";
|
||||
$lastFunctionComment = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// token array
|
||||
list($id, $text) = $token;
|
||||
|
||||
if($bufferingArgs)
|
||||
{
|
||||
$argBuffer .= $text;
|
||||
}
|
||||
switch ($id)
|
||||
{
|
||||
|
||||
case T_COMMENT:
|
||||
case T_ML_COMMENT: // we've defined this
|
||||
case T_DOC_COMMENT: // and this
|
||||
// no action on comments
|
||||
$lastComment = $text;
|
||||
break;
|
||||
case T_FUNCTION:
|
||||
if($openBraces >= 1)
|
||||
{
|
||||
$waitingForFunction = true;
|
||||
}
|
||||
break;
|
||||
case T_STRING:
|
||||
if($waitingForFunction)
|
||||
{
|
||||
$waitingForFunction = false;
|
||||
$waitingForOpenParenthesis = true;
|
||||
$lastFunction = $text;
|
||||
$lastFunctionComment = $lastComment;
|
||||
$lastComment = "";
|
||||
}
|
||||
if($waitingForClassName)
|
||||
{
|
||||
$waitingForClassName = false;
|
||||
$realClassName = $text;
|
||||
}
|
||||
break;
|
||||
case T_CLASS:
|
||||
$openBraces = 0;
|
||||
$waitingForClassName = true;
|
||||
break;
|
||||
case T_CURLY_OPEN:
|
||||
case T_DOLLAR_OPEN_CURLY_BRACES:
|
||||
$waitingForEndEncapsedString = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($classMethods as $key => $value) {
|
||||
$methodSignature = $value['args'];
|
||||
$methodName = $value['name'];
|
||||
$methodComment = $value['comment'];
|
||||
|
||||
$description = MethodTable::getMethodDescription($methodComment) . " " . MethodTable::getMethodCommentAttribute($methodComment, "desc");
|
||||
$description = trim($description);
|
||||
$access = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "access");
|
||||
$roles = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "roles");
|
||||
$instance = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "instance");
|
||||
$returns = MethodTable::getMethodReturnValue($methodComment);
|
||||
$pagesize = MethodTable::getMethodCommentAttributeFirstWord($methodComment, "pagesize");
|
||||
$params = MethodTable::getMethodCommentArguments($methodComment);
|
||||
|
||||
|
||||
//description, arguments, access, [roles, [instance, [returns, [pagesize]]]]
|
||||
$methodTable[$methodName] = array();
|
||||
//$methodTable[$methodName]["signature"] = $methodSignature; //debug purposes
|
||||
$methodTable[$methodName]["description"] = ($description == "") ? "No description given." : $description;
|
||||
$methodTable[$methodName]["arguments"] = MethodTable::getMethodArguments($methodSignature, $params);
|
||||
$methodTable[$methodName]["access"] = ($access == "") ? "private" : $access;
|
||||
|
||||
if($roles != "") $methodTable[$methodName]["roles"] = $roles;
|
||||
if($instance != "") $methodTable[$methodName]["instance"] = $instance;
|
||||
if($returns != "") $methodTable[$methodName]["returns"] = $returns;
|
||||
if($pagesize != "") $methodTable[$methodName]["pagesize"] = $pagesize;
|
||||
}
|
||||
|
||||
return $methodTable;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentServices($comment)
|
||||
{
|
||||
$pieces = explode('@service', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getMethodCommentArguments($comment)
|
||||
{
|
||||
$pieces = explode('@param', $comment);
|
||||
$args = array();
|
||||
if(is_array($pieces) && count($pieces) > 1)
|
||||
{
|
||||
for($i = 0; $i < count($pieces) - 1; $i++)
|
||||
{
|
||||
$ps = strrstr($pieces[$i + 1], '@');
|
||||
$ps = strrstr($ps, '*/');
|
||||
$args[] = MethodTable::cleanComment($ps);
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description from the comment.
|
||||
* The description is(are) the first line(s) in the comment.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function getMethodDescription($comment){
|
||||
$comment = MethodTable::cleanComment(strrstr($comment, "@"));
|
||||
return trim($comment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttribute($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodCommentAttributeFirstLine($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
return MethodTable::cleanComment($pieces);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a comment attribute.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
* @param $attribute(String) The name of the attribute to get its value from.
|
||||
*/
|
||||
function getMethodReturnValue($comment){
|
||||
$result = array('type' => 'void', 'description' => '');
|
||||
$pieces = strstrafter($comment, '@returns');
|
||||
if(FALSE == $pieces) $pieces = strstrafter($comment, '@return');
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$pieces = strrstr($pieces, '@');
|
||||
$pieces = strrstr($pieces, "*");
|
||||
$pieces = strrstr($pieces, "/");
|
||||
$pieces = strrstr($pieces, "-");
|
||||
$pieces = strrstr($pieces, "\n");
|
||||
$pieces = strrstr($pieces, "\r");
|
||||
$pieces = strrstr($pieces, '*/');
|
||||
$pieces = trim(MethodTable::cleanComment($pieces));
|
||||
@list($result['type'], $result['description']) = explode(' ', $pieces, 2);
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getMethodCommentAttributeFirstWord($comment, $attribute){
|
||||
$pieces = strstrafter($comment, '@' . $attribute);
|
||||
if($pieces !== FALSE)
|
||||
{
|
||||
$val = MethodTable::cleanComment($pieces);
|
||||
return trim(strrstr($val, ' '));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the arguments of a method.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $methodSignature(String) The method's signature;
|
||||
*/
|
||||
function getMethodArguments($methodSignature, $commentParams){
|
||||
if(strlen($methodSignature) == 0){
|
||||
//no arguments, return an empty array
|
||||
$result = array();
|
||||
}else{
|
||||
//clean the arguments before returning them
|
||||
$result = MethodTable::cleanArguments(explode(",", $methodSignature), $commentParams);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the function or method's return value.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $value(String) The "dirty" value.
|
||||
*/
|
||||
function cleanReturnValue($value){
|
||||
$result = array();
|
||||
$value = trim($value);
|
||||
|
||||
list($result['type'], $result['description']) = explode(' ', $value, 2);
|
||||
|
||||
$result['type'] = MethodTable::standardizeType($result['type']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes a string and returns the XMLRPC type that most closely matches it.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $type(String) The given type string.
|
||||
*/
|
||||
function standardizeType($type) {
|
||||
$type = strtolower($type);
|
||||
if('str' == $type || 'string' == $type) return 'string';
|
||||
if('int' == $type || 'integer' == $type) return 'int';
|
||||
if('bool' == $type || 'boolean' == $type) return 'boolean';
|
||||
|
||||
// Note that object is not a valid XMLRPC type
|
||||
if('object' == $type || 'class' == $type) return 'object';
|
||||
if('float' == $type || 'dbl' == $type || 'double' == $type || 'flt' == $type) return 'double';
|
||||
|
||||
// Note that null is not a valid XMLRPC type. The null type can have
|
||||
// only one value - null.
|
||||
if('null' == $type) return 'null';
|
||||
|
||||
// Note that mixed is not a valid XMLRPC type
|
||||
if('mixed' == $type) return 'mixed';
|
||||
if('array' == $type || 'arr' == $type) return 'array';
|
||||
if('assoc' == $type || 'struct' == $type) return 'struct';
|
||||
|
||||
// Note that this is not a valid XMLRPC type. As references cannot be
|
||||
// serialized or exported, there is no way this could be XML-RPCed.
|
||||
if('reference' == $type || 'ref' == $type) return 'reference';
|
||||
return 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the arguments array.
|
||||
* This method removes all whitespaces and the leading "$" sign from each argument
|
||||
* in the array.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @param $args(Array) The "dirty" array with arguments.
|
||||
*/
|
||||
function cleanArguments($args, $commentParams){
|
||||
$result = array();
|
||||
|
||||
if(!is_array($args)) return array();
|
||||
|
||||
foreach($args as $index => $arg){
|
||||
$arg = strrstr(str_replace(array('$','&$'), array('','&'), $arg), '=');
|
||||
if(!isset($commentParams[$index]))
|
||||
{
|
||||
$result[] = trim($arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = trim($arg);
|
||||
$end = trim(str_replace('$', '', $commentParams[$index]));
|
||||
|
||||
// Suppress Notice of 'Undefined offset' with @
|
||||
@list($word0, $word1, $tail) = preg_split("/[\s]+/", $end, 3);
|
||||
$word0 = strtolower($word0);
|
||||
$word1 = strtolower($word1);
|
||||
|
||||
$wordBase0 = ereg_replace('^[&$]+','',$word0);
|
||||
$wordBase1 = ereg_replace('^[&$]+','',$word1);
|
||||
$startBase = strtolower(ereg_replace('^[&$]+','',$start));
|
||||
|
||||
if ($wordBase0 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word1);
|
||||
} elseif($wordBase1 == $startBase) {
|
||||
$type = str_replace(array('(',')'),'', $word0);
|
||||
} elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
|
||||
$tail = str_ireplace($word0, '', $end);
|
||||
$type = $regs[3];
|
||||
} else {
|
||||
// default to string
|
||||
$type = 'string';
|
||||
}
|
||||
|
||||
$type = MethodTable::standardizeType($type);
|
||||
/*
|
||||
if($type == 'str') {
|
||||
$type = 'string';
|
||||
} elseif($type == 'int' || $type == 'integer') {
|
||||
$type = 'int';
|
||||
} elseif($type == 'bool' || $type == 'boolean') {
|
||||
$type = 'boolean';
|
||||
} elseif($type == 'object' || $type == 'class') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'object';
|
||||
} elseif($type == 'float' || $type == 'dbl' || $type == 'double' || $type == 'flt') {
|
||||
$type = 'double';
|
||||
} elseif($type == 'null') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// The null type can have only one value - null. Why would
|
||||
// that be an argument to a function? Just in case:
|
||||
$type = 'null';
|
||||
} elseif($type == 'mixed') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
$type = 'mixed';
|
||||
} elseif($type == 'array' || $type == 'arr') {
|
||||
$type = 'array';
|
||||
} elseif($type == 'assoc') {
|
||||
$type = 'struct';
|
||||
} elseif($type == 'reference' || $type == 'ref') {
|
||||
// Note that this is not a valid XMLRPC type
|
||||
// As references cannot be serialized or exported, there is
|
||||
// no way this could be XML-RPCed.
|
||||
$type = 'reference';
|
||||
} else {
|
||||
$type = 'string';
|
||||
}
|
||||
*/
|
||||
$result[] = array('type' => $type, 'description' => $start . ' - ' . $tail);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleans the comment string by removing all comment start and end characters.
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param $comment(String) The method's comment.
|
||||
*/
|
||||
function cleanComment($comment){
|
||||
$comment = str_replace("/**", "", $comment);
|
||||
$comment = str_replace("*/", "", $comment);
|
||||
$comment = str_replace("*", "", $comment);
|
||||
$comment = str_replace("\n", "\\n", trim($comment));
|
||||
$comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
|
||||
$comment = str_replace("\"", "\\\"", $comment);
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function showCode($methodTable){
|
||||
|
||||
if(!is_array($methodTable)) $methodTable = array();
|
||||
|
||||
foreach($methodTable as $methodName=>$methodProps){
|
||||
$result .= "\n\t\"" . $methodName . "\" => array(";
|
||||
|
||||
foreach($methodProps as $key=>$value){
|
||||
$result .= "\n\t\t\"" . $key . "\" => ";
|
||||
|
||||
if($key=="arguments"){
|
||||
$result .= "array(";
|
||||
for($i=0; $i<count($value); $i++){
|
||||
$result .= "\"" . addslashes($value[$i]) . "\"";
|
||||
if($i<count($value)-1){
|
||||
$result .= ", ";
|
||||
}
|
||||
}
|
||||
$result .= ")";
|
||||
}else{
|
||||
$result .= "\"" . $value . "\"";
|
||||
}
|
||||
|
||||
$result .= ",";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result .= "\n\t),";
|
||||
}
|
||||
|
||||
$result = substr($result, 0, -1);
|
||||
$result = "\$this->methodTable = array(" . $result;
|
||||
$result .= "\n);";
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,237 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Allows the admin to control user logins from remote moodles.
|
||||
|
||||
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
$sort = optional_param('sort', 'username', PARAM_ALPHA);
|
||||
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT);
|
||||
$action = trim(strtolower(optional_param('action', '', PARAM_ALPHA)));
|
||||
|
||||
require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
// grab the mnet hosts and remove the localhost
|
||||
$mnethosts = get_records_menu('mnet_host', '', '', 'name', 'id, name');
|
||||
if (array_key_exists($CFG->mnet_localhost_id, $mnethosts)) {
|
||||
unset($mnethosts[$CFG->mnet_localhost_id]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process actions
|
||||
if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
// boot if insufficient permission
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet');
|
||||
}
|
||||
|
||||
// fetch the record in question
|
||||
$id = required_param('id', PARAM_INT);
|
||||
if (!$idrec = get_record('mnet_sso_access_control', 'id', $id)) {
|
||||
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case "delete":
|
||||
delete_records('mnet_sso_access_control', 'id', $id);
|
||||
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
break;
|
||||
|
||||
case "acl":
|
||||
|
||||
// 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') {
|
||||
print_error('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($idrec->username, $mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process the form results
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// check permissions and verify form input
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
if (empty($form->username)) {
|
||||
$formerror['username'] = get_string('enterausername','mnet');
|
||||
}
|
||||
if (empty($form->mnet_host_id)) {
|
||||
$formerror['mnet_host_id'] = get_string('selectahost','mnet');
|
||||
}
|
||||
if (empty($form->accessctrl)) {
|
||||
$formerror['accessctrl'] = get_string('selectaccesslevel','mnet'); ;
|
||||
}
|
||||
|
||||
// process if there are no errors
|
||||
if (count($formerror) == 0) {
|
||||
|
||||
// username can be a comma separated list
|
||||
$usernames = explode(',', $form->username);
|
||||
|
||||
foreach ($usernames as $username) {
|
||||
$username = trim(moodle_strtolower($username));
|
||||
if (!empty($username)) {
|
||||
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
|
||||
if ($form->accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array($username, $mnethosts[$form->mnet_host_id])));
|
||||
} elseif ($form->accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array($username, $mnethosts[$form->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Explain
|
||||
print_box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
$warn = '';
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
$warn = '<p>' . get_string('mnetdisabled','mnet') .'</p>';
|
||||
}
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
|
||||
}
|
||||
|
||||
if (get_config('auth/mnet', 'auto_add_remote_users') != true) {
|
||||
$warn .= '<p>' . get_string('authmnetautoadddisabled','mnet').'</p>';
|
||||
}
|
||||
if (!empty($warn)) {
|
||||
$warn = '<p>' . get_string('ssoaclneeds','mnet').'</p>' . $warn;
|
||||
print_box($warn);
|
||||
}
|
||||
// output the ACL table
|
||||
$columns = array("username", "mnet_host_id", "access", "delete");
|
||||
$headings = array();
|
||||
$string = array('username' => get_string('username'),
|
||||
'mnet_host_id' => get_string('remotehost', 'mnet'),
|
||||
'access' => get_string('accesslevel', 'mnet'),
|
||||
'delete' => get_string('delete'));
|
||||
foreach ($columns as $column) {
|
||||
if ($sort != $column) {
|
||||
$columnicon = "";
|
||||
$columndir = "ASC";
|
||||
} else {
|
||||
$columndir = $dir == "ASC" ? "DESC" : "ASC";
|
||||
$columnicon = $dir == "ASC" ? "down" : "up";
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\" />";
|
||||
}
|
||||
$headings[$column] = "<a href=\"?sort=$column&dir=$columndir&\">".$string[$column]."</a>$columnicon";
|
||||
}
|
||||
$headings['delete'] = '';
|
||||
$acl = get_records('mnet_sso_access_control', '', '', "$sort $dir", '*'); //, $page * $perpage, $perpage);
|
||||
$aclcount = count_records('mnet_sso_access_control');
|
||||
|
||||
if (!$acl) {
|
||||
print_heading(get_string('noaclentries','mnet'));
|
||||
$table = NULL;
|
||||
} else {
|
||||
$table->head = $headings;
|
||||
$table->align = array('left', 'left', 'center');
|
||||
$table->width = "95%";
|
||||
foreach ($acl as $aclrecord) {
|
||||
if ($aclrecord->accessctrl == 'allow') {
|
||||
$accesscolumn = get_string('allow', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=deny&sesskey={$USER->sesskey}\">"
|
||||
. get_string('deny', 'mnet') . "</a>)";
|
||||
} else {
|
||||
$accesscolumn = get_string('deny', 'mnet')
|
||||
. " (<a href=\"?id={$aclrecord->id}&action=acl&accessctrl=allow&sesskey={$USER->sesskey}\">"
|
||||
. get_string('allow', 'mnet') . "</a>)";
|
||||
}
|
||||
$deletecolumn = "<a href=\"?id={$aclrecord->id}&action=delete&sesskey={$USER->sesskey}\">"
|
||||
. get_string('delete') . "</a>";
|
||||
$table->data[] = array ($aclrecord->username, $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($table)) {
|
||||
print_table($table);
|
||||
echo '<p> </p>';
|
||||
print_paging_bar($aclcount, $page, $perpage, "?sort=$sort&dir=$dir&perpage=$perpage&");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// output the add form
|
||||
print_simple_box_start('center','90%','','20');
|
||||
|
||||
?>
|
||||
<div class="mnetaddtoaclform">
|
||||
<form id="mnetaddtoacl" method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $sesskey; ?>" />
|
||||
<?php
|
||||
|
||||
// enter a username
|
||||
echo get_string('username') . ":\n";
|
||||
if (!empty($formerror['username'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo '<input type="text" name="username" size="20" maxlength="100" />';
|
||||
|
||||
// choose a remote host
|
||||
echo " " . get_string('remotehost', 'mnet') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
choose_from_menu($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . get_string('accesslevel', 'mnet') . ":\n";
|
||||
if (!empty($formerror['accessctrl'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
$accessmenu['allow'] = get_string('allow', 'mnet');
|
||||
$accessmenu['deny'] = get_string('deny', 'mnet');
|
||||
choose_from_menu($accessmenu, 'accessctrl');
|
||||
|
||||
// submit button
|
||||
echo '<input type="submit" value="' . get_string('addtoacl', 'mnet') . '" />';
|
||||
echo "</form></div>\n";
|
||||
|
||||
// print errors
|
||||
foreach ($formerror as $error) {
|
||||
echo "<br><span class=\"error\">$error<span>";
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Library functions for mnet
|
||||
*
|
||||
* @author Donal McMullan donal@catalyst.net.nz
|
||||
* @version 0.0.1
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package mnet
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse a file to find out what functions/methods exist in it, and add entries
|
||||
* for the remote-call-enabled functions to the database.
|
||||
*
|
||||
* The path to a file, e.g. auth/mnet/auth.php can be thought of as
|
||||
* type/parentname/docname
|
||||
*
|
||||
* @param string $type mod, auth or enrol
|
||||
* @param string $parentname Implementation of type, e.g. 'mnet' in the
|
||||
* case of auth/mnet/auth.php
|
||||
* @return bool True on success, else false
|
||||
*/
|
||||
function mnet_get_functions($type, $parentname) {
|
||||
global $CFG;
|
||||
$dataobject = new stdClass();
|
||||
$docname = $type.'.php';
|
||||
$publishes = array();
|
||||
if ('mod' == $type) {
|
||||
$docname = 'rpclib.php';
|
||||
$relname = '/mod/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$mnet_publishes = $parentname.'_mnet_publishes';
|
||||
if (function_exists($mnet_publishes)) {
|
||||
(array)$publishes = $mnet_publishes();
|
||||
}
|
||||
} else {
|
||||
// auth or enrol
|
||||
$relname = '/'.$type.'/'.$parentname.'/'.$docname;
|
||||
$filename = $CFG->dirroot.$relname;
|
||||
if (file_exists($filename)) include_once $filename;
|
||||
$class = $type.($type=='enrol'? 'ment':'').'_plugin_'.$parentname;
|
||||
if (class_exists($class)) {
|
||||
$object = new $class();
|
||||
if (method_exists($object, 'mnet_publishes')) {
|
||||
(array)$publishes = $object->mnet_publishes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$methodServiceArray = array();
|
||||
foreach($publishes as $service) {
|
||||
if (is_array($service['methods'])) {
|
||||
foreach($service['methods'] as $methodname) {
|
||||
$methodServiceArray[$methodname][] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable functions that don't exist (any more) in the source
|
||||
// Should these be deleted? What about their permissions records?
|
||||
$rpcrecords = get_records_select('mnet_rpc', ' parent=\''.$parentname.'\' AND parent_type=\''.$type.'\' ', 'function_name ASC ');
|
||||
if (!empty($rpcrecords)) {
|
||||
foreach($rpcrecords as $rpc) {
|
||||
if (!array_key_exists($rpc->function_name, $methodServiceArray)) {
|
||||
$rpc->enabled = 0;
|
||||
update_record('mnet_rpc', $rpc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($filename)) return false;
|
||||
|
||||
if (extension_loaded('tokenizer')) {
|
||||
include_once "$CFG->dirroot/$CFG->admin/mnet/MethodTable.php";
|
||||
$functions = (array)MethodTable::create($filename,false);
|
||||
}
|
||||
|
||||
foreach($methodServiceArray as $method => $servicearray) {
|
||||
if (!empty($functions[$method])) {
|
||||
$details = $functions[$method];
|
||||
$profile = $details['arguments'];
|
||||
if (!isset($details['returns'])) {
|
||||
array_unshift($profile, array('type' => 'void', 'description' => 'No return value'));
|
||||
} else {
|
||||
array_unshift($profile, $details['returns']);
|
||||
}
|
||||
$dataobject->profile = serialize($profile);
|
||||
$dataobject->help = addslashes($details['description']);
|
||||
} else {
|
||||
$dataobject->profile = serialize(array(array('type' => 'void', 'description' => 'No return value')));
|
||||
$dataobject->help = '';
|
||||
}
|
||||
|
||||
$dataobject->function_name = $method;
|
||||
$dataobject->xmlrpc_path = $type.'/'.$parentname.'/'.$docname.'/'.$method;
|
||||
$dataobject->parent_type = $type;
|
||||
$dataobject->parent = $parentname;
|
||||
$dataobject->enabled = '0';
|
||||
|
||||
if ($record_exists = get_record('mnet_rpc', 'xmlrpc_path', $dataobject->xmlrpc_path)) {
|
||||
$dataobject->id = $record_exists->id;
|
||||
$dataobject->enabled = $record_exists->enabled;
|
||||
update_record('mnet_rpc', $dataobject);
|
||||
} else {
|
||||
$dataobject->id = insert_record('mnet_rpc', $dataobject, true);
|
||||
}
|
||||
|
||||
foreach($servicearray as $service) {
|
||||
$serviceobj = get_record('mnet_service', 'name', $service['name']);
|
||||
if (false == $serviceobj) {
|
||||
$serviceobj = new stdClass();
|
||||
$serviceobj->name = $service['name'];
|
||||
$serviceobj->apiversion = $service['apiversion'];
|
||||
$serviceobj->offer = 1;
|
||||
$serviceobj->id = insert_record('mnet_service', $serviceobj, true);
|
||||
}
|
||||
|
||||
if (false == get_record('mnet_service2rpc', 'rpcid', $dataobject->id, 'serviceid', $serviceobj->id)) {
|
||||
$obj = new stdClass();
|
||||
$obj->rpcid = $dataobject->id;
|
||||
$obj->serviceid = $serviceobj->id;
|
||||
insert_record('mnet_service2rpc', $obj, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function upgrade_RPC_functions($returnurl) {
|
||||
global $CFG;
|
||||
|
||||
$basedir = $CFG->dirroot.'/mod';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('mod', $dir);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/auth';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('auth', $dir);
|
||||
}
|
||||
}
|
||||
|
||||
$basedir = $CFG->dirroot.'/enrol';
|
||||
if (file_exists($basedir) && filetype($basedir) == 'dir') {
|
||||
$dirhandle = opendir($basedir);
|
||||
while (false !== ($dir = readdir($dirhandle))) {
|
||||
$firstchar = substr($dir, 0, 1);
|
||||
if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
|
||||
continue;
|
||||
}
|
||||
if (filetype($basedir .'/'. $dir) != 'dir') {
|
||||
continue;
|
||||
}
|
||||
|
||||
mnet_get_functions('enrol', $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
$navlinks = array();
|
||||
$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);
|
||||
|
||||
print_heading(get_string('mnetsettings', 'mnet'));
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table class="generalbox standard" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><span><?php print_string('deleteaserver', 'mnet'); ?>Deleting a Server</span></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (count($warn) > 0){
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right" colspan="2"><?php print_string('receivedwarnings','mnet'); ?>:<br />
|
||||
<?php foreach($warn as $warning) echo $warning .'<br />'; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><?php print_string('reallydeleteserver','mnet'); ?>: "<?php echo $mnet_peer->name; ?>"?</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td width="80">
|
||||
<form method="post" action="delete.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo $mnet_peer->id; ?>" />
|
||||
<input type="hidden" name="step" value="delete" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="get" action="index.php">
|
||||
<input type="submit" name="ignore" value="<?php print_string('cancel'); ?>"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
require_login();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', 'verify', PARAM_ALPHA);
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$warn = array();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
redirect('index.php', get_string('postrequired','mnet') ,7);
|
||||
}
|
||||
|
||||
if ('verify' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$live_users = $mnet_peer->count_live_sessions();
|
||||
if ($live_users > 0) {
|
||||
$warn[] = get_string('usersareonline', 'mnet', $live_users);
|
||||
}
|
||||
include('delete.html');
|
||||
} elseif ('delete' == $step) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$mnet_peer->delete();
|
||||
redirect('peers.php', get_string('hostdeleted', 'mnet'), 5);
|
||||
}
|
||||
?>
|
||||
@@ -1,104 +0,0 @@
|
||||
|
||||
<form id="assignform" method="post" action="">
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
<input type="hidden" name="host" value="<?php p($mnet_peer->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<table class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php print_string('existingusers', 'role', count($mnetenrolledusers)); ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php print_string('potentialusers', 'role', $availableusers->_numOfRows); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($mnetenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
echo "<option value=\"$enrolleduser->id\">".s($fullname)." (".s($enrolleduser->rolename).")</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=false;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
if (!isset($enrolledusers[$user->id])) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
} else {
|
||||
if ($availableusers->_numOfRows > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onfocus ="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><?php print_string('otherenrolledusers', 'mnet'); ?>:<br />
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($remtenrolledusers as $enrolleduser) {
|
||||
$fullname = fullname($enrolleduser, true);
|
||||
print '<li>'
|
||||
. s($fullname) . ' (' . s($enrolleduser->rolename) . ') '
|
||||
. s($enrolleduser->enroltype)."</li>\n";
|
||||
}
|
||||
?></ul></td>
|
||||
<td valign="top"></td>
|
||||
<td valign="top"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,279 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethostid = required_param('host', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (!$mnet_peer->set_id($mnethostid)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
$course = get_record('mnet_enrol_course', 'id', $courseid, 'hostid', $mnet_peer->id);
|
||||
|
||||
if (empty($course)) {
|
||||
print_error('hostcoursenotfound','mnet');
|
||||
}
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
|
||||
$add = optional_param('add', 0, PARAM_BOOL);
|
||||
$remove = optional_param('remove', 0, PARAM_BOOL);
|
||||
$showall = optional_param('showall', 0, PARAM_BOOL);
|
||||
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
|
||||
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
|
||||
$baseurl = "remote_enrolment.php?courseid={$course->id}&host={$mnet_peer->id}";
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
|
||||
$timemodified = time();
|
||||
|
||||
foreach ($frm->addselect as $adduser) {
|
||||
if (!$adduser = clean_param($adduser, PARAM_INT)) {
|
||||
continue;
|
||||
}
|
||||
if (! $enrolment->req_enrol_user($adduser, $course->id)) {
|
||||
$errors[] = "Could not add user with id $adduser to course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
if (! $enrolment->req_unenrol_user($removeuser, $course->id)) {
|
||||
$errors[] = "Could not remove user with id $removeuser from course {$course->id}!";
|
||||
}
|
||||
}
|
||||
} else if ($showall) {
|
||||
$searchtext = '';
|
||||
$previoussearch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepare data for users / enrolled users panes
|
||||
|
||||
|
||||
/// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
/// Pass it the path to the method that we want to execute
|
||||
$mnet_request->set_method('enrol/mnet/enrol.php/course_enrolments');
|
||||
$mnet_request->add_param($course->remoteid, 'int');
|
||||
$mnet_request->send($mnet_peer);
|
||||
$all_enrolled_users = $mnet_request->response;
|
||||
|
||||
unset($mnet_request);
|
||||
|
||||
$select = '';
|
||||
$all_enrolled_usernames = '';
|
||||
$timemodified = array();
|
||||
/// List all the users (homed on this server) who are enrolled on the course
|
||||
/// This will include mnet-enrolled users, and those who have enrolled
|
||||
/// themselves, etc.
|
||||
if (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
foreach($all_enrolled_users as $username => $data) {
|
||||
$all_enrolled_usernames .= "'$username', ";
|
||||
}
|
||||
$select = ' u.username IN (' .substr($all_enrolled_usernames, 0, -2) .') AND ';
|
||||
} else {
|
||||
$all_enrolled_users = array();
|
||||
}
|
||||
|
||||
/// Synch our mnet_enrol_assignments with remote server
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
u.username,
|
||||
u.email,
|
||||
a.enroltype,
|
||||
a.id as enrolid,
|
||||
COALESCE(a.hostid, 0) as wehaverecord,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
ON
|
||||
a.userid = u.id AND a.courseid={$courseid}
|
||||
WHERE
|
||||
$select
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$enrolledusers = get_records_sql($sql)) {
|
||||
$enrolledusers = array();
|
||||
}
|
||||
|
||||
foreach($enrolledusers as $user) {
|
||||
|
||||
$dataobj = new stdClass();
|
||||
$dataobj->userid = $user->id;
|
||||
$dataobj->hostid = $mnet_peer->id;
|
||||
$dataobj->courseid = $courseid;
|
||||
$dataobj->rolename = $all_enrolled_users[$user->username]['name'];
|
||||
$dataobj->enroltype = $all_enrolled_users[$user->username]['enrol'];
|
||||
|
||||
if ($user->wehaverecord == 0) {
|
||||
$dataobj->enroltime = $all_enrolled_users[$user->username]['timemodified'];
|
||||
$dataobj->id = insert_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (array_key_exists($user->username, $all_enrolled_users)) {
|
||||
$dataobj->id = $user->enrolid;
|
||||
update_record('mnet_enrol_assignments', $dataobj);
|
||||
} elseif (is_array($all_enrolled_users) && count($all_enrolled_users)) {
|
||||
delete_record('mnet_enrol_assignments', 'id', $user->enrolid);
|
||||
}
|
||||
}
|
||||
unset($enrolledusers);
|
||||
|
||||
// Read about our remote enrolments in 2 sets
|
||||
// first, get the remote enrolments done via enrol/mnet $mnetenrolledusers
|
||||
// second, get the remote enrolments done with other plugins $remtenrolledusers
|
||||
// NOTE: both arrays are keyed on the userid!
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype = 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$mnetenrolledusers = get_records_sql($sql)) {
|
||||
$mnetenrolledusers = array();
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
u.id,
|
||||
u.firstname,
|
||||
u.lastname,
|
||||
a.rolename,
|
||||
a.enroltype,
|
||||
a.courseid
|
||||
FROM
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}mnet_enrol_assignments a
|
||||
WHERE
|
||||
a.userid = u.id AND
|
||||
a.courseid={$courseid} AND
|
||||
a.enroltype != 'mnet' AND
|
||||
u.deleted = 0 AND
|
||||
u.confirmed = 1 AND
|
||||
u.mnethostid = {$CFG->mnet_localhost_id}
|
||||
ORDER BY
|
||||
u.firstname ASC,
|
||||
u.lastname ASC";
|
||||
|
||||
if (!$remtenrolledusers = get_records_sql($sql)) {
|
||||
$remtenrolledusers = array();
|
||||
}
|
||||
|
||||
$select = '';
|
||||
$exclude = array_merge(array_keys($mnetenrolledusers), array_keys($remtenrolledusers));
|
||||
$exclude[] = 0;
|
||||
$select = 'AND u.username!=\'guest\' AND u.id NOT IN ('. join(',',$exclude) .') ';
|
||||
unset($exclude);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
|
||||
if ($searchtext !== '') { // Search for a subset of remaining users
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$select .= " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
}
|
||||
|
||||
$sql = ('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user u
|
||||
WHERE deleted = 0 AND confirmed = 1
|
||||
AND mnethostid = '.$CFG->mnet_localhost_id.' '
|
||||
.$select
|
||||
.'ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
$availableusers = get_recordset_sql($sql, 0, MAX_USERS_PER_PAGE);
|
||||
|
||||
|
||||
|
||||
/// Print the page
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
|
||||
/// Get some language strings
|
||||
|
||||
$strpotentialusers = get_string('potentialusers', 'role');
|
||||
$strexistingusers = get_string('existingusers', 'role');
|
||||
$straction = get_string('assignroles', 'role');
|
||||
$strroletoassign = get_string('roletoassign', 'role');
|
||||
$strcurrentcontext = get_string('currentcontext', 'role');
|
||||
$strsearch = get_string('search');
|
||||
$strshowall = get_string('showall');
|
||||
$strparticipants = get_string('participants');
|
||||
$strsearchresults = get_string('searchresults');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($mnet_peer->name) . ' : '
|
||||
. format_string($course->shortname) .' '. format_string($course->fullname)
|
||||
. '</strong><br />'
|
||||
. get_string("enrolcourseenrol_desc", "mnet"));
|
||||
|
||||
echo "<hr />";
|
||||
|
||||
include(dirname(__FILE__).'/enr_course_enrol.html');
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = '<p>';
|
||||
foreach ($errors as $e) {
|
||||
$msg .= $e.'<br />';
|
||||
}
|
||||
$msg .= '</p>';
|
||||
notify($msg);
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
$mnethost = required_param('host', PARAM_INT);
|
||||
$host = get_record('mnet_host', 'id', $mnethost);
|
||||
|
||||
$courses = $enrolment->fetch_remote_courses($mnethost);
|
||||
|
||||
/// Print the page
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box('<strong>' . s($host->name) . ' </strong><br />'
|
||||
. get_string("enrolcourses_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table class="generaltable">';
|
||||
|
||||
$icon = "<img src=\"$CFG->pixpath/i/course.gif\"".
|
||||
" class=\"icon\" alt=\"".get_string("course")."\" />";
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?"
|
||||
. "host={$mnethost}&courseid={$course->id}&sesskey={$USER->sesskey}";
|
||||
echo '<tr>'
|
||||
. "<td>$icon</td>"
|
||||
. "<td><a href=\"$link\">".format_string($course->fullname). "</a></td>"
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. '<td>'.format_string($course->shortname). ' - ' .format_string($course->cat_name).'</td>'
|
||||
. '</tr><tr>'
|
||||
. '<td></td>'
|
||||
. "<td align=\"left\" >{$course->summary}</td>"
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table></div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol_config.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('mnetenrol');
|
||||
$CFG->pagepath = 'admin/mnet';
|
||||
|
||||
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
|
||||
|
||||
$enrolment = enrolment_factory::factory('mnet');
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_box(get_string("remoteenrolhosts_desc", "mnet"));
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
|
||||
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
|
||||
. '<table cellspacing="0" cellpadding="5" id="hosts" class="generaltable generalbox" >'
|
||||
. '<tr>'
|
||||
. '<th class="header c0"> '.get_string('host', 'mnet').' </th>'
|
||||
. '<th class="header c1"> '.get_string('enrolments', 'mnet').' </th>'
|
||||
. '<th class="header c2"> '.get_string('courses', 'mnet').' </th>'
|
||||
// . '<th class="header c3"> </th>'
|
||||
. '</tr>';
|
||||
$hosts = $enrolment->list_remote_servers();
|
||||
foreach ($hosts as $host) {
|
||||
$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 = '?';
|
||||
}
|
||||
$enrolcount = get_field_sql("SELECT count(id) FROM {$CFG->prefix}mnet_enrol_assignments WHERE hostid={$host->id}");
|
||||
|
||||
echo '<tr>'
|
||||
. "<td><a href=\"{$coursesurl}\">{$host->name}</a></td>"
|
||||
. "<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/$CFG->admin/report/log/index.php?course_host={$host->id}">'
|
||||
// . get_string('logs', 'mnet').'</a> </td>'
|
||||
. '</tr>';
|
||||
}
|
||||
echo '</table>'
|
||||
. '</div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,151 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure mnet stuff
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('net');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nocurl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
}
|
||||
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
if (!empty($form->submit) && $form->submit == get_string('savechanges')) {
|
||||
if (in_array($form->mode, array("off", "strict", "dangerous"))) {
|
||||
if (set_config('mnet_dispatcher_mode', $form->mode)) {
|
||||
redirect('index.php', get_string('changessaved'));
|
||||
} else {
|
||||
error('Invalid action parameter.', 'index.php');
|
||||
}
|
||||
}
|
||||
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
||||
$MNET->get_private_key();
|
||||
$_SESSION['mnet_confirm_delete_key'] = md5(sha1($MNET->keypair['keypair_PEM'])).':'.time();
|
||||
notice_yesno(get_string("deletekeycheck", "mnet"),
|
||||
"index.php?sesskey=$USER->sesskey&confirm=".md5($MNET->public_key),
|
||||
"index.php",
|
||||
array('sesskey' => $USER->sesskey),
|
||||
NULL,
|
||||
'post',
|
||||
'get');
|
||||
exit;
|
||||
} else {
|
||||
// We're deleting
|
||||
|
||||
|
||||
if (!isset($_SESSION['mnet_confirm_delete_key'])) {
|
||||
// fail - you're being attacked?
|
||||
}
|
||||
|
||||
$key = '';
|
||||
$time = '';
|
||||
@list($key, $time) = explode(':',$_SESSION['mnet_confirm_delete_key']);
|
||||
$MNET->get_private_key();
|
||||
|
||||
if($time < time() - 60) {
|
||||
// fail - you're out of time.
|
||||
print_error ('deleteoutoftime', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($key != md5(sha1($MNET->keypair['keypair_PEM']))) {
|
||||
// fail - you're being attacked?
|
||||
print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$MNET->replace_keys();
|
||||
redirect('index.php', get_string('keydeleted','mnet'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$hosts = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
|
||||
|
||||
admin_externalpage_print_header();
|
||||
?>
|
||||
<center>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><?php print_string('aboutyourhost', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
|
||||
<td><pre><?php echo $MNET->public_key; ?></pre></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td><?php echo userdate($MNET->public_key_expires); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('net', 'mnet'); ?>:</td>
|
||||
<td><input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="radio" name="mode" value="off" <?php echo ("off" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('off', 'mnet'); ?> <br />
|
||||
<input type="radio" name="mode" value="strict" <?php echo ("strict" == $CFG->mnet_dispatcher_mode)? 'checked="checked"' : '' ?> /> <?php print_string('on', 'mnet'); ?><br />
|
||||
<input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr valign="top">
|
||||
<td colspan="2" class="header" cellpadding="0"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td colspan="2" cellpadding="0"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td>
|
||||
<td align="left"><input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="deleteKey" value="" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="commit" />
|
||||
<input type="hidden" name="last_connect_time" value="<?php echo $mnet_peer->last_connect_time; ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo isset($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationid" value="<?php echo isset($mnet_peer->applicationid)? $mnet_peer->applicationid : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationname" value="<?php echo isset($mnet_peer->application->name)? $mnet_peer->application->name : '' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" width="635">
|
||||
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="name" size="30" value="<?php echo $mnet_peer->name; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('hostname', 'mnet'); ?>:</td>
|
||||
<td valign="top"><input type="text" name="wwwroot" size="30" value="<?php echo $mnet_peer->wwwroot; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) $mnet_peer->public_key = '';
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php
|
||||
print_string('publickey', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("publickey", get_string('publickey', 'mnet'), "mnet", true, true);
|
||||
?></td>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0) {
|
||||
$key = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application->xmlrpc_server_url);
|
||||
$mnet_peer->public_key = clean_param($key, PARAM_PEM);
|
||||
}
|
||||
?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if (empty($mnet_peer->public_key)) {
|
||||
print_string('nopubkey', 'mnet');
|
||||
}
|
||||
?><br />
|
||||
<textarea rows="17" cols="65" name="public_key" style="font-size: 8px;"><?php echo $mnet_peer->public_key; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('expires', 'mnet'); ?>:</td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if($mnet_peer->public_key_expires < time()) {
|
||||
print_string('expired', 'mnet');
|
||||
echo ' ';
|
||||
}
|
||||
echo userdate($mnet_peer->public_key_expires);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
if(!empty($currentkey)) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"></td>
|
||||
<td valign="top"><?php print_string('keymismatch', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('currentkey', 'mnet'); ?>:</td>
|
||||
<td valign="top"><pre style="font-size: 8px;"><?php echo $currentkey;?></pre></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('last_connect_time', 'mnet'); ?>:</td>
|
||||
<td valign="top"><?php echo ($mnet_peer->last_connect_time == 0)? get_string('never','mnet') : date('H:i:s d/m/Y',$mnet_peer->last_connect_time);?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('deleted'); ?>:</td>
|
||||
<td valign="top">
|
||||
<input type="radio" name="deleted" value="0" checked="checked" /> <?php print_string('reenableserver','mnet'); ?><br />
|
||||
<input type="radio" name="deleted" value="1" /> <?php print_string('yes'); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($mnet_peer->ip_address) && '' != $mnet_peer->ip_address){
|
||||
?>
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('ipaddress', 'mnet');
|
||||
echo ': <br />';
|
||||
helpbutton("ipaddress", get_string('ipaddress', 'mnet'), "mnet", true, true);
|
||||
?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->ip_address; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges"); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
print_tabs(array($tabs), 'mnetdetails');
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
?>
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<tr>
|
||||
<td align="right" valign="top"><?php print_string('site'); ?>:</td>
|
||||
<td valign="top"><?php echo $mnet_peer->name; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top" colspan="2"><?php print_string('allhosts_no_options'); ?>:</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id && $mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetservices');
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="mnet_services.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="<?php echo $mnet_peer->nextstep; ?>" />
|
||||
<input type="hidden" name="hostid" value="<?php echo ($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
<?php
|
||||
foreach($myservices as $name => $versions) {
|
||||
$version = current($versions);
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<h3><?php echo get_string($name.'_name', $version['parent_type'].'_'.$version['parent'] , $mnet_peer->name); ?></h3>
|
||||
<?php echo get_string($name.'_description', $version['parent_type'].'_'.$version['parent'], $mnet_peer->name); ?>
|
||||
<?php
|
||||
$breakstring = '';
|
||||
foreach($versions as $version){
|
||||
if (count($versions) > 1) {
|
||||
$versionstring = '('.get_string('version','mnet') .' '.$version['apiversion'].')';
|
||||
} else {
|
||||
$versionstring = '';
|
||||
}
|
||||
|
||||
echo $breakstring;
|
||||
?>
|
||||
<input type="hidden" name="exists[<?php echo $version['serviceid']; ?>]" value="1" />
|
||||
<input type="checkbox" name="publish[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_publish']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('publish','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
echo '<a href="#" title="'.get_string('issubscribed','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_publish'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_publish']));
|
||||
}
|
||||
echo '<br />';
|
||||
?>
|
||||
<input type="checkbox" name="subscribe[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_subscribe']))? 'checked="checked" ': '' ; ?>/>
|
||||
<?php
|
||||
print_string('subscribe','mnet');
|
||||
echo $versionstring;
|
||||
if (!empty($version['hostpublishes'])) {
|
||||
echo '<a href="#" title="'.get_string('ispublished','mnet', $mnet_peer->name).'">√</a> ';
|
||||
}
|
||||
if (!empty($version['allhosts_subscribe'])) {
|
||||
print_string("enabled_for_all",'mnet',!empty($version['I_subscribe']));
|
||||
}
|
||||
|
||||
echo '<br />';
|
||||
$breakstring = '. . . . . . . . . . . . . . . . . . . . . . . . <br>';
|
||||
} // end foreach
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end foreach
|
||||
?>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="pubTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="subTreeLoc"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<div id="formElements"><input type="hidden" name="outer" value="4" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,183 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
// force Go ahead with something we've been warned is strange
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
$nocertstring = '';
|
||||
$nocertmatch = '';
|
||||
$badcert = '';
|
||||
$certerror = '';
|
||||
$noipmatch = '';
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmneteditservices = get_string('reviewhostservices', 'mnet');
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
$treevals = array();
|
||||
foreach($_POST['exists'] as $key => $value) {
|
||||
$host2service = get_record('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
$publish = (isset($_POST['publish'][$key]) && $_POST['publish'][$key] == 'on')? 1 : 0;
|
||||
$subscribe = (isset($_POST['subscribe'][$key]) && $_POST['subscribe'][$key] == 'on')? 1 : 0;
|
||||
|
||||
if ($publish != 1 && $subscribe != 1) {
|
||||
if (false == $host2service) {
|
||||
// We don't have or need a record - do nothing!
|
||||
} else {
|
||||
// We don't need the record - delete it
|
||||
delete_records('mnet_host2service', 'hostid', $_POST['hostid'], 'serviceid', $key);
|
||||
}
|
||||
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
|
||||
$host2service = new stdClass();
|
||||
$host2service->hostid = $_POST['hostid'];
|
||||
$host2service->serviceid = $key;
|
||||
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
|
||||
$host2service->id = insert_record('mnet_host2service', $host2service);
|
||||
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
|
||||
$host2service->publish = $publish;
|
||||
$host2service->subscribe = $subscribe;
|
||||
$tf = update_record('mnet_host2service', $host2service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($hostid)) {
|
||||
if (0 == $mnet_peer->id) $mnet_peer->set_id($hostid);
|
||||
$mnet_peer->nextstep = 'verify';
|
||||
|
||||
$id_list = $mnet_peer->id;
|
||||
if (!empty($CFG->mnet_all_hosts_id)) {
|
||||
$id_list .= ', '.$CFG->mnet_all_hosts_id;
|
||||
}
|
||||
|
||||
$concat = sql_concat('COALESCE(h2s.id,0) ', ' \'-\' ', ' svc.id');
|
||||
|
||||
$query = "
|
||||
SELECT DISTINCT
|
||||
$concat as id,
|
||||
svc.id as serviceid,
|
||||
svc.name,
|
||||
svc.offer,
|
||||
svc.apiversion,
|
||||
r.parent_type,
|
||||
r.parent,
|
||||
h2s.hostid,
|
||||
h2s.publish,
|
||||
h2s.subscribe
|
||||
FROM
|
||||
{$CFG->prefix}mnet_service2rpc s2r,
|
||||
{$CFG->prefix}mnet_rpc r,
|
||||
{$CFG->prefix}mnet_service svc
|
||||
LEFT JOIN
|
||||
{$CFG->prefix}mnet_host2service h2s
|
||||
ON
|
||||
h2s.hostid in ($id_list) AND
|
||||
h2s.serviceid = svc.id
|
||||
WHERE
|
||||
svc.offer = '1' AND
|
||||
s2r.serviceid = svc.id AND
|
||||
s2r.rpcid = r.id
|
||||
ORDER BY
|
||||
svc.name ASC";
|
||||
|
||||
$resultset = get_records_sql($query);
|
||||
|
||||
if (is_array($resultset)) {
|
||||
$resultset = array_values($resultset);
|
||||
} else {
|
||||
$resultset = array();
|
||||
}
|
||||
|
||||
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
|
||||
|
||||
$remoteservices = array();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
// Create a new request object
|
||||
$mnet_request = new mnet_xmlrpc_client();
|
||||
|
||||
// Tell it the path to the method that we want to execute
|
||||
$mnet_request->set_method('system/listServices');
|
||||
$mnet_request->send($mnet_peer);
|
||||
if (is_array($mnet_request->response)) {
|
||||
foreach($mnet_request->response as $service) {
|
||||
$remoteservices[$service['name']][$service['apiversion']] = $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$myservices = array();
|
||||
foreach($resultset as $result) {
|
||||
$result->hostpublishes = false;
|
||||
$result->hostsubscribes = false;
|
||||
if (isset($remoteservices[$result->name][$result->apiversion])) {
|
||||
if ($remoteservices[$result->name][$result->apiversion]['publish'] == 1) {
|
||||
$result->hostpublishes = true;
|
||||
}
|
||||
if ($remoteservices[$result->name][$result->apiversion]['subscribe'] == 1) {
|
||||
$result->hostsubscribes = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($myservices[$result->name][$result->apiversion])) {
|
||||
$myservices[$result->name][$result->apiversion] = array('serviceid' => $result->serviceid,
|
||||
'name' => $result->name,
|
||||
'offer' => $result->offer,
|
||||
'apiversion' => $result->apiversion,
|
||||
'parent_type' => $result->parent_type,
|
||||
'parent' => $result->parent,
|
||||
'hostsubscribes' => $result->hostsubscribes,
|
||||
'hostpublishes' => $result->hostpublishes
|
||||
);
|
||||
}
|
||||
|
||||
// allhosts_publish allows us to tell the admin that even though he
|
||||
// is disabling a service, it's still available to the host because
|
||||
// he's also publishing it to 'all hosts'
|
||||
if ($result->hostid == $CFG->mnet_all_hosts_id && $CFG->mnet_all_hosts_id != $mnet_peer->id) {
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['allhosts_subscribe'] = $result->subscribe;
|
||||
} elseif (!empty($result->hostid)) {
|
||||
$myservices[$result->name][$result->apiversion]['I_publish'] = $result->publish;
|
||||
$myservices[$result->name][$result->apiversion]['I_subscribe'] = $result->subscribe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
redirect('peers.php', get_string('nohostid','mnet'), '5');
|
||||
exit;
|
||||
}
|
||||
|
||||
include('./mnet_services.html');
|
||||
?>
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
print_heading(get_string('themes'));
|
||||
$original_theme = fullclone($THEME);
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetthemes');
|
||||
|
||||
$themes = get_list_of_plugins("theme");
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">";
|
||||
|
||||
if (count($report)) {
|
||||
echo '<tr>';
|
||||
echo '<td align="center" colspan="2">';
|
||||
echo '<span class="'.$report[1].'">'.$report[0].'</span>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
if (!$USER->screenreader) {
|
||||
echo "<tr class=\"generaltableheader\"><th scope=\"col\">$strtheme</th>";
|
||||
echo "<th scope=\"col\">$strinfo</th></tr>";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
echo '<td align="center"><span class="informationbox">Choose this option to use your site\'s default theme: <strong>'.$CFG->theme.'</strong>.</span></td>';
|
||||
if ($mnet_peer->theme == '') {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">Site Theme</p>';
|
||||
$options = null;
|
||||
$options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ';
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
|
||||
foreach ($themes as $theme) {
|
||||
|
||||
unset($THEME);
|
||||
|
||||
if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
|
||||
continue;
|
||||
}
|
||||
|
||||
include($CFG->themedir.'/'.$theme.'/config.php');
|
||||
|
||||
$readme = '';
|
||||
$screenshot = '';
|
||||
$screenshotpath = '';
|
||||
|
||||
if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
} else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) {
|
||||
$readme = '<li>'.
|
||||
link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
|
||||
}
|
||||
if (file_exists("$theme/screenshot.png")) {
|
||||
$screenshotpath = "$theme/screenshot.png";
|
||||
} else if (file_exists("$theme/screenshot.jpg")) {
|
||||
$screenshotpath = "$theme/screenshot.jpg";
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
// no point showing this if user is using screen reader
|
||||
if (!$USER->screenreader) {
|
||||
echo "<td align=\"center\">";
|
||||
if ($screenshotpath) {
|
||||
$screenshot = '<li><a href='.$CFG->wwwroot .'/theme/'. $theme.'/screenshot.jpg">'.$strscreenshot.'</a></li>';
|
||||
echo "<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object></td>";
|
||||
} else {
|
||||
echo '<object type="text/html" data="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'" height="200" width="400">'.$theme.'</object></td>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($mnet_peer->theme == $theme) {
|
||||
echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
|
||||
} else {
|
||||
echo '<td valign="top">';
|
||||
}
|
||||
|
||||
if (isset($THEME->sheets)) {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>';
|
||||
} else {
|
||||
echo '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>';
|
||||
}
|
||||
|
||||
if ($screenshot or $readme) {
|
||||
echo '<ul>';
|
||||
if (!$USER->screenreader) {
|
||||
echo '<li><a href="'.$CFG->wwwroot.'/theme/preview.php?preview='.$theme.'">'.$strpreview.'</a></li>';
|
||||
}
|
||||
echo $screenshot.$readme;
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
$options = null;
|
||||
$options['choose'] = $theme;
|
||||
$options['sesskey'] = $sesskey;
|
||||
$options['hostid'] = $mnet_peer->id;
|
||||
print_single_button('mnet_themes.php', $options, $strchoose);
|
||||
echo '</td>';
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
$THEME = $original_theme;
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!$site = get_site()) {
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$strconfiguration = get_string('configuration');
|
||||
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetsettings = get_string('mnetsettings', 'mnet');
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
if (is_int($hostid)) {
|
||||
$mnet_peer->set_id($hostid);
|
||||
}
|
||||
|
||||
$choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strthemes = get_string("themes");
|
||||
$strpreview = get_string("preview");
|
||||
$strchoose = get_string("choose");
|
||||
$strinfo = get_string("info");
|
||||
$strtheme = get_string("theme");
|
||||
$strthemesaved = get_string("themesaved");
|
||||
$strscreenshot = get_string("screenshot");
|
||||
$stroldtheme = get_string("oldtheme");
|
||||
$report = array();
|
||||
$unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name
|
||||
|
||||
if ($choose) {
|
||||
if (confirm_sesskey()) {
|
||||
if ($choose == $unlikely_name) {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->updateparams->force_theme = 1;
|
||||
$mnet_peer->theme = '';
|
||||
$mnet_peer->updateparams->theme = '';
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved'), 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet'), 'errorbox');
|
||||
}
|
||||
} elseif (!is_dir($CFG->themedir .'/'. $choose) || !file_exists($CFG->themedir .'/'. $choose .'/config.php')) {
|
||||
echo 'CHOOSE -'.$choose.' '. $CFG->themedir .'/'. $choose .'/config.php' ;
|
||||
$report = array('This theme is not installed!'.'3', 'errorbox');
|
||||
} else {
|
||||
$mnet_peer->force_theme = 1;
|
||||
$mnet_peer->theme = $choose;
|
||||
$mnet_peer->updateparams->theme = addslashes($choose);
|
||||
if ($mnet_peer->commit()) {
|
||||
$report = array(get_string('themesaved').'1', 'informationbox');
|
||||
} else {
|
||||
$report = array(get_string('themesavederror', 'mnet').'2', 'errorbox');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminroot = admin_get_root();
|
||||
require('./mnet_themes.html');
|
||||
?>
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
|
||||
print_box(get_string('mnetdisabled','mnet'));
|
||||
}
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<form method="post" action="peers.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="updateregisterall" value="1" />
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('registerallhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('registerallhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1"><input type="checkbox" name="registerallhosts" <?php if (!empty($CFG->mnet_register_allhosts)) echo 'checked="checked" '; ?>/></td>
|
||||
<td class="cell c1"> <?php print_string('registerallhosts', 'mnet'); ?> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" colspan="2"><input type="submit" name="submit" value="<?php print_string('savechanges'); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
<tr>
|
||||
<th class="header c0"><?php print_string('site'); ?></th>
|
||||
<th class="header c1"><?php print_string('system','mnet'); ?></th>
|
||||
<th class="header c2"><?php print_string('last_connect_time', 'mnet'); ?></th>
|
||||
<th class="header c3"></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach($hosts as $host) {
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c0"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->name; ?></a></td>
|
||||
<td class="cell c1"><a href="peers.php?step=update&hostid=<?php echo $host->id; ?>"><?php echo $host->wwwroot; ?></a></td>
|
||||
<td class="cell c2"><?php if ($host->id != $CFG->mnet_all_hosts_id) echo $last_connect; ?></td>
|
||||
<td class="cell c3">
|
||||
<?php if ($host->id != $CFG->mnet_all_hosts_id){ ?>
|
||||
<form method="post" action="delete.php">
|
||||
<div>
|
||||
<input type="hidden" name="hostid" value="<?php echo $host->id; ?>" />
|
||||
<input type="hidden" name="step" value="verify" />
|
||||
<input type="submit" name="submit" value="<?php print_string('delete'); ?>"/>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<form method="post" action="peers.php">
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox standard" >
|
||||
|
||||
<tr>
|
||||
<th class="header c4" colspan="4">
|
||||
<?php print_string('addnewhost', 'mnet'); ?>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="hidden" name="step" value="input" />
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c0">wwwroot:</td>
|
||||
<td class="cell c1"><input type="text" name="wwwroot" value="" /></td>
|
||||
<td class="cell c2">
|
||||
<select name="applicationid">
|
||||
<?php
|
||||
foreach($applications as $application) {
|
||||
echo ' <option value="'.$application->id.'">'.$application->display_name."</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="cell c3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c4" align="right" colspan="4"><input type="submit" value="<?php print_string('addhost','mnet'); ?>" /></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,184 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
// Allows the admin to configure other Moodle hosts info
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
/// Initialize variables.
|
||||
|
||||
// Step must be one of:
|
||||
// input Parse the details of a new host and fetch its public key
|
||||
// commit Save our changes (to a new OR existing host)
|
||||
$step = optional_param('step', NULL, PARAM_ALPHA);
|
||||
$hostid = optional_param('hostid', NULL, PARAM_INT);
|
||||
|
||||
// Fetch some strings for the HTML templates
|
||||
$strmnetservices = get_string('mnetservices', 'mnet');
|
||||
$strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
$strmnetthemes = get_string('mnetthemes', 'mnet');
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) set_config('mnet_dispatcher_mode', 'off');
|
||||
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
|
||||
if (!empty($form->wwwroot)) {
|
||||
// ensure we remove trailing slashes
|
||||
$form->wwwroot = preg_replace(':/$:', '', $form->wwwroot);
|
||||
|
||||
// ensure the wwwroot starts with a http or https prefix
|
||||
if (strtolower(substr($form->wwwroot, 0, 4)) != 'http') {
|
||||
$form->wwwroot = 'http://'.$form->wwwroot;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('xmlrpc_encode_request')) {
|
||||
trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
|
||||
print_error('xmlrpc-missing', 'mnet','peers.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($form->updateregisterall)) {
|
||||
if (!empty($form->registerallhosts)) {
|
||||
set_config('mnet_register_allhosts',1);
|
||||
} else {
|
||||
set_config('mnet_register_allhosts',0);
|
||||
}
|
||||
redirect('peers.php', get_string('changessaved'));
|
||||
} else {
|
||||
|
||||
$mnet_peer = new mnet_peer();
|
||||
|
||||
if (!empty($form->id)) {
|
||||
$form->id = clean_param($form->id, PARAM_INT);
|
||||
$mnet_peer->set_id($form->id);
|
||||
} else {
|
||||
// PARAM_URL requires a genuine TLD (I think) This breaks my testing
|
||||
$temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
|
||||
if ($temp_wwwroot !== $form->wwwroot) {
|
||||
trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
|
||||
print_error("invalidurl", 'mnet','peers.php');
|
||||
exit;
|
||||
}
|
||||
unset($temp_wwwroot);
|
||||
$mnet_peer->set_applicationid($form->applicationid);
|
||||
$application = get_field('mnet_application', 'name', 'id', $form->applicationid);
|
||||
$mnet_peer->bootstrap($form->wwwroot, null, $application);
|
||||
}
|
||||
|
||||
if (isset($form->name) && $form->name != $mnet_peer->name) {
|
||||
$form->name = clean_param($form->name, PARAM_NOTAGS);
|
||||
$mnet_peer->set_name($form->name);
|
||||
}
|
||||
|
||||
if (isset($form->deleted) && ($form->deleted == '0' || $form->deleted == '1')) {
|
||||
$mnet_peer->updateparams->deleted = $form->deleted;
|
||||
$mnet_peer->deleted = $form->deleted;
|
||||
}
|
||||
|
||||
if (isset($form->public_key)) {
|
||||
$form->public_key = clean_param($form->public_key, PARAM_PEM);
|
||||
if (empty($form->public_key)) {
|
||||
print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
exit;
|
||||
} else {
|
||||
$oldkey = $mnet_peer->public_key;
|
||||
$mnet_peer->public_key = $form->public_key;
|
||||
$mnet_peer->updateparams->public_key = addslashes($form->public_key);
|
||||
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
$mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($form->public_key);
|
||||
if ($mnet_peer->public_key_expires == false) {
|
||||
$errmsg = '<br />';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
}
|
||||
error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
|
||||
//print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $errmsg);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
|
||||
if ('input' == $form->step) {
|
||||
if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
|
||||
print_error("hostexists", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $mnet_peer->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ('input' == $form->step) {
|
||||
include('./mnet_review.html');
|
||||
} elseif ('commit' == $form->step) {
|
||||
$bool = $mnet_peer->commit();
|
||||
if ($bool) {
|
||||
redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved'));
|
||||
} else {
|
||||
error('Invalid action parameter.', 'index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (is_int($hostid)) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if($currentkey == $mnet_peer->public_key) unset($currentkey);
|
||||
$form = new stdClass();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
include('./mnet_review.html');
|
||||
} else {
|
||||
include('./mnet_review_allhosts.html');
|
||||
}
|
||||
} else {
|
||||
$hosts = get_records_sql(' SELECT
|
||||
h.id,
|
||||
h.wwwroot,
|
||||
h.ip_address,
|
||||
h.name,
|
||||
h.public_key,
|
||||
h.public_key_expires,
|
||||
h.transport,
|
||||
h.portno,
|
||||
h.last_connect_time,
|
||||
h.last_log_id,
|
||||
h.applicationid,
|
||||
a.name as app_name,
|
||||
a.display_name as app_display_name,
|
||||
a.xmlrpc_server_url
|
||||
FROM
|
||||
'.$CFG->prefix.'mnet_host h,
|
||||
'.$CFG->prefix.'mnet_application a
|
||||
WHERE
|
||||
h.id != \''.$CFG->mnet_localhost_id.'\' AND
|
||||
h.deleted = \'0\' AND
|
||||
h.applicationid=a.id');
|
||||
|
||||
if (empty($hosts)) $hosts = array();
|
||||
$applications = get_records('mnet_application');
|
||||
include('./peers.html');
|
||||
}
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
admin_externalpage_print_header();
|
||||
?>
|
||||
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('trustedhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('trustedhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="post" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<textarea name="hostlist" cols="40" rows="20"><?php echo $trusted_hosts; ?></textarea><br />
|
||||
<input type="submit" value="<?php print_string('savechanges'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
|
||||
<tr>
|
||||
<th class="header c0" colspan="2"><?php print_string('testtrustedhosts', 'mnet'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
if (!empty($test_ip_address)){
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<?php
|
||||
if ($in_range) {
|
||||
print_string('is_in_range', 'mnet', $test_ip_address);
|
||||
echo '<br />';
|
||||
print_string('validated_by', 'mnet', $validated_by);
|
||||
} else {
|
||||
print_string('not_in_range', 'mnet', $test_ip_address);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2"><?php print_string('testtrustedhostsexplain', 'mnet'); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td class="cell c1" colspan="2">
|
||||
<form method="get" action="trustedhosts.php">
|
||||
<div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>" />
|
||||
<input type="text" name="testipaddress" value="<?php echo $test_ip_address; ?>" />
|
||||
<input type="submit" value="<?php print_string('go'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
// Allows the admin to configure services for remote hosts
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('trustedhosts');
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
admin_externalpage_print_header();
|
||||
print_error('nosite', '', '', NULL, true);
|
||||
}
|
||||
|
||||
$trusted_hosts = '';//array();
|
||||
$old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts');
|
||||
if (!empty($old_trusted_hosts)) {
|
||||
$old_trusted_hosts = explode(',', $old_trusted_hosts);
|
||||
} else {
|
||||
$old_trusted_hosts = array();
|
||||
}
|
||||
|
||||
$test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST);
|
||||
$in_range = false;
|
||||
if (!empty($test_ip_address)) {
|
||||
foreach($old_trusted_hosts as $host) {
|
||||
list($network, $mask) = explode('/', $host.'/');
|
||||
if (empty($network)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
|
||||
if (ip_in_range($test_ip_address, $network, $mask)) {
|
||||
$in_range = true;
|
||||
$validated_by = $network.'/'.$mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If data submitted, process and store
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$hostlist = preg_split("/[\s,]+/", $form->hostlist);
|
||||
foreach($hostlist as $host) {
|
||||
list($address, $mask) = explode('/', $host.'/');
|
||||
if (empty($address)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
|
||||
unset($address, $mask);
|
||||
}
|
||||
set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet');
|
||||
} elseif (!empty($old_trusted_hosts)) {
|
||||
foreach($old_trusted_hosts as $host) {
|
||||
list($address, $mask) = explode('/', $host.'/');
|
||||
if (empty($address)) continue;
|
||||
if (strlen($mask) == 0) $mask = 32;
|
||||
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
|
||||
unset($address, $mask);
|
||||
}
|
||||
}
|
||||
|
||||
include('./trustedhosts.html');
|
||||
?>
|
||||
+32
-45
@@ -1,69 +1,56 @@
|
||||
<?PHP // $Id$
|
||||
// module.php - allows admin to edit all local configuration variables for a module
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only an admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
$module = optional_param('module', '', PARAM_SAFEDIR);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
if ($module != '') {
|
||||
include_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.
|
||||
$moduleprefix = $module.'_';
|
||||
// let the module process the form data if it has to,
|
||||
// $config is passed to this function by reference
|
||||
$moduleconfig = $module.'_process_options';
|
||||
if (function_exists($moduleconfig)) {
|
||||
$moduleconfig($config);
|
||||
}
|
||||
} else {
|
||||
admin_externalpage_setup('managemodules');
|
||||
|
||||
$moduleprefix = '';
|
||||
}
|
||||
|
||||
unset($config->sesskey);
|
||||
unset($config->module);
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
print_header();
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($moduleprefix.$name, $value);
|
||||
set_config($name, $value);
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
$module = required_param('module', PARAM_SAFEDIR);
|
||||
include_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
admin_externalpage_setup('modsetting'.$module);
|
||||
|
||||
require_variable($module);
|
||||
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strmodulename = get_string("modulename", $module);
|
||||
|
||||
// $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 = 'mod/' . $module . '/config';
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"modules.php\">$strmanagemodules</a> -> $strmodulename");
|
||||
|
||||
print_heading($strmodulename);
|
||||
|
||||
print_simple_box(get_string("configwarning", 'admin'), "center", "60%");
|
||||
print_simple_box("<center>".get_string("configwarning")."</center>", "center", "50%");
|
||||
echo "<br />";
|
||||
|
||||
print_simple_box_start("center", "");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("$CFG->dirroot/mod/$module/config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
+77
-144
@@ -1,26 +1,30 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to manage activity modules
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
require_once("../config.php");
|
||||
require_once("../course/lib.php");
|
||||
|
||||
// defines
|
||||
define('MODULE_TABLE','module_administration_table');
|
||||
optional_variable($disable);
|
||||
optional_variable($enable);
|
||||
optional_variable($delete);
|
||||
optional_variable($confirm);
|
||||
|
||||
admin_externalpage_setup('managemodules');
|
||||
require_login();
|
||||
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stractivities = get_string("activities");
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagemodules = get_string("managemodules");
|
||||
$strdelete = get_string("delete");
|
||||
$strversion = get_string("version");
|
||||
$strhide = get_string("hide");
|
||||
@@ -28,62 +32,41 @@
|
||||
$strsettings = get_string("settings");
|
||||
$stractivities = get_string("activities");
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
$strshowmodulecourse = get_string('showmodulecourse');
|
||||
|
||||
print_header("$site->shortname: $strmanagemodules", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagemodules");
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
if (!empty($hide)) {
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
// Remember the visibility status in visibleold
|
||||
// and hide...
|
||||
$sql = "UPDATE {$CFG->prefix}course_modules
|
||||
SET visibleold=visible,
|
||||
visible=0
|
||||
WHERE module={$module->id}";
|
||||
execute_sql($sql, false);
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just deleted something
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
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
|
||||
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
|
||||
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!empty($show)) {
|
||||
if (!$module = get_record("modules", "name", $show)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field('course_modules', 'visible', '1', 'visibleold',
|
||||
'1', 'module', $module->id); // Get the previous saved visible state for the course module.
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
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
|
||||
set_field("modules", "visible", "1", "id", $module->id); // Show main module
|
||||
set_field("course_modules", "visible", "1", "module", $module->id); // Show all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
if (!empty($delete)) {
|
||||
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (!$confirm) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=1&sesskey=$USER->sesskey",
|
||||
if (empty($confirm)) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=$delete",
|
||||
"modules.php");
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
@@ -105,26 +88,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// delete calendar events
|
||||
if (!delete_records("event", "modulename", $delete)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in calendar event table");
|
||||
}
|
||||
|
||||
// clear course.modinfo for courses
|
||||
// that used this module...
|
||||
$sql = "UPDATE {$CFG->prefix}course
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
FROM {$CFG->prefix}course_modules
|
||||
WHERE module={$module->id})";
|
||||
execute_sql($sql, false);
|
||||
|
||||
// Now delete all the course module records
|
||||
if (!delete_records("course_modules", "module", $module->id)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in course_modules table");
|
||||
}
|
||||
|
||||
// Then delete all the logs
|
||||
// Then delete all the logs
|
||||
if (!delete_records("log", "module", $module->name)) {
|
||||
notify("Error occurred while deleting all $strmodulename records in log table");
|
||||
}
|
||||
@@ -139,34 +108,21 @@
|
||||
notify("Error occurred while deleting the $strmodulename record from modules table");
|
||||
}
|
||||
|
||||
// And the module configuration records
|
||||
if (!execute_sql("DELETE FROM {$CFG->prefix}config WHERE name LIKE '{$module->name}_%'")) {
|
||||
notify("Error occurred while deleting the $strmodulename records from the config table");
|
||||
}
|
||||
|
||||
// cleanup the gradebook
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($module->name, "$CFG->dirroot/mod/$module->name/db/install.xml", false);
|
||||
|
||||
// Delete the capabilities that were defined by this module
|
||||
capabilities_cleanup('mod/'.$module->name);
|
||||
|
||||
// remove entent handlers and dequeue pending events
|
||||
events_uninstall('mod/'.$module->name);
|
||||
|
||||
// Perform any custom uninstall tasks
|
||||
if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
|
||||
require_once($CFG->dirroot . '/mod/' . $module->name . '/lib.php');
|
||||
$uninstallfunction = $module->name . '_uninstall';
|
||||
if (function_exists($uninstallfunction)) {
|
||||
if (! $uninstallfunction() ) {
|
||||
notify('Encountered a problem running uninstall function for '. $module->name.'!');
|
||||
if ($tables = $db->Metatables()) {
|
||||
$prefix = $CFG->prefix.$module->name;
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table, $prefix) === 0) {
|
||||
if (!execute_sql("DROP TABLE $table", false)) {
|
||||
notify("ERROR: while trying to drop table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rebuild_course_cache(); // Because things have changed
|
||||
|
||||
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
@@ -174,9 +130,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading($stractivities);
|
||||
|
||||
/// Get and sort the existing modules
|
||||
|
||||
if (!$modules = get_records("modules")) {
|
||||
@@ -185,80 +138,60 @@
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$strmodulename = get_string("modulename", "$module->name");
|
||||
// Deal with modules which are lacking the language string
|
||||
if ($strmodulename == '[[modulename]]') {
|
||||
$strmodulename = $module->name;
|
||||
}
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname, SORT_LOCALE_STRING);
|
||||
ksort($modulebyname);
|
||||
|
||||
/// Print the table of all modules
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(MODULE_TABLE);
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
|
||||
$table->set_attribute('id', 'modules');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = "../pix";
|
||||
$modpixpath = "../mod";
|
||||
} else {
|
||||
$pixpath = "../theme/$CFG->theme/pix";
|
||||
$modpixpath = "../theme/$CFG->theme/pix/mod";
|
||||
}
|
||||
|
||||
$table->head = array ($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
|
||||
$table->align = array ("LEFT", "RIGHT", "LEFT", "CENTER", "CENTER", "CENTER");
|
||||
$table->wrap = array ("NOWRAP", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
|
||||
foreach ($modulebyname as $modulename => $module) {
|
||||
|
||||
// took out hspace="\10\", because it does not validate. don't know what to replace with.
|
||||
$icon = "<img src=\"$CFG->modpixpath/$module->name/icon.gif\" class=\"icon\" alt=\"\" />";
|
||||
$icon = "<img src=\"$modpixpath/$module->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
$delete = "<a href=\"modules.php?delete=$module->name\">$strdelete</a>";
|
||||
|
||||
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")) {
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
$settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
|
||||
$count = count_records_select("$module->name",'course<>0');
|
||||
if ($count>0) {
|
||||
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
|
||||
"&sesskey={$USER->sesskey}\" title=\"$strshowmodulecourse\">$count</a>";
|
||||
}
|
||||
else {
|
||||
$countlink = "$count";
|
||||
}
|
||||
$count = count_records("$module->name");
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
$visible = "<a href=\"modules.php?hide=$module->name\" title=\"$strhide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = " class=\"dimmed_text\"";
|
||||
$visible = "<a href=\"modules.php?show=$module->name\" title=\"$strshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
$delete = "";
|
||||
$visible = "";
|
||||
$class = "";
|
||||
}
|
||||
|
||||
$extra = '';
|
||||
if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) {
|
||||
$extra = ' <span class="notifyproblem">('.get_string('missingfromdisk').')</span>';
|
||||
}
|
||||
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$icon.' '.$modulename.$extra.'</span>',
|
||||
$countlink,
|
||||
'<span'.$class.'>'.$module->version.'</span>',
|
||||
$visible,
|
||||
$delete,
|
||||
$settings
|
||||
));
|
||||
$table->data[] = array ("<p $class>$icon $modulename</p>", $count, $module->version, $visible, $delete, $settings);
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
$table->print_html();
|
||||
echo "<br /><br />";
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('multilangupgrade');
|
||||
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
###################################################################
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading(get_string('multilangupgrade', 'admin'));
|
||||
|
||||
$strmultilangupgrade = get_String('multilangupgradeinfo', 'admin');
|
||||
|
||||
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
|
||||
notice_yesno($strmultilangupgrade, 'multilangupgrade.php', 'index.php', $optionsyes, null, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
if (!$tables = $db->Metatables() ) { // No tables yet at all.
|
||||
error("no tables");
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
while(@ob_end_flush());
|
||||
|
||||
echo '<strong>Progress:</strong>';
|
||||
$i = 0;
|
||||
$skiptables = array($CFG->prefix.'config', $CFG->prefix.'user_students', $CFG->prefix.'user_teachers');//, $CFG->prefix.'sessions2');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (($CFG->prefix && strpos($table, $CFG->prefix) !== 0)
|
||||
or strpos($table, $CFG->prefix.'pma') === 0) { // Not our tables
|
||||
continue;
|
||||
}
|
||||
if (in_array($table, $skiptables)) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
if ($columns = $db->MetaColumns($table, false)) {
|
||||
if (!array_key_exists('id', $columns) and !array_key_exists('ID', $columns)) {
|
||||
continue; // moodle tables have id
|
||||
}
|
||||
foreach ($columns as $column => $data) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
// first find candidate records
|
||||
$rs = get_recordset_sql("SELECT id, $column FROM $table WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'");
|
||||
if ($rs) {
|
||||
while (!$rs->EOF) {
|
||||
$text = $rs->fields[$column];
|
||||
$id = $rs->fields['id'];
|
||||
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
if ($i % 10 == 0) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
$rs->MoveNext();
|
||||
|
||||
if (empty($text) or is_numeric($text)) {
|
||||
continue; // nothing to do
|
||||
}
|
||||
|
||||
$search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)+/is';
|
||||
$newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
|
||||
|
||||
if (is_null($newtext)) {
|
||||
continue; // regex error
|
||||
}
|
||||
|
||||
if ($newtext != $text) {
|
||||
$newtext = addslashes($newtext);
|
||||
execute_sql("UPDATE $table SET $column='$newtext' WHERE id=$id", false);
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('filter_multilang_converted', 1);
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
notify('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
notify('...finished', 'notifysuccess');
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
|
||||
|
||||
function multilangupgrade_impl($langblock) {
|
||||
$searchtosplit = '/<(?:lang|span) lang="([a-zA-Z0-9_-]*)".*?>(.+?)<\/(?:lang|span)>/is';
|
||||
preg_match_all($searchtosplit, $langblock[0], $rawlanglist);
|
||||
$return = '';
|
||||
foreach ($rawlanglist[1] as $index=>$lang) {
|
||||
$return .= '<span lang="'.$lang.'" class="multilang">'.$rawlanglist[2][$index].'</span>';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
?>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
if (!isset($CFG)) {
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('oacleanup');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
online_assignment_cleanup(true);
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function online_assignment_cleanup($output=false) {
|
||||
global $CFG;
|
||||
|
||||
if ($output) {
|
||||
print_heading('Online Assignment Cleanup');
|
||||
echo '<center>';
|
||||
}
|
||||
|
||||
|
||||
/// We don't want to run this code if we are doing an upgrade from an assignment
|
||||
/// version earlier than 2005041400
|
||||
/// because the assignment type field will not exist
|
||||
$amv = get_field('modules', 'version', 'name', 'assignment');
|
||||
if ((int)$amv < 2005041400) {
|
||||
if ($output) {
|
||||
echo '</center>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// get the module id for assignments from db
|
||||
$arecord = get_record('modules', 'name', 'assignment');
|
||||
$aid = $arecord->id;
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
$courses = get_records('course');
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
|
||||
if ($output) print_heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$sql = 'SELECT * FROM '.$CFG->prefix.'course_sections WHERE course='.$course->id.' AND section>'.$course->numsections.' ORDER BY section ASC';
|
||||
if (!($xsections = get_records_sql($sql))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// cycle through each of the xtra sections
|
||||
foreach ($xsections as $xsection) {
|
||||
|
||||
if ($output) echo 'Checking Section: '.$xsection->section.'<br />';
|
||||
|
||||
/// grab any module instances from the sequence field
|
||||
if (!empty($xsection->sequence)) {
|
||||
$instances = explode(',', $xsection->sequence);
|
||||
|
||||
/// cycle through the instances
|
||||
foreach ($instances as $instance) {
|
||||
/// is this an instance of an online assignment
|
||||
$sql = "SELECT a.id
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}assignment a
|
||||
WHERE cm.id = '$instance' AND
|
||||
cm.module = '$aid' AND
|
||||
cm.instance = a.id AND
|
||||
a.assignmenttype = 'online'";
|
||||
|
||||
|
||||
/// if record exists then we need to move instance to it's correct section
|
||||
if (record_exists_sql($sql)) {
|
||||
|
||||
/// check the new section id
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
$newsection = $xsection->section;
|
||||
/// double check the new section
|
||||
if ($newsection > $course->numsections) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = get_record('course_sections', 'course', $course->id, 'section', '0'))) {
|
||||
continue;
|
||||
}
|
||||
$newsection = $zerosection->id;
|
||||
}
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = get_record('course_sections', 'id', $newsection))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// add instance to correct section
|
||||
array_push($sequence, $instance);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
/// now we need to remove the instance from the old sequence
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = get_record('course_sections', 'id', $xsection->id))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
/// explode the sequence
|
||||
if (($sequence = explode(',', $section->sequence)) === false) {
|
||||
$sequence = array();
|
||||
}
|
||||
|
||||
/// remove the old value from the array
|
||||
$key = array_search($instance, $sequence);
|
||||
unset($sequence[$key]);
|
||||
|
||||
/// implode the sequence
|
||||
$section->sequence = implode(',', $sequence);
|
||||
|
||||
set_field('course_sections', 'sequence', $section->sequence, 'id', $section->id);
|
||||
|
||||
|
||||
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// if the summary and sequence are empty then remove this section
|
||||
if (empty($xsection->summary) and empty($xsection->sequence)) {
|
||||
delete_records('course_sections', 'id', $xsection->id);
|
||||
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/pagelib.php');
|
||||
|
||||
define('PAGE_ADMIN', 'admin');
|
||||
|
||||
// Bounds for block widths
|
||||
// more flexible for theme designers taken from theme config.php
|
||||
$lmin = (empty($THEME->block_l_min_width)) ? 0 : $THEME->block_l_min_width;
|
||||
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
|
||||
$rmin = (empty($THEME->block_r_min_width)) ? 0 : $THEME->block_r_min_width;
|
||||
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
|
||||
|
||||
define('BLOCK_L_MIN_WIDTH', $lmin);
|
||||
define('BLOCK_L_MAX_WIDTH', $lmax);
|
||||
define('BLOCK_R_MIN_WIDTH', $rmin);
|
||||
define('BLOCK_R_MAX_WIDTH', $rmax);
|
||||
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
|
||||
class page_admin extends page_base {
|
||||
|
||||
var $section;
|
||||
var $visiblepathtosection;
|
||||
|
||||
// hack alert!
|
||||
// this function works around the inability to store the section name
|
||||
// in default block, maybe we should "improve" the blocks a bit?
|
||||
function init_extra($section) {
|
||||
global $CFG;
|
||||
|
||||
if($this->full_init_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
// fetch the path parameter
|
||||
$this->section = $section;
|
||||
$current =& $adminroot->locate($section, true);
|
||||
$this->visiblepathtosection = array_reverse($current->visiblepath);
|
||||
|
||||
// all done
|
||||
$this->full_init_done = true;
|
||||
}
|
||||
|
||||
function blocks_get_default() {
|
||||
return 'admin_tree,admin_bookmarks';
|
||||
}
|
||||
|
||||
// seems reasonable that the only people that can edit blocks on the admin pages
|
||||
// are the admins... but maybe we want a role for this?
|
||||
function user_allowed_editing() {
|
||||
return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
|
||||
// has to be fixed. i know there's a "proper" way to do this
|
||||
function user_is_editing() {
|
||||
global $USER;
|
||||
return $USER->adminediting;
|
||||
}
|
||||
|
||||
function url_get_path() {
|
||||
global $CFG;
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
$root =& $adminroot->locate($this->section);
|
||||
if (is_a($root, 'admin_externalpage')) {
|
||||
return $root->url;
|
||||
} else {
|
||||
return ($CFG->wwwroot . '/' . $CFG->admin . '/settings.php');
|
||||
}
|
||||
}
|
||||
|
||||
function url_get_parameters() { // only handles parameters relevant to the admin pagetype
|
||||
return array('section' => (isset($this->section) ? $this->section : ''));
|
||||
}
|
||||
|
||||
function blocks_get_positions() {
|
||||
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
|
||||
}
|
||||
|
||||
function blocks_default_position() {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
|
||||
function blocks_move_position(&$instance, $move) {
|
||||
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
|
||||
return BLOCK_POS_RIGHT;
|
||||
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
|
||||
return BLOCK_POS_LEFT;
|
||||
}
|
||||
return $instance->position;
|
||||
}
|
||||
|
||||
// does anything need to be done here?
|
||||
function init_quick($data) {
|
||||
parent::init_quick($data);
|
||||
}
|
||||
|
||||
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.
|
||||
// if not, print_header() has to be called with a $section parameter
|
||||
|
||||
// The search page currently doesn't handle block editing
|
||||
if ($this->section != 'search' and $this->user_allowed_editing()) {
|
||||
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="hidden" name="section" value="'.$this->section.'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></div>';
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
$navlinks = array();
|
||||
foreach ($this->visiblepathtosection as $element) {
|
||||
$navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
|
||||
}
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, '');
|
||||
}
|
||||
|
||||
function get_type() {
|
||||
return PAGE_ADMIN;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+24
-23
@@ -2,32 +2,33 @@
|
||||
// phpinfo.php - shows phpinfo for the current server
|
||||
|
||||
require_once("../config.php");
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('phpinfo');
|
||||
require_login();
|
||||
|
||||
admin_externalpage_print_header();
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
echo '<div class="phpinfo">';
|
||||
if (isset($topframe)) {
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
print_header("$site->shortname: phpinfo", "$site->fullname",
|
||||
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> PHP info");
|
||||
exit;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES);
|
||||
$html = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
/// Delete styles from output
|
||||
$html = preg_replace('#(\n?<style[^>]*?>.*?</style[^>]*?>)|(\n?<style[^>]*?/>)#is', '', $html);
|
||||
$html = preg_replace('#(\n?<head[^>]*?>.*?</head[^>]*?>)|(\n?<head[^>]*?/>)#is', '', $html);
|
||||
/// Delete DOCTYPE from output
|
||||
$html = preg_replace('/<!DOCTYPE html PUBLIC.*?>/is', '', $html);
|
||||
/// Delete body and html tags
|
||||
$html = preg_replace('/<html.*?>.*?<body.*?>/is', '', $html);
|
||||
$html = preg_replace('/<\/body><\/html>/is', '', $html);
|
||||
|
||||
echo $html;
|
||||
|
||||
echo '</div>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
if (isset($bottomframe)) {
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<head>
|
||||
<title>PHP info</title>
|
||||
</head>
|
||||
|
||||
<frameset rows="80,*">
|
||||
<frame src="phpinfo.php?topframe=true">
|
||||
<frame src="phpinfo.php?bottomframe=true">
|
||||
</frameset>
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/usr/bin/php -f
|
||||
<?php // $Id$
|
||||
define('FULLME','cron'); // prevent warnings
|
||||
//error_reporting(0);
|
||||
//ini_set('display_errors',0);
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
$tmp = explode('@',$_ENV['RECIPIENT']);
|
||||
$address = $tmp[0];
|
||||
|
||||
// BOUNCE EMAILS TO NOREPLY
|
||||
if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
|
||||
$user->email = $_ENV['SENDER'];
|
||||
|
||||
if (!validate_email($user->email)) {
|
||||
die();
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
|
||||
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
|
||||
|
||||
$fd = fopen('php://stdin','r');
|
||||
if ($fd) {
|
||||
while(!feof($fd)) {
|
||||
$body .= fgets($fd);
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
$user->id = 0; // to prevent anything annoying happening
|
||||
|
||||
$from->firstname = null;
|
||||
$from->lastname = null;
|
||||
$from->email = '<>';
|
||||
$from->maildisplay = true;
|
||||
|
||||
email_to_user($user,$from,$subject,$body);
|
||||
die ();
|
||||
}
|
||||
/// ALL OTHER PROCESSING
|
||||
// we need to split up the address
|
||||
$prefix = substr($address,0,4);
|
||||
$mod = substr($address,4,2);
|
||||
$modargs = substr($address,6,-16);
|
||||
$hash = substr($address,-16);
|
||||
|
||||
if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
|
||||
die("HASH DIDN'T MATCH!\n");
|
||||
}
|
||||
list(,$modid) = unpack('C',base64_decode($mod.'=='));
|
||||
|
||||
if ($modid == '0') { // special
|
||||
$modname = 'moodle';
|
||||
}
|
||||
else {
|
||||
$modname = get_field("modules","name","id",$modid);
|
||||
include_once('mod/'.$modname.'/lib.php');
|
||||
}
|
||||
$function = $modname.'_process_email';
|
||||
|
||||
if (!function_exists($function)) {
|
||||
die();
|
||||
}
|
||||
$fd = fopen('php://stdin','r');
|
||||
if (!$fd) {
|
||||
exit();
|
||||
}
|
||||
|
||||
while(!feof($fd)) {
|
||||
$body .= fgets($fd);
|
||||
}
|
||||
|
||||
$function($modargs,$body);
|
||||
|
||||
fclose($handle);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
+74
-129
@@ -1,20 +1,18 @@
|
||||
<?php // $Id$
|
||||
<?PHP // $Id$
|
||||
// register.php - allows admin to register their site on moodle.org
|
||||
|
||||
require_once('../config.php');
|
||||
include("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', 'error');
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
error("No admins");
|
||||
}
|
||||
@@ -23,8 +21,12 @@
|
||||
$admin->country = $CFG->country;
|
||||
}
|
||||
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
|
||||
if (!$admin->secret) { // secret field hasn't been set yet
|
||||
$admin->secret = random_string(15);
|
||||
|
||||
if (!set_field("user", "secret", $admin->secret, "id", $admin->id)) {
|
||||
error("Could not set admin's secret string!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,160 +35,103 @@
|
||||
$stradministration = get_string("administration");
|
||||
$strregistration = get_string("registration");
|
||||
$strregistrationinfo = get_string("registrationinfo");
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strregistration, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$site->shortname: $strregistration", $site->fullname, $navigation);
|
||||
|
||||
print_heading($strregistration);
|
||||
print_header("$site->shortname: $strregistration", "$site->fullname",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
print_simple_box($strregistrationinfo, "center", "70%");
|
||||
echo "<br />";
|
||||
|
||||
|
||||
/// Print the form
|
||||
|
||||
echo "<form id=\"mform1\" class=\"mform\" action=\"http://moodle.org/register/\" method=\"post\">\n";
|
||||
echo '<fieldset id="registration">';
|
||||
echo '<legend>Registration Information</legend>';
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
echo "<form name=\"form\" action=\"http://moodle.org/register/\" method=post>\n";
|
||||
echo "<table cellpadding=9 border=0>\n";
|
||||
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>Moodle URL:</td>\n";
|
||||
echo "<td><p>$CFG->wwwroot</td>\n";
|
||||
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
|
||||
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
|
||||
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\" />\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\">\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$admin->secret\">\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\">\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\" />\n";
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("currentversion").":</td>\n";
|
||||
echo "<td><p>$CFG->release ($CFG->version)</td>\n";
|
||||
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\">\n";
|
||||
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>URL</label></div>';
|
||||
echo '<div class="felement ftext">'.$CFG->wwwroot.'</div>';
|
||||
echo '</div>';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("fullsitename").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"sitename\" value=\"$site->fullname\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("currentversion").'</label></div>';
|
||||
echo '<div class="felement ftext">'."$CFG->release ($CFG->version)".'</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="sitename">'.get_string("fullsitename").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo '<input size="50" id="sitename" type="text" name="sitename" value="'.format_string($site->fullname).'" />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucountry">'.get_string("country").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("country").":</td>\n";
|
||||
echo "<td><p>";
|
||||
choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menupublic">'."<a href=\"http://moodle.org/sites/?country=$admin->country\" title=\"".get_string("publicdirectorytitle")."\">".get_string("publicdirectory")."</a>".'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p><a href=\"http://moodle.org/sites\" title=\"See the current list of sites\" target=_blank>".get_string("publicdirectory")."</a>:</td>\n";
|
||||
echo "<td><p>";
|
||||
$options[0] = get_string("publicdirectory0");
|
||||
$options[1] = get_string("publicdirectory1");
|
||||
$options[2] = get_string("publicdirectory2");
|
||||
choose_from_menu ($options, "public", "2", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menucontact">'.get_string("registrationcontact").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
$options[0] = get_string("registrationcontactno");
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
choose_from_menu ($options, "contact", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td colspan=2><hr size=1 noshade>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label>'.get_string("statistics")."<br />(".get_string("notpublic").')'.'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("administrator").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"adminname\" value=\"".fullname($admin, true)."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
$count = count_records('course')-1;
|
||||
echo get_string("courses").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courses\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("email").":</td>\n";
|
||||
echo "<td><p><input size=50 type=\"text\" name=\"adminemail\" value=\"$admin->email\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
$count = count_records('user', 'deleted', 0);
|
||||
echo get_string("users").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"users\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
// total number of role assignments
|
||||
$count = count_records('role_assignments');
|
||||
echo get_string('roleassignments', 'role').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"roleassignments\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
// first find all distinct roles with mod/course:update
|
||||
// please change the name and strings to something appropriate to reflect the new data collected
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {$CFG->prefix}role_capabilities rc,
|
||||
{$CFG->prefix}role_assignments ra,
|
||||
{$CFG->prefix}user u
|
||||
WHERE (rc.capability = 'moodle/course:update' or rc.capability='moodle/site:doanything')
|
||||
AND rc.roleid = ra.roleid
|
||||
AND u.id = ra.userid";
|
||||
|
||||
$count = count_records_sql($sql);
|
||||
echo get_string("teachers").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"courseupdaters\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('forum_posts');
|
||||
echo get_string("posts", 'forum').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"posts\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('question');
|
||||
echo get_string("questions", 'quiz').": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"questions\" value=\"$count\" />\n";
|
||||
echo '<br />';
|
||||
|
||||
$count = count_records('resource');
|
||||
echo get_string("modulenameplural", "resource").": ".$count;
|
||||
echo "<input type=\"hidden\" name=\"resources\" value=\"$count\" />\n";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminname">'.get_string("administrator").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminname\" name=\"adminname\" value=\"".fullname($admin, true)."\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="adminemail">'.get_string("email").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<input size=\"50\" type=\"text\" id=\"adminemail\" name=\"adminemail\" value=\"$admin->email\" />";
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="fitem">';
|
||||
echo '<div class="fitemtitle"><label for="menumailme">'.get_string("registrationemail").'</label></div>';
|
||||
echo '<div class="felement ftext">';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right><p>".get_string("registrationemail")."</a>:</td>\n";
|
||||
echo "<td><p>\n";
|
||||
$options[0] = get_string("registrationno");
|
||||
$options[1] = get_string("registrationyes");
|
||||
choose_from_menu ($options, "mailme", "1", "", "", "");
|
||||
unset($options);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo '<div class="felement fsubmit"><input name="submitbutton" value="'.get_string('registrationsend').'" type="submit" id="id_submitbutton" /></div>';
|
||||
echo "<tr valign=top>\n";
|
||||
echo "<td align=right> </td>\n";
|
||||
echo "<td><p><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<br />\n";
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php /// $Id$
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('replace');
|
||||
|
||||
$search = optional_param('search', '', PARAM_RAW);
|
||||
$replace = optional_param('replace', '', PARAM_RAW);
|
||||
|
||||
###################################################################
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading('Search and replace text throughout the whole database');
|
||||
|
||||
|
||||
if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
|
||||
|
||||
print_simple_box_start('center');
|
||||
echo '<div align="center">';
|
||||
echo '<form action="replace.php" method="post">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo 'Search whole database for: <input type="text" name="search" /><br />';
|
||||
echo 'Replace with this string: <input type="text" name="replace" /><br />';
|
||||
echo '<input type="submit" value="Yes, do it now" /><br />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
if (!db_replace($search, $replace)) {
|
||||
error('An error has occured during this process');
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
notify('Rebuilding course cache...');
|
||||
rebuild_course_cache();
|
||||
notify('...finished');
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php // $Id$
|
||||
// index.php - scheduled backup logs
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/backup/lib.php');
|
||||
|
||||
admin_externalpage_setup('reportbackups');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
|
||||
require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
/// Scheduled backups are disabled by the server admin
|
||||
if (!empty($CFG->disablescheduledbackups)) {
|
||||
print_error('scheduledbackupsdisabled', '', '', NULL, true);
|
||||
}
|
||||
|
||||
/// Scheduled backups aren't active by the site admin
|
||||
$backup_config = backup_get_config();
|
||||
if (empty($backup_config->backup_sche_active)) {
|
||||
notify(get_string('scheduledbackupsinactive'));
|
||||
}
|
||||
|
||||
/// Get needed strings
|
||||
$backuploglaststatus = get_string("backuploglaststatus");
|
||||
$backuplogdetailed = get_string("backuplogdetailed");
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strbackup = get_string("backup");
|
||||
$strbackupdetails = get_string("backupdetails");
|
||||
$strlogs = get_string("logs");
|
||||
$strftimedatetime = get_string("strftimerecent");
|
||||
$strftimetime = get_string("strftimetime").":%S";
|
||||
$strerror = get_string("error");
|
||||
$strok = get_string("ok");
|
||||
$strunfinished = get_string("unfinished");
|
||||
$strskipped = get_string("skipped");
|
||||
$strcourse = get_string("course");
|
||||
$strtimetaken = get_string("timetaken","quiz");
|
||||
$strstatus = get_string("status");
|
||||
$strnext = get_string("next");
|
||||
|
||||
/// Decide when to show last execution logs or detailed logs
|
||||
/// Lastlog view
|
||||
if (!$courseid) {
|
||||
print_heading($backuploglaststatus);
|
||||
print_simple_box_start('center');
|
||||
/// Now, get every record from backup_courses
|
||||
$courses = get_records("backup_courses");
|
||||
|
||||
if (!$courses) {
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
//Print table header
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strcourse</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\"><font size=\"3\">$strtimetaken</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strstatus</font></td>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
|
||||
foreach ($courses as $course) {
|
||||
/// Get the course shortname
|
||||
$coursename = get_field ("course","fullname","id",$course->courseid);
|
||||
if ($coursename) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"index.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->laststarttime,$strftimedatetime)."</font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\"> - </font></td>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->lastendtime,$strftimedatetime)."</font></td>";
|
||||
if ($course->laststatus == 1) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strok."</font></td>";
|
||||
} else if ($course->laststatus == 2) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strunfinished."</font></td>";
|
||||
} else if ($course->laststatus == 3) {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strskipped."</font></td>";
|
||||
} else {
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strerror."</font></td>";
|
||||
}
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->nextstarttime,$strftimedatetime)."</font></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
/// Detailed View !!
|
||||
} else {
|
||||
print_heading($backuplogdetailed);
|
||||
|
||||
$coursename = get_field("course","fullname","id","$courseid");
|
||||
print_heading("$strcourse: $coursename");
|
||||
|
||||
print_simple_box_start('center');
|
||||
|
||||
/// First, me get all the distinct backups for that course in backup_log
|
||||
$executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid'
|
||||
ORDER BY laststarttime DESC");
|
||||
|
||||
/// Iterate over backup executions
|
||||
if (!$executions) {
|
||||
notify(get_string('nologsfound'));
|
||||
} else {
|
||||
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
||||
foreach($executions as $execution) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\">";
|
||||
print_simple_box("<center>".userdate($execution->laststarttime)."</center>", "center");
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
$logs = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid' AND
|
||||
laststarttime = '$execution->laststarttime'
|
||||
ORDER BY id");
|
||||
if ($logs) {
|
||||
foreach ($logs as $log) {
|
||||
echo "<tr>";
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($log->time,$strftimetime)."</font></td>";
|
||||
$log->info = str_replace("- ERROR!!","- <font color=\"red\">ERROR!!</font>",$log->info);
|
||||
$log->info = str_replace("- OK","- <font color=\"green\">OK</font>",$log->info);
|
||||
echo "<td nowrap=\"nowrap\"><font size=\"2\">".str_replace(" "," ",$log->info)."</font></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportcourseoverview');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM)); // needed?
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
}
|
||||
|
||||
$course = get_site();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
print_error('nostatstodisplay', "", $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n";
|
||||
echo '<div>';
|
||||
|
||||
$table->width = '*';
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
print_table($table);
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
print_heading($reportoptions[$report]);
|
||||
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
if (!empty($param->sql)) {
|
||||
$sql = $param->sql;
|
||||
} else {
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0"
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby;
|
||||
}
|
||||
error_log($sql);
|
||||
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
notify(get_string('statsnodata'));echo '</td></tr></table>';echo '<p>after notify</p>';
|
||||
|
||||
} else {
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo '<div class="graph">(' . get_string("gdneed") .')</div>';
|
||||
} else {
|
||||
echo '<div class="graph"><img alt="'.get_string('courseoverviewgraph').'" src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
|
||||
}
|
||||
|
||||
$table = new StdClass;
|
||||
$table->align = array('left','center','center','center');
|
||||
$table->head = array(get_string('course'),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
if (!empty($param->line3)) {
|
||||
$table->head[] = $param->line3;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$a = array();
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
||||
|
||||
$a[] = $c->line1;
|
||||
if (isset($c->line2)) {
|
||||
$a[] = $c->line2;
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = round($c->line3,2);
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
}
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/lib/graphlib.php');
|
||||
|
||||
$report = required_param('report', PARAM_INT);
|
||||
$time = required_param('time', PARAM_INT);
|
||||
$numcourses = required_param('numcourses', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
stats_check_uptodate();
|
||||
|
||||
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
||||
|
||||
if (!empty($param->sql)) {
|
||||
$sql = $param->sql;
|
||||
} else {
|
||||
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
||||
." WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0"
|
||||
." GROUP BY courseid "
|
||||
.$param->extras
|
||||
." ORDER BY ".$param->orderby;
|
||||
}
|
||||
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
print_error('statsnodata', "", $CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
|
||||
}
|
||||
|
||||
|
||||
$graph = new graph(750,400);
|
||||
|
||||
$graph->parameter['legend'] = 'outside-right';
|
||||
$graph->parameter['legend_size'] = 10;
|
||||
$graph->parameter['x_axis_angle'] = 90;
|
||||
$graph->parameter['title'] = false; // moodle will do a nicer job.
|
||||
$graph->y_tick_labels = null;
|
||||
$graph->offset_relation = null;
|
||||
if ($report != STATS_REPORT_ACTIVE_COURSES) {
|
||||
$graph->parameter['y_decimal_left'] = 2;
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$graph->x_data[] = get_field('course','shortname','id',$c->courseid);
|
||||
$graph->y_data['bar1'][] = $c->{$param->graphline};
|
||||
}
|
||||
$graph->y_order = array('bar1');
|
||||
$graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
|
||||
|
||||
$graph->draw_stack();
|
||||
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportlog');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
|
||||
$course = get_site();
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_mnet_log_selector_form($CFG->mnet_localhost_id, $course);
|
||||
|
||||
echo '<br />';
|
||||
print_heading(get_string('chooselivelogs') .':');
|
||||
|
||||
$heading = link_to_popup_window('/course/report/log/live.php?id='. $course->id,
|
||||
'livelog', get_string('livelogs'),
|
||||
500, 800, '', 'none', true);
|
||||
|
||||
print_heading($heading, 'center', 3);
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/question/upgrade.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportquestion');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
print_heading(get_string('adminreport', 'question'));
|
||||
|
||||
$probstr = '';
|
||||
$contextupgradeversion = 2007081000;
|
||||
if ($CFG->version < $contextupgradeversion){
|
||||
///cwrqpfs issue
|
||||
$probstr = print_heading(get_string('cwrqpfs', 'question'), '', 3, 'main', true);
|
||||
|
||||
if ($updates = question_cwqpfs_to_update()){
|
||||
|
||||
$probstr .=get_string('cwrqpfsinfo', 'question');
|
||||
$probstr .= '<ul>';
|
||||
$catlist = join(array_keys($updates), ',');
|
||||
//get info about cateogries and no of questions used outside category's course
|
||||
$categories = get_records_sql('SELECT qc.*, c.fullname as coursename FROM '.$CFG->prefix.'question_categories as qc, '
|
||||
.$CFG->prefix.'course as c WHERE qc.course = c.id AND qc.id IN ('.$catlist.')');
|
||||
foreach ($updates as $id => $publish){
|
||||
$categories[$id]->caturl = "$CFG->wwwroot/question/category.php?sesskey=".sesskey().
|
||||
"&edit=$id&courseid=".$categories[$id]->course;
|
||||
if ($categories[$id]->publish){
|
||||
$categories[$id]->changefrom = get_string('published', 'question');
|
||||
$categories[$id]->changeto = get_string('unpublished', 'question');
|
||||
} else {
|
||||
$categories[$id]->changefrom = get_string('unpublished', 'question');
|
||||
$categories[$id]->changeto = get_string('published', 'question');
|
||||
}
|
||||
$probstr .= '<li>'.get_string('changepublishstatuscat', 'question', $categories[$id]);
|
||||
if ($questions = get_records_sql('SELECT q.*, qui.id as quizid, qui.name as quizname, cm.id as cmid, '
|
||||
.'qui.course, c.fullname as coursename FROM '.$CFG->prefix.'question q, '
|
||||
.$CFG->prefix.'quiz_question_instances qqi, '
|
||||
.$CFG->prefix.'quiz qui, '
|
||||
.$CFG->prefix.'course_modules cm, '
|
||||
.$CFG->prefix.'modules m, '
|
||||
.$CFG->prefix.'course c '
|
||||
.'WHERE (q.category = '.$id.' AND qqi.question = q.id '
|
||||
.'AND qqi.quiz = qui.id '
|
||||
.'AND qui.course = c.id '
|
||||
.'AND cm.instance = qui.id '
|
||||
.'AND cm.module = m.id '
|
||||
.'AND m.name = \'quiz\''
|
||||
.'AND ('.$categories[$id]->course.' <> qui.course)) ORDER BY qui.id ASC')){
|
||||
|
||||
$probstr .= '<ul>';
|
||||
foreach ($questions as $question){
|
||||
$question->quizurl = "$CFG->wwwroot/mod/quiz/edit.php?cmid=".$question->cmid;
|
||||
$question->qurl = "$CFG->wwwroot/question/question.php?cmid={$question->cmid}&id={$question->id}&returnurl=".urlencode($FULLME);
|
||||
$probstr .= '<li>'.get_string('questionaffected', 'question', $question).'</li>';
|
||||
}
|
||||
$probstr .= '</ul>';
|
||||
}
|
||||
$probstr .= '</li>';
|
||||
}
|
||||
$probstr .= '</ul>';
|
||||
} else {
|
||||
$probstr .=('<p>'.get_string('cwrqpfsnoprob', 'question').'</p>');
|
||||
}
|
||||
}
|
||||
if ($probstr) {
|
||||
print_box($probstr);
|
||||
} else {
|
||||
print_box(get_string('noprobs', 'question'), 'boxwidthnarrow boxaligncenter generalbox');
|
||||
}
|
||||
admin_externalpage_print_footer();
|
||||
?>
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A SimpleTest report format for Moodle.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/simpletestlib/reporter.php');
|
||||
|
||||
/**
|
||||
* Extended in-browser test displayer. HtmlReporter generates
|
||||
* only failure messages and a pass count. ExHtmlReporter also
|
||||
* generates pass messages and a time-stamp.
|
||||
*
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class ExHtmlReporter extends HtmlReporter {
|
||||
|
||||
// Options set when the class is created.
|
||||
var $showpasses;
|
||||
|
||||
// Lang strings. Set in the constructor.
|
||||
var $strrunonlyfolder;
|
||||
var $strrunonlyfile;
|
||||
|
||||
var $strseparator;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bool $showpasses Whether this reporter should output anything for passes.
|
||||
*/
|
||||
function ExHtmlReporter($showpasses) {
|
||||
global $CFG, $THEME;
|
||||
|
||||
$this->HtmlReporter();
|
||||
$this->showpasses = $showpasses;
|
||||
|
||||
$this->strrunonlyfolder = $this->get_string('runonlyfolder');
|
||||
$this->strrunonlyfile = $this->get_string('runonlyfile');
|
||||
$this->strseparator = get_separator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a pass needs to be output.
|
||||
*/
|
||||
function paintPass($message) {
|
||||
//(Implicitly call grandparent, as parent not implemented.)
|
||||
parent::paintPass($message);
|
||||
if ($this->showpasses) {
|
||||
$this->_paintPassFail('pass', $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a fail needs to be output.
|
||||
*/
|
||||
function paintFail($message) {
|
||||
// Explicitly call grandparent, not parent::paintFail.
|
||||
SimpleScorer::paintFail($message);
|
||||
$this->_paintPassFail('fail', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an error (uncaught exception or PHP error) needs to be output.
|
||||
*/
|
||||
function paintError($message) {
|
||||
// Explicitly call grandparent, not parent::paintFail.
|
||||
SimpleScorer::paintError($message);
|
||||
$this->_paintPassFail('exception', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method. Used by printPass/Fail/Error.
|
||||
*/
|
||||
function _paintPassFail($passorfail, $message) {
|
||||
global $FULLME, $CFG;
|
||||
|
||||
print_simple_box_start('', '100%', '', 5, $passorfail . ' generalbox');
|
||||
$url = $this->_htmlEntities($this->_stripParameterFromUrl($FULLME, 'path'));
|
||||
echo '<b class="', $passorfail, '">', $this->get_string($passorfail), '</b>: ';
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
$file = array_shift($breadcrumb);
|
||||
$pathbits = preg_split('/\/|\\\\/', substr($file, strlen($CFG->dirroot) + 1));
|
||||
$file = array_pop($pathbits);
|
||||
$folder = '';
|
||||
foreach ($pathbits as $pathbit) {
|
||||
$folder .= $pathbit . '/';
|
||||
echo "<a href=\"{$url}path=$folder\" title=\"$this->strrunonlyfolder\">$pathbit</a>/";
|
||||
}
|
||||
echo "<a href=\"{$url}path=$folder$file\" title=\"$this->strrunonlyfile\">$file</a>";
|
||||
echo $this->strseparator, implode($this->strseparator, $breadcrumb);
|
||||
echo $this->strseparator, '<br />', $this->_htmlEntities($message), "\n\n";
|
||||
print_simple_box_end();
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a notice needs to be output.
|
||||
*/
|
||||
function paintNotice($message) {
|
||||
$this->paintMessage($this->_htmlEntities($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a simple supplementary message.
|
||||
* @param string $message Text to display.
|
||||
*/
|
||||
function paintMessage($message) {
|
||||
if ($this->showpasses) {
|
||||
print_simple_box_start('', '100%');
|
||||
echo '<span class="notice">', $this->get_string('notice'), '</span>: ';
|
||||
$breadcrumb = $this->getTestList();
|
||||
array_shift($breadcrumb);
|
||||
echo implode($this->strseparator, $breadcrumb);
|
||||
echo $this->strseparator, '<br />', $message, "\n";
|
||||
print_simple_box_end();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output anything that should appear above all the test output.
|
||||
*/
|
||||
function paintHeader($test_name) {
|
||||
// We do this the moodle way instead.
|
||||
}
|
||||
|
||||
/**
|
||||
* Output anything that should appear below all the test output, e.g. summary information.
|
||||
*/
|
||||
function paintFooter($test_name) {
|
||||
$summarydata = new stdClass;
|
||||
$summarydata->run = $this->getTestCaseProgress();
|
||||
$summarydata->total = $this->getTestCaseCount();
|
||||
$summarydata->passes = $this->getPassCount();
|
||||
$summarydata->fails = $this->getFailCount();
|
||||
$summarydata->exceptions = $this->getExceptionCount();
|
||||
|
||||
if ($summarydata->fails == 0 && $summarydata->exceptions == 0) {
|
||||
$status = "passed";
|
||||
} else {
|
||||
$status = "failed";
|
||||
}
|
||||
echo '<div class="unittestsummary ', $status, '">';
|
||||
echo $this->get_string('summary', $summarydata);
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="performanceinfo">',
|
||||
$this->get_string('runat', date('<b>d-m-Y H:i T</b>')),
|
||||
$this->get_string('version', SimpleTestOptions::getVersion()),
|
||||
'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip a specified parameter from the query string of a URL, if present.
|
||||
* Adds a separator to the end of the URL, so that a new parameter
|
||||
* can easily be appended. For example (assuming $param = 'frog'):
|
||||
*
|
||||
* http://example.com/index.php -> http://example.com/index.php?
|
||||
* http://example.com/index.php?frog=1 -> http://example.com/index.php?
|
||||
* http://example.com/index.php?toad=1 -> http://example.com/index.php?toad=1&
|
||||
* http://example.com/index.php?frog=1&toad=1 -> http://example.com/index.php?toad=1&
|
||||
*
|
||||
* @param string $url the URL to modify.
|
||||
* @param string $param the parameter to strip from the URL, if present.
|
||||
*
|
||||
* @return string The modified URL.
|
||||
*/
|
||||
function _stripParameterFromUrl($url, $param) {
|
||||
$url = preg_replace('/(\?|&)' . $param . '=[^&]*&?/', '$1', $url);
|
||||
if (strpos($url, '?') === false) {
|
||||
$url = $url . '?';
|
||||
} else {
|
||||
$url = $url . '&';
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a lang string in the appropriate file.
|
||||
*/
|
||||
function get_string($identifier, $a = NULL) {
|
||||
return get_string($identifier, 'simpletest', $a);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A SimpleTest GroupTest that automatically finds all the
|
||||
* test files in a directory tree according to certain rules.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once($CFG->libdir . '/simpletestlib/test_case.php');
|
||||
|
||||
/**
|
||||
* This is a composite test class for finding test cases and
|
||||
* other RunnableTest classes in a directory tree and combining
|
||||
* them into a group test.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class AutoGroupTest extends GroupTest {
|
||||
|
||||
var $thorough;
|
||||
var $showsearch;
|
||||
|
||||
function AutoGroupTest($showsearch, $thorough, $test_name = null) {
|
||||
$this->GroupTest($test_name);
|
||||
$this->showsearch = $showsearch;
|
||||
$this->thorough = $thorough;
|
||||
}
|
||||
|
||||
function setLabel($test_name) {
|
||||
//:HACK: there is no GroupTest::setLabel, so access parent::_label.
|
||||
$this->_label = $test_name;
|
||||
}
|
||||
|
||||
function addIgnoreFolder($ignorefolder) {
|
||||
$this->ignorefolders[]=$ignorefolder;
|
||||
}
|
||||
|
||||
function _recurseFolders($path) {
|
||||
if ($this->showsearch) {
|
||||
echo '<li>' . basename(realpath($path)) . '<ul>';
|
||||
}
|
||||
|
||||
$files = scandir($path);
|
||||
static $s_count = 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
$file_path = $path . '/' . $file;
|
||||
if (is_dir($file_path)) {
|
||||
if ($file != 'CVS' && !in_array($file_path, $this->ignorefolders)) {
|
||||
$this->_recurseFolders($file_path);
|
||||
}
|
||||
} elseif (preg_match('/simpletest(\/|\\\\)test.*\.php$/', $file_path) ||
|
||||
($this->thorough && preg_match('/simpletest(\/|\\\\)slowtest.*\.php$/', $file_path))) {
|
||||
|
||||
$s_count++;
|
||||
// OK, found: this shows as a 'Notice' for any 'simpletest/test*.php' file.
|
||||
$this->addTestCase(new FindFileNotice($file_path, 'Found unit test file, '. $s_count));
|
||||
|
||||
// addTestFile: Unfortunately this doesn't return fail/success (bool).
|
||||
$this->addTestFile($file_path, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->showsearch) {
|
||||
echo '</ul></li>';
|
||||
}
|
||||
return $s_count;
|
||||
}
|
||||
|
||||
function findTestFiles($dir) {
|
||||
if ($this->showsearch) {
|
||||
echo '<p>Searching folder: ' . realpath($dir) . '</p><ul>';
|
||||
}
|
||||
$path = $dir;
|
||||
$count = $this->_recurseFolders($path);
|
||||
if ($count <= 0) {
|
||||
$this->addTestCase(new BadAutoGroupTest($path, 'Search complete. No unit test files found'));
|
||||
} else {
|
||||
$this->addTestCase(new AutoGroupTestNotice($path, 'Search complete. Total unit test files found: '. $count));
|
||||
}
|
||||
if ($this->showsearch) {
|
||||
echo '</ul>';
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function addTestFile($file, $internalcall = false) {
|
||||
if ($this->showsearch) {
|
||||
if ($internalcall) {
|
||||
echo '<li><b>' . basename($file) . '</b></li>';
|
||||
} else {
|
||||
echo '<p>Adding test file: ' . realpath($file) . '</p>';
|
||||
}
|
||||
// Make sure that syntax errors show up suring the search, otherwise you often
|
||||
// get blank screens because evil people turn down error_reporting elsewhere.
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
if(!is_file($file) ){
|
||||
parent::addTestCase(new BadTest($file, 'Not a file or does not exist'));
|
||||
}
|
||||
parent::addTestFile($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ======================================================================= */
|
||||
// get_class_ex: Insert spaces to prettify the class-name.
|
||||
function get_class_ex($object) {
|
||||
return preg_replace('/(.?)([A-Z])/', '${1} ${2}', get_class($object));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A failing test base-class for when a test suite has NOT loaded properly.
|
||||
* See class, simple_test.php: BadGroupTest.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadTest {
|
||||
|
||||
var $label;
|
||||
var $error;
|
||||
|
||||
function BadTest($label, $error) {
|
||||
$this->label = $label;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function run(&$reporter) {
|
||||
$reporter->paintGroupStart(basename(__FILE__), $this->getSize());
|
||||
$reporter->paintFail(get_class_ex($this) .' [' . $this->getLabel() .
|
||||
'] with error [' . $this->error . ']');
|
||||
$reporter->paintGroupEnd($this->getLabel());
|
||||
return $reporter->getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the number of test cases starting.
|
||||
*/
|
||||
function getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An informational notice base-class for when a test suite is being processed.
|
||||
* See class, simple_test.php: BadGroupTest.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class Notice {
|
||||
|
||||
var $label;
|
||||
var $status;
|
||||
|
||||
function Notice($label, $error) {
|
||||
$this->label = $label;
|
||||
$this->status = $error;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
function run(&$reporter) {
|
||||
$reporter->paintGroupStart(basename(__FILE__), $this->getSize());
|
||||
$reporter->paintNotice(get_class_ex($this) .
|
||||
' ['. $this->getLabel() .'] with status [' . $this->status . ']');
|
||||
$reporter->paintGroupEnd($this->getLabel());
|
||||
return $reporter->getStatus();
|
||||
}
|
||||
|
||||
function getSize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A failing folder test for when the test-user specifies an invalid directory
|
||||
* (run.php?folder=woops).
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadFolderTest extends BadTest { }
|
||||
|
||||
/**
|
||||
* A failing auto test for when no unit test files are found.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class BadAutoGroupTest extends BadTest { }
|
||||
|
||||
/**
|
||||
* Auto group test notices - 1. Search complete. 2. A test file has been found.
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
class AutoGroupTestNotice extends Notice { }
|
||||
|
||||
class FindFileNotice extends Notice { }
|
||||
?>
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Run the unit tests.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @version $Id$
|
||||
* @package SimpleTestEx
|
||||
*/
|
||||
|
||||
/** */
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/simpletestlib.php');
|
||||
require_once('ex_simple_test.php');
|
||||
require_once('ex_reporter.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
/* The UNITTEST constant can be checked elsewhere if you need to know
|
||||
* when your code is being run as part of a unit test. */
|
||||
define('UNITTEST', true);
|
||||
$langfile = 'simpletest';
|
||||
|
||||
// CGI arguments
|
||||
$path = optional_param('path', null, PARAM_PATH);
|
||||
$showpasses = optional_param('showpasses', false, PARAM_BOOL);
|
||||
$showsearch = optional_param('showsearch', false, PARAM_BOOL);
|
||||
$thorough = optional_param('thorough', false, PARAM_BOOL);
|
||||
|
||||
// Print the header.
|
||||
admin_externalpage_setup('reportsimpletest');
|
||||
$strtitle = get_string('unittests', $langfile);
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (!is_null($path)) {
|
||||
// Create the group of tests.
|
||||
$test =& new AutoGroupTest($showsearch, $thorough);
|
||||
|
||||
// OU specific. We use the _nonproject folder for stuff we want to
|
||||
// keep in CVS, but which is not really relevant. It does no harm
|
||||
// to leave this here.
|
||||
$test->addIgnoreFolder($CFG->dirroot . '/_nonproject');
|
||||
|
||||
// Make the reporter, which is what displays the results.
|
||||
$reporter = new ExHtmlReporter($showpasses);
|
||||
|
||||
if ($showsearch) {
|
||||
print_heading('Searching for test cases');
|
||||
}
|
||||
flush();
|
||||
|
||||
// Work out what to test.
|
||||
if (substr($path, 0, 1) == '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
$path = $CFG->dirroot . '/' . $path;
|
||||
if (substr($path, -1) == '/') {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
$displaypath = substr($path, strlen($CFG->dirroot) + 1);
|
||||
$ok = true;
|
||||
if (is_file($path)) {
|
||||
$test->addTestFile($path);
|
||||
} else if (is_dir($path)){
|
||||
$test->findTestFiles($path);
|
||||
} else {
|
||||
print_simple_box(get_string('pathdoesnotexist', $langfile, $path), '', '', '', '', 'errorbox');
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
// If we have something to test, do it.
|
||||
if ($ok) {
|
||||
if ($path == $CFG->dirroot) {
|
||||
$title = get_string('moodleunittests', $langfile, get_string('all', $langfile));
|
||||
} else {
|
||||
$title = get_string('moodleunittests', $langfile, $displaypath);
|
||||
}
|
||||
print_heading($title);
|
||||
$test->run($reporter);
|
||||
}
|
||||
|
||||
$formheader = get_string('retest', $langfile);
|
||||
} else {
|
||||
$displaypath = '';
|
||||
$formheader = get_string('rununittests', $langfile);
|
||||
}
|
||||
// Print the form for adjusting options.
|
||||
print_simple_box_start('center', '70%');
|
||||
echo '<form method="get" action="index.php">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
print_heading($formheader);
|
||||
echo '<p>'; print_checkbox('showpasses', 1, $showpasses, get_string('showpasses', $langfile)); echo '</p>';
|
||||
echo '<p>'; print_checkbox('showsearch', 1, $showsearch, get_string('showsearch', $langfile)); echo '</p>';
|
||||
echo '<p>'; print_checkbox('thorough', 1, $thorough, get_string('thorough', $langfile)); echo '</p>';
|
||||
echo '<p>';
|
||||
echo '<label for="path">', get_string('onlytest', $langfile), '</label> ';
|
||||
echo '<input type="text" id="path" name="path" value="', $displaypath, '" size="40" />';
|
||||
echo '</p>';
|
||||
echo '<input type="submit" value="' . get_string('runtests', $langfile) . '" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
print_simple_box_end();
|
||||
|
||||
// Footer.
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportstats');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = 0;
|
||||
|
||||
if ($report > 50) {
|
||||
$roleid = substr($report,1);
|
||||
$report = 5;
|
||||
}
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time, '', 3);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
if (!$user = get_record('user','id',$userid)) {
|
||||
error("That's an invalid user id");
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
}
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
// $strreports = get_string("reports");
|
||||
// $strstats = get_string('stats');
|
||||
//
|
||||
// $menu = report_stats_mode_menu($course, $mode, $time); // add 4th $url parameter if uncommented!
|
||||
//
|
||||
//
|
||||
// $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
// <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
// $strstats";
|
||||
|
||||
// print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
// $crumb, '', '', true, ' ', $menu);
|
||||
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* this page defines what roles can access (grant user that role and override that roles'
|
||||
* capabilities in different context. For example, we can say that Teachers can only grant
|
||||
* student role or modify student role's capabilities. Note that you need both the right
|
||||
* capability moodle/role:assign or moodle/role:manage and this database table roles_deny_grant
|
||||
* to be able to grant roles. If a user has moodle/role:manage at site level assignment
|
||||
* then he can modify the roles_allow_assign table via this interface.
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
/// form processiong here
|
||||
|
||||
/// get all roles
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$string = explode('_', $grole);
|
||||
$temp[$string[1]][$string[2]] = 1; // if set, means can access
|
||||
}
|
||||
|
||||
// if current assignment is in data_submitted, ignore, else, write deny into db
|
||||
foreach ($roles as $srole) {
|
||||
foreach ($roles as $trole) {
|
||||
if (isset($temp[$srole->id][$trole->id])) { // if set, need to write to db
|
||||
if (!$record = get_record('role_allow_assign', 'roleid', $srole->id, 'allowassign', $trole->id)) {
|
||||
allow_assign($srole->id, $trole->id);
|
||||
}
|
||||
} else { //if set, means can access, attempt to remove it from db
|
||||
delete_records('role_allow_assign', 'roleid', $srole->id, 'allowassign', $trole->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// updated allowassigns sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
/// displaying form here
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab='allowassign';
|
||||
require_once('managetabs.php');
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align[] = 'right';
|
||||
|
||||
/// get all the roles identifier
|
||||
foreach ($roles as $role) {
|
||||
$rolesname[] = format_string($role->name);
|
||||
$roleids[] = $role->id;
|
||||
$table->align[] = 'center';
|
||||
$table->wrap[] = 'nowrap';
|
||||
}
|
||||
|
||||
$table->head = array_merge(array(''), $rolesname);
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$beta = get_box_list($role->id, $roleids);
|
||||
$table->data[] = array_merge(array(format_string($role->name)), $beta);
|
||||
}
|
||||
|
||||
print_simple_box(get_string('configallowassign', 'admin'), 'center');
|
||||
|
||||
echo '<form action="allowassign.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</div></form>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
|
||||
|
||||
function get_box_list($roleid, $arraylist){
|
||||
|
||||
foreach ($arraylist as $targetid) {
|
||||
if (get_record('role_allow_assign', 'roleid', $roleid, 'allowassign', $targetid)) {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
|
||||
} else {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
?>
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* this page defines what roles can override (override roles in different context. For example,
|
||||
* we can say that Admin can override teacher roles in a course
|
||||
* To be able to override roles. If a user has moodle/role:override at context level
|
||||
* and be in the roles_allow_override table.
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
/// form processiong here
|
||||
|
||||
/// get all roles
|
||||
|
||||
$roles = get_all_roles();
|
||||
|
||||
if ($grant = data_submitted()) {
|
||||
|
||||
foreach ($grant as $grole => $val) {
|
||||
if ($grole == 'dummy') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$string = explode('_', $grole);
|
||||
$temp[$string[1]][$string[2]] = 1; // if set, means can access
|
||||
}
|
||||
|
||||
// if current assignment is in data_submitted, ignore, else, write deny into db
|
||||
foreach ($roles as $srole) {
|
||||
foreach ($roles as $trole) {
|
||||
if (isset($temp[$srole->id][$trole->id])) { // if set, need to write to db
|
||||
if (!$record = get_record('role_allow_override', 'roleid', $srole->id, 'allowoverride', $trole->id)) {
|
||||
allow_override($srole->id, $trole->id);
|
||||
}
|
||||
} else { //if set, means can access, attempt to remove it from db
|
||||
delete_records('role_allow_override', 'roleid', $srole->id, 'allowoverride', $trole->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// updated allowoverride sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
/// displaying form here
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab='allowoverride';
|
||||
require_once('managetabs.php');
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->align[] = 'right';
|
||||
|
||||
/// get all the roles identifier
|
||||
foreach ($roles as $role) {
|
||||
$rolesname[] = format_string($role->name);
|
||||
$roleids[] = $role->id;
|
||||
$table->align[] = 'center';
|
||||
$table->wrap[] = 'nowrap';
|
||||
}
|
||||
|
||||
$table->head = array_merge(array(''), $rolesname);
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$beta = get_box_list($role->id, $roleids);
|
||||
$table->data[] = array_merge(array(format_string($role->name)), $beta);
|
||||
}
|
||||
|
||||
print_simple_box(get_string('configallowoverride2', 'admin'), 'center');
|
||||
|
||||
echo '<form action="allowoverride.php" method="post">';
|
||||
print_table($table);
|
||||
echo '<div class="buttons"><input type="submit" value="'.get_string('savechanges').'"/>';
|
||||
echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
|
||||
echo '</div></form>';
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
// returns array
|
||||
function get_box_list($roleid, $arraylist){
|
||||
|
||||
foreach ($arraylist as $targetid) {
|
||||
if (get_record('role_allow_override', 'roleid', $roleid, 'allowoverride', $targetid)) {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
|
||||
} else {
|
||||
$array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
?>
|
||||
@@ -1,112 +0,0 @@
|
||||
<form id="assignform" method="post" action="">
|
||||
<div style="text-align:center;">
|
||||
<label for="extendperiod"><?php print_string('enrolperiod') ?></label> <?php choose_from_menu($periodmenu, "extendperiod", $defaultperiod, $unlimitedperiod); ?>
|
||||
<label for="extendbase"><?php print_string('startingfrom') ?></label> <?php choose_from_menu($basemenu, "extendbase", 3, ""); ?>
|
||||
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="userid" value="<?php p($userid) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<table summary="" style="margin-left:auto;margin-right:auto" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<label for="removeselect"><?php print_string('existingusers', 'role', count($contextusers)); ?></label>
|
||||
<br />
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=false;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;">
|
||||
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($contextusers as $contextuser) {
|
||||
$fullname = fullname($contextuser, true);
|
||||
if ($contextuser->hidden) {
|
||||
$hidden=' ('.get_string('hiddenassign').') ';
|
||||
} else {
|
||||
$hidden="";
|
||||
}
|
||||
echo "<option value=\"$contextuser->id\">".$fullname.", ".$contextuser->email.$hidden."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<label title="<?php print_string('hiddenassign') ?>">
|
||||
<input type="checkbox" name="hidden" value="1" />
|
||||
<img src="<?php echo $CFG->pixpath; ?>/t/hide.gif" alt="<?php print_string('hiddenassign') ?>" class="hide-show-image" />
|
||||
<?php helpbutton('hiddenassign', get_string('hiddenassign')); ?>
|
||||
</label>
|
||||
<?php check_theme_arrows(); ?>
|
||||
<p class="arrow_button">
|
||||
<input name="add" id="add" type="submit" value="<?php echo $THEME->larrow.' '.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
|
||||
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').' '.$THEME->rarrow; ?>" title="<?php print_string('remove'); ?>" />
|
||||
</p>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<label for="addselect"><?php print_string('potentialusers', 'role', $usercount); ?></label>
|
||||
<br />
|
||||
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
|
||||
onfocus="getElementById('assignform').add.disabled=false;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$i=0;
|
||||
if (!empty($searchtext)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . $usercount . ")\">\n";
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
|
||||
} else {
|
||||
if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
|
||||
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
|
||||
} else {
|
||||
while ($user = rs_fetch_next_record($availableusers)) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($i==0) {
|
||||
echo '<option/>'; // empty select breaks xhtml strict
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<label for="searchtext" class="accesshide"><?php p($strsearch) ?></label>
|
||||
<input type="text" name="searchtext" id="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onfocus ="getElementById('assignform').add.disabled=true;
|
||||
getElementById('assignform').remove.disabled=true;
|
||||
getElementById('assignform').removeselect.selectedIndex=-1;
|
||||
getElementById('assignform').addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
getElementById('assignform').previoussearch.value=1;
|
||||
getElementById('assignform').submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchtext)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,461 +0,0 @@
|
||||
<?php // $Id$
|
||||
// Script to assign users to contexts
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // required role id
|
||||
$add = optional_param('add', 0, PARAM_BOOL);
|
||||
$remove = optional_param('remove', 0, PARAM_BOOL);
|
||||
$showall = optional_param('showall', 0, PARAM_BOOL);
|
||||
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
|
||||
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
|
||||
$hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
|
||||
$extendperiod = optional_param('extendperiod', 0, PARAM_INT);
|
||||
$extendbase = optional_param('extendbase', 0, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
|
||||
$errors = array();
|
||||
|
||||
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
|
||||
|
||||
$baseurl = 'assign.php?contextid='.$contextid;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if (!empty($courseid)) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
if (! $context = get_context_instance_by_id($contextid)) {
|
||||
error("Context ID was incorrect (can't find it)");
|
||||
}
|
||||
|
||||
$inmeta = 0;
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseid = $context->instanceid;
|
||||
if ($course = get_record('course', 'id', $courseid)) {
|
||||
$inmeta = $course->metacourse;
|
||||
} else {
|
||||
error('Invalid course id');
|
||||
}
|
||||
|
||||
} else if (!empty($courseid)){ // we need this for user tabs in user context
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Invalid course id');
|
||||
}
|
||||
|
||||
} else {
|
||||
$courseid = SITEID;
|
||||
$course = clone($SITE);
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
require_capability('moodle/role:assign', $context);
|
||||
|
||||
/// needed for tabs.php
|
||||
|
||||
$overridableroles = get_overridable_roles($context, 'name', ROLENAME_BOTH);
|
||||
$assignableroles = get_assignable_roles($context, 'name', ROLENAME_BOTH);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
$strpotentialusers = get_string('potentialusers', 'role');
|
||||
$strexistingusers = get_string('existingusers', 'role');
|
||||
$straction = get_string('assignroles', 'role');
|
||||
$strroletoassign = get_string('roletoassign', 'role');
|
||||
$strsearch = get_string('search');
|
||||
$strshowall = get_string('showall');
|
||||
$strparticipants = get_string('participants');
|
||||
$strsearchresults = get_string('searchresults');
|
||||
|
||||
$unlimitedperiod = get_string('unlimited');
|
||||
$defaultperiod = $course->enrolperiod;
|
||||
for ($i=1; $i<=365; $i++) {
|
||||
$seconds = $i * 86400;
|
||||
$periodmenu[$seconds] = get_string('numdays', '', $i);
|
||||
}
|
||||
|
||||
$timeformat = get_string('strftimedate');
|
||||
$today = time();
|
||||
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
|
||||
|
||||
// MDL-12420, preventing course start date showing up as an option at system context and front page roles.
|
||||
if ($course->startdate > 0) {
|
||||
$basemenu[0] = get_string('startdate') . ' (' . userdate($course->startdate, $timeformat) . ')';
|
||||
}
|
||||
if ($course->enrollable != 2 || ($course->enrolstartdate == 0 || $course->enrolstartdate <= $today) && ($course->enrolenddate == 0 || $course->enrolenddate > $today)) {
|
||||
$basemenu[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
|
||||
}
|
||||
if($course->enrollable == 2) {
|
||||
if($course->enrolstartdate > 0) {
|
||||
$basemenu[4] = get_string('courseenrolstartdate') . ' (' . userdate($course->enrolstartdate, $timeformat) . ')';
|
||||
}
|
||||
if($course->enrolenddate > 0) {
|
||||
$basemenu[5] = get_string('courseenrolenddate') . ' (' . userdate($course->enrolenddate, $timeformat) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
/// Make sure this user can assign that role
|
||||
|
||||
if ($roleid) {
|
||||
if (!isset($assignableroles[$roleid])) {
|
||||
error ('you can not override this role in this context');
|
||||
}
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
$user = get_record('user', 'id', $userid);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
|
||||
|
||||
/// Print the header and tabs
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
/// course header
|
||||
$navlinks = array();
|
||||
if ($courseid != SITEID) {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
|
||||
}
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$fullname", "$fullname", $navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$course->fullname: $fullname", $course->fullname, $navigation, "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
$showroles = 1;
|
||||
$currenttab = 'assign';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_setup('assignroles');
|
||||
admin_externalpage_print_header();
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'assign';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = 'assign';
|
||||
include_once('tabs.php');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Process incoming role assignment
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
|
||||
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
|
||||
|
||||
foreach ($frm->addselect as $adduser) {
|
||||
if (!$adduser = clean_param($adduser, PARAM_INT)) {
|
||||
continue;
|
||||
}
|
||||
$allow = true;
|
||||
if ($inmeta) {
|
||||
if (has_capability('moodle/course:managemetacourse', $context, $adduser)) {
|
||||
//ok
|
||||
} else {
|
||||
$managerroles = get_roles_with_capability('moodle/course:managemetacourse', CAP_ALLOW, $context);
|
||||
if (!empty($managerroles) and !array_key_exists($roleid, $managerroles)) {
|
||||
$erruser = get_record('user', 'id', $adduser, '','','','', 'id, firstname, lastname');
|
||||
$errors[] = get_string('metaassignerror', 'role', fullname($erruser));
|
||||
$allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($allow) {
|
||||
switch($extendbase) {
|
||||
case 0:
|
||||
$timestart = $course->startdate;
|
||||
break;
|
||||
case 3:
|
||||
$timestart = $today;
|
||||
break;
|
||||
case 4:
|
||||
$timestart = $course->enrolstartdate;
|
||||
break;
|
||||
case 5:
|
||||
$timestart = $course->enrolenddate;
|
||||
break;
|
||||
}
|
||||
|
||||
if($extendperiod > 0) {
|
||||
$timeend = $timestart + $extendperiod;
|
||||
} else {
|
||||
$timeend = 0;
|
||||
}
|
||||
if (! role_assign($roleid, $adduser, 0, $context->id, $timestart, $timeend, $hidden)) {
|
||||
$errors[] = "Could not add user with id $adduser to this role!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$topleveladmin = false;
|
||||
|
||||
// we only worry about this if the role has doanything capability at site level
|
||||
if ($context->id == $sitecontext->id && $adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext)) {
|
||||
foreach ($adminroles as $adminrole) {
|
||||
if ($adminrole->id == $roleid) {
|
||||
$topleveladmin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($frm->removeselect as $removeuser) {
|
||||
$removeuser = clean_param($removeuser, PARAM_INT);
|
||||
|
||||
if ($topleveladmin && ($removeuser == $USER->id)) { // Prevent unassigning oneself from being admin
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! role_unassign($roleid, $removeuser, 0, $context->id)) {
|
||||
$errors[] = "Could not remove user with id $removeuser from this role!";
|
||||
} else if ($inmeta) {
|
||||
sync_metacourse($courseid);
|
||||
$newroles = get_user_roles($context, $removeuser, false);
|
||||
if (!empty($newroles) and !array_key_exists($roleid, $newroles)) {
|
||||
$erruser = get_record('user', 'id', $removeuser, '','','','', 'id, firstname, lastname');
|
||||
$errors[] = get_string('metaunassignerror', 'role', fullname($erruser));
|
||||
$allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
} else if ($showall) {
|
||||
$searchtext = '';
|
||||
$previoussearch = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
print_heading_with_help(get_string('frontpageroles', 'admin'), 'assignroles');
|
||||
} else {
|
||||
print_heading_with_help(get_string('assignrolesin', 'role', print_context_name($context)), 'assignroles');
|
||||
}
|
||||
|
||||
if ($context->contextlevel==CONTEXT_SYSTEM) {
|
||||
print_box(get_string('globalroleswarning', 'role'));
|
||||
}
|
||||
|
||||
if ($roleid) { /// prints a form to swap roles
|
||||
|
||||
/// Get all existing participants in this context.
|
||||
// Why is this not done with get_users???
|
||||
|
||||
if (!$contextusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname, u.email, ra.hidden')) {
|
||||
$contextusers = array();
|
||||
}
|
||||
|
||||
$select = "username <> 'guest' AND deleted = 0 AND confirmed = 1";
|
||||
|
||||
$usercount = count_records_select('user', $select) - count($contextusers);
|
||||
|
||||
$searchtext = trim($searchtext);
|
||||
|
||||
if ($searchtext !== '') { // Search for a subset of remaining users
|
||||
$LIKE = sql_ilike();
|
||||
$FULLNAME = sql_fullname();
|
||||
|
||||
$selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
|
||||
$select .= $selectsql;
|
||||
} else {
|
||||
$selectsql = "";
|
||||
}
|
||||
|
||||
if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?)
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* context level is above or equal course context level *
|
||||
* in this case we pull out all users matching search criteria (if any) *
|
||||
* *
|
||||
* MDL-11324 *
|
||||
* a mini get_users_by_capability() call here, this is done instead of *
|
||||
* get_users_by_capability() because *
|
||||
* 1) get_users_by_capability() does not deal with searching by name *
|
||||
* 2) exceptions array can be potentially large for large courses *
|
||||
* 3) get_recordset_sql() is more efficient *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
if ($possibleroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context)) {
|
||||
|
||||
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$validroleids = array();
|
||||
foreach ($possibleroles as $possiblerole) {
|
||||
if (isset($doanythingroles[$possiblerole->id])) { // We don't want these included
|
||||
continue;
|
||||
}
|
||||
if ($caps = role_context_capabilities($possiblerole->id, $context, 'moodle/course:view')) { // resolved list
|
||||
if (isset($caps['moodle/course:view']) && $caps['moodle/course:view'] > 0) { // resolved capability > 0
|
||||
$validroleids[] = $possiblerole->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($validroleids) {
|
||||
$roleids = '('.implode(',', $validroleids).')';
|
||||
|
||||
$select = " SELECT u.id, u.firstname, u.lastname, u.email";
|
||||
$countselect = "SELECT COUNT(u.id)";
|
||||
$from = " FROM {$CFG->prefix}user u
|
||||
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id
|
||||
INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid";
|
||||
$where = " WHERE ra.contextid ".get_related_contexts_string($context)."
|
||||
AND u.deleted = 0
|
||||
AND ra.roleid in $roleids";
|
||||
$excsql = " AND u.id NOT IN (
|
||||
SELECT u.id
|
||||
FROM {$CFG->prefix}role_assignments r,
|
||||
{$CFG->prefix}user u
|
||||
WHERE r.contextid = $contextid
|
||||
AND u.id = r.userid
|
||||
AND r.roleid = $roleid
|
||||
$selectsql)";
|
||||
|
||||
$availableusers = get_recordset_sql($select . $from . $where . $selectsql . $excsql);
|
||||
}
|
||||
|
||||
$usercount = $availableusers->_numOfRows;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* context level is above or equal course context level *
|
||||
* in this case we pull out all users matching search criteria (if any) *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/// MDL-11111 do not include user already assigned this role in this context as available users
|
||||
/// so that the number of available users is right and we save time looping later
|
||||
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
|
||||
FROM '.$CFG->prefix.'user
|
||||
WHERE '.$select.'
|
||||
AND id NOT IN (
|
||||
SELECT u.id
|
||||
FROM '.$CFG->prefix.'role_assignments r,
|
||||
'.$CFG->prefix.'user u
|
||||
WHERE r.contextid = '.$contextid.'
|
||||
AND u.id = r.userid
|
||||
AND r.roleid = '.$roleid.'
|
||||
'.$selectsql.')
|
||||
ORDER BY lastname ASC, firstname ASC');
|
||||
|
||||
$usercount = $availableusers->_numOfRows;
|
||||
}
|
||||
|
||||
echo '<div class="selector">';
|
||||
$assignableroles = array('0'=>get_string('listallroles', 'role').'...') + $assignableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/assign.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$assignableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletoassign);
|
||||
echo '</div>';
|
||||
|
||||
print_simple_box_start('center');
|
||||
include('assign.html');
|
||||
print_simple_box_end();
|
||||
|
||||
if (!empty($errors)) {
|
||||
$msg = '<p>';
|
||||
foreach ($errors as $e) {
|
||||
$msg .= $e.'<br />';
|
||||
}
|
||||
$msg .= '</p>';
|
||||
print_simple_box_start('center');
|
||||
notify($msg);
|
||||
print_simple_box_end();
|
||||
}
|
||||
|
||||
} else { // Print overview table
|
||||
|
||||
// sync metacourse enrolments if needed
|
||||
if ($inmeta) {
|
||||
sync_metacourse($course);
|
||||
}
|
||||
|
||||
// Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
|
||||
// and so determine whether to show the extra column.
|
||||
$rolehodlercount = array();
|
||||
$rolehodlernames = array();
|
||||
$strmorethanten = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
$showroleholders = false;
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$countusers = count_role_users($roleid, $context);
|
||||
$rolehodlercount[$roleid] = $countusers;
|
||||
$roleusers = '';
|
||||
if (0 < $countusers && $countusers <= MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.lastname, u.firstname');
|
||||
if (!empty($roleusers)) {
|
||||
$strroleusers = array();
|
||||
foreach ($roleusers as $user) {
|
||||
$strroleusers[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '" >' . fullname($user) . '</a>';
|
||||
}
|
||||
$rolehodlernames[$roleid] = implode('<br />', $strroleusers);
|
||||
$showroleholders = true;
|
||||
}
|
||||
} else if ($countusers > MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$rolehodlernames[$roleid] = '<a href="'.$baseurl.'&roleid='.$roleid.'">'.$strmorethanten.'</a>';
|
||||
} else {
|
||||
$rolehodlernames[$roleid] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Print overview table
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('users'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
if ($showroleholders) {
|
||||
$table->head[] = '';
|
||||
$table->wrap[] = 'nowrap';
|
||||
$table->align[] = 'left';
|
||||
}
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$description = format_string(get_field('role', 'description', 'id', $roleid));
|
||||
$row = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>',$description, $rolehodlercount[$roleid]);
|
||||
if ($showroleholders) {
|
||||
$row[] = $rolehodlernames[$roleid];
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
@@ -1,219 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$submitlabel = get_string('addrole', 'role');
|
||||
break;
|
||||
case 'edit':
|
||||
default:
|
||||
$submitlabel = get_string('savechanges');
|
||||
}
|
||||
|
||||
if ($action == 'view') {
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form id="rolesform" action="manage.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="action" value="<?php if ($action != 'view') { echo p($action); } ?>" />
|
||||
</fieldset>
|
||||
<table class="roledesc" cellpadding="9" cellspacing="0">
|
||||
<?php if ($action == 'view') { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('name') ?>:</td>
|
||||
<td><?php p($role->name); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('shortname') ?>:</td>
|
||||
<td><?php p($role->shortname); ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('description') ?>:</td>
|
||||
<td><?php p($role->description); $usehtmleditor = false; ?></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('legacytype', 'role') ?>:</td>
|
||||
<td><?php
|
||||
$usehtmleditor = false;
|
||||
if (empty($role->legacytype)) {
|
||||
print_string('none');
|
||||
} else {
|
||||
print_string('legacy:'.$role->legacytype, 'role');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="name"><?php print_string('name') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="name" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
|
||||
if (isset($errors["name"])) formerr($errors["name"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="shortname"><?php print_string('shortname') ?></label></td>
|
||||
<td><?php
|
||||
echo '<input type="text" id="shortname" name="shortname" maxlength="100" size="15" value="'.s($role->shortname).'" />';
|
||||
if (isset($errors["shortname"])) formerr($errors["shortname"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="edit-description"><?php print_string('description') ?></label></td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
|
||||
<td><?php
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
$legacyroles = get_legacy_roles();
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
$options[$ltype] = get_string('legacy:'.$ltype, 'role');
|
||||
}
|
||||
choose_from_menu($options, 'legacytype', $role->legacytype, '');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
print_heading_with_help(get_string('permissions','role'), 'permissions');
|
||||
|
||||
$strinherit = get_string('notset','role');
|
||||
$strallow = get_string('allow','role');
|
||||
$strprevent = get_string('prevent','role');
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
?>
|
||||
|
||||
<table class="rolecap">
|
||||
|
||||
<tr>
|
||||
<th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit" scope="col"><?php p($strinherit); ?></th>
|
||||
<th class="allow" scope="col"><?php p($strallow); ?></th>
|
||||
<th class="prevent" scope="col"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
// init these 2
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
// MDL-11687
|
||||
$strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
|
||||
|
||||
// prepare legacy defaults
|
||||
if (!empty($role->legacytype)) {
|
||||
$defaultcaps = get_default_capabilities($role->legacytype);
|
||||
} else {
|
||||
$defaultcaps = false;
|
||||
}
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
//legacy caps have their own selector
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
//if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
|
||||
get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
}
|
||||
|
||||
// these 2 are used to see to group same mod/core capabilities together
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
if (empty($errors)) {
|
||||
// check the capability override for this cap, this role in this context
|
||||
$localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
|
||||
} else {
|
||||
$localoverride = new object();
|
||||
$localoverride->permission = $role->{$capability->name};
|
||||
}
|
||||
|
||||
$disabled = ($action != 'edit' and $action != 'add') ? ' disabled="disabled" ' : '';
|
||||
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
|
||||
$isinherit = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
|
||||
$isallow = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
|
||||
$isprevent = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
|
||||
$isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
|
||||
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
<td class="inherit <?php echo $isinherit ?>">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="allow <?php echo $isallow ?>">
|
||||
<input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prevent <?php echo $isprevent ?>" >
|
||||
<input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
<td class="prohibit <?php echo $isprohibit ?>" >
|
||||
<input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
|
||||
|
||||
<?php echo $riskinfo; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php if ($action != 'view') { ?>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php p($submitlabel) ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
@@ -1,575 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role
|
||||
$name = optional_param('name', '', PARAM_MULTILANG); // new role name
|
||||
$shortname = optional_param('shortname', '', PARAM_RAW); // new role shortname, special cleaning before storage
|
||||
$description = optional_param('description', '', PARAM_CLEAN); // new role desc
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
if ($cancel) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
$newrole = false;
|
||||
|
||||
$roles = get_all_roles();
|
||||
$rolescount = count($roles);
|
||||
|
||||
/// fix sort order if needed
|
||||
$rolesort = array();
|
||||
$i = 0;
|
||||
foreach ($roles as $rolex) {
|
||||
$rolesort[$i] = $rolex->id;
|
||||
if ($rolex->sortorder != $i) {
|
||||
$r = new object();
|
||||
$r->id = $rolex->id;
|
||||
$r->sortorder = $i;
|
||||
update_record('role', $r);
|
||||
$roles[$rolex->id]->sortorder = $i;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// do not delete these default system roles
|
||||
$defaultroles = array();
|
||||
$defaultroles[] = $CFG->notloggedinroleid;
|
||||
$defaultroles[] = $CFG->guestroleid;
|
||||
$defaultroles[] = $CFG->defaultuserroleid;
|
||||
$defaultroles[] = $CFG->defaultcourseroleid;
|
||||
|
||||
/// form processing, editing a role, adding a role, deleting a role etc.
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
} else if (count_records('role', 'name', $name)) {
|
||||
$errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
|
||||
if (empty($shortname)) {
|
||||
$errors['shortname'] = get_string('errorbadroleshortname', 'role');
|
||||
} else if (count_records('role', 'shortname', $shortname)) {
|
||||
$errors['shortname'] = get_string('errorexistsroleshortname', 'role');
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
$newroleid = create_role($name, $shortname, $description);
|
||||
|
||||
// set proper legacy type
|
||||
if (!empty($legacytype)) {
|
||||
assign_capability($legacyroles[$legacytype], CAP_ALLOW, $newroleid, $sitecontext->id);
|
||||
}
|
||||
|
||||
} else {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
$capabilities = fetch_context_capabilities($sitecontext); // capabilities applicable in this context
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
assign_capability($capname, $value, $newroleid, $sitecontext->id);
|
||||
} else {
|
||||
$newrole->$capname = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// added a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
if (empty($errors)) {
|
||||
$rolename = get_field('role', 'name', 'id', $newroleid);
|
||||
add_to_log(SITEID, 'role', 'add', 'admin/roles/manage.php?action=add', $rolename, '', $USER->id);
|
||||
redirect('manage.php');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
$shortname = moodle_strtolower(clean_param(clean_filename($shortname), PARAM_SAFEDIR)); // only lowercase safe ASCII characters
|
||||
$legacytype = required_param('legacytype', PARAM_RAW);
|
||||
|
||||
$legacyroles = get_legacy_roles();
|
||||
if (!array_key_exists($legacytype, $legacyroles)) {
|
||||
$legacytype = '';
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = get_string('errorbadrolename', 'role');
|
||||
} else if ($rs = get_records('role', 'name', $name)) {
|
||||
unset($rs[$roleid]);
|
||||
if (!empty($rs)) {
|
||||
$errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($shortname)) {
|
||||
$errors['shortname'] = get_string('errorbadroleshortname', 'role');
|
||||
} else if ($rs = get_records('role', 'shortname', $shortname)) {
|
||||
unset($rs[$roleid]);
|
||||
if (!empty($rs)) {
|
||||
$errors['shortname'] = get_string('errorexistsroleshortname', 'role');
|
||||
}
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
$newrole = new object();
|
||||
$newrole->name = $name;
|
||||
$newrole->shortname = $shortname;
|
||||
$newrole->description = $description;
|
||||
$newrole->legacytype = $legacytype;
|
||||
}
|
||||
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
$capabilities = fetch_context_capabilities($sitecontext); // capabilities applicable in this context
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
if (!isset($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// legacy caps have their own selector
|
||||
if (islegacy($data->{$cap->name}) === 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$newrole->$capname = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
// edit default caps
|
||||
$SQL = "SELECT * FROM {$CFG->prefix}role_capabilities
|
||||
WHERE roleid = $roleid AND capability = '$capname'
|
||||
AND contextid = $sitecontext->id";
|
||||
|
||||
$localoverride = get_record_sql($SQL);
|
||||
|
||||
if ($localoverride) { // update current overrides
|
||||
if ($value == CAP_INHERIT) { // inherit = delete
|
||||
unassign_capability($capname, $roleid, $sitecontext->id);
|
||||
|
||||
} else {
|
||||
$localoverride->permission = $value;
|
||||
$localoverride->timemodified = time();
|
||||
$localoverride->modifierid = $USER->id;
|
||||
update_record('role_capabilities', $localoverride);
|
||||
}
|
||||
} else { // insert a record
|
||||
if ($value != CAP_INHERIT) {
|
||||
assign_capability($capname, $value, $roleid, $sitecontext->id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
// update normal role settings
|
||||
$role->id = $roleid;
|
||||
$role->name = $name;
|
||||
$role->shortname = $shortname;
|
||||
$role->description = $description;
|
||||
|
||||
if (!update_record('role', $role)) {
|
||||
error('Could not update role!');
|
||||
}
|
||||
|
||||
// set proper legacy type
|
||||
foreach($legacyroles as $ltype=>$lcap) {
|
||||
if ($ltype == $legacytype) {
|
||||
assign_capability($lcap, CAP_ALLOW, $roleid, $sitecontext->id);
|
||||
} else {
|
||||
unassign_capability($lcap, $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
// edited a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
add_to_log(SITEID, 'role', 'edit', 'admin/roles/manage.php?action=edit&roleid='.$role->id, $role->name, '', $USER->id);
|
||||
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
// edited a role sitewide - with errors, but still...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (in_array($roleid, $defaultroles)) {
|
||||
error('This role is used as one of the default system roles, it can not be deleted');
|
||||
}
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
if (!delete_role($roleid)) {
|
||||
|
||||
// partially deleted a role sitewide...?
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
error('Could not delete role with ID '.$roleid);
|
||||
}
|
||||
// deleted a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
} else if (confirm_sesskey()){
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = (int)count_records('role_assignments', 'roleid', $roleid);
|
||||
notice_yesno(get_string('deleterolesure', 'role', $a), 'manage.php', 'manage.php', $optionsyes, NULL, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'moveup':
|
||||
if (array_key_exists($roleid, $roles) and confirm_sesskey()) {
|
||||
$role = $roles[$roleid];
|
||||
if ($role->sortorder > 0) {
|
||||
$above = $roles[$rolesort[$role->sortorder - 1]];
|
||||
|
||||
if (!switch_roles($role, $above)) {
|
||||
error("Cannot move role with ID $roleid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'movedown':
|
||||
if (array_key_exists($roleid, $roles) and confirm_sesskey()) {
|
||||
$role = $roles[$roleid];
|
||||
if ($role->sortorder + 1 < $rolescount) {
|
||||
$below = $roles[$rolesort[$role->sortorder + 1]];
|
||||
|
||||
if (!switch_roles($role, $below)) {
|
||||
error("Cannot move role with ID $roleid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'duplicate':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
//ok - lets duplicate!
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'duplicate', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
notice_yesno(get_string('duplicaterolesure', 'role', $a), 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// duplicate current role
|
||||
$sourcerole = get_record('role','id',$roleid);
|
||||
|
||||
$fullname = $sourcerole->name;
|
||||
$shortname = $sourcerole->shortname;
|
||||
$currentfullname = "";
|
||||
$currentshortname = "";
|
||||
$counter = 0;
|
||||
|
||||
// find a name for the duplicated role
|
||||
do {
|
||||
if ($counter) {
|
||||
$suffixfull = " ".get_string("copyasnoun")." ".$counter;
|
||||
$suffixshort = "_".$counter;
|
||||
} else {
|
||||
$suffixfull = "";
|
||||
$suffixshort = "";
|
||||
}
|
||||
$currentfullname = $fullname.$suffixfull;
|
||||
// Limit the size of shortname - database column accepts <= 100 chars
|
||||
$currentshortname = substr($shortname, 0, 100 - strlen($suffixshort)).$suffixshort;
|
||||
$coursefull = get_record("role","name",addslashes($currentfullname));
|
||||
$courseshort = get_record("role","shortname",addslashes($currentshortname));
|
||||
$counter++;
|
||||
} while ($coursefull || $courseshort);
|
||||
|
||||
$description = 'duplicate of '.$fullname;
|
||||
if ($newrole = create_role($currentfullname, $currentshortname, $description)) {
|
||||
// dupilcate all the capabilities
|
||||
role_cap_duplicate($sourcerole, $newrole);
|
||||
|
||||
// dup'ed a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
}
|
||||
$rolename = get_field('role', 'name', 'id', $newrole);
|
||||
add_to_log(SITEID, 'role', 'duplicate', 'admin/roles/manage.php?roleid='.$newrole.'&action=duplicate', $rolename, '', $USER->id);
|
||||
redirect('manage.php');
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (!array_key_exists($roleid, $roles)) {
|
||||
redirect('manage.php');
|
||||
}
|
||||
|
||||
if ($confirm and data_submitted() and confirm_sesskey()) {
|
||||
reset_role_capabilities($roleid);
|
||||
|
||||
// reset a role sitewide...
|
||||
mark_context_dirty($sitecontext->path);
|
||||
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?roleid='.$roleid.'&action=reset', $rolename, '', $USER->id);
|
||||
|
||||
redirect('manage.php?action=view&roleid='.$roleid);
|
||||
|
||||
} else {
|
||||
// show confirmation
|
||||
admin_externalpage_print_header();
|
||||
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
|
||||
$a = new object();
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->legacytype = get_legacy_type($roleid);
|
||||
if (empty($a->legacytype)) {
|
||||
$warning = get_string('resetrolesurenolegacy', 'role', $a);
|
||||
} else {
|
||||
$warning = get_string('resetrolesure', 'role', $a);
|
||||
}
|
||||
notice_yesno($warning, 'manage.php', 'manage.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/// print UI now
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
if (($roleid and ($action == 'view' or $action == 'edit')) or $action == 'add') { // view or edit role details
|
||||
|
||||
if ($action == 'add') {
|
||||
$roleid = 0;
|
||||
if (empty($errors) or empty($newrole)) {
|
||||
$role = new object();
|
||||
$role->name = '';
|
||||
$role->shortname = '';
|
||||
$role->description = '';
|
||||
$role->legacytype = '';
|
||||
} else {
|
||||
$role = stripslashes_safe($newrole);
|
||||
}
|
||||
} else if ($action == 'edit' and !empty($errors) and !empty($newrole)) {
|
||||
$role = stripslashes_safe($newrole);
|
||||
} else {
|
||||
if(!$role = get_record('role', 'id', $roleid)) {
|
||||
error('Incorrect role ID!');
|
||||
}
|
||||
$role->legacytype = get_legacy_type($role->id);
|
||||
}
|
||||
|
||||
foreach ($roles as $rolex) {
|
||||
$roleoptions[$rolex->id] = strip_tags(format_string($rolex->name));
|
||||
}
|
||||
|
||||
// this is the array holding capabilities of this role sorted till this context
|
||||
$r_caps = role_context_capabilities($roleid, $sitecontext);
|
||||
|
||||
// this is the available capabilities assignable in this context
|
||||
$capabilities = fetch_context_capabilities($sitecontext);
|
||||
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
print_heading_with_help(get_string('addrole', 'role'), 'roles');
|
||||
break;
|
||||
case 'view':
|
||||
print_heading_with_help(get_string('viewrole', 'role'), 'roles');
|
||||
break;
|
||||
case 'edit':
|
||||
print_heading_with_help(get_string('editrole', 'role'), 'roles');
|
||||
break;
|
||||
}
|
||||
|
||||
echo '<div class="selector">';
|
||||
if ($action == 'view') {
|
||||
popup_form('manage.php?action=view&roleid=', $roleoptions, 'switchrole', $roleid, '', '', '',
|
||||
false, 'self', get_string('selectrole', 'role'));
|
||||
|
||||
echo '<div class="buttons">';
|
||||
|
||||
$legacytype = get_legacy_type($roleid);
|
||||
$options = array();
|
||||
$options['roleid'] = $roleid;
|
||||
$options['action'] = 'edit';
|
||||
print_single_button('manage.php', $options, get_string('edit'));
|
||||
$options['action'] = 'reset';
|
||||
if (empty($legacytype)) {
|
||||
print_single_button('manage.php', $options, get_string('resetrolenolegacy', 'role'));
|
||||
} else {
|
||||
print_single_button('manage.php', $options, get_string('resetrole', 'role'));
|
||||
}
|
||||
$options['action'] = 'duplicate';
|
||||
print_single_button('manage.php', $options, get_string('duplicaterole', 'role'));
|
||||
print_single_button('manage.php', null, get_string('listallroles', 'role'));
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
print_simple_box_start('center');
|
||||
include_once('manage.html');
|
||||
print_simple_box_end();
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor('description');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
print_heading_with_help(get_string('roles', 'role'), 'roles');
|
||||
|
||||
$table = new object;
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->align = array('right', 'left', 'left', 'left');
|
||||
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '90%';
|
||||
$table->data = array();
|
||||
|
||||
$table->head = array(get_string('name'),
|
||||
get_string('description'),
|
||||
get_string('shortname'),
|
||||
get_string('edit'));
|
||||
|
||||
/*************************
|
||||
* List all current roles *
|
||||
**************************/
|
||||
|
||||
foreach ($roles as $role) {
|
||||
|
||||
$stredit = get_string('edit');
|
||||
$strdelete = get_string('delete');
|
||||
$strmoveup = get_string('moveup');
|
||||
$strmovedown = get_string('movedown');
|
||||
|
||||
$row = array();
|
||||
$row[0] = '<a href="manage.php?roleid='.$role->id.'&action=view">'.format_string($role->name).'</a>';
|
||||
$row[1] = format_text($role->description, FORMAT_HTML);
|
||||
$row[2] = s($role->shortname);
|
||||
$row[3] = '<a title="'.$stredit.'" href="manage.php?action=edit&roleid='.$role->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$stredit.'" /></a> ';
|
||||
if (in_array($role->id, $defaultroles)) {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
} else {
|
||||
$row[3] .= '<a title="'.$strdelete.'" href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.'" /></a> ';
|
||||
}
|
||||
if ($role->sortorder != 0) {
|
||||
$row[3] .= '<a title="'.$strmoveup.'" href="manage.php?action=moveup&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" class="iconsmall" alt="'.$strmoveup.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
}
|
||||
if ($role->sortorder+1 < $rolescount) {
|
||||
$row[3] .= '<a title="'.$strmovedown.'" href="manage.php?action=movedown&roleid='.$role->id.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" class="iconsmall" alt="'.$strmovedown.'" /></a> ';
|
||||
} else {
|
||||
$row[3] .= '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" class="iconsmall" alt="" /> ';
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
$options = new object();
|
||||
$options->action = 'add';
|
||||
echo '<div class="buttons">';
|
||||
print_single_button('manage.php', $options, get_string('addrole', 'role'), 'get');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
die;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
// this page deals with the 2 tabs for manage.php and grant.php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$toprow = array();
|
||||
|
||||
$toprow[] = new tabobject('manage', $CFG->wwwroot.'/'.$CFG->admin.'/roles/manage.php', get_string('manageroles', 'role'));
|
||||
|
||||
$toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowassign.php', get_string('allowassign', 'role'));
|
||||
|
||||
$toprow[] = new tabobject('allowoverride', $CFG->wwwroot.'/'.$CFG->admin.'/roles/allowoverride.php', get_string('allowoverride', 'role'));
|
||||
|
||||
$tabs = array($toprow);
|
||||
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
?>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
$strinherit = get_string('inherit','role');
|
||||
$strallow = get_string('allow','role');
|
||||
$strprevent = get_string('prevent','role');
|
||||
$strprohibit = get_string('prohibit','role');
|
||||
$strsafewarning = get_string('safeoverridenotice', 'role');
|
||||
?>
|
||||
|
||||
<form id="overrideform" action="override.php" method="post">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
<input type="hidden" name="userid" value="<?php p($userid) ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
|
||||
</fieldset>
|
||||
|
||||
<table class="rolecap">
|
||||
<tr>
|
||||
<th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
|
||||
<th class="inherit" scope="col"><?php p($strinherit); ?></th>
|
||||
<th class="allow" scope="col"><?php p($strallow); ?></th>
|
||||
<th class="prevent" scope="col"><?php p($strprevent); ?></th>
|
||||
<th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
|
||||
<th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// init these 2
|
||||
$contextlevel = 0;
|
||||
$component = '';
|
||||
|
||||
$strrisks = s(get_string('risks', 'role'));
|
||||
// MDL-11687
|
||||
$strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
|
||||
|
||||
foreach ($capabilities as $capability) {
|
||||
|
||||
// legacy caps should not be overriden - we must use proper capabilities if needed
|
||||
if (islegacy($capability->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// prints a breaker if component or name or context level
|
||||
//if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
|
||||
if (component_level_changed($capability, $component, $contextlevel)) {
|
||||
echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
|
||||
}
|
||||
|
||||
// these 2 are used to see to group same mod/core capabilities together
|
||||
$contextlevel = $capability->contextlevel;
|
||||
$component = $capability->component;
|
||||
|
||||
// check the capability override for this cap, this role in this context
|
||||
if (isset($localoverrides[$capability->name])) {
|
||||
$localpermission = $localoverrides[$capability->name]->permission;
|
||||
} else {
|
||||
$localpermission = 0; // Just inherit
|
||||
}
|
||||
|
||||
if (isset($r_caps[$capability->name])) {
|
||||
$isallow = $r_caps[$capability->name] > 0;
|
||||
$isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500;
|
||||
$isprohibit = $r_caps[$capability->name] <= -500;
|
||||
} else {
|
||||
$isallow = 0;
|
||||
$isprevent = 0;
|
||||
$isprohibit = 0;
|
||||
}
|
||||
|
||||
$isdisabled = $isprohibit || $capability->locked;
|
||||
|
||||
$riskinfo = '<td class="risk managetrust">';
|
||||
$rowclasses = '';
|
||||
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskmanagetrust';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk config">';
|
||||
if (RISK_CONFIG & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskconfig';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk xss">';
|
||||
if (RISK_XSS & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskxss';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk personal">';
|
||||
if (RISK_PERSONAL & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskpersonal';
|
||||
}
|
||||
$riskinfo .= '</td><td class="risk spam">';
|
||||
if (RISK_SPAM & (int)$capability->riskbitmask) {
|
||||
$riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
|
||||
$riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
|
||||
$rowclasses .= ' riskspam';
|
||||
}
|
||||
$riskinfo .= '</td>';
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr class="rolecap <?php echo $rowclasses; ?>">
|
||||
<td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
|
||||
|
||||
<td class="inherit">
|
||||
<input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="0"
|
||||
<?php
|
||||
if ($localpermission == CAP_INHERIT) {echo 'checked="checked" ';}
|
||||
if ($isdisabled) {echo 'disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="allow <?php if ($isallow) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_ALLOW.'"';
|
||||
if ($localpermission == CAP_ALLOW) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="prevent <?php if ($isprevent) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_PREVENT.'"';
|
||||
if ($localpermission == CAP_PREVENT) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
|
||||
<td class="prohibit <?php if ($isprohibit) {echo ' capcurrent';} ?>">
|
||||
<input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>"
|
||||
<?php echo ' value="'.CAP_PROHIBIT.'"';
|
||||
if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked" ';}
|
||||
if ($isdisabled) {echo ' disabled="disabled"';}?> />
|
||||
</td>
|
||||
<?php echo $riskinfo; ?>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
<div class="submit buttons">
|
||||
<input type="submit" value="<?php print_string('savechanges') ?>" />
|
||||
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($safeoverridenotice) {
|
||||
echo '<div class="sefeoverridenotice">'.$strsafewarning.'</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
@@ -1,241 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // requested role id
|
||||
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
if (!$context = get_record('context', 'id', $contextid)) {
|
||||
error('Bad context ID');
|
||||
}
|
||||
|
||||
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
|
||||
error('No site ID');
|
||||
}
|
||||
|
||||
if ($context->id == $sitecontext->id) {
|
||||
error('Can not override base role capabilities');
|
||||
}
|
||||
|
||||
$canoverride = has_capability('moodle/role:override', $context);
|
||||
|
||||
if (!$canoverride and !has_capability('moodle/role:safeoverride', $context)) {
|
||||
error('You do not have permission to change overrides in this context!');
|
||||
}
|
||||
|
||||
if ($courseid) {
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
} else {
|
||||
$course = clone($SITE);
|
||||
$courseid = SITEID;
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$baseurl = 'override.php?contextid='.$context->id;
|
||||
if (!empty($userid)) {
|
||||
$baseurl .= '&userid='.$userid;
|
||||
}
|
||||
if ($courseid != SITEID) {
|
||||
$baseurl .= '&courseid='.$courseid;
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
/// needed for tabs.php
|
||||
$overridableroles = get_overridable_roles($context, 'name', ROLENAME_BOTH);
|
||||
$assignableroles = get_assignable_roles($context, 'name', ROLENAME_BOTH);
|
||||
|
||||
/// Get some language strings
|
||||
|
||||
$strroletooverride = get_string('roletooverride', 'role');
|
||||
$straction = get_string('overrideroles', 'role');
|
||||
$strcurrentrole = get_string('currentrole', 'role');
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
/// Make sure this user can override that role
|
||||
|
||||
if ($roleid) {
|
||||
if (!isset($overridableroles[$roleid])) {
|
||||
error ('you can not override this role in this context');
|
||||
}
|
||||
}
|
||||
|
||||
if ($userid) {
|
||||
$user = get_record('user', 'id', $userid);
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
}
|
||||
|
||||
/// get all cababilities
|
||||
$safeoverridenotice = false;
|
||||
if ($roleid) {
|
||||
if ($capabilities = fetch_context_capabilities($context)) {
|
||||
// find out if we need to lock some capabilities
|
||||
foreach ($capabilities as $capname=>$capability) {
|
||||
$capabilities[$capname]->locked = false;
|
||||
if ($canoverride) {
|
||||
//ok no locking at all
|
||||
continue;
|
||||
}
|
||||
//only limited safe overrides - spam only allowed
|
||||
if ((RISK_DATALOSS & (int)$capability->riskbitmask)
|
||||
or (RISK_MANAGETRUST & (int)$capability->riskbitmask)
|
||||
or (RISK_CONFIG & (int)$capability->riskbitmask)
|
||||
or (RISK_XSS & (int)$capability->riskbitmask)
|
||||
or (RISK_PERSONAL & (int)$capability->riskbitmask)) {
|
||||
$capabilities[$capname]->locked = true;
|
||||
$safeoverridenotice = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$capabilities = null;
|
||||
}
|
||||
|
||||
/// Process incoming role override
|
||||
if ($data = data_submitted() and $roleid and confirm_sesskey()) {
|
||||
$allowed_values = array(CAP_INHERIT, CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT);
|
||||
|
||||
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
|
||||
'', 'capability, permission, id');
|
||||
|
||||
foreach ($capabilities as $cap) {
|
||||
if ($cap->locked) {
|
||||
//user not allowed to change this cap
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($data->{$cap->name})) {
|
||||
//cap not specified in form
|
||||
continue;
|
||||
}
|
||||
|
||||
if (islegacy($data->{$cap->name})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$capname = $cap->name;
|
||||
$value = clean_param($data->{$cap->name}, PARAM_INT);
|
||||
if (!in_array($value, $allowed_values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($localoverrides[$capname])) {
|
||||
// Something exists, so update it
|
||||
assign_capability($capname, $value, $roleid, $context->id, true);
|
||||
} else { // insert a record
|
||||
if ($value != CAP_INHERIT) { // Ignore inherits
|
||||
assign_capability($capname, $value, $roleid, $context->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// force accessinfo refresh for users visiting this context...
|
||||
mark_context_dirty($context->path);
|
||||
$rolename = get_field('role', 'name', 'id', $roleid);
|
||||
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
|
||||
redirect($baseurl);
|
||||
}
|
||||
|
||||
|
||||
/// Print the header and tabs
|
||||
|
||||
if ($context->contextlevel == CONTEXT_USER) {
|
||||
$navlinks = array();
|
||||
/// course header
|
||||
if ($course->id != SITEID) {
|
||||
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
|
||||
}
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$fullname", "$fullname", $navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
/// site header
|
||||
} else {
|
||||
$navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$course->fullname: $fullname", $course->fullname, $navigation, "", "", true, " ", navmenu($course));
|
||||
}
|
||||
$showroles = 1;
|
||||
$currenttab = 'override';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
}
|
||||
|
||||
print_heading_with_help(get_string('overridepermissionsin', 'role', print_context_name($context)), 'overrides');
|
||||
|
||||
if ($roleid) {
|
||||
/// prints a form to swap roles
|
||||
echo '<div class="selector">';
|
||||
$overridableroles = array('0'=>get_string('listallroles', 'role').'...') + $overridableroles;
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/roles/override.php?userid=$userid&courseid=$courseid&contextid=$contextid&roleid=",
|
||||
$overridableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletooverride);
|
||||
echo '</div>';
|
||||
|
||||
$parentcontexts = get_parent_contexts($context);
|
||||
if (!empty($parentcontexts)) {
|
||||
$parentcontext = array_shift($parentcontexts);
|
||||
$parentcontext = get_context_instance_by_id($parentcontext);
|
||||
} else {
|
||||
$parentcontext = $context; // site level in override??
|
||||
}
|
||||
|
||||
$r_caps = role_context_capabilities($roleid, $parentcontext);
|
||||
|
||||
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
|
||||
'', 'capability, permission, id');
|
||||
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
if (!empty($capabilities)) {
|
||||
// Print the capabilities overrideable in this context
|
||||
print_simple_box_start('center');
|
||||
include('override.html');
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
notice(get_string('nocapabilitiesincontext', 'role'),
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/'.$baseurl);
|
||||
}
|
||||
|
||||
} else { // Print overview table
|
||||
|
||||
$table->tablealign = 'center';
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('overrides', 'role'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
|
||||
foreach ($overridableroles as $roleid => $rolename) {
|
||||
$countusers = 0;
|
||||
$overridecount = count_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id");
|
||||
$description = format_string(get_field('role', 'description', 'id', $roleid));
|
||||
$table->data[] = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>', $description, $overridecount);
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
@@ -1,229 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Handles headers and tabs for the roles control at any level apart from SYSTEM level
|
||||
// We also assume that $currenttab, $assignableroles and $overridableroles are defined
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
$navlinks = array();
|
||||
if ($currenttab != 'update') {
|
||||
switch ($context->contextlevel) {
|
||||
|
||||
case CONTEXT_SYSTEM:
|
||||
$stradministration = get_string('administration');
|
||||
$navlinks[] = array('name' => $stradministration, 'link' => '../index.php', 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header($SITE->fullname, "$SITE->fullname", $navigation);
|
||||
break;
|
||||
|
||||
case CONTEXT_USER:
|
||||
print_header();
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSECAT:
|
||||
$category = get_record('course_categories', 'id', $context->instanceid);
|
||||
$strcategories = get_string("categories");
|
||||
$strcategory = get_string("category");
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
$navlinks[] = array('name' => $strcategories,
|
||||
'link' => "$CFG->wwwroot/course/index.php",
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $category->name,
|
||||
'link' => "$CFG->wwwroot/course/category.php?id=$category->id",
|
||||
'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses", $navigation, "", "", true);
|
||||
break;
|
||||
|
||||
case CONTEXT_COURSE:
|
||||
if ($context->instanceid != SITEID) {
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
|
||||
$course = get_record('course', 'id', $context->instanceid);
|
||||
|
||||
require_login($course);
|
||||
$navlinks[] = array('name' => get_string('roles'),
|
||||
'link' => "$CFG->wwwroot/admin/roles/assign.php?contextid=$context->id",
|
||||
'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header($streditcoursesettings, $course->fullname, $navigation);
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTEXT_GROUP:
|
||||
break;
|
||||
|
||||
case CONTEXT_MODULE:
|
||||
// get module type?
|
||||
if (!$cm = get_record('course_modules','id',$context->instanceid)) {
|
||||
error('Bad course module ID');
|
||||
}
|
||||
if (!$module = get_record('modules','id',$cm->module)) { //$module->name;
|
||||
error('Bad module ID');
|
||||
}
|
||||
if (!$course = get_record('course','id',$cm->course)) {
|
||||
error('Bad course ID');
|
||||
}
|
||||
if (!$instance = get_record($module->name, 'id', $cm->instance)) {
|
||||
error("The required instance of this module doesn't exist");
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$fullmodulename = get_string("modulename", $module->name);
|
||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
||||
$strmodulenameplural = get_string("modulenameplural", $module->name);
|
||||
|
||||
if ($module->name == "label") {
|
||||
$focuscursor = "";
|
||||
} else {
|
||||
$focuscursor = "form.name";
|
||||
}
|
||||
|
||||
$navlinks[] = array('name' => $strmodulenameplural,
|
||||
'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
|
||||
'type' => 'misc');
|
||||
|
||||
$navlinks[] = array('name' => $instance->name,
|
||||
'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id",
|
||||
'type' => 'misc');
|
||||
|
||||
$navlinks[] = array('name' => $streditinga,
|
||||
'link' => "$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey(),
|
||||
'type' => 'misc');
|
||||
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header_simple($streditinga, '', $navigation, $focuscursor, "", false);
|
||||
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK:
|
||||
if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) {
|
||||
if ($block = get_record('block', 'id', $blockinstance->blockid)) {
|
||||
$blockname = print_context_name($context);
|
||||
|
||||
|
||||
switch ($blockinstance->pagetype) {
|
||||
case 'course-view':
|
||||
if ($course = get_record('course', 'id', $blockinstance->pageid)) {
|
||||
|
||||
require_login($course);
|
||||
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $blockname", $course->fullname, $navigation);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'blog-view':
|
||||
$strblogs = get_string('blogs','blog');
|
||||
$navlinks[] = array('name' => $strblogs,
|
||||
'link' => $CFG->wwwroot.'/blog/index.php',
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $strblogs", $SITE->fullname, $navigation);
|
||||
break;
|
||||
|
||||
case 'tag-index':
|
||||
$strtags = get_string('tags');
|
||||
$navlinks[] = array('name' => $strtags,
|
||||
'link' => $CFG->wwwroot.'/tag/index.php',
|
||||
'type' => 'misc');
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $strtags", $SITE->fullname, $navigation);
|
||||
break;
|
||||
|
||||
default:
|
||||
$navlinks[] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header("$straction: $blockname", $SITE->fullname, $navigation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$toprow = array();
|
||||
$inactive = array();
|
||||
$activetwo = array();
|
||||
|
||||
|
||||
if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything except SYSTEM context
|
||||
|
||||
if ($context->contextlevel == CONTEXT_MODULE) { // Only show update button if module
|
||||
|
||||
$toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
|
||||
$context->instanceid.'&return=true&sesskey='.sesskey(), get_string('settings'));
|
||||
|
||||
}
|
||||
|
||||
if (!empty($assignableroles)) {
|
||||
$toprow[] = new tabobject('assign',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
|
||||
get_string('localroles', 'role'),
|
||||
get_string('showallroles', 'role'),
|
||||
true);
|
||||
}
|
||||
|
||||
if (!empty($overridableroles)) {
|
||||
$toprow[] = new tabobject('override',
|
||||
$CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
|
||||
get_string('overridepermissions', 'role'),
|
||||
get_string('showallroles', 'role'),
|
||||
true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Here other core tabs should go (always calling tabs.php files)
|
||||
/// All the logic to decide what to show must be self-contained in the tabs file
|
||||
/// eg:
|
||||
/// include_once($CFG->dirroot . '/grades/tabs.php');
|
||||
|
||||
/// Finally, we support adding some 'on-the-fly' tabs here
|
||||
/// All the logic to decide what to show must be self-cointained in the tabs file
|
||||
if (isset($CFG->extratabs) && !empty($CFG->extratabs)) {
|
||||
if ($extratabs = explode(',', $CFG->extratabs)) {
|
||||
asort($extratabs);
|
||||
foreach($extratabs as $extratab) {
|
||||
/// Each extra tab must be one $CFG->dirroot relative file
|
||||
if (file_exists($CFG->dirroot . '/' . $extratab)) {
|
||||
include_once($CFG->dirroot . '/' . $extratab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$inactive[] = $currenttab;
|
||||
|
||||
$tabs = array($toprow);
|
||||
|
||||
/// If there are any secondrow defined, let's introduce it
|
||||
if (isset($secondrow) && is_array($secondrow) && !empty($secondrow)) {
|
||||
$tabs[] = $secondrow;
|
||||
}
|
||||
|
||||
print_tabs($tabs, $currenttab, $inactive, $activetwo);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// searches for admin settings
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$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 = '';
|
||||
|
||||
admin_externalpage_setup('search'); // now hidden page
|
||||
|
||||
// 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($adminroot->errors)) {
|
||||
$errormsg = get_string('errorwithsettings', 'admin');
|
||||
$firsterror = reset($adminroot->errors);
|
||||
$focus = $firsterror->id;
|
||||
}
|
||||
}
|
||||
|
||||
// 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($focus);
|
||||
|
||||
if ($errormsg !== '') {
|
||||
notify ($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
notify ($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
$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 '</div>';
|
||||
echo '<fieldset>';
|
||||
echo '<div class="clearer"><!-- --></div>';
|
||||
if ($resultshtml != '') {
|
||||
echo $resultshtml;
|
||||
} else {
|
||||
echo get_string('noresults','admin');
|
||||
}
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,172 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
|
||||
|
||||
$section = required_param('section', PARAM_SAFEDIR);
|
||||
$return = optional_param('return','', PARAM_ALPHA);
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
|
||||
$adminroot =& admin_get_root(); // need all settings
|
||||
$page =& $adminroot->locate($section);
|
||||
|
||||
if (empty($page) or !is_a($page, 'admin_settingpage')) {
|
||||
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
die;
|
||||
}
|
||||
|
||||
if (!($page->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
die;
|
||||
}
|
||||
|
||||
/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
|
||||
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
$focus = '';
|
||||
|
||||
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 {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// print header stuff ------------------------------------------------------------
|
||||
|
||||
if (empty($SITE->fullname)) {
|
||||
print_header($page->visiblename, $page->visiblename, '', $focus);
|
||||
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
||||
|
||||
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 $page->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
} else {
|
||||
$pageblocks = blocks_setup($PAGE);
|
||||
|
||||
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
|
||||
BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
|
||||
BLOCK_R_MAX_WIDTH);
|
||||
|
||||
$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">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'middle':
|
||||
echo '<td id="middle-column">';
|
||||
print_container_start();
|
||||
echo '<a name="startofcontent"></a>';
|
||||
|
||||
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($page->visiblename);
|
||||
|
||||
echo $page->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'right':
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
||||
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();
|
||||
echo '</td>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo '</tr></table>';
|
||||
}
|
||||
|
||||
if (!empty($CFG->adminusehtmleditor)) {
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "appearance" category
|
||||
|
||||
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'));
|
||||
|
||||
// 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);
|
||||
|
||||
// "htmlsettings" settingpage
|
||||
$temp = new admin_settingpage('htmlsettings', get_string('htmlsettings', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('formatstringstriptags', get_string('stripalltitletags', 'admin'), get_string('configstripalltitletags', 'admin'), 1));
|
||||
$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);
|
||||
|
||||
$temp = new admin_settingpage('ajax', get_string('ajaxuse'));
|
||||
$temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('disablecourseajax', get_string('disablecourseajax', 'admin'), get_string('configdisablecourseajax', 'admin'),
|
||||
isset($CFG->disablecourseajax) ? 1 : empty($CFG->enableajax)));
|
||||
$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
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "courses" category
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/site:backup', $systemcontext)
|
||||
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_enrolment_page());
|
||||
|
||||
// "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_configcheckbox('backup_sche_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 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
|
||||
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines everything related to frontpage
|
||||
|
||||
if (get_site()) { //do not use during installation
|
||||
$frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
|
||||
|
||||
if ($hassiteconfig or has_any_capability(array(
|
||||
'moodle/course:update',
|
||||
'moodle/role:assign',
|
||||
'moodle/site:restore',
|
||||
'moodle/site:backup',
|
||||
'moodle/course:managefiles',
|
||||
'moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall'), $frontpagecontext)) {
|
||||
|
||||
// "frontpage" settingpage
|
||||
$temp = new admin_settingpage('frontpagesettings', get_string('frontpagesettings','admin'), 'moodle/course:update', false, $frontpagecontext);
|
||||
$temp->add(new admin_setting_sitesettext('fullname', get_string('fullsitename'), '', NULL)); // no default
|
||||
$temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'), '', NULL)); // no default
|
||||
$temp->add(new admin_setting_special_frontpagedesc());
|
||||
$temp->add(new admin_setting_courselist_frontpage(false)); // non-loggedin version of the setting (that's what the parameter is for :) )
|
||||
$temp->add(new admin_setting_courselist_frontpage(true)); // loggedin version of the setting
|
||||
$temp->add(new admin_setting_sitesetcheckbox('numsections', get_string('sitesection'), get_string('sitesectionhelp','admin'), 1));
|
||||
$temp->add(new admin_setting_sitesetselect('newsitems', get_string('newsitemsnumber'), '', 3,
|
||||
array('0' => '0',
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5',
|
||||
'6' => '6',
|
||||
'7' => '7',
|
||||
'8' => '8',
|
||||
'9' => '9',
|
||||
'10' => '10')));
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', get_string('coursesperpage', 'admin'), get_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('allowvisiblecoursesinhiddencategories', get_string('allowvisiblecoursesinhiddencategories', 'admin'), get_string('configvisiblecourses', 'admin'), 0));
|
||||
|
||||
// front page default role
|
||||
$roleoptions = array(0=>get_string('none')); // roles to choose from
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$roleoptions[$role->id] = strip_tags(format_string($role->name, true));
|
||||
}
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', 0, $roleoptions));
|
||||
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpageroles', get_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontext->id, 'moodle/role:assign', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', get_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/site:backup', false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', get_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/files/index.php?id='.SITEID.'&wdir=/backupdata', 'moodle/site:restore', false, $frontpagecontext));
|
||||
|
||||
$questioncapabilites = array(
|
||||
'moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall');
|
||||
$ADMIN->add('frontpage', new admin_externalpage('frontpagequestions', get_string('frontpagequestions', 'admin'), $CFG->wwwroot.'/question/edit.php?courseid='.SITEID, $questioncapabilites, false, $frontpagecontext));
|
||||
|
||||
$ADMIN->add('frontpage', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "grades" section
|
||||
|
||||
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
|
||||
|
||||
$temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage');
|
||||
if ($ADMIN->fulltree) {
|
||||
require_once $CFG->libdir.'/grade/constants.php';
|
||||
|
||||
// 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_regradingcheckbox('grade_includescalesinaggregation', get_string('includescalesinaggregation', 'grades'), get_string('configincludescalesinaggregation', 'grades'), 1));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0));
|
||||
|
||||
// enable publishing in exports/imports
|
||||
$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0));
|
||||
|
||||
$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));
|
||||
$defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
|
||||
$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');
|
||||
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('idnumbermod'),
|
||||
'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('importsettings', 'grades')));
|
||||
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
|
||||
$ADMIN->add('grades', new admin_category('gradeexports', get_string('exportsettings', 'grades')));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "appearance" category
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/site:langeditmaster', $systemcontext)
|
||||
or has_capability('moodle/site:langeditlocal', $systemcontext)) { // 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));
|
||||
|
||||
// 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', new admin_externalpage('langedit', get_string('langedit', 'admin'), "$CFG->wwwroot/$CFG->admin/lang.php", array('moodle/site:langeditmaster', 'moodle/site:langeditlocal') ));
|
||||
$ADMIN->add('language', new admin_externalpage('langimport', get_string('langpacks', 'admin'), "$CFG->wwwroot/$CFG->admin/langimport.php"));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
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));
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', get_string('iplookup', 'admin'), get_string('iplookupinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configfile('geoipfile', get_string('geoipfile', 'admin'), get_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
|
||||
$temp->add(new admin_setting_configtext('googlemapkey', get_string('googlemapkey', 'admin'), get_string('configgooglemapkey', 'admin', $CFG->wwwroot), ''));
|
||||
|
||||
$ADMIN->add('location', $temp);
|
||||
|
||||
|
||||
$ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "$CFG->wwwroot/$CFG->admin/timezoneimport.php"));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// * Miscellaneous settings
|
||||
|
||||
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));
|
||||
$item = new admin_setting_configcheckbox('enablehtmlpurifier', get_string('enablehtmlpurifier', 'admin'), get_string('configenablehtmlpurifier', 'admin'), 0);
|
||||
$item->set_updatedcallback('reset_text_filters_cache');
|
||||
$temp->add($item);
|
||||
$temp->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0));
|
||||
|
||||
$ADMIN->add('misc', $temp);
|
||||
|
||||
// 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)));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "mnet" category
|
||||
|
||||
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/$CFG->admin/mnet/index.php",
|
||||
'moodle/site:config'));
|
||||
|
||||
$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/$CFG->admin/mnet/access_control.php",
|
||||
'moodle/site:config'));
|
||||
$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/$CFG->admin/mnet/trustedhosts.php",
|
||||
'moodle/site:config'));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,146 +0,0 @@
|
||||
<?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.'/settingstree.php')) {
|
||||
include($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php');
|
||||
} else 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());
|
||||
$ADMIN->add('blocksettings', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));
|
||||
if (!empty($CFG->blocks_version) and $blocks = get_records('block')) {
|
||||
$blockbyname = array();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
$blockbyname[$blockobject->get_title()] = $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) {
|
||||
$items = array();
|
||||
$items[] = new admin_setting_managefilters();
|
||||
$items[] = new admin_setting_heading('managefilterscommonheading', get_string('commonsettings', 'admin'), '');
|
||||
$items[] = 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')));
|
||||
$items[] = 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')));
|
||||
$items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
|
||||
$items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
|
||||
$items[] = new admin_setting_configcheckbox('filterall', get_string('filterall', 'admin'), get_string('configfilterall', 'admin'), 0);
|
||||
foreach ($items as $item) {
|
||||
$item->set_updatedcallback('reset_text_filters_cache');
|
||||
$temp->add($item);
|
||||
}
|
||||
}
|
||||
$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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
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'),'1'));
|
||||
$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));
|
||||
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));
|
||||
$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));
|
||||
$temp->add(new admin_setting_configcheckbox('cookiesecure', get_string('cookiesecure', 'admin'), get_string('configcookiesecure', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('cookiehttponly', get_string('cookiehttponly', 'admin'), get_string('configcookiehttponly', '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();
|
||||
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_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
|
||||
|
||||
?>
|
||||
@@ -1,270 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "server" category
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
|
||||
// "systempaths" settingpage
|
||||
$temp = new admin_settingpage('systempaths', get_string('systempaths','admin'));
|
||||
$temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'),
|
||||
'1' => get_string('gd1'),
|
||||
'2' => get_string('gd2'))));
|
||||
$temp->add(new admin_setting_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);
|
||||
|
||||
|
||||
|
||||
// "email" settingpage
|
||||
$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_RAW));
|
||||
$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'), ''));
|
||||
$temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
|
||||
$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_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
|
||||
'01' => '01',
|
||||
'02' => '02',
|
||||
'03' => '03',
|
||||
'04' => '04',
|
||||
'05' => '05',
|
||||
'06' => '06',
|
||||
'07' => '07',
|
||||
'08' => '08',
|
||||
'09' => '09',
|
||||
'10' => '10',
|
||||
'11' => '11',
|
||||
'12' => '12',
|
||||
'13' => '13',
|
||||
'14' => '14',
|
||||
'15' => '15',
|
||||
'16' => '16',
|
||||
'17' => '17',
|
||||
'18' => '18',
|
||||
'19' => '19',
|
||||
'20' => '20',
|
||||
'21' => '21',
|
||||
'22' => '22',
|
||||
'23' => '23')));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // not needed here
|
||||
$options = array();
|
||||
$options['0'] = 'UTF-8';
|
||||
$options = array_merge($options, $charsets);
|
||||
$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));
|
||||
if (isloggedin()) {
|
||||
global $USER;
|
||||
$primaryadminemail = $USER->email;
|
||||
$primaryadminname = fullname($USER, true);
|
||||
|
||||
} else {
|
||||
// no defaults during installation - admin user must be created first
|
||||
$primaryadminemail = NULL;
|
||||
$primaryadminname = NULL;
|
||||
}
|
||||
$temp->add(new admin_setting_configtext('supportname', get_string('supportname', 'admin'), get_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('supportemail', get_string('supportemail', 'admin'), get_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('supportpage', get_string('supportpage', 'admin'), get_string('configsupportpage', 'admin'), '', PARAM_URL));
|
||||
$ADMIN->add('server', $temp, 100);
|
||||
|
||||
|
||||
|
||||
// "sessionhandling" settingpage
|
||||
$temp = new admin_settingpage('sessionhandling', get_string('sessionhandling', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('dbsessions', get_string('dbsessions', 'admin'), get_string('configdbsessions', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('sessiontimeout', get_string('sessiontimeout', 'admin'), get_string('configsessiontimeout', 'admin'), 7200, array(14400 => get_string('numhours', '', 4),
|
||||
10800 => get_string('numhours', '', 3),
|
||||
7200 => get_string('numhours', '', 2),
|
||||
5400 => get_string('numhours', '', '1.5'),
|
||||
3600 => get_string('numminutes', '', 60),
|
||||
2700 => get_string('numminutes', '', 45),
|
||||
1800 => get_string('numminutes', '', 30),
|
||||
900 => get_string('numminutes', '', 15),
|
||||
300 => get_string('numminutes', '', 5))));
|
||||
$temp->add(new admin_setting_configtext('sessioncookie', get_string('sessioncookie', 'admin'), get_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiepath', get_string('sessioncookiepath', 'admin'), get_string('configsessioncookiepath', 'admin'), '/', PARAM_LOCALURL));
|
||||
$ADMIN->add('server', $temp, 50);
|
||||
|
||||
|
||||
|
||||
// "rss" settingpage
|
||||
$temp = new admin_settingpage('rss', get_string('rss'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablerssfeeds', get_string('enablerssfeeds', 'admin'), get_string('configenablerssfeeds', 'admin'), 0));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
// "debugging" settingpage
|
||||
$temp = new admin_settingpage('debugging', get_string('debugging', 'admin'));
|
||||
$temp->add(new admin_setting_special_debug());
|
||||
$temp->add(new admin_setting_configcheckbox('debugdisplay', get_string('debugdisplay', 'admin'), get_string('configdebugdisplay', 'admin'), ini_get_bool('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_configcheckbox('perfdebug', get_string('perfdebug', 'admin'), get_string('configperfdebug', 'admin'), '7', '15', '7'));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
// "stats" settingpage
|
||||
$temp = new admin_settingpage('stats', get_string('stats'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablestats', get_string('enablestats', 'admin'), get_string('configenablestats', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configselect('statsfirstrun', get_string('statsfirstrun', 'admin'), get_string('configstatsfirstrun', 'admin'), 'none', array('none' => get_string('none'),
|
||||
60*60*24*7 => get_string('numweeks','moodle',1),
|
||||
60*60*24*14 => get_string('numweeks','moodle',2),
|
||||
60*60*24*21 => get_string('numweeks','moodle',3),
|
||||
60*60*24*28 => get_string('nummonths','moodle',1),
|
||||
60*60*24*56 => get_string('nummonths','moodle',2),
|
||||
60*60*24*84 => get_string('nummonths','moodle',3),
|
||||
60*60*24*112 => get_string('nummonths','moodle',4),
|
||||
60*60*24*140 => get_string('nummonths','moodle',5),
|
||||
60*60*24*168 => get_string('nummonths','moodle',6),
|
||||
'all' => get_string('all') )));
|
||||
$temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsmaxruntime', 'admin'), get_string('configstatsmaxruntime3', 'admin'), 0, array(0 => get_string('untilcomplete'),
|
||||
60*30 => '10 '.get_string('minutes'),
|
||||
60*30 => '30 '.get_string('minutes'),
|
||||
60*60 => '1 '.get_string('hour'),
|
||||
60*60*2 => '2 '.get_string('hours'),
|
||||
60*60*3 => '3 '.get_string('hours'),
|
||||
60*60*4 => '4 '.get_string('hours'),
|
||||
60*60*5 => '5 '.get_string('hours'),
|
||||
60*60*6 => '6 '.get_string('hours'),
|
||||
60*60*7 => '7 '.get_string('hours'),
|
||||
60*60*8 => '8 '.get_string('hours') )));
|
||||
$temp->add(new admin_setting_configtext('statsruntimedays', get_string('statsruntimedays', 'admin'), get_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', get_string('statsruntimestart', 'admin'), get_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0)));
|
||||
$temp->add(new admin_setting_configtext('statsuserthreshold', get_string('statsuserthreshold', 'admin'), get_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
|
||||
|
||||
$options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6);
|
||||
$temp->add(new admin_setting_configselect('statscatdepth', get_string('statscatdepth', 'admin'), get_string('configstatscatdepth', 'admin'), 1, $options));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
// "http" settingpage
|
||||
$temp = new admin_settingpage('http', get_string('http', 'admin'));
|
||||
$temp->add(new admin_setting_configtext('framename', get_string('framename', 'admin'), get_string('configframename', 'admin'), '_top', PARAM_ALPHAEXT));
|
||||
$temp->add(new admin_setting_configcheckbox('slasharguments', get_string('slasharguments', 'admin'), get_string('configslasharguments', 'admin'), 1));
|
||||
$temp->add(new admin_setting_heading('reverseproxy', get_string('reverseproxy', 'admin'), '', ''));
|
||||
$options = array(
|
||||
0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', get_string('getremoteaddrconf', 'admin'), get_string('configgetremoteaddrconf', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_heading('webproxy', get_string('webproxy', 'admin'), get_string('webproxyinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('proxyhost', get_string('proxyhost', 'admin'), get_string('configproxyhost', 'admin'), '', PARAM_HOST));
|
||||
$temp->add(new admin_setting_configtext('proxyport', get_string('proxyport', 'admin'), get_string('configproxyport', 'admin'), 0, PARAM_INT));
|
||||
$options = array('HTTP'=>'HTTP');
|
||||
if (defined('CURLPROXY_SOCKS5')) {
|
||||
$options['SOCKS5'] = 'SOCKS5';
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('proxytype', get_string('proxytype', 'admin'), get_string('configproxytype','admin'), 'HTTP', $options));
|
||||
$temp->add(new admin_setting_configtext('proxyuser', get_string('proxyuser', 'admin'), get_string('configproxyuser', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configpasswordunmask('proxypassword', get_string('proxypassword', 'admin'), get_string('configproxypassword', 'admin'), ''));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('maintenancemode', get_string('sitemaintenancemode', 'admin'), "$CFG->wwwroot/$CFG->admin/maintenance.php"));
|
||||
|
||||
|
||||
$temp = new admin_settingpage('cleanup', get_string('cleanup', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('longtimenosee', get_string('longtimenosee', 'admin'), get_string('configlongtimenosee', 'admin'), 120, array(0 => get_string('never'),
|
||||
1000 => get_string('numdays', '', 1000),
|
||||
365 => get_string('numdays', '', 365),
|
||||
180 => get_string('numdays', '', 180),
|
||||
150 => get_string('numdays', '', 150),
|
||||
120 => get_string('numdays', '', 120),
|
||||
90 => get_string('numdays', '', 90),
|
||||
60 => get_string('numdays', '', 60),
|
||||
30 => get_string('numdays', '', 30),
|
||||
21 => get_string('numdays', '', 21),
|
||||
14 => get_string('numdays', '', 14),
|
||||
7 => get_string('numdays', '', 7) )));
|
||||
$temp->add(new admin_setting_configselect('deleteunconfirmed', get_string('deleteunconfirmed', 'admin'), get_string('configdeleteunconfirmed', 'admin'), 168, array(0 => get_string('never'),
|
||||
168 => get_string('numdays', '', 7),
|
||||
144 => get_string('numdays', '', 6),
|
||||
120 => get_string('numdays', '', 5),
|
||||
96 => get_string('numdays', '', 4),
|
||||
72 => get_string('numdays', '', 3),
|
||||
48 => get_string('numdays', '', 2),
|
||||
24 => get_string('numdays', '', 1),
|
||||
12 => get_string('numhours', '', 12),
|
||||
6 => get_string('numhours', '', 6),
|
||||
1 => get_string('numhours', '', 1))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('deleteincompleteusers', get_string('deleteincompleteusers', 'admin'), get_string('configdeleteincompleteusers', 'admin'), 0, array(0 => get_string('never'),
|
||||
168 => get_string('numdays', '', 7),
|
||||
144 => get_string('numdays', '', 6),
|
||||
120 => get_string('numdays', '', 5),
|
||||
96 => get_string('numdays', '', 4),
|
||||
72 => get_string('numdays', '', 3),
|
||||
48 => get_string('numdays', '', 2),
|
||||
24 => get_string('numdays', '', 1))));
|
||||
|
||||
$temp->add(new admin_setting_configselect('loglifetime', get_string('loglifetime', 'admin'), get_string('configloglifetime', 'admin'), 0, array(0 => get_string('neverdeletelogs'),
|
||||
1000 => get_string('numdays', '', 1000),
|
||||
365 => get_string('numdays', '', 365),
|
||||
180 => get_string('numdays', '', 180),
|
||||
150 => get_string('numdays', '', 150),
|
||||
120 => get_string('numdays', '', 120),
|
||||
90 => get_string('numdays', '', 90),
|
||||
60 => get_string('numdays', '', 60),
|
||||
35 => get_string('numdays', '', 35))));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('disablegradehistory', get_string('disablegradehistory', 'grades'),
|
||||
get_string('configdisablegradehistory', 'grades'), 0, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_configselect('gradehistorylifetime', get_string('gradehistorylifetime', 'grades'),
|
||||
get_string('configgradehistorylifetime', 'grades'), 0, array(0 => get_string('neverdeletehistory', 'grades'),
|
||||
1000 => get_string('numdays', '', 1000),
|
||||
365 => get_string('numdays', '', 365),
|
||||
180 => get_string('numdays', '', 180),
|
||||
150 => get_string('numdays', '', 150),
|
||||
120 => get_string('numdays', '', 120),
|
||||
90 => get_string('numdays', '', 90),
|
||||
60 => get_string('numdays', '', 60),
|
||||
30 => get_string('numdays', '', 30))));
|
||||
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('environment', get_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
|
||||
$ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
|
||||
|
||||
|
||||
// "performance" settingpage
|
||||
$temp = new admin_settingpage('performance', get_string('performance', 'admin'));
|
||||
$temp->add(new admin_setting_special_selectsetup('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_special_selectsetup('rcache', get_string('rcache', 'admin'),
|
||||
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('intcachemax', get_string('intcachemax', 'admin'),
|
||||
get_string('configintcachemax', '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'),
|
||||
'1' => get_string('yes'))));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/mysql/frame.php")) {
|
||||
$ADMIN->add('server', new admin_externalpage('database', get_string('managedatabase'), "$CFG->wwwroot/$CFG->admin/mysql/frame.php"));
|
||||
}
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This is the first file read by the lib/adminlib.php script
|
||||
// We use it to create the categories in correct order,
|
||||
// since they need to exist *before* settingpages and externalpages
|
||||
// are added to them.
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
if (get_site()) {
|
||||
$hassiteconfig = has_capability('moodle/site:config', $systemcontext);
|
||||
} else {
|
||||
// installation starts - no permission checks
|
||||
$hassiteconfig = true;
|
||||
}
|
||||
|
||||
$ADMIN->add('root', new admin_externalpage('adminnotifications', get_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
|
||||
|
||||
// hidden upgrade script
|
||||
$ADMIN->add('root', new admin_externalpage('upgradesettings', get_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.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('location', get_string('location','admin')));
|
||||
$ADMIN->add('root', new admin_category('language', get_string('language')));
|
||||
|
||||
$ADMIN->add('root', new admin_category('modules', get_string('plugins', 'admin')));
|
||||
|
||||
$ADMIN->add('root', new admin_category('security', get_string('security','admin')));
|
||||
$ADMIN->add('root', new admin_category('appearance', get_string('appearance','admin')));
|
||||
$ADMIN->add('root', new admin_category('frontpage', get_string('frontpage','admin')));
|
||||
$ADMIN->add('root', new admin_category('server', get_string('server','admin')));
|
||||
$ADMIN->add('root', new admin_category('mnet', get_string('net','mnet')));
|
||||
|
||||
$ADMIN->add('root', new admin_category('reports', get_string('reports')));
|
||||
foreach (get_list_of_plugins($CFG->admin.'/report') as $plugin) {
|
||||
/// This snippet is temporary until simpletest can be fixed to use xmldb. See MDL-7377 XXX TODO
|
||||
if ($plugin == 'simpletest' && $CFG->dbfamily != 'mysql' && $CFG->dbfamily != 'postgres') {
|
||||
continue;
|
||||
}
|
||||
/// End of removable snippet
|
||||
$reportname = get_string($plugin, 'report_' . $plugin);
|
||||
if ($reportname[1] == '[') {
|
||||
$reportname = get_string($plugin, 'admin');
|
||||
}
|
||||
// ugly hack for special access control in reports
|
||||
switch($plugin) {
|
||||
case 'backups': $cap = 'moodle/site:backup'; break;
|
||||
case 'simpletest': $cap = 'moodle/site:config'; break;
|
||||
default: $cap = 'moodle/site:viewreports';
|
||||
}
|
||||
$ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php",$cap));
|
||||
}
|
||||
|
||||
$ADMIN->add('root', new admin_category('misc', get_string('miscellaneous')));
|
||||
|
||||
// hidden unsupported category
|
||||
$ADMIN->add('root', new admin_category('unsupported', get_string('unsupported', 'admin'), true));
|
||||
|
||||
// hidden search script
|
||||
$ADMIN->add('root', new admin_externalpage('search', get_string('searchresults'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:config', true));
|
||||
|
||||
?>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages in the "unsupported" hidden category, use wisely!
|
||||
|
||||
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', 'moodle/site:config', true));
|
||||
$ADMIN->add('unsupported', new admin_externalpage('healthcenter', get_string('healthcenter'), $CFG->wwwroot.'/'.$CFG->admin.'/health.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('unsupported', new admin_externalpage('toinodb', 'Convert to InnoDB', $CFG->wwwroot.'/'.$CFG->admin.'/innodb.php', 'moodle/site:config', true));
|
||||
$ADMIN->add('unsupported', new admin_externalpage('replace', 'Search and replace', $CFG->wwwroot.'/'.$CFG->admin.'/replace.php', 'moodle/site:config', true));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// This file defines settingpages and externalpages under the "users" category
|
||||
|
||||
if ($hassiteconfig
|
||||
or has_capability('moodle/site:uploadusers', $systemcontext)
|
||||
or has_capability('moodle/user:create', $systemcontext)
|
||||
or has_capability('moodle/user:update', $systemcontext)
|
||||
or has_capability('moodle/user:delete', $systemcontext)
|
||||
or has_capability('moodle/role:manage', $systemcontext)
|
||||
or has_capability('moodle/role:assign', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
|
||||
$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));
|
||||
$temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1));
|
||||
|
||||
$temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', '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('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.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", 'moodle/role:manage'));
|
||||
$ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
|
||||
|
||||
|
||||
// "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);
|
||||
}
|
||||
}
|
||||
if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
|
||||
$guestroles = array();
|
||||
}
|
||||
// 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();
|
||||
$nonguestroles = array();
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$rolename = strip_tags(format_string($role->name, true));
|
||||
$allroles[$role->id] = $rolename;
|
||||
if (!isset($guestroles[$role->id])) {
|
||||
$nonguestroles[$role->id] = $rolename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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, $nonguestroles)); // guest role here breaks a lot of stuff
|
||||
}
|
||||
|
||||
$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_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'))));
|
||||
}
|
||||
|
||||
$ADMIN->add('roles', $temp);
|
||||
|
||||
} // end of speedup
|
||||
|
||||
?>
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<form method="post" action="site.php" name="form" <?php echo $onsubmit ?>>
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size=50 value="<?php p($form->fullname) ?>">
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size=50 value="<?php p($form->shortname) ?>">
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpagedescription") ?>:</P><br />
|
||||
<font size=1>
|
||||
<?PHP
|
||||
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
|
||||
echo "<br />";
|
||||
if ($usehtmleditor) {
|
||||
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
|
||||
} else {
|
||||
helpbutton("html", get_string("helphtml"), "moodle", true, true);
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
</font>
|
||||
</td>
|
||||
<td><?php print_textarea($usehtmleditor, 20, 50, 600, 400, "summary", $form->summary); ?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("frontpageformat") ?>:</td>
|
||||
<td><?php
|
||||
$options = array("0" => get_string("frontpagenews"),
|
||||
"1" => get_string("frontpagecourselist"),
|
||||
"2" => get_string("frontpagecategorynames"));
|
||||
if (count_records("course") > 200) {
|
||||
unset($options[1]);
|
||||
if ($form->frontpage == 1) {
|
||||
$form->frontpage = 2;
|
||||
}
|
||||
}
|
||||
choose_from_menu ($options, "frontpage", "$form->frontpage", "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("newsitemsnumber") ?>:</td>
|
||||
<td><?php
|
||||
$newsitem = get_string("newsitem");
|
||||
$newsitems = get_string("newsitems");
|
||||
$options = array("0" => "0 $newsitems",
|
||||
"1" => "1 $newsitem",
|
||||
"2" => "2 $newsitems",
|
||||
"3" => "3 $newsitems",
|
||||
"4" => "4 $newsitems",
|
||||
"5" => "5 $newsitems",
|
||||
"6" => "6 $newsitems",
|
||||
"7" => "7 $newsitems",
|
||||
"8" => "8 $newsitems",
|
||||
"9" => "9 $newsitems",
|
||||
"10" => "10 $newsitems");
|
||||
choose_from_menu ($options, "newsitems", "$form->newsitems", "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size=25 value="<?php p($form->teacher) ?>">
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<?php if (isset($err["teacher"])) formerr($err["teacher"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size=25 value="<?php p($form->teachers) ?>">
|
||||
(<?php print_string("wordforteacherseg") ?>)
|
||||
<?php if (isset($err["teachers"])) formerr($err["teachers"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size=25 value="<?php p($form->student) ?>">
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<?php if (isset($err["student"])) formerr($err["student"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size=25 value="<?php p($form->students) ?>">
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<?php if (isset($err["students"])) formerr($err["students"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="<?php p($form->id) ?>">
|
||||
<input type="hidden" name="category" value="<?php p($form->category) ?>">
|
||||
<input type="hidden" name="format" value="<?php p($form->format) ?>">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if ($usehtmleditor) {
|
||||
print_richedit_javascript("form", "summary", "no");
|
||||
}
|
||||
?>
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
if ($site = get_site()) {
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
$site->format = "social"; // override
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
validate_form($form, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
|
||||
set_config("frontpage", $form->frontpage);
|
||||
|
||||
$form->timemodified = time();
|
||||
|
||||
if ($form->id) {
|
||||
if (update_record("course", $form)) {
|
||||
redirect("$CFG->wwwroot/", get_string("changessaved"));
|
||||
} else {
|
||||
error("Serious Error! Could not update the site record! (id = $form->id)");
|
||||
}
|
||||
} else {
|
||||
if ($newid = insert_record("course", $form)) {
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if (insert_record("course_categories", $cat)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
|
||||
} else {
|
||||
error("Serious Error! Could not set up a default course category!");
|
||||
}
|
||||
} else {
|
||||
error("Serious Error! Could not set up the site!");
|
||||
}
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
if ($site and empty($form)) {
|
||||
$form = $site;
|
||||
$course = $site;
|
||||
$firsttime = false;
|
||||
} else {
|
||||
$form->fullname = "";
|
||||
$form->shortname = "";
|
||||
$form->summary = "";
|
||||
$form->newsitems = 3;
|
||||
$form->id = "";
|
||||
$form->category = 0;
|
||||
$form->format = "social";
|
||||
$form->teacher = get_string("defaultcourseteacher");
|
||||
$form->teachers = get_string("defaultcourseteachers");
|
||||
$form->student = get_string("defaultcoursestudent");
|
||||
$form->students = get_string("defaultcoursestudents");
|
||||
$firsttime = true;
|
||||
}
|
||||
|
||||
if (isset($CFG->frontpage)) {
|
||||
$form->frontpage = $CFG->frontpage;
|
||||
|
||||
} else {
|
||||
if ($form->newsitems > 0) {
|
||||
$form->frontpage = 0;
|
||||
} else {
|
||||
$form->frontpage = 1;
|
||||
}
|
||||
set_config("frontpage", $form->frontpage);
|
||||
}
|
||||
|
||||
if (empty($focus)) {
|
||||
$focus = "form.fullname";
|
||||
}
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strsitesettings = get_string("sitesettings");
|
||||
|
||||
if ($firsttime) {
|
||||
print_header();
|
||||
print_heading($strsitesettings);
|
||||
print_simple_box(get_string("configintrosite"), "center", "50%");
|
||||
echo "<br />";
|
||||
} else {
|
||||
print_header("$site->shortname: $strsitesettings", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $strsitesettings", "$focus");
|
||||
print_heading($strsitesettings);
|
||||
}
|
||||
|
||||
$defaultformat = FORMAT_HTML;
|
||||
if ($usehtmleditor = can_use_richtext_editor()) {
|
||||
$onsubmit = "onsubmit=\"copyrichtext(form.summary);\"";
|
||||
} else {
|
||||
$onsubmit = "";
|
||||
}
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("site.html");
|
||||
print_simple_box_end();
|
||||
|
||||
if (!$firsttime) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
||||
function validate_form(&$form, &$err) {
|
||||
|
||||
if (empty($form->fullname))
|
||||
$err["fullname"] = get_string("missingsitename");
|
||||
|
||||
if (empty($form->shortname))
|
||||
$err["shortname"] = get_string("missingshortsitename");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/my/pagelib.php');
|
||||
require_once($CFG->dirroot.'/lib/pagelib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
|
||||
$pt = optional_param('pt', null, PARAM_SAFEDIR); //alhanumeric and -
|
||||
|
||||
$pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE,
|
||||
'lib' => '/my/pagelib.php',
|
||||
'name' => get_string('mymoodle','admin')),
|
||||
PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW,
|
||||
'lib' => '/lib/pagelib.php',
|
||||
'name' => get_string('stickyblockscourseview','admin'))
|
||||
// ... more?
|
||||
);
|
||||
|
||||
// for choose_from_menu
|
||||
$options = array();
|
||||
foreach ($pagetypes as $p) {
|
||||
$options[$p['id']] = $p['name'];
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// first thing to do is print the dropdown menu
|
||||
|
||||
$strtitle = get_string('stickyblocks','admin');
|
||||
$strheading = get_string('adminhelpstickyblocks');
|
||||
|
||||
|
||||
|
||||
if (!empty($pt)) {
|
||||
|
||||
require_once($CFG->dirroot.$pagetypes[$pt]['lib']);
|
||||
|
||||
define('ADMIN_STICKYBLOCKS',$pt);
|
||||
|
||||
$PAGE = page_create_object($pt, SITEID);
|
||||
$blocks = blocks_setup($PAGE,BLOCKS_PINNED_TRUE);
|
||||
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
|
||||
|
||||
$navlinks = array(array('name' => get_string('administration'),
|
||||
'link' => "$CFG->wwwroot/$CFG->admin/index.php",
|
||||
'type' => 'misc'));
|
||||
$navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
print_header($strtitle,$strtitle,$navigation);
|
||||
|
||||
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
|
||||
echo '<tr valign="top">';
|
||||
|
||||
echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
echo '<td valign="top" id="middle-column">';
|
||||
print_container_start();
|
||||
|
||||
} else {
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('stickyblocks');
|
||||
admin_externalpage_print_header();
|
||||
}
|
||||
|
||||
|
||||
print_box_start();
|
||||
print_heading($strheading);
|
||||
popup_form("$CFG->wwwroot/$CFG->admin/stickyblocks.php?pt=", $options, 'selecttype', $pt, 'choose', '', '', false, 'self', get_string('stickyblockspagetype','admin').': ');
|
||||
echo '<p>'.get_string('stickyblocksduplicatenotice','admin').'</p>';
|
||||
print_box_end();
|
||||
|
||||
|
||||
if (!empty($pt)) {
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
echo '<td valign="top" style="width: '.$blocks_preferred_width.'px;" id="right-column">';
|
||||
print_container_start();
|
||||
blocks_print_group($PAGE, $blocks, BLOCK_POS_RIGHT);
|
||||
print_container_end();
|
||||
echo '</td>';
|
||||
echo '</tr></table>';
|
||||
print_footer();
|
||||
} else {
|
||||
admin_externalpage_print_footer();
|
||||
}
|
||||
|
||||
?>
|
||||
+28
-13
@@ -1,23 +1,23 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
$zone = optional_param('zone', '', PARAM_PATH); //not a path, but it looks like it anyway
|
||||
include("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
if (!isadmin()) {
|
||||
error("You must be an admin");
|
||||
}
|
||||
|
||||
$strtimezone = get_string("timezone");
|
||||
$strsavechanges = get_string("savechanges");
|
||||
$strusers = get_string("users");
|
||||
$strall = get_string("all");
|
||||
|
||||
print_header($strtimezone, $strtimezone, build_navigation(array(array('name' => $strtimezone, 'link' => null, 'type' => 'misc'))));
|
||||
print_header($strtimezone, $strtimezone, $strtimezone);
|
||||
|
||||
print_heading("");
|
||||
|
||||
if (!empty($zone) and confirm_sesskey()) {
|
||||
if (isset($zone)) {
|
||||
$db->debug = true;
|
||||
echo "<center>";
|
||||
execute_sql("UPDATE {$CFG->prefix}user SET timezone = '$zone'");
|
||||
@@ -27,15 +27,30 @@
|
||||
$USER->timezone = $zone;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
$timezones = get_list_of_timezones();
|
||||
$user = $USER;
|
||||
|
||||
echo '<center><form action="timezone.php" method="get">';
|
||||
if (abs($user->timezone) > 13) {
|
||||
$user->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<center><form action=timezone.php method=get>";
|
||||
echo "$strusers ($strall): ";
|
||||
choose_from_menu ($timezones, "zone", 99, get_string("serverlocaltime"), "", "99");
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
|
||||
echo "<input type=\"submit\" value=\"$strsavechanges\" />";
|
||||
echo "</form></center>";
|
||||
choose_from_menu ($timezones, "zone", $user->timezone, get_string("serverlocaltime"), "", "99");
|
||||
echo "<input type=submit value=\"$strsavechanges\">";
|
||||
echo "</form>";
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// Automatic update of Timezones from a new source
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/olson.php');
|
||||
|
||||
admin_externalpage_setup('timezoneimport');
|
||||
|
||||
$ok = optional_param('ok', 0, PARAM_BOOL);
|
||||
|
||||
|
||||
/// Print headings
|
||||
|
||||
$strimporttimezones = get_string('importtimezones', 'admin');
|
||||
|
||||
admin_externalpage_print_header();
|
||||
|
||||
print_heading($strimporttimezones);
|
||||
|
||||
if (!$ok or !confirm_sesskey()) {
|
||||
$message = '<br /><br />';
|
||||
$message .= $CFG->dataroot.'/temp/olson.txt<br />';
|
||||
$message .= $CFG->dataroot.'/temp/timezone.txt<br />';
|
||||
$message .= '<a href="http://download.moodle.org/timezone/">http://download.moodle.org/timezone/</a><br />';
|
||||
$message .= '<a href="'.$CFG->wwwroot.'/lib/timezone.txt">'.$CFG->dirroot.'/lib/timezone.txt</a><br />';
|
||||
$message .= '<br />';
|
||||
|
||||
$message = get_string("configintrotimezones", 'admin', $message);
|
||||
|
||||
notice_yesno($message, 'timezoneimport.php?ok=1&sesskey='.sesskey(), 'index.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/// Try to find a source of timezones to import from
|
||||
|
||||
$importdone = false;
|
||||
|
||||
/// First, look for an Olson file locally
|
||||
|
||||
$source = $CFG->dataroot.'/temp/olson.txt';
|
||||
if (!$importdone and is_readable($source)) {
|
||||
if ($timezones = olson_to_timezones($source)) {
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
/// Next, look for a CSV file locally
|
||||
|
||||
$source = $CFG->dataroot.'/temp/timezone.txt';
|
||||
if (!$importdone and is_readable($source)) {
|
||||
if ($timezones = get_records_csv($source, 'timezone')) {
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise, let's try moodle.org's copy
|
||||
$source = 'http://download.moodle.org/timezone/';
|
||||
if (!$importdone && ($content=download_file_content($source))) {
|
||||
if ($file = fopen($CFG->dataroot.'/temp/timezone.txt', 'w')) { // Make local copy
|
||||
fwrite($file, $content);
|
||||
fclose($file);
|
||||
if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezone.txt', 'timezone')) { // Parse it
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
unlink($CFG->dataroot.'/temp/timezone.txt');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Final resort, use the copy included in Moodle
|
||||
$source = $CFG->dirroot.'/lib/timezone.txt';
|
||||
if (!$importdone and is_readable($source)) { // Distribution file
|
||||
if ($timezones = get_records_csv($source, 'timezone')) {
|
||||
update_timezone_records($timezones);
|
||||
$importdone = $source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// That's it!
|
||||
|
||||
if ($importdone) {
|
||||
$a = null;
|
||||
$a->count = count($timezones);
|
||||
$a->source = $importdone;
|
||||
print_heading(get_string('importtimezonescount', 'admin', $a), '', 3);
|
||||
|
||||
print_continue('index.php');
|
||||
|
||||
$timezonelist = array();
|
||||
foreach ($timezones as $timezone) {
|
||||
if (is_array($timezone)) {
|
||||
$timezone = (object)$timezone;
|
||||
}
|
||||
if (isset($timezonelist[$timezone->name])) {
|
||||
$timezonelist[$timezone->name]++;
|
||||
} else {
|
||||
$timezonelist[$timezone->name] = 1;
|
||||
}
|
||||
}
|
||||
ksort($timezonelist);
|
||||
|
||||
echo "<br />";
|
||||
print_simple_box_start('center');
|
||||
foreach ($timezonelist as $name => $count) {
|
||||
echo "$name ($count)<br />";
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
} else {
|
||||
print_heading(get_string('importtimezonesfailed', 'admin'), '', 3);
|
||||
print_continue('index.php');
|
||||
}
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user