Subversion Repositories Applications.projet

Rev

Rev 95 | Rev 302 | 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
// +------------------------------------------------------------------------------------------------------+
249 alexandre_ 22
// CVS : $Id: HTML_listeParticipants.class.php,v 1.4 2007-06-25 12:15:06 alexandre_tb Exp $
2 ddelon 23
/**
24
* Application projet
25
*
26
* La classe HTML_listeParticipants
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
249 alexandre_ 34
*@version       $Revision: 1.4 $
2 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ;
44
 
45
 
46
/**
47
 * class HTML_listeParticipants
48
 *
49
 */
50
class HTML_listeParticipants extends HTML_Liste
51
{
52
     /*** Attributes: ***/
53
 
54
    /**
55
     * Le mode, par défaut 0 => normal 1 => modification En mode modification, une
56
     * colonne de plus pour désinscrire un utilisateur
57
     * @access private
58
     */
59
    var $_mode;
60
    /**
61
     * L'url vers la page affichant la liste
62
     * @access private
63
     */
64
    var $_url;
65
 
66
    /**
67
     *
68
     *
69
     * @return void
70
     * @access public
71
     */
72
    function HTML_listeParticipants( $utilise_pager)
73
    {
74
        HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ;
75
    } // end of member function HTML_listeParticipants
76
 
77
    /**
78
     *
79
     *
80
     * @param Array elements Tableau des éléments de l'entête. Des labels.
81
     * @return void
82
     * @access public
83
     */
84
    function construitEntete( $elements )
85
    {
86
        if ($this->_mode == 1) {
87
            array_push ($elements, PROJET_SUPPRIMER) ;
88
        }
89
        $this->addRow ($elements, '', 'TH') ;
90
    } // end of member function construitEntete
91
 
92
    /**
93
     *
94
     *
95
     * @param Array elements Tableau à deux dimension contenant les éléments à afficher.
96
     * @return void
97
     * @access public
98
     */
249 alexandre_ 99
    function construitListe( $elements, $tableau_statut = '', &$projet )
2 ddelon 100
    {
101
        for ($i = 0; $i < count ($elements) ; $i++) {
102
            // L'identifiant de l'utilisateur est le premier élément du tableau
103
            $id_utilisateur = array_shift ($elements[$i]) ;
104
 
105
            // L'identifiant du statut est le dernier
106
            $id_statut = (int) array_pop ($elements[$i]) ;
107
            // En mode modif on ajoute la colonne supprimer
108
            if ($this->_mode == 1) {
109
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
110
                $this->_url->addQueryString('statut', 4) ;
111
                array_push ($elements[$i], '', '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\')">'
112
                                                .PROJET_SUPPRIMER.'</a>');
113
                $this->_url->removeQueryString('statut') ;
114
            }
115
 
249 alexandre_ 116
            // La colonne avec l inscription a la liste  de discussion
117
 
2 ddelon 118
            $this->addRow ($elements[$i]) ;
119
            // mise à jour du champs mail en l'entourant par la balise mailto
120
 
121
            ///                     $i+1 pour sauter la ligne de titre,
95 alexandre_ 122
 
123
            if (strlen ($elements[$i][2]) > 10) {
124
            	$mail_racourci = substr($elements[$i][2], 0, 10).'...' ;
125
            }
126
 
127
            $this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$mail_racourci.'</a>') ;
2 ddelon 128
 
129
            // Mise à jour de la cellule contenant le statut
130
            if ($this->_mode == 1) {
131
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
132
                $select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
133
                $select .= '<select name="statut" onchange="javascript:this.form.submit();">' ;
134
                foreach ($tableau_statut as $cle =>$element_statut) {
135
                    $select .= '<option value="'.$cle.'"' ;
136
                    if ($cle == $id_statut) {
137
                        $select .= ' selected="selected"' ;
138
                    }
139
                    $select .= '>'.$element_statut.'</option>'."\n" ;
140
                }
141
                $select .= '</select>'."\n".'</form>'."\n" ;
142
                $this->setCellContents($i+1, 4, $select) ;
143
            }
144
            if ($id_statut == 1 && $this->_mode != 1) {
145
                $this->setCellContents($i + 1, 4, PROJET_CHEF) ;
146
                $this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ;
147
            }
148
            if ($this->_mode != 1 && $id_statut != 1) {
149
                $this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ;
150
            }
11 alexandre_ 151
            $this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ;
152
            $this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ;
2 ddelon 153
        }
154
 
155
    } // end of member function construitListe
156
 
157
    /**
158
     *
159
     *
160
     * @return void
161
     * @access public
162
     */
163
    function setModeModification( )
164
    {
165
        $this->_mode = 1 ;
166
    } // end of member function setModeModification
167
 
168
    /**
169
     * Renvoie le code HTML de la table.
170
     *
171
     * @return string
172
     * @access public
173
     */
174
    function toHTML( )
175
    {
176
        // Application de style
11 alexandre_ 177
        $this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ;
2 ddelon 178
 
179
        // s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants
180
        if ($this->getRowCount() == 1) {
181
            return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n";
182
        }
183
 
184
        $res = HTML_Table::toHTML() ;
185
 
186
        return $res ;
187
    } // end of member function toHTML
188
 
189
    /**
190
     * Fixe la valeur de l'URL
191
     *
192
     * @param Net_URL url Un pointeur vers un objet Net_URL
193
     * @return void
194
     * @access public
195
     */
196
    function setURL( &$url )
197
    {
198
        $this->_url = $url ;
199
    } // end of member function setURL
200
 
201
} // end of HTML_listeParticipants
202
?>