Subversion Repositories Applications.projet

Rev

Rev 397 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 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
// +------------------------------------------------------------------------------------------------------+
345 alexandre_ 22
// CVS : $Id: liste_externe.class.php,v 1.3 2008-09-16 14:12:04 alexandre_tb Exp $
2 ddelon 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
345 alexandre_ 34
*@version       $Revision: 1.3 $
2 ddelon 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
    {
415 raphael 106
		if(!intval($id_projet)) return NULL;
107
        $requete = sprintf('SELECT plle_id_liste FROM projet_lien_liste_externe WHERE plle_id_projet=%d -- %s',
108
						  intval($id_projet),
109
						  __FILE__ . ':' . __LINE__);
2 ddelon 110
        $resultat = $this->_db->query ($requete) ;
111
        if (DB::isError ($resultat)) {
112
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
113
        }
114
        $tableau_resultat = array() ;
115
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
116
            array_push ($tableau_resultat, $ligne->plle_id_liste) ;
117
        }
118
        return $tableau_resultat ;
119
    } // end of member function getListesAssociees
120
 
121
    /**
122
     *  enregistrerSQL
123
     *
124
     * @return
125
     */
126
 
127
    function enregistrerSQL ($valeur, $id_projet) {
128
 
129
        // on commence par supprimer
415 raphael 130
        $requete = 'delete from projet_lien_liste_externe where plle_id_projet='.intval($id_projet) ;
2 ddelon 131
        $resultat = $this->_db->query ($requete) ;
132
 
133
        // puis on réinsère
134
        foreach ($valeur as $cle => $val) {
135
            if (!preg_match ('/liste_/', $cle)) continue ;
136
            $id_liste = preg_replace ('/liste_/', '', $cle) ;
397 aurelien 137
            $requete = 'insert into projet_lien_liste_externe set plle_id_liste='.$this->_db->escapeSimple($id_liste).
415 raphael 138
            			', plle_id_projet='.inval($id_projet) ;
2 ddelon 139
            $resultat = $this->_db->query ($requete) ;
140
            if (DB::isError ($resultat)) {
141
                die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
142
            }
143
        }
144
    }
145
 
146
    /**
147
     * Renvoie un tableau avec les infos sur la liste, voir les noms des champs de la
148
     * table agora pour une description plus détaillé.
149
     *
150
     * @param int id_liste L'identifiant de la liste
151
     * @return void
152
     * @access public
153
     */
154
    function getInfoListe( $id_liste )
155
    {
397 aurelien 156
        $requete = 'select * from agora where AGO_A_ID='.$this->_db->escapeSimple($id_liste) ;
2 ddelon 157
        $resultat = $this->_db->query ($requete) ;
158
        if (DB::isError ($resultat)) {
345 alexandre_ 159
            return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
2 ddelon 160
        }
161
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
162
        return $ligne ;
163
    } // end of member function getInfoListe
164
 
165
} // end of liste_externe
166
?>