Removed 2 other call to getStaticMember (pb with php 5.5).Fix PHPCS for

constants into database driver classes.
This commit is contained in:
Laurent Destailleur 2014-08-01 00:53:29 +02:00
parent bdc9d5b463
commit 852b78f79f
15 changed files with 42 additions and 33 deletions

View File

@ -35,8 +35,9 @@ if (! $user->admin) accessforbidden();
$rowid = GETPOST('rowid','int'); $rowid = GETPOST('rowid','int');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
// Define possible position of boxes // Define possible position of boxes
$pos_name = getStaticMember('InfoBox','listOfPages'); $pos_name = InfoBox::getListOfPagesForBoxes();
$boxes = array(); $boxes = array();

View File

@ -44,7 +44,7 @@ print_fiche_titre($langs->trans("InfoDatabase"),'','setup');
// Database // Database
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n"; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.$db::label.' '.$db->getVersion().'</td></tr>'."\n"; print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n"; print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'</td></tr>'."\n"; print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n"; print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";

View File

@ -86,7 +86,7 @@ print "<br>\n";
// Database // Database
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Database")."</td></tr>\n"; print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Database")."</td></tr>\n";
$dblabel=$db::label; $dblabel=$db::LABEL;
$dbversion=$db->getVersion(); $dbversion=$db->getVersion();
print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n"; print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n";
print '</table>'; print '</table>';

View File

@ -65,7 +65,7 @@ if ($action == 'delete')
$form=new Form($db); $form=new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$label=$db::label; $label=$db::LABEL;
$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; $help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
llxHeader('','',$help_url); llxHeader('','',$help_url);

View File

@ -38,7 +38,7 @@ $showpass=GETPOST('showpass');
* View * View
*/ */
$label=$db::label; $label=$db::LABEL;
$help_url='EN:Restores|FR:Restaurations|ES:Restauraciones'; $help_url='EN:Restores|FR:Restaurations|ES:Restauraciones';
llxHeader('','',$help_url); llxHeader('','',$help_url);

View File

