Création des bases lors de l'activation du module
This commit is contained in:
parent
fed065dd7f
commit
e169c1fc81
@ -130,6 +130,8 @@ class modMyModule extends DolibarrModules
|
|||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
|
$result=$this->load_tables();
|
||||||
|
|
||||||
return $this->_init($sql);
|
return $this->_init($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +147,53 @@ class modMyModule extends DolibarrModules
|
|||||||
return $this->_remove($sql);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -18,15 +18,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/categories/categorie.php
|
\file htdocs/categories/categorie.php
|
||||||
\ingroup category
|
\ingroup category
|
||||||
\brief Page de l'onglet categories
|
\brief Page de l'onglet categories
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -34,8 +32,6 @@ require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
|||||||
|
|
||||||
$langs->load("categories");
|
$langs->load("categories");
|
||||||
|
|
||||||
$user->getrights();
|
|
||||||
|
|
||||||
$mesg=isset($_GET["mesg"])?'<div class="ok">'.$_GET["mesg"].'</div>':'';
|
$mesg=isset($_GET["mesg"])?'<div class="ok">'.$_GET["mesg"].'</div>':'';
|
||||||
|
|
||||||
if ($_REQUEST["socid"])
|
if ($_REQUEST["socid"])
|
||||||
|
|||||||
@ -15,24 +15,19 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/comm/mailing/cibles.php
|
\file htdocs/comm/mailing/cibles.php
|
||||||
\ingroup mailing
|
\ingroup mailing
|
||||||
\brief Page des cibles de mailing
|
\brief Page des cibles de mailing
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
|
||||||
$langs->load("mails");
|
$langs->load("mails");
|
||||||
|
|
||||||
$user->getrights("mailing");
|
|
||||||
|
|
||||||
if (! $user->rights->mailing->lire || $user->societe_id > 0)
|
if (! $user->rights->mailing->lire || $user->societe_id > 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|||||||
@ -313,62 +313,62 @@ class modTelephonie extends DolibarrModules
|
|||||||
* A faire avant les fichiers *.key.sql
|
* A faire avant les fichiers *.key.sql
|
||||||
*
|
*
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
if ($ok)
|
if ($ok)
|
||||||
{
|
{
|
||||||
$dir = DOL_DOCUMENT_ROOT.'/telephonie/sql/';
|
$dir = DOL_DOCUMENT_ROOT.'/telephonie/sql/';
|
||||||
|
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
$table_exists = 0;
|
$table_exists = 0;
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
{
|
{
|
||||||
if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
|
if (substr($file, strlen($file) - 4) == '.sql' && substr($file,0,4) == 'llx_' && substr($file, -8) <> '.key.sql')
|
||||||
{
|
{
|
||||||
$name = substr($file, 0, strlen($file) - 4);
|
$name = substr($file, 0, strlen($file) - 4);
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
$fp = fopen($dir.$file,"r");
|
$fp = fopen($dir.$file,"r");
|
||||||
if ($fp)
|
if ($fp)
|
||||||
{
|
{
|
||||||
while (!feof ($fp))
|
while (!feof ($fp))
|
||||||
{
|
{
|
||||||
$buf = fgets($fp, 4096);
|
$buf = fgets($fp, 4096);
|
||||||
if (substr($buf, 0, 2) <> '--')
|
if (substr($buf, 0, 2) <> '--')
|
||||||
{
|
{
|
||||||
$buffer .= $buf;
|
$buffer .= $buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//print "<tr><td>Creation de la table $name/td>";
|
//print "<tr><td>Creation de la table $name/td>";
|
||||||
$requestnb++;
|
$requestnb++;
|
||||||
if (@$this->db->query($buffer))
|
if (@$this->db->query($buffer))
|
||||||
{
|
{
|
||||||
//print "<td>OK requete ==== $buffer</td></tr>";
|
//print "<td>OK requete ==== $buffer</td></tr>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS')
|
if ($this->db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS')
|
||||||
{
|
{
|
||||||
//print "<td>Deje existante</td></tr>";
|
//print "<td>Deje existante</td></tr>";
|
||||||
$table_exists = 1;
|
$table_exists = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
|
|||||||
@ -83,7 +83,7 @@ function versiondolibarrarray()
|
|||||||
/**
|
/**
|
||||||
* \brief Launch a sql file
|
* \brief Launch a sql file
|
||||||
* \param sqlfile Full path to 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)
|
function run_sql($sqlfile,$silent=1)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user