MDL-17427 another round of refactoring of upgrade related functions - this should be final now I hope ;-)

This commit is contained in:
skodak 2009-01-29 19:58:47 +00:00
parent 1f20942c3b
commit 0cb93a7e45
20 changed files with 126 additions and 126 deletions

View File

@ -804,7 +804,7 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
/// return to original debugging level
$CFG->debug = $origdebug;
error_reporting($CFG->debug);
upgrade_log_start();
upgrade_started();
/// Both old .sql files and new install.xml are supported
/// But we prioritise install.xml (XMLDB) if present
@ -930,7 +930,7 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
/// return to original debugging level
$CFG->debug = $origdebug;
error_reporting($CFG->debug);
upgrade_log_start();
upgrade_started();
/// Upgrade current language pack if we can
upgrade_language_pack();
@ -1050,7 +1050,7 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
/// just make sure upgrade logging is properly terminated
upgrade_log_finish();
upgrade_finished();
/// Set up the site
if (! $site = get_site()) {

View File

@ -146,10 +146,10 @@
}
}
upgrade_log_start(true); // does not store ugprade runnign flag
upgrade_started(true); // does not store ugprade runnign flag
print_heading('coresystem');
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
upgrade_log_start(); // we want the flag to be stored in config table ;-)
upgrade_started(); // we want the flag to be stored in config table ;-)
/// set all core default records and default settings
require_once("$CFG->libdir/db/install.php");
@ -263,7 +263,7 @@
/// return to original debugging level
$CFG->debug = $origdebug;
error_reporting($CFG->debug);
upgrade_log_start();
upgrade_started();
/// Upgrade current language pack if we can
if (empty($CFG->skiplangupgrade)) {
@ -331,7 +331,7 @@
$sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
if (!$sessionstarted) {
// we neeed this redirect to setup proper session
upgrade_log_finish("index.php?sessionstarted=1&lang=$CFG->lang");
upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang");
}
$adminuser = create_admin_user();
$adminuser->newadminuser = 1;
@ -340,7 +340,7 @@
} else {
/// just make sure upgrade logging is properly terminated
upgrade_log_finish('upgradesettings.php');
upgrade_finished('upgradesettings.php');
}
// Turn xmlstrictheaders back on now.

View File

@ -101,7 +101,7 @@ die;die;die;
upgrade_local_db($return_url); // Return here afterwards
/// just make sure upgrade logging is properly terminated
upgrade_log_finish();
upgrade_finished();
/// make sure admin user is created - this is the last step because we need
/// session to be working properly in order to edit admin account

View File

