Compare commits
201 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ede85e1f | |||
| 8ad8b7dba8 | |||
| 36f0835e72 | |||
| 259b9d05f3 | |||
| da20cd7b43 | |||
| acb4688d29 | |||
| 471952fe82 | |||
| 0d738689bd | |||
| 7390fdde63 | |||
| 1374c61bb4 | |||
| 98d9209a34 | |||
| 8351ce1bd0 | |||
| b911ab236c | |||
| b4730465e6 | |||
| 78cc7bee62 | |||
| 5d6eafcf10 | |||
| 090e19328e | |||
| 34b5e856b0 | |||
| c44a5d5946 | |||
| b7d7679112 | |||
| 64a17788aa | |||
| 0baa1eee59 | |||
| 9f6eeb4abf | |||
| 6a48b42ae8 | |||
| 2dd90f136c | |||
| e6647397b9 | |||
| 07fa10d725 | |||
| 98032d512d | |||
| 389235fb00 | |||
| 656237dd55 | |||
| e3cc5b1a7f | |||
| 0742ea86b2 | |||
| 41f79b5c07 | |||
| ed85c0acd2 | |||
| 9c39028179 | |||
| 9fb4a6300b | |||
| 44c9dc6e7b | |||
| 4af7c9d188 | |||
| 847dee60ce | |||
| e0be8fd6a3 | |||
| 55e03d1233 | |||
| e391f907af | |||
| bef867a96c | |||
| 4207d47742 | |||
| bd7193c7ac | |||
| 77e4a16c4f | |||
| 7daba2713e | |||
| 03b1be3005 | |||
| 5c8511ecf7 | |||
| 52435228c5 | |||
| c9dc3e5564 | |||
| ffaf18a8c1 | |||
| f5fddc6081 | |||
| 9d5a4e2b7c | |||
| ba9103b2c6 | |||
| 79196c9ed5 | |||
| a572cfe5bd | |||
| 92d7776478 | |||
| 2715f96932 | |||
| 6919d9f790 | |||
| 8be0517692 | |||
| a4b65c11b9 | |||
| 64e711f04b | |||
| e6cf40de78 | |||
| 174f5a0189 | |||
| dd56fd7c64 | |||
| 436f83f8ff | |||
| d03f904759 | |||
| 15a6af91f5 | |||
| 0a23dec07a | |||
| 6f8081bef4 | |||
| c643d3ae06 | |||
| 507ccf1c4b | |||
| 60bc533ee8 | |||
| 42f2b8d0dd | |||
| 84047d1fc9 | |||
| b79ac7e0d6 | |||
| 241ceba38c | |||
| 8e49e0833c | |||
| f6bf9c932d | |||
| 1fb2369b09 | |||
| 4de0925820 | |||
| 81f2a1686a | |||
| 5f509554a5 | |||
| edd5d0693d | |||
| d59a75a841 | |||
| 9b482d1cbe | |||
| ca090f3262 | |||
| 12db898084 | |||
| c79345c0f0 | |||
| d691571218 | |||
| 4e1bb6e10c | |||
| a7e920fbfb | |||
| 7a725d6b59 | |||
| 489c6ef357 | |||
| dbb6157aa1 | |||
| 50467e50c9 | |||
| 85a91fb98e | |||
| 75454e2567 | |||
| 06c09f30e3 | |||
| 26daa23d9d | |||
| 74a2ee73ed | |||
| fca41d2589 | |||
| 6de6a45a10 | |||
| 0f1fac1f1f | |||
| 692134ecd4 | |||
| d7706bac2c | |||
| 391e054c03 | |||
| 71f2316fe6 | |||
| 16d610019a | |||
| 4f5791da64 | |||
| c5e3a242b1 | |||
| 13ad1eaf37 | |||
| 7ca448fa83 | |||
| 37efb4f1ee | |||
| 81bd2292bc | |||
| 8fa13d155d | |||
| 465846f082 | |||
| f68815ffcf | |||
| 67b5d74b2c | |||
| 3d0e3ade75 | |||
| 7d1fb2f6ec | |||
| 227e54d65a | |||
| ee6181b1e7 | |||
| 3962c89bbf | |||
| 59137c2c5b | |||
| b83e494d6f | |||
| 3b2164bdca | |||
| aa54d70440 | |||
| d2d4bccec1 | |||
| f3a3c59f48 | |||
| 3d62a46b26 | |||
| 9aacfedb22 | |||
| 12b734434b | |||
| f9068e531c | |||
| 96506c474a | |||
| 0d66e33da5 | |||
| 934fa3ed6c | |||
| 6743d6c520 | |||
| cf76e10e4a | |||
| c800e31213 | |||
| 23580ddacb | |||
| 827fcdb347 | |||
| 60aaf1dc77 | |||
| fd8fa6f9d0 | |||
| 8adf19eda8 | |||
| a6e29ac6a3 | |||
| 52e184904f | |||
| b8d80c062e | |||
| eb9d692f8b | |||
| a805d653d1 | |||
| fe4a0cfe63 | |||
| d0e3447e43 | |||
| f046221272 | |||
| 42a50a0a45 | |||
| 77335e76e9 | |||
| ddf3e875f3 | |||
| 91fa7abf3d | |||
| b060e5b0b8 | |||
| f9c8746704 | |||
| c629aeabe3 | |||
| 27614a5e5d | |||
| ba32fc0042 | |||
| 87b05ba3e0 | |||
| 728f3c9d08 | |||
| d7dd177eb4 | |||
| 507de745e3 | |||
| bf8ff4889b | |||
| f9112bda35 | |||
| ba63612bfa | |||
| 408612d111 | |||
| 60e837038a | |||
| 4cb05cea9d | |||
| 09c1e72a56 | |||
| d2455301b7 | |||
| 1be2b904ab | |||
| 337817e669 | |||
| b17a3a5591 | |||
| c44c552efa | |||
| faa297ce6f | |||
| b6225c0f2f | |||
| 50496af78b | |||
| 8fc52ccf46 | |||
| 9f9324f408 | |||
| d4dc367a5b | |||
| 3ede344b5c | |||
| 5c686792c6 | |||
| 91a4b3bd3e | |||
| 1a6a1487f4 | |||
| a5286ae4cc | |||
| 5b97bff526 | |||
| 1c4873ba1b | |||
| 9a8f8cea49 | |||
| c37f03543b | |||
| cd4ca97611 | |||
| 77bfc4ce0f | |||
| 13c53a4a2e | |||
| d3796a2c61 | |||
| 7bb8ae5911 | |||
| dbe6d9f821 | |||
| 4927443761 |
@@ -25,8 +25,3 @@ CVS
|
||||
/.project
|
||||
/.buildpath
|
||||
/.cache
|
||||
phpunit.xml
|
||||
# Composer support - only composer.json is to be in git, the rest is installed in each checkout.
|
||||
composer.phar
|
||||
composer.lock
|
||||
/vendor/
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ a few minutes:
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
its tables in (or choose an existing database).
|
||||
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
|
||||
|
||||
+3
-3
@@ -12,14 +12,14 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
|
||||
|
||||
$PAGE->set_url($returnurl);
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$auth = optional_param('auth', '', PARAM_PLUGIN);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
||||
|
||||
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
||||
if (empty($CFG->auth)) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
require_once '../config.php';
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
|
||||
$auth = required_param('auth', PARAM_PLUGIN);
|
||||
$auth = required_param('auth', PARAM_SAFEDIR);
|
||||
$PAGE->set_pagetype('admin-auth-' . $auth);
|
||||
|
||||
admin_externalpage_setup('authsetting'.$auth);
|
||||
|
||||
+35
-70
@@ -12,8 +12,6 @@
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$unprotect = optional_param('unprotect', 0, PARAM_INT);
|
||||
$protect = optional_param('protect', 0, PARAM_INT);
|
||||
|
||||
/// Print headings
|
||||
|
||||
@@ -26,9 +24,6 @@
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strshowblockcourse = get_string('showblockcourse');
|
||||
$strprotecthdr = get_string('blockprotect', 'admin'). $OUTPUT->help_icon('blockprotect','admin');
|
||||
$strprotect = get_string('blockprotect', 'admin');
|
||||
$strunprotect = get_string('blockunprotect', 'admin');
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
@@ -48,36 +43,6 @@
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
|
||||
$undeletableblocktypes = array('navigation', 'settings');
|
||||
} else if (is_string($CFG->undeletableblocktypes)) {
|
||||
$undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
|
||||
} else {
|
||||
$undeletableblocktypes = $CFG->undeletableblocktypes;
|
||||
}
|
||||
|
||||
if (!empty($protect) && confirm_sesskey()) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$protect))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
if (!in_array($block->name, $undeletableblocktypes)) {
|
||||
$undeletableblocktypes[] = $block->name;
|
||||
set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
|
||||
}
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($unprotect) && confirm_sesskey()) {
|
||||
if (!$block = $DB->get_record('block', array('id'=>$unprotect))) {
|
||||
print_error('blockdoesnotexist', 'error');
|
||||
}
|
||||
if (in_array($block->name, $undeletableblocktypes)) {
|
||||
$undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
|
||||
set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
|
||||
}
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strmanageblocks);
|
||||
@@ -98,9 +63,34 @@
|
||||
exit;
|
||||
|
||||
} else {
|
||||
uninstall_plugin('block', $block->name);
|
||||
// Inform block it's about to be deleted
|
||||
if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
|
||||
$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 = $DB->get_records('block_instances', array('blockname' => $block->name));
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete block
|
||||
$DB->delete_records('block', array('id'=>$block->id));
|
||||
|
||||
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);
|
||||
|
||||
// Delete the capabilities that were defined by this block
|
||||
capabilities_cleanup('block/'.$block->name);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('block/'.$block->name);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->block = $strblockname;
|
||||
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
|
||||
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
|
||||
@@ -124,32 +114,18 @@
|
||||
|
||||
$table = new flexible_table('admin-blocks-compatible');
|
||||
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
// Sort blocks using current locale.
|
||||
$blocknames = array();
|
||||
foreach ($blocks as $blockid=>$block) {
|
||||
$blockname = $block->name;
|
||||
if (file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blocknames[$blockid] = get_string('pluginname', 'block_'.$blockname);
|
||||
} else {
|
||||
$blocknames[$blockid] = $blockname;
|
||||
}
|
||||
}
|
||||
collatorlib::asort($blocknames);
|
||||
|
||||
foreach ($blocknames as $blockid=>$strblockname) {
|
||||
$block = $blocks[$blockid];
|
||||
$blockname = $block->name;
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$strblockname = '<span class="notifyproblem">'.$blockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $block->version;
|
||||
|
||||
@@ -164,6 +140,7 @@
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
$strblockname = get_string('pluginname', 'block_'.$blockname);
|
||||
}
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||
@@ -201,10 +178,10 @@
|
||||
$visible = '';
|
||||
} else if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.sesskey().'" title="'.$strhide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/hide') . '" class="iconsmall" alt="'.$strhide.'" /></a>';
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon" alt="'.$strhide.'" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.sesskey().'" title="'.$strshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon" alt="'.$strshow.'" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
|
||||
@@ -214,27 +191,15 @@
|
||||
$version = "$block->version ($plugin->version)";
|
||||
}
|
||||
|
||||
if (!$blockobject) {
|
||||
// ignore
|
||||
$undeletable = '';
|
||||
} else if (in_array($blockname, $undeletableblocktypes)) {
|
||||
$undeletable = '<a href="blocks.php?unprotect='.$blockid.'&sesskey='.sesskey().'" title="'.$strunprotect.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="iconsmall" alt="'.$strunprotect.'" /></a>';
|
||||
} else {
|
||||
$undeletable = '<a href="blocks.php?protect='.$blockid.'&sesskey='.sesskey().'" title="'.$strprotect.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/lock') . '" class="iconsmall" alt="'.$strprotect.'" /></a>';
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$table->add_data(array(
|
||||
'<span'.$class.'>'.$strblockname.'</span>',
|
||||
$blocklist,
|
||||
'<span'.$class.'>'.$version.'</span>',
|
||||
$visible,
|
||||
$undeletable,
|
||||
$delete,
|
||||
$settings
|
||||
);
|
||||
$table->add_data($row);
|
||||
));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/// Create "blog" forums in each course and copy blog entries from these courses' participants in these forums
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/blog/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('bloglevelupgrade');
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
|
||||
$go = optional_param('go', 0, PARAM_BOOL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('bloglevelupgrade', 'admin'));
|
||||
|
||||
$strbloglevelupgrade = get_string('bloglevelupgradeinfo', 'admin');
|
||||
|
||||
if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
$optionsyes = array('go'=>1, 'sesskey'=>sesskey());
|
||||
echo $OUTPUT->confirm($strbloglevelupgrade, new moodle_url('bloglevelupgrade.php', $optionsyes), 'index.php');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$i = 0;
|
||||
|
||||
// If $CFG->bloglevel is set to BLOG_GROUP_LEVEL or BLOG_COURSE_LEVEL, create a new "blog" forum in each course
|
||||
// whose enrolled students have written blog entries, copy these entries in that forum and switch off blogs at site level
|
||||
|
||||
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
|
||||
$pbar = new progress_bar('bloglevelupgrade', 500, true);
|
||||
|
||||
$bloggers = $DB->get_records_sql("SELECT userid FROM {post} WHERE module = 'blog' GROUP BY userid");
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
$a = new stdClass();
|
||||
$a->userscount = 0;
|
||||
$a->blogcount = 0;
|
||||
|
||||
foreach ($bloggers as $blogger) {
|
||||
$courses = enrol_get_users_courses($blogger->userid, true, 'groupmode,groupmodeforce');
|
||||
$blogentries = $DB->get_records('post', array('module' => 'blog', 'userid' => $blogger->userid));
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$forum = forum_get_course_forum($course->id, 'blog');
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
if ($CFG->bloglevel == BLOG_GROUP_LEVEL && $course->groupmode != NOGROUPS) {
|
||||
// Unless the course is set to separate groups forced, force the forum to Separate groups
|
||||
if (!($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce)) {
|
||||
$cm->groupmode = SEPARATEGROUPS;
|
||||
$DB->update_record('course_modules', $cm);
|
||||
}
|
||||
|
||||
$groups = groups_get_user_groups($course->id, $blogger->userid);
|
||||
foreach ($groups[0] as $groupid) { // [0] is for all groupings combined
|
||||
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid);
|
||||
}
|
||||
} else {
|
||||
$a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm);
|
||||
}
|
||||
}
|
||||
|
||||
$a->userscount = $i . '/' . count($bloggers);
|
||||
$pbar->update($i, count($bloggers), get_string('bloglevelupgradeprogress', 'admin', $a));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
|
||||
$count = 0;
|
||||
|
||||
$forumcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
foreach ($blogentries as $blogentry) {
|
||||
$discussion = new stdClass();
|
||||
$discussion->course = $forum->course;
|
||||
$discussion->forum = $forum->id;
|
||||
$discussion->name = $blogentry->subject;
|
||||
$discussion->assessed = $forum->assessed;
|
||||
$discussion->message = $blogentry->summary;
|
||||
$discussion->messageformat = $blogentry->summaryformat;
|
||||
$discussion->messagetrust = 0;
|
||||
$discussion->attachments = 0;
|
||||
$discussion->mailnow = false;
|
||||
$discussion->timemodified = $blogentry->created;
|
||||
$discussion->itemid = null;
|
||||
$discussion->groupid = $groupid;
|
||||
$message = '';
|
||||
|
||||
$discussionid = forum_add_discussion($discussion, null, $message);
|
||||
|
||||
// Copy file attachment records
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($sitecontext->id, 'blog', 'attachment', $blogentry->id);
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $storedfile) {
|
||||
$newfile = new stdClass();
|
||||
$newfile->component = 'mod_forum';
|
||||
$newfile->filearea = 'attachment';
|
||||
$newfile->itemid = $discussion->firstpost;
|
||||
$newfile->contextid = $forumcontext->id;
|
||||
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
|
||||
}
|
||||
}
|
||||
|
||||
$files = $fs->get_area_files($sitecontext->id, 'blog', 'post', $blogentry->id);
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $storedfile) {
|
||||
$newfile = new stdClass();
|
||||
$newfile->component = 'mod_forum';
|
||||
$newfile->filearea = 'post';
|
||||
$newfile->itemid = $discussion->firstpost;
|
||||
$newfile->contextid = $forumcontext->id;
|
||||
$fs->create_file_from_storedfile($newfile, $storedfile->get_id());
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
// END OF LOOP
|
||||
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('bloglevel_upgrade_complete', 1);
|
||||
// Finally switch bloglevel to 0 (disabled)
|
||||
set_config('bloglevel', 0);
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
@@ -1,160 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file is used to display a categories sub categories, external pages, and settings.
|
||||
*
|
||||
* @since 2.3
|
||||
* @package admin
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$category = required_param('category', PARAM_SAFEDIR);
|
||||
$return = optional_param('return','', PARAM_ALPHA);
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
/// no guest autologin
|
||||
require_login(0, false);
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/admin/category.php', array('category' => $category));
|
||||
$PAGE->set_pagetype('admin-setting-' . $category);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->navigation->clear_cache();
|
||||
|
||||
$adminroot = admin_get_root(); // need all settings
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
|
||||
if (empty($settingspage) or !($settingspage instanceof admin_category)) {
|
||||
print_error('categoryerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
|
||||
if (!($settingspage->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
}
|
||||
|
||||
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
|
||||
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);
|
||||
}
|
||||
$adminroot = admin_get_root(true); //reload tree
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
}
|
||||
|
||||
if ($PAGE->user_allowed_editing() && $adminediting != -1) {
|
||||
$USER->editing = $adminediting;
|
||||
}
|
||||
|
||||
if ($PAGE->user_allowed_editing()) {
|
||||
$url = clone($PAGE->url);
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$caption = get_string('blockseditoff');
|
||||
$url->param('adminedit', 'off');
|
||||
} else {
|
||||
$caption = get_string('blocksediton');
|
||||
$url->param('adminedit', 'on');
|
||||
}
|
||||
$buttons = $OUTPUT->single_button($url, $caption, 'get');
|
||||
}
|
||||
|
||||
$savebutton = false;
|
||||
$outputhtml = '';
|
||||
foreach ($settingspage->children as $childpage) {
|
||||
if ($childpage->is_hidden()) {
|
||||
continue;
|
||||
}
|
||||
if ($childpage instanceof admin_externalpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link($childpage->url, $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_settingpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/settings.php', array('section' => $childpage->name)), $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_category) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/category.php', array('category' => $childpage->name)), get_string('admincategory', 'admin', $childpage->visiblename)), 3);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
}
|
||||
if ($savebutton) {
|
||||
$outputhtml .= html_writer::start_tag('div', array('class' => 'form-buttons'));
|
||||
$outputhtml .= html_writer::empty_tag('input', array('class' => 'form-submit', 'type' => 'submit', 'value' => get_string('savechanges','admin')));
|
||||
$outputhtml .= html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
$visiblepathtosection = array_reverse($settingspage->visiblepath);
|
||||
$PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection));
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_button($buttons);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($errormsg !== '') {
|
||||
echo $OUTPUT->notification($errormsg);
|
||||
} else if ($statusmsg !== '') {
|
||||
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
$path = array_reverse($settingspage->visiblepath);
|
||||
if (is_array($path)) {
|
||||
$visiblename = join(' / ', $path);
|
||||
} else {
|
||||
$visiblename = $path;
|
||||
}
|
||||
echo $OUTPUT->heading(get_string('admincategory', 'admin', $visiblename), 2);
|
||||
|
||||
echo html_writer::start_tag('form', array('action' => '', 'method' => 'post', 'id' => 'adminsettings'));
|
||||
echo html_writer::start_tag('div');
|
||||
echo html_writer::input_hidden_params(new moodle_url($PAGE->url, array('sesskey' => sesskey(), 'return' => $return)));
|
||||
echo html_writer::end_tag('div');
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
echo $outputhtml;
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
+49
-73
@@ -20,6 +20,7 @@
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - environment check is not present yet
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
@@ -78,16 +79,6 @@ Example:
|
||||
"; //TODO: localize, mark as needed in install - to be translated later when everything is finished
|
||||
|
||||
|
||||
// distro specific customisation
|
||||
$distrolibfile = dirname(dirname(dirname(__FILE__))).'/install/distrolib.php';
|
||||
$distro = null;
|
||||
if (file_exists($distrolibfile)) {
|
||||
require_once($distrolibfile);
|
||||
if (function_exists('distro_get_config')) {
|
||||
$distro = distro_get_config();
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing to do if config.php exists
|
||||
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
|
||||
if (file_exists($configfile)) {
|
||||
@@ -100,16 +91,12 @@ if (file_exists($configfile)) {
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
if ($DB->get_manager()->table_exists('config')) {
|
||||
cli_error(get_string('clialreadyinstalled', 'install'));
|
||||
} else {
|
||||
cli_error(get_string('clialreadyconfigured', 'install'));
|
||||
}
|
||||
cli_error(get_string('clialreadyinstalled', 'install'));
|
||||
}
|
||||
|
||||
$olddir = getcwd();
|
||||
|
||||
// change directory so that includes below work properly
|
||||
// change directory so that includes bellow work properly
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
|
||||
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
|
||||
@@ -127,16 +114,13 @@ if (function_exists('date_default_timezone_set') and function_exists('date_defau
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Disables caching.. just in case.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
if (version_compare(phpversion(), "5.2.8") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n";
|
||||
echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
|
||||
die;
|
||||
}
|
||||
|
||||
// set up configuration
|
||||
@@ -146,6 +130,7 @@ $CFG->dirroot = dirname(dirname(dirname(__FILE__)));
|
||||
$CFG->libdir = "$CFG->dirroot/lib";
|
||||
$CFG->wwwroot = "http://localhost";
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
@@ -167,7 +152,6 @@ require_once($CFG->libdir.'/moodlelib.php');
|
||||
require_once($CFG->libdir.'/deprecatedlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
require_once($CFG->dirroot.'/cache/lib.php');
|
||||
|
||||
require($CFG->dirroot.'/version.php');
|
||||
$CFG->target_release = $release;
|
||||
@@ -194,14 +178,14 @@ if (empty($databases)) {
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'chmod' => isset($distro->directorypermissions) ? sprintf('%04o',$distro->directorypermissions) : '2777', // let distros set dir permissions
|
||||
'chmod' => '2777',
|
||||
'lang' => $CFG->lang,
|
||||
'wwwroot' => '',
|
||||
'dataroot' => empty($distro->dataroot) ? str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'): $distro->dataroot, // initialised later after including libs or by distro
|
||||
'dbtype' => empty($distro->dbtype) ? $defaultdb : $distro->dbtype, // let distro skip dbtype selection
|
||||
'dbhost' => empty($distro->dbhost) ? 'localhost' : $distro->dbhost, // let distros set dbhost
|
||||
'dataroot' => $CFG->dataroot,
|
||||
'dbtype' => $defaultdb,
|
||||
'dbhost' => 'localhost',
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
|
||||
'dbuser' => 'root',
|
||||
'dbpass' => '',
|
||||
'dbsocket' => false,
|
||||
'prefix' => 'mdl_',
|
||||
@@ -244,8 +228,18 @@ echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$languages = get_string_manager()->get_list_of_translations();
|
||||
// Do not put the langs into columns because it is not compatible with RTL.
|
||||
$langlist = implode("\n", $languages);
|
||||
// format the langs nicely - 3 per line
|
||||
$c = 0;
|
||||
$langlist = '';
|
||||
foreach ($languages as $key=>$lang) {
|
||||
$c++;
|
||||
$length = iconv_strlen($lang, 'UTF-8');
|
||||
$padded = $lang.str_repeat(' ', 38-$length);
|
||||
$langlist .= $padded;
|
||||
if ($c % 3 == 0) {
|
||||
$langlist .= "\n";
|
||||
}
|
||||
}
|
||||
$default = $CFG->lang;
|
||||
cli_heading(get_string('availablelangs', 'install'));
|
||||
echo $langlist."\n";
|
||||
@@ -271,7 +265,7 @@ if ($interactive) {
|
||||
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('datarootpermission', 'install'));
|
||||
cli_heading('Data directories permission'); // todo localize
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
|
||||
$error = '';
|
||||
do {
|
||||
@@ -331,7 +325,9 @@ $CFG->httpswwwroot = $CFG->wwwroot;
|
||||
|
||||
|
||||
//We need dataroot before lang download
|
||||
$CFG->dataroot = $options['dataroot'];
|
||||
if (!empty($options['dataroot'])) {
|
||||
$CFG->dataroot = $options['dataroot'];
|
||||
}
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
$i=0;
|
||||
@@ -379,19 +375,26 @@ if ($interactive) {
|
||||
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
|
||||
}
|
||||
}
|
||||
$CFG->tempdir = $CFG->dataroot.'/temp';
|
||||
$CFG->cachedir = $CFG->dataroot.'/cache';
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
$installer = new lang_installer($CFG->lang);
|
||||
$results = $installer->run();
|
||||
foreach ($results as $langcode => $langstatus) {
|
||||
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
|
||||
$a = new stdClass();
|
||||
$a->url = $installer->lang_pack_url($langcode);
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string('remotedownloaderror', 'error', $a));
|
||||
//download lang pack with optional notification
|
||||
if ($CFG->lang != 'en') {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
|
||||
if ($cd->install() == COMPONENT_ERROR) {
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/2.0/'.$CFG->lang.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
cli_problem(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
} else {
|
||||
// install parent lang if defined
|
||||
if ($parentlang = get_parent_language()) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,8 +422,7 @@ if (isset($maturity)) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cli_problem(get_string('maturitycorewarning', 'admin', $maturitylevel));
|
||||
cli_error(get_string('maturityallowunstable', 'admin'));
|
||||
cli_error(get_string('maturitycorewarning', 'admin'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,9 +525,6 @@ if ($interactive) {
|
||||
}
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']), $distro);
|
||||
}
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
@@ -655,29 +654,6 @@ require($configfile);
|
||||
$CFG->lang = $installlang;
|
||||
$SESSION->lang = $CFG->lang;
|
||||
|
||||
require("$CFG->dirroot/version.php");
|
||||
|
||||
// Test environment first.
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
install_cli_database($options, $interactive);
|
||||
|
||||
echo get_string('cliinstallfinished', 'install')."\n";
|
||||
|
||||
@@ -46,8 +46,6 @@ Options:
|
||||
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
|
||||
--adminpass=PASSWORD Password for the moodle admin account.
|
||||
--agree-license Indicates agreement with software license.
|
||||
--fullname=STRING Name of the site
|
||||
--shortname=STRING Name of the site
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
@@ -55,12 +53,12 @@ Example:
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
if (version_compare(phpversion(), "5.2.8") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
fwrite(STDERR, "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install latest Moodle 1.9.x instead.\n");
|
||||
die(1);
|
||||
}
|
||||
|
||||
// Nothing to do if config.php does not exist
|
||||
@@ -68,7 +66,7 @@ $configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
|
||||
if (!file_exists($configfile)) {
|
||||
fwrite(STDERR, 'config.php does not exist, can not continue'); // do not localize
|
||||
fwrite(STDERR, "\n");
|
||||
exit(1);
|
||||
die(1);
|
||||
}
|
||||
|
||||
// Include necessary libs
|
||||
@@ -95,8 +93,6 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'lang' => 'en',
|
||||
'adminuser' => 'admin',
|
||||
'adminpass' => '',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
'agree-license' => false,
|
||||
'help' => false
|
||||
),
|
||||
@@ -125,17 +121,26 @@ if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
|
||||
}
|
||||
$CFG->lang = $options['lang'];
|
||||
|
||||
// download required lang packs
|
||||
if ($CFG->lang !== 'en') {
|
||||
//download lang pack with optional notification
|
||||
if ($CFG->lang != 'en') {
|
||||
make_upload_directory('lang');
|
||||
$installer = new lang_installer($CFG->lang);
|
||||
$results = $installer->run();
|
||||
foreach ($results as $langcode => $langstatus) {
|
||||
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
|
||||
$a = new stdClass();
|
||||
$a->url = $installer->lang_pack_url($langcode);
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string('remotedownloaderror', 'error', $a));
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
|
||||
if ($cd->install() == COMPONENT_ERROR) {
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/2.0/'.$CFG->lang.'.zip';
|
||||
$a->dest = $CFG->dataroot.'/lang';
|
||||
cli_problem(get_string($cd->get_error(), 'error', $a));
|
||||
} else {
|
||||
cli_problem(get_string($cd->get_error(), 'error'));
|
||||
}
|
||||
} else {
|
||||
// install parent lang if defined
|
||||
if ($parentlang = get_parent_language()) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,28 +149,6 @@ if ($CFG->lang !== 'en') {
|
||||
$CFG->early_install_lang = false;
|
||||
get_string_manager(true);
|
||||
|
||||
require("$CFG->dirroot/version.php");
|
||||
|
||||
// Test environment first.
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
list($info, $report) = $error;
|
||||
echo "!! $info !!\n$report\n\n";
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
install_cli_database($options, true);
|
||||
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MySQL collation conversion tool.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2012 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
cli_error('This function is designed for MySQL databases only!');
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'collation'=>false, 'available'=>false),
|
||||
array('h'=>'help', 'l'=>'list', 'a'=>'available'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"MySQL collation conversions script.
|
||||
|
||||
It is strongly recommended to stop the web server before the conversion.
|
||||
This script may be executed before the main upgrade - 1.9.x data for example.
|
||||
|
||||
Options:
|
||||
--collation=COLLATION Convert MySQL tables to different collation
|
||||
-l, --list Show table and column information
|
||||
-a, --available Show list of available collations
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/mysql_collation.php --collation=utf8_general_ci
|
||||
";
|
||||
|
||||
if (!empty($options['collation'])) {
|
||||
$collations = mysql_get_collations();
|
||||
$collation = clean_param($options['collation'], PARAM_ALPHANUMEXT);
|
||||
$collation = strtolower($collation);
|
||||
if (!isset($collations[$collation])) {
|
||||
cli_error("Error: collation '$collation' is not available on this server!");
|
||||
}
|
||||
|
||||
echo "Converting tables and columns to '$collation' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
$errors = 0;
|
||||
foreach ($rs as $table) {
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
if ($table->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
|
||||
} else {
|
||||
$DB->change_database_structure("ALTER TABLE $table->name DEFAULT COLLATE = $collation");
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
}
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $table->name WHERE collation IS NOT NULL";
|
||||
$rs2 = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs2 as $column) {
|
||||
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
||||
echo ' '.str_pad($column->field, 36). " - ";
|
||||
if ($column->collation === $collation) {
|
||||
echo "NO CHANGE\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($column->type === 'tinytext' or $column->type === 'mediumtext' or $column->type === 'text' or $column->type === 'longtext') {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
// primary, unique and inc are not supported for texts
|
||||
$sql = "ALTER TABLE $table->name MODIFY COLUMN $column->field $column->type COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
|
||||
} else if (strpos($column->type, 'varchar') === 0) {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = !is_null($column->default) ? "DEFAULT '$column->default'" : '';
|
||||
// primary, unique and inc are not supported for texts
|
||||
$sql = "ALTER TABLE $table->name MODIFY COLUMN $column->field $column->type COLLATE $collation $notnull $default";
|
||||
$DB->change_database_structure($sql);
|
||||
} else {
|
||||
echo "ERROR (unknown column type: $column->type)\n";
|
||||
$error++;
|
||||
continue;
|
||||
}
|
||||
echo "CONVERTED\n";
|
||||
$converted++;
|
||||
}
|
||||
$rs2->close();
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped, errors: $errors\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
echo "List of tables for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
$prefix = str_replace('_', '\\_', $prefix);
|
||||
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$counts = array();
|
||||
foreach ($rs as $table) {
|
||||
if (isset($counts[$table->collation])) {
|
||||
$counts[$table->collation]++;
|
||||
} else {
|
||||
$counts[$table->collation] = 1;
|
||||
}
|
||||
echo str_pad($table->name, 40);
|
||||
echo $table->collation. "\n";
|
||||
$collations = mysql_get_column_collations($table->name);
|
||||
foreach ($collations as $columname=>$collation) {
|
||||
if (isset($counts[$collation])) {
|
||||
$counts[$collation]++;
|
||||
} else {
|
||||
$counts[$collation] = 1;
|
||||
}
|
||||
echo ' ';
|
||||
echo str_pad($columname, 36);
|
||||
echo $collation. "\n";
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo "\n";
|
||||
echo "Table collations summary for $CFG->wwwroot:\n";
|
||||
foreach ($counts as $collation => $count) {
|
||||
echo "$collation: $count\n";
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['available'])) {
|
||||
echo "List of available MySQL collations for $CFG->wwwroot:\n";
|
||||
$collations = mysql_get_collations();
|
||||
foreach ($collations as $collation) {
|
||||
echo " $collation\n";
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========== Some functions ==============
|
||||
|
||||
function mysql_get_collations() {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SHOW COLLATION WHERE Collation LIKE 'utf8\_%' AND Charset = 'utf8'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $collation) {
|
||||
$collations[$collation->collation] = $collation->collation;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
$collation = $DB->get_dbcollation();
|
||||
if (isset($collations[$collation])) {
|
||||
$collations[$collation] .= ' (default)';
|
||||
}
|
||||
|
||||
return $collations;
|
||||
}
|
||||
|
||||
function mysql_get_column_collations($tablename) {
|
||||
global $DB;
|
||||
|
||||
$collations = array();
|
||||
$sql = "SELECT column_name, collation_name
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_schema = DATABASE() AND table_name = ? AND collation_name IS NOT NULL";
|
||||
$rs = $DB->get_recordset_sql($sql, array($tablename));
|
||||
foreach($rs as $record) {
|
||||
$collations[$record->column_name] = $record->collation_name;
|
||||
}
|
||||
$rs->close();
|
||||
return $collations;
|
||||
}
|
||||
@@ -34,8 +34,8 @@ if ($DB->get_dbfamily() !== 'mysql') {
|
||||
}
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'engine'=>false, 'available'=>false),
|
||||
array('h'=>'help', 'l'=>'list', 'a'=>'available'));
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'engine'=>false),
|
||||
array('h'=>'help', 'l'=>'list'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
@@ -52,7 +52,6 @@ and does not support transactions.
|
||||
Options:
|
||||
--engine=ENGINE Convert MySQL tables to different engine
|
||||
-l, --list Show table information
|
||||
-a, --available Show list of available engines
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
@@ -60,11 +59,7 @@ Example:
|
||||
";
|
||||
|
||||
if (!empty($options['engine'])) {
|
||||
$engines = mysql_get_engines();
|
||||
$engine = clean_param($options['engine'], PARAM_ALPHA);
|
||||
if (!isset($engines[strtoupper($engine)])) {
|
||||
cli_error("Error: engine '$engine' is not available on this server!");
|
||||
}
|
||||
|
||||
echo "Converting tables to '$engine' for $CFG->wwwroot:\n";
|
||||
$prefix = $DB->get_prefix();
|
||||
@@ -73,34 +68,20 @@ if (!empty($options['engine'])) {
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$converted = 0;
|
||||
$skipped = 0;
|
||||
$errors = 0;
|
||||
foreach ($rs as $table) {
|
||||
if (strtoupper($table->engine) === strtoupper($engine)) {
|
||||
$newengine = mysql_get_table_engine($table->name);
|
||||
echo str_pad($table->name, 40). " - NO CONVERSION NEEDED ($newengine)\n";
|
||||
if ($table->engine === $engine) {
|
||||
echo str_pad($table->name, 40). " - NO CONVERSION NEEDED\n";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
echo str_pad($table->name, 40). " - ";
|
||||
|
||||
try {
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} ENGINE = $engine");
|
||||
$newengine = mysql_get_table_engine($table->name);
|
||||
if (strtoupper($newengine) !== strtoupper($engine)) {
|
||||
echo "ERROR ($newengine)\n";
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
echo "DONE ($newengine)\n";
|
||||
$converted++;
|
||||
} catch (moodle_exception $e) {
|
||||
echo $e->getMessage()."\n";
|
||||
$errors++;
|
||||
continue;
|
||||
}
|
||||
$DB->change_database_structure("ALTER TABLE {$table->name} TYPE = $engine");
|
||||
echo "DONE\n";
|
||||
$converted++;
|
||||
}
|
||||
$rs->close();
|
||||
echo "Converted: $converted, skipped: $skipped, errors: $errors\n";
|
||||
echo "Converted: $converted, skipped: $skipped\n";
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['list'])) {
|
||||
@@ -128,53 +109,7 @@ if (!empty($options['engine'])) {
|
||||
}
|
||||
exit(0); // success
|
||||
|
||||
} else if (!empty($options['available'])) {
|
||||
echo "List of available MySQL engines for $CFG->wwwroot:\n";
|
||||
$engines = mysql_get_engines();
|
||||
foreach ($engines as $engine) {
|
||||
echo " $engine\n";
|
||||
}
|
||||
die;
|
||||
|
||||
} else {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========== Some functions ==============
|
||||
|
||||
function mysql_get_engines() {
|
||||
global $DB;
|
||||
|
||||
$sql = "SHOW Engines";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$engines = array();
|
||||
foreach ($rs as $engine) {
|
||||
if (strtoupper($engine->support) !== 'YES' and strtoupper($engine->support) !== 'DEFAULT') {
|
||||
continue;
|
||||
}
|
||||
$engines[strtoupper($engine->engine)] = $engine->engine;
|
||||
if (strtoupper($engine->support) === 'DEFAULT') {
|
||||
$engines[strtoupper($engine->engine)] .= ' (default)';
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
return $engines;
|
||||
}
|
||||
|
||||
function mysql_get_table_engine($tablename) {
|
||||
global $DB;
|
||||
|
||||
$engine = null;
|
||||
$sql = "SHOW TABLE STATUS WHERE Name = '$tablename'"; // no special chars expected here
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
if ($rs->valid()) {
|
||||
$record = $rs->current();
|
||||
$engine = $record->engine;
|
||||
}
|
||||
$rs->close();
|
||||
return $engine;
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Invalidates all Moodle internal caches
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
purge_all_caches();
|
||||
|
||||
exit(0);
|
||||
+9
-20
@@ -20,6 +20,7 @@
|
||||
*
|
||||
* This script is not intended for beginners!
|
||||
* Potential problems:
|
||||
* - environment check is not present yet
|
||||
* - su to apache account or sudo before execution
|
||||
* - not compatible with Windows platform
|
||||
*
|
||||
@@ -36,7 +37,7 @@ require_once($CFG->libdir.'/adminlib.php'); // various admin-only function
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
@@ -82,7 +83,7 @@ if (empty($CFG->version)) {
|
||||
cli_error(get_string('missingconfigversion', 'debug'));
|
||||
}
|
||||
|
||||
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
|
||||
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
|
||||
$CFG->target_release = $release; // used during installation and upgrades
|
||||
|
||||
if ($version < $CFG->version) {
|
||||
@@ -92,13 +93,8 @@ if ($version < $CFG->version) {
|
||||
$oldversion = "$CFG->release ($CFG->version)";
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
if (!moodle_needs_upgrading()) {
|
||||
cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0);
|
||||
}
|
||||
|
||||
// Test environment first.
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
if (!$envstatus) {
|
||||
// test environment first
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
@@ -108,13 +104,6 @@ if (!$envstatus) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
if ($interactive) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = $oldversion;
|
||||
@@ -134,8 +123,7 @@ if (isset($maturity)) {
|
||||
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . PHP_EOL;
|
||||
cli_separator();
|
||||
} else {
|
||||
cli_problem(get_string('maturitycorewarning', 'admin', $maturitylevel));
|
||||
cli_error(get_string('maturityallowunstable', 'admin'));
|
||||
cli_error(get_string('maturitycorewarning', 'admin', $maturitylevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,13 +141,14 @@ if ($version > $CFG->version) {
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
set_config('branch', $branch);
|
||||
|
||||
// unconditionally upgrade
|
||||
upgrade_noncore(true);
|
||||
|
||||
// log in as admin - we need doanything permission when applying defaults
|
||||
session_set_user(get_admin());
|
||||
$admins = get_admins();
|
||||
$admin = reset($admins);
|
||||
session_set_user($admin);
|
||||
|
||||
// apply all default settings, just in case do it twice to fill all defaults
|
||||
admin_apply_default_settings(NULL, false);
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to enable, disable and uninstall course formats
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2012 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$formatname = required_param('format', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/courseformats.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
$formatplugins = $allplugins['format'];
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $formatname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($formatplugins[$formatname]->is_enabled()) {
|
||||
if (get_config('moodlecourse', 'format') === $formatname) {
|
||||
print_error('cannotdisableformat', 'error', $return);
|
||||
}
|
||||
set_config('disabled', 1, 'format_'. $formatname);
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$formatplugins[$formatname]->is_enabled()) {
|
||||
unset_config('disabled', 'format_'. $formatname);
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
if ($sortorder[$formatname]) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex-1];
|
||||
$seq[$currentindex-1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
if ($sortorder[$formatname] < count($sortorder)-1) {
|
||||
$currentindex = $sortorder[$formatname];
|
||||
$seq = array_keys($formatplugins);
|
||||
$seq[$currentindex] = $seq[$currentindex+1];
|
||||
$seq[$currentindex+1] = $formatname;
|
||||
set_config('format_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'uninstall':
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
|
||||
|
||||
$coursecount = $DB->count_records('course', array('format' => $formatname));
|
||||
if ($coursecount) {
|
||||
// Check that default format is set. It will be used to convert courses
|
||||
// using this format
|
||||
$defaultformat = get_config('moodlecourse', 'format');
|
||||
$defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
|
||||
if (!$defaultformat) {
|
||||
echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$format = $formatplugins[$formatname];
|
||||
$deleteurl = $format->get_uninstall_url();
|
||||
if (!$deleteurl) {
|
||||
// somebody was trying to cheat and type non-existing link
|
||||
echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
if ($coursecount) {
|
||||
$message = get_string('formatuninstallwithcourses', 'admin',
|
||||
(object)array('count' => $coursecount, 'format' => $format->displayname,
|
||||
'defaultformat' => $defaultformat->displayname));
|
||||
} else {
|
||||
$message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
|
||||
}
|
||||
$deleteurl->param('confirm', 1);
|
||||
echo $OUTPUT->confirm($message, $deleteurl, $return);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->plugin = $format->displayname;
|
||||
$a->directory = $format->rootdir;
|
||||
uninstall_plugin('format', $formatname);
|
||||
echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
redirect($return);
|
||||
@@ -36,12 +36,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
if (defined('STDIN')) {
|
||||
fwrite(STDERR, "ERROR: This script no longer supports CLI, please use admin/cli/cron.php instead\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// This is a fake CLI script, it is a really ugly hack which emulates
|
||||
// CLI via web interface, please do not use this hack elsewhere
|
||||
define('CLI_SCRIPT', true);
|
||||
@@ -81,9 +75,6 @@ if (check_browser_version('MSIE')) {
|
||||
@header('Content-Type: text/plain; charset=utf-8');
|
||||
}
|
||||
|
||||
// we do not want html markup in emulated CLI
|
||||
@ini_set('html_errors', 'off');
|
||||
|
||||
// execute the cron
|
||||
cron_run();
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?PHP
|
||||
// dbperformance.php - shows latest ADOdb stats for the current server
|
||||
|
||||
// disable moodle specific debug messages and any errors in output
|
||||
define('NO_DEBUG_DISPLAY', true);
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
error('TODO: rewrite db perf code'); // TODO: rewrite
|
||||
|
||||
|
||||
$topframe = optional_param('topframe', 0, PARAM_BOOL);
|
||||
$bottomframe = optional_param('bottomframe', 0, PARAM_BOOL);
|
||||
$do = optional_param('do', '', PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$strdatabaseperformance = get_string("databaseperformance");
|
||||
$stradministration = get_string("administration");
|
||||
$site = get_site();
|
||||
|
||||
if (!empty($topframe)) {
|
||||
$PAGE->set_url('/admin/dbperformance.php');
|
||||
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
|
||||
$PAGE->navbar->add($strdatabaseperformance);
|
||||
$PAGE->set_title("$site->shortname: $strdatabaseperformance");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
echo $OUTPUT->header();
|
||||
exit;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class database_export_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbexport', 'dbtransfer'));
|
||||
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>5, 'cols'=>60));
|
||||
|
||||
$this->add_action_buttons(false, get_string('exportdata', 'dbtransfer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class database_transfer_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbtransfer', 'dbtransfer'));
|
||||
|
||||
$supported = array (
|
||||
'mysqli/native',
|
||||
'pgsql/native',
|
||||
'mssql/native',
|
||||
'oci/native',
|
||||
'sqlite3/pdo',
|
||||
);
|
||||
$drivers = array();
|
||||
foreach($supported as $driver) {
|
||||
list($dbtype, $dblibrary) = explode('/', $driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if ($targetdb->driver_installed() !== true) {
|
||||
continue;
|
||||
}
|
||||
$drivers[$driver] = $driver;
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
|
||||
$mform->addElement('text', 'dbhost', get_string('dbhost', 'install'));
|
||||
$mform->addElement('text', 'dbname', get_string('database', 'install'));
|
||||
$mform->addElement('text', 'dbuser', get_string('user'));
|
||||
$mform->addElement('text', 'dbpass', get_string('password'));
|
||||
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
|
||||
|
||||
$mform->addRule('dbhost', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbname', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbuser', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbpass', get_string('required'), 'required', null);
|
||||
$mform->addRule('prefix', get_string('required'), 'required', null);
|
||||
|
||||
$this->add_action_buttons(false, get_string('transferdata', 'dbtransfer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require('../../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('database_export_form.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('dbexport');
|
||||
|
||||
//create form
|
||||
$form = new database_export_form();
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
dbtransfer_export_xml_database($data->description, $DB);
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// TODO: add some more info here
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
require('../../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('database_transfer_form.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('dbtransfer');
|
||||
|
||||
// Create the form
|
||||
$form = new database_transfer_form();
|
||||
|
||||
// If we have valid input.
|
||||
if ($data = $form->get_data()) {
|
||||
// Connect to the other database.
|
||||
list($dbtype, $dblibrary) = explode('/', $data->driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if (!$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, null)) {
|
||||
throw new dbtransfer_exception('notargetconectexception', null, "$CFG->wwwroot/$CFG->admin/dbtransfer/");
|
||||
}
|
||||
if ($targetdb->get_tables()) {
|
||||
throw new dbtransfer_exception('targetdatabasenotempty', null, "$CFG->wwwroot/$CFG->admin/dbtransfer/");
|
||||
}
|
||||
|
||||
// Start output.
|
||||
echo $OUTPUT->header();
|
||||
$data->dbtype = $dbtype;
|
||||
echo $OUTPUT->heading(get_string('transferringdbto', 'dbtransfer', $data));
|
||||
|
||||
// Do the transfer.
|
||||
$feedback = new html_list_progress_trace();
|
||||
dbtransfer_transfer_database($DB, $targetdb, $feedback);
|
||||
$feedback->finished();
|
||||
|
||||
// Finish up.
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// Otherwise display the settings form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('transferdbtoserver', 'dbtransfer'));
|
||||
echo '<p>', get_string('transferdbintro', 'dbtransfer'), "</p>\n\n";
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
- exporting to server file >2GB fails in 32bit operating systems - needs warning
|
||||
- we may run out of disk space exporting to srever file - we must verify the file is not truncated; read from the end of file?
|
||||
- when sending file >4GB - FAT32 limit, Apache limit, browser limit - needs warning
|
||||
- there must be some form of progress bar during export, transfer - new tracking class could be passed around
|
||||
- command line operation - could work around some 2G/4G limits in PHP; useful for cron full backups
|
||||
- by default allow exporting into empty database only (no tables with the same prefix yet)
|
||||
- all dangerous operation (like deleting of all data) should be confirmed by key found in special file in dataroot
|
||||
(user would need file access to dataroot which might prevent various "accidents")
|
||||
- implement "Export/import running" notification in lib/setup.php (similar to new upgrade flag in config table)
|
||||
- gzip compression when storing xml file - the xml is very verbose and full of repeated tags (zip is not suitable here at all)
|
||||
this could help us keep the files bellow 2G (expected ratio is > 10:1)
|
||||
|
||||
*/
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/dtllib.php');
|
||||
|
||||
|
||||
function dbtransfer_export_xml_database($description, $mdb) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
|
||||
header('Content-Type: application/xhtml+xml; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename=database.xml');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
|
||||
header('Pragma: public');
|
||||
|
||||
while(@ob_flush());
|
||||
|
||||
$var = new file_xml_database_exporter('php://output', $mdb);
|
||||
$var->export_database($description);
|
||||
|
||||
// no more output
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
|
||||
@set_time_limit(0);
|
||||
|
||||
session_get_instance()->write_close(); // release session
|
||||
|
||||
$var = new database_mover($sourcedb, $targetdb, true, $feedback);
|
||||
$var->export_database(null);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
// 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_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));
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Purge moodledata');
|
||||
|
||||
if (empty($sure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey());
|
||||
|
||||
$formcontinue = new single_button(new moodle_url('delete.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button('index.php', get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!data_submitted() or empty($reallysure)) {
|
||||
$optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
|
||||
$formcontinue = new single_button(new moodle_url('delete.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button('index.php', get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('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) ?',
|
||||
$formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('wrongcall', 'error');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
|
||||
function delete_subdirectories($rootdir) {
|
||||
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
delete_subdirectories($fullfile);
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (rmdir($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
}
|
||||
} else {
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (unlink($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
|
||||
+4
-50
@@ -8,18 +8,14 @@ require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$editor = required_param('editor', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$editor = optional_param('editor', '', PARAM_SAFEDIR);
|
||||
|
||||
// get currently installed and enabled auth plugins
|
||||
$available_editors = editors_get_available();
|
||||
if (!empty($editor) and empty($available_editors[$editor])) {
|
||||
@@ -82,48 +78,6 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
if ($editor === 'textarea') {
|
||||
redirect($returnurl);
|
||||
}
|
||||
if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) {
|
||||
$strplugin = get_string('pluginname', 'editor_'.$editor);
|
||||
} else {
|
||||
$strplugin = $editor;
|
||||
}
|
||||
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->heading(get_string('editors', 'core_editor'));
|
||||
|
||||
$deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
|
||||
echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin),
|
||||
$deleteurl, $returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Remove from enabled list.
|
||||
$key = array_search($editor, $active_editors);
|
||||
unset($active_editors[$key]);
|
||||
set_config('texteditors', implode(',', $active_editors));
|
||||
|
||||
// Delete everything!!
|
||||
uninstall_plugin('editor', $editor);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->name = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/lib/editor/$editor";
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-53
@@ -23,21 +23,17 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$enrol = required_param('enrol', PARAM_PLUGIN);
|
||||
$action = required_param('action', PARAM_ACTION);
|
||||
$enrol = required_param('enrol', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$migrate = optional_param('migrate', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_url('/admin/enrol.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_sesskey();
|
||||
|
||||
$enabled = enrol_get_plugins(true);
|
||||
@@ -45,13 +41,10 @@ $all = enrol_get_plugins(false);
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
case 'enable':
|
||||
@@ -61,7 +54,6 @@ switch ($action) {
|
||||
$enabled = array_keys($enabled);
|
||||
$enabled[] = $enrol;
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabled));
|
||||
$syscontext->mark_dirty(); // resets all enrol caches
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
@@ -97,60 +89,24 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
|
||||
|
||||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
|
||||
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
|
||||
} else {
|
||||
$strplugin = $enrol;
|
||||
}
|
||||
|
||||
$PAGE->set_title($strplugin);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
|
||||
|
||||
$deleteurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>0));
|
||||
$migrateurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>1));
|
||||
|
||||
$migrate = new single_button($migrateurl, get_string('uninstallmigrate', 'enrol'));
|
||||
$delete = new single_button($deleteurl, get_string('uninstalldelete', 'enrol'));
|
||||
$cancel = new single_button($return, get_string('cancel'), 'get');
|
||||
|
||||
$buttons = $OUTPUT->render($delete) . $OUTPUT->render($cancel);
|
||||
if ($enrol !== 'manual') {
|
||||
$buttons = $OUTPUT->render($migrate) . $buttons;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
echo html_writer::tag('p', markdown_to_html(get_string('uninstallconfirm', 'enrol', $strplugin)));
|
||||
echo html_writer::tag('div', $buttons, array('class' => 'buttons'));
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
|
||||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// This may take a long time.
|
||||
set_time_limit(0);
|
||||
|
||||
// Disable plugin to prevent concurrent cron execution.
|
||||
unset($enabled[$enrol]);
|
||||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
|
||||
|
||||
if ($migrate) {
|
||||
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));
|
||||
|
||||
require_once("$CFG->dirroot/enrol/manual/locallib.php");
|
||||
enrol_manual_migrate_plugin_enrolments($enrol);
|
||||
|
||||
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
|
||||
}
|
||||
|
||||
// Delete everything!!
|
||||
} else { // Delete everything!!
|
||||
uninstall_plugin('enrol', $enrol);
|
||||
$syscontext->mark_dirty(); // Resets all enrol caches.
|
||||
|
||||
$a = new stdClass();
|
||||
$a->plugin = $strplugin;
|
||||
$a->directory = "$CFG->dirroot/enrol/$enrol";
|
||||
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
|
||||
|
||||
+124
-96
@@ -1,109 +1,137 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2006 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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); //
|
||||
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
/// 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');
|
||||
|
||||
// Parameters
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$version = optional_param('version', '', PARAM_FILE); //
|
||||
/// Print the header stuff
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$extraurlparams = array();
|
||||
if ($version) {
|
||||
$extraurlparams['version'] = $version;
|
||||
}
|
||||
admin_externalpage_setup('environment', '', $extraurlparams);
|
||||
/// Print the component download link
|
||||
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.sesskey().'">'.$strupdate.'</a></div>';
|
||||
|
||||
// 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_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
echo $OUTPUT->heading($strenvironment);
|
||||
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', $PAGE->url);
|
||||
die();
|
||||
}
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
redirect($PAGE->url, get_string($cd->get_error(), 'error'));
|
||||
die;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
redirect($PAGE->url, get_string('componentinstalled', 'admin'));
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 bigger than current
|
||||
foreach ($env_versions as $env_version) {
|
||||
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
||||
$versions[$env_version] = $env_version;
|
||||
/// 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.'/';
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error', $a), 'errorbox');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'), 'errorbox');
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
echo $OUTPUT->box(get_string($cd->get_error(), 'error'));
|
||||
break;
|
||||
case COMPONENT_INSTALLED:
|
||||
echo $OUTPUT->box(get_string('componentinstalled', 'admin'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Add 'upwards' to the last element
|
||||
$versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
|
||||
} else {
|
||||
$versions = array('error' => get_string('error'));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the results of the environment check.
|
||||
list($envstatus, $environment_results) = check_moodle_environment($version);
|
||||
/// Start of main box
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
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 bigger 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"> ';
|
||||
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
|
||||
$select->label = $strmoodleversion;
|
||||
echo $OUTPUT->render($select);
|
||||
echo '</div>';
|
||||
|
||||
/// End of main box
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Gather and show results
|
||||
$status = check_moodle_environment($version, $environment_results);
|
||||
|
||||
/// Print footer
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
// Display the page.
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
|
||||
|
||||
+10
-344
@@ -214,7 +214,11 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
@@ -331,7 +335,11 @@
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
@@ -434,346 +442,4 @@
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.2" requires="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.2" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</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="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</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_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.3" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.2" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</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="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</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_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.4" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.2" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</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="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</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_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+6
-8
@@ -34,11 +34,11 @@
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $systemcontext);
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
|
||||
@@ -68,7 +68,7 @@
|
||||
switch ($action) {
|
||||
|
||||
case 'setstate':
|
||||
if ($newstate = optional_param('newstate', '', PARAM_INT)) {
|
||||
if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) {
|
||||
filter_set_global_state($filterpath, $newstate);
|
||||
if ($newstate == TEXTFILTER_DISABLED) {
|
||||
filter_set_applies_to_strings($filterpath, false);
|
||||
@@ -242,20 +242,19 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
|
||||
// Disable/off/on
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
|
||||
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Re-order
|
||||
$updown = '';
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />';
|
||||
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
|
||||
if ($filterinfo->active != TEXTFILTER_DISABLED) {
|
||||
if (!$isfirstrow) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall')));
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if (!$islastactive) {
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall')));
|
||||
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down')));
|
||||
} else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
@@ -264,7 +263,6 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
|
||||
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
|
||||
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
|
||||
+1336
File diff suppressed because it is too large
Load Diff
@@ -39,17 +39,13 @@ while(!feof($fd)) {
|
||||
$action = clam_handle_infected_file($file,$log->userid,true);
|
||||
clam_replace_infected_file($file);
|
||||
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
|
||||
$course = $DB->get_record_sql($sql, array('courseid' => $log->course));
|
||||
context_instance_preload($course);
|
||||
|
||||
$user = $DB->get_record("user", array("id"=>$log->userid));
|
||||
$course = $DB->get_record("course", array("id"=>$log->course));
|
||||
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
|
||||
$a->date = userdate($log->time);
|
||||
|
||||
$a->action = $action;
|
||||
$a->course = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
|
||||
$a->course = $course->fullname;
|
||||
$a->user = fullname($user);
|
||||
|
||||
notify_user($user,$subject,$a);
|
||||
@@ -86,7 +82,7 @@ function notify_admins($user,$subject,$a) {
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
@@ -107,7 +103,7 @@ function notify_admins_unknown($file,$a) {
|
||||
foreach ($admins as $admin) {
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userfrom = $admin;
|
||||
$eventdata->userto = $admin;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $body;
|
||||
|
||||
@@ -0,0 +1,790 @@
|
||||
<?php
|
||||
|
||||
ob_start(); //for whitespace test
|
||||
require_once('../config.php');
|
||||
|
||||
// extra whitespace test - intentionally breaks cookieless mode
|
||||
$extraws = '';
|
||||
while (ob_get_level()) {
|
||||
$extraws .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
echo $OUTPUT->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();
|
||||
}
|
||||
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
function health_find_problems() {
|
||||
global $OUTPUT;
|
||||
|
||||
echo $OUTPUT->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 {
|
||||
echo $OUTPUT->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) {
|
||||
global $OUTPUT;
|
||||
$problem = new $classname;
|
||||
$data = array(
|
||||
'title' => $problem->title(),
|
||||
'severity' => $problem->severity(),
|
||||
'description' => $problem->description(),
|
||||
'solution' => $problem->solution()
|
||||
);
|
||||
|
||||
echo $OUTPUT->heading(get_string('healthcenter'));
|
||||
echo $OUTPUT->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_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 $DB;
|
||||
$lastcron = $DB->get_field_sql('SELECT max(lastcron) FROM {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() {
|
||||
global $CFG;
|
||||
|
||||
$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 higher
|
||||
$newmemlimit = ($oldmemlimit + 1024*1024*5);
|
||||
raise_memory_limit($newmemlimit);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
reduce_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.');
|
||||
}
|
||||
}
|
||||
/* // not implemented in 2.0 yet
|
||||
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_000012 extends problem_base {
|
||||
function title() {
|
||||
return 'Random questions data consistency';
|
||||
}
|
||||
function exists() {
|
||||
global $DB;
|
||||
return $DB->record_exists_select('question', "qtype = 'random' AND parent <> id", array());
|
||||
}
|
||||
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 $DB;
|
||||
$positionexpr = $DB->sql_position($DB->sql_concat("','", "q.id", "','"),
|
||||
$DB->sql_concat("','", "qma.sequence", "','"));
|
||||
return $DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {question_multianswer} qma ON $positionexpr > 0
|
||||
WHERE qma.question <> q.parent") ||
|
||||
$DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {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 $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT * FROM {question} q
|
||||
JOIN {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 $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT qc.*, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {context} con ON qc.contextid = con.id
|
||||
WHERE con.id IS NULL");
|
||||
}
|
||||
function severity() {
|
||||
return SEVERITY_ANNOYANCE;
|
||||
}
|
||||
function description() {
|
||||
global $DB;
|
||||
$problemcategories = $DB->get_records_sql("
|
||||
SELECT qc.id, qc.name, qc.contextid, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
|
||||
FROM {question_categories} qc
|
||||
LEFT JOIN {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";
|
||||
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
|
||||
WHERE
|
||||
NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'question q WHERE q.category = ' . $CFG->prefix . 'question_categories.id)
|
||||
AND NOT EXISTS (SELECT * FROM ' . $CFG->prefix . 'context con WHERE 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 $DB;
|
||||
return $DB->record_exists_sql("
|
||||
SELECT parent_qc.id AS parent, child_qc.id AS child, child_qc.contextid
|
||||
FROM {question_categories} child_qc
|
||||
JOIN {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 $DB;
|
||||
$problemcategories = $DB->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 {question_categories} child_qc
|
||||
JOIN {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";
|
||||
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() {
|
||||
global $DB;
|
||||
static $answer = null;
|
||||
|
||||
if (is_null($answer)) {
|
||||
$categories = $DB->get_records('question_categories', array(), '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
|
||||
|
||||
*/
|
||||
|
||||
|
||||
+171
-208
@@ -26,23 +26,16 @@
|
||||
// Check that config.php exists, if not then call the install script
|
||||
if (!file_exists('../config.php')) {
|
||||
header('Location: ../install.php');
|
||||
die();
|
||||
die;
|
||||
}
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible
|
||||
if (version_compare(phpversion(), '5.3.2') < 0) {
|
||||
if (version_compare(phpversion(), '5.2.0') < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
||||
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
||||
echo "Please upgrade your server software or install older Moodle version.";
|
||||
die();
|
||||
}
|
||||
|
||||
// make sure iconv is available and actually works
|
||||
if (!function_exists('iconv')) {
|
||||
// this should not happen, this must be very borked install
|
||||
echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
|
||||
die();
|
||||
echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
|
||||
echo "Please upgrade your server software or use latest Moodle 1.9.x instead.";
|
||||
die;
|
||||
}
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
@@ -50,15 +43,12 @@ define('NO_OUTPUT_BUFFERING', true);
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications
|
||||
|
||||
$id = optional_param('id', '', PARAM_TEXT);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
||||
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
||||
|
||||
// Check some PHP server settings
|
||||
|
||||
@@ -84,26 +74,29 @@ if (is_float_problem()) {
|
||||
}
|
||||
|
||||
// Set some necessary variables during set-up to avoid PHP warnings later on this page
|
||||
if (!isset($CFG->framename)) {
|
||||
$CFG->framename = '_top';
|
||||
}
|
||||
if (!isset($CFG->release)) {
|
||||
$CFG->release = '';
|
||||
}
|
||||
if (!isset($CFG->version)) {
|
||||
$CFG->version = '';
|
||||
}
|
||||
if (!isset($CFG->branch)) {
|
||||
$CFG->branch = '';
|
||||
}
|
||||
|
||||
$version = null;
|
||||
$release = null;
|
||||
$branch = null;
|
||||
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
|
||||
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
|
||||
$CFG->target_release = $release; // used during installation and upgrades
|
||||
|
||||
if (!$version or !$release) {
|
||||
print_error('withoutversion', 'debug'); // without version, stop
|
||||
}
|
||||
|
||||
// Turn off xmlstrictheaders during upgrade.
|
||||
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
|
||||
$CFG->xmlstrictheaders = false;
|
||||
|
||||
if (!core_tables_exist()) {
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
@@ -118,57 +111,65 @@ if (!core_tables_exist()) {
|
||||
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
|
||||
$PAGE->navbar->add($strlicense);
|
||||
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_licence_page();
|
||||
die();
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
|
||||
echo $OUTPUT->heading(get_string('copyrightnotice'));
|
||||
$copyrightnotice = text_to_html(get_string('gpl3'));
|
||||
$copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($copyrightnotice, 'copyrightnotice');
|
||||
echo '<br />';
|
||||
$continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/en/License");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading("Moodle $release");
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
||||
die();
|
||||
if (isset($maturity)) {
|
||||
// main version.php declares moodle code maturity
|
||||
if ($maturity < MATURITY_STABLE) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
echo $OUTPUT->box(
|
||||
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
}
|
||||
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload("index.php?agreelicense=1&lang=$CFG->lang");
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// check plugin dependencies
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
$url = new moodle_url('/admin/index.php', array('agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang));
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $url);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
//TODO: add a page with list of non-standard plugins here
|
||||
|
||||
$strdatabasesetup = get_string('databasesetup');
|
||||
upgrade_init_javascript();
|
||||
|
||||
$PAGE->navbar->add($strdatabasesetup);
|
||||
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
||||
$PAGE->set_heading($strinstallation);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->header();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$DB->setup_is_unicodedb()) {
|
||||
if (!$DB->change_db_encoding()) {
|
||||
@@ -185,98 +186,86 @@ if (!core_tables_exist()) {
|
||||
// and upgrade if possible.
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
purge_all_caches();
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
if (upgrade_stale_php_files_present()) {
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_stale_php_files_page();
|
||||
die();
|
||||
}
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_heading($strdatabasechecking);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
||||
die();
|
||||
echo $OUTPUT->header();
|
||||
if (isset($maturity)) {
|
||||
// main version.php declares moodle code maturity
|
||||
if ($maturity < MATURITY_STABLE) {
|
||||
$maturitylevel = get_string('maturity'.$maturity, 'admin');
|
||||
echo $OUTPUT->box(
|
||||
$OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
}
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
$cancelurl = new moodle_url('index.php');
|
||||
echo $OUTPUT->confirm(get_string('upgradesure', 'admin', $a->newversion), $continueurl, $cancelurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strcurrentrelease);
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading("Moodle $release");
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
echo $OUTPUT->box($releasenoteslink);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload('index.php?confirmupgrade=1');
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
if (empty($CFG->skiplangupgrade)) {
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
print_string('langpackwillbeupdated', 'admin');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->continue_button('index.php?confirmupgrade=1&confirmrelease=1');
|
||||
}
|
||||
|
||||
} else if (empty($confirmplugins)) {
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
} elseif (empty($confirmplugins)) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
||||
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
if ($fetchupdates) {
|
||||
// no sesskey support guaranteed here
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
available_update_checker::instance()->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($reloadurl, $reloadurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins, $reloadurl,
|
||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strplugincheck);
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
print_string('pluginchecknotice');
|
||||
echo $OUTPUT->box_end();
|
||||
print_plugin_tables();
|
||||
print_upgrade_reload('index.php?confirmupgrade=1&confirmrelease=1');
|
||||
$button = new single_button(new moodle_url('index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get');
|
||||
$button->class = 'continuebutton';
|
||||
echo $OUTPUT->render($button);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
@@ -293,55 +282,28 @@ if ($release <> $CFG->release) { // Update the release version
|
||||
set_config('release', $release);
|
||||
}
|
||||
|
||||
if ($branch <> $CFG->branch) { // Update the branch
|
||||
set_config('branch', $branch);
|
||||
}
|
||||
|
||||
if (moodle_needs_upgrading()) {
|
||||
if (!$PAGE->headerprinted) {
|
||||
// means core upgrade or installation was not already done
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
$PAGE->set_title($strplugincheck);
|
||||
$PAGE->set_heading($strplugincheck);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
if ($fetchupdates) {
|
||||
// no sesskey support guaranteed here
|
||||
available_update_checker::instance()->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($PAGE->url, $PAGE->url);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// dependencies check passed, let's rock!
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins,
|
||||
new moodle_url($PAGE->url),
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strplugincheck);
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
print_string('pluginchecknotice');
|
||||
echo $OUTPUT->box_end();
|
||||
print_plugin_tables();
|
||||
print_upgrade_reload('index.php');
|
||||
$button = new single_button(new moodle_url('index.php', array('confirmplugincheck'=>1)), get_string('upgradestart', 'admin'), 'get');
|
||||
$button->class = 'continuebutton';
|
||||
echo $OUTPUT->render($button);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -377,13 +339,8 @@ if (during_initial_install()) {
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup SESSION to make sure other code does not complain in the future.
|
||||
unset($SESSION->has_timed_out);
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
// at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
|
||||
$adminids = explode(',', $CFG->siteadmins);
|
||||
$adminuser = get_complete_user_data('id', reset($adminids));
|
||||
// at this stage there can be only one admin - users may change username, so do not rely on that
|
||||
$adminuser = get_complete_user_data('id', $CFG->siteadmins);
|
||||
|
||||
if ($adminuser->password === 'adminsetuppending') {
|
||||
// prevent installation hijacking
|
||||
@@ -392,7 +349,8 @@ if (during_initial_install()) {
|
||||
}
|
||||
// login user and let him set password and admin details
|
||||
$adminuser->newadminuser = 1;
|
||||
complete_user_login($adminuser);
|
||||
message_set_default_message_preferences($adminuser);
|
||||
complete_user_login($adminuser, false);
|
||||
redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself
|
||||
|
||||
} else {
|
||||
@@ -404,9 +362,13 @@ if (during_initial_install()) {
|
||||
upgrade_finished('upgradesettings.php');
|
||||
}
|
||||
|
||||
// Turn xmlstrictheaders back on now.
|
||||
$CFG->xmlstrictheaders = $origxmlstrictheaders;
|
||||
unset($origxmlstrictheaders);
|
||||
|
||||
// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
// check that site is properly customized
|
||||
@@ -437,52 +399,53 @@ if (any_new_admin_settings($adminroot)){
|
||||
// Everything should now be set up, and the user is an admin
|
||||
|
||||
// Print default admin page with notifications.
|
||||
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
// Available updates for Moodle core
|
||||
$updateschecker = available_update_checker::instance();
|
||||
$availableupdates = array();
|
||||
$availableupdates['core'] = $updateschecker->get_update_info('core',
|
||||
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
||||
|
||||
// Available updates for contributed plugins
|
||||
$pluginman = plugin_manager::instance();
|
||||
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
|
||||
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
|
||||
if (!empty($plugininfo->availableupdates)) {
|
||||
foreach ($plugininfo->availableupdates as $pluginavailableupdate) {
|
||||
if ($pluginavailableupdate->version > $plugininfo->versiondisk) {
|
||||
if (!isset($availableupdates[$plugintype.'_'.$pluginname])) {
|
||||
$availableupdates[$plugintype.'_'.$pluginname] = array();
|
||||
}
|
||||
$availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The timestamp of the most recent check for available updates
|
||||
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
||||
|
||||
$buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
|
||||
//check if the site is registered on Moodle.org
|
||||
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
|
||||
echo $OUTPUT->box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
|
||||
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
|
||||
echo $OUTPUT->box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
|
||||
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered);
|
||||
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
|
||||
echo $OUTPUT->box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// If no recently cron run
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
$helpbutton = $OUTPUT->help_icon('cron', 'admin');
|
||||
echo $OUTPUT->box(get_string('cronwarning', 'admin').' '.$helpbutton, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// Hidden bloglevel upgrade
|
||||
$showbloglevelupgrade = ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) && empty($CFG->bloglevel_upgrade_complete);
|
||||
if ($showbloglevelupgrade) {
|
||||
echo $OUTPUT->box(get_string('bloglevelupgradenotice', 'admin'), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// diagnose DB, especially the sloppy MyISAM tables
|
||||
$diagnose = $DB->diagnose();
|
||||
if ($diagnose !== NULL) {
|
||||
echo $OUTPUT->box($diagnose, 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
// Alert if we are currently in maintenance mode
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "$CFG->wwwroot/$CFG->admin/settings.php?section=maintenancemode"), 'generalbox adminwarning');
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// 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>';
|
||||
echo $OUTPUT->box($copyrighttext, 'copyright');
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB');
|
||||
|
||||
if ($DB->get_dbfamily() != 'mysql') {
|
||||
notice('This function is for MySQL databases only!', 'index.php');
|
||||
}
|
||||
|
||||
if (data_submitted() and $confirm and confirm_sesskey()) {
|
||||
|
||||
echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
|
||||
|
||||
if ($tables = $DB->get_tables()) {
|
||||
$DB->set_debug(true);
|
||||
foreach ($tables as $table) {
|
||||
$fulltable = $DB->get_prefix().$table;
|
||||
$DB->change_database_structure("ALTER TABLE $fulltable TYPE=INNODB");
|
||||
}
|
||||
$DB->set_debug(false);
|
||||
}
|
||||
echo $OUTPUT->notification('... done.', 'notifysuccess');
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
} else {
|
||||
$optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey());
|
||||
$formcontinue = new single_button(new moodle_url('/admin/innodb.php', $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url('/admin/index.php'), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm('Are you sure you want convert all your tables to the InnoDB format?', $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Fetches language packages from download.moodle.org server
|
||||
*
|
||||
* Language packages are available at http://download.moodle.org/langpack/2.0/
|
||||
* in ZIP format together with a file languages.md5 containing their hashes
|
||||
* and meta info.
|
||||
* Locally, language packs are saved into $CFG->dataroot/lang/
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2005 Yu Zhang
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
$thisversion = '2.0'; // TODO this information should be taken from version.php or similar source
|
||||
|
||||
admin_externalpage_setup('langimport');
|
||||
|
||||
if (!empty($CFG->skiplangupgrade)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string('langimportdisabled', 'admin'));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$mode = optional_param('mode', 0, PARAM_INT); // action
|
||||
$pack = optional_param('pack', array(), PARAM_SAFEDIR); // pack to install
|
||||
$uninstalllang = optional_param('uninstalllang', '', PARAM_LANG); // installed pack to uninstall
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL); // uninstallation confirmation
|
||||
|
||||
define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
$notice_ok = array();
|
||||
$notice_error = array();
|
||||
|
||||
if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) {
|
||||
set_time_limit(0);
|
||||
make_upload_directory('temp');
|
||||
make_upload_directory('lang');
|
||||
|
||||
if (is_array($pack)) {
|
||||
$packs = $pack;
|
||||
} else {
|
||||
$packs = array($pack);
|
||||
}
|
||||
|
||||
foreach ($packs as $pack) {
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion, $pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install();
|
||||
switch ($status) {
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/'.$thisversion.'/'.$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);
|
||||
if ($parentlang = get_parent_language($pack)) {
|
||||
// install also parent pack if specified
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion,
|
||||
$parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMPONENT_UPTODATE:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->notification('Had an unspecified error with the component installer, sorry.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == DELETION_OF_SELECTED_LANG and !empty($uninstalllang)) {
|
||||
if ($uninstalllang == 'en') {
|
||||
$notice_error[] = 'English language pack can not be uninstalled';
|
||||
|
||||
} else if (!$confirm and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'admin', $uninstalllang),
|
||||
'langimport.php?mode='.DELETION_OF_SELECTED_LANG.'&uninstalllang='.$uninstalllang.'&confirm=1',
|
||||
'langimport.php');
|
||||
echo $OUTPUT->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);
|
||||
}
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == UPDATE_ALL_LANG) {
|
||||
set_time_limit(0);
|
||||
|
||||
if (!$availablelangs = get_remote_list_of_languages()) {
|
||||
print_error('cannotdownloadlanguageupdatelist', 'error');
|
||||
}
|
||||
$md5array = array(); // (string)langcode => (string)md5
|
||||
foreach ($availablelangs as $alang) {
|
||||
$md5array[$alang[0]] = $alang[1];
|
||||
}
|
||||
|
||||
// filter out unofficial packs
|
||||
$currentlangs = array_keys(get_string_manager()->get_list_of_translations(true));
|
||||
$updateablelangs = array();
|
||||
foreach ($currentlangs 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')){
|
||||
$updateablelangs[] = $clang;
|
||||
}
|
||||
}
|
||||
|
||||
// then filter out packs that have the same md5 key
|
||||
$neededlangs = array(); // all the packs that needs updating
|
||||
foreach ($updateablelangs as $ulang) {
|
||||
if (!is_installed_lang($ulang, $md5array[$ulang])) {
|
||||
$neededlangs[] = $ulang;
|
||||
}
|
||||
}
|
||||
|
||||
make_upload_directory('temp');
|
||||
make_upload_directory('lang');
|
||||
|
||||
$updated = false; // any packs updated?
|
||||
foreach ($neededlangs as $pack) {
|
||||
if ($pack == 'en') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// delete old directories
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// copy and unzip new version
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/'.$thisversion, $pack.'.zip', 'languages.md5', 'lang')) {
|
||||
$status = $cd->install();
|
||||
switch ($status) {
|
||||
|
||||
case COMPONENT_ERROR:
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
$a = new stdClass();
|
||||
$a->url = 'http://download.moodle.org/langpack/'.$thisversion.'/'.$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_UPTODATE:
|
||||
// should not get here
|
||||
break;
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackupdated', 'admin', $pack);
|
||||
$updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
$notice_ok[] = get_string('langupdatecomplete','admin');
|
||||
} else {
|
||||
$notice_ok[] = get_string('nolangupdateneeded','admin');
|
||||
}
|
||||
}
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('langimport', 'admin'));
|
||||
|
||||
$installedlangs = get_string_manager()->get_list_of_translations(true);
|
||||
|
||||
$missingparents = array();
|
||||
foreach ($installedlangs as $installedlang => $unused) {
|
||||
$parent = get_parent_language($installedlang);
|
||||
if (empty($parent) or ($parent === 'en')) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($installedlangs[$parent])) {
|
||||
$missingparents[$installedlang] = $parent;
|
||||
}
|
||||
}
|
||||
|
||||
if ($availablelangs = get_remote_list_of_languages()) {
|
||||
$remote = true;
|
||||
} else {
|
||||
$remote = false;
|
||||
$availablelangs = array();
|
||||
echo $OUTPUT->box_start();
|
||||
print_string('remotelangnotavailable', 'admin', $CFG->dataroot.'/lang/');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if ($notice_ok) {
|
||||
$info = implode('<br />', $notice_ok);
|
||||
echo $OUTPUT->notification($info, 'notifysuccess');
|
||||
}
|
||||
|
||||
if ($notice_error) {
|
||||
$info = implode('<br />', $notice_error);
|
||||
echo $OUTPUT->notification($info, 'notifyproblem');
|
||||
}
|
||||
|
||||
if ($missingparents) {
|
||||
foreach ($missingparents as $l=>$parent) {
|
||||
$a = new stdClass();
|
||||
$a->lang = $installedlangs[$l];
|
||||
$a->parent = $parent;
|
||||
foreach ($availablelangs as $alang) {
|
||||
if ($alang[0] == $parent) {
|
||||
$shortlang = $alang[0];
|
||||
$a->parent = $alang[2].' ('.$shortlang.')';
|
||||
}
|
||||
}
|
||||
$info = get_string('missinglangparent', 'admin', $a);
|
||||
echo $OUTPUT->notification($info, 'notifyproblem');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
echo html_writer::start_tag('table');
|
||||
echo html_writer::start_tag('tr');
|
||||
|
||||
// list of installed languages
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => DELETION_OF_SELECTED_LANG));
|
||||
echo html_writer::start_tag('td', array('valign' => 'top'));
|
||||
echo html_writer::start_tag('form', array('id' => 'uninstallform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('installedlangs','admin'), 'uninstalllang');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($installedlangs, 'uninstalllang', '', false, array('size' => 15));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('uninstall','admin')));
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
if ($remote) {
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => UPDATE_ALL_LANG));
|
||||
echo html_writer::start_tag('form', array('id' => 'updateform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::tag('fieldset', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('updatelangs','admin'))));
|
||||
echo html_writer::end_tag('form');
|
||||
}
|
||||
echo html_writer::end_tag('td');
|
||||
|
||||
// list of available languages
|
||||
$options = array();
|
||||
foreach ($availablelangs as $alang) {
|
||||
if (!empty($alang[0]) and trim($alang[0]) !== 'en' and !is_installed_lang($alang[0], $alang[1])) {
|
||||
$options[$alang[0]] = $alang[2].' ('.$alang[0].')';
|
||||
}
|
||||
}
|
||||
if (!empty($options)) {
|
||||
echo html_writer::start_tag('td', array('valign' => 'top'));
|
||||
$url = new moodle_url('/admin/langimport.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
|
||||
echo html_writer::start_tag('form', array('id' => 'installform', 'action' => $url->out(), 'method' => 'post'));
|
||||
echo html_writer::start_tag('fieldset');
|
||||
echo html_writer::label(get_string('availablelangs','install'), 'pack');
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::select($options, 'pack[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
echo html_writer::empty_tag('br');
|
||||
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('install','admin')));
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
echo html_writer::end_tag('td');
|
||||
}
|
||||
|
||||
echo html_writer::end_tag('tr');
|
||||
echo html_writer::end_tag('table');
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Local functions /////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 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 list of available language packs from download.moodle.org
|
||||
*
|
||||
* @return array|bool false if can not download
|
||||
*/
|
||||
function get_remote_list_of_languages() {
|
||||
$source = 'http://download.moodle.org/langpack/2.0/languages.md5';
|
||||
$availablelangs = array();
|
||||
|
||||
if ($content = download_file_content($source)) {
|
||||
$alllines = explode("\n", $content);
|
||||
foreach($alllines as $line) {
|
||||
if (!empty($line)){
|
||||
$availablelangs[] = explode(',', $line);
|
||||
}
|
||||
}
|
||||
return $availablelangs;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains functions used by the admin pages
|
||||
*
|
||||
* @since 2.1
|
||||
* @package admin
|
||||
* @copyright 2011 Andrew Davis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a list of page types
|
||||
* @param string $pagetype current page type
|
||||
* @param stdClass $parentcontext Block's parent context
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$array = array(
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
// Add the missing * (any page) option for them. MDL-30340
|
||||
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
|
||||
// and some day we should stop behaving that way, so proper pagetypes
|
||||
// can be specified for it (like course-category-* or so).
|
||||
// Luckly... the option we are introducing '*' is independent
|
||||
// of that varying behavior, so will work.
|
||||
if ($pagetype == 'admin-course-category') {
|
||||
$array += array(
|
||||
'*' => get_string('page-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
+2
-2
@@ -24,11 +24,11 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/licenselib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$action = optional_param('action', '', PARAM_ACTION);
|
||||
$license = optional_param('license', '', PARAM_SAFEDIR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* Displays the list of found local plugins, their version (if found) and
|
||||
* a link to delete the local plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/dev/Local_customisation
|
||||
* @see http://docs.moodle.org/en/Development:Local_customisation
|
||||
* @package admin
|
||||
* @copyright 2010 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -33,7 +33,7 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('managelocalplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
@@ -89,7 +89,7 @@ foreach (get_plugin_list('local') as $plugin => $plugindir) {
|
||||
}
|
||||
$plugins[$plugin] = $strpluginname;
|
||||
}
|
||||
collatorlib::asort($plugins);
|
||||
textlib_get_instance()->asort($plugins);
|
||||
|
||||
foreach ($plugins as $plugin => $name) {
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Message outputs configuration page
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page
|
||||
admin_externalpage_setup('managemessageoutputs');
|
||||
|
||||
// Require site configuration capability
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
$uninstall = optional_param('uninstall', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
if (!empty($disable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
|
||||
}
|
||||
|
||||
if (!empty($uninstall) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
message_processor_uninstall($processor->name);
|
||||
$a = new stdClass();
|
||||
$a->processor = $processorname;
|
||||
$a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
|
||||
notice(get_string('processordeletefiles', 'message', $a), 'message.php');
|
||||
}
|
||||
}
|
||||
|
||||
if ($disable || $enable || $uninstall) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
// Page settings
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
|
||||
// Display the manage message outputs interface
|
||||
$processors = get_message_processors();
|
||||
$messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
|
||||
// Display the page
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
@@ -22,7 +22,7 @@ if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sesskey = sesskey();
|
||||
$formerror = array();
|
||||
|
||||
@@ -103,7 +103,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
$usernames = explode(',', $form->username);
|
||||
|
||||
foreach ($usernames as $username) {
|
||||
$username = trim(textlib::strtolower($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') {
|
||||
@@ -203,18 +203,17 @@ echo get_string('username') . ":\n";
|
||||
if (!empty($formerror['username'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::label(get_string('username'), 'menuusername', false, array('class' => 'accesshide'));
|
||||
echo '<input id="menuusername" type="text" name="username" size="20" maxlength="100" />';
|
||||
echo '<input type="text" name="username" size="20" maxlength="100" />';
|
||||
|
||||
// choose a remote host
|
||||
echo " " . html_writer::label(get_string('remotehost', 'mnet'), 'menumnet_host_id') . ":\n";
|
||||
echo " " . get_string('remotehost', 'mnet') . ":\n";
|
||||
if (!empty($formerror['mnet_host_id'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
echo html_writer::select($mnethosts, 'mnet_host_id');
|
||||
|
||||
// choose an access level
|
||||
echo " " . html_writer::label(get_string('accesslevel', 'mnet'), 'menuaccessctrl') . ":\n";
|
||||
echo " " . get_string('accesslevel', 'mnet') . ":\n";
|
||||
if (!empty($formerror['accessctrl'])) {
|
||||
echo '<span class="error"> * </span>';
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ $hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$mnet = get_mnet_environment();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
require_login();
|
||||
admin_externalpage_setup('net');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
+16
-25
@@ -38,10 +38,9 @@ class mnet_simple_host_form extends moodleform {
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', null, 'required', null, 'client');
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
|
||||
$DB->get_records_menu('mnet_application', array(), 'id,display_name'));
|
||||
@@ -50,7 +49,7 @@ class mnet_simple_host_form extends moodleform {
|
||||
$this->add_action_buttons(false, get_string('addhost', 'mnet'));
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
function validation($data) {
|
||||
global $DB;
|
||||
|
||||
$wwwroot = $data['wwwroot'];
|
||||
@@ -82,13 +81,11 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
|
||||
$mform->addElement('text', 'name', get_string('site'));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
$mform->addRule('name', get_string('maximumchars', '', 80), 'maxlength', 80, 'client');
|
||||
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
|
||||
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'));
|
||||
$mform->setType('wwwroot', PARAM_URL);
|
||||
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
$themes = array('' => get_string('forceno'));
|
||||
foreach (array_keys(get_plugin_list('theme')) as $themename) {
|
||||
@@ -98,7 +95,15 @@ class mnet_review_host_form extends moodleform {
|
||||
|
||||
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
|
||||
$mform->setType('public_key', PARAM_PEM);
|
||||
$mform->addRule('public_key', get_string('required'), 'required');
|
||||
|
||||
if ($mnet_peer && !empty($mnet_peer->deleted)) {
|
||||
$radioarray = array();
|
||||
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
|
||||
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
}
|
||||
|
||||
// finished with form controls, now the static informational stuff
|
||||
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
|
||||
@@ -135,35 +140,21 @@ class mnet_review_host_form extends moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'),
|
||||
$OUTPUT->box('<pre>' . $credstr . '</pre>', 'generalbox certdetails'));
|
||||
}
|
||||
|
||||
if ($mnet_peer && !empty($mnet_peer->deleted)) {
|
||||
$radioarray = array();
|
||||
$radioarray[] = $mform->createElement('static', 'deletedinfo', '',
|
||||
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('yes'), 1);
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('no'), 0);
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'), $OUTPUT->box('<pre>' . $credstr . '</pre>'));
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
$this->add_action_buttons(false);
|
||||
}
|
||||
|
||||
function validation($data, $files) {
|
||||
function validation($data) {
|
||||
$errors = array();
|
||||
if ($data['oldpublickey'] == $data['public_key']) {
|
||||
return;
|
||||
}
|
||||
$mnet_peer = new mnet_peer(); // idiotic api
|
||||
$mnet_peer->wwwroot = $data['wwwroot']; // just hard-set this rather than bootstrap the object
|
||||
if (empty($data['public_key'])) {
|
||||
$errors['public_key'] = get_string('publickeyrequired', 'mnet');
|
||||
} else if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
|
||||
if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
|
||||
$errmsg = '';
|
||||
foreach ($mnet_peer->error as $err) {
|
||||
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
|
||||
|
||||
+6
-21
@@ -30,11 +30,11 @@
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/mnet/lib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/mnet/peer_forms.php');
|
||||
require_once($CFG->dirroot.'/admin/mnet/peer_forms.php');
|
||||
|
||||
require_login();
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
|
||||
/// Initialize variables.
|
||||
@@ -190,7 +190,7 @@ if ($formdata = $reviewform->get_data()) {
|
||||
|
||||
// normal flow - just display all hosts with links
|
||||
echo $OUTPUT->header();
|
||||
$hosts = mnet_get_hosts(true);
|
||||
$hosts = mnet_get_hosts();
|
||||
|
||||
// print the table to display the register all hosts setting
|
||||
$table = new html_table();
|
||||
@@ -231,43 +231,28 @@ $table->head = array(
|
||||
);
|
||||
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
|
||||
$baseurl = new moodle_url('/admin/mnet/peers.php');
|
||||
$deleted = array();
|
||||
foreach($hosts as $host) {
|
||||
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
|
||||
if (trim($host->name) === '') {
|
||||
// should not happen but...
|
||||
$host->name = '???';
|
||||
}
|
||||
// process all hosts first since it's the easiest
|
||||
if ($host->id == $CFG->mnet_all_hosts_id) {
|
||||
$table->data[] = array(html_writer::link($hosturl, get_string('allhosts', 'core_mnet')), '*', '', '');
|
||||
continue;
|
||||
}
|
||||
|
||||
// populate the list of deleted hosts
|
||||
if ($host->deleted) {
|
||||
$deleted[] = html_writer::link($hosturl, $host->name);
|
||||
$table->data[] = array(html_writer::tag('a', $host->name, array('href'=>$hosturl)), '', '', '');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($host->last_connect_time == 0) {
|
||||
$last_connect = get_string('never');
|
||||
} else {
|
||||
$last_connect = userdate($host->last_connect_time, get_string('strftimedatetime', 'core_langconfig'));
|
||||
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
|
||||
}
|
||||
$table->data[] = array(
|
||||
html_writer::link($hosturl, $host->name),
|
||||
html_writer::link($host->wwwroot, $host->wwwroot),
|
||||
html_writer::link($hosturl, $host->wwwroot),
|
||||
$last_connect,
|
||||
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
|
||||
);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
|
||||
if ($deleted) {
|
||||
echo $OUTPUT->box(get_string('deletedhosts', 'core_mnet', join(', ', $deleted)), 'deletedhosts');
|
||||
}
|
||||
|
||||
// finally, print the initial form to add a new host
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
|
||||
|
||||
@@ -34,7 +34,7 @@ $hostid = required_param('hostid', PARAM_INT);
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
@@ -39,15 +39,6 @@ class mnet_profile_form extends moodleform {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mnetprofileimportfields = '';
|
||||
if (isset($CFG->mnetprofileimportfields)) {
|
||||
$mnetprofileimportfields = str_replace(',', ', ', $CFG->mnetprofileimportfields);
|
||||
}
|
||||
|
||||
$mnetprofileexportfields = '';
|
||||
if (isset($CFG->mnetprofileexportfields)) {
|
||||
$mnetprofileexportfields = str_replace(',', ', ', $CFG->mnetprofileexportfields);
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$fields = mnet_profile_field_options();
|
||||
@@ -58,7 +49,7 @@ class mnet_profile_form extends moodleform {
|
||||
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), $mnetprofileimportfields);
|
||||
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileimportfields));
|
||||
|
||||
// Fields to export ----------------------------------------------------
|
||||
$mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
|
||||
@@ -66,7 +57,7 @@ class mnet_profile_form extends moodleform {
|
||||
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), $mnetprofileexportfields);
|
||||
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileexportfields));
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ $mnet = get_mnet_environment();
|
||||
require_login();
|
||||
admin_externalpage_setup('mnetpeers');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
|
||||
@@ -36,7 +36,7 @@ class mnet_services_form extends moodleform {
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$mnet_peer =& $this->_customdata['peer'];
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
$myservices =& mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ $strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'/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';
|
||||
|
||||
@@ -24,7 +24,7 @@ if ($CFG->mnet_dispatcher_mode === 'off') {
|
||||
require_login();
|
||||
admin_externalpage_setup('mnettestclient');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
error_reporting(DEBUG_ALL);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
require_login();
|
||||
admin_externalpage_setup('trustedhosts');
|
||||
|
||||
$context = context_system::instance();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
|
||||
|
||||
|
||||
+5
-6
@@ -11,9 +11,9 @@
|
||||
|
||||
admin_externalpage_setup('managemodules');
|
||||
|
||||
$show = optional_param('show', '', PARAM_PLUGIN);
|
||||
$hide = optional_param('hide', '', PARAM_PLUGIN);
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$show = optional_param('show', '', PARAM_SAFEDIR);
|
||||
$hide = optional_param('hide', '', PARAM_SAFEDIR);
|
||||
$delete = optional_param('delete', '', PARAM_SAFEDIR);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
}
|
||||
|
||||
uninstall_plugin('mod', $delete);
|
||||
$a = new stdClass();
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
|
||||
@@ -161,11 +160,11 @@
|
||||
$class = '';
|
||||
} else if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=".sesskey()."\" title=\"$strhide\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('t/hide') . "\" class=\"iconsmall\" alt=\"$strhide\" /></a>";
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/hide') . "\" class=\"icon\" alt=\"$strhide\" /></a>";
|
||||
$class = '';
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=".sesskey()."\" title=\"$strshow\">".
|
||||
"<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>";
|
||||
"<img src=\"" . $OUTPUT->pix_url('i/show') . "\" class=\"icon\" alt=\"$strshow\" /></a>";
|
||||
$class = ' class="dimmed_text"';
|
||||
}
|
||||
if ($module->name == "forum") {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
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);
|
||||
|
||||
###################################################################
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->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());
|
||||
echo $OUTPUT->confirm($strmultilangupgrade, new moodle_url('multilangupgrade.php', $optionsyes), 'index.php');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
if (!$tables = $DB->get_tables() ) { // No tables yet at all.
|
||||
print_error('notables', 'debug');
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
/// Turn off time limits, sometimes upgrades can be slow.
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
echo '<strong>Progress:</strong>';
|
||||
$i = 0;
|
||||
$skiptables = array('config', 'user_students', 'user_teachers');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (strpos($table,'pma') === 0) { // Not our tables
|
||||
continue;
|
||||
}
|
||||
if (in_array($table, $skiptables)) { // Don't process these
|
||||
continue;
|
||||
}
|
||||
$fulltable = $DB->get_prefix().$table;
|
||||
if ($columns = $DB->get_columns($table)) {
|
||||
if (!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
|
||||
$sql = "SELECT id, $column FROM $fulltable WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $data) {
|
||||
$text = $data->$column;
|
||||
$id = $data->id;
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
if ($i % 10 == 0) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
|
||||
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) {
|
||||
$DB->execute("UPDATE $fulltable SET $column=? WHERE id=?", array($newtext, $id));
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set conversion flag - switches to new plugin automatically
|
||||
set_config('filter_multilang_converted', 1);
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
|
||||
echo $OUTPUT->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;
|
||||
}
|
||||
|
||||
+6
-24
@@ -42,36 +42,20 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
|
||||
/// get a list of all courses on this site
|
||||
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
|
||||
$courses = $DB->get_records_sql($sql);
|
||||
$courses = $DB->get_records('course');
|
||||
|
||||
/// cycle through each course
|
||||
foreach ($courses as $course) {
|
||||
context_instance_preload($course);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
if (empty($course->fullname)) {
|
||||
$fullname = get_string('course').': '.$course->id;
|
||||
} else {
|
||||
$fullname = format_string($course->fullname, true, array('context' => $context));
|
||||
}
|
||||
$fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
|
||||
if ($output) echo $OUTPUT->heading($fullname);
|
||||
|
||||
/// retrieve a list of sections beyond what is currently being shown
|
||||
$courseformatoptions = course_get_format($course)->get_format_options();
|
||||
if (!isset($courseformatoptions['numsections'])) {
|
||||
// Course format does not use numsections
|
||||
if ($output) {
|
||||
echo 'No extra sections<br />';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$sql = "SELECT *
|
||||
FROM {course_sections}
|
||||
WHERE course=? AND section>?
|
||||
ORDER BY section ASC";
|
||||
$params = array($course->id, $courseformatoptions['numsections']);
|
||||
$params = array($course->id, $course->numsections);
|
||||
if (!($xsections = $DB->get_records_sql($sql, $params))) {
|
||||
if ($output) echo 'No extra sections<br />';
|
||||
continue;
|
||||
@@ -102,7 +86,7 @@ function online_assignment_cleanup($output=false) {
|
||||
/// the journal update erroneously stored it in course_sections->section
|
||||
$newsection = $xsection->section;
|
||||
/// double check the new section
|
||||
if ($newsection > $courseformatoptions['numsections']) {
|
||||
if ($newsection > $course->numsections) {
|
||||
/// get the record for section 0 for this course
|
||||
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
|
||||
continue;
|
||||
@@ -112,9 +96,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
/// grab the section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
|
||||
if ($output) {
|
||||
echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'<br />';
|
||||
}
|
||||
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -135,7 +117,7 @@ function online_assignment_cleanup($output=false) {
|
||||
|
||||
/// grab the old section record
|
||||
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'<br />';
|
||||
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'<br />';
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* An oauth2 redirection endpoint which can be used for an application:
|
||||
* http://tools.ietf.org/html/draft-ietf-oauth-v2-26#section-3.1.2
|
||||
*
|
||||
* This is used because some oauth servers will not allow a redirect urls
|
||||
* with get params (like repository callback) and that needs to be called
|
||||
* using the state param.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2012 Dan Poltawski
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/config.php');
|
||||
|
||||
// The authorization code generated by the authorization server.
|
||||
$code = required_param('code', PARAM_RAW);
|
||||
// The state parameter we've given (used in moodle as a redirect url).
|
||||
$state = required_param('state', PARAM_LOCALURL);
|
||||
|
||||
$redirecturl = new moodle_url($state);
|
||||
$params = $redirecturl->params();
|
||||
|
||||
if (isset($params['sesskey']) and confirm_sesskey($params['sesskey'])) {
|
||||
$redirecturl->param('oauth2code', $code);
|
||||
redirect($redirecturl);
|
||||
} else {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides an overview of installed plagiarism plugins
|
||||
*
|
||||
* Displays the list of found plagiarism plugins, their version (if found) and
|
||||
* a link to delete the plagiarism plugin.
|
||||
*
|
||||
* @see http://docs.moodle.org/dev/Plagiarism_API
|
||||
* @package admin
|
||||
* @copyright 2012 Dan Marsden <dan@danmarsden.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
admin_externalpage_setup('manageplagiarismplugins');
|
||||
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) { // If data submitted, then process and store.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageplagiarism', 'plagiarism'));
|
||||
|
||||
if (!$confirm) {
|
||||
if (get_string_manager()->string_exists('pluginname', 'plagiarism_' . $delete)) {
|
||||
$strpluginname = get_string('pluginname', 'plagiarism_' . $delete);
|
||||
} else {
|
||||
$strpluginname = $delete;
|
||||
}
|
||||
echo $OUTPUT->confirm(get_string('plagiarismplugindeleteconfirm', 'plagiarism', $strpluginname),
|
||||
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
|
||||
$PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
uninstall_plugin('plagiarism', $delete);
|
||||
$a = new stdclass();
|
||||
$a->name = $delete;
|
||||
$pluginlocation = get_plugin_types();
|
||||
$a->directory = $pluginlocation['plagiarism'] . '/' . $delete;
|
||||
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($PAGE->url);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print the table of all installed plagiarism plugins.
|
||||
|
||||
$txt = get_strings(array('settings', 'name', 'version', 'delete'));
|
||||
|
||||
$plagiarismplugins = get_plugin_list('plagiarism');
|
||||
if (empty($plagiarismplugins)) {
|
||||
echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
|
||||
echo $OUTPUT->box_start('generalbox authsui');
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array($txt->name, $txt->version, $txt->delete, $txt->settings);
|
||||
$table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'manageplagiarismtable generaltable';
|
||||
|
||||
// Iterate through auth plugins and add to the display table.
|
||||
$authcount = count($plagiarismplugins);
|
||||
foreach ($plagiarismplugins as $plugin => $dir) {
|
||||
if (file_exists($dir.'/settings.php')) {
|
||||
$displayname = "<span>".get_string($plugin, 'plagiarism_'.$plugin)."</span>";
|
||||
// Settings link.
|
||||
$url = new moodle_url("/plagiarism/$plugin/settings.php");
|
||||
$settings = html_writer::link($url, $txt->settings);
|
||||
// Get version.
|
||||
$version = get_config('plagiarism_' . $plugin);
|
||||
if (!empty($version->version)) {
|
||||
$version = $version->version;
|
||||
} else {
|
||||
$version = '?';
|
||||
}
|
||||
// Delete link.
|
||||
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
|
||||
$delete = html_writer::link($delete, get_string('delete'));
|
||||
$table->data[] = array($displayname, $version, $delete, $settings);
|
||||
}
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
echo get_string('configplagiarismplugins', 'plagiarism');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* UI for general plugins management
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
|
||||
$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
|
||||
$contribonly = optional_param('contribonly', false, PARAM_BOOL);
|
||||
|
||||
$pluginman = plugin_manager::instance();
|
||||
$checker = available_update_checker::instance();
|
||||
|
||||
// Filtering options.
|
||||
$options = array(
|
||||
'updatesonly' => $updatesonly,
|
||||
'contribonly' => $contribonly,
|
||||
);
|
||||
|
||||
if ($fetchremote) {
|
||||
require_sesskey();
|
||||
$checker->fetch();
|
||||
redirect(new moodle_url($PAGE->url, $options));
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
|
||||
$deployer->initialize($myurl, $myurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
echo $output->plugin_management_page($pluginman, $checker, $options);
|
||||
+2
-4
@@ -5,7 +5,7 @@ require_once($CFG->libdir . '/portfoliolib.php');
|
||||
require_once($CFG->libdir . '/portfolio/forms.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$portfolio = optional_param('pf', '', PARAM_ALPHANUMEXT);
|
||||
$portfolio = optional_param('pf', '', PARAM_FORMAT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$sure = optional_param('sure', '', PARAM_ALPHA);
|
||||
|
||||
@@ -35,7 +35,7 @@ if ($action == 'newon') {
|
||||
|
||||
admin_externalpage_setup($pagename);
|
||||
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$baseurl = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
||||
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/portfolio.php?sesskey=" . sesskey();
|
||||
@@ -197,7 +197,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$currentaction = 'hide';
|
||||
}
|
||||
$select = new single_select(portfolio_action_url($pluginid, 'pf'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . $pluginid);
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$table->data[] = array($pluginname, $OUTPUT->render($select), $settings);
|
||||
}
|
||||
if (!in_array($plugin, $usedplugins)) {
|
||||
@@ -219,7 +218,6 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$insaneplugins[] = $p;
|
||||
} else {
|
||||
$select = new single_select(portfolio_action_url($p, 'pf'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . $p);
|
||||
$select->set_label(get_string('action'), array('class' => 'accesshide'));
|
||||
$table->data[] = array(portfolio_static_function($p, 'get_name'), $OUTPUT->render($select), '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
admin_externalpage_setup('purgecaches');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ($confirm) {
|
||||
require_sesskey();
|
||||
|
||||
@@ -1,302 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to manage question behaviours.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage questionengine
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('manageqbehaviours');
|
||||
$thispageurl = new moodle_url('/admin/qbehaviours.php');
|
||||
|
||||
$behaviours = get_plugin_list('qbehaviour');
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql_menu("
|
||||
SELECT behaviour, COUNT(1)
|
||||
FROM {question_attempts} GROUP BY behaviour");
|
||||
$needed = array();
|
||||
$archetypal = array();
|
||||
foreach ($behaviours as $behaviour => $notused) {
|
||||
if (!array_key_exists($behaviour, $counts)) {
|
||||
$counts[$behaviour] = 0;
|
||||
}
|
||||
$needed[$behaviour] = ($counts[$behaviour] > 0) ||
|
||||
$pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour);
|
||||
$archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour);
|
||||
}
|
||||
foreach ($counts as $behaviour => $count) {
|
||||
if (!array_key_exists($behaviour, $behaviours)) {
|
||||
$counts['missing'] += $count;
|
||||
}
|
||||
}
|
||||
$needed['missing'] = true;
|
||||
|
||||
// Work of the correct sort order.
|
||||
$config = get_config('question');
|
||||
$sortedbehaviours = array();
|
||||
foreach ($behaviours as $behaviour => $notused) {
|
||||
$sortedbehaviours[$behaviour] = question_engine::get_behaviour_name($behaviour);
|
||||
}
|
||||
if (!empty($config->behavioursortorder)) {
|
||||
$sortedbehaviours = question_engine::sort_behaviours($sortedbehaviours,
|
||||
$config->behavioursortorder, '');
|
||||
}
|
||||
|
||||
if (!empty($config->disabledbehaviours)) {
|
||||
$disabledbehaviours = explode(',', $config->disabledbehaviours);
|
||||
} else {
|
||||
$disabledbehaviours = array();
|
||||
}
|
||||
|
||||
// Process actions ============================================================
|
||||
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$disable])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $disable);
|
||||
}
|
||||
|
||||
if (array_search($disable, $disabledbehaviours) === false) {
|
||||
$disabledbehaviours[] = $disable;
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$enable])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
if (!$archetypal[$enable]) {
|
||||
print_error('cannotenablebehaviour', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
if (($key = array_search($enable, $disabledbehaviours)) !== false) {
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$up])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $up);
|
||||
}
|
||||
|
||||
// This function works fine for behaviours, as well as qtypes.
|
||||
$neworder = question_reorder_qtypes($sortedbehaviours, $up, -1);
|
||||
set_config('behavioursortorder', implode(',', $neworder), 'question');
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$down])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $down);
|
||||
}
|
||||
|
||||
// This function works fine for behaviours, as well as qtypes.
|
||||
$neworder = question_reorder_qtypes($sortedbehaviours, $down, +1);
|
||||
set_config('behavioursortorder', implode(',', $neworder), 'question');
|
||||
redirect($thispageurl);
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missing') {
|
||||
print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
|
||||
}
|
||||
|
||||
if (!isset($behaviours[$delete])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $delete);
|
||||
}
|
||||
|
||||
$behaviourname = $sortedbehaviours[$delete];
|
||||
if ($counts[$delete] > 0) {
|
||||
print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
|
||||
echo $OUTPUT->confirm(
|
||||
get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
|
||||
}
|
||||
if (($key = array_search($delete, $disabledbehaviours)) !== false) {
|
||||
unset($disabledbehaviours[$key]);
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
$behaviourorder = array_keys($sortedbehaviours);
|
||||
if (($key = array_search($delete, $behaviourorder)) !== false) {
|
||||
unset($behaviourorder[$key]);
|
||||
set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qbehaviour_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->behaviour = $behaviourname;
|
||||
$a->directory = get_plugin_directory('qbehaviour', $delete);
|
||||
echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
|
||||
|
||||
// Set up the table.
|
||||
$table = new flexible_table('qbehaviouradmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
|
||||
'available', 'delete'));
|
||||
$table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'),
|
||||
get_string('availableq', 'question'), get_string('delete')));
|
||||
$table->set_attribute('id', 'qbehaviours');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
foreach ($sortedbehaviours as $behaviour => $behaviourname) {
|
||||
$row = array();
|
||||
|
||||
// Question icon and name.
|
||||
$row[] = $behaviourname;
|
||||
|
||||
// Count
|
||||
$row[] = $counts[$behaviour];
|
||||
|
||||
// Question version number.
|
||||
$version = get_config('qbehaviour_' . $behaviour, 'version');
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
$plugin = $pluginmanager->get_plugin_info('qbehaviour_' . $behaviour);
|
||||
$required = $plugin->get_other_required_plugins();
|
||||
if (!empty($required)) {
|
||||
$strrequired = array();
|
||||
foreach ($required as $component => $notused) {
|
||||
$strrequired[] = $pluginmanager->plugin_name($component);
|
||||
}
|
||||
$row[] = implode(', ', $strrequired);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Are people allowed to select this behaviour?
|
||||
$rowclass = '';
|
||||
if ($archetypal[$behaviour]) {
|
||||
$enabled = array_search($behaviour, $disabledbehaviours) === false;
|
||||
$icons = question_behaviour_enable_disable_icons($behaviour, $enabled);
|
||||
if (!$enabled) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = $OUTPUT->spacer(array('class' => 'iconsmall'));
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
$icons .= question_behaviour_icon_html('up', $behaviour, 't/up', get_string('up'), null);
|
||||
$icons .= question_behaviour_icon_html('down', $behaviour, 't/down', get_string('down'), null);
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$behaviour]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallbehaviour', 'question')));
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
|
||||
$table->finish_output();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function question_behaviour_enable_disable_icons($behaviour, $enabled) {
|
||||
if ($enabled) {
|
||||
return question_behaviour_icon_html('disable', $behaviour, 't/hide',
|
||||
get_string('enabled', 'question'), get_string('disable'));
|
||||
} else {
|
||||
return question_behaviour_icon_html('enable', $behaviour, 't/show',
|
||||
get_string('disabled', 'question'), get_string('enable'));
|
||||
}
|
||||
}
|
||||
|
||||
function question_behaviour_icon_html($action, $behaviour, $icon, $alt, $tip) {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->action_icon(new moodle_url('/admin/qbehaviours.php',
|
||||
array($action => $behaviour, 'sesskey' => sesskey())),
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
null, array('title' => $tip));
|
||||
}
|
||||
|
||||
+247
-266
@@ -1,312 +1,293 @@
|
||||
<?php
|
||||
// Allows the admin to manage question types.
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
/**
|
||||
* Allows the admin to manage question types.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage questionbank
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
/// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('manageqtypes');
|
||||
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('moodle/question:config', $systemcontext);
|
||||
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
|
||||
|
||||
admin_externalpage_setup('manageqtypes');
|
||||
$thispageurl = new moodle_url('/admin/qtypes.php');
|
||||
|
||||
$qtypes = question_bank::get_all_qtypes();
|
||||
$pluginmanager = plugin_manager::instance();
|
||||
|
||||
// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql("
|
||||
SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
|
||||
FROM {question} GROUP BY qtype", array());
|
||||
$needed = array();
|
||||
foreach ($qtypes as $qtypename => $qtype) {
|
||||
if (!isset($counts[$qtypename])) {
|
||||
$counts[$qtypename] = new stdClass;
|
||||
$counts[$qtypename]->numquestions = 0;
|
||||
$counts[$qtypename]->numhidden = 0;
|
||||
/// Get some data we will need - question counts and which types are needed.
|
||||
$counts = $DB->get_records_sql("
|
||||
SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
|
||||
FROM {question} GROUP BY qtype", array());
|
||||
$needed = array();
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
if (!isset($counts[$qtypename])) {
|
||||
$counts[$qtypename] = new stdClass;
|
||||
$counts[$qtypename]->numquestions = 0;
|
||||
$counts[$qtypename]->numhidden = 0;
|
||||
}
|
||||
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
|
||||
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
|
||||
}
|
||||
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0 ||
|
||||
$pluginmanager->other_plugins_that_require($qtype->plugin_name());
|
||||
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
|
||||
}
|
||||
$needed['missingtype'] = true; // The system needs the missing question type.
|
||||
foreach ($counts as $qtypename => $count) {
|
||||
if (!isset($qtypes[$qtypename])) {
|
||||
$counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
|
||||
$counts['missingtype']->numhidden += $count->numhidden;
|
||||
$needed['missingtype'] = true; // The system needs the missing question type.
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
foreach ($qtype->requires_qtypes() as $reqtype) {
|
||||
$needed[$reqtype] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Work of the correct sort order.
|
||||
$config = get_config('question');
|
||||
$sortedqtypes = array();
|
||||
foreach ($qtypes as $qtypename => $qtype) {
|
||||
$sortedqtypes[$qtypename] = $qtype->local_name();
|
||||
}
|
||||
$sortedqtypes = question_bank::sort_qtype_array($sortedqtypes, $config);
|
||||
|
||||
// Process actions ============================================================
|
||||
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$disable])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $disable);
|
||||
foreach ($counts as $qtypename => $count) {
|
||||
if (!isset($QTYPES[$qtypename])) {
|
||||
$counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
|
||||
$counts['missingtype']->numhidden += $count->numhidden;
|
||||
}
|
||||
}
|
||||
|
||||
set_config($disable . '_disabled', 1, 'question');
|
||||
redirect($thispageurl);
|
||||
}
|
||||
/// Work of the correct sort order.
|
||||
$config = get_config('question');
|
||||
$sortedqtypes = array();
|
||||
foreach ($QTYPES as $qtypename => $qtype) {
|
||||
$sortedqtypes[$qtypename] = $qtype->local_name();
|
||||
}
|
||||
$sortedqtypes = question_sort_qtype_array($sortedqtypes, $config);
|
||||
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$enable])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $enable);
|
||||
/// Process actions ============================================================
|
||||
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$disable])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $disable);
|
||||
}
|
||||
|
||||
set_config($disable . '_disabled', 1, 'question');
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
if (!$qtypes[$enable]->menu_name()) {
|
||||
print_error('cannotenable', 'question', $thispageurl, $enable);
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$enable])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $enable);
|
||||
}
|
||||
|
||||
if (!$QTYPES[$enable]->menu_name()) {
|
||||
print_error('cannotenable', 'question', admin_url('qtypes.php'), $enable);
|
||||
}
|
||||
|
||||
unset_config($enable . '_disabled', 'question');
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
unset_config($enable . '_disabled', 'question');
|
||||
redirect($thispageurl);
|
||||
}
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$up])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $up);
|
||||
}
|
||||
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$up])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $up);
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect($thispageurl);
|
||||
}
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
if (!isset($QTYPES[$down])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $down);
|
||||
}
|
||||
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$down])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $down);
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect(admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
|
||||
question_save_qtype_order($neworder, $config);
|
||||
redirect($thispageurl);
|
||||
}
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missingtype') {
|
||||
print_error('cannotdeletemissingqtype', 'admin', admin_url('qtypes.php'));
|
||||
}
|
||||
|
||||
// Delete.
|
||||
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Check it is OK to delete this question type.
|
||||
if ($delete == 'missingtype') {
|
||||
print_error('cannotdeletemissingqtype', 'question', $thispageurl);
|
||||
}
|
||||
if (!isset($QTYPES[$delete])) {
|
||||
print_error('unknownquestiontype', 'question', admin_url('qtypes.php'), $delete);
|
||||
}
|
||||
|
||||
if (!isset($qtypes[$delete])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $delete);
|
||||
}
|
||||
$qtypename = $QTYPES[$delete]->local_name();
|
||||
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
|
||||
print_error('cannotdeleteqtypeinuse', 'admin', admin_url('qtypes.php'), $qtypename);
|
||||
}
|
||||
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
|
||||
print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteqtypeneeded', 'admin', admin_url('qtypes.php'), $qtypename);
|
||||
}
|
||||
|
||||
if ($needed[$delete] > 0) {
|
||||
print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
|
||||
}
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$qtypename = $QTYPES[$delete]->local_name();
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'admin', $qtypename));
|
||||
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'admin', $qtypename),
|
||||
admin_url('qtypes.php?delete=' . $delete . '&confirm=1'),
|
||||
admin_url('qtypes.php'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$qtypename = $qtypes[$delete]->local_name();
|
||||
// Do the deletion.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
|
||||
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
|
||||
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
|
||||
$thispageurl);
|
||||
echo $OUTPUT->heading(get_string('deletingqtype', 'admin', $qtypename));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
|
||||
}
|
||||
unset_config($delete . '_disabled', 'question');
|
||||
unset_config($delete . '_sortorder', 'question');
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, $QTYPES[$delete]->plugin_dir() . '/db/install.xml', false);
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qtype/' . $delete);
|
||||
|
||||
$a->qtype = $qtypename;
|
||||
$a->directory = $QTYPES[$delete]->plugin_dir();
|
||||
echo $OUTPUT->box(get_string('qtypedeletefiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button(admin_url('qtypes.php'));
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
// End of process actions ==================================================
|
||||
|
||||
/// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
|
||||
echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
|
||||
|
||||
// Delete any configuration records.
|
||||
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
|
||||
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
|
||||
/// Set up the table.
|
||||
$table = new flexible_table('qtypeadmintable');
|
||||
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
|
||||
'availableto', 'delete', 'settings'));
|
||||
$table->define_headers(array(get_string('questiontype', 'admin'), get_string('numquestions', 'admin'),
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
/// Add a row for each question type.
|
||||
$createabletypes = question_type_menu();
|
||||
foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$qtype = $QTYPES[$qtypename];
|
||||
$row = array();
|
||||
|
||||
// Question icon and name.
|
||||
$fakequestion = new stdClass;
|
||||
$fakequestion->qtype = $qtypename;
|
||||
$icon = print_question_icon($fakequestion, true);
|
||||
$row[] = $icon . ' ' . $localname;
|
||||
|
||||
// Number of questions of this type.
|
||||
if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
|
||||
if ($counts[$qtypename]->numhidden > 0) {
|
||||
$strcount = get_string('numquestionsandhidden', 'admin', $counts[$qtypename]);
|
||||
} else {
|
||||
$strcount = $counts[$qtypename]->numquestions;
|
||||
}
|
||||
if ($canviewreports) {
|
||||
$row[] = '<a href="' . admin_url('/report/questioninstances/index.php?qtype=' . $qtypename) .
|
||||
'" title="' . get_string('showdetails', 'admin') . '">' . $strcount . '</a>';
|
||||
} else {
|
||||
$strcount;
|
||||
}
|
||||
} else {
|
||||
$row[] = 0;
|
||||
}
|
||||
|
||||
// Question version number.
|
||||
$version = get_config('qtype_' . $qtypename, 'version');
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = '<span class="disabled">' . get_string('nodatabase', 'admin') . '</span>';
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
$requiredtypes = $qtype->requires_qtypes();
|
||||
$strtypes = array();
|
||||
if (!empty($requiredtypes)) {
|
||||
foreach ($requiredtypes as $required) {
|
||||
$strtypes[] = $QTYPES[$required]->local_name();
|
||||
}
|
||||
$row[] = implode(', ', $strtypes);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Are people allowed to create new questions of this type?
|
||||
$rowclass = '';
|
||||
if ($qtype->menu_name()) {
|
||||
$createable = isset($createabletypes[$qtypename]);
|
||||
$icons = enable_disable_button($qtypename, $createable);
|
||||
if (!$createable) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = '<img src="' . $OUTPUT->pix_url('spacer') . '" alt="" class="spacer" />';
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
$icons .= icon_html('up', $qtypename, 't/up', get_string('up'), '');
|
||||
$icons .= icon_html('down', $qtypename, 't/down', get_string('down'), '');
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = '<a href="' . admin_url('qtypes.php?delete=' . $qtypename .
|
||||
'&sesskey=' . sesskey()) . '" title="' .
|
||||
get_string('uninstallqtype', 'admin') . '">' . get_string('delete') . '</a>';
|
||||
}
|
||||
|
||||
// Settings link, if available.
|
||||
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
|
||||
if ($settings instanceof admin_externalpage) {
|
||||
$row[] = '<a href="' . $settings->url .
|
||||
'">' . get_string('settings') . '</a>';
|
||||
} else if ($settings instanceof admin_settingpage) {
|
||||
$row[] = '<a href="' . admin_url('settings.php?section=qtypesetting' . $qtypename) .
|
||||
'">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
unset_config($delete . '_disabled', 'question');
|
||||
unset_config($delete . '_sortorder', 'question');
|
||||
|
||||
// Then the tables themselves
|
||||
drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
|
||||
$table->finish_output();
|
||||
|
||||
// Remove event handlers and dequeue pending events
|
||||
events_uninstall('qtype_' . $delete);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->qtype = $qtypename;
|
||||
$a->directory = $qtypes[$delete]->plugin_dir();
|
||||
echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($thispageurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
function admin_url($endbit) {
|
||||
global $CFG;
|
||||
return $CFG->wwwroot . '/' . $CFG->admin . '/' . $endbit;
|
||||
}
|
||||
|
||||
// End of process actions ==================================================
|
||||
|
||||
// Print the page heading.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
|
||||
|
||||
// Set up the table.
|
||||
$table = new flexible_table('qtypeadmintable');
|
||||
$table->define_baseurl($thispageurl);
|
||||
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
|
||||
'availableto', 'delete', 'settings'));
|
||||
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
$createabletypes = question_bank::get_creatable_qtypes();
|
||||
foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
$qtype = $qtypes[$qtypename];
|
||||
$row = array();
|
||||
|
||||
// Question icon and name.
|
||||
$fakequestion = new stdClass;
|
||||
$fakequestion->qtype = $qtypename;
|
||||
$icon = print_question_icon($fakequestion, true);
|
||||
$row[] = $icon . ' ' . $localname;
|
||||
|
||||
// Number of questions of this type.
|
||||
if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
|
||||
if ($counts[$qtypename]->numhidden > 0) {
|
||||
$strcount = get_string('numquestionsandhidden', 'question', $counts[$qtypename]);
|
||||
} else {
|
||||
$strcount = $counts[$qtypename]->numquestions;
|
||||
}
|
||||
if ($canviewreports) {
|
||||
$row[] = html_writer::link(new moodle_url('/report/questioninstances/index.php',
|
||||
array('qtype' => $qtypename)), $strcount, array('title' => get_string('showdetails', 'admin')));
|
||||
} else {
|
||||
$strcount;
|
||||
}
|
||||
} else {
|
||||
$row[] = 0;
|
||||
}
|
||||
|
||||
// Question version number.
|
||||
$version = get_config('qtype_' . $qtypename, 'version');
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
$plugin = $pluginmanager->get_plugin_info($qtype->plugin_name());
|
||||
$requiredtypes = $plugin->get_other_required_plugins();
|
||||
$strtypes = array();
|
||||
if (!empty($requiredtypes)) {
|
||||
foreach ($requiredtypes as $required => $notused) {
|
||||
$strtypes[] = $pluginmanager->plugin_name($required);
|
||||
}
|
||||
$row[] = implode(', ', $strtypes);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Are people allowed to create new questions of this type?
|
||||
$rowclass = '';
|
||||
if ($qtype->menu_name()) {
|
||||
$createable = isset($createabletypes[$qtypename]);
|
||||
$icons = question_types_enable_disable_icons($qtypename, $createable);
|
||||
if (!$createable) {
|
||||
$rowclass = 'dimmed_text';
|
||||
}
|
||||
} else {
|
||||
$icons = $OUTPUT->spacer();
|
||||
}
|
||||
|
||||
// Move icons.
|
||||
$icons .= question_type_icon_html('up', $qtypename, 't/up', get_string('up'), '');
|
||||
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
|
||||
$row[] = $icons;
|
||||
|
||||
// Delete link, if available.
|
||||
if ($needed[$qtypename]) {
|
||||
$row[] = '';
|
||||
} else {
|
||||
$row[] = html_writer::link(new moodle_url($thispageurl,
|
||||
array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
|
||||
array('title' => get_string('uninstallqtype', 'question')));
|
||||
}
|
||||
|
||||
// Settings link, if available.
|
||||
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
|
||||
if ($settings instanceof admin_externalpage) {
|
||||
$row[] = html_writer::link($settings->url, get_string('settings'));
|
||||
} else if ($settings instanceof admin_settingpage) {
|
||||
$row[] = html_writer::link(new moodle_url('/admin/settings.php',
|
||||
array('section' => 'qtypesetting' . $qtypename)), get_string('settings'));
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
$table->add_data($row, $rowclass);
|
||||
}
|
||||
|
||||
$table->finish_output();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function question_types_enable_disable_icons($qtypename, $createable) {
|
||||
function enable_disable_button($qtypename, $createable) {
|
||||
if ($createable) {
|
||||
return question_type_icon_html('disable', $qtypename, 't/hide',
|
||||
get_string('enabled', 'question'), get_string('disable'));
|
||||
return icon_html('disable', $qtypename, 'i/hide', get_string('enabled', 'question'), get_string('disable'));
|
||||
} else {
|
||||
return question_type_icon_html('enable', $qtypename, 't/show',
|
||||
get_string('disabled', 'question'), get_string('enable'));
|
||||
return icon_html('enable', $qtypename, 'i/show', get_string('disabled', 'question'), get_string('enable'));
|
||||
}
|
||||
}
|
||||
|
||||
function question_type_icon_html($action, $qtypename, $icon, $alt, $tip) {
|
||||
function icon_html($action, $qtypename, $icon, $alt, $tip) {
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->action_icon(new moodle_url('/admin/qtypes.php',
|
||||
array($action => $qtypename, 'sesskey' => sesskey())),
|
||||
new pix_icon($icon, $alt, 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
null, array('title' => $tip));
|
||||
if ($tip) {
|
||||
$tip = 'title="' . $tip . '" ';
|
||||
}
|
||||
$html = ' <form action="' . admin_url('qtypes.php') . '" method="post"><div>';
|
||||
$html .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
$html .= '<input type="image" name="' . $action . '" value="' . $qtypename .
|
||||
'" src="' . $OUTPUT->pix_url($icon) . '" alt="' . $alt . '" ' . $tip . '/>';
|
||||
$html .= '</div></form>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ $hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
$token = optional_param('token', '', PARAM_TEXT);
|
||||
$error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
|
||||
admin_externalpage_setup('registrationhubs');
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
if (!empty($error) and $error == 'urlalreadyexist') {
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub',
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
} else {
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ class hub_selector_form extends moodleform {
|
||||
$options = array();
|
||||
foreach ($hubs as $hub) {
|
||||
//to not display a name longer than 100 character (too big)
|
||||
if (textlib::strlen($hub['name']) > 100) {
|
||||
$hubname = textlib::substr($hub['name'], 0, 100);
|
||||
if (strlen($hub['name']) > 100) {
|
||||
$hubname = substr($hub['name'], 0, 100);
|
||||
$hubname = $hubname . "...";
|
||||
} else {
|
||||
$hubname = $hub['name'];
|
||||
@@ -203,7 +203,7 @@ class site_registration_form extends moodleform {
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
|
||||
if ($sitename === false) {
|
||||
$sitename = format_string($site->fullname, true, array('context' => context_course::instance(SITEID)));
|
||||
$sitename = $site->fullname;
|
||||
}
|
||||
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
|
||||
if ($sitedescription === false) {
|
||||
@@ -236,7 +236,6 @@ class site_registration_form extends moodleform {
|
||||
$geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
|
||||
$contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
|
||||
$emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
|
||||
$emailalert = ($emailalert === 0) ? 0 : 1;
|
||||
$coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
|
||||
$usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
|
||||
$roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
|
||||
@@ -280,14 +279,27 @@ class site_registration_form extends moodleform {
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
$mform->addHelpButton('description', 'sitedesc', 'hub');
|
||||
|
||||
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
|
||||
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
|
||||
|
||||
$languages = get_string_manager()->get_list_of_languages();
|
||||
collatorlib::asort($languages);
|
||||
textlib_get_instance()->asort($languages);
|
||||
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
|
||||
$languages);
|
||||
$mform->setType('language', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('language', 'sitelang', 'hub');
|
||||
$mform->setDefault('language', $language);
|
||||
|
||||
$mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
|
||||
$mform->addElement('hidden', 'moodleversion', $CFG->version);
|
||||
$mform->setType('moodleversion', PARAM_INT);
|
||||
$mform->addHelpButton('versionstring', 'siteversion', 'hub');
|
||||
|
||||
$mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
|
||||
$mform->addElement('hidden', 'moodlerelease', $CFG->release);
|
||||
$mform->setType('moodlerelease', PARAM_TEXT);
|
||||
$mform->addHelpButton('releasestring', 'siterelease', 'hub');
|
||||
|
||||
$mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
|
||||
array('rows' => 4, 'cols' => 41));
|
||||
$mform->setType('address', PARAM_TEXT);
|
||||
@@ -348,20 +360,6 @@ class site_registration_form extends moodleform {
|
||||
//TODO site logo
|
||||
$mform->addElement('hidden', 'imageurl', ''); //TODO: temporary
|
||||
$mform->setType('imageurl', PARAM_URL);
|
||||
|
||||
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
|
||||
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
|
||||
|
||||
$mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
|
||||
$mform->addElement('hidden', 'moodleversion', $CFG->version);
|
||||
$mform->setType('moodleversion', PARAM_INT);
|
||||
$mform->addHelpButton('versionstring', 'siteversion', 'hub');
|
||||
|
||||
$mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
|
||||
$mform->addElement('hidden', 'moodlerelease', $CFG->release);
|
||||
$mform->setType('moodlerelease', PARAM_TEXT);
|
||||
$mform->addHelpButton('releasestring', 'siterelease', 'hub');
|
||||
|
||||
/// Display statistic that are going to be retrieve by the hub
|
||||
$coursecount = $DB->count_records('course') - 1;
|
||||
$usercount = $DB->count_records('user', array('deleted' => 0));
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* Thsi page displays a hub selector or a hub URL + password. Then it will redirect to
|
||||
* the site registration form (with the selected hub as parameter)
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/forms.php');
|
||||
|
||||
admin_externalpage_setup('registrationselector');
|
||||
|
||||
$hubselectorform = new hub_selector_form();
|
||||
$fromform = $hubselectorform->get_data();
|
||||
|
||||
//// Redirect to the registration form if an URL has been choosen ////
|
||||
|
||||
$selectedhuburl = optional_param('publichub', false, PARAM_URL);
|
||||
$unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
|
||||
$password = optional_param('password', '', PARAM_RAW);
|
||||
|
||||
if (!empty($unlistedhuburl)) {
|
||||
if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
|
||||
$huburl = $unlistedhuburl;
|
||||
}
|
||||
} else if (!empty($selectedhuburl)) {
|
||||
$huburl = $selectedhuburl;
|
||||
}
|
||||
|
||||
|
||||
//redirect
|
||||
if (!empty($huburl) and confirm_sesskey()) {
|
||||
$hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
|
||||
$params = array('sesskey' => sesskey(), 'huburl' => $huburl,
|
||||
'password' => $password, 'hubname' => $hubname);
|
||||
redirect(new moodle_url($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php",
|
||||
$params));
|
||||
}
|
||||
|
||||
|
||||
//// OUTPUT ////
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
|
||||
$hubselectorform->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -22,9 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* On this page the administrator selects which hub he wants to register,
|
||||
* except for MOOCH. Admins can register with MOOCH with the top admin menu "Registration" link.
|
||||
* On this page the administrator can also unregister from any hubs, including MOOCH.
|
||||
* On this page the administrator select if he wants to register on Moodle.org or
|
||||
* a specific hub
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
@@ -35,7 +34,7 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
|
||||
require_once($CFG->dirroot . '/course/publish/lib.php');
|
||||
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
|
||||
|
||||
admin_externalpage_setup('registrationhubs');
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
|
||||
@@ -127,15 +126,13 @@ if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//do not check sesskey if confirm = false because this script is linked into email message
|
||||
if (!empty($errormessage)) {
|
||||
echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
|
||||
}
|
||||
if (empty($cancel) and $unregistration and !$confirm) {
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//do not check sesskey if confirm = false because this script is linked into email message
|
||||
if (!empty($errormessage)) {
|
||||
echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
|
||||
}
|
||||
|
||||
$hub = $registrationmanager->get_registeredhub($huburl);
|
||||
echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main');
|
||||
if ($cleanregdata) {
|
||||
@@ -145,60 +142,18 @@ if (empty($cancel) and $unregistration and !$confirm) {
|
||||
$siteunregistrationform = new site_unregistration_form('',
|
||||
array('huburl' => $huburl, 'hubname' => $hub->hubname));
|
||||
}
|
||||
|
||||
$siteunregistrationform->display();
|
||||
} else {
|
||||
$registeredonmoodleorg = false;
|
||||
$moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL);
|
||||
if (!empty($moodleorghub)) {
|
||||
$registeredonmoodleorg = true;
|
||||
}
|
||||
}
|
||||
|
||||
// load the hub selector form
|
||||
$hubselectorform = new hub_selector_form();
|
||||
$fromform = $hubselectorform->get_data();
|
||||
$selectedhuburl = optional_param('publichub', false, PARAM_URL);
|
||||
$unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
|
||||
$password = optional_param('password', '', PARAM_RAW);
|
||||
$registeringhuburl = null;
|
||||
if (!empty($unlistedhuburl)) {
|
||||
if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
|
||||
$registeringhuburl = $unlistedhuburl;
|
||||
}
|
||||
} else if (!empty($selectedhuburl)) {
|
||||
$registeringhuburl = $selectedhuburl;
|
||||
}
|
||||
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
|
||||
echo $renderer->registrationselector($registeredonmoodleorg);
|
||||
|
||||
// a hub has been selected, redirect to the hub registration page
|
||||
if (empty($cancel) and !empty($registeringhuburl) and confirm_sesskey()) {
|
||||
$hubname = optional_param(clean_param($registeringhuburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
|
||||
$params = array('sesskey' => sesskey(), 'huburl' => $registeringhuburl,
|
||||
'password' => $password, 'hubname' => $hubname);
|
||||
redirect(new moodle_url($CFG->wwwroot . "/" . $CFG->admin . "/registration/register.php",
|
||||
$params));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//check if the site is registered on Moodle.org and display a message about registering on MOOCH
|
||||
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
|
||||
if (empty($registered)) {
|
||||
$warningmsg = get_string('registermoochtips', 'hub');
|
||||
$warningmsg .= $renderer->single_button(new moodle_url('register.php', array('huburl' => HUB_MOODLEORGHUBURL
|
||||
, 'hubname' => 'Moodle.org')), get_string('register', 'admin'));
|
||||
echo $renderer->box($warningmsg, 'buttons mdl-align generalbox adminwarning');
|
||||
}
|
||||
|
||||
//do not check sesskey if confirm = false because this script is linked into email message
|
||||
if (!empty($errormessage)) {
|
||||
echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('registerwith', 'hub'));
|
||||
|
||||
$hubselectorform->display();
|
||||
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
if (extension_loaded('xmlrpc')) {
|
||||
$hubs = $registrationmanager->get_registered_on_hubs();
|
||||
if (!empty($hubs)) {
|
||||
echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* This page displays the site registration form for Moodle.org/MOOCH or for a different hub.
|
||||
* This page displays the site registration form.
|
||||
* It handles redirection to the hub to continue the registration workflow process.
|
||||
* It also handles update operation by web service.
|
||||
*/
|
||||
@@ -39,17 +39,15 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
$huburl = required_param('huburl', PARAM_URL);
|
||||
$huburl = rtrim($huburl, "/");
|
||||
|
||||
if ($huburl == HUB_MOODLEORGHUBURL) { // register to Moodle.org
|
||||
admin_externalpage_setup('registrationmoodleorg');
|
||||
} else { //register to a hub
|
||||
admin_externalpage_setup('registrationhub');
|
||||
}
|
||||
|
||||
$password = optional_param('password', '', PARAM_TEXT);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
$registrationmanager = new registration_manager();
|
||||
|
||||
@@ -147,12 +145,5 @@ if (!empty($error)) {
|
||||
echo $error;
|
||||
}
|
||||
|
||||
//some Moodle.org resitration explanation
|
||||
if ($huburl == HUB_MOODLEORGHUBURL) {
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
|
||||
$renderer = $PAGE->get_renderer('core', 'register');
|
||||
echo $renderer->moodleorg_registration_message();
|
||||
}
|
||||
|
||||
$siteregistrationform->display();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -30,23 +30,6 @@
|
||||
*/
|
||||
class core_register_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display Moodle.org registration message about benefit to register on Moodle.org
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
$moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
|
||||
$moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
|
||||
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'MOOCH');
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
|
||||
$items = array(get_string('registermoodleorgli1', 'admin'),
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
|
||||
get_string('registermoodleorgli3', 'admin', $moochurl));
|
||||
$moodleorgregmsg .= html_writer::alist($items);
|
||||
return $moodleorgregmsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a box message confirming a site registration (add or update)
|
||||
* @param string $confirmationmessage
|
||||
@@ -59,6 +42,57 @@ class core_register_renderer extends plugin_renderer_base {
|
||||
return $this->output->box($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page to register on Moodle.org or on a specific hub
|
||||
*/
|
||||
public function registrationselector($updatemoodleorg = false) {
|
||||
global $CFG;
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
|
||||
$table->size = array('50%', '50%');
|
||||
//$table->attributes['class'] = 'registerindextable';
|
||||
//Moodle.org information cell
|
||||
$moodleorgcell = get_string('moodleorgregistrationdetail', 'hub');
|
||||
$moodleorgcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
|
||||
$moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));
|
||||
|
||||
//Specific hub information cell
|
||||
$specifichubcell = get_string('specifichubregistrationdetail', 'hub');
|
||||
$specifichubcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
|
||||
$specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));
|
||||
|
||||
//add information cells
|
||||
$cells = array($moodleorgcell, $specifichubcell);
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
|
||||
//Moodle.org button cell
|
||||
$registeronmoodleorgurl = new moodle_url("/" . $CFG->admin . "/registration/register.php",
|
||||
array('sesskey' => sesskey(), 'huburl' => HUB_MOODLEORGHUBURL
|
||||
, 'hubname' => 'Moodle.org'));
|
||||
$registeronmoodleorgbutton = new single_button($registeronmoodleorgurl,
|
||||
$updatemoodleorg ? get_string('updatesite', 'hub', 'Moodle.org') : get_string('registeronmoodleorg', 'hub'));
|
||||
$registeronmoodleorgbutton->class = 'centeredbutton';
|
||||
$registeronmoodleorgbuttonhtml = $this->output->render($registeronmoodleorgbutton);
|
||||
$moodleorgcell = $registeronmoodleorgbuttonhtml;
|
||||
|
||||
//Specific hub button cell
|
||||
$registeronspecifichuburl = new moodle_url("/" . $CFG->admin . "/registration/hubselector.php",
|
||||
array('sesskey' => sesskey()));
|
||||
$registeronspecifichubbutton = new single_button($registeronspecifichuburl,
|
||||
get_string('registeronspecifichub', 'hub'));
|
||||
$registeronspecifichubbutton->class = 'centeredbutton';
|
||||
$registeronspecifichubbuttonhtml = $this->output->render($registeronspecifichubbutton);
|
||||
$specifichubcell = $registeronspecifichubbuttonhtml;
|
||||
|
||||
//add button cells
|
||||
$cells = array($moodleorgcell, $specifichubcell);
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the listing of registered on hub
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@ $url = optional_param('url', '', PARAM_URL);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
$token = optional_param('token', '', PARAM_TEXT);
|
||||
|
||||
admin_externalpage_setup('registrationhubs');
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
//check that we are waiting a confirmation from this hub, and check that the token is correct
|
||||
$registrationmanager = new registration_manager();
|
||||
|
||||
-1407
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/// Search and replace strings throughout all texts in the whole database
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
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);
|
||||
$sure = optional_param('sure', 0, PARAM_BOOL);
|
||||
|
||||
###################################################################
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading('Search and replace text throughout the whole database');
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql' and $DB->get_dbfamily() !== 'postgres') {
|
||||
//TODO: add $DB->text_replace() to DML drivers
|
||||
echo $OUTPUT->notification('Sorry, this feature is implemented only for MySQL and PostgreSQL databases.');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
if (!data_submitted() or !$search or !$replace or !confirm_sesskey() or !$sure) { /// Print a form
|
||||
echo $OUTPUT->notification('This script is not supported, always make complete backup before proceeding!<br />This operation can not be reverted!');
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="replace.php" method="post"><div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<div><label for="search">Search whole database for: </label><input id="search" type="text" name="search" size="40" /> (usually previous server URL)</div>';
|
||||
echo '<div><label for="replace">Replace with this string: </label><input type="text" id="replace" name="replace" size="40" /> (usually new server URL)</div>';
|
||||
echo '<div><label for="sure">I understand the risks of this operation: </label><input type="checkbox" id="sure" name="sure" value="1" /></div>';
|
||||
echo '<div class="buttons"><input type="submit" class="singlebutton" value="Yes, do it now" /></div>';
|
||||
echo '</div></form>';
|
||||
echo '</div>';
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
db_replace($search, $replace);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Rebuild course cache which might be incorrect now
|
||||
echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
|
||||
rebuild_course_cache();
|
||||
echo $OUTPUT->notification('...finished', 'notifysuccess');
|
||||
|
||||
echo $OUTPUT->continue_button('index.php');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// index.php - scheduled backup logs
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/backup/lib.php');
|
||||
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
|
||||
admin_externalpage_setup('reportbackups');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Automated backups aren't active by the site admin
|
||||
$backup_config = backup_get_config();
|
||||
if (empty($backup_config->backup_auto_active)) {
|
||||
echo $OUTPUT->notification(get_string('automatedbackupsinactive', 'backup'));
|
||||
}
|
||||
|
||||
/// 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("backupnext");
|
||||
|
||||
/// Decide when to show last execution logs or detailed logs
|
||||
/// Lastlog view
|
||||
if (!$courseid) {
|
||||
echo $OUTPUT->heading($backuploglaststatus);
|
||||
echo $OUTPUT->box_start();
|
||||
/// Now, get every record from backup_courses
|
||||
$courses = $DB->get_records("backup_courses");
|
||||
|
||||
if (!$courses) {
|
||||
echo $OUTPUT->notification(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 = $DB->get_field ("course", "fullname", array("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>";
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
/// Detailed View !!
|
||||
} else {
|
||||
echo $OUTPUT->heading($backuplogdetailed);
|
||||
|
||||
$coursename = $DB->get_field("course", "fullname", array("id"=>"$courseid"));
|
||||
echo $OUTPUT->heading("$strcourse: $coursename");
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
/// First, me get all the distinct backups for that course in backup_log
|
||||
$executions = $DB->get_records_sql("SELECT DISTINCT laststarttime
|
||||
FROM {backup_log}
|
||||
WHERE courseid = ? AND backuptype = ?
|
||||
ORDER BY laststarttime DESC", array($courseid,'scheduledbackup'));
|
||||
|
||||
/// Iterate over backup executions
|
||||
if (!$executions) {
|
||||
echo $OUTPUT->notification(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\">";
|
||||
echo $OUTPUT->box(userdate($execution->laststarttime));
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
$logs = $DB->get_records_sql("SELECT *
|
||||
FROM {backup_log}
|
||||
WHERE courseid = ? AND laststarttime = ? AND backuptype = ?
|
||||
ORDER BY id", array($courseid, $execution->laststarttime,'scheduledbackup'));
|
||||
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>";
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('reports', new admin_externalpage('reportbackups', get_string('backups', 'admin'), "$CFG->wwwroot/$CFG->admin/report/backups/index.php",'moodle/backup:backupcourse'));
|
||||
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* For a given capability, show what permission it has for every role, and
|
||||
* everywhere that it is overridden.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package roles
|
||||
*/
|
||||
|
||||
/** */
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// Check permissions.
|
||||
require_login();
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $systemcontext);
|
||||
|
||||
// Get URL parameters.
|
||||
$capability = optional_param('capability', '', PARAM_CAPABILITY);
|
||||
$roleids = optional_param('roles', array('0'), PARAM_INTEGER);
|
||||
|
||||
// Clean the passed in list of role ids. If 'All' selected as an option, or
|
||||
// if none were selected, do all roles.
|
||||
$allroles = get_all_roles();
|
||||
$cleanedroleids = array();
|
||||
foreach ($roleids as $roleid) {
|
||||
if ($roleid == 0) {
|
||||
$cleanedroleids = array_keys($allroles);
|
||||
break;
|
||||
}
|
||||
if (array_key_exists($roleid, $allroles)) {
|
||||
$cleanedroleids[] = $roleid;
|
||||
}
|
||||
}
|
||||
if (empty($cleanedroleids)) {
|
||||
$cleanedroleids = array_keys($allroles);
|
||||
}
|
||||
|
||||
// Include the required JavaScript.
|
||||
$PAGE->requires->js_init_call('M.report_capability.init', array(get_string('search')));
|
||||
|
||||
// Log.
|
||||
add_to_log(SITEID, "admin", "report capability", "report/capability/index.php?capability=$capability", $capability);
|
||||
|
||||
// Print the header.
|
||||
admin_externalpage_setup('reportcapability');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Prepare the list of capabilities to choose from
|
||||
$allcapabilities = fetch_context_capabilities($systemcontext);
|
||||
$capabilitychoices = array();
|
||||
foreach ($allcapabilities as $cap) {
|
||||
$capabilitychoices[$cap->name] = $cap->name . ': ' . get_capability_string($cap->name);
|
||||
}
|
||||
|
||||
// Prepare the list of roles to choose from
|
||||
$rolechoices = array('0' => get_string('all'));
|
||||
foreach ($allroles as $role) {
|
||||
$rolechoices[$role->id] = $role->name;
|
||||
}
|
||||
if (count($cleanedroleids) == count($allroles)) {
|
||||
// Select 'All', rather than each role individually.
|
||||
$selectedroleids = array('0');
|
||||
} else {
|
||||
$selectedroleids = $cleanedroleids;
|
||||
}
|
||||
|
||||
// Print the settings form.
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
echo '<form method="get" action="." id="settingsform"><div>';
|
||||
echo $OUTPUT->heading(get_string('reportsettings', 'report_capability'));
|
||||
echo '<p id="intro">', get_string('intro', 'report_capability') , '</p>';
|
||||
echo '<p><label for="menucapability"> ' . get_string('capabilitylabel', 'report_capability') . '</label></p>';
|
||||
echo html_writer::select($capabilitychoices, 'capability', $capability, array(''=>'choose'), array('size'=>10));
|
||||
echo '<p><label for="menuroles"> ' . get_string('roleslabel', 'report_capability') . '</label></p>';
|
||||
echo html_writer::select($rolechoices, 'roles[]', $selectedroleids, false, array('size'=>10, 'multiple'=>'multiple'));
|
||||
echo '<p><input type="submit" id="settingssubmit" value="' . get_string('getreport', 'report_capability') . '" /></p>';
|
||||
echo '</div></form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
// If we have a capability, generate the report.
|
||||
if ($capability) {
|
||||
|
||||
// Work out the bits needed for the SQL WHERE clauses.
|
||||
$params = array($capability);
|
||||
$sqlroletest = '';
|
||||
if (count($cleanedroleids) != count($allroles)) {
|
||||
list($sqlroletest, $roleparams) = $DB->get_in_or_equal($cleanedroleids);
|
||||
$params = array_merge($params, $roleparams);
|
||||
$sqlroletest = 'AND roleid ' . $sqlroletest;
|
||||
}
|
||||
|
||||
// Get all the role_capabilities rows for this capability - that is, all
|
||||
// role definitions, and all role overrides.
|
||||
$rolecaps = $DB->get_records_sql("
|
||||
SELECT id, roleid, contextid, permission
|
||||
FROM {role_capabilities}
|
||||
WHERE capability = ? $sqlroletest", $params);
|
||||
|
||||
// In order to display a nice tree of contexts, we need to get all the
|
||||
// ancestors of all the contexts in the query we just did.
|
||||
$relevantpaths = $DB->get_records_sql_menu("
|
||||
SELECT DISTINCT con.path, 1
|
||||
FROM {context} con JOIN {role_capabilities} rc ON rc.contextid = con.id
|
||||
WHERE capability = ? $sqlroletest", $params);
|
||||
$requiredcontexts = array($systemcontext->id);
|
||||
foreach ($relevantpaths as $path => $notused) {
|
||||
$requiredcontexts = array_merge($requiredcontexts, explode('/', trim($path, '/')));
|
||||
}
|
||||
$requiredcontexts = array_unique($requiredcontexts);
|
||||
|
||||
// Now load those contexts.
|
||||
list($sqlcontexttest, $contextparams) = $DB->get_in_or_equal($requiredcontexts);
|
||||
$contexts = get_sorted_contexts('ctx.id ' . $sqlcontexttest, $contextparams);
|
||||
|
||||
// Prepare some empty arrays to hold the data we are about to compute.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$contexts[$conid]->children = array();
|
||||
$contexts[$conid]->rolecapabilities = array();
|
||||
}
|
||||
|
||||
// Put the contexts into a tree structure.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$parentcontextid = get_parent_contextid($con);
|
||||
if ($parentcontextid) {
|
||||
$contexts[$parentcontextid]->children[] = $conid;
|
||||
}
|
||||
}
|
||||
|
||||
// Put the role capabilities into the context tree.
|
||||
foreach ($rolecaps as $rolecap) {
|
||||
$contexts[$rolecap->contextid]->rolecapabilities[$rolecap->roleid] = $rolecap->permission;
|
||||
}
|
||||
|
||||
// Fill in any missing rolecaps for the system context.
|
||||
foreach ($cleanedroleids as $roleid) {
|
||||
if (!isset($contexts[$systemcontext->id]->rolecapabilities[$roleid])) {
|
||||
$contexts[$systemcontext->id]->rolecapabilities[$roleid] = CAP_INHERIT;
|
||||
}
|
||||
}
|
||||
|
||||
// Print the report heading.
|
||||
echo $OUTPUT->heading(get_string('reportforcapability', 'report_capability', get_capability_string($capability)), 2, 'main', 'report');
|
||||
if (count($cleanedroleids) != count($allroles)) {
|
||||
$rolenames = array();
|
||||
foreach ($cleanedroleids as $roleid) {
|
||||
$rolenames[] = $allroles[$roleid]->name;
|
||||
}
|
||||
echo '<p>', get_string('forroles', 'report_capability', implode(', ', $rolenames)), '</p>';
|
||||
}
|
||||
|
||||
// Now, recursively print the contexts, and the role information.
|
||||
print_report_tree($systemcontext->id, $contexts, $allroles);
|
||||
}
|
||||
|
||||
// Footer.
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function print_report_tree($contextid, $contexts, $allroles) {
|
||||
global $CFG;
|
||||
|
||||
// Array for holding lang strings.
|
||||
static $strpermissions = null;
|
||||
if (is_null($strpermissions)) {
|
||||
$strpermissions = array(
|
||||
CAP_INHERIT => get_string('notset','role'),
|
||||
CAP_ALLOW => get_string('allow','role'),
|
||||
CAP_PREVENT => get_string('prevent','role'),
|
||||
CAP_PROHIBIT => get_string('prohibit','role')
|
||||
);
|
||||
}
|
||||
|
||||
// Start the list item, and print the context name as a link to the place to
|
||||
// make changes.
|
||||
if ($contextid == get_system_context()->id) {
|
||||
$url = "$CFG->wwwroot/$CFG->admin/roles/manage.php";
|
||||
$title = get_string('changeroles', 'report_capability');
|
||||
} else {
|
||||
$url = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid";
|
||||
$title = get_string('changeoverrides', 'report_capability');
|
||||
}
|
||||
echo '<h3><a href="' . $url . '" title="' . $title . '">', print_context_name($contexts[$contextid]), '</a></h3>';
|
||||
|
||||
// If there are any role overrides here, print them.
|
||||
if (!empty($contexts[$contextid]->rolecapabilities)) {
|
||||
$rowcounter = 0;
|
||||
echo '<table class="generaltable rolecaps"><tbody>';
|
||||
foreach ($allroles as $role) {
|
||||
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
|
||||
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
|
||||
echo '<tr class="r' . ($rowcounter % 2) . '"><th class="cell">', $role->name,
|
||||
'</th><td class="cell">' . $strpermissions[$permission] . '</td></tr>';
|
||||
$rowcounter++;
|
||||
}
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
|
||||
// After we have done the site context, change the string for CAP_INHERIT
|
||||
// from 'notset' to 'inherit'.
|
||||
$strpermissions[CAP_INHERIT] = get_string('inherit','role');
|
||||
|
||||
// If there are any child contexts, print them recursively.
|
||||
if (!empty($contexts[$contextid]->children)) {
|
||||
echo '<ul>';
|
||||
foreach ($contexts[$contextid]->children as $childcontextid) {
|
||||
echo '<li>';
|
||||
print_report_tree($childcontextid, $contexts, $allroles);
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_capability', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report_capability
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['capabilitylabel'] = 'Capability:';
|
||||
$string['capabilityreport'] = 'Capability report';
|
||||
$string['forroles'] = 'For roles {$a}';
|
||||
$string['getreport'] = 'Get the report';
|
||||
$string['changeoverrides'] = 'Change overrides in this context';
|
||||
$string['changeroles'] = 'Change role definitions';
|
||||
$string['intro'] = 'This report shows, for a particular capability, what permission that capability has in the definition of every role (or a selection of roles), and everywhere in the site where that capability is overridden.';
|
||||
$string['pluginname'] = 'Capability report';
|
||||
$string['reportforcapability'] = 'Report for capability \'{$a}\'';
|
||||
$string['reportsettings'] = 'Report settings';
|
||||
$string['roleslabel'] = 'Roles:';
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
M.report_capability = {
|
||||
select: null,
|
||||
input: null,
|
||||
button: null,
|
||||
|
||||
init: function(Y, strsearch) {
|
||||
var context = M.report_capability;
|
||||
|
||||
// Find the form controls.
|
||||
context.select = document.getElementById('menucapability');
|
||||
context.button = document.getElementById('settingssubmit');
|
||||
|
||||
// Create a div to hold the search UI.
|
||||
var div = document.createElement('div');
|
||||
div.id = 'capabilitysearchui';
|
||||
|
||||
// Find the capability search input.
|
||||
var input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.id = 'capabilitysearch';
|
||||
context.input = input;
|
||||
|
||||
// Create a label for the search input.
|
||||
var label = document.createElement('label');
|
||||
label.htmlFor = input.id;
|
||||
label.appendChild(document.createTextNode(strsearch + ' '));
|
||||
|
||||
// Tie it all together
|
||||
div.appendChild(label);
|
||||
div.appendChild(input);
|
||||
context.select.parentNode.insertBefore(div, context.select);
|
||||
Y.on('keyup', context.typed, input);
|
||||
Y.on('change', context.validate, context.select);
|
||||
context.select.options[0].style.display = 'none';
|
||||
context.validate();
|
||||
},
|
||||
|
||||
typed: function() {
|
||||
var context = M.report_capability;
|
||||
|
||||
var filtertext = context.input.value;
|
||||
var options = context.select.options;
|
||||
var onlycapability = -1;
|
||||
for (var i = 1; i < options.length; i++) {
|
||||
if (options[i].text.indexOf(filtertext) >= 0) {
|
||||
options[i].disabled = false;
|
||||
options[i].style.display = 'block';
|
||||
if (onlycapability == -1) {
|
||||
onlycapability = i;
|
||||
} else {
|
||||
onlycapability = -2;
|
||||
}
|
||||
} else {
|
||||
options[i].disabled = true;
|
||||
options[i].selected = false;
|
||||
options[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
if (onlycapability >= 0) {
|
||||
options[onlycapability].selected = true;
|
||||
}
|
||||
if (onlycapability == -1) {
|
||||
context.input.className = "error";
|
||||
} else {
|
||||
context.input.className = "";
|
||||
}
|
||||
context.validate();
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
var context = M.report_capability;
|
||||
context.button.disabled = (context.select.value == '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('roles', new admin_externalpage('reportcapability', get_string('pluginname', 'report_capability'), "$CFG->wwwroot/$CFG->admin/report/capability/index.php",'moodle/role:manage'));
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// page parameters
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
|
||||
$sort = optional_param('sort', 'timemodified', PARAM_ALPHA);
|
||||
$dir = optional_param('dir', 'DESC', PARAM_ALPHA);
|
||||
|
||||
admin_externalpage_setup('reportconfiglog');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
|
||||
|
||||
$changescount = $DB->count_records('config_log');
|
||||
|
||||
$columns = array('firstname' => get_string('firstname'),
|
||||
'lastname' => get_string('lastname'),
|
||||
'timemodified' => get_string('timemodified', 'report_configlog'),
|
||||
'plugin' => get_string('plugin', 'report_configlog'),
|
||||
'name' => get_string('setting', 'report_configlog'),
|
||||
'value' => get_string('value', 'report_configlog'),
|
||||
'oldvalue' => get_string('oldvalue', 'report_configlog'),
|
||||
);
|
||||
$hcolumns = array();
|
||||
|
||||
|
||||
if (!isset($columns[$sort])) {
|
||||
$sort = 'lastname';
|
||||
}
|
||||
|
||||
foreach ($columns as $column=>$strcolumn) {
|
||||
if ($sort != $column) {
|
||||
$columnicon = '';
|
||||
if ($column == 'lastaccess') {
|
||||
$columndir = 'DESC';
|
||||
} else {
|
||||
$columndir = 'ASC';
|
||||
}
|
||||
} else {
|
||||
$columndir = $dir == 'ASC' ? 'DESC':'ASC';
|
||||
if ($column == 'lastaccess') {
|
||||
$columnicon = $dir == 'ASC' ? 'up':'down';
|
||||
} else {
|
||||
$columnicon = $dir == 'ASC' ? 'down':'up';
|
||||
}
|
||||
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
|
||||
|
||||
}
|
||||
$hcolumns[$column] = "<a href=\"index.php?sort=$column&dir=$columndir&page=$page&perpage=$perpage\">".$strcolumn."</a>$columnicon";
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
|
||||
echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
|
||||
|
||||
$override = new stdClass();
|
||||
$override->firstname = 'firstname';
|
||||
$override->lastname = 'lastname';
|
||||
$fullnamelanguage = get_string('fullnamedisplay', '', $override);
|
||||
if (($CFG->fullnamedisplay == 'firstname lastname') or
|
||||
($CFG->fullnamedisplay == 'firstname') or
|
||||
($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname' )) {
|
||||
$fullnamedisplay = $hcolumns['firstname'].' / '.$hcolumns['lastname'];
|
||||
} else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
|
||||
$fullnamedisplay = $hcolumns['lastname'].' / '.$hcolumns['firstname'];
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']);
|
||||
$table->align = array('left', 'left', 'left', 'left', 'left', 'left');
|
||||
$table->size = array('30%', '10%', '10%', '10%', '20%', '20%');
|
||||
$table->width = '95%';
|
||||
$table->data = array();
|
||||
|
||||
if ($sort == 'firstname' or $sort == 'lastname') {
|
||||
$orderby = "u.$sort $dir";
|
||||
} else {
|
||||
$orderby = "cl.$sort $dir";
|
||||
}
|
||||
|
||||
$ufields = user_picture::fields('u');
|
||||
$sql = "SELECT $ufields,
|
||||
cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue
|
||||
FROM {config_log} cl
|
||||
JOIN {user} u ON u.id = cl.userid
|
||||
ORDER BY $orderby";
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage);
|
||||
foreach ($rs as $log) {
|
||||
$row = array();
|
||||
$row[] = userdate($log->timemodified);
|
||||
$row[] = fullname($log);
|
||||
if (is_null($log->plugin)) {
|
||||
$row[] = 'core';
|
||||
} else {
|
||||
$row[] = $log->plugin;
|
||||
}
|
||||
$row[] = $log->name;
|
||||
$row[] = s($log->value);
|
||||
$row[] = s($log->oldvalue);
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
+3
-4
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -17,16 +18,14 @@
|
||||
/**
|
||||
* Strings for component 'report_configlog', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report
|
||||
* @subplugin configlog
|
||||
* @copyright 2009 petr Skoda
|
||||
* @package report_configlog
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['configlog'] = 'Config changes';
|
||||
$string['oldvalue'] = 'Original value';
|
||||
$string['plugin'] = 'Plugin';
|
||||
$string['pluginname'] = 'Config changes';
|
||||
$string['setting'] = 'Setting';
|
||||
$string['timemodified'] = 'Date';
|
||||
$string['value'] = 'New value';
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('reports', new admin_externalpage('reportconfiglog', get_string('configlog', 'report_configlog'), "$CFG->wwwroot/$CFG->admin/report/configlog/index.php"));
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'report/courseoverview:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
} else {
|
||||
print_error('statsdisable');
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_setup('reportcourseoverview');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$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);
|
||||
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
|
||||
|
||||
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', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n";
|
||||
echo '<div>';
|
||||
|
||||
$table = new html_table();
|
||||
$table->width = '*';
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
|
||||
$reporttypemenu = html_writer::select($reportoptions,'report',$report, false);
|
||||
$timeoptionsmenu = html_writer::select($timeoptions,'time',$time, false);
|
||||
|
||||
$table->data[] = array(get_string('statsreporttype'),$reporttypemenu,
|
||||
get_string('statstimeperiod'),$timeoptionsmenu,
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
echo $OUTPUT->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 {".'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 = $DB->get_records_sql($sql, $param->params, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
echo $OUTPUT->notification(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 html_table();
|
||||
$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.'">'.$DB->get_field('course', 'shortname', array('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;
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_courseoverview', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report_courseoverview
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['courseoverview:view'] = 'View course overview report';
|
||||
$string['pluginname'] = 'Course overview';
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
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('report/courseoverview:view', 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 {".'stats_'.$param->table."}
|
||||
WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0
|
||||
GROUP BY courseid
|
||||
$param->extras
|
||||
ORDER BY $param->orderby";
|
||||
}
|
||||
|
||||
$courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
$PAGE->set_url('/admin/report/courseoverview/index.php');
|
||||
print_error('statsnodata', 'error', $PAGE->url->out());
|
||||
}
|
||||
|
||||
|
||||
$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[] = $DB->get_field('course', 'shortname', array('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();
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('pluginname', 'report_courseoverview'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'report/courseoverview:view'));
|
||||
@@ -0,0 +1,27 @@
|
||||
<?PHP
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$plugin->version = 2010090501;
|
||||
$plugin->requires = 2010090501;
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Defines the capabilities used by the Language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
/* allows the user to view the current language customization */
|
||||
'report/customlang:view' => array(
|
||||
'riskbitmask' => RISK_CONFIG,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
|
||||
/* allows the user to edit the current language customization */
|
||||
'report/customlang:edit' => array(
|
||||
'riskbitmask' => RISK_CONFIG | RISK_XSS,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/report/customlang/db" VERSION="20110419" COMMENT="XMLDB file for Moodle admin/report/customlang"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="report_customlang" COMMENT="Contains the working checkout of all strings and their customization" NEXT="report_customlang_components">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="lang"/>
|
||||
<FIELD NAME="lang" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The code of the language this string belongs to. Like en, cs or es" PREVIOUS="id" NEXT="componentid"/>
|
||||
<FIELD NAME="componentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the component" PREVIOUS="lang" NEXT="stringid"/>
|
||||
<FIELD NAME="stringid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The identifier of the string" PREVIOUS="componentid" NEXT="original"/>
|
||||
<FIELD NAME="original" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false" COMMENT="English original of the string" PREVIOUS="stringid" NEXT="master"/>
|
||||
<FIELD NAME="master" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Master translation of the string as is distributed in the official lang pack, null if not translated" PREVIOUS="original" NEXT="local"/>
|
||||
<FIELD NAME="local" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Local customization of the string, null if not customized" PREVIOUS="master" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The timestamp of when the original or master was recently modified" PREVIOUS="local" NEXT="timecustomized"/>
|
||||
<FIELD NAME="timecustomized" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The timestamp of when the value of the local translation was recently modified, null if not customized yet" PREVIOUS="timemodified" NEXT="outdated"/>
|
||||
<FIELD NAME="outdated" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Either the English original or the master translation changed and the customization may be outdated" PREVIOUS="timecustomized" NEXT="modified"/>
|
||||
<FIELD NAME="modified" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Has the string been modified via the translator?" PREVIOUS="outdated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_component"/>
|
||||
<KEY NAME="fk_component" TYPE="foreign" FIELDS="componentid" REFTABLE="report_customlang_components" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="uq_lang_component_string" UNIQUE="true" FIELDS="lang, componentid, stringid" COMMENT="For a given language and component, string identifiers must be unique"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="report_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack" PREVIOUS="report_customlang">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Language customization report upgrades
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
function xmldb_report_customlang_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
$result = true;
|
||||
|
||||
/**
|
||||
* Use proper plugin prefix for tables
|
||||
*/
|
||||
if ($oldversion < 2010111200) {
|
||||
if ($dbman->table_exists('customlang')) {
|
||||
$dbman->rename_table(new xmldb_table('customlang'), 'report_customlang');
|
||||
}
|
||||
if ($dbman->table_exists('customlang_components')) {
|
||||
$dbman->rename_table(new xmldb_table('customlang_components'), 'report_customlang_components');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2010111200, 'report', 'customlang');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the foreign key after the tables rename
|
||||
*/
|
||||
if ($oldversion < 2010111500) {
|
||||
$table = new xmldb_table('report_customlang');
|
||||
$oldkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'customlang_components', array('id'));
|
||||
$newkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'report_customlang_components', array('id'));
|
||||
|
||||
$dbman->drop_key($table, $oldkey);
|
||||
$dbman->add_key($table, $newkey);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2010111500, 'report', 'customlang');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the version field from integer to varchar
|
||||
*/
|
||||
if ($oldversion < 2011041900) {
|
||||
$table = new xmldb_table('report_customlang_components');
|
||||
$field = new xmldb_field('version', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'name');
|
||||
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2011041900, 'report', 'customlang');
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/customlang/locallib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/customlang/filter_form.php');
|
||||
|
||||
require_login(SITEID, false);
|
||||
require_capability('report/customlang:edit', get_system_context());
|
||||
|
||||
$lng = required_param('lng', PARAM_LANG);
|
||||
$currentpage = optional_param('p', 0, PARAM_INT);
|
||||
$translatorsubmitted = optional_param('translatorsubmitted', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_pagelayout('standard');
|
||||
$PAGE->set_url('/admin/report/customlang/edit.php', array('lng' => $lng));
|
||||
navigation_node::override_active_url(new moodle_url('/admin/report/customlang/index.php'));
|
||||
$PAGE->set_title(get_string('pluginname', 'report_customlang'));
|
||||
$PAGE->set_heading(get_string('pluginname', 'report_customlang'));
|
||||
$PAGE->requires->js_init_call('M.report_customlang.init_editor', array(), true);
|
||||
|
||||
if (empty($lng)) {
|
||||
// PARAM_LANG validation failed
|
||||
print_error('missingparameter');
|
||||
}
|
||||
|
||||
// pre-output processing
|
||||
$filter = new report_customlang_filter_form($PAGE->url, null, 'post', '', array('class'=>'filterform'));
|
||||
$filterdata = report_customlang_utils::load_filter($USER);
|
||||
$filter->set_data($filterdata);
|
||||
|
||||
if ($filter->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
|
||||
} elseif ($submitted = $filter->get_data()) {
|
||||
report_customlang_utils::save_filter($submitted, $USER);
|
||||
redirect(new moodle_url($PAGE->url, array('p'=>0)));
|
||||
}
|
||||
|
||||
if ($translatorsubmitted) {
|
||||
$strings = optional_param('cust', array(), PARAM_RAW);
|
||||
$updates = optional_param('updates', array(), PARAM_INT);
|
||||
$checkin = optional_param('savecheckin', false, PARAM_RAW);
|
||||
|
||||
if ($checkin === false) {
|
||||
$nexturl = $PAGE->url;
|
||||
} else {
|
||||
$nexturl = new moodle_url('/admin/report/customlang/index.php', array('action'=>'checkin', 'lng' => $lng, 'sesskey'=>sesskey()));
|
||||
}
|
||||
|
||||
if (!is_array($strings)) {
|
||||
$strings = array();
|
||||
}
|
||||
$current = $DB->get_records_list('report_customlang', 'id', array_keys($strings));
|
||||
$now = time();
|
||||
|
||||
foreach ($strings as $recordid => $customization) {
|
||||
$customization = trim($customization);
|
||||
|
||||
if (empty($customization) and !is_null($current[$recordid]->local)) {
|
||||
$current[$recordid]->local = null;
|
||||
$current[$recordid]->modified = 1;
|
||||
$current[$recordid]->outdated = 0;
|
||||
$current[$recordid]->timecustomized = null;
|
||||
$DB->update_record('report_customlang', $current[$recordid]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($customization)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($customization !== $current[$recordid]->local) {
|
||||
$current[$recordid]->local = $customization;
|
||||
$current[$recordid]->modified = 1;
|
||||
$current[$recordid]->outdated = 0;
|
||||
$current[$recordid]->timecustomized = $now;
|
||||
$DB->update_record('report_customlang', $current[$recordid]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($updates)) {
|
||||
$updates = array();
|
||||
}
|
||||
if (!empty($updates)) {
|
||||
list($sql, $params) = $DB->get_in_or_equal($updates);
|
||||
$DB->set_field_select('report_customlang', 'outdated', 0, "local IS NOT NULL AND id $sql", $params);
|
||||
}
|
||||
|
||||
redirect($nexturl);
|
||||
}
|
||||
|
||||
$translator = new report_customlang_translator($PAGE->url, $lng, $filterdata, $currentpage);
|
||||
|
||||
// output starts here
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
$paginator = $output->paging_bar($translator->numofrows, $currentpage, report_customlang_translator::PERPAGE, $PAGE->url, 'p');
|
||||
|
||||
echo $output->header();
|
||||
$filter->display();
|
||||
echo $paginator;
|
||||
echo $output->render($translator);
|
||||
echo $paginator;
|
||||
echo $output->footer();
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package tool
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -28,51 +29,51 @@ require_once($CFG->dirroot . '/lib/formslib.php');
|
||||
/**
|
||||
* Form for filtering the strings to customize
|
||||
*/
|
||||
class tool_customlang_filter_form extends moodleform {
|
||||
class report_customlang_filter_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
$current = $this->_customdata['current'];
|
||||
|
||||
$mform->addElement('header', 'filtersettings', get_string('filter', 'tool_customlang'));
|
||||
$mform->addElement('header', 'filtersettings', get_string('filter', 'report_customlang'));
|
||||
|
||||
// Component
|
||||
$options = array();
|
||||
foreach (tool_customlang_utils::list_components() as $component => $normalized) {
|
||||
foreach (report_customlang_utils::list_components() as $component => $normalized) {
|
||||
list($type, $plugin) = normalize_component($normalized);
|
||||
if ($type == 'core' and is_null($plugin)) {
|
||||
$plugin = 'moodle';
|
||||
}
|
||||
$options[$type][$normalized] = $component.'.php';
|
||||
}
|
||||
$mform->addElement('selectgroups', 'component', get_string('filtercomponent', 'tool_customlang'), $options,
|
||||
$mform->addElement('selectgroups', 'component', get_string('filtercomponent', 'report_customlang'), $options,
|
||||
array('multiple'=>'multiple', 'size'=>7));
|
||||
|
||||
// Customized only
|
||||
$mform->addElement('advcheckbox', 'customized', get_string('filtercustomized', 'tool_customlang'));
|
||||
$mform->addElement('advcheckbox', 'customized', get_string('filtercustomized', 'report_customlang'));
|
||||
$mform->setType('customized', PARAM_BOOL);
|
||||
$mform->setDefault('customized', 0);
|
||||
|
||||
// Only helps
|
||||
$mform->addElement('advcheckbox', 'helps', get_string('filteronlyhelps', 'tool_customlang'));
|
||||
$mform->addElement('advcheckbox', 'helps', get_string('filteronlyhelps', 'report_customlang'));
|
||||
$mform->setType('helps', PARAM_BOOL);
|
||||
$mform->setDefault('helps', 0);
|
||||
|
||||
// Modified only
|
||||
$mform->addElement('advcheckbox', 'modified', get_string('filtermodified', 'tool_customlang'));
|
||||
$mform->addElement('advcheckbox', 'modified', get_string('filtermodified', 'report_customlang'));
|
||||
$mform->setType('filtermodified', PARAM_BOOL);
|
||||
$mform->setDefault('filtermodified', 0);
|
||||
|
||||
// Substring
|
||||
$mform->addElement('text', 'substring', get_string('filtersubstring', 'tool_customlang'));
|
||||
$mform->addElement('text', 'substring', get_string('filtersubstring', 'report_customlang'));
|
||||
$mform->setType('substring', PARAM_RAW);
|
||||
|
||||
// String identifier
|
||||
$mform->addElement('text', 'stringid', get_string('filterstringid', 'tool_customlang'));
|
||||
$mform->addElement('text', 'stringid', get_string('filterstringid', 'report_customlang'));
|
||||
$mform->setType('stringid', PARAM_STRINGID);
|
||||
|
||||
// Show strings - submit button
|
||||
$mform->addElement('submit', 'submit', get_string('filtershowstrings', 'tool_customlang'));
|
||||
$mform->addElement('submit', 'submit', get_string('filtershowstrings', 'report_customlang'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Performs checkout of the strings into the translation table
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true); // progress bar is used here
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login(SITEID, false);
|
||||
require_capability('report/customlang:view', get_system_context());
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
$lng = optional_param('lng', '', PARAM_LANG);
|
||||
|
||||
admin_externalpage_setup('reportcustomlang');
|
||||
$langs = get_string_manager()->get_list_of_translations();
|
||||
|
||||
// pre-output actions
|
||||
if ($action === 'checkout') {
|
||||
require_sesskey();
|
||||
require_capability('report/customlang:edit', get_system_context());
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
}
|
||||
|
||||
$PAGE->set_cacheable(false); // progress bar is used here
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'report_customlang'));
|
||||
$progressbar = new progress_bar();
|
||||
$progressbar->create(); // prints the HTML code of the progress bar
|
||||
|
||||
// we may need a bit of extra execution time and memory here
|
||||
@set_time_limit(HOURSECS);
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
report_customlang_utils::checkout($lng, $progressbar);
|
||||
|
||||
echo $output->continue_button(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)), 'get');
|
||||
echo $output->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === 'checkin') {
|
||||
require_sesskey();
|
||||
require_capability('report/customlang:edit', get_system_context());
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'report_customlang'));
|
||||
echo $output->heading($langs[$lng], 3);
|
||||
$numofmodified = report_customlang_utils::get_count_of_modified($lng);
|
||||
if ($numofmodified != 0) {
|
||||
echo $output->heading(get_string('modifiednum', 'report_customlang', $numofmodified), 3);
|
||||
echo $output->confirm(get_string('confirmcheckin', 'report_customlang'),
|
||||
new moodle_url($PAGE->url, array('action'=>'checkin', 'lng'=>$lng, 'confirm'=>1)),
|
||||
new moodle_url($PAGE->url, array('lng'=>$lng)));
|
||||
} else {
|
||||
echo $output->heading(get_string('modifiedno', 'report_customlang', $numofmodified), 3);
|
||||
echo $output->continue_button(new moodle_url($PAGE->url, array('lng' => $lng)));
|
||||
}
|
||||
echo $output->footer();
|
||||
die();
|
||||
|
||||
} else {
|
||||
report_customlang_utils::checkin($lng);
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
|
||||
// output starts here
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'report_customlang'));
|
||||
|
||||
if (empty($lng)) {
|
||||
$s = new single_select($PAGE->url, 'lng', $langs);
|
||||
$s->label = get_accesshide(get_string('language'));
|
||||
$s->class = 'langselector';
|
||||
echo $output->box($OUTPUT->render($s), 'langselectorbox');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $output->heading($langs[$lng], 3);
|
||||
|
||||
$numofmodified = report_customlang_utils::get_count_of_modified($lng);
|
||||
|
||||
if ($numofmodified != 0) {
|
||||
echo $output->heading(get_string('modifiednum', 'report_customlang', $numofmodified), 3);
|
||||
}
|
||||
|
||||
$menu = array();
|
||||
if (has_capability('report/customlang:edit', get_system_context())) {
|
||||
$menu['checkout'] = array(
|
||||
'title' => get_string('checkout', 'report_customlang'),
|
||||
'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)),
|
||||
'method' => 'post',
|
||||
);
|
||||
if ($numofmodified != 0) {
|
||||
$menu['checkin'] = array(
|
||||
'title' => get_string('checkin', 'report_customlang'),
|
||||
'url' => new moodle_url($PAGE->url, array('action' => 'checkin', 'lng' => $lng)),
|
||||
'method' => 'post',
|
||||
);
|
||||
}
|
||||
}
|
||||
echo $output->render(new report_customlang_menu($menu));
|
||||
|
||||
echo $output->footer();
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for Language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['checkin'] = 'Check in strings into disk';
|
||||
$string['checkout'] = 'Check out strings into the translator';
|
||||
$string['checkoutdone'] = 'Strings checked out successfully into the translator';
|
||||
$string['checkoutinprogress'] = 'Checking out strings into the translator';
|
||||
$string['confirmcheckin'] = 'You are about to check in modified strings into your local language pack. This will export the customized strings from the translator into the data directory and Moodle will start using the modified strings. Press \'Continue\' button to proceed check in.';
|
||||
$string['customlang:edit'] = 'Edit local translation';
|
||||
$string['customlang:view'] = 'View local translation';
|
||||
$string['filter'] = 'Filter strings';
|
||||
$string['filtercomponent'] = 'Show strings of these components';
|
||||
$string['filtercustomized'] = 'Customized only';
|
||||
$string['filtermodified'] = 'Modified only';
|
||||
$string['filteronlyhelps'] = 'Help only';
|
||||
$string['filtershowstrings'] = 'Show strings';
|
||||
$string['filterstringid'] = 'String identifier';
|
||||
$string['filtersubstring'] = 'Only strings containing';
|
||||
$string['headingcomponent'] = 'Component';
|
||||
$string['headinglocal'] = 'Local customization';
|
||||
$string['headingstandard'] = 'Standard text';
|
||||
$string['headingstringid'] = 'String';
|
||||
$string['markinguptodate'] = 'Marking the customization as up-to-date';
|
||||
$string['markinguptodate_help'] = 'The customized translation may get outdated if either the English original or the master translation has modified since the string was customized on your site. Review the customized translation. If you find it up-to-date, click the checkbox. Edit it otherwise.';
|
||||
$string['markuptodate'] = 'mark as up-to-date';
|
||||
$string['modifiedno'] = 'There are no modified strings to check in.';
|
||||
$string['modifiednum'] = 'There are {$a} modified strings. You must check in them into disk to store them permanently.';
|
||||
$string['nostringsfound'] = 'No strings found, please modify the filter settings';
|
||||
$string['placeholder'] = 'Placeholders';
|
||||
$string['placeholder_help'] = 'Placeholders are special statements like `{$a}` or `{$a->something}` within the string. They are replaced with a value when the string is actually printed.
|
||||
|
||||
It is important to copy them exactly as they are in the original string. Do not translate them nor change their left-to-right orientation.';
|
||||
$string['placeholderwarning'] = 'string contains a placeholder';
|
||||
$string['pluginname'] = 'Language customization';
|
||||
$string['savecheckin'] = 'Save and check in strings into files';
|
||||
$string['savecontinue'] = 'Save and continue editing';
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@@ -0,0 +1,535 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Definition of classes used by language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Provides various utilities to be used by the plugin
|
||||
*
|
||||
* All the public methods here are static ones, this class can not be instantiated
|
||||
*/
|
||||
class report_customlang_utils {
|
||||
|
||||
/**
|
||||
* Rough number of strings that are being processed during a full checkout.
|
||||
* This is used to estimate the progress of the checkout.
|
||||
*/
|
||||
const ROUGH_NUMBER_OF_STRINGS = 16500;
|
||||
|
||||
/** @var array cache of {@link self::list_components()} results */
|
||||
protected static $components = null;
|
||||
|
||||
/**
|
||||
* This class can not be instantiated
|
||||
*/
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all components installed on the server
|
||||
*
|
||||
* @return array (string)legacyname => (string)frankenstylename
|
||||
*/
|
||||
public static function list_components() {
|
||||
|
||||
$list['moodle'] = 'core';
|
||||
|
||||
$coresubsystems = get_core_subsystems();
|
||||
ksort($coresubsystems); // should be but just in case
|
||||
foreach ($coresubsystems as $name => $location) {
|
||||
if ($name != 'moodle.org') {
|
||||
$list[$name] = 'core_'.$name;
|
||||
}
|
||||
}
|
||||
|
||||
$plugintypes = get_plugin_types();
|
||||
foreach ($plugintypes as $type => $location) {
|
||||
$pluginlist = get_plugin_list($type);
|
||||
foreach ($pluginlist as $name => $ununsed) {
|
||||
if ($type == 'mod') {
|
||||
if (array_key_exists($name, $list)) {
|
||||
throw new Exception('Activity module and core subsystem name collision');
|
||||
}
|
||||
$list[$name] = $type.'_'.$name;
|
||||
} else {
|
||||
$list[$type.'_'.$name] = $type.'_'.$name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the translator database with the strings from files
|
||||
*
|
||||
* This should be executed each time before going to the translation page
|
||||
*
|
||||
* @param string $lang language code to checkout
|
||||
* @param progress_bar $progressbar optionally, the given progress bar can be updated
|
||||
*/
|
||||
public static function checkout($lang, progress_bar $progressbar = null) {
|
||||
global $DB;
|
||||
|
||||
// make sure that all components are registered
|
||||
$current = $DB->get_records('report_customlang_components', null, 'name', 'name,version,id');
|
||||
foreach (self::list_components() as $component) {
|
||||
if (empty($current[$component])) {
|
||||
$record = new stdclass();
|
||||
$record->name = $component;
|
||||
if (!$version = get_component_version($component)) {
|
||||
$record->version = null;
|
||||
} else {
|
||||
$record->version = $version;
|
||||
}
|
||||
$DB->insert_record('report_customlang_components', $record);
|
||||
} elseif ($version = get_component_version($component)) {
|
||||
if (is_null($current[$component]->version) or ($version > $current[$component]->version)) {
|
||||
$DB->set_field('report_customlang_components', 'version', $version, array('id' => $current[$component]->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($current);
|
||||
|
||||
// initialize the progress counter - stores the number of processed strings
|
||||
$done = 0;
|
||||
$strinprogress = get_string('checkoutinprogress', 'report_customlang');
|
||||
|
||||
// reload components and fetch their strings
|
||||
$stringman = get_string_manager();
|
||||
$components = $DB->get_records('report_customlang_components');
|
||||
foreach ($components as $component) {
|
||||
$sql = "SELECT stringid, id, lang, componentid, original, master, local, timemodified, timecustomized, outdated, modified
|
||||
FROM {report_customlang} s
|
||||
WHERE lang = ? AND componentid = ?
|
||||
ORDER BY stringid";
|
||||
$current = $DB->get_records_sql($sql, array($lang, $component->id));
|
||||
$english = $stringman->load_component_strings($component->name, 'en', true, true);
|
||||
if ($lang == 'en') {
|
||||
$master =& $english;
|
||||
} else {
|
||||
$master = $stringman->load_component_strings($component->name, $lang, true, true);
|
||||
}
|
||||
$local = $stringman->load_component_strings($component->name, $lang, true, false);
|
||||
|
||||
foreach ($english as $stringid => $stringoriginal) {
|
||||
$stringmaster = isset($master[$stringid]) ? $master[$stringid] : null;
|
||||
$stringlocal = isset($local[$stringid]) ? $local[$stringid] : null;
|
||||
$now = time();
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$done++;
|
||||
$donepercent = floor(min($done, self::ROUGH_NUMBER_OF_STRINGS) / self::ROUGH_NUMBER_OF_STRINGS * 100);
|
||||
$progressbar->update_full($donepercent, $strinprogress);
|
||||
}
|
||||
|
||||
if (isset($current[$stringid])) {
|
||||
$needsupdate = false;
|
||||
$currentoriginal = $current[$stringid]->original;
|
||||
$currentmaster = $current[$stringid]->master;
|
||||
$currentlocal = $current[$stringid]->local;
|
||||
|
||||
if ($currentoriginal !== $stringoriginal or $currentmaster !== $stringmaster) {
|
||||
$needsupdate = true;
|
||||
$current[$stringid]->original = $stringoriginal;
|
||||
$current[$stringid]->master = $stringmaster;
|
||||
$current[$stringid]->timemodified = $now;
|
||||
$current[$stringid]->outdated = 1;
|
||||
}
|
||||
|
||||
if ($stringmaster !== $stringlocal) {
|
||||
$needsupdate = true;
|
||||
$current[$stringid]->local = $stringlocal;
|
||||
$current[$stringid]->timecustomized = $now;
|
||||
}
|
||||
|
||||
if ($needsupdate) {
|
||||
$DB->update_record('report_customlang', $current[$stringid]);
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
$record = new stdclass();
|
||||
$record->lang = $lang;
|
||||
$record->componentid = $component->id;
|
||||
$record->stringid = $stringid;
|
||||
$record->original = $stringoriginal;
|
||||
$record->master = $stringmaster;
|
||||
$record->timemodified = $now;
|
||||
$record->outdated = 0;
|
||||
if ($stringmaster !== $stringlocal) {
|
||||
$record->local = $stringlocal;
|
||||
$record->timecustomized = $now;
|
||||
} else {
|
||||
$record->local = null;
|
||||
$record->timecustomized = null;
|
||||
}
|
||||
|
||||
$DB->insert_record('report_customlang', $record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$progressbar->update_full(100, get_string('checkoutdone', 'report_customlang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the translator database into disk files
|
||||
*
|
||||
* @param mixed $lang language code
|
||||
*/
|
||||
public static function checkin($lang) {
|
||||
global $DB, $USER, $CFG;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
if ($lang !== clean_param($lang, PARAM_LANG)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get all customized strings from updated components
|
||||
$sql = "SELECT s.*, c.name AS component
|
||||
FROM {report_customlang} s
|
||||
JOIN {report_customlang_components} c ON s.componentid = c.id
|
||||
WHERE s.lang = ?
|
||||
AND (s.local IS NOT NULL OR s.modified = 1)
|
||||
ORDER BY componentid, stringid";
|
||||
$strings = $DB->get_records_sql($sql, array($lang));
|
||||
|
||||
$files = array();
|
||||
foreach ($strings as $string) {
|
||||
if (!is_null($string->local)) {
|
||||
$files[$string->component][$string->stringid] = $string->local;
|
||||
}
|
||||
}
|
||||
|
||||
fulldelete(self::get_localpack_location($lang));
|
||||
foreach ($files as $component => $strings) {
|
||||
self::dump_strings($lang, $component, $strings);
|
||||
}
|
||||
|
||||
$DB->set_field_select('report_customlang', 'modified', 0, 'lang = ?', array($lang));
|
||||
$sm = get_string_manager();
|
||||
$sm->reset_caches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns full path to the directory where local packs are dumped into
|
||||
*
|
||||
* @param string $lang language code
|
||||
* @return string full path
|
||||
*/
|
||||
protected static function get_localpack_location($lang) {
|
||||
global $CFG;
|
||||
|
||||
return $CFG->langlocalroot.'/'.$lang.'_local';
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes strings into a local language pack file
|
||||
*
|
||||
* @param string $component the name of the component
|
||||
* @param array $strings
|
||||
*/
|
||||
protected static function dump_strings($lang, $component, $strings) {
|
||||
global $CFG;
|
||||
|
||||
if ($lang !== clean_param($lang, PARAM_LANG)) {
|
||||
debugging('Unable to dump local strings for non-installed language pack .'.s($lang));
|
||||
return false;
|
||||
}
|
||||
if ($component !== clean_param($component, PARAM_SAFEDIR)) {
|
||||
throw new coding_exception('Incorrect component name');
|
||||
}
|
||||
if (!$filename = self::get_component_filename($component)) {
|
||||
debugging('Unable to find the filename for the component '.s($component));
|
||||
return false;
|
||||
}
|
||||
if ($filename !== clean_param($filename, PARAM_FILE)) {
|
||||
throw new coding_exception('Incorrect file name '.s($filename));
|
||||
}
|
||||
list($package, $subpackage) = normalize_component($component);
|
||||
$packageinfo = " * @package $package";
|
||||
if (!is_null($subpackage)) {
|
||||
$packageinfo .= "\n * @subpackage $subpackage";
|
||||
}
|
||||
$filepath = self::get_localpack_location($lang);
|
||||
$filepath = $filepath.'/'.$filename;
|
||||
if (!is_dir(dirname($filepath))) {
|
||||
check_dir_exists(dirname($filepath));
|
||||
}
|
||||
|
||||
if (!$f = fopen($filepath, 'w')) {
|
||||
debugging('Unable to write '.s($filepath));
|
||||
return false;
|
||||
}
|
||||
fwrite($f, <<<EOF
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Local language pack from $CFG->wwwroot
|
||||
*
|
||||
$packageinfo
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
EOF
|
||||
);
|
||||
|
||||
foreach ($strings as $stringid => $text) {
|
||||
if ($stringid !== clean_param($stringid, PARAM_STRINGID)) {
|
||||
debugging('Invalid string identifier '.s($stringid));
|
||||
continue;
|
||||
}
|
||||
fwrite($f, '$string[\'' . $stringid . '\'] = ');
|
||||
fwrite($f, var_export($text, true));
|
||||
fwrite($f, ";\n");
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the file where the component's local strings should be exported into
|
||||
*
|
||||
* @param string $component normalized name of the component, eg 'core' or 'mod_workshop'
|
||||
* @return string|boolean filename eg 'moodle.php' or 'workshop.php', false if not found
|
||||
*/
|
||||
protected static function get_component_filename($component) {
|
||||
if (is_null(self::$components)) {
|
||||
self::$components = self::list_components();
|
||||
}
|
||||
$return = false;
|
||||
foreach (self::$components as $legacy => $normalized) {
|
||||
if ($component === $normalized) {
|
||||
$return = $legacy.'.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of modified strings checked out in the translator
|
||||
*
|
||||
* @param string $lang language code
|
||||
* @return int
|
||||
*/
|
||||
public static function get_count_of_modified($lang) {
|
||||
global $DB;
|
||||
|
||||
return $DB->count_records('report_customlang', array('lang'=>$lang, 'modified'=>1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves filter data into a persistant storage such as user session
|
||||
*
|
||||
* @see self::load_filter()
|
||||
* @param stdclass $data filter values
|
||||
* @param stdclass $persistant storage object
|
||||
*/
|
||||
public static function save_filter(stdclass $data, stdclass $persistant) {
|
||||
if (!isset($persistant->report_customlang_filter)) {
|
||||
$persistant->report_customlang_filter = array();
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key !== 'submit') {
|
||||
$persistant->report_customlang_filter[$key] = serialize($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the previously saved filter settings from a persistent storage
|
||||
*
|
||||
* @see self::save_filter()
|
||||
* @param stdclass $persistant storage object
|
||||
* @return stdclass filter data
|
||||
*/
|
||||
public static function load_filter(stdclass $persistant) {
|
||||
$data = new stdclass();
|
||||
if (isset($persistant->report_customlang_filter)) {
|
||||
foreach ($persistant->report_customlang_filter as $key => $value) {
|
||||
$data->{$key} = unserialize($value);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the action menu of the report
|
||||
*/
|
||||
class report_customlang_menu implements renderable {
|
||||
|
||||
/** @var menu items */
|
||||
protected $items = array();
|
||||
|
||||
public function __construct(array $items = array()) {
|
||||
global $CFG;
|
||||
|
||||
foreach ($items as $itemkey => $item) {
|
||||
$this->add_item($itemkey, $item['title'], $item['url'], empty($item['method']) ? 'post' : $item['method']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu items
|
||||
*
|
||||
* @return array (string)key => (object)[->(string)title ->(moodle_url)url ->(string)method]
|
||||
*/
|
||||
public function get_items() {
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds item into the menu
|
||||
*
|
||||
* @param string $key item identifier
|
||||
* @param string $title localized action title
|
||||
* @param moodle_url $url action handler
|
||||
* @param string $method form method
|
||||
*/
|
||||
public function add_item($key, $title, moodle_url $url, $method) {
|
||||
if (isset($this->items[$key])) {
|
||||
throw new coding_exception('Menu item already exists');
|
||||
}
|
||||
if (empty($title) or empty($key)) {
|
||||
throw new coding_exception('Empty title or item key not allowed');
|
||||
}
|
||||
$item = new stdclass();
|
||||
$item->title = $title;
|
||||
$item->url = $url;
|
||||
$item->method = $method;
|
||||
$this->items[$key] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the translation tool
|
||||
*/
|
||||
class report_customlang_translator implements renderable {
|
||||
|
||||
/** @const int number of rows per page */
|
||||
const PERPAGE = 100;
|
||||
|
||||
/** @var int total number of the rows int the table */
|
||||
public $numofrows = 0;
|
||||
|
||||
/** @var moodle_url */
|
||||
public $handler;
|
||||
|
||||
/** @var string language code */
|
||||
public $lang;
|
||||
|
||||
/** @var int page to display, starting with page 0 */
|
||||
public $currentpage = 0;
|
||||
|
||||
/** @var array of stdclass strings to display */
|
||||
public $strings = array();
|
||||
|
||||
/** @var stdclass */
|
||||
protected $filter;
|
||||
|
||||
public function __construct(moodle_url $handler, $lang, $filter, $currentpage = 0) {
|
||||
global $DB;
|
||||
|
||||
$this->handler = $handler;
|
||||
$this->lang = $lang;
|
||||
$this->filter = $filter;
|
||||
$this->currentpage = $currentpage;
|
||||
|
||||
if (empty($filter) or empty($filter->component)) {
|
||||
// nothing to do
|
||||
$this->currentpage = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($filter->component, SQL_PARAMS_NAMED);
|
||||
|
||||
$csql = "SELECT COUNT(*)";
|
||||
$fsql = "SELECT s.id, s.*, c.name AS component";
|
||||
$sql = " FROM {report_customlang_components} c
|
||||
JOIN {report_customlang} s ON s.componentid = c.id
|
||||
WHERE s.lang = :lang
|
||||
AND c.name $insql";
|
||||
|
||||
$params = array_merge(array('lang' => $lang), $inparams);
|
||||
|
||||
if (!empty($filter->customized)) {
|
||||
$sql .= " AND s.local IS NOT NULL";
|
||||
}
|
||||
|
||||
if (!empty($filter->modified)) {
|
||||
$sql .= " AND s.modified = 1";
|
||||
}
|
||||
|
||||
if (!empty($filter->stringid)) {
|
||||
$sql .= " AND s.stringid = :stringid";
|
||||
$params['stringid'] = $filter->stringid;
|
||||
}
|
||||
|
||||
if (!empty($filter->substring)) {
|
||||
$sql .= " AND (".$DB->sql_like('s.original', ':substringoriginal', false)." OR
|
||||
".$DB->sql_like('s.master', ':substringmaster', false)." OR
|
||||
".$DB->sql_like('s.local', ':substringlocal', false).")";
|
||||
$params['substringoriginal'] = '%'.$filter->substring.'%';
|
||||
$params['substringmaster'] = '%'.$filter->substring.'%';
|
||||
$params['substringlocal'] = '%'.$filter->substring.'%';
|
||||
}
|
||||
|
||||
if (!empty($filter->helps)) {
|
||||
$sql .= " AND ".$DB->sql_like('s.stringid', ':help', false); //ILIKE
|
||||
$params['help'] = '%\_help';
|
||||
} else {
|
||||
$sql .= " AND ".$DB->sql_like('s.stringid', ':link', false, true, true); //NOT ILIKE
|
||||
$params['link'] = '%\_link';
|
||||
}
|
||||
|
||||
$osql = " ORDER BY c.name, s.stringid";
|
||||
|
||||
$this->numofrows = $DB->count_records_sql($csql.$sql, $params);
|
||||
$this->strings = $DB->get_records_sql($fsql.$sql.$osql, $params, ($this->currentpage) * self::PERPAGE, self::PERPAGE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
M.report_customlang = M.report_customlang || {};
|
||||
|
||||
/**
|
||||
* YUI instance holder
|
||||
*/
|
||||
M.report_customlang.Y = {};
|
||||
|
||||
/**
|
||||
* Initialize JS support for the edit.php
|
||||
*
|
||||
* @param {Object} Y YUI instance
|
||||
*/
|
||||
M.report_customlang.init_editor = function(Y) {
|
||||
M.report_customlang.Y = Y;
|
||||
|
||||
Y.all('#translator .local textarea').each(function (textarea) {
|
||||
var cell = textarea.get('parentNode');
|
||||
textarea.setStyle('height', cell.getComputedStyle('height'));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Output rendering of Language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Rendering methods for the report widgets
|
||||
*/
|
||||
class report_customlang_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Renders customlang report menu
|
||||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function render_report_customlang_menu(report_customlang_menu $menu) {
|
||||
$output = '';
|
||||
foreach ($menu->get_items() as $item) {
|
||||
$output .= $this->single_button($item->url, $item->title, $item->method);
|
||||
}
|
||||
return $this->box($output, 'menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders customlang translation table
|
||||
*
|
||||
* @param report_customlang_translator $translator
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function render_report_customlang_translator(report_customlang_translator $translator) {
|
||||
$output = '';
|
||||
|
||||
if (empty($translator->strings)) {
|
||||
return $this->heading(get_string('nostringsfound', 'report_customlang'), 3);
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->id = 'translator';
|
||||
$table->head = array(
|
||||
get_string('headingcomponent', 'report_customlang'),
|
||||
get_string('headingstringid', 'report_customlang'),
|
||||
get_string('headingstandard', 'report_customlang'),
|
||||
get_string('headinglocal', 'report_customlang'),
|
||||
);
|
||||
|
||||
foreach ($translator->strings as $string) {
|
||||
$cells = array();
|
||||
// component name
|
||||
$cells[0] = new html_table_cell($string->component);
|
||||
$cells[0]->attributes['class'] = 'component';
|
||||
// string identification code
|
||||
$cells[1] = new html_table_cell(html_writer::tag('div', s($string->stringid), array('class' => 'stringid')));
|
||||
$cells[1]->attributes['class'] = 'stringid';
|
||||
// master translation of the string
|
||||
$master = html_writer::tag('div', s($string->master), array('class' => 'preformatted'));
|
||||
$minheight = strlen($string->master) / 200;
|
||||
if (preg_match('/\{\$a(->.+)?\}/', $string->master)) {
|
||||
$master .= html_writer::tag('div', $this->help_icon('placeholder', 'report_customlang',
|
||||
get_string('placeholderwarning', 'report_customlang')), array('class' => 'placeholderinfo'));
|
||||
}
|
||||
$cells[2] = new html_table_cell($master);
|
||||
$cells[2]->attributes['class'] = 'standard master';
|
||||
// local customization of the string
|
||||
$textareaattributes = array('name'=>'cust['.$string->id.']', 'cols'=>40, 'rows'=>3);
|
||||
if ($minheight>1) {
|
||||
$textareaattributes['style'] = 'min-height:' . (int) 4*$minheight . 'em;';
|
||||
}
|
||||
$textarea = html_writer::tag('textarea', s($string->local), $textareaattributes);
|
||||
$cells[3] = new html_table_cell($textarea);
|
||||
if (!is_null($string->local) and $string->outdated) {
|
||||
$mark = html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'update_' . $string->id,
|
||||
'name' => 'updates[]', 'value' => $string->id));
|
||||
$help = $this->help_icon('markinguptodate', 'report_customlang');
|
||||
$mark .= html_writer::tag('label', get_string('markuptodate', 'report_customlang') . $help,
|
||||
array('for' => 'update_' . $string->id));
|
||||
$mark = html_writer::tag('div', $mark, array('class' => 'uptodatewrapper'));
|
||||
} else {
|
||||
$mark = '';
|
||||
}
|
||||
$cells[3] = new html_table_cell($textarea."\n".$mark);
|
||||
$cells[3]->attributes['class'] = 'local';
|
||||
$cells[3]->id = 'id_'.$string->id;
|
||||
if (!is_null($string->local)) {
|
||||
$cells[3]->attributes['class'] .= ' customized';
|
||||
}
|
||||
if ($string->outdated) {
|
||||
$cells[3]->attributes['class'] .= ' outdated';
|
||||
}
|
||||
if ($string->modified) {
|
||||
$cells[3]->attributes['class'] .= ' modified';
|
||||
}
|
||||
|
||||
if ($string->original !== $string->master) {
|
||||
$cells[0]->rowspan = $cells[1]->rowspan = $cells[3]->rowspan = 2;
|
||||
}
|
||||
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
|
||||
if ($string->original !== $string->master) {
|
||||
$cells = array();
|
||||
// original of the string
|
||||
$cells[2] = new html_table_cell(html_writer::tag('div', s($string->original), array('class' => 'preformatted')));
|
||||
$cells[2]->attributes['class'] = 'standard original';
|
||||
$row = new html_table_row($cells);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$output .= html_writer::start_tag('form', array('method'=>'post', 'action'=>$translator->handler->out()));
|
||||
$output .= html_writer::start_tag('div');
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'translatorsubmitted', 'value'=>1));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
$save1 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecontinue', 'value'=>get_string('savecontinue', 'report_customlang')));
|
||||
$save2 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecheckin', 'value'=>get_string('savecheckin', 'report_customlang')));
|
||||
$output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
|
||||
$output .= html_writer::table($table);
|
||||
$output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('form');
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$ADMIN->add('language', new admin_externalpage('reportcustomlang', get_string('pluginname', 'report_customlang'), "$CFG->wwwroot/$CFG->admin/report/customlang/index.php", 'report/customlang:view'));
|
||||
@@ -0,0 +1,69 @@
|
||||
.path-admin-report-customlang .langselectorbox,
|
||||
.path-admin-report-customlang fieldset.buttonsbar,
|
||||
.path-admin-report-customlang .menu {
|
||||
margin: 5px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang .menu .singlebutton,
|
||||
.path-admin-report-customlang .menu .singlebutton form,
|
||||
.path-admin-report-customlang .menu .singlebutton form div {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
|
||||
.path-admin-report-customlang .mform.filterform {
|
||||
width: 70%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang .mform.filterform .fitem .fitemtitle {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang .mform.filterform .fitem .felement {
|
||||
width: 60%;
|
||||
margin-left: 31%;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .standard,
|
||||
.path-admin-report-customlang #translator .local {
|
||||
min-width: 35%;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .customized {
|
||||
background-color: #e7f1c3;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .customized.outdated {
|
||||
background-color: #f3f2aa;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .modified {
|
||||
background-color: #ffd3d9;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .customized.modified {
|
||||
background-color: #d2ebff;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator textarea {
|
||||
width: 100%;
|
||||
min-height: 4em;
|
||||
}
|
||||
|
||||
.path-admin-report-customlang #translator .placeholderinfo {
|
||||
text-align: center;
|
||||
border: 1px dotted #ddd;
|
||||
background-color: #f6f6f6;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
#page-admin-report-customlang-index .continuebutton {
|
||||
margin-top: 1em;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2011041900;
|
||||
$plugin->requires = 2010120700;
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
// just a link to course report
|
||||
$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/course/report/log/index.php?id=".SITEID, 'coursereport/log:view'));
|
||||
$ADMIN->add('reports', new admin_externalpage('reportloglive', get_string('loglive', 'coursereport_log'), "$CFG->wwwroot/course/report/log/indexlive.php?id=".SITEID, 'coursereport/log:viewlive'));
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package core
|
||||
* @subpackage profiling
|
||||
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// TODO: Move all the DB stuff to profiling_db_xxxx() function in xhprof_moodle.php
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
|
||||
|
||||
define('PROFILING_RUNSPERPAGE', 50);
|
||||
|
||||
// page parameters
|
||||
$script = optional_param('script', null, PARAM_PATH);
|
||||
$runid = optional_param('runid', null, PARAM_ALPHANUM);
|
||||
$runid2 = optional_param('runid2', null, PARAM_ALPHANUM);
|
||||
$listurl = optional_param('listurl', null, PARAM_PATH);
|
||||
$runreference= optional_param('runreference', 0, PARAM_INT);
|
||||
$runcomment = optional_param('runcomment', null, PARAM_TEXT);
|
||||
|
||||
$dbfields = 'runid, url, totalexecutiontime, totalcputime, ' .
|
||||
'totalcalls, totalmemory, runreference, runcomment, timecreated';
|
||||
|
||||
admin_externalpage_setup('reportprofiling');
|
||||
|
||||
// Always add listurl if available
|
||||
if ($listurl) {
|
||||
$listurlnav = new moodle_url('/admin/report/profiling/index.php', array('listurl' => $listurl));
|
||||
$PAGE->navbar->add($listurl, $listurlnav);
|
||||
}
|
||||
|
||||
// Header
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// We have requested the last available run for one script
|
||||
if (isset($script)) {
|
||||
// Get the last available run for the given script
|
||||
$run = $DB->get_record_sql("SELECT $dbfields
|
||||
FROM {profiling}
|
||||
WHERE url = ?
|
||||
AND id = (SELECT MAX(id)
|
||||
FROM {profiling}
|
||||
WHERE url = ?)",
|
||||
array($script, $script), IGNORE_MISSING);
|
||||
|
||||
// No run found for script, warn and exit
|
||||
if (!$run) {
|
||||
notice(get_string('cannotfindanyrunforurl', 'report_profiling', $script), 'index.php');
|
||||
}
|
||||
|
||||
// Check if there is any previous run marked as reference one
|
||||
$prevreferences = $DB->get_records_select('profiling',
|
||||
'url = ? AND runreference = 1 AND timecreated < ?',
|
||||
array($run->url, $run->timecreated),
|
||||
'timecreated DESC', 'runid', 0, 1);
|
||||
$prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
$header = get_string('lastrunof', 'report_profiling', $script);
|
||||
echo $OUTPUT->heading($header);
|
||||
$table = profiling_print_run($run, $prevrunid);
|
||||
echo $table;
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
// We have requested the diff between 2 runs
|
||||
} else if (isset($runid) && isset($runid2)) {
|
||||
$run1 = $DB->get_record('profiling', array('runid'=>$runid), $dbfields, MUST_EXIST);
|
||||
$run2 = $DB->get_record('profiling', array('runid'=>$runid2), $dbfields, MUST_EXIST);
|
||||
if ($run1->url == $run2->url && $run1->runid != $run2->runid) {
|
||||
if ($run2->timecreated < $run1->timecreated) {
|
||||
$runtemp = $run1;
|
||||
$run1 = $run2;
|
||||
$run2 = $runtemp;
|
||||
}
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
$header = get_string('differencesbetween2runsof', 'report_profiling', $run1->url);
|
||||
echo $OUTPUT->heading($header);
|
||||
$table = profiling_print_rundiff($run1, $run2);
|
||||
echo $table;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
|
||||
// We have requested one run, invoke it
|
||||
} else if (isset($runid)) {
|
||||
// Check if we are trying to update the runreference/runcomment for the run
|
||||
if (isset($runcomment) && confirm_sesskey()) {
|
||||
$id = $DB->get_field('profiling', 'id', array('runid' => $runid), MUST_EXIST);
|
||||
$rec = new stdClass();
|
||||
$rec->id = $id;
|
||||
$rec->runreference = (bool)$runreference;
|
||||
$rec->runcomment = $runcomment;
|
||||
$DB->update_record('profiling', $rec);
|
||||
}
|
||||
// Get the requested runid
|
||||
$run = $DB->get_record('profiling', array('runid'=>$runid), $dbfields, IGNORE_MISSING);
|
||||
|
||||
// No run found for runid, warn and exit
|
||||
if (!$run) {
|
||||
notice(get_string('cannotfindanyrunforrunid', 'report_profiling', $runid), 'index.php');
|
||||
}
|
||||
|
||||
// Check if there is any previous run marked as reference one
|
||||
$prevreferences = $DB->get_records_select('profiling',
|
||||
'url = ? AND runreference = 1 AND timecreated < ?',
|
||||
array($run->url, $run->timecreated),
|
||||
'timecreated DESC', 'runid', 0, 1);
|
||||
$prevrunid = $prevreferences ? reset($prevreferences)->runid : false;
|
||||
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
|
||||
$header = get_string('summaryof', 'report_profiling', $run->url);
|
||||
echo $OUTPUT->heading($header);
|
||||
$table = profiling_print_run($run, $prevrunid);
|
||||
echo $table;
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
// Default: List one page of runs
|
||||
} else {
|
||||
|
||||
// The flexitable that will root listings
|
||||
$table = new xhprof_table_sql('profiling-list-table');
|
||||
$baseurl = $CFG->wwwroot . '/admin/report/profiling/index.php';
|
||||
|
||||
// Check if we are listing all or some URL ones
|
||||
$sqlconditions = '';
|
||||
$sqlparams = array();
|
||||
if (!isset($listurl)) {
|
||||
$header = get_string('pluginname', 'report_profiling');
|
||||
$sqlconditions = '1 = 1';
|
||||
$table->set_listurlmode(false);
|
||||
} else {
|
||||
$header = get_string('profilingrunsfor', 'report_profiling', $listurl);
|
||||
$sqlconditions = 'url = :url';
|
||||
$sqlparams['url'] = $listurl;
|
||||
$table->set_listurlmode(true);
|
||||
$baseurl .= '?listurl=' . urlencode($listurl);
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading($header);
|
||||
|
||||
// TODO: Fix flexitable to validate tsort/thide/tshow/tifirs/tilast/page
|
||||
// TODO: Fix table_sql to allow it to work without WHERE clause
|
||||
// add silly condition (1 = 1) because of table_sql bug
|
||||
$table->set_sql($dbfields, '{profiling}', $sqlconditions, $sqlparams);
|
||||
$table->set_count_sql("SELECT COUNT(*) FROM {profiling} WHERE $sqlconditions", $sqlparams);
|
||||
$columns = array(
|
||||
'url', 'timecreated', 'totalexecutiontime', 'totalcputime',
|
||||
'totalcalls', 'totalmemory', 'runcomment');
|
||||
$headers = array(
|
||||
get_string('url'), get_string('date'), get_string('executiontime', 'report_profiling'),
|
||||
get_string('cputime', 'report_profiling'), get_string('calls', 'report_profiling'),
|
||||
get_string('memory', 'report_profiling'), get_string('comment', 'report_profiling'));
|
||||
$table->define_columns($columns);
|
||||
$table->define_headers($headers);
|
||||
$table->sortable(true, 'timecreated', SORT_DESC);
|
||||
$table->define_baseurl($baseurl);
|
||||
$table->column_suppress('url');
|
||||
$table->out(PROFILING_RUNSPERPAGE, true);
|
||||
|
||||
// Print the controller block with different options
|
||||
echo profiling_list_controls($listurl);
|
||||
}
|
||||
|
||||
// Footer.
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_profiling', language 'en', branch 'MOODLE_20_STABLE'
|
||||
*
|
||||
* @package report_profiling
|
||||
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['calls'] = 'Function calls';
|
||||
$string['cannotfindanyrunforurl'] = 'Sorry, cannot find any profiling run for the \'{$a}\' URL';
|
||||
$string['cannotfindanyrunforrunid'] = 'Sorry, cannot find the \'{$a}\' profiling run';
|
||||
$string['comment'] = 'Comment';
|
||||
$string['differencesbetween2runsof'] = 'Differences between 2 runs of {$a}';
|
||||
$string['executiontime'] = 'Execution time';
|
||||
$string['cputime'] = 'CPU time';
|
||||
$string['lastrunof'] = 'Summary of last run of {$a}';
|
||||
$string['markreferencerun'] = 'Mark as reference run/comment';
|
||||
$string['memory'] = 'Memory used';
|
||||
$string['pluginname'] = 'Profiling runs';
|
||||
$string['profilingfocusscript'] = 'Focus on profiling runs for the script: {$a}';
|
||||
$string['profilingruns'] = 'Profiling runs';
|
||||
$string['profilingrunsfor'] = 'Profiling runs for {$a}';
|
||||
$string['referencerun'] = 'Reference run/comment';
|
||||
$string['runid'] = 'Run ID';
|
||||
$string['summaryof'] = 'Summary of {$a}';
|
||||
$string['viewdetails'] = 'View profiling details';
|
||||
$string['viewdiff'] = 'View profiling differences with last reference run';
|
||||
$string['viewdiffdetails'] = 'View profiling diff details';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user