431 |
mathias |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: liste_externe.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $
|
|
|
23 |
/**
|
|
|
24 |
* Application projet
|
|
|
25 |
*
|
|
|
26 |
* La classe liste_externe
|
|
|
27 |
*
|
|
|
28 |
*@package projet
|
|
|
29 |
//Auteur original :
|
|
|
30 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
|
|
31 |
//Autres auteurs :
|
|
|
32 |
*@author Aucun
|
|
|
33 |
*@copyright Tela-Botanica 2000-2004
|
|
|
34 |
*@version $Revision: 1.2 $
|
|
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
// | ENTETE du PROGRAMME |
|
|
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* class liste_externe
|
|
|
45 |
*
|
|
|
46 |
*/
|
|
|
47 |
class liste_externe
|
|
|
48 |
{
|
|
|
49 |
/*** Attributes: ***/
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Identifiant de la liste, dans la table agora et dans la table
|
|
|
53 |
* projet_lien_liste_externe
|
|
|
54 |
* @access private
|
|
|
55 |
*/
|
|
|
56 |
var $_id_liste;
|
|
|
57 |
/**
|
|
|
58 |
*
|
|
|
59 |
* @access private
|
|
|
60 |
*/
|
|
|
61 |
var $_db;
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Constructeur
|
|
|
65 |
*
|
|
|
66 |
* @param DB objetDB Un objet PEAR::DB
|
|
|
67 |
* @return void
|
|
|
68 |
* @access public
|
|
|
69 |
*/
|
|
|
70 |
function liste_externe(&$objetDB )
|
|
|
71 |
{
|
|
|
72 |
$this->_db = $objetDB ;
|
|
|
73 |
} // end of member function liste_externe
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Renvoie un tableau avec en clé l'identifiant d'une liste et en valeur le nom de
|
|
|
77 |
* la liste.
|
|
|
78 |
*
|
|
|
79 |
* @return Array
|
|
|
80 |
* @access public
|
|
|
81 |
*/
|
|
|
82 |
function getListeNom( )
|
|
|
83 |
{
|
|
|
84 |
$requete = 'select AGO_A_ID, AGO_A_NOMGRPLG from agora' ;
|
|
|
85 |
$resultat = $this->_db->query ($requete) ;
|
|
|
86 |
if (DB::isError ($resultat)) {
|
|
|
87 |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
|
|
|
88 |
}
|
|
|
89 |
$tableau_resultat = array() ;
|
|
|
90 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
91 |
$tableau_resultat[$ligne['AGO_A_ID']] = $ligne['AGO_A_NOMGRPLG'] ;
|
|
|
92 |
}
|
|
|
93 |
return $tableau_resultat ;
|
|
|
94 |
} // end of member function getListeNom
|
|
|
95 |
|
|
|
96 |
/**
|
|
|
97 |
* Renvoie un tableau avec les identifiants des listes associées au projet passé en
|
|
|
98 |
* paramètre.
|
|
|
99 |
*
|
|
|
100 |
* @param int id_projet L'identifiant du projet
|
|
|
101 |
* @return Array
|
|
|
102 |
* @access public
|
|
|
103 |
*/
|
|
|
104 |
function getListesAssociees( $id_projet )
|
|
|
105 |
{
|
|
|
106 |
$requete = 'select plle_id_liste from projet_lien_liste_externe where plle_id_projet='.$this->_db->escapeSimple($id_projet) ;
|
|
|
107 |
$resultat = $this->_db->query ($requete) ;
|
|
|
108 |
if (DB::isError ($resultat)) {
|
|
|
109 |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
|
|
|
110 |
}
|
|
|
111 |
$tableau_resultat = array() ;
|
|
|
112 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
113 |
array_push ($tableau_resultat, $ligne->plle_id_liste) ;
|
|
|
114 |
}
|
|
|
115 |
return $tableau_resultat ;
|
|
|
116 |
} // end of member function getListesAssociees
|
|
|
117 |
|
|
|
118 |
/**
|
|
|
119 |
* enregistrerSQL
|
|
|
120 |
*
|
|
|
121 |
* @return
|
|
|
122 |
*/
|
|
|
123 |
|
|
|
124 |
function enregistrerSQL ($valeur, $id_projet) {
|
|
|
125 |
|
|
|
126 |
// on commence par supprimer
|
|
|
127 |
$requete = 'delete from projet_lien_liste_externe where plle_id_projet='.$this->_db->escapeSimple($id_projet) ;
|
|
|
128 |
$resultat = $this->_db->query ($requete) ;
|
|
|
129 |
|
|
|
130 |
// puis on réinsère
|
|
|
131 |
foreach ($valeur as $cle => $val) {
|
|
|
132 |
if (!preg_match ('/liste_/', $cle)) continue ;
|
|
|
133 |
$id_liste = preg_replace ('/liste_/', '', $cle) ;
|
|
|
134 |
$requete = 'insert into projet_lien_liste_externe set plle_id_liste='.$this->_db->escapeSimple($id_liste).', plle_id_projet='.$this->_db->escapeSimple($id_projet) ;
|
|
|
135 |
$resultat = $this->_db->query ($requete) ;
|
|
|
136 |
if (DB::isError ($resultat)) {
|
|
|
137 |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
/**
|
|
|
143 |
* Renvoie un tableau avec les infos sur la liste, voir les noms des champs de la
|
|
|
144 |
* table agora pour une description plus détaillé.
|
|
|
145 |
*
|
|
|
146 |
* @param int id_liste L'identifiant de la liste
|
|
|
147 |
* @return void
|
|
|
148 |
* @access public
|
|
|
149 |
*/
|
|
|
150 |
function getInfoListe( $id_liste )
|
|
|
151 |
{
|
|
|
152 |
$requete = 'select * from agora where AGO_A_ID='.$this->_db->escapeSimple($id_liste) ;
|
|
|
153 |
$resultat = $this->_db->query ($requete) ;
|
|
|
154 |
if (DB::isError ($resultat)) {
|
|
|
155 |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
|
|
|
156 |
}
|
|
|
157 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
|
|
158 |
return $ligne ;
|
|
|
159 |
} // end of member function getInfoListe
|
|
|
160 |
|
|
|
161 |
} // end of liste_externe
|
|
|
162 |
?>
|