Nouvelle syntaxe

This commit is contained in:
Rodolphe Quiedeville 2003-11-15 17:42:11 +00:00
parent edbb42dc52
commit 5de40f70bc
7 changed files with 53 additions and 199 deletions

View File

@ -21,9 +21,9 @@
*
*/
include_once "modDolibarrModules.class.php";
include_once "DolibarrModules.class.php";
class modAdherent extends modDolibarrModules
class modAdherent extends DolibarrModules
{
/*
@ -36,6 +36,13 @@ class modAdherent extends modDolibarrModules
$this->db = $DB ;
$this->depends = array();
$this->name = "Adhérents";
$this->description = "Gestion des adhérents d'une association";
$this->const_name = "MAIN_MODULE_ADHERENT";
$this->const_config = MAIN_MODULE_ADHERENT;
$this->config_page_url = "adherent.php";
$this->const = array();
$this->boxes = array();

View File

@ -20,7 +20,9 @@
*
*/
class modBoutique
include_once "DolibarrModules.class.php";
class modBoutique extends DolibarrModules
{
/*
@ -31,27 +33,36 @@ class modBoutique
Function modBoutique($DB)
{
$this->db = $DB ;
$this->name = "Boutique";
$this->description = "Gestion des boutiques";
$this->const_name = "MAIN_MODULE_BOUTIQUE";
$this->const_config = MAIN_MODULE_BOUTIQUE;
$this->depends = array();
$this->const = array();
$this->boxes = array();
/*
* Boites
*/
$this->boxes[0][0] = "Livres";
$this->boxes[0][1] = "box_boutique_livre.php";
}
/*
*
*
*
*/
Function init()
{
/*
* Activation du module
*/
$sql = array(
"REPLACE INTO llx_boxes_def (name,file) VALUES('Livres', 'box_boutique_livre.php');"
);
$sql = array();
for ($i = 0 ; $i < sizeof($sql) ; $i++)
{
$this->db->query($sql[$i]);
}
return $this->_init($sql);
}
/*
*
@ -59,8 +70,9 @@ class modBoutique
*/
Function remove()
{
$sql = "DELETE FROM llx_boxes_def WHERE file = 'box_boutique_livre.php';";
$this->db->query($sql);
$sql = array();
return $this->_remove($sql);
}
}
?>

View File

@ -1,174 +0,0 @@
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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$
*
*/
class modDolibarrModules
{
/*
* Initialisation
*
*/
Function modDolibarrModules($DB)
{
$this->db = $DB ;
}
/*
*
*
*
*/
Function _init($array_sql)
{
/*
* Activation du module
*/
$err = 0;
foreach ($this->boxes as $key => $value)
{
$titre = $this->boxes[$key][0];
$file = $this->boxes[$key][1];
$sql = "SELECT count(*) FROM llx_boxes_def WHERE name ='".$titre."'";
if ( $this->db->query($sql) )
{
$row = $this->db->fetch_row($sql);
if ($row[0] == 0)
{
$sql = "insert into llx_boxes_def (name, file) values ('".$titre."','".$file."')";
if (! $this->db->query($sql) )
{
$err++;
}
}
}
else
{
$err++;
}
}
foreach ($this->const as $key => $value)
{
$name = $this->const[$key][0];
$type = $this->const[$key][1];
$val = $this->const[$key][2];
$note = $this->const[$key][3];
$sql = "SELECT count(*) FROM llx_const WHERE name ='".$name."'";
if ( $this->db->query($sql) )
{
$row = $this->db->fetch_row($sql);
if ($row[0] == 0)
{
if (strlen($note)){
$sql = "INSERT INTO llx_const (name,type,value,note) VALUES ('".$name."','".$type."','".$val."','$note')";
}elseif (strlen($val))
{
$sql = "INSERT INTO llx_const (name,type,value) VALUES ('".$name."','".$type."','".$val."')";
}
else
{
$sql = "INSERT INTO llx_const (name,type) VALUES ('".$name."','".$type."')";
}
if (! $this->db->query($sql) )
{
$err++;
}
}
}
else
{
$err++;
}
}
/*
*
*/
for ($i = 0 ; $i < sizeof($array_sql) ; $i++)
{
if (! $this->db->query($array_sql[$i]))
{
$err++;
}
}
if ($err > 0)
{
return 0;
}
else
{
return 1;
}
}
/*
*
*
*/
Function _remove($array_sql)
{
$err = 0;
for ($i = 0 ; $i < sizeof($array_sql) ; $i++)
{
if (! $this->db->query($array_sql[$i]))
{
$err++;
}
}
/*
* Boites
*/
foreach ($this->boxes as $key => $value)
{
$titre = $this->boxes[$key][0];
$file = $this->boxes[$key][1];
$sql = "DELETE FROM llx_boxes_def WHERE file = '".$file."'";
if (! $this->db->query($sql) )
{
$err++;
}
}
if ($err > 0)
{
return 0;
}
else
{
return 1;
}
}
}
?>

View File

@ -19,38 +19,43 @@
* $Source$
*
*/
include_once "DolibarrModules.class.php";
class modDon
class modDon extends DolibarrModules
{
/*
* Initialisation
*
*/
Function modDon($DB)
{
$this->db = $DB ;
$this->name = "Don";
$this->description = "Gestion des dons (expérimental)";
$this->const_name = "MAIN_MODULE_DON";
$this->const_config = MAIN_MODULE_DON;
$this->depends = array();
$this->const = array();
$this->boxes = array();
}
/*
*
*
*
*/
Function init()
{
/*
* Activation du module
*/
$sql = array(
);
$sql = array();
for ($i = 0 ; $i < sizeof($sql) ; $i++)
{
$this->db->query($sql[$i]);
}
return $this->_init($sql);
}
/*
*
@ -58,7 +63,9 @@ class modDon
*/
Function remove()
{
$sql = array();
return $this->_remove($sql);
}
}
?>

View File

@ -40,6 +40,7 @@ class modExternalRss extends DolibarrModules
$this->depends = array();
$this->const = array();
$this->boxes = array();
/*
* Boites

View File

@ -39,6 +39,9 @@ class modPostnuke extends DolibarrModules
$this->const_config = MAIN_MODULE_POSTNUKE;
$this->depends = array();
$this->const = array();
$this->boxes = array();
}
/*
*

View File

@ -29,7 +29,6 @@ class modSociete extends DolibarrModules
* Initialisation
*
*/
Function modSociete($DB)
{
$this->db = $DB ;
@ -39,7 +38,6 @@ class modSociete extends DolibarrModules
$this->const_name = "MAIN_MODULE_SOCIETE";
$this->const_config = MAIN_MODULE_SOCIETE;
$this->depends = array();
$this->const = array();