Subversion Repositories Applications.gtt

Rev

Rev 2 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
1
<?php
1
<?php
2
 
2
 
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 Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser 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
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser 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
 
22
 
23
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com                                                 |
23
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com                                                 |
24
// |@version 3                                                                                            |
24
// |@version 3                                                                                            |
25
 
25
 
26
 
26
 
27
class Preference
27
class Preference
28
{
28
{
-
 
29
	private $table = 'gestion_preferences';
29
   var $_utilisateur=null;
30
	private $id_utilisateur = null;
30
   var $_projet =null;
31
	private $id_projet = null;
31
   
32
	
32
   /**
-
 
33
   *constructeur
33
	/*** Constructeur */
34
   */
-
 
35
   function Preference($u,$p)
34
	function Preference($u, $p)
36
   {
35
	{
37
       $this->_utilisateur=$u;
36
		$this->_utilisateur = $u;
38
       $this->_projet=$p;
37
		$this->_projet = $p;
39
   }
38
	}
40
   
39
	
41
   
-
 
42
   /**
40
	/**
43
   *enregistrer une preference dans la base de donnees
41
	* Ajouter une préférence dans la base de données.
44
   *@return 1 si ok
-
 
45
   *@return 0 si aucun enregistrement effectue
42
	*@return true si ok, false si aucun enregistrement effectué
46
   *@return -1 si erreur
-
 
47
   */
43
	*/
48
   
-
 
49
   function enregistrerPreference()
44
	function ajouter()
50
   {
45
	{
51
       $table=GEST_PREFERENCES;
46
		$requete =	'INSERT INTO gestion_preferences (gp_id_utilisateur, gp_id_projet) '.
52
       
-
 
53
       $champs =array(
-
 
54
                GEST_CHAMPS_ID_UTILISATEUR =>$this->_utilisateur,
47
					'VALUES ('.$this->id_utilisateur.', '.$this->id_projet.')';
55
		GEST_CHAMPS_ID_PROJET =>$this->_projet);
48
		$resultat = $GLOBALS['db']->query($requete);
56
		
-
 
57
       $resultat = $GLOBALS['db']->autoExecute($table,$champs,DB_AUTOQUERY_INSERT);
-
 
58
    
49
		
59
       if (DB::isError($resultat)) {
50
		if (DB::isError($resultat)) {
60
           die($resultat->getMessage());
-
 
61
       }
51
			die($resultat->getMessage());
62
       
52
		}
63
        $j=$GLOBALS['db']->affectedRows();
53
		$nbre_enregistrement_ajoute = $GLOBALS['db']->affectedRows();
64
   
54
        
65
    if ($j==1)
-
 
66
    {
55
		if ($nbre_enregistrement_ajoute == 1) {
67
	return 1;
56
			return true;
68
    }elseif($j==0){
-
 
69
	return 0;
-
 
70
    }else{
57
		} elseif ($nbre_enregistrement_ajoute == 0) {
71
	return -1;
58
			return false;
72
    }
59
		}
73
  }
60
	}
74
   
61
 
75
   /**
62
	/**
76
   *recuperer la liste de preferences d'un utilisateur
63
	* Récupérer la liste de préférences d'un utilisateur.
77
   *@param identifiant utilisateur
64
	*@param identifiant utilisateur.
78
   */
65
	*/
79
   function  recupererTableauPreferences()
66
	function  recupererTableauPreferences()
80
  {
67
	{
81
       $table=array();
68
		$table = array();
82
       $requete="SELECT P.".GEST_CHAMPS_ID_PROJET.", P.".GEST_CHAMPS_NOM_PROJET." ,C.".GEST_CHAMPS_ID_CATEGORIE.",C.".GEST_CHAMPS_LIBELLE_CATEGORIE.
69
		$requete =	"SELECT P.".GEST_CHAMPS_ID_PROJET.", P.".GEST_CHAMPS_NOM_PROJET." ,C.".GEST_CHAMPS_ID_CATEGORIE.",C.".GEST_CHAMPS_LIBELLE_CATEGORIE.
83
                " FROM ".GEST_PREFERENCES." F, ".GEST_PROJET." P,".GEST_CATEGORIE." C".
70
					" FROM ".GEST_PREFERENCES." F, ".GEST_PROJET." P,".GEST_CATEGORIE." C".
84
		" WHERE ".GEST_CHAMPS_ID_UTILISATEUR. " = $this->_utilisateur".
71
					" WHERE ".GEST_CHAMPS_ID_UTILISATEUR. " = $this->_utilisateur".
85
		" AND  F.".GEST_CHAMPS_ID_PROJET." = P.".GEST_CHAMPS_ID_PROJET.
72
					" AND  F.".GEST_CHAMPS_ID_PROJET." = P.".GEST_CHAMPS_ID_PROJET.
86
		" AND P.".GEST_CHAMPS_ID_CATEGORIE." = C.".GEST_CHAMPS_ID_CATEGORIE.
73
					" AND P.".GEST_CHAMPS_ID_CATEGORIE." = C.".GEST_CHAMPS_ID_CATEGORIE.
87
		" ORDER BY ".GEST_CHAMPS_LIBELLE_CATEGORIE;
74
					" ORDER BY ".GEST_CHAMPS_LIBELLE_CATEGORIE;
88
	$resultat = $GLOBALS['db']->query($requete);
75
		$resultat = $GLOBALS['db']->query($requete);
89
     
76
		
90
      (DB::isError($resultat)) ? die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
77
		(DB::isError($resultat)) ? die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
91
      
78
		
92
      while($ligne=$resultat->fetchRow(DB_FETCHMODE_ASSOC))
-
 
93
      {
79
		while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
94
	  $case=array('id_proj'=>$ligne[GEST_CHAMPS_ID_PROJET],'nom_proj'=>$ligne[GEST_CHAMPS_NOM_PROJET],'id_cat'=>$ligne[GEST_CHAMPS_ID_CATEGORIE],'libelle_cat'=>$ligne[GEST_CHAMPS_LIBELLE_CATEGORIE]);
80
			$case = array('id_proj' => $ligne[GEST_CHAMPS_ID_PROJET], 'nom_proj' => $ligne[GEST_CHAMPS_NOM_PROJET],'id_cat' => $ligne[GEST_CHAMPS_ID_CATEGORIE], 'libelle_cat' => $ligne[GEST_CHAMPS_LIBELLE_CATEGORIE]);
95
	  array_push($table,$case);
81
			array_push($table, $case);
96
      }
82
		}
97
	return $table;
83
		return $table;
98
  }
84
	}
99
      
85
      
100
      /**
86
      /**
101
      *supprimer liste de preferences
87
      *supprimer liste de preferences
102
      *pour un utilisateur donne
88
      *pour un utilisateur donne
103
      *@param identifiant d'un utilisateur
89
      *@param identifiant d'un utilisateur
104
      */
90
      */
105
      
91
      
106
      function supprimerPreferences($id)
92
	function supprimerPreferences($id)
107
      {
93
	{
108
	  $requete="DELETE FROM ".GEST_PREFERENCES.
94
		$requete =	'DELETE FROM '.GEST_PREFERENCES.' '.
109
	           " WHERE ".GEST_CHAMPS_ID_UTILISATEUR. " =$id ";
-
 
110
		   
95
					'WHERE '.GEST_CHAMPS_ID_UTILISATEUR.' = '.$id;
111
          $resultat = $GLOBALS['db']->query($requete);
-
 
112
	  
96
		$resultat = $GLOBALS['db']->query($requete);
113
	 $j=$GLOBALS['db']->affectedRows();
-
 
114
          return $j;
97
		return $GLOBALS['db']->affectedRows();
115
      }
98
	}
116
     
99
	
117
     /**
100
	/**
118
     *fonction renvoyant vrai si un projet est dans la liste de preference d'un utilisateur
101
	* Méthode renvoyant vrai si un projet est dans la liste de préférence d'un utilisateur.
119
     *$id : identifiant du projet a chercher
102
	*$id : identifiant du projet a chercher
120
     @return true : si existe
103
	*@return true : si existe
121
     @return false si n'existe pas
104
	*@return false si n'existe pas
122
     */
-
 
123
     
105
	*/
124
     function isInPreferences($id)
106
	function isInPreferences($id)
125
     {
107
	{
126
	$tab=$this->recupererTableauPreferences(); 
108
		$tab = $this->recupererTableauPreferences(); 
127
	$res=false;
109
		$res = false;
128
	for ($r=0; $r<count($tab);$r++)
-
 
129
	{
110
		for ($r = 0; $r < count($tab); $r++) {
130
	    $t=$tab[$r];
111
			$t = $tab[$r];
131
	    if ($t['id_proj']==$id)
-
 
132
	    {
112
			if ($t['id_proj'] == $id) {
133
		$res=true;
113
				$res = true;
134
	    }
114
			}
135
	}  
115
		}
136
	return $res;	    
116
		return $res;	    
137
     }
117
	}
138
     
118
	
139
     /**
119
	/**
140
      *afficher preferences
120
	* Afficher préférences
141
      */
-
 
142
      
121
	*/
143
      function afficherPreference()
122
	function afficherPreference()
144
      {
123
	{
145
	  echo "<br /> preferences <br />";
124
		echo "<br /> preferences <br />";
146
	  $u= array($this->_utilisateur,$this->_projet);
125
		$u= array($this->_utilisateur,$this->_projet);
147
	  
126
		
148
	  foreach ($u as $p)
-
 
149
	  {
127
		foreach ($u as $p) {
150
	      echo "$p , ";
128
			echo "$p , ";
151
	  }
-
 
152
	  
129
		}
153
	  echo "<br /> ";
130
		echo "<br /> ";
154
      }
131
	}
155
}
132
}
156
?>
133
?>