Some cleanups to the flow

This commit is contained in:
moodler 2006-03-29 16:03:05 +00:00
parent 00a67d879c
commit 004bd0cc39
2 changed files with 35 additions and 76 deletions

View File

@ -49,15 +49,14 @@
case INSTALLATION_OF_SELECTED_LANG: ///installation of selected language pack
if (confirm_sesskey()) {
if ($confirm) {
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
@mkdir ($CFG->dataroot.'/lang/');
require_once($CFG->libdir.'/componentlib.class.php');
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
$pack.'.zip', 'languages.md5', 'lang')) {
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
switch ($status) {
@mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there
@mkdir ($CFG->dataroot.'/lang/');
require_once($CFG->libdir.'/componentlib.class.php');
if ($cd = new component_installer('http://download.moodle.org', 'lang16',
$pack.'.zip', 'languages.md5', 'lang')) {
$status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
switch ($status) {
case ERROR:
if ($cd->get_error() == 'remotedownloadnotallowed') {
@ -69,36 +68,18 @@
error(get_string($cd->get_error(), 'error'));
}
break;
case UPTODATE:
break;
case INSTALLED:
@unlink($CFG->dataroot.'/cache/languages');
notice(get_string('langpackupdated','admin',$pack), 'langimport.php');
redirect('langimport.php', get_string('langpackupdated','admin',$pack));
break;
case UPTODATE:
break;
default:
//We shouldn't reach this point
}
} else {
//We shouldn't reach this point
}
} else { //print confirm box, no confirmation yet
if (confirm_sesskey()) {
print_simple_box_start('center','100%');
echo '<div align="center">';
echo '<form name="langform" action="langimport.php?mode=2" method="POST">';
echo '<input name="pack" type="hidden" value="'.$pack.'" />';
echo '<input name="displaylang" type="hidden" value="'.$displaylang.'" />';
echo '<input name="confirm" type="hidden" value="1" />';
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
print_heading(get_string('confirminstall','admin',$displaylang),2);
echo '<input type="submit" value="'.get_string('ok').'"/>';
echo '&nbsp;<input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
echo '</form>';
echo '</div>';
print_simple_box_end();
}
} else {
notify('Had an unspecified error with the component installer, sorry.');
}
}
break;
@ -109,13 +90,9 @@
$langconfig = get_record('config','name','lang');
$langconfig->value = $sitelang;
if (!empty($sitelang) && update_record('config',$langconfig)){
echo '<div align="center">';
notify (get_string('sitelangchanged','admin'));
echo '<form action="langimport.php" method="POST">';
echo '<input type="submit" value="'.get_string('ok').'" />';
echo '</form></div>';
redirect('langimport.php', get_string('sitelangchanged','admin'));
} else {
error ('can not update site language');
error('Could not update the default site language!');
}
}
@ -123,20 +100,10 @@
case DELETION_OF_SELECTED_LANG: //delete a directory(ies) containing a lang pack completely
if (!$confirm && confirm_sesskey()) {
print_simple_box_start('center','100%');
echo '<div align="center">';
echo '<form name="langform" action="langimport.php?mode=4" method="POST">';
echo '<input name="uninstalllang" type="hidden" value="'.$uninstalllang.'" />';
echo '<input name="confirm" type="hidden" value="1" />';
print_heading(get_string('uninstallconfirm','admin',$uninstalllang),2);
echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
echo '<input type="submit" value="'.get_string('uninstall','admin').'"/>';
echo '&nbsp;<input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
echo '</form>';
echo '</div>';
print_simple_box_end();
}
else if (confirm_sesskey()) {
notice_yesno(get_string('uninstallconfirm', 'admin', $uninstalllang),
'langimport.php?mode=4&amp;uninstalllang='.$uninstalllang.'&amp;confirm=1&amp;sesskey='.sesskey(),
'langimport.php');
} else if (confirm_sesskey()) {
if ($uninstalllang == 'en_utf8') {
error ('en_utf8 can not be uninstalled!');
}
@ -152,13 +119,9 @@
}
//delete the direcotries
if ($rm1 or $rm2) {
echo '<div align="center">';
print_string('langpackremoved','admin');
echo '<form action="langimport.php" method="POST">';
echo '<input type="submit" value="'.get_string('ok').'" />';
echo '</form></div>';
redirect('langimport.php', get_string('langpackremoved','admin'));
} else { //nothing deleted, possibly due to permission error
error ('An error has occurred, language pack is not completely uninstalled, please check file permission');
error('An error has occurred, language pack is not completely uninstalled, please check file permissions');
}
}
@unlink($CFG->dataroot.'/cache/languages');
@ -246,7 +209,7 @@
//Print error string or whatever you want to do
break;
case INSTALLED:
print_string('langpackupdated','admin',$pack);
notify(get_string('langpackupdated','admin',$pack), 'notifysuccess');
$updated = true;
//Print/do whatever you want
break;
@ -257,15 +220,11 @@
}
}
echo '<div align="center"><form action="langimport.php" method="POST">';
if ($updated) {
echo '<br />';
notify(get_string('langupdatecomplete','admin'));
notice(get_string('langupdatecomplete','admin'), 'langimport.php');
} else {
notify(get_string('nolangupdateneeded','admin'));
notice(get_string('nolangupdateneeded','admin'), 'langimport.php');
}
echo '<input type="submit" value="'.get_string('ok').'" />';
echo '</form></div>';
break;
@ -369,7 +328,7 @@
}
if ($remote) {
echo '</select>';
echo '<br/ ><input type="submit" value="'.get_string('install','admin').'">';
echo '<br/ ><input type="submit" value="<-- '.get_string('install','admin').'">';
}
echo '</form>';