@ -28,7 +28,7 @@ define('INSECURE_DATAROOT_ERROR', 2);
* @return void
*
*/
function upgrade_log_display_entry($module, $action, $mtable, $field) {
function update_log_display_entry($module, $action, $mtable, $field) {
global $DB;
if ($type = $DB->get_record('log_display', array('module'=>$module, 'action'=>$action))) {
@ -424,7 +424,7 @@ function upgrade_plugins($type, $dir) {
$info->pluginversion = $plugin->version;
$info->currentmoodle = $CFG->version;
$info->requiremoodle = $plugin->requires;
upgrade_log_start();
upgrade_started();
notify(get_string('pluginrequirementsnotmet', 'error', $info));
$updated_plugins = true;
continue;
@ -444,7 +444,7 @@ function upgrade_plugins($type, $dir) {
// do nothing
} else if ($installedversion < $plugin->version) {
$updated_plugins = true;
upgrade_log_start();
upgrade_started();
print_heading($dir.'/'. $plugin->name .' plugin needs upgrading');
@set_time_limit(0); // To allow slow databases to complete the long SQL
@ -565,7 +565,7 @@ function upgrade_activity_modules() {
$info->moduleversion = $module->version;
$info->currentmoodle = $CFG->version;
$info->requiremoodle = $module->requires;
upgrade_log_start();
upgrade_started();
notify(get_string('modulerequirementsnotmet', 'error', $info));
continue;
}
@ -584,7 +584,7 @@ function upgrade_activity_modules() {
notify('Upgrade file ' . $mod . ': ' . $fullmod . '/db/upgrade.php is not readable');
continue;
}
upgrade_log_start();
upgrade_started();
print_heading($module->name .' module needs upgrading');
@ -625,7 +625,7 @@ function upgrade_activity_modules() {
}
} else { // module not installed yet, so install it
upgrade_log_start();
upgrade_started();
print_heading($module->name);
/// Execute install.xml (XMLDB) - must be present
@ -852,7 +852,7 @@ function create_admin_user($user_input=NULL) {
* Marks start of upgrade, blocks any other access to site.
* The upgrade is finished at the end of script or after timeout.
*/
function upgrade_log_start($preinstall=false) {
function upgrade_started($preinstall=false) {
global $CFG, $DB;
static $started = false;
@ -885,7 +885,7 @@ function upgrade_log_start($preinstall=false) {
* Internal function - executed if upgrade interruped.
*/
function upgrade_finished_handler() {
upgrade_log_finish();
upgrade_finished();
}
/**
@ -893,7 +893,7 @@ function upgrade_finished_handler() {
*
* This function may be called repeatedly.
*/
function upgrade_log_finish($continueurl=null) {
function upgrade_finished($continueurl=null) {
global $CFG, $DB;
if (!empty($CFG->upgraderunning)) {

View File

@ -1172,7 +1172,7 @@ function upgrade_blocks_plugins() {
// do nothing
} else if ($currblock->version < $block->version) {
$updated_blocks = true;
upgrade_log_start();
upgrade_started();
print_heading('New version of '.$blocktitle.' ('.$block->name.') exists');
@set_time_limit(0); // To allow slow databases to complete the long SQL
@ -1239,7 +1239,7 @@ function upgrade_blocks_plugins() {
print_error('blocknameconflict', '', '', (object)array('name'=>$block->name, 'conflict'=>$conflictblock));
}
$updated_blocks = true;
upgrade_log_start();
upgrade_started();
print_heading($block->name);
@set_time_limit(0); // To allow slow databases to complete the long SQL

View File

@ -106,24 +106,24 @@ function xmldb_main_install() {
$DB->insert_record('mnet_application', $mnet_app);
/// insert log entries - replaces statements section in install.xml
upgrade_log_display_entry('user', 'view', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('course', 'user report', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('course', 'view', 'course', 'fullname');
upgrade_log_display_entry('course', 'update', 'course', 'fullname');
upgrade_log_display_entry('course', 'enrol', 'course', 'fullname');
upgrade_log_display_entry('course', 'unenrol', 'course', 'fullname');
upgrade_log_display_entry('course', 'report log', 'course', 'fullname');
upgrade_log_display_entry('course', 'report live', 'course', 'fullname');
upgrade_log_display_entry('course', 'report outline', 'course', 'fullname');
upgrade_log_display_entry('course', 'report participation', 'course', 'fullname');
upgrade_log_display_entry('course', 'report stats', 'course', 'fullname');
upgrade_log_display_entry('message', 'write', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('message', 'read', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('message', 'add contact', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('message', 'remove contact', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('message', 'block contact', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('message', 'unblock contact', 'user', 'CONCAT(firstname,\' \',lastname)');
upgrade_log_display_entry('group', 'view', 'groups', 'name');
update_log_display_entry('user', 'view', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('course', 'user report', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('course', 'view', 'course', 'fullname');
update_log_display_entry('course', 'update', 'course', 'fullname');
update_log_display_entry('course', 'enrol', 'course', 'fullname');
update_log_display_entry('course', 'unenrol', 'course', 'fullname');
update_log_display_entry('course', 'report log', 'course', 'fullname');
update_log_display_entry('course', 'report live', 'course', 'fullname');
update_log_display_entry('course', 'report outline', 'course', 'fullname');
update_log_display_entry('course', 'report participation', 'course', 'fullname');
update_log_display_entry('course', 'report stats', 'course', 'fullname');
update_log_display_entry('message', 'write', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'read', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'add contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'remove contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'block contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'unblock contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('group', 'view', 'groups', 'name');
/// Create guest record

View File

@ -127,7 +127,7 @@ function upgrade_local_db() {
require($CFG->dirroot.'/local/version.php'); // Get code versions
if (empty($CFG->local_version)) { // install
upgrade_log_start();
upgrade_started();
if (file_exists($CFG->dirroot.'/local/db/install.php')) {
require_once($CFG->dirroot.'/local/db/install.php');
xmldb_local_install();
@ -142,7 +142,7 @@ function upgrade_local_db() {
return true;
} else if ($local_version > $CFG->local_version) { // upgrade!
upgrade_log_start();
upgrade_started();
if (file_exists($CFG->dirroot.'/local/db/upgrade.php')) {
require_once($CFG->dirroot.'/local/db/upgrade.php');
xmldb_local_upgrade($CFG->local_version);

View File

@ -9,10 +9,10 @@ function xmldb_assignment_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('assignment', 'view', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'add', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'update', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'view submission', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'upload', 'assignment', 'name');
update_log_display_entry('assignment', 'view', 'assignment', 'name');
update_log_display_entry('assignment', 'add', 'assignment', 'name');
update_log_display_entry('assignment', 'update', 'assignment', 'name');
update_log_display_entry('assignment', 'view submission', 'assignment', 'name');
update_log_display_entry('assignment', 'upload', 'assignment', 'name');
}

View File

@ -9,9 +9,9 @@ function xmldb_chat_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('chat', 'view', 'chat', 'name');
upgrade_log_display_entry('chat', 'add', 'chat', 'name');
upgrade_log_display_entry('chat', 'update', 'chat', 'name');
upgrade_log_display_entry('chat', 'report', 'chat', 'name');
upgrade_log_display_entry('chat', 'talk', 'chat', 'name');
update_log_display_entry('chat', 'view', 'chat', 'name');
update_log_display_entry('chat', 'add', 'chat', 'name');
update_log_display_entry('chat', 'update', 'chat', 'name');
update_log_display_entry('chat', 'report', 'chat', 'name');
update_log_display_entry('chat', 'talk', 'chat', 'name');
}

View File

@ -9,11 +9,11 @@ function xmldb_choice_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('choice', 'view', 'choice', 'name');
upgrade_log_display_entry('choice', 'update', 'choice', 'name');
upgrade_log_display_entry('choice', 'add', 'choice', 'name');
upgrade_log_display_entry('choice', 'report', 'choice', 'name');
upgrade_log_display_entry('choice', 'choose', 'choice', 'name');
upgrade_log_display_entry('choice', 'choose again', 'choice', 'name');
update_log_display_entry('choice', 'view', 'choice', 'name');
update_log_display_entry('choice', 'update', 'choice', 'name');
update_log_display_entry('choice', 'add', 'choice', 'name');
update_log_display_entry('choice', 'report', 'choice', 'name');
update_log_display_entry('choice', 'choose', 'choice', 'name');
update_log_display_entry('choice', 'choose again', 'choice', 'name');
}

View File

@ -9,13 +9,13 @@ function xmldb_data_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('data', 'view', 'data', 'name');
upgrade_log_display_entry('data', 'add', 'data', 'name');
upgrade_log_display_entry('data', 'update', 'data', 'name');
upgrade_log_display_entry('data', 'record delete', 'data', 'name');
upgrade_log_display_entry('data', 'fields add', 'data_fields', 'name');
upgrade_log_display_entry('data', 'fields update', 'data_fields', 'name');
upgrade_log_display_entry('data', 'templates saved', 'data', 'name');
upgrade_log_display_entry('data', 'templates def', 'data', 'name');
update_log_display_entry('data', 'view', 'data', 'name');
update_log_display_entry('data', 'add', 'data', 'name');
update_log_display_entry('data', 'update', 'data', 'name');
update_log_display_entry('data', 'record delete', 'data', 'name');
update_log_display_entry('data', 'fields add', 'data_fields', 'name');
update_log_display_entry('data', 'fields update', 'data_fields', 'name');
update_log_display_entry('data', 'templates saved', 'data', 'name');
update_log_display_entry('data', 'templates def', 'data', 'name');
}

View File

@ -9,10 +9,10 @@ function xmldb_feedback_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('feedback', 'startcomplete', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'submit', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'delete', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'view', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'view all', 'course', 'shortname');
update_log_display_entry('feedback', 'startcomplete', 'feedback', 'name');
update_log_display_entry('feedback', 'submit', 'feedback', 'name');
update_log_display_entry('feedback', 'delete', 'feedback', 'name');
update_log_display_entry('feedback', 'view', 'feedback', 'name');
update_log_display_entry('feedback', 'view all', 'course', 'shortname');
}

View File

@ -9,17 +9,17 @@ function xmldb_forum_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('forum', 'add', 'forum', 'name');
upgrade_log_display_entry('forum', 'update', 'forum', 'name');
upgrade_log_display_entry('forum', 'add discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'add post', 'forum_posts', 'subject');
upgrade_log_display_entry('forum', 'update post', 'forum_posts', 'subject');
upgrade_log_display_entry('forum', 'user report', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)');
upgrade_log_display_entry('forum', 'move discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'view subscribers', 'forum', 'name');
upgrade_log_display_entry('forum', 'view discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'view forum', 'forum', 'name');
upgrade_log_display_entry('forum', 'subscribe', 'forum', 'name');
upgrade_log_display_entry('forum', 'unsubscribe', 'forum', 'name');
update_log_display_entry('forum', 'add', 'forum', 'name');
update_log_display_entry('forum', 'update', 'forum', 'name');
update_log_display_entry('forum', 'add discussion', 'forum_discussions', 'name');
update_log_display_entry('forum', 'add post', 'forum_posts', 'subject');
update_log_display_entry('forum', 'update post', 'forum_posts', 'subject');
update_log_display_entry('forum', 'user report', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)');
update_log_display_entry('forum', 'move discussion', 'forum_discussions', 'name');
update_log_display_entry('forum', 'view subscribers', 'forum', 'name');
update_log_display_entry('forum', 'view discussion', 'forum_discussions', 'name');
update_log_display_entry('forum', 'view forum', 'forum', 'name');
update_log_display_entry('forum', 'subscribe', 'forum', 'name');
update_log_display_entry('forum', 'unsubscribe', 'forum', 'name');
}

View File

@ -9,19 +9,19 @@ function xmldb_glossary_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('glossary', 'add', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view all', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'delete category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'delete comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'approve entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view entry', 'glossary_entries', 'concept');
update_log_display_entry('glossary', 'add', 'glossary', 'name');
update_log_display_entry('glossary', 'update', 'glossary', 'name');
update_log_display_entry('glossary', 'view', 'glossary', 'name');
update_log_display_entry('glossary', 'view all', 'glossary', 'name');
update_log_display_entry('glossary', 'add entry', 'glossary', 'name');
update_log_display_entry('glossary', 'update entry', 'glossary', 'name');
update_log_display_entry('glossary', 'add category', 'glossary', 'name');
update_log_display_entry('glossary', 'update category', 'glossary', 'name');
update_log_display_entry('glossary', 'delete category', 'glossary', 'name');
update_log_display_entry('glossary', 'add comment', 'glossary', 'name');
update_log_display_entry('glossary', 'update comment', 'glossary', 'name');
update_log_display_entry('glossary', 'delete comment', 'glossary', 'name');
update_log_display_entry('glossary', 'approve entry', 'glossary', 'name');
update_log_display_entry('glossary', 'view entry', 'glossary_entries', 'concept');
}

View File

@ -9,7 +9,7 @@ function xmldb_label_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('label', 'add', 'label', 'name');
upgrade_log_display_entry('label', 'update', 'label', 'name');
update_log_display_entry('label', 'add', 'label', 'name');
update_log_display_entry('label', 'update', 'label', 'name');
}

View File

@ -9,8 +9,8 @@ function xmldb_lesson_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('lesson', 'start', 'lesson', 'name');
upgrade_log_display_entry('lesson', 'end', 'lesson', 'name');
upgrade_log_display_entry('lesson', 'view', 'lesson_pages', 'title');
update_log_display_entry('lesson', 'start', 'lesson', 'name');
update_log_display_entry('lesson', 'end', 'lesson', 'name');
update_log_display_entry('lesson', 'view', 'lesson_pages', 'title');
}

View File

@ -9,18 +9,18 @@ function xmldb_quiz_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('quiz', 'add', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'update', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'view', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'report', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'attempt', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'submit', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'review', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'editquestions', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'preview', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'start attempt', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'close attempt', 'quiz', 'name');
upgrade_log_display_entry('quiz', 'continue attempt', 'quiz', 'name');
update_log_display_entry('quiz', 'add', 'quiz', 'name');
update_log_display_entry('quiz', 'update', 'quiz', 'name');
update_log_display_entry('quiz', 'view', 'quiz', 'name');
update_log_display_entry('quiz', 'report', 'quiz', 'name');
update_log_display_entry('quiz', 'attempt', 'quiz', 'name');
update_log_display_entry('quiz', 'submit', 'quiz', 'name');
update_log_display_entry('quiz', 'review', 'quiz', 'name');
update_log_display_entry('quiz', 'editquestions', 'quiz', 'name');
update_log_display_entry('quiz', 'preview', 'quiz', 'name');
update_log_display_entry('quiz', 'start attempt', 'quiz', 'name');
update_log_display_entry('quiz', 'close attempt', 'quiz', 'name');
update_log_display_entry('quiz', 'continue attempt', 'quiz', 'name');
$record = new object();
$record->name = 'overview';

View File

@ -10,8 +10,8 @@ function xmldb_resource_install() {
/// Install logging support
upgrade_log_display_entry('resource', 'view', 'resource', 'name');
upgrade_log_display_entry('resource', 'update', 'resource', 'name');
upgrade_log_display_entry('resource', 'add', 'resource', 'name');
update_log_display_entry('resource', 'view', 'resource', 'name');
update_log_display_entry('resource', 'update', 'resource', 'name');
update_log_display_entry('resource', 'add', 'resource', 'name');
}

View File

@ -9,9 +9,9 @@ function xmldb_scorm_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('scorm', 'view', 'scorm', 'name');
upgrade_log_display_entry('scorm', 'review', 'scorm', 'name');
upgrade_log_display_entry('scorm', 'update', 'scorm', 'name');
upgrade_log_display_entry('scorm', 'add', 'scorm', 'name');
update_log_display_entry('scorm', 'view', 'scorm', 'name');
update_log_display_entry('scorm', 'review', 'scorm', 'name');
update_log_display_entry('scorm', 'update', 'scorm', 'name');
update_log_display_entry('scorm', 'add', 'scorm', 'name');
}

View File

@ -9,13 +9,13 @@ function xmldb_survey_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('survey', 'add', 'survey', 'name');
upgrade_log_display_entry('survey', 'update', 'survey', 'name');
upgrade_log_display_entry('survey', 'download', 'survey', 'name');
upgrade_log_display_entry('survey', 'view form', 'survey', 'name');
upgrade_log_display_entry('survey', 'view graph', 'survey', 'name');
upgrade_log_display_entry('survey', 'view report', 'survey', 'name');
upgrade_log_display_entry('survey', 'submit', 'survey', 'name');
update_log_display_entry('survey', 'add', 'survey', 'name');
update_log_display_entry('survey', 'update', 'survey', 'name');
update_log_display_entry('survey', 'download', 'survey', 'name');
update_log_display_entry('survey', 'view form', 'survey', 'name');
update_log_display_entry('survey', 'view graph', 'survey', 'name');
update_log_display_entry('survey', 'view report', 'survey', 'name');
update_log_display_entry('survey', 'submit', 'survey', 'name');
/// insert survey data