MCMS
[ class tree: MCMS ] [ index: MCMS ] [ all elements ]

Source for file Author.php

Documentation is available at Author.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | MCMS: a PHP Content Management System for creating accessible sites. |
  5. // | Copyright (C) 2005  Silvio Moioli                                    |
  6. // |                                                                      |
  7. // | This program is free software; you can redistribute it and/or modify |
  8. // | it under the terms of the GNU General Public License as published by |
  9. // | the Free Software Foundation; either version 2 of the License, or    |
  10. // | (at your option) any later version.                                  |
  11. // |                                                                      |
  12. // | This program is distributed in the hope that it will be useful,      |
  13. // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  14. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  15. // | GNU General Public License for more details.                         |
  16. // |                                                                      |
  17. // | You should have received a copy of the GNU General Public License    |
  18. // | along with this program; if not, write to the Free Software          |
  19. // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
  20. // +----------------------------------------------------------------------+
  21. // | Authors: Silvio Moioli <silvio at moioli dot net> www.moioli.net     |
  22. // +----------------------------------------------------------------------+
  23. //
  24. //$Id:
  25. /**
  26.  * Interfaccia per la gestione degli autori dei siti gestiti da MCMS.
  27.  *
  28.  * @package  MCMS
  29.  * @version  2
  30.  * @author   Silvio Moioli <silvio at moioli dot net>
  31.  *
  32.  */
  33.  
  34. /** Carica la classe base di MCMS per l'interfacciamento al Database */
  35. require_once $_SERVER["DOCUMENT_ROOT"]."/admin/lib/model/Engine.php";
  36.  
  37. /**
  38.  * Interfaccia per la gestione degli autori dei siti gestiti da MCMS.
  39.  *
  40.  * Permette di gestire tutti i dettagli di un autore di uno o più
  41.  * siti, articoli o notizie.
  42.  * 
  43.  * @package  MCMS
  44.  * @version  2
  45.  * @author   Silvio Moioli <silvio at moioli dot net>
  46.  *
  47.  */
  48.  
  49. class Author extends PEAR
  50. {
  51.     //Attributi
  52.         /**
  53.      * @var int $ID ID del database sottostante per questo sito.
  54.      */
  55.     var $ID = 0;
  56.     /**
  57.      * @var Engine il motore del database sottostante per questo sito.
  58.      */
  59.     var $engine = NULL;
  60.  
  61.     //Costruttori   
  62.         /**
  63.      * Costruttore di lettura
  64.      *
  65.      * Costruttore "di lettura" (costruisce un autore da un record del
  66.      * database già esistente).
  67.      * Nota: non può essere creato una nuovo autore da qui, ma solo dal Factory
  68.      * Method nella classe Engine.
  69.      * Per i costruttori "di scrittura", quindi, vedere la classe Engine
  70.      * nel file Engine.php.
  71.      *
  72.      * @param int $ID l'ID del database sottostante
  73.      * @param Engine $engine un motore per interagire con il database
  74.      *  sottostante
  75.      * @return mixed l'autore se la costruzione è andata a buon fine, altrimenti
  76.      *  un PEAR_Error
  77.      * @see Engine
  78.      */
  79.     function Author($ID$engine)
  80.     {
  81.         if (settype($ID"integer"&& $ID>0){
  82.              $this->ID = $ID;
  83.              $this->engine = $engine;
  84.         }
  85.     }
  86.     
  87.     //Metodi
  88.         /**
  89.      * Ritorna l'ID di questo autore.
  90.      * 
  91.      * Solo le classi del package MCMS potrebbero avere bisogno di
  92.      * questo parametro, per le interrogazioni al Database.
  93.      *
  94.      * @access protected
  95.      * @return int l'ID del database sottostante
  96.      */
  97.      function getID()
  98.      {
  99.          return $this->ID;
  100.      }
  101.      
  102.     /**
  103.      * Ritorna il motore sottostante a questo autore.
  104.      * 
  105.      * Solo le classi del package MCMS potrebbero avere bisogno di
  106.      * questo parametro, per le interrogazioni al Database.
  107.      *
  108.      * @access protected
  109.      * @return int l'ID del database sottostante
  110.      */
  111.      function getEngine()
  112.      {
  113.          return $this->engine;
  114.      }
  115.      
  116.     /**
  117.      * Getter per il campo Nome dalla tabella Autore.
  118.      * 
  119.      * Ritorna il nome di battesimo di questo autore.
  120.      *
  121.      * @return mixed il nome (string) se l'operazione è andata a
  122.      *  buon fine, altrimenti un DB_ERROR
  123.      */
  124.      function getName()
  125.      {
  126.         $thisEngine $this->getEngine();
  127.         $thisDB $thisEngine->getDB();
  128.         $thisID $thisDB->escapeSimple($this->getID());
  129.         $res $thisDB->getOne("SELECT `nome autore` FROM `autori`".
  130.                                "WHERE `id autore` = '$thisIDLIMIT 1;");
  131.         
  132.         #$thisDB->disconnect();
  133.         return $res;
  134.      }
  135.      
  136.     /**
  137.      * Setter per il campo Nome dalla tabella Autore.
  138.      * 
  139.      * Cambia il nome di battesimo di questo autore
  140.      *
  141.      * @param string $name il nuovo nome
  142.      * @return mixed true se l'operazione è andata a buon fine, altrimenti
  143.      *  un DB_ERROR
  144.      */
  145.      function setName($name)
  146.      {
  147.         $thisEngine $this->getEngine();
  148.         $thisDB $thisEngine->getDB();
  149.         $thisID $thisDB->escapeSimple($this->getID());
  150.         $name $thisDB->escapeSimple($name);
  151.         $thisDB->query("UPDATE `autoriSET `nome autore`='$name'".
  152.                        "WHERE `id autore` = '$thisID';");
  153.         
  154.         #$thisDB->disconnect();
  155.         return true;
  156.      }   
  157.      
  158.     /**
  159.      * Getter per il campo Cognome dalla tabella Autore.
  160.      * 
  161.      * Ritorna il cognome di questo autore.
  162.      *
  163.      * @return mixed il cognome (string) se l'operazione è andata a
  164.      *  buon fine, altrimenti un DB_ERROR
  165.      */
  166.      function getSurname()
  167.      {
  168.         $thisEngine $this->getEngine();
  169.         $thisDB $thisEngine->getDB();
  170.         $thisID $thisDB->escapeSimple($this->getID());
  171.         $res $thisDB->getOne("SELECT `cognome autore` FROM `autori`".
  172.                                "WHERE `id autore` = '$thisIDLIMIT 1;");
  173.         
  174.         #$thisDB->disconnect();
  175.         return $res;
  176.      }
  177.      
  178.     /**
  179.      * Setter per il campo Cognome dalla tabella Autore.
  180.      * 
  181.      * Cambia il cognome di questo autore
  182.      *
  183.      * @param string $cognome il nuovo cognome
  184.      * @return mixed true se l'operazione è andata a buon fine, altrimenti
  185.      *  un DB_ERROR
  186.      */
  187.      function setSurname($cognome)
  188.      {
  189.         $thisEngine $this->getEngine();
  190.         $thisDB $thisEngine->getDB();
  191.         $thisID $thisDB->escapeSimple($this->getID());
  192.         $cognome $thisDB->escapeSimple($cognome);
  193.         $thisDB->query("UPDATE `autoriSET `cognome autore`='$cognome'".
  194.                        "WHERE `id autore` = '$thisID';");
  195.         
  196.         #$thisDB->disconnect();
  197.         return true;
  198.      
  199.      
  200.     /**
  201.      * Getter per il campo Nickname dalla tabella Autore.
  202.      * 
  203.      * Ritorna il nickname di questo autore.
  204.      *
  205.      * @return mixed il nickname (string) se l'operazione è andata a
  206.      *  buon fine, altrimenti un DB_ERROR
  207.      */
  208.      function getNick()
  209.      {
  210.         $thisEngine $this->getEngine();
  211.         $thisDB $thisEngine->getDB();
  212.         $thisID $thisDB->escapeSimple($this->getID());
  213.         $res $thisDB->getOne("SELECT `nick autore` FROM `autori`".
  214.                                "WHERE `id autore` = '$thisIDLIMIT 1;");
  215.         
  216.         #$thisDB->disconnect();
  217.         return $res;
  218.      }
  219.      
  220.     /**
  221.      * Setter per il campo Nickname dalla tabella Autore.
  222.      * 
  223.      * Cambia il nickname di questo autore
  224.      *
  225.      * @param string $nickname il nuovo nickname
  226.      * @return mixed true se l'operazione è andata a buon fine, altrimenti
  227.      *  un DB_ERROR
  228.      */
  229.      function setNick($nickname)
  230.      {
  231.         $thisEngine $this->getEngine();
  232.         $thisDB $thisEngine->getDB();
  233.         $thisID $thisDB->escapeSimple($this->getID());
  234.         $nickname $thisDB->escapeSimple($thisDB->escapeSimple($nickname));
  235.         $thisDB->query("UPDATE `autoriSET `nick autore`='$nickname'".
  236.                        "WHERE `id autore` = '$thisID';");
  237.         
  238.         #$thisDB->disconnect();
  239.         return true;
  240.      
  241.  
  242.      
  243.     /**
  244.      * Getter per il campo Email dalla tabella Autore.
  245.      * 
  246.      * Ritorna l'indirizzo email di questo autore.
  247.      *
  248.      * @return mixed l'indirizzo email (string) se l'operazione è andata a
  249.      *  buon fine, altrimenti un DB_ERROR
  250.      */
  251.      function getEmail()
  252.      {
  253.         $thisEngine $this->getEngine();
  254.         $thisDB $thisEngine->getDB();
  255.         $thisID $thisDB->escapeSimple($this->getID());
  256.         $res $thisDB->getOne("SELECT `email autore` FROM `autori`".
  257.                                "WHERE `id autore` = '$thisIDLIMIT 1;");
  258.         
  259.         #$thisDB->disconnect();
  260.         return $res;
  261.      }
  262.      
  263.     /**
  264.      * Setter per il campo Email dalla tabella Autore.
  265.      * 
  266.      * Cambia l'indirizzo email di questo autore.
  267.      *
  268.      * @param string $email il nuovo indirizzo
  269.      * @return mixed true se l'operazione è andata a buon fine, altrimenti
  270.      *  un DB_ERROR
  271.      */
  272.      function setEmail($email)
  273.      {
  274.         $thisEngine $this->getEngine();
  275.         $thisDB $thisEngine->getDB();
  276.         $thisID $thisDB->escapeSimple($this->getID());
  277.         $email $thisDB->escapeSimple($email);
  278.         $thisDB->query("UPDATE `autoriSET `email autore`='$email'".
  279.                        "WHERE `id autore` = '$thisID';");
  280.         
  281.         #$thisDB->disconnect();
  282.         return true;
  283.      
  284. }
  285. ?>

Documentation generated on Wed, 26 Jul 2006 21:44:49 +0200 by phpDocumentor 1.3.0RC6