From d5f09b7e4d802cdc2d5f3f876c48ea918c961488 Mon Sep 17 00:00:00 2001 From: cweiske Date: Sat, 3 Oct 2009 21:52:30 +0000 Subject: make the application work again git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@388 b3834d28-1941-0410-a4f8-b48e95affb8f --- src/SemanticScuttle/Service/Bookmark.php | 62 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'src/SemanticScuttle/Service/Bookmark.php') diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index f119593..6075a0d 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -1,23 +1,33 @@ db = & $db; + public function __construct($db) + { + $this->db = $db; $this->tablename = $GLOBALS['tableprefix'] .'bookmarks'; } function _getbookmark($fieldname, $value, $all = false) { if (!$all) { - $userservice = & ServiceFactory :: getServiceInstance('UserService'); + $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User'); $sId = $userservice->getCurrentUserId(); $range = ' AND uId = '. $sId; } else { @@ -51,7 +61,7 @@ class BookmarkService { if ($row = & $this->db->sql_fetchrow($dbresult)) { if ($include_tags) { - $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag'); $row['tags'] = $b2tservice->getTagsForBookmark($bid); } $output = $row; @@ -118,7 +128,7 @@ class BookmarkService { return false; } - $userservice = & ServiceFactory::getServiceInstance('UserService'); + $userservice = SemanticScuttle_Service_Factory::getServiceInstance('User'); $user = $userservice->getCurrentUser(); //user has to be either admin, or owner @@ -160,7 +170,7 @@ class BookmarkService { // Note that date is expected to be a string that's interpretable by strtotime(). function addBookmark($address, $title, $description, $privateNote, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false, $sId = -1) { if($sId == -1) { - $userservice = & ServiceFactory :: getServiceInstance('UserService'); + $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User'); $sId = $userservice->getCurrentUserId(); } @@ -204,7 +214,7 @@ class BookmarkService { $extension = end($uriparts); unset($uriparts); - $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag'); if (!$b2tservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not insert bookmark', '', __LINE__, __FILE__, $sql, $this->db); @@ -260,7 +270,7 @@ class BookmarkService { $extension = end($uriparts); unset($uriparts); - $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag'); if (!$b2tservice->attachTags($bId, $categories, $fromApi, $extension)) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not update bookmark', '', __LINE__, __FILE__, $sql, $this->db); @@ -282,9 +292,9 @@ class BookmarkService { // bookmarks; otherwise, just get the public bookmarks. // - if the $user is set and IS the logged-in user, then get all bookmarks. - $userservice =& ServiceFactory::getServiceInstance('UserService'); - $b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService'); - $tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService'); + $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User'); + $b2tservice =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark2Tag'); + $tag2tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag'); $sId = $userservice->getCurrentUserId(); if ($userservice->isLoggedOn()) { @@ -480,15 +490,15 @@ class BookmarkService { return true; } - function deleteBookmarksForUser($uId) { - $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks WHERE uId = '. intval($uId); - - if (!($dbresult = & $this->db->sql_query($query))) { - message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db); - return false; - } - - return true; + function deleteBookmarksForUser($uId) { + $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks WHERE uId = '. intval($uId); + + if (!($dbresult = & $this->db->sql_query($query))) { + message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + return true; } function countOthers($address) { @@ -496,7 +506,7 @@ class BookmarkService { return false; } - $userservice = & ServiceFactory :: getServiceInstance('UserService'); + $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User'); $sId = $userservice->getCurrentUserId(); if ($userservice->isLoggedOn()) { -- cgit v1.2.3-54-g00ecf