[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 // Classe sondage 20 // 21 22 if (defined("_BD_SONDAGE")) 23 return; 24 25 define("_BD_SONDAGE", "1"); 26 27 require_once("PEAR.php"); 28 require_once("DB.php"); 29 require_once dirname(__FILE__). "/metier.php"; 30 require_once dirname(__FILE__). "/inc_sondage_factory.php"; 31 32 define("SONDAGE", "id_article, actif, affichage_public"); 33 34 /** 35 * Gestion de la table des sondages (link) 36 * @author François Xavier LACROIX <fxlacroix@clever-age.com> 37 * @access public 38 */ 39 40 class BD_sondage extends BD_metier { 41 42 /** 43 * $_id_article id. 44 * @var BiGint 45 * @access private 46 */ 47 var $_id_article; 48 49 /** 50 * $_actif. 51 * @var Char(3) 52 * @access private 53 */ 54 var $_actif; 55 56 /** 57 * $_affichage_public 58 * @var Char(3) 59 * @access private 60 */ 61 var $_affichage_public; 62 63 /** 64 * DB_sondage constructor. 65 * 66 * @access public 67 */ 68 // {{{ bdSondage 69 function bdSondage () { } 70 71 // }}} 72 73 // {{{ getIdArticle() 74 function getIdArticle () { 75 return $this->_id_article; 76 } 77 78 // }}} 79 80 // {{{ setIdArticle() 81 function setIdArticle ($id_article) { 82 $this->_id_article = $id_article; 83 } 84 85 // }}} 86 87 // {{{ getActif() 88 function getActif () { 89 return $this->_actif; 90 } 91 92 // }}} 93 94 // {{{ setActif() 95 function setActif ($actif) { 96 $this->_actif = $actif; 97 } 98 99 // }}} 100 101 // {{{ getAffichagePublic() 102 function getAffichagePublic () { 103 return $this->_affichage_public; 104 } 105 106 // }}} 107 108 // {{{ setAffichagePublic() 109 function setAffichagePublic ($affichage_public) { 110 $this->_affichage_public = $affichage_public; 111 } 112 113 // }}} 114 115 // {{{ Create() 116 //Fonction de création d'un objet dans la table ".$GLOBALS['table_prefix']."_cm_lists_subscribers 117 118 function create () { 119 $db = &$this->_getDB(); 120 121 if (DB::isError($db)) { 122 return PEAR::raiseError("[" . get_class($this). " DB_sondage : create()] " . $db->getMessage(). "", null, 123 null, null, 124 null, null, 125 false); 126 } 127 128 if ($this->_id_article == null) 129 $this->_id_article = 0; 130 131 if ($this->_actif == null) 132 $this->_actif = ""; 133 134 if ($this->_affichage_public == null) 135 $this->_affichage_public = ""; 136 137 $query 138 = "INSERT INTO " . $GLOBALS['table_prefix']. "_sondages (" . SONDAGE . ") VALUES " . "('" . $this->_id_article . "', " . "'" . $this->_actif . "', " . "'" . $this->_affichage_public . "')"; 139 140 //echo"<br />$query<br><br />"; 141 142 $result = $db->query($query); 143 144 if (DB::isError($result)) { 145 return PEAR::raiseError("[" . get_class($this). " DB_sondage : create()] " . $result->getMessage(). "", 146 null, 147 null, 148 null, 149 null, 150 null, 151 false); 152 } 153 } 154 155 // }}} 156 157 // {{{ load_lst() 158 //load_lst() charge un objet de la base par son identifiant lst_id 159 160 function loadArticle ($id_article) { 161 $db = &$this->_getDB(); 162 163 if (DB::isError($db)) { 164 return PEAR::raiseError("[" . get_class($this). " DB_sondage : loadArticle()] " . $db->getMessage(). "", 165 null, 166 null, 167 null, 168 null, 169 null, 170 false); 171 } 172 173 $query = "SELECT " . SONDAGE . " FROM " . $GLOBALS['table_prefix']. "_sondages WHERE id_article = $id_article"; 174 175 $result = $db->query($query); 176 177 if (DB::isError($result)) { 178 return PEAR::raiseError("[" . get_class($this). " DB_sondage : loadArticle()] " . $result->getMessage(). "", 179 null, 180 null, 181 null, 182 null, 183 null, 184 false); 185 } 186 else { 187 if ($row = $result->fetchRow()) { 188 $this->_id_article = $row['id_article']; 189 $this->_actif = $row['actif']; 190 $this->_affichage_public = $row['affichage_public']; 191 } 192 else { 193 return PEAR::raiseError("[" . get_class($this). " DB_sondage : loadArticle()] Aucuns liens associés!", 194 null, 195 null, 196 null, 197 null, 198 null, 199 false); 200 } 201 $result->free(); 202 } 203 } 204 205 // }}} 206 207 // {{{ parametrerSondage() 208 //parametrerSondage() verifie les reponse et ajuste la configuration du sondage 209 function parametrerSondage ($id_article) { 210 $db = &$this->_getDB(); 211 212 if (DB::isError($db)) { 213 return PEAR::raiseError("[" . get_class($this). " DB_sondage : loadArticle()] " . $db->getMessage(). "", 214 null, 215 null, 216 null, 217 null, 218 null, 219 false); 220 } 221 222 $query 223 = "SELECT actif, affichage_public FROM " . $GLOBALS['table_prefix']. "_sondages WHERE id_article = $id_article"; 224 225 $result = $db->query($query); 226 227 if (DB::isError($result)) { 228 return PEAR::raiseError("[" . get_class($this). " DB_sondage : loadArticle()] " . $result->getMessage(). "", 229 null, 230 null, 231 null, 232 null, 233 null, 234 false); 235 } 236 else { 237 if ($result->numRows()) { 238 $row = $result->fetchRow(); 239 $actif_affiche[0] = $row['actif']; 240 //Bizarre ce $tab!!! 241 //$tab[1] = $row['affichage_public']; 242 $actif_affiche[1] = $row['affichage_public']; 243 } 244 else { 245 $actif_affiche[0] = 'oui'; 246 $actif_affiche[1] = 'non'; 247 $db->query( 248 "INSERT INTO " . $GLOBALS['table_prefix']. "_sondages (id_article, actif, affichage_public) VALUES ($id_article, 'oui', 'non')"); 249 } 250 return ($actif_affiche); 251 } 252 } 253 254 // {{{ modifierProfile() 255 //modifierProfile() modifie les paramètres du sondage 256 function modifierProfile ($actif, $affichage_public, $id_article) { 257 $db = &$this->_getDB(); 258 259 if (DB::isError($db)) { 260 return PEAR::raiseError("[" . get_class($this). " DB_sondage : modifierProfile()] " . $db->getMessage(). "", 261 null, 262 null, 263 null, 264 null, 265 null, 266 false); 267 } 268 269 $query 270 = "UPDATE " . $GLOBALS['table_prefix']. "_sondages SET actif = '$actif', affichage_public = '$affichage_public' WHERE id_article = $id_article"; 271 272 $result = $db->query($query); 273 274 if (DB::isError($result)) { 275 return PEAR::raiseError( 276 "[" . get_class($this). " DB_sondage : modifierProfile()] " . $result->getMessage(). "", null, 277 null, null, 278 null, null, 279 false); 280 } 281 } 282 283 // }}} 284 285 // {{{ factory() 286 //Fonction factory pour l'instanciation de l'objet 287 288 function &factory ($dbParameters, $dbOptions = null) { 289 if (file_exists( 290 dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/sondage_" . $dbParameters->_dbEngine . ".php") 291 == false) { 292 include_once(dirname(__FILE__). "/common/sondage_common.php"); 293 $classname = "BD_sondage"; 294 } 295 else { 296 include_once( 297 dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/sondage_" . $dbParameters->_dbEngine . ".php"); 298 $classname = "BD_sondage_" . $dbParameters->_dbEngine; 299 } 300 301 if (!class_exists($classname)) { 302 return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false); 303 } 304 305 $obj = &new $classname; 306 $result = $obj->setDbParameters($dbParameters); 307 308 if ($dbOptions != null) { 309 $obj->setDbOptions($dbOptions); 310 } 311 312 if (PEAR::isError($result)) { 313 return $result; 314 } 315 else { 316 return $obj; 317 } 318 } 319 320 // }}} 321 322 } 323 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |