Subversion Repositories Applications.projet

Rev

Rev 249 | 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: liste.php,v 1.8 2007-06-25 12:15:07 alexandre_tb Exp $
23
/**
24
* Application projet
25
*
26
* Fichier de pr�sentation de la liste des projets
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.8 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
$titre = '<h1>'.PROJET_LISTE.'</h1>'."\n" ;
43
 
44
if (PROJET_UTILISE_TYPE && $this->_type != '') {
45
    $projetListe = projet::getProjetDuType($this->_type, $this->_db) ;
46
} else {
47
    // Un tableau de tous les projets dans $projetListe
48
    $projetListe = projet::getTousLesProjets($this->_db, $this->_projet_exclu) ;
49
}
50
 
51
// On inclue un fichier local
52
if (file_exists(PROJET_CHEMIN_APPLI.'langues/pro_langue_'.$GLOBALS['lang'].'.local.inc.php'))
53
	include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_'.$GLOBALS['lang'].'.local.inc.php' ;
54
// On verifie si l'utilisateur participe a des projets
55
//echo PROJET_CHEMIN_APPLI.'langues/pro_langue_'.$GLOBALS['lang'].'.local.inc.php';
56
// Entete de la liste, qu'on recupere dans un template
57
 
58
if (PROJET_UTILISE_TYPE && $this->_type != "") {
59
	include_once PROJET_CHEMIN_CLASSES.'projetTemplate.class.php' ;
60
	include_once 'HTML/Template/IT.php';
61
	$template = new projetTemplate ($this->_db) ;
62
	$chaine = $template->getTemplate(2, $GLOBALS['lang'], $this->_type);
63
	if (projetTemplate::isError ($chaine)) return $chaine->getMessage() ;
64
	$tpl = new HTML_Template_IT() ;
65
	$tpl -> setTemplate($chaine);
66
 
67
}
68
 
69
if ($auth){
70
	include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
71
    $utilisateur_liste = new inscription_liste($this->_db) ;
72
    // On teste ici s'il y a une mise a jour de statut
73
    if (isset($_POST['statut'])) {
74
        // $_POST['statut'] et $_GET['identifiant_projet'] proviennent du formulaire voir HTML_listeProjet
75
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
76
        $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
77
        $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
78
        $projet = new projet ($this->_db, $_GET['identifiant_projet']) ;
79
        $projet->getListesAssociees() ;
80
        $utilisateur_liste->modifierTypeInscription($projet->_listes_associes[0],$annuaire, $_POST['statut']) ;
81
    }
82
    if (count($participant->getIdProjetsStatuts($id_u))) {
83
		include_once PROJET_CHEMIN_CLASSES.'HTML_listeProjet.class.php' ;
84
        $HTML_projetListe = new HTML_listeProjet(true) ;
85
        $entete_liste = array($auth ? PROJET_VOUS_PARTICIPEZ : PROJET_LISTE) ;
86
        if ($auth) array_push ($entete_liste, PROJET_SE_DESINSCRIRE, PROJET_LISTE_DE_DISCUSSION) ;
87
 
88
 
89
        $tableau_resultat = array () ;
90
 
91
        $HTML_projetListe->construitEntete ($entete_liste) ;
92
 
93
        // On construit $tableau_resultat avec une ligne par projet contenant un tableau (titre, statut_nom, id_statut, id_projet)
94
        include_once PROJET_CHEMIN_CLASSES.'statut_liste.class.php' ;
95
        $statut_liste = new statut_liste($this->_db) ;
96
        $tableau_statut = $statut_liste->getTousLesStatuts() ;
97
 
98
        $statut = '' ;
99
        $i = 0 ;
100
        $HTML_projetListe->setModeModification() ;
101
        $HTML_projetListe->setURL($this->_url) ;
102
        foreach ($projetListe as $projet) {
103
            if (participe::getStatutSurProjetCourant($id_u, $projet->getId(), $this->_db) == 4) continue ;
104
            if ($auth) {
105
                if ($projet->avoirListe()) {
106
                    $projet->getListesAssociees() ;
107
                    $statut = $utilisateur_liste->getStatutInscrit($projet->_listes_associes[0]->getId(), $this->_auth) ;
108
                    //if ($statut == '') $statut = 0 ;
109
                }
110
            }
111
 
112
            $this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $projet->getId()) ;
113
            $ligne_tableau = array ($projet->getId(), $projet->getResume(),
114
						'<a href="'.$this->_url->getURL().'">'.$projet->getTitre().'</a>'
115
						) ;
116
            if ($auth) {
117
                $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_PROJET) ;
118
                array_push ($ligne_tableau, '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.
119
                                        PROJET_SE_DESINSCRIRE_CONFIRMATION.'\');">'.PROJET_SE_DESINSCRIRE.'</a>') ;
120
                if ($projet->avoirListe()) {
121
                    array_push ($ligne_tableau, $statut) ;
122
                } else {
123
                    array_push($ligne_tableau, '') ;
124
                }
125
                array_push ($tableau_resultat, $ligne_tableau) ;
126
                $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
127
            }
128
            $statut = '' ;
129
        }
130
        $HTML_projetListe->construitListe ($tableau_resultat, $tableau_statut) ;
131
 
132
 
133
        if ($HTML_projetListe->getRowCount() > 1) {
134
        	$res .= '<p>'.PROJET_PARTICIPER.'</p>';
135
        	$res .= $HTML_projetListe->toHTML() ;
136
        }
137
    } else {
138
        $res .= '<p>'.PROJET_INSCRIT_AUCUN_PROJET.'</p>' ;
139
    }
140
}
141
 
142
// Un texte pour ceux qui ne sont pas identifi�s
143
if (!$auth) {
144
    $res .= '<p>'.PROJET_TEXTE_NON_IDENTIFIE.'</p>'."\n" ;
145
}
146
 
147
// Maintenant la liste des projets ou l'utilisateur ne participe pas.
148
// Et si pas loggue tous les projets
149
if ($auth) {
150
    $projetNonParticipantListe = $participant -> getProjetsNonParticipant($id_u) ;
151
    // Si certain projet sont � exclure, on les exclu
152
    $projet_a_exclure = array() ;
153
    if (count($this->_projet_exclu)) {
154
    	arsort($this->_projet_exclu) ;
155
        foreach ($this->_projet_exclu as $valeur) {
156
        	for ($i = 0; $i < count($projetNonParticipantListe); $i++) {
157
        		if ($projetNonParticipantListe[$i]->getId() == $valeur)  array_push ($projet_a_exclure, $i);}
158
        }
159
    }
160
    if (PROJET_UTILISE_TYPE && $this->_type != '') {
161
    	for ($i = 0; $i < count($projetNonParticipantListe); $i++) {
162
    		if ($projetNonParticipantListe[$i]->getType() != $this->_type) array_push ($projet_a_exclure, $i) ;
163
    	}
164
   	}
165
 
166
    foreach ($projet_a_exclure as $valeur) {
167
    	unset ($projetNonParticipantListe[$valeur]) ;
168
    }
169
	include_once PROJET_CHEMIN_CLASSES.'HTML_listeProjet.class.php';
170
    $HTML_projetNonParticipantListe = new HTML_listeProjet(true) ;
171
    $entete_liste = array (PROJET_LISTE) ;
172
    array_push ($entete_liste, PROJET_S_INSCRIRE) ;
173
 
174
    $HTML_projetNonParticipantListe->construitEntete($entete_liste) ;
175
 
176
    $liste_projet = array() ;
177
    // La liste
178
 
179
    foreach ($projetNonParticipantListe as $projet) {
180
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $projet->getId()) ;
181
        $ligne_projet = array ($projet->getResume(),
182
                            '<a href="'.$this->_url->getURL().'">'.$projet->getTitre().'</a>'      // le nom du projet
183
                                ) ;
184
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
185
        array_push ($ligne_projet, '<a href="'.$this->_url->getURL().'">'.PROJET_S_INSCRIRE.'</a>') ;
186
 
187
        $this->_url->removeQueryString(PROJET_VARIABLE_ACTION);
188
        array_push ($liste_projet, $ligne_projet) ;
189
    }
190
    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
191
    $HTML_projetNonParticipantListe->construitListe($liste_projet) ;
192
    if ($HTML_projetNonParticipantListe->getRowCount() > 1) $res .= $HTML_projetNonParticipantListe->toHTML() ;
193
} else {
194
    $projetNonParticipantListe = & $projetListe ;
195
    include_once PROJET_CHEMIN_CLASSES.'HTML_listeProjet.class.php' ;
196
    $HTML_projetNonParticipantListe = new HTML_listeProjet(true) ;
197
    $entete_liste = array (PROJET_LISTE) ;
198
    $HTML_projetNonParticipantListe->construitEntete($entete_liste) ;
199
 
200
    $liste_projet = array() ;
201
    // La liste
202
    foreach ($projetNonParticipantListe as $projet) {
203
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $projet->getId()) ;
204
        $ligne_projet = array ( $projet->getResume(),
205
                            '<a href="'.$this->_url->getURL().'">'.$projet->getTitre().'</a>',  // le nom du projet
206
                            ) ;
207
 
208
        $this->_url->removeQueryString(PROJET_VARIABLE_ACTION);
209
        array_push ($liste_projet, $ligne_projet) ;
210
    }
211
    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
212
    $HTML_projetNonParticipantListe->construitListe($liste_projet) ;
213
    if ($HTML_projetNonParticipantListe->getRowCount() > 1) {
214
		$res .= '<p>'.PROJET_TOUS_LES_PROJETS.'</p>' ;
215
		$res .= $HTML_projetNonParticipantListe->toHTML() ;
216
    }
217
}
218
// Nettoyage de l'url
219
 
220
if (PROJET_UTILISE_TYPE && $this->_type != '') {
221
	$tpl->setVariable('liste_projet', $res) ;
222
	$res = $tpl->get();
223
}
224
$this->_url->removeQueryString (PROJET_VARIABLE_ID_PROJET);
225
return $titre.$res ;
226
 
227
/* +--Fin du code ----------------------------------------------------------------------------------------+
228
*
229
* $Log: liste.php,v $
230
* Revision 1.8  2007-06-25 12:15:07  alexandre_tb
231
* merge from narmer
232
*
233
* Revision 1.7  2007-06-01 13:56:13  alexandre_tb
234
* ajout d un include manquant
235
*
236
* Revision 1.6  2007/04/19 15:34:35  neiluj
237
* préparration release (livraison) "Narmer" - v0.25
238
*
239
* Revision 1.5  2006/12/19 09:48:50  alexandre_tb
240
* am�lioration du retour erreur lors de l appel au template
241
*
242
* Revision 1.4  2006/12/18 17:24:09  alexandre_tb
243
* inclusion du fichier de langue en utilisant la globale 'lang'
244
*
245
* Revision 1.3  2006/09/18 09:56:28  alexandre_tb
246
* utilisation d'un template pour l'ent�te de la liste des projets
247
*
248
* Revision 1.2  2005/11/28 16:25:23  alexandre_tb
249
* nettoyage URL en sortie de programme
250
*
251
* Revision 1.1  2005/11/25 14:47:51  alexandre_tb
252
* version initiale
253
*
254
 
255
*
256
*
257
* +-- Fin du code ----------------------------------------------------------------------------------------+
258
*/
259
 
260
 
66 alexandre_ 261
?>