home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
- */
-
- class bookmarks extends db
- {
- function bookmarks()
- {
- $this->db();
- }
-
- function add_bookmark($user_id, $URL, $name, $new_window)
- {
- $url = htmlentities($URL);
- $name = htmlentities($name);
-
- if ($new_window == true)
- {
- $new_window = 1;
- }
- else
- {
- $new_window = 0;
- }
- $bookmark_id = $this->nextid("bookmarks");
- if ($bookmark_id > 0)
- {
- $sql = "INSERT INTO bookmarks (id, user_id, URL, name, new_window)";
- $sql .= " VALUES ('$bookmark_id', '$user_id', '".smart_addslashes($URL)."', '".smart_addslashes($name)."', '$new_window')";
- $this->query($sql);
- if ($this->affected_rows() > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }else
- {
- return false;
- }
- }
-
- function update_bookmark($bookmark_id, $URL, $name, $new_window)
- {
- if ($new_window == true)
- {
- $new_window = 1;
- }else
- {
- $new_window = 0;
- }
-
- $sql = "UPDATE bookmarks SET URL='".smart_addslashes($URL)."', name='".smart_addslashes($name)."', new_window='$new_window'";
- $sql .= " WHERE id='$bookmark_id'";
- return ($this->query($sql));
-
- }
-
- function delete_bookmark($user_id, $id)
- {
-
- $sql = "DELETE FROM bookmarks WHERE id='$id' AND user_id='$user_id'";
- $this->query($sql);
- if ($this->affected_rows() > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- function get_bookmarks($user_id)
- {
- $sql = "SELECT * FROM bookmarks WHERE user_id='$user_id' ORDER BY name ASC";
- $this->query($sql);
- return $this->num_rows();
- }
-
- function get_bookmark($bookmark_id)
- {
- $sql = "SELECT * FROM bookmarks WHERE id='$bookmark_id'";
- $this->query($sql);
- if($this->next_record())
- {
- return $this->Record;
- }
- return false;
- }
-
- function delete_user($user_id)
- {
- $this->get_bookmarks($user_id);
- $del = new bookmarks;
- while ($this->next_record())
- {
-
- $del->delete_bookmark($user_id, $this->f("id"));
- }
-
- }
- }
-