phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r5172 - in phpcompta/tags/rel650: html/admin include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5172 - in phpcompta/tags/rel650: html/admin include
Date: Sun, 20 Jan 2013 15:57:40 +0100 (CET)

Author: danydb
Date: 2013-01-20 15:57:40 +0100 (Sun, 20 Jan 2013)
New Revision: 5172

Modified:
   phpcompta/tags/rel650/html/admin/setup.php
   phpcompta/tags/rel650/include/class_database.php
   phpcompta/tags/rel650/include/dossier.inc.php
Log:
0000778: Si dossier n'existe pas alors il y a une erreur dans administration > 
dossier

Modified: phpcompta/tags/rel650/html/admin/setup.php
===================================================================
--- phpcompta/tags/rel650/html/admin/setup.php  2013-01-18 23:28:52 UTC (rev 
5171)
+++ phpcompta/tags/rel650/html/admin/setup.php  2013-01-20 14:57:40 UTC (rev 
5172)
@@ -463,8 +463,17 @@
 for ($e=0;$e < $MaxDossier;$e++) {
   $db_row=$cn->fetch($e);
   echo "<h3>Patching ".$db_row['dos_name'].'</h3>';
-  $db=new Database($db_row['dos_id'],'dos');
-  $db->apply_patch($db_row['dos_name']);
+  
+  $name=$cn->format_name($db_row['dos_id'],'dos');
+  
+  if ( $cn->exist_database($name)> 0 )
+  {
+    $db=new Database($db_row['dos_id'],'dos');
+    $db->apply_patch($db_row['dos_name']);
+  } else 
+  {
+      echo_warning(_("Dossier inexistant")." $name");
+  }
   Dossier::synchro_admin($db_row['dos_id']);
  }
 
@@ -478,8 +487,16 @@
 for ($e=0;$e < $MaxDossier;$e++) {
   $db_row=$cn->fetch($e);
   echo "<h3>Patching ".$db_row['mod_name']."</h3>";
-  $db=new Database($db_row['mod_id'],'mod');
-  $db->apply_patch($db_row['mod_name']);
+  $name=$cn->format_name($db_row['mod_id'],'mod');
+  
+  if ( $cn->exist_database($name)> 0 )
+  {
+    $db=new Database($db_row['mod_id'],'mod');
+    $db->apply_patch($db_row['mod_name']);
+   } else 
+  {
+      echo_warning(_("Modèle inexistant")." $name");
+  }
  }
 
 //----------------------------------------------------------------------

Modified: phpcompta/tags/rel650/include/class_database.php
===================================================================
--- phpcompta/tags/rel650/include/class_database.php    2013-01-18 23:28:52 UTC 
(rev 5171)
+++ phpcompta/tags/rel650/include/class_database.php    2013-01-20 14:57:40 UTC 
(rev 5172)
@@ -550,6 +550,38 @@
         return false;
     }
     /**
+     * return the name of the database with the domain name
+     * @param $p_id of the folder WITHOUT the domain name
+     * @param $p_type dos for folder mod for template
+     * @return formatted name
+     */
+    function format_name($p_id,$p_type)
+    {
+        switch ($p_type)
+        {
+            case 'dos':
+                $sys_name=sprintf("%sdossier%d",strtolower(domaine),$p_name);
+                break;
+            case 'mod':
+                $sys_name=sprintf("%smod%d",strtolower(domaine),$p_name);
+                break;
+            default:
+                echo_error(__FILE__." format_name invalid type ".$p_type, 
__LINE__);
+        }
+        return $sys_name;
+    }
+    /**
+     * Count the database name in a system view
+     * @param $p_name string database name
+     * @return number of database found (normally 0 or 1)
+     */
+    function exist_database($p_name)
+    {
+        $database_exist=$this->get_value('select count(*) 
+                from pg_catalog.pg_database where datname = 
lower($1)',array($p_name));
+        return $database_exist;
+    }
+    /**
      address@hidden check if the large object exists
      address@hidden $p_oid of the large object
      address@hidden return true if the large obj exist or false if not

Modified: phpcompta/tags/rel650/include/dossier.inc.php
===================================================================
--- phpcompta/tags/rel650/include/dossier.inc.php       2013-01-18 23:28:52 UTC 
(rev 5171)
+++ phpcompta/tags/rel650/include/dossier.inc.php       2013-01-20 14:57:40 UTC 
(rev 5172)
@@ -197,8 +197,9 @@
            $str_name=domaine.'dossier'.$Dossier['dos_id'];
             
            echo "<TD><I>  ".h($Dossier['dos_description'])."</I></td>";
-            $database_exist=$repocn->get_value('select count(*) 
-                from pg_catalog.pg_database where datname = 
lower($1)',array($str_name));
+            
+            $database_exist=$repocn->exist_database($str_name);
+            
             if ($database_exist > 0 )
             {
                 $size=$repocn->get_value("select 
pg_database_size($1)/(1024*1024)::float",



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]