[ 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/ -> bookmark4u.class.php (source)

   1  <?php
   2  /* Copyright (c) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   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: bookmark4u.class.php,v 1.6 2005/08/11 20:06:04 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/bookmark4u.class.php,v $
  20   */
  21  
  22  /**
  23          \file       htdocs/bookmark4u.class.php
  24          \brief      Fichier de la classe bookmark4u
  25          \author     Rodolphe Quiedeville
  26          \version    $Revision: 1.6 $
  27  */
  28  
  29  class Bookmark4u
  30  {
  31      var $db;
  32      
  33      var $id;
  34      
  35      
  36      /**
  37       *    \brief Constructeur de la classe
  38       *    \param  $DB         handler accès base de données
  39       *    \param  $id         id de l'utilisateur (0 par défaut)
  40       */
  41      function Bookmark4u(&$DB, $id=0)
  42      {
  43        $this->db = &$DB;
  44        $this->id = $id;
  45        return 1;
  46      }
  47      
  48      /**
  49       *
  50       *
  51       */
  52      function get_bk4u_uid($user)
  53      {
  54          $sql = "SELECT bk4u_uid FROM ".MAIN_DB_PREFIX."bookmark4u_login";
  55          $sql .= " WHERE fk_user =".$user->id;
  56      
  57          if ($this->db->query($sql))
  58          {
  59              $num = $this->db->num_rows();
  60      
  61              if ($num == 0)
  62              {
  63                  $this->uid = 0;
  64                  return 0;
  65              }
  66              else
  67              {
  68                  $row = $this->db->fetch_row();
  69      
  70                  $this->uid = $row[0];
  71                  return 0;
  72              }
  73      
  74              $this->db->free();
  75          }
  76          else
  77          {
  78              return 1;
  79          }
  80      }
  81      
  82      /**
  83       *
  84       *
  85       *
  86       */
  87      function get_bk4u_login()
  88      {
  89          $sql = "SELECT user FROM bookmark4u.bk4u_passwd";
  90          $sql .= " WHERE uid =".$this->uid;
  91      
  92          if ($this->db->query($sql))
  93          {
  94              $num = $this->db->num_rows();
  95      
  96              if ($num == 0)
  97              {
  98                  return 0;
  99              }
 100              else
 101              {
 102                  $row = $this->db->fetch_row();
 103      
 104                  $this->login = $row[0];
 105                  return 0;
 106              }
 107      
 108              $this->db->free();
 109          }
 110          else
 111          {
 112              return 1;
 113          }
 114      }
 115      
 116      
 117      
 118      /**
 119       *    \brief      Créé un compte bookmark4u
 120       *    \param      user    Objet du user
 121       *    \return     int     <0 si ko, >0 si ok
 122       */
 123      function create_account_from_user($user)
 124      {
 125          global $langs;
 126          // \todo rendre la base et la table générique
 127      
 128          $sql = "INSERT INTO bookmark4u.bk4u_passwd (user, passwd, name, email, logincnt, rdate)";
 129          $sql .= " VALUES ('$user->login',password('$user->pass'),'$user->fullname','$user->email',0,now());";
 130          $resql=$this->db->query($sql);
 131          if ($resql)
 132          {
 133              $this->uid = $this->db->last_insert_id("bookmark4u.bk4u_passwd");
 134      
 135              $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark4u_login";
 136              $sql .= " (fk_user, bk4u_uid)";
 137              $sql .= " VALUES ($user->id, $this->uid)";
 138      
 139              $resql2=$this->db->query($sql);
 140              if ($resql2)
 141              {
 142                  return 1;
 143              }
 144              else
 145              {
 146                  dolibarr_syslog("Bookmark4u::Create_account_from_user INSERT 2");
 147                  $this->error=$langs->trans("UnknownError");
 148                  return -2;
 149              }
 150          }
 151          else
 152          {
 153              dolibarr_syslog("Bookmark4u::Create_account_from_user INSERT 1");
 154              $this->error=$langs->trans("UnknownError");
 155              return -1;
 156          }
 157      
 158      }
 159  
 160  }
 161  ?>


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