home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / classes / bookmarks.class.inc < prev    next >
Text File  |  2004-03-08  |  2KB  |  114 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. class bookmarks extends db
  14. {
  15.     function bookmarks()
  16.     {
  17.         $this->db();
  18.     }
  19.  
  20.     function add_bookmark($user_id, $URL, $name, $new_window)
  21.     {
  22.         $url = htmlentities($URL);
  23.         $name = htmlentities($name);
  24.  
  25.         if ($new_window == true)
  26.         {
  27.             $new_window = 1;
  28.         }
  29.         else
  30.         {
  31.             $new_window = 0;
  32.         }
  33.         $bookmark_id = $this->nextid("bookmarks");
  34.         if ($bookmark_id > 0)
  35.         {
  36.             $sql = "INSERT INTO bookmarks (id, user_id, URL, name, new_window)";
  37.             $sql .= " VALUES ('$bookmark_id', '$user_id', '".smart_addslashes($URL)."', '".smart_addslashes($name)."', '$new_window')";
  38.                $this->query($sql);
  39.             if ($this->affected_rows() > 0)
  40.             {
  41.                 return true;
  42.             }
  43.             else
  44.             {
  45.                 return false;
  46.             }
  47.         }else
  48.         {
  49.             return false;
  50.         }
  51.     }
  52.  
  53.     function update_bookmark($bookmark_id, $URL, $name, $new_window)
  54.     {
  55.         if ($new_window == true)
  56.         {
  57.             $new_window = 1;
  58.         }else
  59.         {
  60.             $new_window = 0;
  61.         }
  62.  
  63.         $sql = "UPDATE bookmarks SET URL='".smart_addslashes($URL)."', name='".smart_addslashes($name)."', new_window='$new_window'";
  64.         $sql .= " WHERE id='$bookmark_id'";
  65.         return ($this->query($sql));
  66.  
  67.     }
  68.  
  69.     function delete_bookmark($user_id, $id)
  70.     {
  71.  
  72.         $sql = "DELETE FROM bookmarks WHERE id='$id' AND user_id='$user_id'";
  73.         $this->query($sql);
  74.         if ($this->affected_rows() > 0)
  75.         {
  76.             return true;
  77.         }
  78.         else
  79.         {
  80.             return false;
  81.         }
  82.     }
  83.  
  84.     function get_bookmarks($user_id)
  85.     {
  86.         $sql = "SELECT * FROM bookmarks WHERE user_id='$user_id' ORDER BY name ASC";
  87.         $this->query($sql);
  88.         return $this->num_rows();
  89.     }
  90.  
  91.     function get_bookmark($bookmark_id)
  92.     {
  93.         $sql = "SELECT * FROM bookmarks WHERE id='$bookmark_id'";
  94.         $this->query($sql);
  95.         if($this->next_record())
  96.         {
  97.             return $this->Record;
  98.         }
  99.         return false;
  100.     }
  101.  
  102.     function delete_user($user_id)
  103.     {
  104.         $this->get_bookmarks($user_id);
  105.         $del = new bookmarks;
  106.         while ($this->next_record())
  107.         {
  108.  
  109.             $del->delete_bookmark($user_id, $this->f("id"));
  110.         }
  111.  
  112.     }
  113. }
  114.