[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Agora1-4/ecrire/include/bd/ -> newsletter_cm_list.php (source)

   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 ".$GLOBALS['table_prefix']."_cm_list_subscribers
  20  //
  21  
  22  if (defined("_BD_NEWSLETTER_CM_COMMON_LIST"))
  23      return;
  24  
  25  define("_BD_NEWSLETTER_CM_COMMON_LIST", "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_newsletter_cm_list_factory.php";
  31  
  32  define("SUBSCRIBERS_LINK", "lst_id, sub_id, lsr_mode, lsr_id");
  33  define("NEWSLETTERS_ALL_LIST",
  34         "lst_id, lst_name, lst_comment, lst_moderation, lst_moderator_email, lst_subscribe_subject, lst_subscribe_text, lst_subject, lst_unsubscribe_subject, lst_unsubscribe_text, lst_subject_tag, lst_html_skeleton, lst_text_skeleton, lst_nb_articles");
  35  define("SUBSCRIBERS_ALL_FIELDS",
  36         "sub_id, sub_email, sub_first_name, sub_middle_name, sub_last_name, sub_title ,sub_profile");
  37  
  38  /**
  39   * Gestion des listes de newsletter par id (cf. subscriber_cm)
  40   * @author  François Xavier LACROIX <fxlacroix@clever-age.com>
  41   * @access  public
  42   */
  43  
  44  class BD_newsletter_cm_list extends BD_metier {
  45  
  46      /**
  47         * Newsletter ID.
  48         * @var     int
  49         * @access  private
  50         */
  51      var $_lst_id;
  52  
  53      /**
  54       * nom de la liste newsletter.
  55       * @var    int
  56       * @access  private
  57       */
  58      var $_lst_name;
  59  
  60      /**
  61       * Commentaire associé
  62       * @var     String
  63       * @access  private
  64       */
  65      var $_lst_comment;
  66  
  67      /**
  68       * lst_moderation
  69       * @var     String(open)
  70       * @access  private
  71       */
  72      var $_lst_moderation;
  73  
  74      /**
  75       * liste des mails modérateurs
  76       * @var     string
  77       * @access  private
  78       */
  79      var $_lst_moderator_email;
  80  
  81      /**
  82       * lst_subscribe_subject
  83       * @var     String
  84       * @access  private
  85       */
  86      var $_lst_subscribe_subject;
  87  
  88      /**
  89       * lst_subscribe_text
  90       * @var     string
  91       * @access  private
  92       */
  93      var $_lst_subscribe_text;
  94  
  95      /**
  96       * lst_subject disponible
  97       * @var     string
  98       * @access  private
  99       */
 100      var $_lst_subject;
 101  
 102      /**
 103       * lst_unsubscribe_subject 
 104       * @var     string
 105       * @access  private
 106       */
 107      var $_lst_unsubscribe_subject;
 108  
 109      /**
 110       * lst_unsubscribe_text pour se désincrire
 111       * @var     string
 112       * @access  private
 113       */
 114      var $_lst_unsubscribe_text;
 115  
 116      /**
 117       * lst_subject_tag
 118       * @var     int
 119       * @access  private
 120       */
 121      var $_lst_subject_tag;
 122  
 123      /**
 124       * lst_html_skeleton
 125       * @var     string
 126       * @access  private
 127       */
 128      var $_lst_html_skeleton;
 129  
 130      /**
 131       * lst_html_skeleton
 132       * @var     string
 133       * @access  private
 134       */
 135      var $_lst_text_skeleton;
 136  
 137      /**
 138      * lst_html_skeleton
 139      * @var     int
 140      * @access  private
 141      */
 142      var $_lst_nb_articles;
 143  
 144  	function newsletterCmList () { }
 145  
 146      // }}}
 147  
 148      // {{{ newsletterCmList()
 149  
 150  	function getLstId () {
 151          return $this->_lst_id;
 152      }
 153  
 154      // }}}
 155  
 156      // {{{ getLstId()
 157  
 158  	function setLstId ($id) {
 159          $this->_lst_id = $id;
 160      }
 161  
 162      // }}}
 163  
 164      // {{{ setLstId()
 165  
 166  	function getLstName () {
 167          return $this->_lst_name;
 168      }
 169  
 170      // }}}
 171  
 172      // {{{ getLstName()
 173  
 174  	function setLstName ($name) {
 175          $this->_lst_name = $name;
 176      }
 177  
 178      // }}}
 179  
 180      // {{{ setLstName()
 181  
 182  	function getLstComment () {
 183          return $this->_lst_comment;
 184      }
 185  
 186      // }}}
 187  
 188      // {{{ getLstComment()
 189  
 190  	function setLstComment ($name) {
 191          $this->_lst_comment = $name;
 192      }
 193  
 194      // }}}
 195  
 196      // {{{ setLstComment()
 197  
 198  	function getLstModeration () {
 199          return $this->_lst_moderation;
 200      }
 201  
 202      // }}}
 203  
 204      // {{{ getLstModeration()
 205  
 206  	function setLstModeration ($name) {
 207          $this->_lst_moderation = $name;
 208      }
 209  
 210      // }}}
 211  
 212      // {{{ setLstModeration()
 213  
 214  	function get_lst_moderator_email () {
 215          return $this->_lst_moderator_email;
 216      }
 217  
 218      // }}}
 219  
 220      // {{{ get_lst_moderator_email()
 221  
 222  	function setLstModeratorEmail ($mail) {
 223          $this->_lst_moderator_email = $mail;
 224      }
 225  
 226      // }}}
 227  
 228      // {{{ setLstModeratorEmail()
 229  
 230  	function getLstSubscribeSubject () {
 231          return $this->_lst_subscribe_subject;
 232      }
 233  
 234      // }}}
 235  
 236      // {{{ getLstSubscribeSubject()
 237  
 238  	function setLstSubscribeSubject ($mail) {
 239          $this->_lst_subscribe_subject = $mail;
 240      }
 241  
 242      // }}}
 243  
 244      // {{{ setLstSubscribeSubject()
 245  
 246  	function getLstSubscribeText () {
 247          return $this->_lst_subscribe_text;
 248      }
 249  
 250      // }}}
 251  
 252      // {{{ getLstSubscribeText()
 253  
 254  	function setLstSubscribeText ($tex) {
 255          $this->_lst_subscribe_text = $tex;
 256      }
 257  
 258      // }}}
 259  
 260      // {{{ setLstSubscribeText()
 261  
 262  	function getLstSubject () {
 263          return $this->_lst_subject;
 264      }
 265  
 266      // }}}
 267  
 268      // {{{ getLstSubject()
 269  
 270  	function setLstSubject ($sub) {
 271          $this->_lst_subject = $sub;
 272      }
 273  
 274      // }}}
 275  
 276      // {{{ setLstSubject()
 277  
 278  	function getLstUnsubscribeSubject () {
 279          return $this->_lst_unsubscribe_subject;
 280      }
 281  
 282      // }}}
 283  
 284      // {{{ getLstUnsubscribeSubject()
 285  
 286  	function setLsUnsubscribeSubject ($sub) {
 287          $this->_lst_unsubscribe_subject = $sub;
 288      }
 289  
 290      // }}}
 291  
 292      // {{{ setLsUnsubscribeSubject()
 293  
 294  	function getLstUnsubscribeText () {
 295          return $this->_lst_unsubscribe_text;
 296      }
 297  
 298      // }}}
 299  
 300      // {{{ getLstUnsubscribeText()
 301  
 302  	function setLstUnsubscribeText ($tex) {
 303          $this->_lst_unsubscribe_text = $tex;
 304      }
 305  
 306      // }}}
 307  
 308      // {{{ setLstUnsubscribeText()
 309  
 310  	function getLstSubjectTag () {
 311          return $this->_lst_subject_tag;
 312      }
 313  
 314      // }}}
 315  
 316      // {{{ getLstSubjectTag()
 317  
 318  	function setLstSubjectTag ($tag) {
 319          $this->_lst_subject_tag = $tag;
 320      }
 321  
 322      // }}}
 323  
 324      // {{{ setLstSubjectTag()
 325  
 326  	function getLstHtmlSkeleton () {
 327          return $this->_lst_html_skeleton;
 328      }
 329  
 330      // }}}
 331  
 332      // {{{ getLstHtmlSkeleton()
 333  
 334  	function setLstHtmlSkeleton ($skeleton) {
 335          $this->_lst_html_skeleton = $skeleton;
 336      }
 337  
 338      // }}}
 339  
 340      // {{{ setLstHtmlSkeleton()
 341  
 342  	function getLstTextSkeleton () {
 343          return $this->_lst_text_skeleton;
 344      }
 345  
 346      // }}}
 347  
 348      // {{{ getLstTextSkeleton()
 349  
 350  	function setLstTextSkeleton ($skeleton) {
 351          $this->_lst_text_skeleton = $skeleton;
 352      }
 353  
 354      // }}}
 355  
 356      // {{{ setLstTextSkeleton()
 357  
 358  	function getLstNbArticles () {
 359          return $this->_lst_nb_articles;
 360      }
 361  
 362      // }}}
 363  
 364      // {{{ getLstNbArticles()
 365  
 366  	function setLstNbArticles ($article) {
 367          $this->_lst_nb_articles = $article;
 368      }
 369  
 370      // }}}
 371  
 372      // {{{ setLstNbArticles()
 373  
 374      //
 375      //La fonction create crée un nouvel enregistrement dans la table ".$GLOBALS['table_prefix']."_cm_list
 376      //
 377  	function create () {
 378          $db = &$this->_getDB();
 379  
 380          if (DB::isError($db)) {
 381              return PEAR::raiseError(
 382                         "[" . get_class($this). " DB_newsletter_cm_list : create()] " . $db->getMessage(). "", null,
 383                         null, null,
 384                         null, null,
 385                         false);
 386          }
 387  
 388          if ($this->_lst_id == null)
 389              $this->_lst_id = 0;
 390  
 391          if ($this->_lst_name == null)
 392              $this->_lst_name = "";
 393  
 394          if ($this->_lst_comment == null)
 395              $this->_lst_comment = "";
 396  
 397          if ($this->_lst_moderation == null)
 398              $this->_lst_moderation = "";
 399  
 400          if ($this->_lst_moderator_email == null)
 401              $this->_lst_moderator_email = "";
 402  
 403          if ($this->_lst_subscribe_subject == null)
 404              $this->_lst_subscribe_subject = "";
 405  
 406          if ($this->_lst_subscribe_text == null)
 407              $this->_lst_subscribe_text = "";
 408  
 409          if ($this->_lst_unsubscribe_subject == null)
 410              $this->_lst_unsubscribe_subject = "";
 411  
 412          if ($this->_lst_unsubscribe_text == null)
 413              $this->_lst_unsubscribe_text = "";
 414  
 415          if ($this->_lst_subject_tag == null)
 416              $this->_lst_subject_tag = 0;
 417  
 418          if ($this->_lst_html_skeleton == null)
 419              $this->_lst_html_skeleton = "";
 420  
 421          if ($this->_lst_text_skeleton == null)
 422              $this->_lst_text_skeleton = "";
 423  
 424          if ($this->_lst_nb_articles == null)
 425              $this->_lst_nb_articles = 0;
 426  
 427          $query
 428              = "INSERT INTO " . $GLOBALS['table_prefix']. "_cm_lists (" . NEWSLETTERS_ALL_LIST . ") VALUES " . "('" . $this->_lst_id . "', " . "'" . $this->_lst_name . "', " . "'" . $this->_lst_comment . "', " . "'" . $this->_lst_moderation . "', " . "'" . $this->_lst_moderator_email . "', " . "'" . $this->_lst_subscribe_subject . "', " . "'" . $this->_lst_subscribe_text . "', " . "'" . $this->_lst_subject . "', " . "'" . $this->_lst_unsubscribe_subject . "', " . "'" . $this->_lst_unsubscribe_text . "', " . "'" . $this->_lst_subject_tag . "', " . "'" . $this->_lst_html_skeleton . "', " . "'" . $this->_lst_text_skeleton . "', " . "'" . $this->_lst_nb_articles . "')";
 429  
 430          //echo $query;
 431          //echo"<br />$query<br><br />";
 432          $result = $db->query($query);
 433  
 434          if (DB::isError($result)) {
 435              echo (mysql_error());
 436              return PEAR::raiseError(
 437                         "[" . get_class($this). " DB_newsletter_cm_list : delete()] " . $result->getMessage(). "", null,
 438                         null, null,
 439                         null, null,
 440                         false);
 441          }
 442      }
 443  
 444      // }}}
 445  
 446      // {{{ create()
 447  
 448      //La fonction load() affecte un enregistrement de la table ".$GLOBALS['table_prefix']."_cm_list
 449  
 450  	function load ($lst_id) {
 451          $db = &$this->_getDB();
 452  
 453          if (DB::isError($db)) {
 454              return PEAR::raiseError("[" . get_class($this). " DB_nwsletter_cm_list : load()] " . $db->getMessage(). "",
 455                                      null,
 456                                      null,
 457                                      null,
 458                                      null,
 459                                      null,
 460                                      false);
 461          }
 462  
 463          $query
 464              = "SELECT " . NEWSLETTERS_ALL_LIST . " FROM " . $GLOBALS['table_prefix']. "_cm_lists WHERE lst_id = $lst_id";
 465  
 466          //echo $query;
 467  
 468          $result = $db->query($query);
 469  
 470          if (DB::isError($result)) {
 471              return PEAR::raiseError(
 472                         "[" . get_class($this). " DB_newsletter_cm_list : load()] " . $result->getMessage(). "", null,
 473                         null, null,
 474                         null, null,
 475                         false);
 476          }
 477          else {
 478              if ($row = $result->fetchRow()) {
 479                  $this->_lst_id = $row['lst_id'];
 480                  $this->_lst_name = $row['lst_name'];
 481                  $this->_lst_comment = $row['lst_comment'];
 482                  $this->_lst_moderation = $row['lst_moderation'];
 483                  $this->_lst_moderator_email = $row['lst_moderator_email'];
 484                  $this->_lst_subscribe_subject = $row['lst_subscribe_subject'];
 485                  $this->_lst_subscribe_text = $row['lst_subscribe_text'];
 486                  $this->_lst_subject = $row['lst_subject'];
 487                  $this->_lst_unsubscribe_subject = $row['lst_unsubscribe_subject'];
 488                  $this->_lst_unsubscribe_text = $row['lst_unsubscribe_text'];
 489                  $this->_lst_subject_tag = $row['lst_subject_tag'];
 490                  $this->_lst_html_skeleton = $row['lst_html_skeleton'];
 491                  $this->_lst_text_skeleton = $row['lst_text_skeleton'];
 492                  $this->_lst_nb_articles = $row['lst_nb_articles'];
 493              }
 494              else {
 495                  return PEAR::raiseError(
 496                             "[" . get_class(
 497                                       $this). " DB_nwsletter_cm_list : load($idArticle)] Aucunes listes ne correspond pas à cet ID!",
 498                             null,
 499                             null,
 500                             null,
 501                             null,
 502                             null,
 503                             false);
 504              }
 505              $result->free();
 506          }
 507      }
 508  
 509      // }}}
 510  
 511      // {{{ load()
 512  
 513      //La fonction delete() supprimer un enregistrement de la table ".$GLOBALS['table_prefix']."_cm_list
 514      //Par défaut, la fonction supprimer l'identifiant de l'objet appelant
 515      //Si une valeur est en entrée (lst_id), alors c'est cet identifiant qui sera supprimé
 516      //Chaque objet a donc la fonctionnalité de pouvoir supprimer n'importe quel objet de la base!!
 517  
 518  	function delete ($lst_id = '') {
 519          if ($lst_id == '')
 520              $lst_id = $this->getLstId();
 521  
 522          $db = &$this->_getDB();
 523  
 524          if (DB::isError($db)) {
 525              return PEAR::raiseError(
 526                         "[" . get_class($this). " DB_newsletter_cm_list : delete()] " . $db->getMessage(). "", null,
 527                         null, null,
 528                         null, null,
 529                         false);
 530          }
 531  
 532          $query = "DELETE FROM " . $GLOBALS['table_prefix']. "_cm_lists WHERE lst_id = $lst_id";
 533  
 534          $result = $db->query($query);
 535  
 536          if (DB::isError($result)) {
 537              return PEAR::raiseError(
 538                         "[" . get_class($this). " DB_newsletter_cm_list : delete()] " . $result->getMessage(). "", null,
 539                         null, null,
 540                         null, null,
 541                         false);
 542          }
 543      }
 544  
 545      // }}}
 546  
 547      // {{{ delete()
 548  
 549      //Fonction factory pour l'instanciation de l'objet
 550  
 551      function &factory ($dbParameters, $dbOptions = null) {
 552          if (file_exists(dirname(
 553                              __FILE__). "/" . $dbParameters->_dbEngine . "/newsletter_cm_list_" . $dbParameters->_dbEngine . ".php") == false)
 554              {
 555              include_once (dirname(__FILE__). "/common/newsletter_cm_list_common.php");
 556              $classname = "BD_newsletter_cm_list";
 557          }
 558          else {
 559              include_once (dirname(
 560                                __FILE__). "/" . $dbParameters->_dbEngine . "/newsletter_cm_list_" . $dbParameters->_dbEngine . ".php");
 561              $classname = "BD_newsletter_cm_list_" . $dbParameters->_dbEngine;
 562          }
 563  
 564          if (!class_exists($classname)) {
 565              return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false);
 566          }
 567  
 568          $obj = &new $classname;
 569          $result = $obj->setDbParameters($dbParameters);
 570  
 571          if ($dbOptions != null) {
 572              $obj->setDbOptions($dbOptions);
 573          }
 574  
 575          if (PEAR::isError($result)) {
 576              return $result;
 577          }
 578          else {
 579              return $obj;
 580          }
 581      }
 582  }
 583  // }}}
 584  
 585  // {{{ factory()
 586  
 587  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7