Subversion Repositories Applications.projet

Rev

Rev 302 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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: HTML_listeParticipants.class.php,v 1.4 2007-06-25 12:15:06 alexandre_tb Exp $
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
34
*@version       $Revision: 1.4 $
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
     */
99
    function construitListe( $elements, $tableau_statut = '', &$projet )
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
            if (count ($elements)>5) $inscrit_liste = (int) array_pop ($elements[$i]);
107
            $id_statut = (int) array_pop ($elements[$i]) ;
108
            // En mode modif on ajoute la colonne supprimer
109
            if ($this->_mode == 1) {
110
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
111
                $this->_url->addQueryString('statut', 4) ;
112
                $supprimer = '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\')">'.PROJET_SUPPRIMER.'</a>';
113
                if (count ($elements) > 5) array_push ($elements[$i], '');
114
                array_push ($elements[$i], '', $supprimer);
115
                $this->_url->removeQueryString('statut') ;
116
            }
117
 
118
            // La colonne avec l inscription a la liste  de discussion
119
 
120
            $this->addRow ($elements[$i]) ;
121
            // mise à jour du champs mail en l'entourant par la balise mailto
122
 
123
            ///                     $i+1 pour sauter la ligne de titre,
124
 
125
            if (strlen ($elements[$i][2]) > 10) {
126
            	$mail_racourci = substr($elements[$i][2], 0, 10).'...' ;
127
            }
128
 
129
            $this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$mail_racourci.'</a>') ;
130
 
131
            // Mise à jour de la cellule contenant le statut
132
            if ($this->_mode == 1) {
133
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
134
                $select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
135
                $select .= '<select name="statut" onchange="javascript:this.form.submit();">' ;
136
                foreach ($tableau_statut as $cle =>$element_statut) {
137
                    $select .= '<option value="'.$cle.'"' ;
138
                    if ($cle == $id_statut) {
139
                        $select .= ' selected="selected"' ;
140
                    }
141
                    $select .= '>'.$element_statut.'</option>'."\n" ;
142
                }
143
                $select .= '</select>'."\n".'</form>'."\n" ;
144
                $this->setCellContents($i+1, 4, $select) ;
145
 
146
                // Colonne avec l inscription a la liste de discussion
147
                if (count ($elements)>5) {
148
                	$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
149
 
150
                	$select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
151
	                $select .= '<select name="inscription_liste" onchange="javascript:this.form.submit();">' ;
152
	                $select .= '<option value="0">Non inscrit</option>';
153
					$select .= '<option value="1"'.($inscrit_liste ? ' selected="selected"': '').'>Inscrit</option>';
154
	                $select .= '</select>'."\n".'</form>'."\n" ;
155
	                $this->setCellContents($i+1, 5, $select) ;
156
                }
157
            }
158
            if ($id_statut == 1 && $this->_mode != 1) {
159
                $this->setCellContents($i + 1, 4, PROJET_CHEF) ;
160
                $this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ;
161
            }
162
            if ($this->_mode != 1 && $id_statut != 1) {
163
                $this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ;
164
            }
165
            $this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ;
166
            $this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ;
167
        }
168
 
169
    } // end of member function construitListe
170
 
171
    /**
172
     *
173
     *
174
     * @return void
175
     * @access public
176
     */
177
    function setModeModification( )
178
    {
179
        $this->_mode = 1 ;
180
    } // end of member function setModeModification
181
 
182
    /**
183
     * Renvoie le code HTML de la table.
184
     *
185
     * @return string
186
     * @access public
187
     */
188
    function toHTML( )
189
    {
190
        // Application de style
191
        $this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ;
192
 
193
        // s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants
194
        if ($this->getRowCount() == 1) {
195
            return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n";
196
        }
197
 
198
        $res = HTML_Table::toHTML() ;
199
 
200
        return $res ;
201
    } // end of member function toHTML
202
 
203
    /**
204
     * Fixe la valeur de l'URL
205
     *
206
     * @param Net_URL url Un pointeur vers un objet Net_URL
207
     * @return void
208
     * @access public
209
     */
210
    function setURL( &$url )
211
    {
212
        $this->_url = $url ;
213
    } // end of member function setURL
214
 
215
} // end of HTML_listeParticipants
216
?>