Pārlūkot izejas kodu

Removed 2 other call to getStaticMember (pb with php 5.5).Fix PHPCS for
constants into database driver classes.

Laurent Destailleur 11 gadi atpakaļ
vecāks
revīzija
852b78f79f

+ 2 - 1
htdocs/admin/boxes.php

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

+ 1 - 1
htdocs/admin/system/database.php

@@ -44,7 +44,7 @@ print_fiche_titre($langs->trans("InfoDatabase"),'','setup');
 // 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";

+ 1 - 1
htdocs/admin/system/index.php

@@ -86,7 +86,7 @@ print "<br>\n";
 // 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>';

+ 1 - 1
htdocs/admin/tools/dolibarr_export.php

@@ -65,7 +65,7 @@ if ($action == 'delete')
 $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);

+ 1 - 1
htdocs/admin/tools/dolibarr_import.php

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

+ 4 - 4
htdocs/admin/tools/export.php

@@ -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."
 -- ------------------------------------------------------
@@ -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 (');
@@ -497,7 +497,7 @@ function backup_tables($outputfile, $tables='*')
 	        fwrite($handle,"\n\n\n");
 	    }
     }
-    
+
     /* Backup Procedure structure*/
     /*
      $result = $db->query('SHOW PROCEDURE STATUS');

+ 14 - 7
htdocs/core/class/infobox.class.php

@@ -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
@@ -137,12 +144,12 @@ class InfoBox
                             	$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;
@@ -150,7 +157,7 @@ class InfoBox
                             }
                         }
                         //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
-                        
+
                         //print 'xx module='.$module.' enabled='.$enabled;
                         if ($enabled) $boxes[]=$box;
                         else unset($box);

+ 2 - 2
htdocs/core/db/mssql.class.php

@@ -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;
 

+ 2 - 2
htdocs/core/db/mysql.class.php

@@ -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;
 

+ 2 - 2
htdocs/core/db/mysqli.class.php

@@ -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;
 

+ 2 - 2
htdocs/core/db/pgsql.class.php

@@ -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;
 

+ 2 - 2
htdocs/core/db/sqlite.class.php

@@ -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;
 

+ 4 - 3
htdocs/core/modules/DolibarrModules.class.php

@@ -523,8 +523,10 @@ abstract class DolibarrModules
 
         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';
@@ -564,7 +566,6 @@ abstract class DolibarrModules
                         {
                             $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";

+ 3 - 3
htdocs/install/fileconf.php

@@ -307,10 +307,10 @@ if (! empty($force_install_message))
                     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';

+ 1 - 1
htdocs/install/upgrade.php

@@ -168,7 +168,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
         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)