diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php
index e65558bc40b..3dca2566a91 100644
--- a/dev/skeletons/modMyModule.class.php
+++ b/dev/skeletons/modMyModule.class.php
@@ -130,6 +130,8 @@ class modMyModule extends DolibarrModules
{
$sql = array();
+ $result=$this->load_tables();
+
return $this->_init($sql);
}
@@ -145,6 +147,53 @@ class modMyModule extends DolibarrModules
return $this->_remove($sql);
}
+
+ /**
+ * \brief Create tables and keys (called by this->init)
+ * \return int <=0 if KO, >0 if OK
+ */
+ function load_tables()
+ {
+ include_once(DOL_DOCUMENT_ROOT ."/lib/admin.lib.php");
+
+ global $db;
+
+ $ok = 1;
+ if ($ok)
+ {
+ $dir = DOL_DOCUMENT_ROOT.'/mysql/tables/mymodule/';
+ $ok = 0;
+
+ // Run llx_mytable.sql files
+ $handle=opendir($dir);
+ while (($file = readdir($handle))!==false)
+ {
+ if (eregi('\.sql$',$file) && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
+ {
+ $result=run_sql($file,1);
+ }
+ }
+ closedir($handle);
+
+ // Run llx_mytable.key.sql files
+ $handle=opendir($dir);
+ while (($file = readdir($handle))!==false)
+ {
+ if (eregi('\.sql$',$file) && substr($file,0,4) == 'llx_' && substr($file, -8) == '.key.sql')
+ {
+ $result=run_sql($file,1);
+ }
+ }
+ closedir($handle);
+
+ if ($error == 0)
+ {
+ $ok = 1;
+ }
+ }
+
+ return $ok;
+ }
}
?>
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index c75e08c2bbe..c4c0feb5272 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -18,15 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
*/
/**
\file htdocs/categories/categorie.php
\ingroup category
\brief Page de l'onglet categories
- \version $Revision$
+ \version $Id$
*/
require("./pre.inc.php");
@@ -34,8 +32,6 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
$langs->load("categories");
-$user->getrights();
-
$mesg=isset($_GET["mesg"])?'
'.$_GET["mesg"].'
':'';
if ($_REQUEST["socid"])
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 4c7d291f2a7..a6d1b7b5808 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -15,24 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- * $Source$
*/
/**
\file htdocs/comm/mailing/cibles.php
\ingroup mailing
\brief Page des cibles de mailing
- \version $Revision$
+ \version $Id$
*/
require("./pre.inc.php");
$langs->load("mails");
-$user->getrights("mailing");
-
if (! $user->rights->mailing->lire || $user->societe_id > 0)
accessforbidden();
diff --git a/htdocs/includes/modules/modTelephonie.class.php b/htdocs/includes/modules/modTelephonie.class.php
index ba0fce6d938..ed84c5a5072 100644
--- a/htdocs/includes/modules/modTelephonie.class.php
+++ b/htdocs/includes/modules/modTelephonie.class.php
@@ -313,62 +313,62 @@ class modTelephonie extends DolibarrModules
* A faire avant les fichiers *.key.sql
*
***************************************************************************************/
- $ok = 1;
- if ($ok)
- {
- $dir = DOL_DOCUMENT_ROOT.'/telephonie/sql/';
+ $ok = 1;
+ if ($ok)
+ {
+ $dir = DOL_DOCUMENT_ROOT.'/telephonie/sql/';
- $ok = 0;
- $handle=opendir($dir);
- $table_exists = 0;
- while (($file = readdir($handle))!==false)
- {
- if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
- {
- $name = substr($file, 0, strlen($file) - 4);
- $buffer = '';
- $fp = fopen($dir.$file,"r");
- if ($fp)
- {
- while (!feof ($fp))
- {
- $buf = fgets($fp, 4096);
- if (substr($buf, 0, 2) <> '--')
- {
- $buffer .= $buf;
- }
- }
- fclose($fp);
- }
-
- //print "| Creation de la table $name/td>";
- $requestnb++;
- if (@$this->db->query($buffer))
- {
- //print " | OK requete ==== $buffer |
";
- }
- else
- {
- if ($this->db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS')
- {
- //print "Deje existante | ";
- $table_exists = 1;
- }
- else
- {
- $error++;
- }
- }
- }
-
- }
- closedir($handle);
+ $ok = 0;
+ $handle=opendir($dir);
+ $table_exists = 0;
+ while (($file = readdir($handle))!==false)
+ {
+ if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
+ {
+ $name = substr($file, 0, strlen($file) - 4);
+ $buffer = '';
+ $fp = fopen($dir.$file,"r");
+ if ($fp)
+ {
+ while (!feof ($fp))
+ {
+ $buf = fgets($fp, 4096);
+ if (substr($buf, 0, 2) <> '--')
+ {
+ $buffer .= $buf;
+ }
+ }
+ fclose($fp);
+ }
+
+ //print "| Creation de la table $name/td>";
+ $requestnb++;
+ if (@$this->db->query($buffer))
+ {
+ //print " | OK requete ==== $buffer |
";
+ }
+ else
+ {
+ if ($this->db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS')
+ {
+ //print "Deje existante | ";
+ $table_exists = 1;
+ }
+ else
+ {
+ $error++;
+ }
+ }
+ }
+
+ }
+ closedir($handle);
- if ($error == 0)
- {
- $ok = 1;
- }
- }
+ if ($error == 0)
+ {
+ $ok = 1;
+ }
+ }
/***************************************************************************************
diff --git a/htdocs/lib/admin.lib.php b/htdocs/lib/admin.lib.php
index ee640688ff0..efa66f633cd 100644
--- a/htdocs/lib/admin.lib.php
+++ b/htdocs/lib/admin.lib.php
@@ -83,7 +83,7 @@ function versiondolibarrarray()
/**
* \brief Launch a sql file
* \param sqlfile Full path to sql file
-* \return int <0 if ko, >0 if ok
+* \return int <=0 if KO, >0 if OK
*/
function run_sql($sqlfile,$silent=1)
{