@ -416,7 +416,7 @@ function backup_tables($outputfile, $tables='*')
// Print headers and global mysql config vars // Print headers and global mysql config vars
$sqlhead = ''; $sqlhead = '';
$sqlhead .= "-- ".$db::label." dump via php $sqlhead .= "-- ".$db::LABEL." dump via php
-- --
-- Host: ".$db->db->host_info." Database: ".$db->database_name." -- Host: ".$db->db->host_info." Database: ".$db->database_name."
-- ------------------------------------------------------ -- ------------------------------------------------------
@ -464,11 +464,11 @@ function backup_tables($outputfile, $tables='*')
fwrite($handle, "\n--\n-- Dumping data for table `".$table."`\n--\n"); fwrite($handle, "\n--\n-- Dumping data for table `".$table."`\n--\n");
if (!GETPOST("nobin_nolocks")) fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back) if (!GETPOST("nobin_nolocks")) fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back)
if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n"); if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n");
$sql='SELECT * FROM '.$table; $sql='SELECT * FROM '.$table;
$result = $db->query($sql); $result = $db->query($sql);
$num_fields = $db->num_rows($result); $num_fields = $db->num_rows($result);
while($row = $db->fetch_row($result)) while($row = $db->fetch_row($result))
{ {
// For each row of data we print a line of INSERT // For each row of data we print a line of INSERT
fwrite($handle,'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES ('); fwrite($handle,'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES (');
@ -497,7 +497,7 @@ function backup_tables($outputfile, $tables='*')
fwrite($handle,"\n\n\n"); fwrite($handle,"\n\n\n");
} }
} }
/* Backup Procedure structure*/ /* Backup Procedure structure*/
/* /*
$result = $db->query('SHOW PROCEDURE STATUS'); $result = $db->query('SHOW PROCEDURE STATUS');

View File

@ -23,12 +23,19 @@
*/ */
/** /**
* Class to manage boxes on pages * Class to manage boxes on pages. This is an utility class (all is static)
*/ */
class InfoBox class InfoBox
{ {
static $listOfPages = array(0=>'Home'); // Nom des positions 0=Home, 1=... /**
* Name of positions 0=Home, 1=...
*
* @return array Array with list of zones
*/
static function getListOfPagesForBoxes()
{
return array(0=>'Home');
}
/** /**
* Return array of boxes qualified for area and user * Return array of boxes qualified for area and user
@ -137,12 +144,12 @@ class InfoBox
$arrayelem=explode('|',$moduleelem); $arrayelem=explode('|',$moduleelem);
$tmpenabled=0; // $tmpenabled is used for the '|' test (OR) $tmpenabled=0; // $tmpenabled is used for the '|' test (OR)
foreach($arrayelem as $module) foreach($arrayelem as $module)
{ {
$tmpmodule=preg_replace('/@[^@]+/','',$module); $tmpmodule=preg_replace('/@[^@]+/','',$module);
if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1;
//print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>'; //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
} }
if (empty($tmpenabled)) // We found at least one module required that disabled if (empty($tmpenabled)) // We found at least one module required that disabled
{ {
$enabled=0; $enabled=0;
break; break;
@ -150,7 +157,7 @@ class InfoBox
} }
} }
//print '=>'.$boxname.'-enabled='.$enabled.'<br>'; //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
//print 'xx module='.$module.' enabled='.$enabled; //print 'xx module='.$module.' enabled='.$enabled;
if ($enabled) $boxes[]=$box; if ($enabled) $boxes[]=$box;
else unset($box); else unset($box);

View File

@ -33,13 +33,13 @@ class DoliDBMssql extends DoliDB
//! Database type //! Database type
public $type='mssql'; public $type='mssql';
//! Database label //! Database label
const label='MSSQL'; const LABEL='MSSQL';
//! Charset used to force charset when creating database //! Charset used to force charset when creating database
var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database //! Collate used to force collate when creating database
var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
const versionmin='2000'; const VERSIONMIN='2000';
//! Resultset of last query //! Resultset of last query
private $_results; private $_results;

View File

@ -34,9 +34,9 @@ class DoliDBMysql extends DoliDB
//! Database type //! Database type
public $type='mysql'; public $type='mysql';
//! Database label //! Database label
const label='MySQL'; const LABEL='MySQL';
//! Version min database //! Version min database
const versionmin='4.1.0'; const VERSIONMIN='4.1.0';
//! Resultset of last query //! Resultset of last query
private $_results; private $_results;

View File

@ -34,9 +34,9 @@ class DoliDBMysqli extends DoliDB
//! Database type //! Database type
public $type='mysqli'; public $type='mysqli';
//! Database label //! Database label
const label='MySQL'; const LABEL='MySQL';
//! Version min database //! Version min database
const versionmin='4.1.0'; const VERSIONMIN='4.1.0';
//! Resultset of last query //! Resultset of last query
private $_results; private $_results;

View File

@ -37,13 +37,13 @@ class DoliDBPgsql extends DoliDB
//! Database type //! Database type
public $type='pgsql'; // Name of manager public $type='pgsql'; // Name of manager
//! Database label //! Database label
const label='PostgreSQL'; // Label of manager const LABEL='PostgreSQL'; // Label of manager
//! Charset //! Charset
var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database //! Collate used to force collate when creating database
var $forcecollate=''; // Can't be static as it may be forced with a dynamic value var $forcecollate=''; // Can't be static as it may be forced with a dynamic value
//! Version min database //! Version min database
const versionmin='8.4.0'; // Version min database const VERSIONMIN='8.4.0'; // Version min database
//! Resultset of last query //! Resultset of last query
private $_results; private $_results;

View File

@ -34,9 +34,9 @@ class DoliDBSqlite extends DoliDB
//! Database type //! Database type
public $type='sqlite'; public $type='sqlite';
//! Database label //! Database label
const label='PDO Sqlite'; const LABEL='PDO Sqlite';
//! Version min database //! Version min database
const versionmin='3.0.0'; const VERSIONMIN='3.0.0';
//! Resultset of last query //! Resultset of last query
private $_results; private $_results;

View File

@ -523,8 +523,10 @@ abstract class DolibarrModules
if (is_array($this->boxes)) if (is_array($this->boxes))
{ {
foreach ($this->boxes as $key => $value) $pos_name = InfoBox::getListOfPagesForBoxes();
{
foreach ($this->boxes as $key => $value)
{
$file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:''; $file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:'';
$note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:''; $note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:'';
$enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home'; $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home';
@ -564,7 +566,6 @@ abstract class DolibarrModules
{ {
$lastid=$this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def","rowid"); $lastid=$this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def","rowid");
$pos_name = getStaticMember('InfoBox','listOfPages');
foreach ($pos_name as $key2 => $val2) foreach ($pos_name as $key2 => $val2)
{ {
//print 'key2='.$key2.'-val2='.$val2."<br>\n"; //print 'key2='.$key2.'-val2='.$val2."<br>\n";

View File

@ -307,10 +307,10 @@ if (! empty($force_install_message))
include_once $dir."/".$file; include_once $dir."/".$file;
if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation
// Version min of database // Version min of database
$versionbasemin=explode('.',$class::versionmin); $versionbasemin=explode('.',$class::VERSIONMIN);
$note='('.$class::label.' >= '.$class::versionmin.')'; $note='('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
// Switch to mysql if mysqli is not present // Switch to mysql if mysqli is not present
if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';

View File

@ -168,7 +168,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version"); dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");
// Test database version // Test database version
$versionmindb=$db::versionmin; $versionmindb=$db::VERSIONMIN;
//print join('.',$versionarray).' - '.join('.',$versionmindb); //print join('.',$versionarray).' - '.join('.',$versionmindb);
if (count($versionmindb) && count($versionarray) if (count($versionmindb) && count($versionarray)
&& versioncompare($versionarray,$versionmindb) < 0) && versioncompare($versionarray,$versionmindb) < 0)