<?php
/*
* This file is part of the Booby project.
* The booby project is located at the following location:
* http://www.nauta.be/booby/
*
* Booby - Copyright (c) 2003 - 2004 Barry Nauta
*
* The Booby project is released under the General Public License
* More detailes in the file 'gpl.html' or on the following
* website: http://www.gnu.org and look for licenses
*
* Enjoy :-)
*/
require_once ('plugins/bookmarks/model/Bookmark.php');
require_once ('plugins/bookmarks/model/BookmarkFactory.php');
require_once ('base/model/Services.php');
/**
* Bookmark operations. The BusinessLogic operations that can be
* performed on Bookmarks
*
* @author Barry Nauta February 2003
* @package be.nauta.booby.plugins.bookmarks.model
* @copyright
*
* Copyright (c) 2003 - 2004 Barry Nauta
*
* The Booby project is released under the General Public License
* More detailes on the following
* website: <code>http://www.gnu.org</code>
* and look for licenses
*/
class BookmarkServices extends Services
{
/**
* Default constructor
*/
function BookmarkServices ()
{
parent :: Services ();
$this->itemFactory = new BookmarkFactory ();
include ('plugins/bookmarks/sql/bookmarkQueries.php');
$this->queries = $queries;
}
/**
* Adds a bookmark for a user
*
* @param integer userId the identifier for the user
* @param object item the bookmark to be added
*/
function addItem ($userId, $item)
{
global $db;
$now = date ("Y-m-d H:i:s");
$query = sprintf ($this->queries['addItem'],
$userId,
$this->stringUtils->gpcAddSlashes ($item->parentId),
$this->stringUtils->gpcAddSlashes ($item->isParent),
$this->stringUtils->gpcAddSlashes ($item->name),
$this->stringUtils->gpcAddSlashes ($item->description),
$this->stringUtils->gpcAddSlashes ($item->visibility),
$this->stringUtils->gpcAddSlashes ($item->category),
$this->stringUtils->gpcAddSlashes ($now),
$this->stringUtils->gpcAddSlashes ($item->locator));
$db->Execute ($query) or die ('AddBookmark: not able to add
bookmark ' . $query . " " . $db->ErrorMsg());
$query = $this->queries['lastItemInsertId'];
$result=$db->Execute($query)
or die ("addBookmark: " .$db->ErrorMsg () . " " . $query);
return $result->fields[0];
}
/**
* Modifies a bookmark
* @param integer userId the identifier of the user who modifies
* a bookmark
* @param object item the modified bookmark
* @todo Do we really need the userId?
*/
function modifyItem ($userId, $item)
{
global $db;
$now = date ("Y-m-d H:i:s");
$query = sprintf ($this->queries['modifyItem'],
$now,
$this->stringUtils->gpcAddSlashes ($item->name),
$this->stringUtils->gpcAddSlashes ($item->parentId),
$this->stringUtils->gpcAddSlashes (trim($item->description)),
$this->stringUtils->gpcAddSlashes ($item->locator),
$item->visibility,
$item->itemId);
$result = $db->Execute ($query) or die
("ModifyItem Error: " .
$db->ErrorMsg () . " " . $query);
}
/**
* Updates the visite count for a specific user and its itemId
* @param integer userId the identifier for the user
* @itemId integer itemId the identifier for the item for which we would like to
* update its visit count
* @todo Do we really need the userId?
*/
function updateVisiteCount ($userId, $itemId)
{
parent::updateVisiteCount($userId, $itemId);
global $db;
$now = date ("Y-m-d H:i:s");
// now add last visit information
$query = sprintf ($this->queries['updateVisitedInformation'],
$now, $itemId);
$result = $db->Execute ($query) or die
("UpdateVisiteCOunt Error: " . $db->ErrorMsg () . " " . $query);
}
}
?>