View File

@ -5,11 +5,11 @@
$string['adminseesallevents'] = 'Administrators see all events';
$string['adminseesownevents'] = 'Administrators are just like other users';
$string['allowrenames'] = 'Allow renames';
$string['availablelangs'] = 'Available Language Packs';
$string['backgroundcolour'] = 'Transparent Colour';
$string['availablelangs'] = 'Available language packs';
$string['backgroundcolour'] = 'Transparent colour';
$string['badwordsconfig'] = 'Enter your list of bad words separated by commas.';
$string['badwordsdefault'] = 'If the custom list is empty, a default list from the language pack will be used.';
$string['badwordslist'] = 'Custom Bad Words List';
$string['badwordslist'] = 'Custom bad words list';
$string['blockinstances'] = 'Instances';
$string['blockmultiple'] = 'Multiple';
$string['cachetext'] = 'Text cache lifetime';
@ -96,7 +96,7 @@ $string['configsectioninterface'] = 'Interface';
$string['configsectionmail'] = 'Mail';
$string['configsectionmaintenance'] = 'Maintenance';
$string['configsectionmisc'] = 'Miscellaneous';
$string['configsectionoperatingsystem'] = 'Operating System';
$string['configsectionoperatingsystem'] = 'Operating system';
$string['configsectionpermissions'] = 'Permissions';
$string['configsectionrequestedcourse'] = 'Course requests';
$string['configsectionsecurity'] = 'Security';
@ -175,7 +175,7 @@ $string['lang16notify'] = 'Moodle 1.6 and above allows you to install and update
$string['langimport'] = 'Language import utility';
$string['langimportsuccess'] = 'Language pack successfully upgraded';
$string['langpackremoved'] = 'Language pack was uninstalled';
$string['langpackupdated'] = 'Language pack $a updated';
$string['langpackupdated'] = 'Language pack $a was successfully installed';
$string['langupdatecomplete'] = 'Language pack update completed';
$string['latexpreamble'] = 'LaTeX preamble';
$string['latexsettings'] = 'LaTeX renderer Settings';
@ -229,10 +229,10 @@ $string['timezoneforced'] = 'This is forced by the site administrator';
$string['timezoneisforcedto'] = 'Force all users to use';
$string['timezonenotforced'] = 'Users can choose their own timezone';
$string['updatecomponent'] = 'Update Component';
$string['updatelangs'] = 'Update Language Packs';
$string['updatelangs'] = 'Update all local language packs';
$string['unicodeupgradenotice'] = 'In Moodle 1.6 we have migrated all languages to Unicode. To complete the upgrade for this site, you need to convert all the data in your database to Unicode using our migration script. <a href=\"utfdbmigrate.php\">Click here to run the migration script now</a>!';
$string['uninstall'] = 'Uninstall Seleted Language Pack';
$string['uninstallconfirm'] = 'You are about to completely uninstall Language Pack $a, are you sure?';
$string['uninstall'] = 'Uninstall selected language pack';
$string['uninstallconfirm'] = 'You are about to completely uninstall language pack $a, are you sure?';
$string['upgradeforumread'] = 'A new feature has been added in Moodle 1.5 to track read/unread forum posts.<br />To use this functionality you need to <a href=\"$a\">update your tables</a>.';
$string['upgradeforumreadinfo'] = 'A new feature has been added in Moodle 1.5 to track read/unread forum posts. To use this functionality you need to update your tables with all the tracking information for existing posts. Depending on the size of your site this can take a long time (hours) and can be quite taxing on the database, so it\'s best to do it during a quiet period. However, your site will continue functioning during this upgrade and users won\'t be affected. Once you start this process you should let it finish (keep your browser window open). However, if you stop the process by closing the window: don\'t worry, you can start over.<br /><br />Do you want to start the upgrading process now?';
$string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. <a href=\"$a\">More information</a>';