Subversion Repositories Applications.projet

Rev

Rev 415 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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