Skip to content

Commit

Permalink
Removed 2 other call to getStaticMember (pb with php 5.5).Fix PHPCS for
Browse files Browse the repository at this point in the history
constants into database driver classes.
  • Loading branch information
eldy committed Jul 31, 2014
1 parent bdc9d5b commit 852b78f
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 33 deletions.
3 changes: 2 additions & 1 deletion htdocs/admin/boxes.php
Expand Up @@ -35,8 +35,9 @@
$rowid = GETPOST('rowid','int');
$action = GETPOST('action','alpha');


// Define possible position of boxes
$pos_name = getStaticMember('InfoBox','listOfPages');
$pos_name = InfoBox::getListOfPagesForBoxes();
$boxes = array();


Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/system/database.php
Expand Up @@ -44,7 +44,7 @@
// Database
print '<table class="noborder" width="100%">';
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[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";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/system/index.php
Expand Up @@ -86,7 +86,7 @@
// Database
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Database")."</td></tr>\n";
$dblabel=$db::label;
$dblabel=$db::LABEL;
$dbversion=$db->getVersion();
print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n";
print '</table>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/tools/dolibarr_export.php
Expand Up @@ -65,7 +65,7 @@
$form=new Form($db);
$formfile = new FormFile($db);

$label=$db::label;
$label=$db::LABEL;

$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
llxHeader('','',$help_url);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/tools/dolibarr_import.php
Expand Up @@ -38,7 +38,7 @@
* View
*/

$label=$db::label;
$label=$db::LABEL;

$help_url='EN:Restores|FR:Restaurations|ES:Restauraciones';
llxHeader('','',$help_url);
Expand Down
8 changes: 4 additions & 4 deletions htdocs/admin/tools/export.php
Expand Up @@ -416,7 +416,7 @@ function backup_tables($outputfile, $tables='*')

// Print headers and global mysql config vars
$sqlhead = '';
$sqlhead .= "-- ".$db::label." dump via php
$sqlhead .= "-- ".$db::LABEL." dump via php
--
-- Host: ".$db->db->host_info." Database: ".$db->database_name."
-- ------------------------------------------------------
Expand Down Expand Up @@ -464,11 +464,11 @@ function backup_tables($outputfile, $tables='*')
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_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n");

$sql='SELECT * FROM '.$table;
$result = $db->query($sql);
$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
fwrite($handle,'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES (');
Expand Down Expand Up @@ -497,7 +497,7 @@ function backup_tables($outputfile, $tables='*')
fwrite($handle,"\n\n\n");
}
}

/* Backup Procedure structure*/
/*
$result = $db->query('SHOW PROCEDURE STATUS');
Expand Down
21 changes: 14 additions & 7 deletions htdocs/core/class/infobox.class.php
Expand Up @@ -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
{
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
Expand Down Expand Up @@ -137,20 +144,20 @@ static function listBoxes($db, $mode, $zone, $user, $excludelist=array())
$arrayelem=explode('|',$moduleelem);
$tmpenabled=0; // $tmpenabled is used for the '|' test (OR)
foreach($arrayelem as $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>';
}
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;
break;
}
}
}
//print '=>'.$boxname.'-enabled='.$enabled.'<br>';

//print 'xx module='.$module.' enabled='.$enabled;
if ($enabled) $boxes[]=$box;
else unset($box);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/db/mssql.class.php
Expand Up @@ -33,13 +33,13 @@ class DoliDBMssql extends DoliDB
//! Database type
public $type='mssql';
//! Database label
const label='MSSQL';
const LABEL='MSSQL';
//! Charset used to force charset when creating database
var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value
//! 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
//! Version min database
const versionmin='2000';
const VERSIONMIN='2000';
//! Resultset of last query
private $_results;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/db/mysql.class.php
Expand Up @@ -34,9 +34,9 @@ class DoliDBMysql extends DoliDB
//! Database type
public $type='mysql';
//! Database label
const label='MySQL';
const LABEL='MySQL';
//! Version min database
const versionmin='4.1.0';
const VERSIONMIN='4.1.0';
//! Resultset of last query
private $_results;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/db/mysqli.class.php
Expand Up @@ -34,9 +34,9 @@ class DoliDBMysqli extends DoliDB
//! Database type
public $type='mysqli';
//! Database label
const label='MySQL';
const LABEL='MySQL';
//! Version min database
const versionmin='4.1.0';
const VERSIONMIN='4.1.0';
//! Resultset of last query
private $_results;

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

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/db/sqlite.class.php
Expand Up @@ -34,9 +34,9 @@ class DoliDBSqlite extends DoliDB
//! Database type
public $type='sqlite';
//! Database label
const label='PDO Sqlite';
const LABEL='PDO Sqlite';
//! Version min database
const versionmin='3.0.0';
const VERSIONMIN='3.0.0';
//! Resultset of last query
private $_results;

Expand Down
7 changes: 4 additions & 3 deletions htdocs/core/modules/DolibarrModules.class.php
Expand Up @@ -523,8 +523,10 @@ function insert_boxes($option='')

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']:'';
$note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:'';
$enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home';
Expand Down Expand Up @@ -564,7 +566,6 @@ function insert_boxes($option='')
{
$lastid=$this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def","rowid");

$pos_name = getStaticMember('InfoBox','listOfPages');
foreach ($pos_name as $key2 => $val2)
{
//print 'key2='.$key2.'-val2='.$val2."<br>\n";
Expand Down
6 changes: 3 additions & 3 deletions htdocs/install/fileconf.php
Expand Up @@ -307,10 +307,10 @@
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

// Version min of database
$versionbasemin=explode('.',$class::versionmin);
$note='('.$class::label.' >= '.$class::versionmin.')';
$versionbasemin=explode('.',$class::VERSIONMIN);
$note='('.$class::LABEL.' >= '.$class::VERSIONMIN.')';

// Switch to mysql if mysqli is not present
if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/install/upgrade.php
Expand Up @@ -168,7 +168,7 @@
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");

// Test database version
$versionmindb=$db::versionmin;
$versionmindb=$db::VERSIONMIN;
//print join('.',$versionarray).' - '.join('.',$versionmindb);
if (count($versionmindb) && count($versionarray)
&& versioncompare($versionarray,$versionmindb) < 0)
Expand Down

0 comments on commit 852b78f

Please sign in to comment.