Feature #272 - Installation scripts: Repetitive code elimination.

skala
Ivan Tcholakov 15 years ago
parent 1b61d77f73
commit 9a08d8cf16
  1. 23
      main/install/install.lib.php
  2. 22
      main/install/install_db.inc.php
  3. 22
      main/install/update-db-1.6.x-1.8.0.inc.php
  4. 22
      main/install/update-db-1.8.0-1.8.2.inc.php
  5. 21
      main/install/update-db-1.8.2-1.8.3.inc.php
  6. 21
      main/install/update-db-1.8.3-1.8.4.inc.php
  7. 21
      main/install/update-db-1.8.4-1.8.5.inc.php
  8. 21
      main/install/update-db-1.8.5-1.8.6.inc.php
  9. 21
      main/install/update-db-1.8.6-1.8.6.1.inc.php
  10. 21
      main/install/update-db-1.8.6.1-1.8.6.2.inc.php
  11. 21
      main/install/update-db-1.8.6.2-1.8.7.inc.php

@ -3,6 +3,7 @@
/**
==============================================================================
* Chamilo LMS
* This file contains functions used by the install and upgrade scripts.
*
* Ideas for future additions:
@ -28,6 +29,28 @@ define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
==============================================================================
*/
/**
* Connecting to the databse server - the common routine.
*/
function database_server_connect() {
global $dbHostForm, $dbUsernameForm, $dbPassForm;
if (($res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm))) === false) {
$no = Database::errno();
$msg = Database::error();
echo '<hr />#'.$no.': '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />'.
get_lang('PleaseCheckTheseValues').' :<br /><br />'.
'<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />'.
'<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />'.
'<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />'.
get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.'.
'<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>'.
'</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
}
/**
* We assume this function is called from install scripts that reside inside the install folder.
*/

@ -24,27 +24,7 @@ if (!defined('SYSTEM_INSTALLATION')) {
set_file_folder_permissions();
@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
if (Database::errno() > 0) {
$no = Database::errno();
$msg = Database::error();
echo '<hr />['.$no.'] &ndash; '.$msg.'<hr />
The MySQL server doesn\'t work or login / pass is bad.<br /><br />
Please check these values:<br /><br />
<strong>host</strong> : '.$dbHostForm.'<br />
<strong>user</strong> : '.$dbUsernameForm.'<br />
<strong>password</strong> : '.str_repeat('*', api_strlen($dbPassForm)).'<br /><br />
Please go back to step 3.
<p><button type="submit" class="back" name="step3" value="&lt; Back" >Back</button></p>
</td></tr></table></form></body></html>';
exit();
}
// Disabling special SQL modes (MySQL 5)
Database::query("set session sql_mode='';");
database_server_connect();
// Initialization of the database encoding to be used.
Database::query("SET SESSION character_set_server='utf8';");

@ -81,27 +81,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />
'.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -80,27 +80,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />
'.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -80,26 +80,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -79,26 +79,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -60,26 +60,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -64,26 +64,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -64,26 +64,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -64,26 +64,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

@ -64,26 +64,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
' '.get_lang('PleaseCheckTheseValues').' :<br /><br />
<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />
<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />
<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />
'.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.
<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
</td></tr></table></form></body></html>';
exit ();
}
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
database_server_connect();
$dblist = Database::get_databases();

Loading…
Cancel
Save