[ 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/ -> auteur.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 Auteur business persistence abstraction.
  20  //
  21  
  22  if (defined("_BD_AUTEUR"))
  23      return;
  24  
  25  define("_BD_AUTEUR", "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_filtres.php";
  31  require_once dirname(__FILE__). "/../../inc_meta.php";
  32  require_once dirname(__FILE__). "/../authorization/inc_authorization_factory.php";
  33  
  34  /** Pattern d'url menant à la page d'édition de l'auteur */
  35  define('SA_URL_AUTEUR', '/ecrire/auteurs_edit.php?id_auteur=%s');
  36  
  37  /** Noms de tous les champs de la table dans la base de données */
  38  define("AUTEUR_ALL_FIELDS",
  39         " id_auteur, nom, bio, email, nom_site, url_site, login, pass, statut, profil, maj, pgp, htpass, " . "en_ligne , imessage, messagerie, alea_actuel, alea_futur,prefs, cookie_oubli, source, extra, lang, low_sec ");
  40  
  41  /**
  42   * BD_auteur is a base class for auteur business persistence abstraction implementations, and must be
  43   * inherited by all such.
  44   * @package    BD
  45   * @author  Antoine Angénieux <aangenieux@clever-age.com>
  46   * @author     Erwan Le Bescond <elebescond@clever-age.com>
  47   * @access    public
  48   */
  49  class BD_auteur extends BD_metier {
  50      // {{{ properties
  51  
  52      /**
  53      * Auteur ID.
  54      * @var     int
  55      * @access  private
  56      */
  57      var $_auteurId;
  58  
  59      /**
  60      * Name.
  61      * @var     String
  62      * @access  private
  63      */
  64      var $_nom;
  65  
  66      /**
  67      * Description of the user.
  68      * @var     String
  69      * @access  private
  70      */
  71      var $_bio;
  72  
  73      /**
  74      * Email.
  75      * @var     String
  76      * @access  private
  77      */
  78      var $_email;
  79  
  80      /**
  81      * Site name.
  82      * @var     String
  83      * @access  private
  84      */
  85      var $_nomSite;
  86  
  87      /**
  88      * Site url.
  89      * @var     String
  90      * @access  private
  91      */
  92      var $_urlSite;
  93  
  94      /**
  95      * login.
  96      * @var     String
  97      * @access  private
  98      */
  99      var $_login;
 100  
 101      /**
 102      * password.
 103      * @var     String
 104      * @access  private
 105      */
 106      var $_pass;
 107  
 108      /**
 109      * Statute.
 110      * @var     String
 111      * @access  private
 112      */
 113      var $_statut;
 114  
 115      /**
 116      * Profil.
 117      * @var     int
 118      * @access  private
 119      */
 120      var $_profil;
 121  
 122      /**
 123      * last update.
 124      * @var     Date
 125      * @access  private
 126      */
 127      var $_maj;
 128  
 129      /**
 130      * signature.
 131      * @var     String
 132      * @access  private
 133      */
 134      var $_pgp;
 135  
 136      /**
 137      * htpass.
 138      * @var     String
 139      * @access  private
 140      */
 141      var $_htpass;
 142  
 143      /**
 144      * online.
 145      * @var     Date
 146      * @access  private
 147      */
 148      var $_enLigne;
 149  
 150      /**
 151      * internal message
 152      * @var     String
 153      * @access  private
 154      */
 155      var $_imessage;
 156  
 157      /**
 158      * message
 159      * @var     String
 160      * @access  private
 161      */
 162      var $_messagerie;
 163  
 164      /**
 165      * useful variable.
 166      * @var     String
 167      * @access  private
 168      */
 169      var $_aleaActuel;
 170  
 171      /**
 172      * useful variable.
 173      * @var     String
 174      * @access  private
 175      */
 176      var $_aleaFutur;
 177  
 178      /**
 179      * preferences.
 180      * @var     String
 181      * @access  private
 182      */
 183      var $_prefs;
 184  
 185      /**
 186      * useful variable.
 187      * @var     String
 188      * @access  private
 189      */
 190      var $_cookieOubli;
 191  
 192      /**
 193      * source.
 194      * @var     String
 195      * @access  private
 196      */
 197      var $_source;
 198  
 199      /**
 200      * extra.
 201      * @var     String
 202      * @access  private
 203      */
 204      var $_extra;
 205  
 206      /**
 207      * lang.
 208      * @var     String
 209      * @access  private
 210      */
 211      var $_lang;
 212  
 213      /**
 214      * lowSec.
 215      * @var     String
 216      * @access  private
 217      */
 218      var $_lowSec;
 219  
 220      /** 
 221  * isLoaded
 222  * nous dit si l'objet est chargé ou pas 
 223  * @access private
 224  */
 225      var $_isLoaded = false;
 226  
 227      // }}}
 228  
 229      // {{{ factory()
 230      function &factory ($dbParameters = null, $dbOptions = null) {
 231          if (file_exists(
 232                  dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/auteur_" . $dbParameters->_dbEngine . ".php")
 233              == false) {
 234              include_once(dirname(__FILE__). "/common/auteur_common.php");
 235              $classname = "BD_auteur_common";
 236          }
 237          else {
 238              include_once(
 239                  dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/auteur_" . $dbParameters->_dbEngine . ".php");
 240              $classname = "BD_auteur_" . $dbParameters->_dbEngine;
 241          }
 242  
 243          if (!class_exists($classname)) {
 244              return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false);
 245          }
 246  
 247          $obj = &new $classname;
 248          $result = $obj->setDbParameters($dbParameters);
 249  
 250          if ($dbOptions != null) {
 251              $obj->setDbOptions($dbOptions);
 252          }
 253  
 254          if (PEAR::isError($result)) {
 255              return $result;
 256          }
 257          else {
 258              return $obj;
 259          }
 260      }
 261  
 262      // }}}
 263  
 264      // {{{ constructor
 265  
 266      /**
 267       * DB_auteur constructor.
 268       *
 269       * @access public
 270       */
 271  
 272  	function BD_auteur () { }
 273  
 274      // }}}
 275  
 276      // {{{ getAuteurId()
 277  
 278      /**
 279       * Returns the Author's ID
 280       * @return  int
 281       * @access  public
 282       */
 283  
 284  	function getAuteurId () {
 285          return $this->_auteurId;
 286      }
 287  
 288      // }}}
 289  
 290      // {{{ setAuteurId()
 291  
 292      /**
 293       * Sets the Author's ID
 294       * @param   int
 295       * @access  public
 296       */
 297  
 298  	function setAuteurId ($auteurId) {
 299          $this->_auteurId = $auteurId;
 300      }
 301  
 302      // }}}
 303  
 304      // {{{ getNom()
 305  
 306      /**
 307       * Returns the Author's Name
 308       * @return  String
 309       * @access  public
 310       */
 311  
 312  	function getNom () {
 313          return empty($this->_nom) ? $this->getLogin() : $this->_nom;
 314      }
 315  
 316      // }}}
 317  
 318      // {{{ setNom()
 319  
 320      /**
 321       * Sets the Author's Name
 322       * @param  String
 323       * @access  public
 324       */
 325  
 326  	function setNom ($nom) {
 327          $this->_nom = $nom;
 328      }
 329  
 330      // }}}
 331  
 332      // {{{ getBio()
 333  
 334      /**
 335       * Returns the Author's Biography
 336       * @return  String
 337       * @access  public
 338       */
 339  
 340  	function getBio () {
 341          return $this->_bio;
 342      }
 343  
 344      // }}}
 345  
 346      // {{{ setBio()
 347  
 348      /**
 349       * Sets the Author's Biography
 350       * @param  String
 351       * @access  public
 352       */
 353  	function setBio ($bio) {
 354          $this->_bio = $bio;
 355      }
 356  
 357      // }}}
 358  
 359      // {{{ getEmail()
 360  
 361      /**
 362       * Returns the Author Email
 363       * @return  String
 364       * @access  public
 365       */
 366  
 367  	function getEmail () {
 368          return $this->_email;
 369      }
 370  
 371      // }}}
 372  
 373      // {{{ setEmail()
 374  
 375      /**
 376       * Sets the Author Email
 377       * @param  String
 378       * @access  public
 379       */
 380  
 381  	function setEmail ($email) {
 382          $this->_email = $email;
 383      }
 384  
 385      // }}}
 386  
 387      // {{{ getNomSite()
 388  
 389      /**
 390       * Returns the Author's Site Name
 391       * @return  String
 392       * @access  public
 393       */
 394  
 395  	function getNomSite () {
 396          return $this->_nomSite;
 397      }
 398  
 399      // }}}
 400  
 401      // {{{ setNomSite()
 402  
 403      /**
 404       * Sets the Author's Site Name
 405       * @param  String
 406       * @access  public
 407       */
 408  
 409  	function setNomSite ($nomSite) {
 410          $this->_nomSite = $nomSite;
 411      }
 412  
 413      // }}}
 414  
 415      // {{{ getUrlSite()
 416  
 417      /**
 418       * Returns the Author's Site URL
 419       * @return  String
 420       * @access  public
 421       */
 422  
 423  	function getUrlSite () {
 424          return $this->_urlSite;
 425      }
 426  
 427      // }}}
 428  
 429      // {{{ setUrlSite()
 430  
 431      /**
 432       * Sets the Author's Site URL
 433       * @param  String
 434       * @access  public
 435       */
 436  
 437  	function setUrlSite ($urlSite) {
 438          $this->_urlSite = $urlSite;
 439      }
 440  
 441      // }}}
 442  
 443      // {{{ getLogin()
 444  
 445      /**
 446       * Returns the Author's Login
 447       * @return  String
 448       * @access  public
 449       */
 450  
 451  	function getLogin () {
 452          return $this->_login;
 453      }
 454  
 455      // }}}
 456  
 457      // {{{ setLogin()
 458  
 459      /**
 460       * Sets the Author's Login
 461       * @param  String
 462       * @access  public
 463       */
 464  
 465  	function setLogin ($login) {
 466          $this->_login = $login;
 467      }
 468  
 469      // }}}
 470  
 471      // {{{ getPass()
 472  
 473      /**
 474       * Returns the Author's Password
 475       * @return  String
 476       * @access  public
 477       */
 478  
 479  	function getPass () {
 480          return $this->_pass;
 481      }
 482  
 483      // }}}
 484  
 485      // {{{ setPass()
 486  
 487      /**
 488       * Sets the Author's Password
 489       * @param  String
 490       * @access  public
 491       */
 492  
 493  	function setPass ($pass) {
 494          $this->_pass = $pass;
 495      }
 496  
 497      // }}}
 498  
 499      // {{{ getStatut()
 500  
 501      /**
 502       * Returns the Author's Statute
 503       * @return  String
 504       * @access  public
 505       */
 506  
 507  	function getStatut () {
 508          return $this->_statut;
 509      }
 510  
 511      // }}}
 512  
 513      // {{{ setStatut()
 514  
 515      /**
 516       * Sets the Author's Statute
 517       * @param  String
 518       * @access  public
 519       */
 520  
 521  	function setStatut ($statut) {
 522          $this->_statut = $statut;
 523      }
 524  
 525      // }}}
 526  
 527      // {{{ getProfil()
 528  
 529      /**
 530       * Returns the Author's Profile
 531       * @return  int
 532       * @access  public
 533       */
 534  
 535  	function getProfil () {
 536          return $this->_profil;
 537      }
 538  
 539      // }}}
 540  
 541      // {{{ setProfil()
 542  
 543      /**
 544       * Sets the Author's Profil
 545       * @param  int
 546       * @access  public
 547       */
 548  
 549  	function setProfil ($profil) {
 550          $this->_profil = $profil;
 551      }
 552  
 553      // }}}
 554  
 555      // {{{ getMaj()
 556  
 557      /**
 558       * Returns the last update
 559       * @return  Date
 560       * @access  public
 561       */
 562  
 563  	function getMaj () {
 564          return $this->_maj;
 565      }
 566  
 567      // }}}
 568  
 569      // {{{ setMaj()
 570  
 571      /**
 572       * Sets the last update
 573       * @param  Date
 574       * @access  public
 575       */
 576  
 577  	function setMaj ($maj) {
 578          $this->_maj = $maj;
 579      }
 580  
 581      // }}}
 582  
 583      // {{{ getPgp()
 584  
 585      /**
 586       * Returns the Author's Pgp
 587       * @return  String
 588       * @access  public
 589       */
 590  
 591  	function getPgp () {
 592          return $this->_pgp;
 593      }
 594  
 595      // }}}
 596  
 597      // {{{ setPgp()
 598  
 599      /**
 600       * Sets the Author's Pgp
 601       * @param  String
 602       * @access  public
 603       */
 604  
 605  	function setPgp ($pgp) {
 606          $this->_pgp = $pgp;
 607      }
 608  
 609      // }}}
 610  
 611      // {{{ getHtpass()
 612  
 613      /**
 614       * Returns the Author's HtPassword
 615       * @return  String
 616       * @access  public
 617       */
 618  
 619  	function getHtpass () {
 620          return $this->_htpass;
 621      }
 622  
 623      // }}}
 624  
 625      // {{{ setHtpass()
 626  
 627      /**
 628       * Sets the Author's HtPassword
 629       * @param  String
 630       * @access  public
 631       */
 632  
 633  	function setHtpass ($htpass) {
 634          $this->_htpass = $htpass;
 635      }
 636  
 637      // }}}
 638  
 639      // {{{ getEnLigne()
 640  
 641      /**
 642       * Returns the date since the moment author is on line
 643       * @return  String
 644       * @access  public
 645       */
 646  
 647  	function getEnLigne () {
 648          return $this->_enLigne;
 649      }
 650  
 651      // }}}
 652  
 653      // {{{ setEnLigne()
 654  
 655      /**
 656       * Sets the date since the moment author is on line
 657       * @param  String
 658       * @access  public
 659       */
 660  	function setEnLigne ($enLigne) {
 661          $this->_enLigne = $enLigne;
 662      }
 663  
 664      // }}}
 665  
 666      // {{{ getImessage()
 667  
 668      /**
 669       * Returns if the Author uses Imessage
 670       * @return  String
 671       * @access  public
 672       */
 673  
 674  	function getImessage () {
 675          return $this->_imessage;
 676      }
 677  
 678      // }}}
 679  
 680      // {{{ setImessage()
 681  
 682      /**
 683       * Sets if the Author uses Imessage
 684       * @param  String
 685       * @access  public
 686       */
 687  
 688  	function setImessage ($imessage) {
 689          $this->_imessage = $imessage;
 690      }
 691  
 692      // }}}
 693  
 694      // {{{ getMessagerie()
 695  
 696      /**
 697       * Returns the Author uses Message
 698       * @return  String
 699       * @access  public
 700       */
 701  
 702  	function getMessagerie () {
 703          return $this->_messagerie;
 704      }
 705  
 706      // }}}
 707  
 708      // {{{ setMessagerie()
 709  
 710      /**
 711       * Sets the Author uses Message
 712       * @param  String
 713       * @access  public
 714       */
 715  
 716  	function setMessagerie ($messagerie) {
 717          $this->_messagerie = $messagerie;
 718      }
 719  
 720      // }}}
 721  
 722      // {{{ getAleaActuel()
 723  
 724      /**
 725       * Returns the Current alea
 726       * @return  String
 727       * @access  public
 728       */
 729  
 730  	function getAleaActuel () {
 731          return $this->_aleaActuel;
 732      }
 733  
 734      // }}}
 735  
 736      // {{{ setAleaActuel()
 737  
 738      /**
 739       * Sets the Current alea
 740       * @param  String
 741       * @access  public
 742       */
 743  
 744  	function setAleaActuel ($aleaActuel) {
 745          $this->_aleaActuel = $aleaActuel;
 746      }
 747  
 748      // }}}
 749  
 750      // {{{ getAleaFutur()
 751  
 752      /**
 753       * Returns the Future alea
 754       * @return  String
 755       * @access  public
 756       */
 757  
 758  	function getAleaFutur () {
 759          return $this->_aleaFutur;
 760      }
 761  
 762      // }}}
 763  
 764      // {{{ setAleaFutur()
 765  
 766      /**
 767       * Sets the Future alea
 768       * @param  String
 769       * @access  public
 770       */
 771  
 772  	function setAleaFutur ($aleaFutur) {
 773          $this->_aleaFutur = $aleaFutur;
 774      }
 775  
 776      // }}}
 777  
 778      // {{{ getPrefs()
 779  
 780      /**
 781       * Returns the Author's preferences
 782       * @return  String
 783       * @access  public
 784       */
 785  
 786  	function getPrefs () {
 787          return $this->_prefs;
 788      }
 789  
 790      // }}}
 791  
 792      // {{{ setPrefs()
 793  
 794      /**
 795       * Sets the Author's preferences
 796       * @param  String
 797       * @access  public
 798       */
 799  
 800  	function setPrefs ($prefs) {
 801          $this->_prefs = $prefs;
 802      }
 803  
 804      // }}}
 805  
 806      // {{{ getCookieOubli()
 807  
 808      /**
 809       * Returns the cookie forgotten
 810       * @return  String
 811       * @access  public
 812       */
 813  
 814  	function getCookieOubli () {
 815          return $this->_cookieOubli;
 816      }
 817  
 818      // }}}
 819  
 820      // {{{ setCookieOubli()
 821  
 822      /**
 823       * Sets the cookie forgotten
 824       * @param  String
 825       * @access  public
 826       */
 827  
 828  	function setCookieOubli ($cookieOubli) {
 829          $this->_cookieOubli = $cookieOubli;
 830      }
 831  
 832      // }}}
 833  
 834      // {{{ getSource()
 835  
 836      /**
 837       * Returns the Source
 838       * @return  String
 839       * @access  public
 840       */
 841  
 842  	function getSource () {
 843          return $this->_source;
 844      }
 845  
 846      // }}}
 847  
 848      // {{{ setSource()
 849  
 850      /**
 851       * Sets the Source
 852       * @param  String
 853       * @access  public
 854       */
 855  
 856  	function setSource ($source) {
 857          $this->_source = $source;
 858      }
 859  
 860      /**
 861       * Returns the Extra
 862       * @return  String
 863       * @access  public
 864       */
 865  
 866  	function getExtra () {
 867          return $this->_extra;
 868      }
 869  
 870      // }}}
 871  
 872      // {{{ setExtra()
 873  
 874      /**
 875       * Sets the Extra
 876       * @param  String
 877       * @access  public
 878       */
 879  
 880  	function setExtra ($extra) {
 881          $this->_extra = $extra;
 882      }
 883  
 884      // }}}
 885  
 886      /**
 887       * Returns the lang
 888       * @return  String
 889       * @access  public
 890       */
 891  
 892  	function getLang () {
 893          return $this->_lang;
 894      }
 895  
 896      // }}}
 897  
 898      // {{{ setLang()
 899  
 900      /**
 901       * Sets the Lang
 902       * @param  String
 903       * @access  public
 904       */
 905  
 906  	function setLang ($lang) {
 907          $this->_lang = $lang;
 908      }
 909  
 910      // }}}
 911  
 912      /**
 913       * Returns the low sec
 914       * @return  String
 915       * @access  public
 916       */
 917  
 918  	function getLowSec () {
 919          return $this->_lowSec;
 920      }
 921  
 922      // }}}
 923  
 924      // {{{ setLowSec()
 925  
 926      /**
 927       * Sets the Low sec
 928       * @param  String
 929       * @access  public
 930       */
 931  
 932  	function setLowSec ($lowSec) {
 933          $this->_lowSec = $lowSec;
 934      }
 935  
 936      // }}}
 937  
 938      // }}}
 939  
 940  	function getIsLoaded () {
 941          return $this->_isLoaded;
 942      }
 943  
 944      // }}}
 945  
 946      // {{{
 947  
 948  	function setIsLoaded ($isLoaded) {
 949          $this->_isLoaded = $isLoaded;
 950      }
 951  
 952      // }}}
 953  
 954      /** Renvoie l'url vers la page de l'auteur */
 955  	function getUrl () {
 956          return sprintf(lire_meta('adresse_site'). SA_URL_AUTEUR, $this->getAuteurId());
 957      }
 958  
 959      // {{{ create()
 960  
 961      /**
 962       * This method is used to create a new author in the database
 963       * @access public
 964       */
 965  
 966  	function create () {
 967          $db = &$this->_getDB();
 968  
 969          if (DB::isError($db)) {
 970              return PEAR::raiseError("[" . get_class($this). " DB_auteur : create()] " . $db->getMessage(). "", null,
 971                                      null, null,
 972                                      null, null,
 973                                      false);
 974          }
 975  
 976          $string_prefix = $GLOBALS['table_prefix']. "_auteurs";
 977          $auteurId = $db->nextId($string_prefix, true);
 978  
 979          if (DB::isError($auteurId)) {
 980              return PEAR::raiseError("[" . get_class($this). " DB_auteur : create()] " . $auteurId->getMessage(). "",
 981                                      null,
 982                                      null,
 983                                      null,
 984                                      null,
 985                                      null,
 986                                      false);
 987          }
 988  
 989          $this->setEnLigne('0000-00-00 00:00:00');
 990          $this->_auteurId = $auteurId;
 991  
 992          if ($this->_profil == null)
 993              $this->_profil = 0;
 994  
 995          if ($this->_urlSite == null)
 996              $this->_urlSite = '';
 997  
 998          if ($this->_nomSite == null)
 999              $this->_nomSite = '';
1000  
1001          if ($this->_bio == null)
1002              $this->_bio = '';
1003  
1004          if ($this->_statut == null)
1005              $this->_statut = '';
1006  
1007          if ($this->_pgp == null)
1008              $this->_pgp = '';
1009  
1010          $this->_aleaActuel = '';
1011          $this->_aleaFutur = '';
1012  
1013          $query
1014              = "INSERT INTO " . $GLOBALS['table_prefix']. "_auteurs (" . AUTEUR_ALL_FIELDS . ") VALUES " . "(" . $this->_auteurId . ", " . "'" . $db->quoteString(
1015                                                                                                                                                      $this->_nom). "', " . "'" . $db->quoteString(
1016                                                                                                                                                                                      $this->_bio). "', " . "'" . $db->quoteString(
1017                                                                                                                                                                                                                      $this->_email). "', " . "'" . $db->quoteString(
1018                                                                                                                                                                                                                                                        $this->_nomSite). "', " . "'" . $db->quoteString(
1019                                                                                                                                                                                                                                                                                            $this->_urlSite). "', " . "'" . $db->quoteString(
1020                                                                                                                                                                                                                                                                                                                                $this->_login). "', " . "'" . $db->quoteString(
1021                                                                                                                                                                                                                                                                                                                                                                  $this->_pass). "', " . "'" . $db->quoteString(
1022                                                                                                                                                                                                                                                                                                                                                                                                   $this->_statut). "', " . $this->_profil . ", " . "'" . $db->quoteString(
1023                                                                                                                                                                                                                                                                                                                                                                                                                                                              $this->_maj). "', " . "'" . $db->quoteString(
1024                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              $this->_pgp). "', " . "'" . $db->quoteString(
1025                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              $this->_htpass). "', " . "'" . $db->quoteString(
1026                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 $this->_enLigne). "', " . "'" . $db->quoteString(
1027                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     $this->_imessage). "', " . "'" . $db->quoteString(
1028                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          $this->_messagerie). "', " . "'" . $db->quoteString(
1029                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 $this->_aleaActuel). "', " . "'" . $db->quoteString(
1030                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        $this->_aleaFutur). "', " . "'" . $db->quoteString(
1031                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              $this->_prefs). "', " . "'" . $db->quoteString(
1032                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                $this->_cookieOubli). "', " . "'" . $db->quoteString(
1033                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        $this->_source). "', " . "'" . $db->quoteString(
1034                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           $this->_extra). "', " . "'" . $db->quoteString(
1035                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             $this->_lang). "', " . "'" . $db->quoteString(
1036                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              $this->_lowSec). "' )";
1037  
1038          //echo "$query<br>";
1039  
1040          $result = $db->query($query);
1041  
1042          if (DB::isError($result)) {
1043              return PEAR::raiseError("[" . get_class($this). " DB_auteur : create()] " . $result->getMessage(). "", null,
1044                                      null, null,
1045                                      null, null,
1046                                      false);
1047          }
1048  
1049          $this->_isLoaded = true;
1050      }
1051  
1052      // }}}
1053  
1054      // {{{ delete()
1055  
1056      /**
1057       * This method is used to delete an author from the database
1058       * @access  public
1059       * @param   int $idAuteur id of author to delete
1060       */
1061  
1062  	function delete ($auteurId) {
1063          $db = &$this->_getDB();
1064  
1065          if (DB::isError($db)) {
1066              return PEAR::raiseError("[" . get_class($this). " DB_auteur : delete()] " . $db->getMessage(). "", null,
1067                                      null, null,
1068                                      null, null,
1069                                      false);
1070          }
1071  
1072          $query = "DELETE FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE id_auteur = $auteurId";
1073  
1074          $result = $db->query($query);
1075  
1076          if (DB::isError($result)) {
1077              return PEAR::raiseError("[" . get_class($this). " DB_auteur : delete()] " . $result->getMessage(). "", null,
1078                                      null, null,
1079                                      null, null,
1080                                      false);
1081          }
1082      }
1083  
1084      // }}}
1085  
1086      // {{{ update()
1087  
1088      /**
1089       * This method is used to update this author in the database
1090       * @access public
1091       */
1092  
1093  	function update () {
1094          $db = &$this->_getDB();
1095  
1096          if (DB::isError($db)) {
1097              return PEAR::raiseError("[" . get_class($this). " DB_auteur : update()] " . $db->getMessage(). "", null,
1098                                      null, null,
1099                                      null, null,
1100                                      false);
1101          }
1102  
1103          $maDate = new Date();
1104          $this->setMaj($maDate->getDate(DATE_FORMAT_ISO));
1105  
1106          if ($this->getEnLigne() == null) {
1107              $this->setEnLigne('0000-00-00 00:00:00');
1108          }
1109          if($this->_prefs == null) $this->_prefs = 'a:3:{s:7:"couleur";d:2;s:7:"display";d:2;s:7:"options";s:8:"avancees";}';
1110          
1111          $query = "UPDATE " . $GLOBALS['table_prefix']. "_auteurs " 
1112                  ."SET nom = '".$db->quoteString($this->_nom) 
1113                  ."', bio = '" . $db->quoteString($this->_bio)
1114                  ."', email = '" . $db->quoteString($this->_email)
1115                  ."', nom_site = '" . $db->quoteString($this->_nomSite)
1116                  ."', url_site = '" . $db->quoteString($this->_urlSite)
1117                  ."', login = '" . $db->quoteString($this->_login)
1118                  ."', pass = '" . $db->quoteString($this->_pass)
1119                  ."', statut = '" . $db->quoteString($this->_statut)
1120                  ."', profil= " . $this->_profil
1121                  .", maj = '" . $db->quoteString($this->_maj)
1122                  ."', pgp = '" . $db->quoteString($this->_pgp)
1123                  ."', htpass = '" . $db->quoteString($this->_htpass)
1124                  ."', en_ligne = '" . $db->quoteString($this->_enLigne)
1125                  ."', imessage = '" . $db->quoteString($this->_imessage)
1126                  ."', messagerie = '" . $db->quoteString($this->_messagerie)
1127                  ."', alea_actuel = '" . $db->quoteString($this->_aleaActuel)
1128                  ."', alea_futur = '" . $db->quoteString($this->_aleaFutur)
1129                  ."', prefs = '" . $db->quoteString($this->_prefs)
1130                  ."', cookie_oubli = '" . $db->quoteString($this->_cookieOubli)
1131                  ."', source = '" . $db->quoteString($this->_source)
1132                  ."', extra = '" . $db->quoteString($this->_extra)
1133                  ."', lang = '" . $db->quoteString($this->_lang)
1134                  ."', low_sec = '" . $db->quoteString($this->_low_sec)
1135                  ."' WHERE id_auteur = " . $this->_auteurId;
1136  
1137          //echo "<br>".$query."<br>";
1138  
1139          $result = $db->query($query);
1140  
1141          if (DB::isError($result)) {
1142              return PEAR::raiseError("[" . get_class($this). " DB_auteur : update()] " 
1143                                      . $result->getMessage(). "", null, null, null,
1144                                      null, null, false);
1145          }
1146      }
1147  
1148      // }}}
1149  
1150      // {{{ load()
1151  
1152      /**
1153       * This method is used to load an author from the database
1154       * @access  public
1155       * @param   int $idAuteur id of author to load
1156       */
1157  
1158  	function load ($auteurId) {
1159          if (($this->_isLoaded) and ($this->_auteurId == $auteurId))
1160              return; // l'article est chargé 
1161  
1162          $db = &$this->_getDB();
1163  
1164          if (DB::isError($db)) {
1165              return PEAR::raiseError("[" . get_class($this). " DB_auteur : load()1] " . $db->getMessage(). "", null,
1166                                      null, null,
1167                                      null, null,
1168                                      false);
1169          }
1170  
1171          $query
1172              = "SELECT" . AUTEUR_ALL_FIELDS . "FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE id_auteur = $auteurId";
1173  
1174          //echo '<br />' . $query . '<br />';
1175  
1176          $result = $db->query($query);
1177  
1178          if (DB::isError($result)) {
1179              return PEAR::raiseError("[" . get_class($this). " DB_auteur : load()] " . $result->getMessage(). "", null,
1180                                      null, null,
1181                                      null, null,
1182                                      false);
1183          }
1184          else {
1185              if ($row = $result->fetchRow()) {
1186                  $maDate = new Date($row['maj']);
1187                  $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1188  
1189                  $this->_fetchData($row);
1190                  return 1;
1191              }
1192              else {
1193                  return PEAR::raiseError(
1194                             "[" . get_class(
1195                                       $this). " DB_auteur : load(" . $auteurId . ")] Aucun auteur ne correspond à cet ID!",
1196                             null,
1197                             null,
1198                             null,
1199                             null,
1200                             null,
1201                             false);
1202              }
1203              $result->free();
1204          }
1205  
1206          $this->_isLoaded = true;
1207      }
1208  
1209      // }}}
1210  
1211      // {{{ _fetchData()
1212  
1213      /**
1214       * This method is used to fetch result set fields into the object fields
1215       *
1216       * @param   $row    resultset row
1217       * @access  private
1218       */
1219  	function _fetchData ($row) {
1220          $this->setAuteurId($row['id_auteur']);
1221          $this->setNom($row['nom']);
1222          $this->setBio($row['bio']);
1223          $this->setEmail($row['email']);
1224          $this->setNomSite($row['nom_site']);
1225          $this->setUrlSite($row['url_site']);
1226          $this->setLogin($row['login']);
1227          $this->setPass($row['pass']);
1228          $this->setStatut($row['statut']);
1229          $this->setProfil($row['profil']);
1230          $this->setMaj($row['maj']);
1231          $this->setPgp($row['pgp']);
1232          $this->setHtpass($row['htpass']);
1233          $this->setEnLigne($row['en_ligne']);
1234          $this->setImessage($row['imessage']);
1235          $this->setMessagerie($row['messagerie']);
1236          $this->setAleaActuel($row['alea_actuel']);
1237          $this->setAleaFutur($row['alea_futur']);
1238          $this->setPrefs($row['prefs']);
1239          $this->setCookieOubli($row['cookie_oubli']);
1240          $this->setSource($row['source']);
1241          $this->setExtra($row['extra']);
1242          $this->setLang($row['lang']);
1243          $this->setLowSec($row['low_sec']);
1244      }
1245  
1246      // }}}
1247  
1248      // {{{ deleteMajDate($majDate)
1249  
1250      /**
1251       * This method is used to delete all authors former to mydate
1252       * @access  public
1253       */
1254  
1255  	function deleteMajDate ($mydate) {
1256          $db = &$this->_getDB();
1257  
1258          if (DB::isError($db)) {
1259              return PEAR::raiseError("[" . get_class($this). " DB_auteur : deleteMajDate()] " . $db->getMessage(). "",
1260                                      null,
1261                                      null,
1262                                      null,
1263                                      null,
1264                                      null,
1265                                      false);
1266          }
1267  
1268          $dateTmp = new Date($mydate);
1269          $mydate = $dateTmp->getDate(DATE_FORMAT_ISO);
1270  
1271          $query = "DELETE FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE maj < '$mydate'";
1272  
1273          $result = $db->query($query);
1274  
1275          if (DB::isError($result)) {
1276              return PEAR::raiseError(
1277                         "[" . get_class($this). " DB_auteur : deleteMajDate()] " . $result->getMessage(). "", null, null,
1278                         null, null, null,
1279                         false);
1280          }
1281      }
1282  
1283      // }}}
1284  
1285      // {{{ deleteAllAuteurIdsExceptAuteurIds($auteurs)
1286  
1287  	function deleteAllAuteurIdsExceptAuteurIds ($auteurs) {
1288          $db = &$this->_getDB();
1289  
1290          if (DB::isError($db)) {
1291              return PEAR::raiseError(
1292                         "[" . get_class(
1293                                   $this). " DB_auteur : deleteAllAuteurIdsExceptAuteurIds()] " . $db->getMessage(). "",
1294                         null,
1295                         null,
1296                         null,
1297                         null,
1298                         null,
1299                         false);
1300          }
1301  
1302          $query = "DELETE FROM " . $GLOBALS['table_prefix']. "_auteurs_articles WHERE id_auteur NOT IN ($auteurs)";
1303  
1304          $result = $db->query($query);
1305  
1306          if (DB::isError($result)) {
1307              return PEAR::raiseError(
1308                         "[" . get_class(
1309                                   $this). " DB_auteur : deleteAllAuteurIdsExceptAuteurIds()] " . $result->getMessage(). "",
1310                         null,
1311                         null,
1312                         null,
1313                         null,
1314                         null,
1315                         false);
1316          }
1317      }
1318  
1319      // }}}
1320  
1321      // {{{ getAllAuteurId()
1322  
1323  	function getAllAuteurId () {
1324          $db = &$this->_getDB();
1325  
1326          if (DB::isError($db)) {
1327              return PEAR::raiseError("[" . get_class($this). " DB_auteur : getAllAuteurId()] " . $db->getMessage(). "",
1328                                      null,
1329                                      null,
1330                                      null,
1331                                      null,
1332                                      null,
1333                                      false);
1334          }
1335  
1336          $query = "SELECT id_auteur FROM " . $GLOBALS['table_prefix']. "_auteurs";
1337  
1338          $result = $db->query($query);
1339  
1340          if (DB::isError($result)) {
1341              return PEAR::raiseError(
1342                         "[" . get_class($this). " DB_auteur : getAllAuteurId()] " . $result->getMessage(). "", null,
1343                         null, null,
1344                         null, null,
1345                         false);
1346          }
1347  
1348          while ($row = $result->fetchRow()) {
1349              $auteurs[] = $row['id_auteur'];
1350          }
1351  
1352          $result->free();
1353          return $auteurs;
1354      }
1355  
1356      // }}}
1357  
1358      // {{{ getAllAuteurIdForProfils($profil)
1359  
1360  	function getAllAuteurIdForProfils ($profils) {
1361          $auteurs = array();
1362          $db = &$this->_getDB();
1363  
1364          if (DB::isError($db)) {
1365              return PEAR::raiseError(
1366                         "[" . get_class($this). " DB_auteur : getAllAuteurIdForProfils()] " . $db->getMessage(). "",
1367                         null,
1368                         null,
1369                         null,
1370                         null,
1371                         null,
1372                         false);
1373          }
1374  
1375          $query = "SELECT id_auteur FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1376                  "WHERE profil IN (" . join(",", $profils). ")";
1377  
1378          $result = $db->query($query);
1379  
1380          if (DB::isError($result)) {
1381              return PEAR::raiseError(
1382                         "[" . get_class($this). " DB_auteur : getAllAuteurIdForProfils ()] " . $result->getMessage(). "",
1383                         null,
1384                         null,
1385                         null,
1386                         null,
1387                         null,
1388                         false);
1389          }
1390  
1391          while ($row = $result->fetchRow()) {
1392              $auteurs[] = $row['id_auteur'];
1393          }
1394  
1395          $result->free();
1396          return $auteurs;
1397      }
1398  
1399      // }}}
1400  
1401      // {{{ getHtpassWithLoginExceptStatuts($statut1, $statut2)
1402  
1403      /**
1404       * Returns an array of htpass.
1405       *
1406       *
1407       * @return an array of htpass
1408       * @param $statut1
1409       * @param $statut2
1410       * @access public
1411       */
1412  
1413  	function getHtpassWithLoginExceptStatuts ($statut1, $statut2) {
1414          $logins = array();
1415          $db = &$this->_getDB();
1416  
1417          if (DB::isError($db)) {
1418              return PEAR::raiseError(
1419                         "[" . get_class(
1420                                   $this). " DB_auteur : getHtpassWithLoginExceptStatuts()] " . $db->getMessage(). "",
1421                         null,
1422                         null,
1423                         null,
1424                         null,
1425                         null,
1426                         false);
1427          }
1428  
1429          $query
1430              = "SELECT login, htpass FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE statut != '$statut1' AND statut!='$statut2'";
1431  
1432          $result = $db->query($query);
1433  
1434          if (DB::isError($result)) {
1435              return PEAR::raiseError(
1436                         "[" . get_class($this). " DB_auteur : getHtpassWithLoginExceptStatuts()] " . $result->getMessage(). "",
1437                         null,
1438                         null,
1439                         null,
1440                         null,
1441                         null,
1442                         false);
1443          }
1444  
1445          while ($row = $result->fetchRow()) {
1446              $logins[$row['login']] = $row['htpass'];
1447          }
1448  
1449          $result->free();
1450          return $loginss;
1451      }
1452  
1453      // }}}
1454  
1455      // {{{ getHtpassWithLoginForStatut($statut)
1456  
1457      /**
1458       * Returns an array of htpass.
1459       *
1460       *
1461       * @return an array of htpass
1462       * @param $statut1
1463       * @param $statut2
1464       * @access public
1465       */
1466  
1467  	function getHtpassWithLoginForStatut ($statut) {
1468          $logins = array();
1469          $db = &$this->_getDB();
1470  
1471          if (DB::isError($db)) {
1472              return PEAR::raiseError(
1473                         "[" . get_class($this). " DB_auteur : getHtpassWithLoginForStatut()] " . $db->getMessage(). "",
1474                         null,
1475                         null,
1476                         null,
1477                         null,
1478                         null,
1479                         false);
1480          }
1481  
1482          $query = "SELECT login, htpass FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE statut = '$statut'";
1483  
1484          $result = $db->query($query);
1485  
1486          if (DB::isError($result)) {
1487              return PEAR::raiseError(
1488                         "[" . get_class(
1489                                   $this). " DB_auteur : getHtpassWithLoginForStatut()] " . $result->getMessage(). "",
1490                         null,
1491                         null,
1492                         null,
1493                         null,
1494                         null,
1495                         false);
1496          }
1497  
1498          while ($row = $result->fetchRow()) {
1499              $logins[$row['login']] = $row['htpass'];
1500          }
1501  
1502          $result->free();
1503          return $loginss;
1504      }
1505  
1506      // }}}
1507  
1508      // {{{ getHtpassWithLoginForProfil($profil)
1509  
1510      /**
1511       * Returns an array of htpass.
1512       *
1513       *
1514       * @return an array of htpass
1515       * @param $statut1
1516       * @param $statut2
1517       * @access public
1518       */
1519  
1520  	function getHtpassWithLoginForProfil ($profil) {
1521          $logins = array();
1522          $db = &$this->_getDB();
1523  
1524          if (DB::isError($db)) {
1525              return PEAR::raiseError(
1526                         "[" . get_class($this). " DB_auteur : getHtpassWithLoginForProfil()] " . $db->getMessage(). "",
1527                         null,
1528                         null,
1529                         null,
1530                         null,
1531                         null,
1532                         false);
1533          }
1534  
1535          $profilMetier = &recuperer_instance_profil();
1536          $monProfil = $profilMetier->getProfilForIntitule($profil);
1537  
1538          $query = "SELECT login, htpass " .
1539                  "FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1540                  "WHERE profil =" . $monProfil->getPoids();
1541  
1542          $result = $db->query($query);
1543  
1544          if (DB::isError($result)) {
1545              return PEAR::raiseError(
1546                         "[" . get_class(
1547                                   $this). " DB_auteur : getHtpassWithLoginForProfil()] " . $result->getMessage(). "",
1548                         null,
1549                         null,
1550                         null,
1551                         null,
1552                         null,
1553                         false);
1554          }
1555  
1556          while ($row = $result->fetchRow()) {
1557              $logins[$row['login']] = $row['htpass'];
1558          }
1559  
1560          $result->free();
1561          return $loginss;
1562      }
1563  
1564      // }}}
1565  
1566      // {{{ getAllForLoginAndSource($login, $source)
1567  
1568      /**
1569       * Returns an array of Autors.
1570       *
1571       *
1572       * @return an array of Autors
1573       * @param $login
1574       * @param $source
1575       * @access public
1576       */
1577  
1578      function &getAllForLoginAndSource ($login, $source) {
1579          $result = array();
1580          $db = &$this->_getDB();
1581  
1582          if (DB::isError($db)) {
1583              return PEAR::raiseError(
1584                         "[" . get_class($this). " DB_auteur : getAllForLoginAndSource()] " . $db->getMessage(). "", null,
1585                         null, null,
1586                         null, null,
1587                         false);
1588          }
1589  
1590          $query = "SELECT " . AUTEUR_ALL_FIELDS . " " .
1591                  "FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1592                  "WHERE login='$login' AND source='$source'";
1593  
1594          $queryResult = $db->query($query);
1595  
1596          if (DB::isError($queryResult)) {
1597              return PEAR::raiseError(
1598                         "[" . get_class(
1599                                   $this). " DB_auteur : getAllForLoginAndSource()] " . $queryResult->getMessage(). "",
1600                         null,
1601                         null,
1602                         null,
1603                         null,
1604                         null,
1605                         false);
1606          }
1607  
1608          while ($row = $queryResult->fetchRow()) {
1609              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1610  
1611              $maDate = new Date($row['maj']);
1612              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1613  
1614              $resultAuteur->_fetchData($row);
1615              $result[] = &$resultAuteur;
1616          }
1617  
1618          $queryResult->free();
1619          return $result;
1620      }
1621  
1622      // }}}
1623  
1624      // {{{ getAllForLogin($login)
1625  
1626      /**
1627       * Returns an array of Autors.
1628       *
1629       *
1630       * @return an array of Autors
1631       * @param $login
1632       * @access public
1633       */
1634  
1635      function &getAllForLogin ($login) {
1636          $result = array();
1637          $db = &$this->_getDB();
1638  
1639          if (DB::isError($db)) {
1640              return PEAR::raiseError("[" . get_class($this). " DB_auteur : getAllForLogin()] " . $db->getMessage(). "",
1641                                      null,
1642                                      null,
1643                                      null,
1644                                      null,
1645                                      null,
1646                                      false);
1647          }
1648  
1649          $query = "SELECT " . AUTEUR_ALL_FIELDS 
1650                  ." FROM " . $GLOBALS['table_prefix']. "_auteurs "
1651                  ."WHERE login='$login'";
1652  
1653          $queryResult = $db->query($query);
1654  
1655          if (DB::isError($queryResult)) {
1656              return PEAR::raiseError(
1657                         "[" . get_class($this). " DB_auteur : getAllForLogin()] " . $queryResult->getMessage(). "", null,
1658                         null, null,
1659                         null, null,
1660                         false);
1661          }
1662  
1663          while ($row = $queryResult->fetchRow()) {
1664              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1665  
1666              $maDate = new Date($row['maj']);
1667              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1668  
1669              $resultAuteur->_fetchData($row);
1670              $result[] = &$resultAuteur;
1671          }
1672  
1673          $queryResult->free();
1674          return $result;
1675      }
1676  
1677      // }}}
1678  
1679      // {{{ getAllForLoginExceptStatuts($login, $statut1, $statut2)
1680  
1681      /**
1682       * Returns an array of Autors.
1683       *
1684       *
1685       * @return an array of Autors
1686       * @param $login
1687       * @param $statut1
1688       * @param $statut2
1689       * @access public
1690       */
1691  
1692      function &getAllForLoginExceptStatuts ($login, $statut1, $statut2) {
1693          $result = array();
1694          $db = &$this->_getDB();
1695  
1696          if (DB::isError($db)) {
1697              return PEAR::raiseError(
1698                         "[" . get_class($this). " DB_auteur : getAllForLoginExceptStatuts()] " . $db->getMessage(). "",
1699                         null,
1700                         null,
1701                         null,
1702                         null,
1703                         null,
1704                         false);
1705          }
1706  
1707          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
1708                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1709                  "WHERE login='$login' AND statut!='$statut1' AND statut!='$statut2'";
1710  
1711          $queryResult = $db->query($query);
1712  
1713          if (DB::isError($queryResult)) {
1714              return PEAR::raiseError(
1715                         "[" . get_class(
1716                                   $this). " DB_auteur : getAllForLoginExceptStatuts()] " . $queryResult->getMessage(). "",
1717                         null,
1718                         null,
1719                         null,
1720                         null,
1721                         null,
1722                         false);
1723          }
1724  
1725          while ($row = $queryResult->fetchRow()) {
1726              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1727  
1728              $maDate = new Date($row['maj']);
1729              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1730  
1731              $resultAuteur->_fetchData($row);
1732              $result[] = &$resultAuteur;
1733          }
1734  
1735          $queryResult->free();
1736          return $result;
1737      }
1738  
1739      // }}}
1740  
1741      // {{{ getAllForLoginandPassAndSourceExceptStatut($login, $pass, $source, $statut)
1742  
1743      /**
1744       * Returns an array of Autors.
1745       *
1746       *
1747       * @return an array of Autors
1748       * @param $login
1749       * @param $pass
1750       * @param $source
1751       * @param $statut
1752       * @access public
1753       */
1754  
1755      function &getAllForLoginAndPassAndSourceExceptStatut ($login, $pass, $source, $statut) {
1756          $result = array();
1757          $db = &$this->_getDB();
1758  
1759          if (DB::isError($db)) {
1760              return PEAR::raiseError(
1761                         "[" . get_class(
1762                                   $this). " DB_auteur : getAllForLoginAndPassAndSourceExceptStatut()] " . $db->getMessage(). "",
1763                         null,
1764                         null,
1765                         null,
1766                         null,
1767                         null,
1768                         false);
1769          }
1770  
1771          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
1772                  "FROM ".$GLOBALS['table_prefix']."_auteurs ".
1773                  "WHERE login='".addslashes($login)."' ". 
1774                  "AND pass='".addslashes($pass)."' ". 
1775                  "AND statut<>'$statut' ".
1776                  "AND source='$source'";
1777  
1778          //echo "<br>$query<br>";
1779          $queryResult = $db->query($query);
1780  
1781          if (DB::isError($queryResult)) {
1782              return PEAR::raiseError(
1783                         "[" . get_class(
1784                                   $this). " DB_auteur : getAllForLoginAndPassAndSourceExceptStatut()] " . $queryResult->getMessage(). "",
1785                         null,
1786                         null,
1787                         null,
1788                         null,
1789                         null,
1790                         false);
1791          }
1792  
1793          while ($row = $queryResult->fetchRow()) {
1794              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1795  
1796              $maDate = new Date($row['maj']);
1797              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1798  
1799              $resultAuteur->_fetchData($row);
1800              $result[] = &$resultAuteur;
1801          }
1802  
1803          $queryResult->free();
1804          return $result;
1805      }
1806  
1807      // }}}
1808  
1809      // {{{ getAllForLoginandPassAndSourceExceptProfil($login, $pass, $source, $profil)
1810  
1811      /**
1812       * Returns an array of Autors.
1813       *
1814       *
1815       * @return an array of Autors
1816       * @param $login
1817       * @param $pass
1818       * @param $source
1819       * @param $profil
1820       * @access public
1821       */
1822  
1823      function &getAllForLoginAndPassAndSourceExceptProfil ($login, $pass, $source, $profil) {
1824          $result = array();
1825          $db = &$this->_getDB();
1826  
1827          if (DB::isError($db)) {
1828              return PEAR::raiseError(
1829                         "[" . get_class(
1830                                   $this). " DB_auteur : getAllForLoginAndPassAndSourceExceptProfil()] " . $db->getMessage(). "",
1831                         null,
1832                         null,
1833                         null,
1834                         null,
1835                         null,
1836                         false);
1837          }
1838  
1839          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
1840                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1841                  "WHERE login LIKE '" . addslashes($login). "' " .
1842                  "AND pass LIKE '" . addslashes($pass). "' " .
1843                  "AND profil<>$profil " .
1844                  "AND source='$source'";
1845  
1846          //echo "<br>$query<br>";
1847  
1848          $queryResult = $db->query($query);
1849  
1850          if (DB::isError($queryResult)) {
1851              return PEAR::raiseError(
1852                         "[" . get_class(
1853                                   $this). " DB_auteur : getAllForLoginAndPassAndSourceExceptProfil()] " . $queryResult->getMessage(). "",
1854                         null,
1855                         null,
1856                         null,
1857                         null,
1858                         null,
1859                         false);
1860          }
1861  
1862          while ($row = $queryResult->fetchRow()) {
1863              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1864  
1865              $maDate = new Date($row['maj']);
1866              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1867  
1868              $resultAuteur->_fetchData($row);
1869              $result[] = &$resultAuteur;
1870          }
1871  
1872          $queryResult->free();
1873          return $result;
1874      }
1875  
1876      // }}}
1877  
1878      // {{{ getAllExceptMessagerieAndAuteurIdAndPassAndLogin($messagerie, $auteurId, $pass , $login)
1879  
1880      /**
1881       * Returns an array of Autors.
1882       *
1883       *
1884       * @return an array of Autors
1885       * @param $messagerie
1886       * @param $auteurId
1887       * @param $pass
1888       * @param $login
1889       * @access public
1890       */
1891  
1892      function &getAllExceptMessagerieAndAuteurIdAndPassAndLogin ($messagerie, $auteurId, $pass, $login) {
1893          $result = array();
1894          $db = &$this->_getDB();
1895  
1896          if (DB::isError($db)) {
1897              return PEAR::raiseError(
1898                         "[" . get_class(
1899                                   $this). " DB_auteur : getAllExceptMessagerieAndAuteurIdAndPassAndLogin()] " . $db->getMessage(). "",
1900                         null,
1901                         null,
1902                         null,
1903                         null,
1904                         null,
1905                         false);
1906          }
1907  
1908          $query = "SELECT " . AUTEUR_ALL_FIELDS
1909                  ." FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1910                  "WHERE messagerie<>'$messagerie' " .
1911                  "AND id_auteur<>$auteurId " .
1912                  "AND pass<>'$pass' " .
1913                  "AND login<>'$login'";
1914  
1915          $queryResult = $db->query($query);
1916  
1917          if (DB::isError($queryResult)) {
1918              return PEAR::raiseError(
1919                         "[" . get_class(
1920                                   $this). " DB_auteur : getAllExceptMessagerieAndAuteurIdAndPassAndLogin()] " . $queryResult->getMessage(). "",
1921                         null,
1922                         null,
1923                         null,
1924                         null,
1925                         null,
1926                         false);
1927          }
1928  
1929          while ($row = $queryResult->fetchRow()) {
1930              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1931  
1932              $maDate = new Date($row['maj']);
1933              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1934  
1935              $resultAuteur->_fetchData($row);
1936              $result[] = &$resultAuteur;
1937          }
1938  
1939          $queryResult->free();
1940          return $result;
1941      }
1942  
1943      // }}}
1944  
1945      // {{{ getAllForEmail($email)
1946  
1947      /**
1948       * Returns an array of Autors.
1949       *
1950       *
1951       * @return an array of Autors
1952       * @param $email
1953       * @access public
1954       */
1955  
1956      function &getAllForEmail ($email) {
1957          $result = array();
1958          $db = &$this->_getDB();
1959  
1960          if (DB::isError($db)) {
1961              return PEAR::raiseError("[" . get_class($this). " DB_auteur : getAllForEmail()] " . $db->getMessage(). "",
1962                                      null,
1963                                      null,
1964                                      null,
1965                                      null,
1966                                      null,
1967                                      false);
1968          }
1969  
1970          $query = "SELECT " . AUTEUR_ALL_FIELDS
1971                  ." FROM " . $GLOBALS['table_prefix']. "_auteurs " .
1972                  "WHERE email='$email'";
1973  
1974          $queryResult = $db->query($query);
1975  
1976          if (DB::isError($queryResult)) {
1977              return PEAR::raiseError(
1978                         "[" . get_class($this). " DB_auteur : getAllForEmail()] " . $queryResult->getMessage(). "", null,
1979                         null, null,
1980                         null, null,
1981                         false);
1982          }
1983  
1984          while ($row = $queryResult->fetchRow()) {
1985              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
1986  
1987              $maDate = new Date($row['maj']);
1988              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
1989  
1990              $resultAuteur->_fetchData($row);
1991              $result[] = &$resultAuteur;
1992          }
1993  
1994          $queryResult->free();
1995          return $result;
1996      }
1997  
1998      // }}}
1999  
2000      // {{{ getAllForStatut($statut)
2001  
2002      /**
2003       * Returns an array of Autors.
2004       *
2005       *
2006       * @return an array of Autors
2007       * @param $statut
2008       * @access public
2009       */
2010  
2011      function &getAllForStatut ($statut) {
2012          $result = array();
2013          $db = &$this->_getDB();
2014  
2015          if (DB::isError($db)) {
2016              return PEAR::raiseError("[" . get_class($this). " DB_auteur : getAllForStatut()] " . $db->getMessage(). "",
2017                                      null,
2018                                      null,
2019                                      null,
2020                                      null,
2021                                      null,
2022                                      false);
2023          }
2024  
2025          $query = "SELECT " . AUTEUR_ALL_FIELDS
2026                  ." FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2027                  "WHERE statut='$statut'";
2028  
2029          $queryResult = $db->query($query);
2030  
2031          if (DB::isError($queryResult)) {
2032              return PEAR::raiseError(
2033                         "[" . get_class($this). " DB_auteur : getAllForStatut()] " . $queryResult->getMessage(). "",
2034                         null,
2035                         null,
2036                         null,
2037                         null,
2038                         null,
2039                         false);
2040          }
2041  
2042          while ($row = $queryResult->fetchRow()) {
2043              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2044  
2045              $maDate = new Date($row['maj']);
2046              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2047  
2048              $resultAuteur->_fetchData($row);
2049              $result[] = &$resultAuteur;
2050          }
2051  
2052          $queryResult->free();
2053          return $result;
2054      }
2055  
2056      // }}}
2057  
2058      // {{{ getAllForStatutAndMaj($statut, $myDate)
2059  
2060      /**
2061       * Returns an array of Autors.
2062       *
2063       *
2064       * @return an array of Autors
2065       * @param $statut
2066       * @param $myDate
2067       * @access public
2068       */
2069  
2070      function &getAllForStatutAndMaj ($statut, $myDate) {
2071          $result = array();
2072          $db = &$this->_getDB();
2073  
2074          if (DB::isError($db)) {
2075              return PEAR::raiseError(
2076                         "[" . get_class($this). " DB_auteur : getAllForStatutAndMaj()] " . $db->getMessage(). "", null,
2077                         null, null,
2078                         null, null,
2079                         false);
2080          }
2081  
2082          $dateTmp = new Date($myDate);
2083          $myDate = $dateTmp->getDate(DATE_FORMAT_ISO);
2084  
2085          $query = "SELECT " . AUTEUR_ALL_FIELDS .
2086                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2087                  "WHERE statut='$statut' AND maj < '$mydate'";
2088  
2089          $queryResult = $db->query($query);
2090  
2091          if (DB::isError($queryResult)) {
2092              return PEAR::raiseError(
2093                         "[" . get_class(
2094                                   $this). " DB_auteur : getAllForStatutAndMaj()] " . $queryResult->getMessage(). "",
2095                         null,
2096                         null,
2097                         null,
2098                         null,
2099                         null,
2100                         false);
2101          }
2102  
2103          while ($row = $queryResult->fetchRow()) {
2104              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2105  
2106              $maDate = new Date($row['maj']);
2107              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2108  
2109              $resultAuteur->_fetchData($row);
2110              $result[] = &$resultAuteur;
2111          }
2112  
2113          $queryResult->free();
2114          return $result;
2115      }
2116  
2117      // }}}
2118  
2119      // {{{ getAllForLoginAndNotStatut($login, $statut)
2120  
2121      /**
2122       * Returns an array of Autors.
2123       *
2124       *
2125       * @return an array of Autors
2126       * @param $login
2127       * @param $statut
2128       * @access public
2129       */
2130  
2131      function &getAllForLoginAndNotStatut ($login, $statut) {
2132          $result = array();
2133          $db = &$this->_getDB();
2134  
2135          if (DB::isError($db)) {
2136              return PEAR::raiseError(
2137                         "[" . get_class($this). " DB_auteur : getAllForLoginAndNotStatut()] " . $db->getMessage(). "",
2138                         null,
2139                         null,
2140                         null,
2141                         null,
2142                         null,
2143                         false);
2144          }
2145  
2146          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
2147                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2148                  "WHERE login='$login' AND statut!='$statut'";
2149  
2150          $queryResult = $db->query($query);
2151  
2152          if (DB::isError($queryResult)) {
2153              return PEAR::raiseError(
2154                         "[" . get_class(
2155                                   $this). " DB_auteur : getAllForLoginAndNotStatut()] " . $queryResult->getMessage(). "",
2156                         null,
2157                         null,
2158                         null,
2159                         null,
2160                         null,
2161                         false);
2162          }
2163  
2164          while ($row = $queryResult->fetchRow()) {
2165              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2166  
2167              $maDate = new Date($row['maj']);
2168              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2169  
2170              $resultAuteur->_fetchData($row);
2171              $result[] = &$resultAuteur;
2172          }
2173  
2174          $queryResult->free();
2175          return $result;
2176      }
2177  
2178      // }}}
2179  
2180      // {{{ getAllForLoginAndNotProfil($login, $profil)
2181  
2182      /**
2183       * Returns an array of Autors.
2184       *
2185       *
2186       * @return an array of Autors
2187       * @param $login
2188       * @param $profil
2189       * @access public
2190       */
2191  
2192      function &getAllForLoginAndNotProfil ($login, $profil) {
2193          $result = array();
2194          $db = &$this->_getDB();
2195  
2196          if (DB::isError($db)) {
2197              return PEAR::raiseError(
2198                         "[" . get_class($this). " DB_auteur : getAllForLoginAndNotProfil()] " . $db->getMessage(). "",
2199                         null,
2200                         null,
2201                         null,
2202                         null,
2203                         null,
2204                         false);
2205          }
2206  
2207          $query = "SELECT " . AUTEUR_ALL_FIELDS 
2208                  ." FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2209                  "WHERE login='$login' AND profil!=$profil";
2210  
2211          //echo '<br>' . $query . '<br>';
2212          $queryResult = $db->query($query);
2213  
2214          if (DB::isError($queryResult)) {
2215              return PEAR::raiseError(
2216                         "[" . get_class(
2217                                   $this). " DB_auteur : getAllForLoginAndNotProfil()] " . $queryResult->getMessage(). "",
2218                         null,
2219                         null,
2220                         null,
2221                         null,
2222                         null,
2223                         false);
2224          }
2225  
2226          while ($row = $queryResult->fetchRow()) {
2227              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2228              $maDate = new Date($row['maj']);
2229              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2230              //var_dump($row);
2231              $resultAuteur->_fetchData($row);
2232              $result[] = &$resultAuteur;
2233          }
2234  
2235          $queryResult->free();
2236  
2237          return $result;
2238      }
2239  
2240      // }}}
2241  
2242      // {{{ getAllForCookieOubliAndNotStatutAndNotPass($p, '5poubelle', "")
2243  
2244      /**
2245       * Returns an array of Autors.
2246       *
2247       *
2248       * @return an array of Autors
2249       * @param $login
2250       * @param $statut
2251       * @access public
2252       */
2253  
2254      function &getAllForCookieOubliAndNotStatutAndNotPass ($cookieOubli, $statut, $pass) {
2255          $result = array();
2256          $db = &$this->_getDB();
2257  
2258          if (DB::isError($db)) {
2259              return PEAR::raiseError(
2260                         "[" . get_class(
2261                                   $this). " DB_auteur : getAllForCookieOubliAndNotStatutAndNotPass()] " . $db->getMessage(). "",
2262                         null,
2263                         null,
2264                         null,
2265                         null,
2266                         null,
2267                         false);
2268          }
2269  
2270          $query = "SELECT " . AUTEUR_ALL_FIELDS .
2271                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2272                  "WHERE cookie_oubli='$cookieOublie' AND statut!='$statut' AND pass!='$pass'";
2273  
2274          //echo '<br>' . $query . '<br>';
2275  
2276          $queryResult = $db->query($query);
2277  
2278          if (DB::isError($queryResult)) {
2279              return PEAR::raiseError(
2280                         "[" . get_class(
2281                                   $this). " DB_auteur : getAllForCookieOubliAndNotStatutAndNotPass()] " . $queryResult->getMessage(). "",
2282                         null,
2283                         null,
2284                         null,
2285                         null,
2286                         null,
2287                         false);
2288          }
2289  
2290          while ($row = $queryResult->fetchRow()) {
2291              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2292  
2293              $maDate = new Date($row['maj']);
2294              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2295  
2296              $resultAuteur->_fetchData($row);
2297              $result[] = &$resultAuteur;
2298          }
2299  
2300          $queryResult->free();
2301          return $result;
2302      }
2303  
2304      // }}}
2305  
2306      // {{{ getAllForCookieOubliAndNotProfilAndNotPass($p, '5poubelle', "")
2307  
2308      /**
2309       * Returns an array of Autors.
2310       *
2311       *
2312       * @return an array of Autors
2313       * @param $login
2314       * @param $profil
2315       * @access public
2316       */
2317  
2318      function &getAllForCookieOubliAndNotProfilAndNotPass ($cookieOubli, $profil, $pass) {
2319          $result = array();
2320          $db = &$this->_getDB();
2321  
2322          if (DB::isError($db)) {
2323              return PEAR::raiseError(
2324                         "[" . get_class(
2325                                   $this). " DB_auteur : getAllForCookieOubliAndNotProfilAndNotPass()] " . $db->getMessage(). "",
2326                         null,
2327                         null,
2328                         null,
2329                         null,
2330                         null,
2331                         false);
2332          }
2333  
2334          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
2335                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
2336                  "WHERE profil!=$profil AND pass!='$pass'"; //cookie_oubli='$cookieOublie' AND 
2337          //echo '<br>' . $query . '<br>';
2338  
2339          $queryResult = $db->query($query);
2340  
2341          if (DB::isError($queryResult)) {
2342              return PEAR::raiseError(
2343                         "[" . get_class(
2344                                   $this). " DB_auteur : getAllForCookieOubliAndNotProfilAndNotPass()] " . $queryResult->getMessage(). "",
2345                         null,
2346                         null,
2347                         null,
2348                         null,
2349                         null,
2350                         false);
2351          }
2352  
2353          while ($row = $queryResult->fetchRow()) {
2354              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2355  
2356              $maDate = new Date($row['maj']);
2357              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2358  
2359              $resultAuteur->_fetchData($row);
2360              $result[] = &$resultAuteur;
2361          }
2362  
2363          $queryResult->free();
2364          return $result;
2365      }
2366  
2367      // }}}
2368  
2369      // {{{ getAllForRubriqueIds($rubriques)
2370  
2371      /**
2372       * Returns an array of Breve.
2373       *
2374       *
2375       * @return Array of Breve
2376       * @param $rubriques
2377       * @access public
2378       */
2379  
2380      function &getAllForArticleIds ($articles) {
2381          $auteurs = array();
2382          $db = &$this->_getDB();
2383  
2384          if (DB::isError($db)) {
2385              return PEAR::raiseError(
2386                         "[" . get_class($this). " DB_auteur : getAllForArticleIds()] " . $db->getMessage(). "", null,
2387                         null, null,
2388                         null, null,
2389                         false);
2390          }
2391  
2392          $query = "SELECT DISTINCT".$GLOBALS['table_prefix']."_auteurs.id_auteur, maj ".
2393                  "FROM ".$GLOBALS['table_prefix']."_auteurs, ".$GLOBALS['table_prefix']."_auteurs_articles lien " .
2394                  "WHERE id_article IN ($articles) " .
2395                  "AND ".$GLOBALS['table_prefix']."_auteurs.id_auteur=lien.id_auteur";
2396  
2397          $queryResult = $db->query($query);
2398  
2399          if (DB::isError($queryResult)) {
2400              return PEAR::raiseError(
2401                         "[" . get_class($this). " DB_auteur : getAllForArticleIds()] " . $queryResult->getMessage(). "",
2402                         null,
2403                         null,
2404                         null,
2405                         null,
2406                         null,
2407                         false);
2408          }
2409  
2410          while ($row = $queryResult->fetchRow()) {
2411              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2412  
2413              $maDate = new Date($row['maj']);
2414              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2415  
2416              $resultAuteur->_fetchData($row);
2417              $auteurs[] = &$resultAuteur;
2418          }
2419  
2420          $queryResult->free();
2421  
2422          return $auteurs;
2423      }
2424  
2425      // }}}
2426  
2427      // {{{ getAllForArticleId($articleId)
2428  
2429      /**
2430       * Returns an array of Autors.
2431       *
2432       *
2433       * @return an array of Autors
2434       * @param $articleId
2435       * @access public
2436       */
2437  
2438      function &getAllForArticleId ($articleId) {
2439          $result = array();
2440          $db = &$this->_getDB();
2441  
2442          if (DB::isError($db)) {
2443              return PEAR::raiseError(
2444                         "[" . get_class($this). " DB_auteur : getAllForArticleId()] " . $db->getMessage(). "", null,
2445                         null, null,
2446                         null, null,
2447                         false);
2448          }
2449  
2450          $query = "SELECT auteurs.id_auteur AS id_auteur, nom, bio, email, nom_site, url_site, login, pass, statut, profil, maj, pgp, htpass, en_ligne, imessage, messagerie, alea_actuel, alea_futur, prefs, cookie_oubli, source " .
2451                  "FROM ".$GLOBALS['table_prefix']."_auteurs auteurs, ".$GLOBALS['table_prefix']."_auteurs_articles lien " .
2452                  "WHERE lien.id_article=$articleId AND auteurs.id_auteur=lien.id_auteur";
2453  
2454          $queryResult = $db->query($query);
2455  
2456          if (DB::isError($queryResult)) {
2457              return PEAR::raiseError(
2458                         "[" . get_class($this). " DB_auteur : getAllForArticleId()] " . $queryResult->getMessage(). "",
2459                         null,
2460                         null,
2461                         null,
2462                         null,
2463                         null,
2464                         false);
2465          }
2466  
2467          while ($row = $queryResult->fetchRow()) {
2468              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2469  
2470              $maDate = new Date($row['maj']);
2471              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2472  
2473              $resultAuteur->_fetchData($row);
2474              $result[] = &$resultAuteur;
2475          }
2476  
2477          $queryResult->free();
2478          return $result;
2479      }
2480  
2481      // }}}
2482  
2483      // {{{ getAllForMessageId($messageId)
2484  
2485      /**
2486       * Returns an array of Autors.
2487       *
2488       *
2489       * @return an array of Autors
2490       * @param $messageId
2491       * @access public
2492       */
2493  
2494      function &getAllForMessageId ($messageId) {
2495          $result = array();
2496          $db = &$this->_getDB();
2497  
2498          if (DB::isError($db)) {
2499              return PEAR::raiseError(
2500                         "[" . get_class($this). " DB_auteur : getAllForMessageId()] " . $db->getMessage(). "", null,
2501                         null, null,
2502                         null, null,
2503                         false);
2504          }
2505  
2506          $query = "SELECT auteurs.* " .
2507                  "FROM ".$GLOBALS['table_prefix']."_auteurs auteurs, ".$GLOBALS['table_prefix']."_auteurs_messages lien " .
2508                  "WHERE lien.id_message=$messageId " .
2509                  "AND lien.id_auteur=auteurs.id_auteur";
2510  
2511          $queryResult = $db->query($query);
2512  
2513          if (DB::isError($queryResult)) {
2514              return PEAR::raiseError(
2515                         "[" . get_class($this). " DB_auteur : getAllForMessageId()] " . $queryResult->getMessage(). "",
2516                         null,
2517                         null,
2518                         null,
2519                         null,
2520                         null,
2521                         false);
2522          }
2523  
2524          while ($row = $queryResult->fetchRow()) {
2525              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2526  
2527              $maDate = new Date($row['maj']);
2528              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2529  
2530              $resultAuteur->_fetchData($row);
2531              $result[] = &$resultAuteur;
2532          }
2533  
2534          $queryResult->free();
2535          return $result;
2536      }
2537  
2538      // }}}
2539  
2540      // {{{ getAllForMessageIdExceptAuteurId($messageId, $auteurId)
2541  
2542      /**
2543       * Returns an array of Autors.
2544       *
2545       *
2546       * @return an array of Autors
2547       * @param $messageId
2548       * @param $auteurId
2549       * @access public
2550       */
2551  
2552      function &getAllForMessageIdExceptAuteurId ($messageId, $auteurId) {
2553          $result = array();
2554          $db = &$this->_getDB();
2555  
2556          if (DB::isError($db)) {
2557              return PEAR::raiseError(
2558                         "[" . get_class(
2559                                   $this). " DB_auteur : getAllForMessageIdExceptAuteurId()] " . $db->getMessage(). "",
2560                         null,
2561                         null,
2562                         null,
2563                         null,
2564                         null,
2565                         false);
2566          }
2567  
2568          $query = "SELECT auteurs.nom FROM ".$GLOBALS['table_prefix']."_auteurs auteurs, ".$GLOBALS['table_prefix']."_auteurs_messages lien " .
2569                  "WHERE lien.id_message=$messageId " .
2570                  "AND lien.id_auteur!=$auteurId " .
2571                  "AND lien.id_auteur=auteurs.id_auteur";
2572  
2573          $queryResult = $db->query($query);
2574  
2575          if (DB::isError($queryResult)) {
2576              return PEAR::raiseError(
2577                         "[" . get_class(
2578                                   $this). " DB_auteur : getAllForMessageIdExceptAuteurId()] " . $queryResult->getMessage(). "",
2579                         null,
2580                         null,
2581                         null,
2582                         null,
2583                         null,
2584                         false);
2585          }
2586  
2587          while ($row = $queryResult->fetchRow()) {
2588              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2589              $resultAuteur->_fetchData($row);
2590              $result[] = &$resultAuteur;
2591          }
2592  
2593          $queryResult->free();
2594          return $result;
2595      }
2596  
2597      // }}}
2598  
2599      // {{{ getAllForAuteurIds($les_auteurs, $critere)
2600  
2601      /**
2602       * Returns an array of Autors.
2603       *
2604       *
2605       * @return an array of Autors
2606       * @param $les_auteurs
2607       * @param $critere
2608       * @access public
2609       */
2610  
2611      function &getAllForAuteurIds ($les_auteurs, $critere) {
2612          $result = array();
2613          $db = &$this->_getDB();
2614  
2615          if (DB::isError($db)) {
2616              return PEAR::raiseError(
2617                         "[" . get_class($this). " DB_auteur : getAllForAuteurIds()] " . $db->getMessage(). "", null,
2618                         null, null,
2619                         null, null,
2620                         false);
2621          }
2622  
2623          $query = "SELECT ".AUTEUR_ALL_FIELDS.
2624                  " FROM ".$GLOBALS['table_prefix']."_auteurs " .
2625                  "WHERE id_auteur IN ($les_auteurs) ORDER BY $critere";
2626  
2627          $queryResult = $db->query($query);
2628  
2629          if (DB::isError($queryResult)) {
2630              return PEAR::raiseError(
2631                         "[" . get_class($this). " DB_auteur : getAllForAuteurIds()] " . $queryResult->getMessage(). "",
2632                         null,
2633                         null,
2634                         null,
2635                         null,
2636                         null,
2637                         false);
2638          }
2639  
2640          while ($row = $queryResult->fetchRow()) {
2641              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2642  
2643              $maDate = new Date($row['maj']);
2644              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2645  
2646              $resultAuteur->_fetchData($row);
2647              $result[] = &$resultAuteur;
2648          }
2649  
2650          $queryResult->free();
2651          return $result;
2652      }
2653  
2654      // }}}
2655  
2656      // {{{ getAllParticipants($ze_auteurs, $les_auteurs)
2657  
2658      /**
2659       * Returns an array of Autors.
2660       *
2661       *
2662       * @return an array of Autors
2663       * @param $les_auteurs
2664       * @param $critere
2665       * @access public
2666       */
2667  
2668      function &getAllParticipants ($ze_auteurs, $les_auteurs) {
2669          $result = array();
2670          $db = &$this->_getDB();
2671  
2672          if (DB::isError($db)) {
2673              return PEAR::raiseError(
2674                         "[" . get_class($this). " DB_auteur : getAllParticipants()] " . $db->getMessage(). "", null,
2675                         null, null,
2676                         null, null,
2677                         false);
2678          }
2679  
2680          $profilMetier = &recuperer_instance_profil();
2681          $allProfils = $profilMetier->getAllProfils();
2682  
2683          while (list(, $monProfil) = each($allProfils)) {
2684              $poids[] = $monProfil->getPoids();
2685          }
2686  
2687          $query = "SELECT " . AUTEUR_ALL_FIELDS . " FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE ";
2688  
2689          if ($les_auteurs)
2690              $query .= "id_auteur NOT IN ($ze_auteurs) AND ";
2691  
2692          $query .= " messagerie<>'non' AND profil IN (" . join(",", $poids). ") ORDER BY profil, nom";
2693          
2694          $queryResult = $db->query($query);
2695  
2696          if (DB::isError($queryResult)) {
2697              return PEAR::raiseError(
2698                         "[" . get_class($this). " DB_auteur : getAllParticipants()] " . $queryResult->getMessage(). "",
2699                         null,
2700                         null,
2701                         null,
2702                         null,
2703                         null,
2704                         false);
2705          }
2706  
2707          while ($row = $queryResult->fetchRow()) {
2708              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2709  
2710              $maDate = new Date($row['maj']);
2711              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2712  
2713              $resultAuteur->_fetchData($row);
2714              $result[] = &$resultAuteur;
2715          }
2716  
2717          $queryResult->free();
2718          return $result;
2719      }
2720  
2721      // }}}
2722  
2723      // {{{ getAllExceptAuteurIdsAndStatuts($lesAuteurs)
2724  
2725      /**
2726       * Returns an array of Autors.
2727       *
2728       *
2729       * @return an array of Autors
2730       * @param $lesAuteurs
2731       * @access public
2732       */
2733  
2734      function &getAllExceptAuteurIdsAndStatuts ($lesAuteurs) {
2735          $result = array();
2736          $db = &$this->_getDB();
2737  
2738          if (DB::isError($db)) {
2739              return PEAR::raiseError(
2740                         "[" . get_class(
2741                                   $this). " DB_auteur : getAllExceptAuteurIdsAndStatuts()] " . $db->getMessage(). "",
2742                         null,
2743                         null,
2744                         null,
2745                         null,
2746                         null,
2747                         false);
2748          }
2749  
2750          $query = "SELECT " . AUTEUR_ALL_FIELDS . " FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE ";
2751  
2752          if ($lesAuteurs)
2753              $query .= "id_auteur NOT IN ($lesAuteurs) AND ";
2754  
2755          $query .= "statut<>'5poubelle' AND statut<>'nouveau' ORDER BY statut, nom";
2756  
2757          $queryResult = $db->query($query);
2758  
2759          if (DB::isError($queryResult)) {
2760              return PEAR::raiseError(
2761                         "[" . get_class(
2762                                   $this). " DB_auteur : getAllExceptAuteurIdsAndStatuts()] " . $queryResult->getMessage(). "",
2763                         null,
2764                         null,
2765                         null,
2766                         null,
2767                         null,
2768                         false);
2769          }
2770  
2771          while ($row = $queryResult->fetchRow()) {
2772              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2773  
2774              $maDate = new Date($row['maj']);
2775              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2776  
2777              $resultAuteur->_fetchData($row);
2778              $result[] = &$resultAuteur;
2779          }
2780  
2781          $queryResult->free();
2782          return $result;
2783      }
2784  
2785      // }}}
2786  
2787      // {{{ getAllExceptAuteurIdsAndProfils($lesAuteurs)
2788  
2789      /**
2790       * Returns an array of Autors.
2791       *
2792       *
2793       * @return an array of Autors
2794       * @param $lesAuteurs
2795       * @access public
2796       */
2797  
2798      function &getAllExceptAuteurIdsAndProfils ($lesAuteurs) {
2799          $result = array();
2800          $db = &$this->_getDB();
2801  
2802          if (DB::isError($db)) {
2803              return PEAR::raiseError(
2804                         "[" . get_class(
2805                                   $this). " DB_auteur : getAllExceptAuteurIdsAndProfils()] " . $db->getMessage(). "",
2806                         null,
2807                         null,
2808                         null,
2809                         null,
2810                         null,
2811                         false);
2812          }
2813  
2814          $query = "SELECT " . AUTEUR_ALL_FIELDS . " FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE ";
2815  
2816          if ($lesAuteurs)
2817              $query .= "id_auteur NOT IN ($lesAuteurs) AND ";
2818  
2819          $profilMetier = &recuperer_instance_profil();
2820          $monProfil = $profilMetier->getProfilForIntitule('texte_statut_poubelle');
2821  
2822          $query .= "profil<>" . $monProfil->getPoids(). " ORDER BY profil, nom";
2823  
2824          //echo '<br>' . $query . '<br>';
2825  
2826          $queryResult = $db->query($query);
2827  
2828          if (DB::isError($queryResult)) {
2829              return PEAR::raiseError(
2830                         "[" . get_class(
2831                                   $this). " DB_auteur : getAllExceptAuteurIdsAndProfils()] " . $queryResult->getMessage(). "",
2832                         null,
2833                         null,
2834                         null,
2835                         null,
2836                         null,
2837                         false);
2838          }
2839  
2840          while ($row = $queryResult->fetchRow()) {
2841              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2842  
2843              $maDate = new Date($row['maj']);
2844              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2845  
2846              $resultAuteur->_fetchData($row);
2847              $result[] = &$resultAuteur;
2848          }
2849  
2850          $queryResult->free();
2851          return $result;
2852      }
2853  
2854      // }}}
2855  
2856      // {{{ getAllAuteurs()
2857  
2858      /**
2859       * Returns an array of Autors.
2860       *
2861       *
2862       * @return an array of Autors
2863       * @access public
2864       */
2865  
2866      function &getAllAuteurs () {
2867          $result = array();
2868          $db = &$this->_getDB();
2869  
2870          if (DB::isError($db)) {
2871              return PEAR::raiseError("[" . get_class($this). " DB_auteur : getAllAuteurs()] " . $db->getMessage(). "",
2872                                      null,
2873                                      null,
2874                                      null,
2875                                      null,
2876                                      null,
2877                                      false);
2878          }
2879  
2880          $query = "SELECT " . AUTEUR_ALL_FIELDS . " FROM " . $GLOBALS['table_prefix']. "_auteurs";
2881  
2882          $queryResult = $db->query($query);
2883  
2884          if (DB::isError($queryResult)) {
2885              return PEAR::raiseError(
2886                         "[" . get_class($this). " DB_auteur : getAllAuteurs()] " . $queryResult->getMessage(). "", null,
2887                         null, null,
2888                         null, null,
2889                         false);
2890          }
2891  
2892          while ($row = $queryResult->fetchRow()) {
2893              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
2894  
2895              $maDate = new Date($row['maj']);
2896              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
2897  
2898              $resultAuteur->_fetchData($row);
2899              $result[] = &$resultAuteur;
2900          }
2901  
2902          $queryResult->free();
2903          return $result;
2904      }
2905  
2906      // }}}
2907  
2908      // {{{ updateHtPassAndPassAndAleaActuelAndCookieOubliForCookieOubli($htpass, $pass, $aleaActuel, $newCookieOubli , $cookieOubli)
2909  
2910      /**
2911       * Update HTpass Pass AleaActuel and cookieOublie fro CookieOublie.
2912       *
2913       *
2914       * @return an array of Autors
2915       * @param $htpass
2916       * @param $mdpass
2917       * @param $aleaActuel
2918       * @param $newCookieOubli
2919       * @param $cookieOubli
2920       * @access public
2921       */
2922  
2923      function updateHtPassAndPassAndAleaActuelAndCookieOubliForCookieOubli (
2924          $htpass, $pass, $aleaActuel, $newCookieOubli, $cookieOubli) {
2925          $db = &$this->_getDB();
2926  
2927          if (DB::isError($db)) {
2928              return PEAR::raiseError(
2929                         "[" . get_class(
2930                                   $this). " DB_auteur : updateHtPassAndPassAndAleaActuelAndCookieOubliForCookieOubli()] " . $db->getMessage(). "",
2931                         null,
2932                         null,
2933                         null,
2934                         null,
2935                         null,
2936                         false);
2937          }
2938  
2939          $query = "UPDATE ".$GLOBALS['table_prefix']."_auteurs " .
2940                  "SET htpass='$htpass', pass='$pass', alea_actuel='$aleaActuel', cookie_oubli='$newCookieOubli' " .
2941                  "WHERE cookie_oubli='$cookieOubli'";
2942  
2943          $result = $db->query($query);
2944  
2945          if (DB::isError($result)) {
2946              return PEAR::raiseError(
2947                         "[" . get_class(
2948                                   $this). " DB_auteur : updateHtPassAndPassAndAleaActuelAndCookieOubliForCookieOubli()] " . $result->getMessage(). "",
2949                         null,
2950                         null,
2951                         null,
2952                         null,
2953                         null,
2954                         false);
2955          }
2956      }
2957  
2958      // }}}
2959  
2960      // {{{ updateCookieOubliForEmail($cookie, $email)
2961  
2962      /**
2963       * Update CookieOublie for email.
2964       *
2965       *
2966       * @return an array of Autors
2967       * @param $Cookie
2968       * @param $email
2969       * @access public
2970       */
2971  
2972  	function updateCookieOubliForEmail ($cookie, $email) {
2973          $db = &$this->_getDB();
2974  
2975          if (DB::isError($db)) {
2976              return PEAR::raiseError(
2977                         "[" . get_class($this). " DB_auteur : updateCookieOubliForEmail()] " . $db->getMessage(). "",
2978                         null,
2979                         null,
2980                         null,
2981                         null,
2982                         null,
2983                         false);
2984          }
2985  
2986          $query = "UPDATE ".$GLOBALS['table_prefix']."_auteurs SET cookie_oubli = '$cookie' " .
2987                  "WHERE email ='$email'";
2988  
2989          $result = $db->query($query);
2990  
2991          if (DB::isError($result)) {
2992              return PEAR::raiseError(
2993                         "[" . get_class($this). " DB_auteur : updateCookieOubliForEmail()] " . $result->getMessage(). "",
2994                         null,
2995                         null,
2996                         null,
2997                         null,
2998                         null,
2999                         false);
3000          }
3001      }
3002  
3003      // }}}
3004  
3005      // {{{ updateStatutForLogin($statut, $login)
3006  
3007      /**
3008       * Update Statut for login.
3009       *
3010       *
3011       * @update Statut
3012       * @param $statut
3013       * @param $login
3014       * @access public
3015       */
3016  
3017  	function updateStatutForLogin ($statut, $login) {
3018          $db = &$this->_getDB();
3019  
3020          if (DB::isError($db)) {
3021              return PEAR::raiseError(
3022                         "[" . get_class($this). " DB_auteur : updateStatutForLogin()] " . $db->getMessage(). "", null,
3023                         null, null,
3024                         null, null,
3025                         false);
3026          }
3027  
3028          $query = "UPDATE ".$GLOBALS['table_prefix']."_auteurs " .
3029                  "SET statut='$statut' WHERE login='$login'";
3030  
3031          $result = $db->query($query);
3032  
3033          if (DB::isError($result)) {
3034              return PEAR::raiseError(
3035                         "[" . get_class($this). " DB_auteur : updateStatutForLogin()] " . $result->getMessage(). "",
3036                         null,
3037                         null,
3038                         null,
3039                         null,
3040                         null,
3041                         false);
3042          }
3043      }
3044  
3045      // }}}
3046  
3047      // {{{ updateProfilForLogin($profil, $login)
3048  
3049      /**
3050       * Update profil for login.
3051       *
3052       *
3053       * @update profil
3054       * @param $profil
3055       * @param $login
3056       * @access public
3057       */
3058  
3059  	function updateProfilForLogin ($profil, $login) {
3060          $db = &$this->_getDB();
3061  
3062          if (DB::isError($db)) {
3063              return PEAR::raiseError(
3064                         "[" . get_class($this). " DB_auteur : updateProfilForLogin()] " . $db->getMessage(). "", null,
3065                         null, null,
3066                         null, null,
3067                         false);
3068          }
3069  
3070          $query = "UPDATE ".$GLOBALS['table_prefix']."_auteurs SET profil='$profil' WHERE login='$login'";
3071  
3072          $result = $db->query($query);
3073  
3074          if (DB::isError($result)) {
3075              return PEAR::raiseError(
3076                         "[" . get_class($this). " DB_auteur : updateProfilForLogin()] " . $result->getMessage(). "",
3077                         null,
3078                         null,
3079                         null,
3080                         null,
3081                         null,
3082                         false);
3083          }
3084      }
3085  
3086      // }}}
3087  
3088      // {{{ updatePassAndAleaFuturForLogin($pass, $aleaFutur, $login)
3089  
3090      /**
3091       * Update Pass and Alea for login.
3092       *
3093       *
3094       * @update Pass and Alea Futeur
3095       * @param $pass
3096       * @param $aleaFutur
3097       * @param $login
3098       * @access public
3099       */
3100  
3101  	function updatePassAndAleaFuturForLogin ($pass, $aleaFutur, $login) {
3102          $db = &$this->_getDB();
3103  
3104          if (DB::isError($db)) {
3105              return PEAR::raiseError(
3106                         "[" . get_class(
3107                                   $this). " DB_auteur : updatePassAndAleaFuturForLogin()] " . $db->getMessage(). "",
3108                         null,
3109                         null,
3110                         null,
3111                         null,
3112                         null,
3113                         false);
3114          }
3115  
3116          $query = "UPDATE ".$GLOBALS['table_prefix']."_auteurs " .
3117                  "SET alea_actuel = alea_futur, pass = ".$db->quote($pass).", alea_futur = '$aleaFutur' ".
3118                  "WHERE login LIKE ".$db->quote($login);
3119  
3120          $result = $db->query($query);
3121  
3122          if (DB::isError($result)) {
3123              return PEAR::raiseError(
3124                         "[" . get_class(
3125                                   $this). " DB_auteur : updatePassAndAleaFuturForLogin()] " . $result->getMessage(). "",
3126                         null,
3127                         null,
3128                         null,
3129                         null,
3130                         null,
3131                         false);
3132          }
3133      }
3134  
3135      // }}}
3136  
3137      // {{{ getAllInfosForDisplay($visiteurs, $connect_profil, &$tri, &$auteurs, &$nombre_auteurs)
3138  
3139      /**
3140       * get All infos for display list of writters.
3141       *
3142       *
3143       * @return tri, auteurs and nombre_auteurs
3144       * @param $visiteur
3145       * @param $connect_statut
3146       * @param $tri
3147       * @param $auteurs
3148       * @param $nombre_auteurs
3149  
3150       * @access public
3151       */
3152  
3153  	function getAllInfosForDisplay ($visiteurs, $connect_profil, &$tri, &$auteurs, &$nombre_auteurs) {
3154          $db = &$this->_getDB();
3155  
3156          if (DB::isError($db)) {
3157              return PEAR::raiseError(
3158                         "[" . get_class($this). " DB_auteur : getAllInfosForDisplay()] " . $db->getMessage(). "", null,
3159                         null, null,
3160                         null, null,
3161                         false);
3162          }
3163  
3164          //
3165          // Construire la requete
3166          //
3167  
3168          // limiter les statuts affiches
3169          $profilMetier         = &recuperer_instance_profil();
3170          $profilPoubelle         = $profilMetier->getProfilForIntitule('texte_statut_poubelle');
3171          $profilVisiteur         = $profilMetier->getProfilForIntitule('item_non_abonne');
3172          $profilRedacteur     = $profilMetier->getProfilForIntitule('item_redacteur');
3173          $profilRedacteurEnChef = $profilMetier->getProfilForIntitule('item_redacteur_en_chef');
3174          $profilWebmestre     = $profilMetier->getProfilForIntitule('item_webmestre');
3175          $profilAdministrateur = $profilMetier->getProfilForIntitule('item_administrateur');
3176  
3177          $authorization = &recuperer_instance_authorization('afficherAuteursVisiteurs', 
3178                                                          $GLOBALS['connect_id_auteur'],
3179                                                          array('visiteurs' => $visiteurs));
3180  
3181          if ($authorization->isAuthorizedAction()) {
3182              $sql_statut_auteurs = " AND auteurs.statut like 'forum' OR auteurs.profil IN (".$profilPoubelle->getPoids().")";
3183              $sql_statut_articles = '';
3184              $tri = 'nom';
3185          }
3186          else {
3187              $authorization = &recuperer_instance_authorization('afficherAuteurs', $GLOBALS['connect_id_auteur']);
3188              if ($authorization->isAuthorizedAction()) {
3189                  $sql_statut_auteurs
3190                      = " AND auteurs.profil IN (" . $profilAdministrateur->getPoids(). ", " .
3191                                              $profilWebmestre->getPoids(). ", " .
3192                                              $profilRedacteurEnChef->getPoids(). ", " . 
3193                                              $profilRedacteur->getPoids(). ")";
3194                  $sql_statut_articles = " AND articles.statut IN ('prop', 'publie')";
3195              }
3196              else {
3197                  $sql_statut_auteurs
3198                      = " AND auteurs.profil IN (" . $profilAdministrateur->getPoids(). ", " . 
3199                                              $profilWebmestre->getPoids(). ", " . 
3200                                              $profilRedacteurEnChef->getPoids(). ", " . 
3201                                              $profilRedacteur->getPoids(). ", " . 
3202                                              $profilPoubelle->getPoids(). ")";
3203                  $sql_statut_articles = "";
3204              }
3205          }
3206          // tri
3207          switch ($tri) {
3208              case 'nombre':
3209                  $sql_order = ' ORDER BY compteur DESC, nom';
3210                  $type_requete = 'nombre';
3211                  break;
3212  
3213              case 'statut':
3214                  $sql_order = ' ORDER BY auteurs.profil, nom';
3215                  $type_requete = 'auteur';
3216                  break;
3217  
3218         case 'login':
3219                $sql_order = ' ORDER BY login';
3220                $type_requete = 'auteur';
3221                break;
3222          
3223              case 'nom':
3224              default:
3225                  $sql_order = ' ORDER BY nom';
3226                  $type_requete = 'auteur';
3227          }
3228  
3229          // si on doit afficher les auteurs par statut ou par nom,
3230          // la requete principale est simple, et une autre requete
3231          // vient calculer les nombres d'articles publies ;
3232          // si en revanche on doit classer par nombre, la bonne requete
3233          // est la concatenation de $query_nombres et de $query_auteurs
3234  
3235          $auteurs = array();
3236  
3237          if ($type_requete == 'auteur') {
3238              $query
3239                  = "SELECT id_auteur, nom, bio, email, nom_site, url_site, login, pass, statut, profil, maj, pgp, htpass, en_ligne , imessage, messagerie, alea_actuel, alea_futur, prefs, cookie_oubli, source " . 
3240                    " FROM " . $GLOBALS['table_prefix']. "_auteurs auteurs " .
3241                    "WHERE 1=1 $sql_statut_auteurs    $sql_order";
3242  
3243              $queryResult = $db->query($query);
3244  
3245              if (DB::isError($queryResult)) {
3246                  return PEAR::raiseError(
3247                             "[" . get_class(
3248                                       $this). " DB_auteur : getAllInfosForDisplay()] " . $queryResult->getMessage(). "",
3249                             null,
3250                             null,
3251                             null,
3252                             null,
3253                             null,
3254                             false);
3255              }
3256  
3257              while ($row = $queryResult->fetchRow()) {
3258                  $auteurs[$row['id_auteur']] = $row;
3259                  $nombre_auteurs++;
3260  
3261                  $nom_auteur = strtoupper($row['nom']);
3262                  $premiere_lettre = addslashes(strtoupper(substr($nom_auteur, 0, 1)));
3263  
3264                  if ($premiere_lettre != $lettre_prec) {
3265                      $lettre[$premiere_lettre] = $nombre_auteurs;
3266                  }
3267                  $lettre_prec = $premiere_lettre;
3268              }
3269  
3270              $queryResult->free();
3271  
3272              $query = "SELECT auteurs.id_auteur, UPPER(auteurs.nom) AS nom, COUNT(articles.id_article) AS compteur " .
3273                          "FROM " . $GLOBALS['table_prefix']. "_auteurs auteurs, " . $GLOBALS['table_prefix']. "_auteurs_articles lien, " . $GLOBALS['table_prefix']. "_articles articles " .
3274                          "WHERE auteurs.id_auteur = lien.id_auteur " .
3275                          "AND lien.id_article = articles.id_article $sql_statut_auteurs $sql_statut_articles " .
3276                          "GROUP BY auteurs.id_auteur, auteurs.profil, nom $sql_order";
3277  
3278              $queryResult = $db->query($query);
3279  
3280              if (DB::isError($queryResult)) {
3281                  return PEAR::raiseError(
3282                             "[" . get_class(
3283                                       $this). " DB_auteur : getAllInfosForDisplay()] " . $queryResult->getMessage(). "",
3284                             null,
3285                             null,
3286                             null,
3287                             null,
3288                             null,
3289                             false);
3290              }
3291  
3292              while ($row = $queryResult->fetchRow())
3293                  $auteurs[$row['id_auteur']]['compteur'] = $row['compteur'];
3294  
3295              $queryResult->free();
3296  
3297              // si on n'est pas minirezo, supprimer les auteurs sans article publie
3298              // sauf les admins, toujours visibles.
3299              // TODO : on ne devrait pas checker les autorisations ici 
3300              $authorization = &recuperer_instance_authorization('afficherNombreArticle', $GLOBALS['connect_id_auteur']);
3301              if (!$authorization->isAuthorizedAction()) {
3302              }
3303          }
3304          else { // tri par nombre
3305  
3306              $profilMetier = &recuperer_instance_profil();
3307              $allProfils = $profilMetier->getAllProfils();
3308  
3309              if (PEAR::isError($allProfils)) {
3310                  die($allProfils->getMessage());
3311              }
3312  
3313              while (list(, $monProfil) = each($allProfils)) {
3314                  $poids[] = $monProfil->getPoids();
3315              }
3316        // ***************** Debut modification anpe.fr *************************
3317              $query = "SELECT auteurs.id_auteur, auteurs.nom, auteurs.login, auteurs.url_site, auteurs.email, auteurs.statut, auteurs.profil,  ".
3318                "COUNT(articles.id_article) AS compteur ".
3319                "FROM ".$GLOBALS['table_prefix']."_auteurs auteurs, ".$GLOBALS['table_prefix']."_auteurs_articles lien, ".$GLOBALS['table_prefix']."_articles articles ".
3320                "WHERE auteurs.id_auteur=lien.id_auteur AND lien.id_article=articles.id_article AND auteurs.profil IN (" . join(",", $poids) . ") ".
3321                "GROUP BY auteurs.id_auteur, auteurs.nom, auteurs.url_site, auteurs.email, auteurs.statut, auteurs.profil ".
3322                "ORDER BY compteur DESC, auteurs.nom ASC";
3323              /*
3324              $query = "SELECT auteurs.id_auteur, auteurs.nom, auteurs.url_site, auteurs.email, auteurs.statut, auteurs.profil, " .
3325                      "COUNT(articles.id_article) AS compteur " .
3326                      "FROM " . $GLOBALS['table_prefix']. "_auteurs auteurs, " . $GLOBALS['table_prefix']. "_auteurs_articles lien, " . $GLOBALS['table_prefix']. "_articles articles " .
3327                      "WHERE auteurs.id_auteur=lien.id_auteur AND lien.id_article=articles.id_article AND auteurs.profil IN (" . join(",", $poids). ") " .
3328                      "GROUP BY auteurs.id_auteur, auteurs.nom, auteurs.url_site, auteurs.email, auteurs.statut, auteurs.profil " .
3329                      "ORDER BY compteur DESC, auteurs.nom ASC";
3330        */
3331              // ***************** Fin modification anpe.fr ***************************
3332  
3333              //echo "<br>$query<br>";
3334              $queryResult = $db->query($query);
3335  
3336              if (DB::isError($queryResult)) {
3337                  return PEAR::raiseError(
3338                             "[" . get_class(
3339                                       $this). " DB_auteur : getAllInfosForDisplay()] " . $queryResult->getMessage(). "",
3340                             null,
3341                             null,
3342                             null,
3343                             null,
3344                             null,
3345                             false);
3346              }
3347  
3348              unset($vus);
3349  
3350              while ($row = $queryResult->fetchRow()) {
3351                  $auteurs[$row['id_auteur']] = $row;
3352                  $vus .= ',' . $row['id_auteur'];
3353                  $nombre_auteurs++;
3354              }
3355  
3356              $queryResult->free();
3357  
3358              // si on est admin, ajouter tous les auteurs sans articles
3359              // sinon ajouter seulement les admins sans articles
3360              $authorization = &recuperer_instance_authorization('afficherNombreArticle', $GLOBALS['connect_id_auteur']);
3361  
3362              if ($authorization->isAuthorizedAction())
3363                  $sql_statut_auteurs_ajout = $sql_statut_auteurs;
3364              else {
3365                  $profilMetier = &recuperer_instance_profil();
3366                  $monProfil8 = $profilMetier->getProfilForIntitule('item_administrateur');
3367                  $monProfil4 = $profilMetier->getProfilForIntitule('item_webmestre');
3368                  $sql_statut_auteurs_ajout = " AND auteurs.profil IN (" . $monProfil8->getPoids(). "," . $monProfil4->getPoids(). ")";
3369              }
3370  
3371              $query = "SELECT auteurs.*, UPPER(nom), 0 as compteur " .
3372                      "FROM " . $GLOBALS['table_prefix']. "_auteurs auteurs " .
3373                      "WHERE id_auteur NOT IN (0$vus) $sql_statut_auteurs_ajout $sql_order";
3374              //echo $query;
3375  
3376              $queryResult = $db->query($query);
3377  
3378              if (DB::isError($queryResult)) {
3379                  return PEAR::raiseError(
3380                             "[" . get_class(
3381                                       $this). " DB_auteur : getAllInfosForDisplay()] " . $queryResult->getMessage(). "",
3382                             null,
3383                             null,
3384                             null,
3385                             null,
3386                             null,
3387                             false);
3388              }
3389  
3390              while ($row = $queryResult->fetchRow()) {
3391                  $auteurs[$row['id_auteur']] = $row;
3392                  $nombre_auteurs++;
3393              }
3394              $queryResult->free();
3395          }
3396  
3397          unset($rub_restreinte);
3398          $authorization = &recuperer_instance_authorization('afficherAdminRestreint', 
3399                                                          $GLOBALS['connect_id_auteur']);
3400  
3401          if ($authorization->isAuthorizedAction()) { // recuperer les admins restreints
3402              $rubriqueMetier = &recuperer_instance_rubrique();
3403              $rub_restreinte = $rubriqueMetier->getAllAuteurRubrique();
3404              if (PEAR::isError($rub_restreinte)) {
3405                  die($rub_restreinte->getMessage());
3406              }
3407          }
3408  
3409          return $lettre;
3410      }
3411  
3412      // }}}
3413  
3414      /**
3415       * Returns an array of Autors.
3416       *
3417       *
3418       * @return an array of Autors
3419       * @param $email
3420       * @access public
3421       */
3422  
3423      function &getAllForLoginAndNotAuteurIdAndNotStatut ($login, $id_auteur, $statut) {
3424          $result = array();
3425          $db = &$this->_getDB();
3426  
3427          if (DB::isError($db)) {
3428              return PEAR::raiseError(
3429                         "[" . get_class(
3430                                   $this). " DB_auteur : getAllForLoginAndNotAuteurIdAndNotStatut()] " . $db->getMessage(). "",
3431                         null,
3432                         null,
3433                         null,
3434                         null,
3435                         null,
3436                         false);
3437          }
3438  
3439          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
3440                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
3441                  "WHERE login='" . addslashes($login). 
3442                  "' AND id_auteur!=$id_auteur AND statut!='$statut'";
3443  
3444          $queryResult = $db->query($query);
3445  
3446          if (DB::isError($queryResult)) {
3447              return PEAR::raiseError(
3448                         "[" . get_class(
3449                                   $this). " DB_auteur : getAllForLoginAndNotAuteurIdAndNotStatut()] " . $queryResult->getMessage(). "",
3450                         null,
3451                         null,
3452                         null,
3453                         null,
3454                         null,
3455                         false);
3456          }
3457  
3458          while ($row = $queryResult->fetchRow()) {
3459              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
3460  
3461              $maDate = new Date($row['maj']);
3462              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
3463  
3464              $resultAuteur->_fetchData($row);
3465              $result[] = &$resultAuteur;
3466          }
3467  
3468          $queryResult->free();
3469          return $result;
3470      }
3471  
3472      // }}}
3473  
3474      /**
3475       * Returns an array of Autors.
3476       *
3477       *
3478       * @return an array of Autors
3479       * @param $email
3480       * @access public
3481       */
3482  
3483      function &getAllForLoginAndNotAuteurIdAndNotProfil ($login, $id_auteur, $profil) {
3484          $result = array();
3485          $db = &$this->_getDB();
3486  
3487          if (DB::isError($db)) {
3488              return PEAR::raiseError(
3489                         "[" . get_class(
3490                                   $this). " DB_auteur : getAllForLoginAndNotAuteurIdAndNotStatut()] " . $db->getMessage(). "",
3491                         null,
3492                         null,
3493                         null,
3494                         null,
3495                         null,
3496                         false);
3497          }
3498  
3499          $profilMetier = &recuperer_instance_profil();
3500          $monProfil = $profilMetier->getProfilForIntitule($profil);
3501          $query = "SELECT " . AUTEUR_ALL_FIELDS . 
3502                  " FROM " . $GLOBALS['table_prefix']. "_auteurs " .
3503                  "WHERE login='" . addslashes($login). "' " .
3504                  "AND id_auteur!=$id_auteur AND profil!=" . $monProfil->getPoids();
3505  
3506          //echo $query;
3507  
3508          $queryResult = $db->query($query);
3509  
3510          if (DB::isError($queryResult)) {
3511              return PEAR::raiseError(
3512                         "[" . get_class(
3513                                   $this). " DB_auteur : getAllForLoginAndNotAuteurIdAndNotStatut()] " . $queryResult->getMessage(). "",
3514                         null,
3515                         null,
3516                         null,
3517                         null,
3518                         null,
3519                         false);
3520          }
3521  
3522          while ($row = $queryResult->fetchRow()) {
3523              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
3524  
3525              $maDate = new Date($row['maj']);
3526              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
3527  
3528              $resultAuteur->_fetchData($row);
3529              $result[] = &$resultAuteur;
3530          }
3531  
3532          $queryResult->free();
3533          return $result;
3534      }
3535  
3536      // }}}
3537  
3538      // {{{ createIgnore()
3539  
3540  	function createIgnore () {
3541          $db = &$this->_getDB();
3542  
3543          if (DB::isError($db)) {
3544              return PEAR::raiseError("[" . get_class($this). " DB_auteur : createIgnore()] " . $db->getMessage(). "",
3545                                      null,
3546                                      null,
3547                                      null,
3548                                      null,
3549                                      null,
3550                                      false);
3551          }
3552  
3553          $string_prefix = $GLOBALS['table_prefix']. "_auteurs";
3554          $auteurId = $db->nextId($string_prefix, true);
3555  
3556          if (DB::isError($auteurId)) {
3557              return PEAR::raiseError(
3558                         "[" . get_class($this). " DB_auteur : createIgnore()] " . $auteurId->getMessage(). "", null,
3559                         null, null,
3560                         null, null,
3561                         false);
3562          }
3563  
3564          $this->_auteurId = $auteurId;
3565  
3566          $query = "SELECT id_auteur " .
3567                  "FROM " . $GLOBALS['table_prefix']. "_auteurs " .
3568                  "WHERE id_auteur=" . $this->_auteurId . "";
3569  
3570          $result = $db->getOne($query);
3571  
3572          if (DB::isError($result)) {
3573              return PEAR::raiseError("[" . get_class($this). " DB_auteur : createIgnore()] " . $result->getMessage(). "",
3574                                      null,
3575                                      null,
3576                                      null,
3577                                      null,
3578                                      null,
3579                                      false);
3580          }
3581  
3582          if ($result->numRows() == 0) {
3583              $query = "INSERT INTO " . $GLOBALS['table_prefix']. "_auteurs (" . AUTEUR_ALL_FIELDS . ") " .
3584                      "VALUES " . "(" . $this->_auteurId . ", " . 
3585                                  "'" . $db->quoteString($this->_nom). "', " . 
3586                                  "'" . $db->quoteString($this->_bio). "', " . 
3587                                  "'" . $db->quoteString($this->_email). "', " . 
3588                                  "'" . $db->quoteString($this->_nomSite). "', " . 
3589                                  "'" . $db->quoteString($this->_urlSite). "', " . 
3590                                  "'" . $db->quoteString($this->_login). "', " . 
3591                                  "'" . $db->quoteString($this->_pass). "', " . 
3592                                  "'" . $db->quoteString($this->_statut). "', " . 
3593                                  "'" . $db->quoteString($this->_maj). "', " . 
3594                                  "'" . $db->quoteString($this->_pgp). "', " . 
3595                                  "'" . $db->quoteString($this->_htpass). "', " . 
3596                                  "'" . $db->quoteString($this->_enLigne). "', " . 
3597                                  "'" . $db->quoteString($this->_imessage). "', " . 
3598                                  "'" . $db->quoteString($this->_messagerie). "', " . 
3599                                  "'" . $db->quoteString($this->_aleaActuel). "', " . 
3600                                  "'" . $db->quoteString($this->_aleaFutur). "', " . 
3601                                  "'" . $db->quoteString($this->_prefs). "', " . 
3602                                  "'" . $db->quoteString($this->_cookieOubli). "', " . 
3603                                  "'" . $db->quoteString($this->_source). "')";
3604  
3605              $result = $db->query($query);
3606              if (DB::isError($result)) {
3607                  return PEAR::raiseError(
3608                             "[" . get_class($this). " DB_auteur : createIgnore()] " . $result->getMessage(). "", null,
3609                             null, null,
3610                             null, null,
3611                             false);
3612              }
3613          }
3614      }
3615  
3616      // }}}
3617  
3618      // {{{ getAllConnections($auteurId)
3619  
3620      /**
3621       * This method returns all Connections
3622       * @param auteurId
3623       * @return  int
3624       * @access  public
3625       */
3626      function &getAllConnections ($auteurId) {
3627          $result = array();
3628          $db = &$this->_getDB();
3629  
3630          if (DB::isError($db)) {
3631              return PEAR::raiseError(
3632                         "[" . get_class($this). " DB_auteur : getAllConnections()] " . $db->getMessage(). "", null, null,
3633                         null, null, null,
3634                         false);
3635          }
3636  
3637          $maDate = new Date();
3638          $maDate->subtractSeconds(intval(5 * 60));
3639  
3640          $query
3641              = "SELECT " . AUTEUR_ALL_FIELDS . " FROM " . $GLOBALS['table_prefix']. "_auteurs WHERE id_auteur!=$auteurId AND imessage!='non' AND messagerie!='non' AND en_ligne>'" . $maDate->getDate(
3642                                                                                                                                                                                          DATE_FORMAT_ISO). "'";
3643          //echo $query.'<br>';
3644          //$query = "SELECT id_auteur, nom FROM ".$GLOBALS['table_prefix']."_auteurs WHERE id_auteur!=$auteurId AND imessage!='non' AND messagerie!='non' AND en_ligne>DATE_SUB(NOW(),INTERVAL 5 MINUTE)";
3645  
3646          $queryResult = $db->query($query);
3647  
3648          if (DB::isError($queryResult)) {
3649              return PEAR::raiseError(
3650                         "[" . get_class($this). " DB_auteur : getAllConnections()] " . $queryResult->getMessage(). "",
3651                         null,
3652                         null,
3653                         null,
3654                         null,
3655                         null,
3656                         false);
3657          }
3658  
3659          while ($row = $queryResult->fetchRow()) {
3660              $resultAuteur = &BD_auteur::factory($this->getDbParameters(), $this->getDbOptions());
3661  
3662              $maDate = new Date($row['maj']);
3663              $row['maj'] = $maDate->getDate(DATE_FORMAT_TIMESTAMP);
3664  
3665              $resultAuteur->_fetchData($row);
3666              $result[] = &$resultAuteur;
3667          }
3668  
3669          $queryResult->free();
3670          return $result;
3671      }
3672  
3673      // }}}
3674  
3675      /** Renvoie l'id de la première rubrique pour laquelle l'auteur à des droits.
3676       * @param      int      $id_rubrique_parente
3677       * @return     int
3678       * @todo       J'ai comme l'impression que l'algo n'est pas optimal...
3679       *             Si l'auteur n'a pas de droits sur la première rubrique testée, on descend dans
3680       *             l'arbo de ladite rubrique au lieu de tester auparavant les rubriques du même niveau.
3681       */
3682  	function getPremiereRubrique ($id_rubrique_parente = 0) {
3683          $rubrique = &recuperer_instance_rubrique();
3684          $rubriques_filles = $rubrique->getAllForParentId($id_rubrique_parente);
3685  
3686          foreach ($rubriques_filles as $rub) {
3687              $rub_id = $rub->getRubriqueId();
3688              $auth = &recuperer_instance_authorization('isManagedRubriqueByAuteurId', $this->getAuteurId(),
3689                                                        array('rubriqueId' => $rub_id));
3690              if ($auth->isAuthorizedAction()) {
3691                  return $rub_id;
3692              }
3693              else {
3694                  return $this->getPremiereRubrique($rub_id);
3695              }
3696          }
3697      }
3698  }
3699  ?>


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