Subversion Repositories Applications.projet

Rev

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

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