[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/bookmarks/ -> bookmark.class.php (source)

   1  <?php
   2  /* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program 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.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: bookmark.class.php,v 1.2 2005/09/02 21:57:49 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/bookmarks/bookmark.class.php,v $
  20   */
  21  
  22  /**
  23          \file       htdocs/bookmarks/bookmark.class.php
  24          \ingroup    bookmark
  25          \brief      Fichier de la classe des bookmark
  26          \version    $Revision: 1.2 $
  27  */
  28  
  29  
  30  /**
  31          \class      Bookmark
  32          \brief      Classe permettant la gestion des bookmarks
  33  */
  34  
  35  class Bookmark
  36  {
  37      var $db;
  38  
  39      var $id;
  40      var $fk_user;
  41      var $datec;
  42      var $url;
  43      var $target;
  44      var $title;
  45      var $favicon;
  46  
  47      /**
  48       *    \brief      Constructeur
  49       *    \param      db          Handler d'accès base de données
  50       *    \param      id          Id du bookmark
  51       */
  52      function Bookmark($db, $id=-1)
  53      {
  54          $this->db = $db;
  55          $this->id = $id;
  56      }
  57  
  58      /**
  59       *    \brief      Charge le bookmark
  60       *    \param      id          Id du bookmark à charger
  61       */
  62      function fetch($id)
  63      {
  64          $sql = "SELECT rowid, fk_user, ".$this->db->pdate("dateb").", url, target,";
  65          $sql.= " title, favicon";
  66          $sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
  67          $sql.= " WHERE rowid = ".$id;
  68  
  69          $resql  = $this->db->query ($sql);
  70  
  71          if ($resql)
  72          {
  73              $obj = $this->db->fetch_object($resql);
  74  
  75              $this->id       = $obj->rowid;
  76              $this->fk_user = $obj->fk_user;
  77              $this->datec   = $obj->datec;
  78              $this->url     = $obj->url;
  79              $this->target  = $obj->target;
  80              $this->title   = stripslashes($obj->title);
  81              $this->favicon = $obj->favicon;
  82  
  83              $this->db->free($resql);
  84              return $this->id;
  85          }
  86          else
  87          {
  88              dolibarr_print_error ($this->db);
  89              return -1;
  90          }
  91      }
  92  
  93      /**
  94       *      \brief      Insere bookmark en base
  95       *      \return     int     <0 si ko, rowid du bookmark créé si ok
  96       */
  97      function create()
  98      {
  99          $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
 100          $sql.= " ,title,favicon";
 101          if ($this->fk_soc) $sql.=",fk_soc";
 102          $sql.= ")";
 103          $sql.= " VALUES ('".$this->fk_user."', sysdate(),";
 104          $sql.= " '".$this->url."', '".$this->target."',";
 105          $sql.= " '".addslashes($this->title)."', '".$this->favicon."'";
 106          if ($this->fk_soc) $sql.=",".$this->fk_soc;
 107          $sql.= ")";
 108          $resql = $this->db->query ($sql);
 109  
 110          if ($resql)
 111          {
 112              $id = $this->db->last_insert_id (MAIN_DB_PREFIX."bookmark");
 113  
 114              if ($id > 0)
 115              {
 116                  $this->id = $id;
 117                  return $id;
 118              }
 119              else
 120              {
 121                  $this->error=$this->db->error();
 122                  return -2;
 123              }
 124          }
 125          else
 126          {
 127              dolibarr_print_error ($this->db);
 128              return -1;
 129          }
 130      }
 131  
 132      /**
 133       *      \brief      Mise à jour du bookmark
 134       *      \return     int         <0 si ko, >0 si ok
 135       */
 136      function update()
 137      {
 138          $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
 139          $sql.= " SET fk_user = '".$this->fk_user."'";
 140          $sql.= " ,dateb = '".$this->datec."'";
 141          $sql.= " ,url = '".$this->url."'";
 142          $sql.= " ,target = '".$this->target."'";
 143          $sql.= " ,title = '".$this->title."'";
 144          $sql.= " ,favicon = '".$this->favicon."'";
 145          $sql.= " WHERE rowid = ".$this->id;
 146  
 147          if ($this->db->query ($sql))
 148          {
 149              return 1;
 150          }
 151          else
 152          {
 153              $this->error=$this->db->error();
 154              return -1;
 155          }
 156      }
 157  
 158      /**
 159       *      \brief      Supprime le bookmark
 160       *      \param      id          Id bookmark à supprimer
 161       *      \return     int         <0 si ko, >0 si ok
 162       */
 163      function remove($id)
 164      {
 165          $sql  = "DELETE FROM ".MAIN_DB_PREFIX."bookmark";
 166          $sql .= " WHERE rowid = ".$id;
 167          
 168          $resql=$this->db->query ($sql);
 169          if ($resql)
 170          {
 171              return 1;
 172          }
 173          else
 174          {
 175              $this->error=$this->db->error();
 176              return -1;
 177          }
 178  
 179      }
 180  
 181  }
 182  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics