[ 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 // Base class for NewsletterInstance List Data abstraction. 20 // $Id$ 21 22 /** 23 * BD_newsletterInstanceListData is a base class for newsletter instances lists data 24 * database abstraction implementations, and must be inherited by all such. 25 * @package BD 26 * @author Antoine Angénieux <aangenieux@clever-age.com> 27 * @author Erwan Le Bescond <elebescond@clever-age.com> 28 * @access public 29 */ 30 31 if (defined("_BD_NEWSLETTERINSTANCELISTDATA")) 32 return; 33 34 define("_BD_NEWSLETTERINSTANCELISTDATA", "1"); 35 36 require_once("PEAR.php"); 37 require_once("DB.php"); 38 require_once dirname(__FILE__). "/objectlistdata.php"; 39 require_once dirname(__FILE__). "/inc_listdata_querytypes_constants.php"; 40 require_once (dirname(__FILE__). '/inc_newsletter_instance_factory.php'); 41 42 class BD_newsletterInstanceListData extends BD_objectListData { 43 44 /** 45 * Create a new newsletter instance list data object for the specified database parameters 46 * passed 47 * 48 * @param BD_parameters $dbParameters database configuration object 49 * @return mixed a newly created ArticleListData object, or a PEAR error code on 50 * error 51 * @access public 52 */ 53 function &factory ($dbParameters = null, $dbOptions = null) { 54 if (file_exists(dirname( 55 __FILE__). "/" . $dbParameters->_dbEngine . "/newsletter_instancelistdata_" . $dbParameters->_dbEngine . ".php") == false) 56 { 57 include_once (dirname(__FILE__). "/common/newsletter_instancelistdata_common.php"); 58 $classname = "BD_newsletterInstanceListData_common"; 59 } 60 else { 61 include_once (dirname( 62 __FILE__). "/" . $dbParameters->_dbEngine . "/newsletter_instancelistdata_" . $dbParameters->_dbEngine . ".php"); 63 $classname = "BD_newsletterInstanceListData_" . $dbParameters->_dbEngine; 64 } 65 66 if (!class_exists($classname)) { 67 return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false); 68 } 69 70 $obj = &new $classname; 71 72 $result = $obj->setDbParameters($dbParameters); 73 74 if ($dbOptions != null) { 75 $obj->setDbOptions($dbOptions); 76 } 77 78 if (PEAR::isError($result)) { 79 return $result; 80 } 81 else { 82 return $obj; 83 } 84 } 85 86 // {{{ constructor 87 88 /** 89 * Abstract Constructor. 90 * 91 * @access public 92 */ 93 94 function BD_newsletterInstanceListData () { 95 $par = get_parent_class(get_parent_class($this)); 96 97 $this->$par(); 98 } 99 100 // }}} 101 102 // {{{ displayHTMLList($titre_table, $queryType, $params, $afficher_visites = false, $afficher_auteurs = true, $toujours_afficher = false, $afficher_cadre = true) 103 104 /** 105 * returns the HTML List for the various article data lists implementations 106 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 107 * while overloading this method. 108 * 109 * @return String reprensenting the generated HTML list navigation 110 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 111 * @param $params array containing the query parameters 112 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 113 * @access public 114 */ 115 116 function displayHTMLList ($titre_table, $queryType, $params = array()) { 117 global $connect_id_auteur, $connect_statut; 118 $copyParams = $params; 119 $requete = $this->_getQuery($queryType, false, $params); 120 $tranches = $this->_getHTMLNavigation($queryType, $copyParams, 3); 121 /* 122 $tranches = afficher_tranches_requete($requete, $afficher_auteurs ? 3 : 2); 123 */ 124 if (strlen($tranches)) { 125 $db = &$this->_getDB(); 126 127 if (DB::isError($db)) { 128 die ("Impossible d'obternir une connexion à la base de données! " . $db->getMessage()); 129 } 130 131 if ($this->_getQueryIsLimited()) { 132 $limitStart = $this->_getLimitStart(); 133 $limitCount = $this->_getLimitCount(); 134 $result = $db->limitQuery($requete, $limitStart, $limitCount, $copyParams); 135 } 136 else { 137 $result = $db->query($requete, $params); 138 } 139 140 if (DB::isError($result)) { 141 die ("la requete a échouée! " . $result->getMessage()); 142 } 143 144 if ($result->numRows() > 0) { 145 debut_cadre_relief ("newsletter-24.gif"); 146 echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td width='100%' background=''>"; 147 echo "<table width='100%' cellpadding='3' cellspacing='0' border='0'>"; 148 149 bandeau_titre_boite($titre_table, true); 150 151 while ($row = $result->fetchRow()) { 152 echo '<tr bgcolor="#FFFFFF"><td class="arial2" colspan="5"><a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '"><img src="img_pack/puce-verte.gif" alt="" width="13" height="14" border="0"></a> <a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '">' . $row['pst_subject']. '</a></td>' . '<td class="arial2" nowrap>crée le ' . $row['pst_date_create']. '</td></tr>'; 153 } 154 155 echo "</table></td></tr></table>"; 156 fin_cadre_relief(); 157 } 158 $result->free(); 159 } 160 } 161 // }}} 162 163 // {{{ displayHTMLList($titre_table, $queryType, $params, $afficher_visites = false, $afficher_auteurs = true, $toujours_afficher = false, $afficher_cadre = true) 164 165 /** 166 * returns the HTML List for the various article data lists implementations 167 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 168 * while overloading this method. 169 * One thing has been added to this function to permit some action via button 170 * 171 * @return String reprensenting the generated HTML list navigation 172 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 173 * @param $params array containing the query parameters 174 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 175 * @access public 176 */ 177 178 function displayHTMLListWithPercentage ($titre_table, $queryType, $params = array(), $preparation = true) { 179 global $connect_id_auteur, $connect_statut; 180 $copyParams = $params; 181 $requete = $this->_getQuery($queryType, false, $params); 182 $tranches = $this->_getHTMLNavigation($queryType, $copyParams, 3); 183 /* 184 $tranches = afficher_tranches_requete($requete, $afficher_auteurs ? 3 : 2); 185 */ 186 if (strlen($tranches)) { 187 $db = &$this->_getDB(); 188 189 if (DB::isError($db)) { 190 die ("Impossible d'obternir une connexion à la base de données! " . $db->getMessage()); 191 } 192 193 if ($this->_getQueryIsLimited()) { 194 $limitStart = $this->_getLimitStart(); 195 $limitCount = $this->_getLimitCount(); 196 // hack Olivier Mansour - limitQuery renvoi une vielle erreur => pas de listes paginÂŽes 197 // TODO : FIXME 198 //$result = $db->limitQuery($requete, $limitStart, $limitCount, $copyParams); 199 $result = $db->query($requete, $params); 200 } 201 else { 202 $result = $db->query($requete, $params); 203 } 204 205 if (DB::isError($result)) { 206 die ("la requete a échouée! " . $result->getMessage()); 207 } 208 209 if ($result->numRows() > 0) { 210 debut_cadre_relief ("newsletter-24.gif"); 211 echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td width='100%' background=''>"; 212 echo "<table width='100%' cellpadding='3' cellspacing='0' border='0'>"; 213 214 bandeau_titre_boite($titre_table, true); 215 216 while ($row = $result->fetchRow()) { 217 $newsletterPartie = &recuperer_instance_newsletter_instance(); 218 $tabPercentage = $newsletterPartie->percentage_left($row['pst_id'], $row['lst_id']); 219 220 //On vérifie que le dénominateur n'est pas égal à 0 221 if ($tabPercentage[1] != 0) 222 $currentPercentage = round(100 * $tabPercentage[0] / $tabPercentage[1], 1); 223 else 224 $currentPercentage = 0; 225 if (($currentPercentage != 100) && ($preparation == false)) { 226 echo '<tr bgcolor="#FFFFFF"><td class="arial2" colspan="4"><a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '"><img src="img_pack/puce-verte.gif" alt="" width="13" height="14" border="0"></a> <a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '">' . $row['pst_subject']. '</a></td>' . '<td class="arial2" nowrap>' . $currentPercentage . '%</td><td class="arial2" nowrap>crée le ' . $row['pst_date_create']. '</td></tr>'; 227 } 228 else { 229 if ($preparation == true) { 230 $formulaireSuppress 231 = "<a href=\"suppress_pst.php?id_newsletter=" . $row['lst_id']. "&action=suppress&id_pst=" . $row['pst_id']. "\" title='" . _T('suppressPst'). "' ><img src='img_pack/suppress.gif' height='12' width='12' alt='" . _T('suppressPst'). "'></a>"; 232 } 233 else { 234 $formulaireSuppress 235 = "<a href=\"suppress_pst.php?id_newsletter=" . $row['lst_id']. "&action=suppress&id_pst=" . $row['pst_id']. "\" title='" . _T('suppressPst'). "' ><img src='img_pack/suppress.gif' height='12' width='12' alt='" . _T('suppressPst'). "'></a>"; 236 $formulaireNbUser 237 = "<a href=\"consult_post_done.php?id_newsletter=" . $row['lst_id']. "&action=suppress&id_pst=" . $row['pst_id']. "\" title='" . _T('exporter_la_liste_post'). "' ><img src='img_pack/telechargerUser.png' height='12' width='12' alt='" . _T('listeSubSent'). "'></a>"; 238 } 239 240 $authorization = &recuperer_instance_authorization('supprimerLettreEnvoi', 241 $GLOBALS['connect_id_auteur']); 242 243 if (!$authorization->isAuthorizedAction()) { 244 $formulaireSuppress = ""; 245 } 246 247 $authorization = &recuperer_instance_authorization('exporterSubscriberPostDone', 248 $GLOBALS['connect_id_auteur']); 249 250 if (!$authorization->isAuthorizedAction()) { 251 $formulaireNbUser = ""; 252 } 253 echo '<tr bgcolor="#FFFFFF" align="center"><td class="arial2" colspan="4"><a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '"><img src="img_pack/puce-verte.gif" alt="" width="13" height="14" border="0"></a> <a href="postinfo.php?id_post=' . $row['pst_id']. '&id_newsletter=' . $row['lst_id']. '" title="' . $row['pst_subject']. '">' . $row['pst_subject']. '</a></td>' . '<td class="arial2" nowrap>' . $formulaireSuppress . " " . $formulaireNbUser . '</td><td class="arial2" nowrap>crée le ' . $row['pst_date_create']. '</td></tr>'; 254 } 255 } 256 257 echo "</table></td></tr></table>"; 258 fin_cadre_relief(); 259 } 260 $result->free(); 261 } 262 } 263 264 // }}} 265 266 // {{{ _fillQueries() 267 268 /** 269 * This methods fill the query associative arrays with SQL 92 compliant 270 * queries. Each driver that requires specific SQL querying must implement 271 * the _adaptQueriesToDriver() method. 272 * @access private 273 * @see _adaptQueriesToDriver() 274 */ 275 function _fillQueries () { 276 $this->_queries[NEWSLETTER_INSTANCE_BY_SENT_DATE] 277 = 'SELECT pst_id, lst_id, pst_date_create, pst_date_update, pst_date_sent, pst_subject ' . ' FROM ' . $GLOBALS['table_prefix']. '_cm_posts' . ' WHERE pst_date_sent ! 0 AND lst_id = ?' . ' ORDER BY pst_date_sent desc, pst_date_create desc'; 278 $this->_queriesCount[NEWSLETTER_INSTANCE_BY_SENT_DATE] 279 = 'SELECT COUNT(pst_id) ' . ' FROM ' . $GLOBALS['table_prefix']. '_cm_posts' . ' WHERE pst_date_sent ! 0 AND lst_id = ?'; 280 } 281 282 // }}} 283 284 } 285 ?>
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 |