Major refactoring: transform user into object, define parameters used into each file, ...
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@173 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
9aafe7551e
commit
15b91c7e66
51 changed files with 2247 additions and 1820 deletions
|
@ -19,6 +19,8 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
19
admin.php
19
admin.php
|
@ -18,7 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
$bookmark2tagservice = & ServiceFactory :: getServiceInstance('Bookmark2Tagservice');
|
$bookmark2tagservice = & ServiceFactory :: getServiceInstance('Bookmark2Tagservice');
|
||||||
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
||||||
|
@ -27,19 +28,21 @@ $templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
|
|
||||||
// Header variables
|
// Header variables
|
||||||
$tplVars['subtitle'] = T_('Manage users');
|
$tplVars['subtitle'] = T_('Manage users');
|
||||||
$tplVars['loadjs'] = true;
|
$tplVars['loadjs'] = true;
|
||||||
|
$tplVars['sidebar_blocks'] = array('users' );
|
||||||
|
|
||||||
if ( !$userservice->isLoggedOn() ) {
|
if ( !$userservice->isLoggedOn() ) {
|
||||||
header('Location: '. createURL('login', ''));
|
header('Location: '. createURL('login', ''));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
//$currentUser = $userservice->getCurrentUser();
|
||||||
$currentUserID = $userservice->getCurrentUserId();
|
//$currentUserID = $userservice->getCurrentUserId();
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
//$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
if ( !$userservice->isAdmin($currentUserID) ) {
|
if ( !$currentObjectUser->isAdmin() ) {
|
||||||
header('Location: '. createURL('bookmarks', $currentUsername));
|
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ if ( $action ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$templatename = 'userlist.tpl';
|
$templatename = 'userlist.tpl';
|
||||||
$users =& $userservice->getAllUsers();
|
$users =& $userservice->getObjectUsers();
|
||||||
|
|
||||||
if ( !is_array($users) ) {
|
if ( !is_array($users) ) {
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
|
@ -24,8 +24,15 @@ header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT');
|
||||||
header('Cache-Control: no-cache, must-revalidate');
|
header('Cache-Control: no-cache, must-revalidate');
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
||||||
$bookmark = intval($_GET['id']);
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['id']) ? define('GET_ID', $_GET['id']): define('GET_ID', '');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$bookmark = intval(GET_ID);
|
||||||
if (!$bookmarkservice->editAllowed($bookmark)) {
|
if (!$bookmarkservice->editAllowed($bookmark)) {
|
||||||
$result = T_('You are not allowed to delete this bookmark');
|
$result = T_('You are not allowed to delete this bookmark');
|
||||||
} elseif ($bookmarkservice->deleteBookmark($bookmark)) {
|
} elseif ($bookmarkservice->deleteBookmark($bookmark)) {
|
||||||
|
|
|
@ -25,6 +25,9 @@ header("Cache-Control: no-cache, must-revalidate");
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['url']) ? define('GET_URL', $_GET['url']): define('GET_URL', '');
|
||||||
|
|
||||||
function getTitle($url) {
|
function getTitle($url) {
|
||||||
$fd = @fopen($url, 'r');
|
$fd = @fopen($url, 'r');
|
||||||
if ($fd) {
|
if ($fd) {
|
||||||
|
@ -65,6 +68,6 @@ echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||||
getTitle
|
getTitle
|
||||||
</method>
|
</method>
|
||||||
<result>
|
<result>
|
||||||
<?php echo getTitle($_GET['url']); ?>
|
<?php echo getTitle(GET_URL); ?>
|
||||||
</result>
|
</result>
|
||||||
</response>
|
</response>
|
||||||
|
|
|
@ -24,11 +24,18 @@ header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
|
||||||
header("Cache-Control: no-cache, must-revalidate");
|
header("Cache-Control: no-cache, must-revalidate");
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
if ($userservice->isReserved($_GET['username'])) {
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['username']) ? define('GET_USERNAME', $_GET['username']): define('GET_USERNAME', '');
|
||||||
|
|
||||||
|
|
||||||
|
if ($userservice->isReserved(GET_USERNAME)) {
|
||||||
$result = 'false';
|
$result = 'false';
|
||||||
} else {
|
} else {
|
||||||
$result = $userservice->getUserByUsername($_GET['username']) ? 'false' : 'true';
|
$result = $userservice->getUserByUsername(GET_USERNAME) ? 'false' : 'true';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<response>
|
<response>
|
||||||
|
|
|
@ -20,11 +20,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
|
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
header('Location: '. createURL('populartags'));
|
header('Location: '. createURL('populartags'));
|
||||||
|
@ -51,8 +55,8 @@ if (isset($user) && $user != '') {
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if ($userinfo = $userservice->getUserByUsername($user)) {
|
if ($userinfo = $userservice->getObjectUserByUsername($user)) {
|
||||||
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
$userid = $userinfo->getId();
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
|
|
@ -1,64 +1,76 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2006 - 2007 Scuttle project
|
Copyright (C) 2006 - 2007 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
|
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['hash']) ? define('POST_HASH', $_POST['hash']): define('POST_HASH', '');
|
||||||
|
isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
|
||||||
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
|
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$template = 'bookmarkcommondescriptionedit.tpl';
|
$template = 'bookmarkcommondescriptionedit.tpl';
|
||||||
|
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
//$logged_on_user = $userservice->getCurrentUser();
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if(is_null($currentObjectUser)) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
if (POST_CONFIRM) {
|
||||||
|
if (strlen($hash)>0 &&
|
||||||
if (strlen($hash)>0 &&
|
$cdservice->addBookmarkDescription(POST_HASH, stripslashes(POST_TITLE), stripslashes(POST_DESCRIPTION), $currentObjectUser->getId(), time())
|
||||||
$cdservice->addBookmarkDescription($_POST['hash'], stripslashes($_POST['title']), stripslashes($_POST['description']), $logged_on_user['uId'], time())
|
) {
|
||||||
) {
|
$tplVars['msg'] = T_('Bookmark common description updated');
|
||||||
$tplVars['msg'] = T_('Bookmark common description updated');
|
header('Location: '. POST_REFERRER);
|
||||||
header('Location: '. $_POST['referrer']);
|
} else {
|
||||||
} else {
|
$tplVars['error'] = T_('Failed to update the bookmark common description');
|
||||||
$tplVars['error'] = T_('Failed to update the bookmark common description');
|
$template = 'error.500.tpl';
|
||||||
$template = 'error.500.tpl';
|
}
|
||||||
}
|
} elseif (POST_CANCEL) {
|
||||||
} elseif ($_POST['cancel']) {
|
$logged_on_user = $userservice->getCurrentUser();
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
header('Location: '. POST_REFERRER);
|
||||||
header('Location: '. $_POST['referrer']);
|
|
||||||
} else {
|
} else {
|
||||||
$bkm = $bookmarkservice->getBookmarkByHash($hash);
|
$bkm = $bookmarkservice->getBookmarkByHash($hash);
|
||||||
|
|
||||||
$tplVars['subtitle'] = T_('Edit Bookmark Common Description') .': '. $bkm['bAddress'];
|
$tplVars['subtitle'] = T_('Edit Bookmark Common Description') .': '. $bkm['bAddress'];
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $hash;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $hash;
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||||
$tplVars['hash'] = $hash;
|
$tplVars['hash'] = $hash;
|
||||||
$tplVars['description'] = $cdservice->getLastBookmarkDescription($hash);
|
$tplVars['description'] = $cdservice->getLastBookmarkDescription($hash);
|
||||||
}
|
}
|
||||||
$templateservice->loadTemplate($template, $tplVars);
|
$templateservice->loadTemplate($template, $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
389
bookmarks.php
389
bookmarks.php
|
@ -1,26 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2004 - 2006 Scuttle project
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
@ -28,59 +29,85 @@ $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
if (isset($_GET['action']) && ($_GET['action'] == "add") && !$userservice->isLoggedOn()) {
|
/* Managing all possible inputs */
|
||||||
$loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING']));
|
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
|
||||||
header('Location: '. createURL('login', '?'. $loginqry));
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
exit();
|
|
||||||
|
isset($_GET['title']) ? define('GET_TITLE', $_GET['title']): define('GET_TITLE', '');
|
||||||
|
isset($_GET['address']) ? define('GET_ADDRESS', $_GET['address']): define('GET_ADDRESS', '');
|
||||||
|
isset($_GET['description']) ? define('GET_DESCRIPTION', $_GET['description']): define('GET_DESCRIPTION', '');
|
||||||
|
isset($_GET['tags']) ? define('GET_TAGS', $_GET['tags']): define('GET_TAGS', '');
|
||||||
|
|
||||||
|
isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
|
||||||
|
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
|
||||||
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
||||||
|
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
|
||||||
|
|
||||||
|
isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
|
||||||
|
isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POPUP', '');
|
||||||
|
|
||||||
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ((GET_ACTION == "add") && !$userservice->isLoggedOn()) {
|
||||||
|
$loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING']));
|
||||||
|
header('Location: '. createURL('login', '?'. $loginqry));
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($userservice->isLoggedOn()) {
|
||||||
|
//$currentUser = $userservice->getCurrentUser();
|
||||||
|
//$currentUserID = $userservice->getCurrentUserId();
|
||||||
|
//$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
$currentUserID = $currentObjectUser->getId();
|
||||||
|
$currentUsername = $currentObjectUser->getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||||
|
|
||||||
$loggedon = false;
|
|
||||||
if ($userservice->isLoggedOn()) {
|
|
||||||
$loggedon = true;
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
|
||||||
$currentUserID = $userservice->getCurrentUserId();
|
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
}
|
|
||||||
|
|
||||||
$endcache = false;
|
$endcache = false;
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
$hash = md5($_SERVER['REQUEST_URI'] . $user);
|
$hash = md5($_SERVER['REQUEST_URI'] . $user);
|
||||||
|
|
||||||
// Don't cache if its users' own bookmarks
|
// Don't cache if its users' own bookmarks
|
||||||
if ($loggedon) {
|
if ($userservice->isLoggedOn()) {
|
||||||
if ($currentUsername != $user) {
|
if ($currentUsername != $user) {
|
||||||
// Cache for 5 minutes
|
// Cache for 5 minutes
|
||||||
$cacheservice->Start($hash);
|
$cacheservice->Start($hash);
|
||||||
$endcache = true;
|
$endcache = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Cache for 30 minutes
|
// Cache for 30 minutes
|
||||||
$cacheservice->Start($hash, 1800);
|
$cacheservice->Start($hash, 1800);
|
||||||
$endcache = true;
|
$endcache = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pagetitle = $rssCat = $catTitle = '';
|
$pagetitle = $rssCat = $catTitle = '';
|
||||||
if ($user) {
|
if ($user) {
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if (!($userinfo = $userservice->getUserByUsername($user))) {
|
if (!($userinfo = $userservice->getUserByUsername($user))) {
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$userid =& $userinfo['uId'];
|
$userid =& $userinfo['uId'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pagetitle .= ': '. $user;
|
$pagetitle .= ': '. $user;
|
||||||
}
|
}
|
||||||
if ($cat) {
|
if ($cat) {
|
||||||
$catTitle = ': '. str_replace('+', ' + ', $cat);
|
$catTitle = ': '. str_replace('+', ' + ', $cat);
|
||||||
$pagetitle .= $catTitle;
|
$pagetitle .= $catTitle;
|
||||||
}
|
}
|
||||||
$pagetitle = substr($pagetitle, 2);
|
$pagetitle = substr($pagetitle, 2);
|
||||||
|
|
||||||
|
@ -90,137 +117,139 @@ $tplVars['loadjs'] = true;
|
||||||
// ADD A BOOKMARK
|
// ADD A BOOKMARK
|
||||||
$saved = false;
|
$saved = false;
|
||||||
$templatename = 'bookmarks.tpl';
|
$templatename = 'bookmarks.tpl';
|
||||||
if ($loggedon && isset($_POST['submitted'])) {
|
if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
|
||||||
if (!$_POST['title'] || !$_POST['address']) {
|
if (!POST_TITLE || !POST_ADDRESS) {
|
||||||
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
||||||
$templatename = 'editbookmark.tpl';
|
$templatename = 'editbookmark.tpl';
|
||||||
} else {
|
} else {
|
||||||
$address = trim($_POST['address']);
|
$address = trim(POST_ADDRESS);
|
||||||
// If the bookmark exists already, edit the original
|
// If the bookmark exists already, edit the original
|
||||||
if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
|
if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
|
||||||
$bookmark =& $bookmarkservice->getBookmarkByAddress($address);
|
$bookmark =& $bookmarkservice->getBookmarkByAddress($address);
|
||||||
header('Location: '. createURL('edit', $bookmark['bId']));
|
header('Location: '. createURL('edit', $bookmark['bId']));
|
||||||
exit();
|
exit();
|
||||||
// If it's new, save it
|
// If it's new, save it
|
||||||
} else {
|
} else {
|
||||||
$title = trim($_POST['title']);
|
$title = trim(POST_TITLE);
|
||||||
$description = trim($_POST['description']);
|
$description = trim(POST_DESCRIPTION);
|
||||||
$status = intval($_POST['status']);
|
$status = intval(POST_STATUS);
|
||||||
$categories = trim($_POST['tags']);
|
$categories = trim(POST_TAGS);
|
||||||
$saved = true;
|
$saved = true;
|
||||||
if ($bookmarkservice->addBookmark($address, $title, $description, $status, $categories)) {
|
if ($bookmarkservice->addBookmark($address, $title, $description, $status, $categories)) {
|
||||||
if (isset($_POST['popup'])) {
|
if (POST_POPUP != '') {
|
||||||
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
|
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
|
||||||
} else {
|
} else {
|
||||||
$tplVars['msg'] = T_('Bookmark saved');
|
$tplVars['msg'] = T_('Bookmark saved');
|
||||||
// Redirection option
|
// Redirection option
|
||||||
if ($GLOBALS['useredir']) {
|
if ($GLOBALS['useredir']) {
|
||||||
$address = $GLOBALS['url_redir'] . $address;
|
$address = $GLOBALS['url_redir'] . $address;
|
||||||
}
|
}
|
||||||
//header('Location: '. $address); // not useful
|
//header('Location: '. $address); // not useful
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
|
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
|
||||||
$templatename = 'editbookmark.tpl';
|
$templatename = 'editbookmark.tpl';
|
||||||
$saved = false;
|
$saved = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['action']) && ($_GET['action'] == "add")) {
|
if (GET_ACTION == "add") {
|
||||||
// If the bookmark exists already, edit the original
|
// If the bookmark exists already, edit the original
|
||||||
if ($bookmarkservice->bookmarkExists(stripslashes($_GET['address']), $currentUserID)) {
|
if ($bookmarkservice->bookmarkExists(stripslashes(GET_ADDRESS), $currentUserID)) {
|
||||||
$bookmark =& $bookmarkservice->getBookmarks(0, NULL, $currentUserID, NULL, NULL, NULL, NULL, NULL, NULL, md5(stripslashes($_GET['address'])));
|
$bookmark =& $bookmarkservice->getBookmarks(0, NULL, $currentUserID, NULL, NULL, NULL, NULL, NULL, NULL, md5(stripslashes(GET_ADDRESS)));
|
||||||
$popup = (isset($_GET['popup'])) ? '?popup=1' : '';
|
$popup = (GET_POPUP!='') ? '?popup=1' : '';
|
||||||
header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup));
|
header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$templatename = 'editbookmark.tpl';
|
$templatename = 'editbookmark.tpl';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($templatename == 'editbookmark.tpl') {
|
if ($templatename == 'editbookmark.tpl') {
|
||||||
if ($loggedon) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
|
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
|
||||||
if (isset($_POST['submitted'])) {
|
if (POST_SUBMITTED != '') {
|
||||||
$tplVars['row'] = array(
|
$tplVars['row'] = array(
|
||||||
'bTitle' => stripslashes($_POST['title']),
|
'bTitle' => stripslashes(POST_TITLE),
|
||||||
'bAddress' => stripslashes($_POST['address']),
|
'bAddress' => stripslashes(POST_ADDRESS),
|
||||||
'bDescription' => stripslashes($_POST['description']),
|
'bDescription' => stripslashes(POST_DESCRIPTION),
|
||||||
'tags' => ($_POST['tags'] ? explode(',', stripslashes($_POST['tags'])) : array())
|
'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()),
|
||||||
);
|
'bStatus' => 0,
|
||||||
$tplVars['tags'] = $_POST['tags'];
|
);
|
||||||
} else {
|
$tplVars['tags'] = POST_TAGS;
|
||||||
$tplVars['row'] = array(
|
} else {
|
||||||
'bTitle' => stripslashes($_GET['title']),
|
$tplVars['row'] = array(
|
||||||
'bAddress' => stripslashes($_GET['address']),
|
'bTitle' => stripslashes(GET_TITLE),
|
||||||
'bDescription' => stripslashes($_GET['description']),
|
'bAddress' => stripslashes(GET_ADDRESS),
|
||||||
'tags' => ($_GET['tags'] ? explode(',', stripslashes($_GET['tags'])) : array())
|
'bDescription' => stripslashes(GET_DESCRIPTION),
|
||||||
);
|
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
|
||||||
}
|
'bStatus' => 0
|
||||||
$title = T_('Add a Bookmark');
|
);
|
||||||
$tplVars['pagetitle'] = $title;
|
}
|
||||||
$tplVars['subtitle'] = $title;
|
$title = T_('Add a Bookmark');
|
||||||
$tplVars['btnsubmit'] = T_('Add Bookmark');
|
$tplVars['pagetitle'] = $title;
|
||||||
$tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null;
|
$tplVars['subtitle'] = $title;
|
||||||
} else {
|
$tplVars['btnsubmit'] = T_('Add Bookmark');
|
||||||
$tplVars['error'] = T_('You must be logged in before you can add bookmarks.');
|
$tplVars['popup'] = (GET_POPUP!='') ? GET_POPUP : null;
|
||||||
}
|
} else {
|
||||||
} else if ($user && !isset($_GET['popup'])) {
|
$tplVars['error'] = T_('You must be logged in before you can add bookmarks.');
|
||||||
|
}
|
||||||
$tplVars['sidebar_blocks'] = array('profile', 'watchstatus');
|
} else if ($user && GET_POPUP == '') {
|
||||||
|
|
||||||
if (!$cat) {
|
$tplVars['sidebar_blocks'] = array('profile', 'watchstatus');
|
||||||
$cat = NULL;
|
|
||||||
$tplVars['currenttag'] = NULL;
|
|
||||||
$tplVars['sidebar_blocks'][] = 'menu';
|
|
||||||
} else {
|
|
||||||
$rssCat = '/'. filter($cat, 'url');
|
|
||||||
$tplVars['currenttag'] = $cat;
|
|
||||||
$tplVars['sidebar_blocks'][] = 'tagactions';
|
|
||||||
$tplVars['sidebar_blocks'][] = 'linked';
|
|
||||||
$tplVars['sidebar_blocks'][] = 'related';
|
|
||||||
$tplVars['sidebar_blocks'][] = 'menu';
|
|
||||||
}
|
|
||||||
$tplVars['popCount'] = 30;
|
|
||||||
$tplVars['sidebar_blocks'][] = 'popular';
|
|
||||||
|
|
||||||
$tplVars['userid'] = $userid;
|
|
||||||
$tplVars['userinfo'] =& $userinfo;
|
|
||||||
$tplVars['user'] = $user;
|
|
||||||
$tplVars['range'] = 'user';
|
|
||||||
|
|
||||||
// Pagination
|
|
||||||
$perpage = getPerPageCount();
|
|
||||||
if (isset($_GET['page']) && intval($_GET['page']) > 1) {
|
|
||||||
$page = $_GET['page'];
|
|
||||||
$start = ($page - 1) * $perpage;
|
|
||||||
} else {
|
|
||||||
$page = 0;
|
|
||||||
$start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set template vars
|
|
||||||
$tplVars['rsschannels'] = array(
|
|
||||||
array(filter($sitename .': '. $pagetitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder()))
|
|
||||||
);
|
|
||||||
|
|
||||||
$tplVars['page'] = $page;
|
if (!$cat) {
|
||||||
$tplVars['start'] = $start;
|
$cat = NULL;
|
||||||
$tplVars['bookmarkCount'] = $start + 1;
|
$tplVars['currenttag'] = NULL;
|
||||||
|
$tplVars['sidebar_blocks'][] = 'menu';
|
||||||
|
} else {
|
||||||
|
$rssCat = '/'. filter($cat, 'url');
|
||||||
|
$tplVars['currenttag'] = $cat;
|
||||||
|
$tplVars['sidebar_blocks'][] = 'tagactions';
|
||||||
|
$tplVars['sidebar_blocks'][] = 'linked';
|
||||||
|
$tplVars['sidebar_blocks'][] = 'related';
|
||||||
|
$tplVars['sidebar_blocks'][] = 'menu';
|
||||||
|
}
|
||||||
|
$tplVars['popCount'] = 30;
|
||||||
|
$tplVars['sidebar_blocks'][] = 'popular';
|
||||||
|
|
||||||
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder());
|
$tplVars['userid'] = $userid;
|
||||||
$tplVars['total'] = $bookmarks['total'];
|
$tplVars['userinfo'] =& $userinfo;
|
||||||
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
|
$tplVars['user'] = $user;
|
||||||
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
|
$tplVars['range'] = 'user';
|
||||||
$tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s');
|
|
||||||
if ($userservice->isLoggedOn() && $user == $currentUsername) {
|
// Pagination
|
||||||
$title = T_('My Bookmarks') . filter($catTitle);
|
$perpage = getPerPageCount();
|
||||||
} else {
|
if (intval(GET_PAGE) > 1) {
|
||||||
$title = filter($pagetitle);
|
$page = GET_PAGE;
|
||||||
}
|
$start = ($page - 1) * $perpage;
|
||||||
$tplVars['pagetitle'] = $title;
|
} else {
|
||||||
$tplVars['subtitle'] = $title;
|
$page = 0;
|
||||||
|
$start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set template vars
|
||||||
|
$tplVars['rsschannels'] = array(
|
||||||
|
array(filter($sitename .': '. $pagetitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder()))
|
||||||
|
);
|
||||||
|
|
||||||
|
$tplVars['page'] = $page;
|
||||||
|
$tplVars['start'] = $start;
|
||||||
|
$tplVars['bookmarkCount'] = $start + 1;
|
||||||
|
|
||||||
|
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder());
|
||||||
|
$tplVars['total'] = $bookmarks['total'];
|
||||||
|
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
|
||||||
|
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
|
||||||
|
$tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s');
|
||||||
|
if ($userservice->isLoggedOn() && $user == $currentUsername) {
|
||||||
|
$title = T_('My Bookmarks') . filter($catTitle);
|
||||||
|
} else {
|
||||||
|
$title = filter($pagetitle);
|
||||||
|
}
|
||||||
|
$tplVars['pagetitle'] = $title;
|
||||||
|
$tplVars['subtitle'] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['summarizeLinkedTags'] = true;
|
$tplVars['summarizeLinkedTags'] = true;
|
||||||
|
@ -229,7 +258,7 @@ $tplVars['pageName'] = PAGE_BOOKMARKS;
|
||||||
$templateservice->loadTemplate($templatename, $tplVars);
|
$templateservice->loadTemplate($templatename, $tplVars);
|
||||||
|
|
||||||
if ($usecache && $endcache) {
|
if ($usecache && $endcache) {
|
||||||
// Cache output if existing copy has expired
|
// Cache output if existing copy has expired
|
||||||
$cacheservice->End($hash);
|
$cacheservice->End($hash);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Define constants use in all the application.
|
* Define constants used in all the application.
|
||||||
* Some constants are based on variables from configuration file.
|
* Some constants are based on variables from configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
59
edit.php
59
edit.php
|
@ -21,10 +21,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
|
isset($_POST['delete']) ? define('POST_DELETE', $_POST['delete']): define('POST_DELETE', '');
|
||||||
|
|
||||||
|
isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
|
||||||
|
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
|
||||||
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
||||||
|
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
|
||||||
|
|
||||||
|
isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
|
||||||
|
isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POPUP', '');
|
||||||
|
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
|
||||||
// Header variables
|
// Header variables
|
||||||
$tplVars['subtitle'] = T_('Edit Bookmark');
|
$tplVars['subtitle'] = T_('Edit Bookmark');
|
||||||
$tplVars['loadjs'] = true;
|
$tplVars['loadjs'] = true;
|
||||||
|
@ -39,39 +58,41 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
|
||||||
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
|
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
} else if ($_POST['submitted']) {
|
} else if (POST_SUBMITTED != '') {
|
||||||
if (!$_POST['title'] || !$_POST['address']) {
|
if (!POST_TITLE || !POST_ADDRESS) {
|
||||||
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
$tplVars['error'] = T_('Your bookmark must have a title and an address');
|
||||||
} else {
|
} else {
|
||||||
// Update bookmark
|
// Update bookmark
|
||||||
$bId = intval($bookmark);
|
$bId = intval($bookmark);
|
||||||
$address = trim($_POST['address']);
|
$address = trim(POST_ADDRESS);
|
||||||
$title = trim($_POST['title']);
|
$title = trim(POST_TITLE);
|
||||||
$description = trim($_POST['description']);
|
$description = trim(POST_DESCRIPTION);
|
||||||
$status = intval($_POST['status']);
|
$status = intval(POST_STATUS);
|
||||||
$tags = trim($_POST['tags']);
|
$tags = trim(POST_TAGS);
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $status, $tags)) {
|
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $status, $tags)) {
|
||||||
$tplvars['error'] = T_('Error while saving your bookmark');
|
$tplvars['error'] = T_('Error while saving your bookmark');
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['popup'])) {
|
if (POST_POPUP != '') {
|
||||||
$tplVars['msg'] = (isset($_POST['popup'])) ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
|
//$tplVars['msg'] = (POST_POPUP != '') ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
|
||||||
} elseif (isset($_POST['referrer'])) {
|
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
|
||||||
header('Location: '. $_POST['referrer']);
|
} elseif (POST_REFERRER != '') {
|
||||||
|
$tplVars['msg'] = T_('Bookmark saved');
|
||||||
|
header('Location: '. POST_REFERRER);
|
||||||
} else {
|
} else {
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
$tplVars['msg'] = T_('Bookmark saved');
|
||||||
|
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($_POST['delete']) {
|
if (POST_DELETE != '') {
|
||||||
// Delete bookmark
|
// Delete bookmark
|
||||||
if ($bookmarkservice->deleteBookmark($bookmark)) {
|
if ($bookmarkservice->deleteBookmark($bookmark)) {
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
if (POST_REFERRER != '') {
|
||||||
if (isset($_POST['referrer'])) {
|
header('Location: '. POST_REFERRER);
|
||||||
header('Location: '. $_POST['referrer']);
|
|
||||||
} else {
|
} else {
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +103,7 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null;
|
$tplVars['popup'] = (GET_POPUP) ? GET_POPUP : null;
|
||||||
$tplVars['row'] =& $row;
|
$tplVars['row'] =& $row;
|
||||||
$tplVars['formaction'] = createURL('edit', $bookmark);
|
$tplVars['formaction'] = createURL('edit', $bookmark);
|
||||||
$tplVars['btnsubmit'] = T_('Save Changes');
|
$tplVars['btnsubmit'] = T_('Save Changes');
|
||||||
|
|
23
history.php
23
history.php
|
@ -21,27 +21,34 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
@list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
@list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||||
|
|
||||||
$loggedon = false;
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/*$loggedon = false;
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$loggedon = true;
|
$loggedon = true;
|
||||||
$currentUser = $userservice->getCurrentUser();
|
$currentUser = $userservice->getCurrentUser();
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
$hashtext = $_SERVER['REQUEST_URI'];
|
$hashtext = $_SERVER['REQUEST_URI'];
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$hashtext .= $currentUsername;
|
$hashtext .= $currentObjectUser->getUsername();
|
||||||
}
|
}
|
||||||
$cachehash = md5($hashtext);
|
$cachehash = md5($hashtext);
|
||||||
|
|
||||||
|
@ -51,8 +58,8 @@ if ($usecache) {
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
$perpage = getPerPageCount();
|
$perpage = getPerPageCount();
|
||||||
if (isset($_GET['page']) && intval($_GET['page']) > 1) {
|
if (intval(GET_PAGE) > 1) {
|
||||||
$page = $_GET['page'];
|
$page = GET_PAGE;
|
||||||
$start = ($page - 1) * $perpage;
|
$start = ($page - 1) * $perpage;
|
||||||
} else {
|
} else {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
|
@ -76,6 +83,12 @@ if ($bookmark =& $bookmarkservice->getBookmarkByHash($hash)) {
|
||||||
//$tplVars['cat_url'] = createURL('tags', '%2$s');
|
//$tplVars['cat_url'] = createURL('tags', '%2$s');
|
||||||
$tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
|
$tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
|
||||||
$tplVars['nav_url'] = createURL('history', $hash .'/%3$s');
|
$tplVars['nav_url'] = createURL('history', $hash .'/%3$s');
|
||||||
|
$tplVars['rsschannels'] = array();
|
||||||
|
if($userservice->isLoggedOn()) {
|
||||||
|
$tplVars['user'] = $currentObjectUser->getUsername();
|
||||||
|
} else {
|
||||||
|
$tplVars['user'] = '';
|
||||||
|
}
|
||||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||||
} else {
|
} else {
|
||||||
// Throw a 404 error
|
// Throw a 404 error
|
||||||
|
|
172
import.php
172
import.php
|
@ -1,109 +1,121 @@
|
||||||
<?
|
<?
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2004 - 2006 Scuttle project
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
// First input is $_FILES
|
||||||
|
// Other inputs
|
||||||
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
||||||
$userinfo = $userservice->getCurrentUser();
|
$userinfo = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
if (isset($_POST['status']) && is_numeric($_POST['status'])) {
|
if (is_numeric(POST_STATUS)) {
|
||||||
$status = intval($_POST['status']);
|
$status = intval(POST_STATUS);
|
||||||
} else {
|
} else {
|
||||||
$status = 2;
|
$status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$depth = array();
|
$depth = array();
|
||||||
$xml_parser = xml_parser_create();
|
$xml_parser = xml_parser_create();
|
||||||
xml_set_element_handler($xml_parser, "startElement", "endElement");
|
xml_set_element_handler($xml_parser, "startElement", "endElement");
|
||||||
|
|
||||||
if (!($fp = fopen($_FILES['userfile']['tmp_name'], "r")))
|
if (!($fp = fopen($_FILES['userfile']['tmp_name'], "r")))
|
||||||
die(T_("Could not open XML input"));
|
die(T_("Could not open XML input"));
|
||||||
|
|
||||||
while ($data = fread($fp, 4096)) {
|
while ($data = fread($fp, 4096)) {
|
||||||
if (!xml_parse($xml_parser, $data, feof($fp))) {
|
if (!xml_parse($xml_parser, $data, feof($fp))) {
|
||||||
die(sprintf(T_("XML error: %s at line %d"),
|
die(sprintf(T_("XML error: %s at line %d"),
|
||||||
xml_error_string(xml_get_error_code($xml_parser)),
|
xml_error_string(xml_get_error_code($xml_parser)),
|
||||||
xml_get_current_line_number($xml_parser)));
|
xml_get_current_line_number($xml_parser)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xml_parser_free($xml_parser);
|
xml_parser_free($xml_parser);
|
||||||
header('Location: '. createURL('bookmarks', $userinfo[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
|
||||||
} else {
|
} else {
|
||||||
$templatename = 'importDelicious.tpl';
|
$templatename = 'importDelicious.tpl';
|
||||||
$tplVars['subtitle'] = T_('Import Bookmarks from del.icio.us');
|
$tplVars['subtitle'] = T_('Import Bookmarks from del.icio.us');
|
||||||
$tplVars['formaction'] = createURL('import');
|
$tplVars['formaction'] = createURL('import');
|
||||||
$templateservice->loadTemplate($templatename, $tplVars);
|
$templateservice->loadTemplate($templatename, $tplVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function startElement($parser, $name, $attrs) {
|
function startElement($parser, $name, $attrs) {
|
||||||
global $depth, $status, $tplVars, $userservice;
|
global $depth, $status, $tplVars, $userservice;
|
||||||
|
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
if ($name == 'POST') {
|
if ($name == 'POST') {
|
||||||
while(list($attrTitle, $attrVal) = each($attrs)) {
|
while(list($attrTitle, $attrVal) = each($attrs)) {
|
||||||
switch ($attrTitle) {
|
switch ($attrTitle) {
|
||||||
case 'HREF':
|
case 'HREF':
|
||||||
$bAddress = $attrVal;
|
$bAddress = $attrVal;
|
||||||
break;
|
break;
|
||||||
case 'DESCRIPTION':
|
case 'DESCRIPTION':
|
||||||
$bTitle = $attrVal;
|
$bTitle = $attrVal;
|
||||||
break;
|
break;
|
||||||
case 'EXTENDED':
|
case 'EXTENDED':
|
||||||
$bDescription = $attrVal;
|
$bDescription = $attrVal;
|
||||||
break;
|
break;
|
||||||
case 'TIME':
|
case 'TIME':
|
||||||
$bDatetime = $attrVal;
|
$bDatetime = $attrVal;
|
||||||
break;
|
break;
|
||||||
case 'TAG':
|
case 'TAG':
|
||||||
$tags = strtolower($attrVal);
|
$tags = strtolower($attrVal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
|
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
|
||||||
$tplVars['error'] = T_('You have already submitted this bookmark.');
|
$tplVars['error'] = T_('You have already submitted this bookmark.');
|
||||||
} else {
|
} else {
|
||||||
// Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z.
|
// Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z.
|
||||||
$bDatetime = substr($bDatetime, 0, -1);
|
$bDatetime = substr($bDatetime, 0, -1);
|
||||||
|
|
||||||
// If bookmark claims to be from the future, set it to be now instead
|
// If bookmark claims to be from the future, set it to be now instead
|
||||||
if (strtotime($bDatetime) > time()) {
|
if (strtotime($bDatetime) > time()) {
|
||||||
$bDatetime = gmdate('Y-m-d H:i:s');
|
$bDatetime = gmdate('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $status, $tags, $bDatetime, true, true))
|
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $status, $tags, $bDatetime, true, true))
|
||||||
$tplVars['msg'] = T_('Bookmark imported.');
|
$tplVars['msg'] = T_('Bookmark imported.');
|
||||||
else
|
else
|
||||||
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
|
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$depth[$parser]++;
|
$depth[$parser]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function endElement($parser, $name) {
|
function endElement($parser, $name) {
|
||||||
global $depth;
|
global $depth;
|
||||||
$depth[$parser]--;
|
$depth[$parser]--;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,16 +20,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
// First input is $_FILES
|
||||||
|
// Other inputs
|
||||||
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
||||||
$userinfo = $userservice->getCurrentUser();
|
$userinfo = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
if (isset($_POST['status']) && is_numeric($_POST['status'])) {
|
if (is_numeric(POST_STATUS)) {
|
||||||
$status = intval($_POST['status']);
|
$status = intval(POST_STATUS);
|
||||||
} else {
|
} else {
|
||||||
$status = 2;
|
$status = 2;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +89,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header('Location: '. createURL('bookmarks', $userinfo[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
|
||||||
} else {
|
} else {
|
||||||
$templatename = 'importNetscape.tpl';
|
$templatename = 'importNetscape.tpl';
|
||||||
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
|
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
|
||||||
|
|
|
@ -28,11 +28,10 @@ $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
/* Managing possible inputs */
|
/* Managing all possible inputs */
|
||||||
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
|
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
|
||||||
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
//isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_SORT', '');
|
|
||||||
|
|
||||||
|
|
||||||
// Logout action
|
// Logout action
|
||||||
|
@ -91,6 +90,8 @@ $tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
|
||||||
$tplVars['nav_url'] = createURL('index', '%3$s');
|
$tplVars['nav_url'] = createURL('index', '%3$s');
|
||||||
$tplVars['summarizeLinkedTags'] = true;
|
$tplVars['summarizeLinkedTags'] = true;
|
||||||
$tplVars['pageName'] = PAGE_INDEX;
|
$tplVars['pageName'] = PAGE_INDEX;
|
||||||
|
$tplVars['user'] = '';
|
||||||
|
$tplVars['currenttag'] = '';
|
||||||
|
|
||||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||||
|
|
||||||
|
|
29
login.php
29
login.php
|
@ -20,20 +20,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['keeppass']) ? define('POST_KEEPPASS', $_POST['keeppass']): define('POST_KEEPPASS', '');
|
||||||
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
|
isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define('POST_USERNAME', '');
|
||||||
|
isset($_POST['password']) ? define('POST_PASSWORD', $_POST['password']): define('POST_PASSWORD', '');
|
||||||
|
isset($_POST['query']) ? define('POST_QUERY', $_POST['query']): define('POST_QUERY', '');
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
$keeppass = isset($_POST['keeppass'])&&($_POST['keeppass']=='yes')?true:false;
|
$keeppass = (POST_KEEPPASS=='yes')?true:false;
|
||||||
|
|
||||||
$login = false;
|
$login = false;
|
||||||
if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['password'])) {
|
if (POST_SUBMITTED!='' && POST_USERNAME!='' && POST_PASSWORD!='') {
|
||||||
$posteduser = trim(utf8_strtolower($_POST['username']));
|
$posteduser = trim(utf8_strtolower(POST_USERNAME));
|
||||||
$login = $userservice->login($posteduser, $_POST['password'], $keeppass);
|
$login = $userservice->login($posteduser, POST_PASSWORD, $keeppass);
|
||||||
if ($login) {
|
if ($login) {
|
||||||
if ($_POST['query'])
|
if (POST_QUERY)
|
||||||
header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query']));
|
header('Location: '. createURL('bookmarks', $posteduser .'?'. POST_QUERY));
|
||||||
else
|
else
|
||||||
header('Location: '. createURL('bookmarks', $posteduser));
|
header('Location: '. createURL('bookmarks', $posteduser));
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,9 +54,8 @@ if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['pas
|
||||||
}
|
}
|
||||||
if (!$login) {
|
if (!$login) {
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$cUser = $userservice->getCurrentUser();
|
$cUser = $userservice->getCurrentObjectUser();
|
||||||
$cUsername = strtolower($cUser[$userservice->getFieldName('username')]);
|
header('Location: '. createURL('bookmarks', strtolower($cUser->getUsername())));
|
||||||
header('Location: '. createURL('bookmarks', $cUsername));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['subtitle'] = T_('Log In');
|
$tplVars['subtitle'] = T_('Log In');
|
||||||
|
|
98
password.php
98
password.php
|
@ -1,68 +1,78 @@
|
||||||
<?
|
<?
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2005 Scuttle project
|
Copyright (C) 2005 Scuttle project
|
||||||
https://sourceforge.net/projects/scuttle/
|
https://sourceforge.net/projects/scuttle/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
|
isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define('POST_USERNAME', '');
|
||||||
|
isset($_POST['email']) ? define('POST_EMAIL', $_POST['email']): define('POST_EMAIL', '');
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
// IF SUBMITTED
|
// IF SUBMITTED
|
||||||
if (isset($_POST['submitted'])) {
|
if (POST_SUBMITTED != '') {
|
||||||
|
|
||||||
// NO USERNAME
|
// NO USERNAME
|
||||||
if (!$_POST['username']) {
|
if (!POST_USERNAME) {
|
||||||
$tplVars['error'] = T_('You must enter your username.');
|
$tplVars['error'] = T_('You must enter your username.');
|
||||||
|
|
||||||
// NO E-MAIL
|
// NO E-MAIL
|
||||||
} elseif (!$_POST['email']) {
|
} elseif (!POST_EMAIL) {
|
||||||
$tplVars['error'] = T_('You must enter your <abbr title="electronic mail">e-mail</abbr> address.');
|
$tplVars['error'] = T_('You must enter your <abbr title="electronic mail">e-mail</abbr> address.');
|
||||||
|
|
||||||
// USERNAME AND E-MAIL
|
// USERNAME AND E-MAIL
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// NO MATCH
|
// NO MATCH
|
||||||
if (!($userinfo = $userservice->getUserByUsername($_POST['username']))) {
|
$userinfo = $userservice->getObjectUserByUsername(POST_USERNAME);
|
||||||
$tplVars['error'] = T_('No matches found for that username.');
|
if ($userinfo == '') {
|
||||||
|
$tplVars['error'] = T_('No matches found for that username.');
|
||||||
|
|
||||||
} elseif ($_POST['email'] != $userinfo['email']) {
|
} elseif (POST_EMAIL != $userinfo->getEmail()) {
|
||||||
$tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
|
$tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
|
||||||
|
|
||||||
// MATCH
|
// MATCH
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// GENERATE AND STORE PASSWORD
|
// GENERATE AND STORE PASSWORD
|
||||||
$password = $userservice->generatePassword($userinfo['uId']);
|
$password = $userservice->generatePassword($userinfo->getId());
|
||||||
if (!($password = $userservice->generatePassword($userinfo['uId']))) {
|
if (!($password = $userservice->generatePassword($userinfo->getId()))) {
|
||||||
$tplVars['error'] = T_('There was an error while generating your new password. Please try again.');
|
$tplVars['error'] = T_('There was an error while generating your new password. Please try again.');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// SEND E-MAIL
|
// SEND E-MAIL
|
||||||
$message = T_('Your new password is:') ."\n". $password ."\n\n". T_('To keep your bookmarks secure, you should change this password in your profile the next time you log in.');
|
$message = T_('Your new password is:') ."\n". $password ."\n\n". T_('To keep your bookmarks secure, you should change this password in your profile the next time you log in.');
|
||||||
$message = wordwrap($message, 70);
|
$message = wordwrap($message, 70);
|
||||||
$headers = 'From: '. $adminemail;
|
$headers = 'From: '. $adminemail;
|
||||||
$mail = mail($_POST['email'], sprintf(T_('%s Account Information'), $sitename), $message);
|
$mail = mail(POST_EMAIL, sprintf(T_('%s Account Information'), $sitename), $message);
|
||||||
|
|
||||||
$tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), $_POST['email']);
|
$tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), POST_EMAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$templatename = 'password.tpl';
|
$templatename = 'password.tpl';
|
||||||
|
|
|
@ -20,21 +20,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
|
||||||
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
|
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
$hashtext = $_SERVER['REQUEST_URI'];
|
$hashtext = $_SERVER['REQUEST_URI'];
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$hashtext .= $userservice->getCurrentUserID();
|
$hashtext .= $currentObjectUser->getId();
|
||||||
$currentUser = $userservice->getCurrentUser();
|
if ($currentObjectUser->getUsername() == $user) {
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
if ($currentUsername == $user) {
|
|
||||||
$hashtext .= $user;
|
$hashtext .= $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,8 +56,9 @@ if (isset($user) && $user != '') {
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if ($userinfo = $userservice->getUserByUsername($user)) {
|
$userinfo = $userservice->getObjectUserByUsername($user);
|
||||||
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
if ($userinfo != '') {
|
||||||
|
$userid = $userinfo->getId();
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
@ -77,8 +82,8 @@ if (isset($userid)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['sidebar_blocks'] = array('linked');
|
$tplVars['sidebar_blocks'] = array('linked');
|
||||||
|
|
||||||
$tplVars['subtitle'] = $pagetitle;
|
$tplVars['subtitle'] = $pagetitle;
|
||||||
|
|
||||||
$templateservice->loadTemplate('tags.tpl', $tplVars);
|
$templateservice->loadTemplate('tags.tpl', $tplVars);
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
|
|
63
profile.php
63
profile.php
|
@ -20,32 +20,45 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
|
isset($_POST['pPass']) ? define('POST_PASS', $_POST['pPass']): define('POST_PASS', '');
|
||||||
|
isset($_POST['pPassConf']) ? define('POST_PASSCONF', $_POST['pPassConf']): define('POST_PASSCONF', '');
|
||||||
|
isset($_POST['pName']) ? define('POST_NAME', $_POST['pName']): define('POST_NAME', '');
|
||||||
|
isset($_POST['pMail']) ? define('POST_MAIL', $_POST['pMail']): define('POST_MAIL', '');
|
||||||
|
isset($_POST['pPage']) ? define('POST_PAGE', $_POST['pPage']): define('POST_PAGE', '');
|
||||||
|
isset($_POST['pDesc']) ? define('POST_DESC', $_POST['pDesc']): define('POST_DESC', '');
|
||||||
|
|
||||||
|
isset($_POST['token']) ? define('POST_TOKEN', $_POST['token']): define('POST_TOKEN', '');
|
||||||
|
isset($_SESSION['token']) ? define('SESSION_TOKEN', $_SESSION['token']): define('SESSION_TOKEN', '');
|
||||||
|
isset($_SESSION['token_stamp']) ? define('SESSION_TOKENSTAMP', $_SESSION['token_stamp']): define('SESSION_TOKENSTAMP', '');
|
||||||
|
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||||
|
|
||||||
$loggedon = false;
|
|
||||||
if ($userservice->isLoggedOn()) {
|
|
||||||
$loggedon = true;
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
|
||||||
$currentUserID = $userservice->getCurrentUserId();
|
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
$user = urldecode($user);
|
$user = urldecode($user);
|
||||||
if (!($userinfo = $userservice->getUserByUsername($user))) {
|
$userinfo = $userservice->getObjectUserByUsername($user);
|
||||||
|
if ($userinfo == '') {
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$userid =& $userinfo['uId'];
|
$userid =& $userinfo->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,7 +67,7 @@ if ($user) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user == $currentUsername) {
|
if ($userservice->isLoggedOn() && $user == $currentObjectUser->getUsername()) {
|
||||||
$title = T_('My Profile');
|
$title = T_('My Profile');
|
||||||
} else {
|
} else {
|
||||||
$title = T_('Profile') .': '. $user;
|
$title = T_('Profile') .': '. $user;
|
||||||
|
@ -65,19 +78,19 @@ $tplVars['subtitle'] = $title;
|
||||||
$tplVars['user'] = $user;
|
$tplVars['user'] = $user;
|
||||||
$tplVars['userid'] = $userid;
|
$tplVars['userid'] = $userid;
|
||||||
|
|
||||||
if (isset($_POST['submitted']) && $currentUserID == $userid) {
|
if (POST_SUBMITTED!='' && $currentObjectUser->getId() == $userid) {
|
||||||
$error = false;
|
$error = false;
|
||||||
$detPass = trim($_POST['pPass']);
|
$detPass = trim(POST_PASS);
|
||||||
$detPassConf = trim($_POST['pPassConf']);
|
$detPassConf = trim(POST_PASSCONF);
|
||||||
$detName = trim($_POST['pName']);
|
$detName = trim(POST_NAME);
|
||||||
$detMail = trim($_POST['pMail']);
|
$detMail = trim(POST_MAIL);
|
||||||
$detPage = trim($_POST['pPage']);
|
$detPage = trim(POST_PAGE);
|
||||||
$detDesc = filter($_POST['pDesc']);
|
$detDesc = filter(POST_DESC);
|
||||||
|
|
||||||
// manage token preventing from CSRF vulnaribilities
|
// manage token preventing from CSRF vulnaribilities
|
||||||
if ( !isset($_SESSION['token'], $_SESSION['token_stamp'])
|
if ( SESSION_TOKEN == ''
|
||||||
|| time() - $_SESSION['token_stamp'] > 600 //limit token lifetime, optionnal
|
|| time() - SESSION_TOKENSTAMP > 600 //limit token lifetime, optionnal
|
||||||
|| $_SESSION['token'] != $_POST['token']) {
|
|| SESSION_TOKEN != POST_TOKEN) {
|
||||||
$error = true;
|
$error = true;
|
||||||
$tplVars['error'] = T_('Invalid Token');
|
$tplVars['error'] = T_('Invalid Token');
|
||||||
}
|
}
|
||||||
|
@ -101,10 +114,10 @@ if (isset($_POST['submitted']) && $currentUserID == $userid) {
|
||||||
$tplVars['msg'] = T_('Changes saved.');
|
$tplVars['msg'] = T_('Changes saved.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$userinfo = $userservice->getUserByUsername($user);
|
$userinfo = $userservice->getObjectUserByUsername($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($currentUserID != $userid) {
|
if (!$userservice->isLoggedOn() || $currentObjectUser->getId() != $userid) {
|
||||||
$templatename = 'profile.tpl.php';
|
$templatename = 'profile.tpl.php';
|
||||||
} else {
|
} else {
|
||||||
//Token Init
|
//Token Init
|
||||||
|
@ -117,6 +130,6 @@ if ($currentUserID != $userid) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['row'] = $userinfo;
|
$tplVars['objectUser'] = $userinfo;
|
||||||
$templateservice->loadTemplate($templatename, $tplVars);
|
$templateservice->loadTemplate($templatename, $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
24
register.php
24
register.php
|
@ -20,16 +20,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
|
||||||
|
isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define('POST_USERNAME', '');
|
||||||
|
isset($_POST['password']) ? define('POST_PASS', $_POST['password']): define('POST_PASS', '');
|
||||||
|
isset($_POST['email']) ? define('POST_MAIL', $_POST['email']): define('POST_MAIL', '');
|
||||||
|
isset($_POST['antispamAnswer']) ? define('POST_ANTISPAMANSWER', $_POST['antispamAnswer']): define('POST_ANTISPAMANSWER', '');
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
if (isset($_POST['submitted'])) {
|
if (POST_SUBMITTED != '') {
|
||||||
$posteduser = trim(utf8_strtolower($_POST['username']));
|
$posteduser = trim(utf8_strtolower(POST_USERNAME));
|
||||||
|
|
||||||
// Check if form is incomplete
|
// Check if form is incomplete
|
||||||
if (!($posteduser) || !($_POST['password']) || !($_POST['email'])) {
|
if (!($posteduser) || POST_PASS == '' || POST_MAIL == '') {
|
||||||
$tplVars['error'] = T_('You <em>must</em> enter a username, password and e-mail address.');
|
$tplVars['error'] = T_('You <em>must</em> enter a username, password and e-mail address.');
|
||||||
|
|
||||||
// Check if username is reserved
|
// Check if username is reserved
|
||||||
|
@ -45,17 +55,17 @@ if (isset($_POST['submitted'])) {
|
||||||
$tplVars['error'] = T_('This username is not valid (too long, forbidden characters...), please make another choice.');
|
$tplVars['error'] = T_('This username is not valid (too long, forbidden characters...), please make another choice.');
|
||||||
|
|
||||||
// Check if e-mail address is valid
|
// Check if e-mail address is valid
|
||||||
} elseif (!$userservice->isValidEmail($_POST['email'])) {
|
} elseif (!$userservice->isValidEmail(POST_MAIL)) {
|
||||||
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
|
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
|
||||||
|
|
||||||
// Check if antispam answer is valid
|
// Check if antispam answer is valid
|
||||||
} elseif (strcmp($_POST['antispamAnswer'], $GLOBALS['antispamAnswer']) != 0) {
|
} elseif (strcmp(POST_ANTISPAMANSWER, $GLOBALS['antispamAnswer']) != 0) {
|
||||||
$tplVars['error'] = T_('Antispam answer is not valid. Please try again.');
|
$tplVars['error'] = T_('Antispam answer is not valid. Please try again.');
|
||||||
|
|
||||||
// Register details
|
// Register details
|
||||||
} elseif ($userservice->addUser($posteduser, $_POST['password'], $_POST['email'])) {
|
} elseif ($userservice->addUser($posteduser, POST_PASS, POST_MAIL)) {
|
||||||
// Log in with new username
|
// Log in with new username
|
||||||
$login = $userservice->login($posteduser, $_POST['password']);
|
$login = $userservice->login($posteduser, POST_PASS);
|
||||||
if ($login) {
|
if ($login) {
|
||||||
header('Location: '. createURL('bookmarks', $posteduser));
|
header('Location: '. createURL('bookmarks', $posteduser));
|
||||||
}
|
}
|
||||||
|
|
134
rss.php
134
rss.php
|
@ -1,77 +1,88 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2004 - 2006 Scuttle project
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
header('Content-Type: application/xml');
|
header('Content-Type: application/xml');
|
||||||
list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
if(isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) >1) {
|
||||||
|
list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
} else {
|
||||||
|
$url = '';
|
||||||
|
$user = '';
|
||||||
|
$cat = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
$hashtext = $_SERVER['REQUEST_URI'];
|
$hashtext = $_SERVER['REQUEST_URI'];
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$hashtext .= $userservice->getCurrentUserID();
|
$hashtext .= $userservice->getCurrentUserID();
|
||||||
$currentUser = $userservice->getCurrentUser();
|
$currentUser = $userservice->getCurrentUser();
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
if ($currentUsername == $user) {
|
if ($currentUsername == $user) {
|
||||||
$hashtext .= $user;
|
$hashtext .= $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$hash = md5($hashtext);
|
$hash = md5($hashtext);
|
||||||
|
|
||||||
// Cache for an hour
|
// Cache for an hour
|
||||||
$cacheservice->Start($hash, 3600);
|
$cacheservice->Start($hash, 3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
$watchlist = null;
|
$watchlist = null;
|
||||||
|
$pagetitle = '';
|
||||||
if ($user && $user != 'all') {
|
if ($user && $user != 'all') {
|
||||||
if ($user == 'watchlist') {
|
if ($user == 'watchlist') {
|
||||||
$user = $cat;
|
$user = $cat;
|
||||||
$cat = null;
|
$cat = null;
|
||||||
$watchlist = true;
|
$watchlist = true;
|
||||||
}
|
}
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if ($userinfo = $userservice->getUserByUsername($user)) {
|
if ($userinfo = $userservice->getUserByUsername($user)) {
|
||||||
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
//throw a 404 error
|
//throw a 404 error
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pagetitle .= ": ". $user;
|
$pagetitle .= ": ". $user;
|
||||||
} else {
|
} else {
|
||||||
$userid = NULL;
|
$userid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cat) {
|
if ($cat) {
|
||||||
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
||||||
|
@ -79,28 +90,29 @@ $tplVars['feedlink'] = ROOT;
|
||||||
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
||||||
|
|
||||||
$bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
|
$bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
|
||||||
|
|
||||||
$bookmarks_tmp =& filter($bookmarks['bookmarks']);
|
$bookmarks_tmp =& filter($bookmarks['bookmarks']);
|
||||||
|
|
||||||
$bookmarks_tpl = array();
|
$bookmarks_tpl = array();
|
||||||
foreach(array_keys($bookmarks_tmp) as $key) {
|
foreach(array_keys($bookmarks_tmp) as $key) {
|
||||||
$row =& $bookmarks_tmp[$key];
|
$row =& $bookmarks_tmp[$key];
|
||||||
|
|
||||||
$_link = $row['bAddress'];
|
$_link = $row['bAddress'];
|
||||||
// Redirection option
|
// Redirection option
|
||||||
if ($GLOBALS['useredir']) {
|
if ($GLOBALS['useredir']) {
|
||||||
$_link = $GLOBALS['url_redir'] . $_link;
|
$_link = $GLOBALS['url_redir'] . $_link;
|
||||||
}
|
}
|
||||||
$_pubdate = gmdate("r", strtotime($row['bDatetime']));
|
$_pubdate = gmdate("r", strtotime($row['bDatetime']));
|
||||||
// array_walk($row['tags'], 'filter');
|
// array_walk($row['tags'], 'filter');
|
||||||
|
|
||||||
$bookmarks_tpl[] = array(
|
$bookmarks_tpl[] = array(
|
||||||
'title' => $row['bTitle'],
|
'title' => $row['bTitle'],
|
||||||
'link' => $_link,
|
'link' => $_link,
|
||||||
'description' => $row['bDescription'],
|
'description' => $row['bDescription'],
|
||||||
'creator' => $row['username'],
|
'creator' => $row['username'],
|
||||||
'pubdate' => $_pubdate,
|
'pubdate' => $_pubdate,
|
||||||
'tags' => $row['tags']
|
'tags' => $row['tags']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
unset($bookmarks_tmp);
|
unset($bookmarks_tmp);
|
||||||
unset($bookmarks);
|
unset($bookmarks);
|
||||||
|
@ -109,7 +121,7 @@ $tplVars['bookmarks'] =& $bookmarks_tpl;
|
||||||
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Cache output if existing copy has expired
|
// Cache output if existing copy has expired
|
||||||
$cacheservice->End($hash);
|
$cacheservice->End($hash);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/* Manage input */
|
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
$select_watchlist = isset($select_watchlist)?$select_watchlist:'';
|
$select_watchlist = isset($select_watchlist)?$select_watchlist:'';
|
||||||
$select_all = isset($select_all)?$select_all:'';
|
$select_all = isset($select_all)?$select_all:'';
|
||||||
?>
|
?>
|
||||||
|
@ -9,13 +11,11 @@ $select_all = isset($select_all)?$select_all:'';
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
$logged_on = false;
|
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$currentUser = $userservice->getCurrentUser();
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
$currentUsername = $currentUser->getUsername();
|
||||||
$logged_on = true;
|
|
||||||
}
|
}
|
||||||
if ($logged_on || isset($user)) {
|
if ($userservice->isLoggedOn() || isset($user)) {
|
||||||
?>
|
?>
|
||||||
<td><?php echo T_('Search' /* Search ... for */); ?></td>
|
<td><?php echo T_('Search' /* Search ... for */); ?></td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -26,7 +26,7 @@ $select_all = isset($select_all)?$select_all:'';
|
||||||
<option value="<?php echo $user ?>"<?php //echo $selectUser; ?>><?php echo T_("this user's bookmarks"); ?></option>
|
<option value="<?php echo $user ?>"<?php //echo $selectUser; ?>><?php echo T_("this user's bookmarks"); ?></option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($logged_on) {
|
if ($userservice->isLoggedOn()) {
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $currentUsername; ?>"<?php //echo $selectMy; ?>><?php echo T_('my bookmarks'); ?></option>
|
<option value="<?php echo $currentUsername; ?>"<?php //echo $selectMy; ?>><?php echo T_('my bookmarks'); ?></option>
|
||||||
<option value="watchlist"<?php echo $select_watchlist; ?>><?php echo T_('my watchlist'); ?></option>
|
<option value="watchlist"<?php echo $select_watchlist; ?>><?php echo T_('my watchlist'); ?></option>
|
||||||
|
|
215
search.php
215
search.php
|
@ -1,117 +1,136 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2005 - 2006 Scuttle project
|
Copyright (C) 2005 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['terms']) ? define('POST_TERMS', $_POST['terms']): define('POST_TERMS', '');
|
||||||
|
isset($_POST['range']) ? define('POST_RANGE', $_POST['range']): define('POST_RANGE', '');
|
||||||
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
|
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
if (isset($_POST['terms'])) {
|
if (POST_TERMS != '') {
|
||||||
// Redirect to GET
|
// Redirect to GET
|
||||||
header('Location: '. createURL('search', $_POST['range'] .'/'. filter($_POST['terms'], 'url')));
|
header('Location: '. createURL('search', POST_RANGE .'/'. filter(POST_TERMS, 'url')));
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
} else {
|
} else {
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
/* Service creation: only useful services are created */
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$searchhistoryservice =& ServiceFactory::getServiceInstance('SearchHistoryService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$searchhistoryservice =& ServiceFactory::getServiceInstance('SearchHistoryService');
|
||||||
|
|
||||||
$logged_on_userid = $userservice->getCurrentUserId();
|
/* Managing current logged user */
|
||||||
list($url, $range, $terms, $page) = explode('/', $_SERVER['PATH_INFO']);
|
$currentUserId = $userservice->getCurrentUserId();
|
||||||
|
|
||||||
|
|
||||||
|
$exploded = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
if(count($exploded) == 4) {
|
||||||
|
list($url, $range, $terms, $page) = $exploded;
|
||||||
|
} else {
|
||||||
|
list($url, $range, $terms) = $exploded;
|
||||||
|
$page= NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$tplvars = array();
|
$tplvars = array();
|
||||||
$tplVars['loadjs'] = true;
|
$tplVars['loadjs'] = true;
|
||||||
|
|
||||||
// Pagination
|
|
||||||
$perpage = getPerPageCount();
|
|
||||||
if (isset($_GET['page']) && intval($_GET['page']) > 1) {
|
|
||||||
$page = $_GET['page'];
|
|
||||||
$start = ($page - 1) * $perpage;
|
|
||||||
} else {
|
|
||||||
$page = 0;
|
|
||||||
$start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$s_user = NULL;
|
|
||||||
$s_start = NULL;
|
|
||||||
$s_end = NULL;
|
|
||||||
$s_watchlist = NULL;
|
|
||||||
|
|
||||||
// No search terms
|
// Pagination
|
||||||
if (is_null($terms)) {
|
$perpage = getPerPageCount();
|
||||||
$tplVars['subtitle'] = T_('Search Bookmarks');
|
if (intval(GET_PAGE) > 1) {
|
||||||
$s_start = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
|
$page = GET_PAGE;
|
||||||
$s_end = date('Y-m-d H:i:s', strtotime('tomorrow'));
|
$start = ($page - 1) * $perpage;
|
||||||
|
} else {
|
||||||
// Search terms
|
$page = 0;
|
||||||
} else {
|
$start = 0;
|
||||||
$tplVars['subtitle'] = T_('Search Results');
|
}
|
||||||
$selected = ' selected="selected"';
|
|
||||||
|
|
||||||
switch ($range) {
|
$s_user = NULL;
|
||||||
case 'all':
|
$s_start = NULL;
|
||||||
$tplVars['select_all'] = $selected;
|
$s_end = NULL;
|
||||||
$s_user = NULL;
|
$s_watchlist = NULL;
|
||||||
break;
|
|
||||||
case 'watchlist':
|
|
||||||
$tplVars['select_watchlist'] = $selected;
|
|
||||||
$s_user = $logged_on_userid;
|
|
||||||
$s_watchlist = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$s_user = $range;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($s_user)) {
|
// No search terms
|
||||||
if (is_numeric($s_user)) {
|
if (is_null($terms)) {
|
||||||
$s_user = intval($s_user);
|
$tplVars['subtitle'] = T_('Search Bookmarks');
|
||||||
} else {
|
$s_start = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
|
||||||
if (!($userinfo = $userservice->getUserByUsername($s_user) ) ) {
|
$s_end = date('Y-m-d H:i:s', strtotime('tomorrow'));
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $s_user);
|
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
$s_user =& $userinfo[$userservice->getFieldName('primary')];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $s_user, NULL, $terms, getSortOrder(), $s_watchlist, $s_start, $s_end);
|
|
||||||
|
|
||||||
// Save search
|
// Search terms
|
||||||
$searchhistoryservice->addSearch($terms, $range, $bookmarks['total'], $logged_on_userid);
|
} else {
|
||||||
|
$tplVars['subtitle'] = T_('Search Results');
|
||||||
$tplVars['page'] = $page;
|
$selected = ' selected="selected"';
|
||||||
$tplVars['start'] = $start;
|
|
||||||
$tplVars['popCount'] = 25;
|
switch ($range) {
|
||||||
$tplVars['sidebar_blocks'] = array('search', 'recent');
|
case 'all':
|
||||||
$tplVars['range'] = $range;
|
$tplVars['select_all'] = $selected;
|
||||||
$tplVars['terms'] = $terms;
|
$s_user = NULL;
|
||||||
$tplVars['pagetitle'] = T_('Search Bookmarks');
|
break;
|
||||||
$tplVars['bookmarkCount'] = $start + 1;
|
case 'watchlist':
|
||||||
$tplVars['total'] = $bookmarks['total'];
|
$tplVars['select_watchlist'] = $selected;
|
||||||
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
|
$s_user = $currentUserId;
|
||||||
$tplVars['cat_url'] = createURL('tags', '%2$s');
|
$s_watchlist = true;
|
||||||
$tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
|
break;
|
||||||
|
default:
|
||||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
$s_user = $range;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($s_user)) {
|
||||||
|
if (is_numeric($s_user)) {
|
||||||
|
$s_user = intval($s_user);
|
||||||
|
} else {
|
||||||
|
$userinfo = $userservice->getObjectUserByUsername($s_user);
|
||||||
|
if ($userinfo == '' ) {
|
||||||
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $s_user);
|
||||||
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$s_user =& $userinfo->getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $s_user, NULL, $terms, getSortOrder(), $s_watchlist, $s_start, $s_end);
|
||||||
|
|
||||||
|
// Save search
|
||||||
|
$searchhistoryservice->addSearch($terms, $range, $bookmarks['total'], $currentUserId);
|
||||||
|
|
||||||
|
$tplVars['rsschannels'] = array();
|
||||||
|
$tplVars['page'] = $page;
|
||||||
|
$tplVars['start'] = $start;
|
||||||
|
$tplVars['popCount'] = 25;
|
||||||
|
$tplVars['sidebar_blocks'] = array('search', 'recent');
|
||||||
|
$tplVars['range'] = $range;
|
||||||
|
$tplVars['terms'] = $terms;
|
||||||
|
$tplVars['pagetitle'] = T_('Search Bookmarks');
|
||||||
|
$tplVars['bookmarkCount'] = $start + 1;
|
||||||
|
$tplVars['total'] = $bookmarks['total'];
|
||||||
|
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
|
||||||
|
$tplVars['cat_url'] = createURL('tags', '%2$s');
|
||||||
|
$tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
|
||||||
|
|
||||||
|
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,188 +1,189 @@
|
||||||
<?php
|
<?php
|
||||||
class Bookmark2TagService {
|
class Bookmark2TagService {
|
||||||
var $db;
|
var $db;
|
||||||
var $tablename;
|
var $tablename;
|
||||||
|
|
||||||
function &getInstance(&$db) {
|
|
||||||
static $instance;
|
|
||||||
if (!isset($instance))
|
|
||||||
$instance =& new Bookmark2TagService($db);
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Bookmark2TagService(&$db) {
|
|
||||||
$this->db =& $db;
|
|
||||||
$this->tablename = $GLOBALS['tableprefix'] .'bookmarks2tags';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNotSystemTag($var) {
|
|
||||||
if (utf8_substr($var, 0, 7) == 'system:')
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function attachTags($bookmarkid, $tags, $fromApi = false, $extension = NULL, $replace = true, $fromImport = false) {
|
|
||||||
// Make sure that categories is an array of trimmed strings, and that if the categories are
|
|
||||||
// coming in from an API call to add a bookmark, that underscores are converted into strings.
|
|
||||||
if (!is_array($tags)) {
|
|
||||||
$tags = trim($tags);
|
|
||||||
if ($tags != '') {
|
|
||||||
if (substr($tags, -1) == ',') {
|
|
||||||
$tags = substr($tags, 0, -1);
|
|
||||||
}
|
|
||||||
if ($fromApi) {
|
|
||||||
$tags = explode(' ', $tags);
|
|
||||||
} else {
|
|
||||||
$tags = explode(',', $tags);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$tags = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//clean tags from strange characters
|
|
||||||
$tags = str_replace(array('"', '\''), "_", $tags);
|
|
||||||
|
|
||||||
|
|
||||||
$tags_count = count($tags);
|
|
||||||
for ($i = 0; $i < $tags_count; $i++) {
|
|
||||||
$tags[$i] = trim(strtolower($tags[$i]));
|
|
||||||
if ($fromApi) {
|
|
||||||
include_once(dirname(__FILE__) .'/../functions.inc.php');
|
|
||||||
$tags[$i] = convertTag($tags[$i], 'in');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tags_count > 0) {
|
|
||||||
// Remove system tags
|
|
||||||
$tags = array_filter($tags, array($this, "isNotSystemTag"));
|
|
||||||
|
|
||||||
// Eliminate any duplicate categories
|
|
||||||
$temp = array_unique($tags);
|
|
||||||
$tags = array_values($temp);
|
|
||||||
} else {
|
|
||||||
// Unfiled
|
|
||||||
$tags[] = 'system:unfiled';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Media and file types
|
|
||||||
if (!is_null($extension)) {
|
|
||||||
include_once(dirname(__FILE__) .'/../functions.inc.php');
|
|
||||||
if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) {
|
|
||||||
$tags[] = 'system:filetype:'. $extension;
|
|
||||||
$tags[] = 'system:media:'. array_shift($keys);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Imported
|
|
||||||
if ($fromImport) {
|
|
||||||
$tags[] = 'system:imported';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->sql_transaction('begin');
|
|
||||||
|
|
||||||
if ($replace) {
|
|
||||||
if (!$this->deleteTagsForBookmark($bookmarkid)){
|
|
||||||
$this->db->sql_transaction('rollback');
|
|
||||||
message_die(GENERAL_ERROR, 'Could not attach tags (deleting old ones failed)', '', __LINE__, __FILE__, $sql, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
|
||||||
$tts =& ServiceFactory::getServiceInstance('Tag2TagService');
|
|
||||||
|
|
||||||
// Create links between tags
|
|
||||||
foreach($tags as $key => $tag) {
|
|
||||||
if(strpos($tag, '=')) {
|
|
||||||
// case "="
|
|
||||||
$pieces = explode('=', $tag);
|
|
||||||
$nbPieces = count($pieces);
|
|
||||||
if($nbPieces > 1) {
|
|
||||||
for($i = 0; $i < $nbPieces-1; $i++) {
|
|
||||||
$bookmark = $bs->getBookmark($bookmarkid);
|
|
||||||
$uId = $bookmark['uId'];
|
|
||||||
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '=', $uId);
|
|
||||||
}
|
|
||||||
$tags[$key] = $pieces[0]; // Attach just the last tag to the bookmark
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// case ">"
|
|
||||||
$pieces = explode('>', $tag);
|
|
||||||
$nbPieces = count($pieces);
|
|
||||||
if($nbPieces > 1) {
|
|
||||||
for($i = 0; $i < $nbPieces-1; $i++) {
|
|
||||||
$bookmark = $bs->getBookmark($bookmarkid);
|
|
||||||
$uId = $bookmark['uId'];
|
|
||||||
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
|
|
||||||
}
|
|
||||||
$tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
function &getInstance(&$db) {
|
||||||
|
static $instance;
|
||||||
|
if (!isset($instance))
|
||||||
|
$instance =& new Bookmark2TagService($db);
|
||||||
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the categories to the DB.
|
function Bookmark2TagService(&$db) {
|
||||||
for ($i = 0; $i < count($tags); $i++) {
|
$this->db =& $db;
|
||||||
if ($tags[$i] != '') {
|
$this->tablename = $GLOBALS['tableprefix'] .'bookmarks2tags';
|
||||||
$values = array(
|
}
|
||||||
|
|
||||||
|
function isNotSystemTag($var) {
|
||||||
|
if (utf8_substr($var, 0, 7) == 'system:')
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachTags($bookmarkid, $tags, $fromApi = false, $extension = NULL, $replace = true, $fromImport = false) {
|
||||||
|
// Make sure that categories is an array of trimmed strings, and that if the categories are
|
||||||
|
// coming in from an API call to add a bookmark, that underscores are converted into strings.
|
||||||
|
if (!is_array($tags)) {
|
||||||
|
$tags = trim($tags);
|
||||||
|
if ($tags != '') {
|
||||||
|
if (substr($tags, -1) == ',') {
|
||||||
|
$tags = substr($tags, 0, -1);
|
||||||
|
}
|
||||||
|
if ($fromApi) {
|
||||||
|
$tags = explode(' ', $tags);
|
||||||
|
} else {
|
||||||
|
$tags = explode(',', $tags);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$tags = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//clean tags from strange characters
|
||||||
|
$tags = str_replace(array('"', '\''), "_", $tags);
|
||||||
|
|
||||||
|
|
||||||
|
$tags_count = is_array($tags)?count($tags):0;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $tags_count; $i++) {
|
||||||
|
$tags[$i] = trim(strtolower($tags[$i]));
|
||||||
|
if ($fromApi) {
|
||||||
|
include_once(dirname(__FILE__) .'/../functions.inc.php');
|
||||||
|
$tags[$i] = convertTag($tags[$i], 'in');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tags_count > 0) {
|
||||||
|
// Remove system tags
|
||||||
|
$tags = array_filter($tags, array($this, "isNotSystemTag"));
|
||||||
|
|
||||||
|
// Eliminate any duplicate categories
|
||||||
|
$temp = array_unique($tags);
|
||||||
|
$tags = array_values($temp);
|
||||||
|
} else {
|
||||||
|
// Unfiled
|
||||||
|
$tags[] = 'system:unfiled';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Media and file types
|
||||||
|
if (!is_null($extension)) {
|
||||||
|
include_once(dirname(__FILE__) .'/../functions.inc.php');
|
||||||
|
if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) {
|
||||||
|
$tags[] = 'system:filetype:'. $extension;
|
||||||
|
$tags[] = 'system:media:'. array_shift($keys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Imported
|
||||||
|
if ($fromImport) {
|
||||||
|
$tags[] = 'system:imported';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->sql_transaction('begin');
|
||||||
|
|
||||||
|
if ($replace) {
|
||||||
|
if (!$this->deleteTagsForBookmark($bookmarkid)){
|
||||||
|
$this->db->sql_transaction('rollback');
|
||||||
|
message_die(GENERAL_ERROR, 'Could not attach tags (deleting old ones failed)', '', __LINE__, __FILE__, $sql, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
|
$tts =& ServiceFactory::getServiceInstance('Tag2TagService');
|
||||||
|
|
||||||
|
// Create links between tags
|
||||||
|
foreach($tags as $key => $tag) {
|
||||||
|
if(strpos($tag, '=')) {
|
||||||
|
// case "="
|
||||||
|
$pieces = explode('=', $tag);
|
||||||
|
$nbPieces = count($pieces);
|
||||||
|
if($nbPieces > 1) {
|
||||||
|
for($i = 0; $i < $nbPieces-1; $i++) {
|
||||||
|
$bookmark = $bs->getBookmark($bookmarkid);
|
||||||
|
$uId = $bookmark['uId'];
|
||||||
|
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '=', $uId);
|
||||||
|
}
|
||||||
|
$tags[$key] = $pieces[0]; // Attach just the last tag to the bookmark
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// case ">"
|
||||||
|
$pieces = explode('>', $tag);
|
||||||
|
$nbPieces = count($pieces);
|
||||||
|
if($nbPieces > 1) {
|
||||||
|
for($i = 0; $i < $nbPieces-1; $i++) {
|
||||||
|
$bookmark = $bs->getBookmark($bookmarkid);
|
||||||
|
$uId = $bookmark['uId'];
|
||||||
|
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
|
||||||
|
}
|
||||||
|
$tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the categories to the DB.
|
||||||
|
for ($i = 0; $i < count($tags); $i++) {
|
||||||
|
if ($tags[$i] != '') {
|
||||||
|
$values = array(
|
||||||
'bId' => intval($bookmarkid),
|
'bId' => intval($bookmarkid),
|
||||||
'tag' => $tags[$i]
|
'tag' => $tags[$i]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$this->hasTag($bookmarkid, $tags[$i])) {
|
if (!$this->hasTag($bookmarkid, $tags[$i])) {
|
||||||
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
||||||
if (!($dbresult =& $this->db->sql_query($sql))) {
|
if (!($dbresult =& $this->db->sql_query($sql))) {
|
||||||
$this->db->sql_transaction('rollback');
|
$this->db->sql_transaction('rollback');
|
||||||
message_die(GENERAL_ERROR, 'Could not attach tags', '', __LINE__, __FILE__, $sql, $this->db);
|
message_die(GENERAL_ERROR, 'Could not attach tags', '', __LINE__, __FILE__, $sql, $this->db);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->db->sql_transaction('commit');
|
$this->db->sql_transaction('commit');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTag($uId, $tag) {
|
|
||||||
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
|
||||||
|
|
||||||
$query = 'DELETE FROM '. $this->getTableName();
|
function deleteTag($uId, $tag) {
|
||||||
$query.= ' USING '. $this->getTableName() .', '. $bs->getTableName();
|
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$query.= ' WHERE '. $this->getTableName() .'.bId = '. $bs->getTableName() .'.bId';
|
|
||||||
$query.= ' AND '. $bs->getTableName() .'.uId = '. $uId;
|
|
||||||
$query.= ' AND '. $this->getTableName() .'.tag = "'. $this->db->sql_escape($tag) .'"';
|
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
$query = 'DELETE FROM '. $this->getTableName();
|
||||||
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
$query.= ' USING '. $this->getTableName() .', '. $bs->getTableName();
|
||||||
return false;
|
$query.= ' WHERE '. $this->getTableName() .'.bId = '. $bs->getTableName() .'.bId';
|
||||||
}
|
$query.= ' AND '. $bs->getTableName() .'.uId = '. $uId;
|
||||||
|
$query.= ' AND '. $this->getTableName() .'.tag = "'. $this->db->sql_escape($tag) .'"';
|
||||||
|
|
||||||
return true;
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
}
|
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
function deleteTagsForBookmark($bookmarkid) {
|
}
|
||||||
if (!is_int($bookmarkid)) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not delete tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = 'DELETE FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
function deleteTagsForBookmark($bookmarkid) {
|
||||||
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
if (!is_int($bookmarkid)) {
|
||||||
return false;
|
message_die(GENERAL_ERROR, 'Could not delete tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
$query = 'DELETE FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid);
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow deletion in admin page */
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
function deleteTagsForUser($uId) {
|
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
$qmask = 'DELETE FROM %s USING %s, %s WHERE %s.bId = %s.bId AND %s.uId = %d';
|
return false;
|
||||||
$query = sprintf($qmask,
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow deletion in admin page */
|
||||||
|
function deleteTagsForUser($uId) {
|
||||||
|
$qmask = 'DELETE FROM %s USING %s, %s WHERE %s.bId = %s.bId AND %s.uId = %d';
|
||||||
|
$query = sprintf($qmask,
|
||||||
$this->getTableName(),
|
$this->getTableName(),
|
||||||
$this->getTableName(),
|
$this->getTableName(),
|
||||||
$GLOBALS['tableprefix'].'bookmarks',
|
$GLOBALS['tableprefix'].'bookmarks',
|
||||||
|
@ -191,245 +192,246 @@ class Bookmark2TagService {
|
||||||
$GLOBALS['tableprefix'].'bookmarks',
|
$GLOBALS['tableprefix'].'bookmarks',
|
||||||
$uId);
|
$uId);
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getTagsForBookmark($bookmarkid) {
|
function &getTagsForBookmark($bookmarkid) {
|
||||||
if (!is_int($bookmarkid)) {
|
if (!is_int($bookmarkid)) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
message_die(GENERAL_ERROR, 'Could not get tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = 'SELECT tag FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND LEFT(tag, 7) <> "system:" ORDER BY tag';
|
$query = 'SELECT tag FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND LEFT(tag, 7) <> "system:" ORDER BY tag';
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = array();
|
$tags = array();
|
||||||
while ($row =& $this->db->sql_fetchrow($dbresult)) {
|
while ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
$tags[] = $row['tag'];
|
$tags[] = $row['tag'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getTags($userid = NULL) {
|
function &getTags($userid = NULL) {
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$logged_on_user = $userservice->getCurrentUserId();
|
$logged_on_user = $userservice->getCurrentUserId();
|
||||||
|
|
||||||
$query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'bookmarks2tags AS T ON B.bId = T.bId';
|
$query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'bookmarks2tags AS T ON B.bId = T.bId';
|
||||||
|
|
||||||
$conditions = array();
|
$conditions = array();
|
||||||
if (!is_null($userid)) {
|
if (!is_null($userid)) {
|
||||||
$conditions['U.'. $userservice->getFieldName('primary')] = intval($userid);
|
$conditions['U.'. $userservice->getFieldName('primary')] = intval($userid);
|
||||||
if ($logged_on_user != $userid)
|
if ($logged_on_user != $userid)
|
||||||
$conditions['B.bStatus'] = 0;
|
$conditions['B.bStatus'] = 0;
|
||||||
} else {
|
} else {
|
||||||
$conditions['B.bStatus'] = 0;
|
$conditions['B.bStatus'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
|
$query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $this->db->sql_fetchrowset($dbresult);
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns the tags related to the specified tags; i.e. attached to the same bookmarks
|
|
||||||
function &getRelatedTags($tags, $for_user = NULL, $logged_on_user = NULL, $limit = 10) {
|
|
||||||
$conditions = array();
|
|
||||||
// Only count the tags that are visible to the current user.
|
|
||||||
if ($for_user != $logged_on_user || is_null($for_user))
|
|
||||||
$conditions['B.bStatus'] = 0;
|
|
||||||
|
|
||||||
if (!is_null($for_user))
|
$output = $this->db->sql_fetchrowset($dbresult);
|
||||||
$conditions['B.uId'] = $for_user;
|
return $output;
|
||||||
|
}
|
||||||
// Set up the tags, if need be.
|
|
||||||
if (is_numeric($tags))
|
|
||||||
$tags = NULL;
|
|
||||||
if (!is_array($tags) and !is_null($tags))
|
|
||||||
$tags = explode('+', trim($tags));
|
|
||||||
|
|
||||||
$tagcount = count($tags);
|
|
||||||
for ($i = 0; $i < $tagcount; $i++) {
|
|
||||||
$tags[$i] = trim($tags[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the SQL query.
|
|
||||||
$query_1 = 'SELECT DISTINCTROW T0.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B, '. $this->getTableName() .' AS T0';
|
|
||||||
$query_2 = '';
|
|
||||||
$query_3 = ' WHERE B.bId = T0.bId ';
|
|
||||||
if (count($conditions) > 0)
|
|
||||||
$query_4 = ' AND '. $this->db->sql_build_array('SELECT', $conditions);
|
|
||||||
else
|
|
||||||
$query_4 = '';
|
|
||||||
// Handle the parts of the query that depend on any tags that are present.
|
|
||||||
for ($i = 1; $i <= $tagcount; $i++) {
|
|
||||||
$query_2 .= ', '. $this->getTableName() .' AS T'. $i;
|
|
||||||
$query_4 .= ' AND T'. $i .'.bId = B.bId AND T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i - 1]) .'" AND T0.tag <> "'. $this->db->sql_escape($tags[$i - 1]) .'"';
|
|
||||||
}
|
|
||||||
$query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
|
|
||||||
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
|
|
||||||
|
|
||||||
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$output = $this->db->sql_fetchrowset($dbresult);
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the most popular tags used for a particular bookmark hash
|
|
||||||
function &getRelatedTagsByHash($hash, $limit = 20) {
|
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
|
||||||
$sId = $userservice->getCurrentUserId();
|
|
||||||
// Logged in
|
|
||||||
if ($userservice->isLoggedOn()) {
|
|
||||||
$arrWatch = $userservice->getWatchList($sId);
|
|
||||||
// From public bookmarks or user's own
|
|
||||||
$privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')';
|
|
||||||
// From shared bookmarks in watchlist
|
|
||||||
foreach ($arrWatch as $w) {
|
|
||||||
$privacy .= ' OR (B.uId = '. $w .' AND B.bStatus = 1)';
|
|
||||||
}
|
|
||||||
$privacy .= ') ';
|
|
||||||
// Not logged in
|
|
||||||
} else {
|
|
||||||
$privacy = ' AND B.bStatus = 0 ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = "'. $hash .'" '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC';
|
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
function &getPopularTags($user = NULL, $limit = 30, $logged_on_user = NULL, $days = NULL) {
|
|
||||||
// Only count the tags that are visible to the current user.
|
|
||||||
if (($user != $logged_on_user) || is_null($user) || ($user === false))
|
|
||||||
$privacy = ' AND B.bStatus = 0';
|
|
||||||
else
|
|
||||||
$privacy = '';
|
|
||||||
|
|
||||||
if (is_null($days) || !is_int($days))
|
|
||||||
$span = '';
|
|
||||||
else
|
|
||||||
$span = ' AND B.bDatetime > "'. date('Y-m-d H:i:s', time() - (86400 * $days)) .'"';
|
|
||||||
|
|
||||||
$query = 'SELECT T.tag, COUNT(T.bId) AS bCount FROM '. $this->getTableName() .' AS T, '. $GLOBALS['tableprefix'] .'bookmarks AS B WHERE ';
|
|
||||||
if (is_null($user) || ($user === false)) {
|
|
||||||
$query .= 'B.bId = T.bId AND B.bStatus = 0';
|
|
||||||
} else {
|
|
||||||
$query .= 'B.uId = '. $this->db->sql_escape($user) .' AND B.bId = T.bId'. $privacy;
|
|
||||||
}
|
|
||||||
$query .= $span .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
|
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get popular tags', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = $this->db->sql_fetchrowset($dbresult);
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasTag($bookmarkid, $tag) {
|
|
||||||
$query = 'SELECT COUNT(*) AS tCount FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND tag ="'. $this->db->sql_escape($tag) .'"';
|
|
||||||
|
|
||||||
if (! ($dbresult =& $this->db->sql_query($query)) ) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not find tag', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
|
||||||
if ($row['tCount'] > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renameTag($userid, $old, $new, $fromApi = false) {
|
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
|
||||||
|
|
||||||
if (is_null($userid) || is_null($old) || is_null($new))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Find bookmarks with old tag
|
|
||||||
$bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old);
|
|
||||||
$bookmarks =& $bookmarksInfo['bookmarks'];
|
|
||||||
|
|
||||||
// Delete old tag
|
|
||||||
$this->deleteTag($userid, $old);
|
|
||||||
|
|
||||||
// Attach new tags
|
|
||||||
foreach(array_keys($bookmarks) as $key) {
|
|
||||||
$row =& $bookmarks[$key];
|
|
||||||
$this->attachTags($row['bId'], $new, $fromApi, NULL, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function &tagCloud($tags = NULL, $steps = 5, $sizemin = 90, $sizemax = 225, $sortOrder = NULL) {
|
|
||||||
|
|
||||||
if (is_null($tags) || count($tags) < 1) {
|
|
||||||
$output = false;
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
$min = $tags[count($tags) - 1]['bCount'];
|
|
||||||
$max = $tags[0]['bCount'];
|
|
||||||
|
|
||||||
for ($i = 1; $i <= $steps; $i++) {
|
|
||||||
$delta = ($max - $min) / (2 * $steps - $i);
|
|
||||||
$limit[$i] = $i * $delta + $min;
|
|
||||||
}
|
|
||||||
$sizestep = ($sizemax - $sizemin) / $steps;
|
|
||||||
foreach ($tags as $row) {
|
|
||||||
$next = false;
|
|
||||||
for ($i = 1; $i <= $steps; $i++) {
|
|
||||||
if (!$next && $row['bCount'] <= $limit[$i]) {
|
|
||||||
$size = $sizestep * ($i - 1) + $sizemin;
|
|
||||||
$next = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tempArray = array('size' => $size .'%');
|
|
||||||
$row = array_merge($row, $tempArray);
|
|
||||||
$output[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sortOrder == 'alphabet_asc') {
|
|
||||||
usort($output, create_function('$a,$b','return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteAll() {
|
|
||||||
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
|
||||||
$this->db->sql_query($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Properties
|
// Returns the tags related to the specified tags; i.e. attached to the same bookmarks
|
||||||
function getTableName() { return $this->tablename; }
|
function &getRelatedTags($tags, $for_user = NULL, $logged_on_user = NULL, $limit = 10) {
|
||||||
function setTableName($value) { $this->tablename = $value; }
|
$conditions = array();
|
||||||
|
// Only count the tags that are visible to the current user.
|
||||||
|
if ($for_user != $logged_on_user || is_null($for_user))
|
||||||
|
$conditions['B.bStatus'] = 0;
|
||||||
|
|
||||||
|
if (!is_null($for_user))
|
||||||
|
$conditions['B.uId'] = $for_user;
|
||||||
|
|
||||||
|
// Set up the tags, if need be.
|
||||||
|
if (is_numeric($tags))
|
||||||
|
$tags = NULL;
|
||||||
|
if (!is_array($tags) and !is_null($tags))
|
||||||
|
$tags = explode('+', trim($tags));
|
||||||
|
|
||||||
|
$tagcount = count($tags);
|
||||||
|
for ($i = 0; $i < $tagcount; $i++) {
|
||||||
|
$tags[$i] = trim($tags[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the SQL query.
|
||||||
|
$query_1 = 'SELECT DISTINCTROW T0.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B, '. $this->getTableName() .' AS T0';
|
||||||
|
$query_2 = '';
|
||||||
|
$query_3 = ' WHERE B.bId = T0.bId ';
|
||||||
|
if (count($conditions) > 0)
|
||||||
|
$query_4 = ' AND '. $this->db->sql_build_array('SELECT', $conditions);
|
||||||
|
else
|
||||||
|
$query_4 = '';
|
||||||
|
// Handle the parts of the query that depend on any tags that are present.
|
||||||
|
for ($i = 1; $i <= $tagcount; $i++) {
|
||||||
|
$query_2 .= ', '. $this->getTableName() .' AS T'. $i;
|
||||||
|
$query_4 .= ' AND T'. $i .'.bId = B.bId AND T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i - 1]) .'" AND T0.tag <> "'. $this->db->sql_escape($tags[$i - 1]) .'"';
|
||||||
|
}
|
||||||
|
$query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
|
||||||
|
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
|
||||||
|
|
||||||
|
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$output = $this->db->sql_fetchrowset($dbresult);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the most popular tags used for a particular bookmark hash
|
||||||
|
function &getRelatedTagsByHash($hash, $limit = 20) {
|
||||||
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
$sId = $userservice->getCurrentUserId();
|
||||||
|
// Logged in
|
||||||
|
if ($userservice->isLoggedOn()) {
|
||||||
|
$arrWatch = $userservice->getWatchList($sId);
|
||||||
|
// From public bookmarks or user's own
|
||||||
|
$privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')';
|
||||||
|
// From shared bookmarks in watchlist
|
||||||
|
foreach ($arrWatch as $w) {
|
||||||
|
$privacy .= ' OR (B.uId = '. $w .' AND B.bStatus = 1)';
|
||||||
|
}
|
||||||
|
$privacy .= ') ';
|
||||||
|
// Not logged in
|
||||||
|
} else {
|
||||||
|
$privacy = ' AND B.bStatus = 0 ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = "'. $hash .'" '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC';
|
||||||
|
|
||||||
|
if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$output = $this->db->sql_fetchrowset($dbresult);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function &getPopularTags($user = NULL, $limit = 30, $logged_on_user = NULL, $days = NULL) {
|
||||||
|
// Only count the tags that are visible to the current user.
|
||||||
|
if (($user != $logged_on_user) || is_null($user) || ($user === false))
|
||||||
|
$privacy = ' AND B.bStatus = 0';
|
||||||
|
else
|
||||||
|
$privacy = '';
|
||||||
|
|
||||||
|
if (is_null($days) || !is_int($days))
|
||||||
|
$span = '';
|
||||||
|
else
|
||||||
|
$span = ' AND B.bDatetime > "'. date('Y-m-d H:i:s', time() - (86400 * $days)) .'"';
|
||||||
|
|
||||||
|
$query = 'SELECT T.tag, COUNT(T.bId) AS bCount FROM '. $this->getTableName() .' AS T, '. $GLOBALS['tableprefix'] .'bookmarks AS B WHERE ';
|
||||||
|
if (is_null($user) || ($user === false)) {
|
||||||
|
$query .= 'B.bId = T.bId AND B.bStatus = 0';
|
||||||
|
} else {
|
||||||
|
$query .= 'B.uId = '. $this->db->sql_escape($user) .' AND B.bId = T.bId'. $privacy;
|
||||||
|
}
|
||||||
|
$query .= $span .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
|
||||||
|
|
||||||
|
if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get popular tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $this->db->sql_fetchrowset($dbresult);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasTag($bookmarkid, $tag) {
|
||||||
|
$query = 'SELECT COUNT(*) AS tCount FROM '. $this->getTableName() .' WHERE bId = '. intval($bookmarkid) .' AND tag ="'. $this->db->sql_escape($tag) .'"';
|
||||||
|
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not find tag', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
if ($row['tCount'] > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renameTag($userid, $old, $new, $fromApi = false) {
|
||||||
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
|
|
||||||
|
if (is_null($userid) || is_null($old) || is_null($new))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Find bookmarks with old tag
|
||||||
|
$bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old);
|
||||||
|
$bookmarks =& $bookmarksInfo['bookmarks'];
|
||||||
|
|
||||||
|
// Delete old tag
|
||||||
|
$this->deleteTag($userid, $old);
|
||||||
|
|
||||||
|
// Attach new tags
|
||||||
|
foreach(array_keys($bookmarks) as $key) {
|
||||||
|
$row =& $bookmarks[$key];
|
||||||
|
$this->attachTags($row['bId'], $new, $fromApi, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function &tagCloud($tags = NULL, $steps = 5, $sizemin = 90, $sizemax = 225, $sortOrder = NULL) {
|
||||||
|
|
||||||
|
if (is_null($tags) || count($tags) < 1) {
|
||||||
|
$output = false;
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$min = $tags[count($tags) - 1]['bCount'];
|
||||||
|
$max = $tags[0]['bCount'];
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $steps; $i++) {
|
||||||
|
$delta = ($max - $min) / (2 * $steps - $i);
|
||||||
|
$limit[$i] = $i * $delta + $min;
|
||||||
|
}
|
||||||
|
$sizestep = ($sizemax - $sizemin) / $steps;
|
||||||
|
foreach ($tags as $row) {
|
||||||
|
$next = false;
|
||||||
|
for ($i = 1; $i <= $steps; $i++) {
|
||||||
|
if (!$next && $row['bCount'] <= $limit[$i]) {
|
||||||
|
$size = $sizestep * ($i - 1) + $sizemin;
|
||||||
|
$next = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tempArray = array('size' => $size .'%');
|
||||||
|
$row = array_merge($row, $tempArray);
|
||||||
|
$output[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sortOrder == 'alphabet_asc') {
|
||||||
|
usort($output, create_function('$a,$b','return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
||||||
|
$this->db->sql_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
function getTableName() { return $this->tablename; }
|
||||||
|
function setTableName($value) { $this->tablename = $value; }
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,6 +20,8 @@ class BookmarkService {
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
$sId = $userservice->getCurrentUserId();
|
$sId = $userservice->getCurrentUserId();
|
||||||
$range = ' AND uId = '. $sId;
|
$range = ' AND uId = '. $sId;
|
||||||
|
} else {
|
||||||
|
$range = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = 'SELECT * FROM '. $this->getTableName() .' WHERE '. $fieldname .' = "'. $this->db->sql_escape($value) .'"'. $range;
|
$query = 'SELECT * FROM '. $this->getTableName() .' WHERE '. $fieldname .' = "'. $this->db->sql_escape($value) .'"'. $range;
|
||||||
|
@ -271,6 +273,7 @@ class BookmarkService {
|
||||||
} else {
|
} else {
|
||||||
$arrWatch = $userservice->getWatchlist($user);
|
$arrWatch = $userservice->getWatchlist($user);
|
||||||
if (count($arrWatch) > 0) {
|
if (count($arrWatch) > 0) {
|
||||||
|
$query_3_1 = '';
|
||||||
foreach($arrWatch as $row) {
|
foreach($arrWatch as $row) {
|
||||||
$query_3_1 .= 'B.uId = '. intval($row) .' OR ';
|
$query_3_1 .= 'B.uId = '. intval($row) .' OR ';
|
||||||
}
|
}
|
||||||
|
@ -280,7 +283,7 @@ class BookmarkService {
|
||||||
}
|
}
|
||||||
$query_3 .= ' AND ('. $query_3_1 .') AND B.bStatus IN (0, 1)';
|
$query_3 .= ' AND ('. $query_3_1 .') AND B.bStatus IN (0, 1)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query_5 = '';
|
$query_5 = '';
|
||||||
if($hash == null) {
|
if($hash == null) {
|
||||||
$query_5.= ' GROUP BY B.bHash';
|
$query_5.= ' GROUP BY B.bHash';
|
||||||
|
|
|
@ -1,153 +1,153 @@
|
||||||
<?php
|
<?php
|
||||||
class CommonDescriptionService {
|
class CommonDescriptionService {
|
||||||
var $db;
|
var $db;
|
||||||
var $tablename;
|
var $tablename;
|
||||||
|
|
||||||
function &getInstance(&$db) {
|
function &getInstance(&$db) {
|
||||||
static $instance;
|
static $instance;
|
||||||
if (!isset($instance))
|
if (!isset($instance))
|
||||||
$instance =& new CommonDescriptionService($db);
|
$instance =& new CommonDescriptionService($db);
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
|
||||||
|
|
||||||
function CommonDescriptionService(&$db) {
|
|
||||||
$this->db =& $db;
|
|
||||||
$this->tablename = $GLOBALS['tableprefix'] .'commondescription';
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTagDescription($tag, $desc, $uId, $time) {
|
|
||||||
// Check if no modification
|
|
||||||
$lastDesc = $this->getLastTagDescription($tag);
|
|
||||||
if($lastDesc['cdDescription'] == $desc) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If modification
|
function CommonDescriptionService(&$db) {
|
||||||
$datetime = gmdate('Y-m-d H:i:s', $time);
|
$this->db =& $db;
|
||||||
$values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
|
$this->tablename = $GLOBALS['tableprefix'] .'commondescription';
|
||||||
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($sql))) {
|
|
||||||
$this->db->sql_transaction('rollback');
|
|
||||||
message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
function addTagDescription($tag, $desc, $uId, $time) {
|
||||||
}
|
// Check if no modification
|
||||||
|
$lastDesc = $this->getLastTagDescription($tag);
|
||||||
|
if($lastDesc['cdDescription'] == $desc) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function getLastTagDescription($tag) {
|
// If modification
|
||||||
$query = "SELECT *";
|
$datetime = gmdate('Y-m-d H:i:s', $time);
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
$values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
|
||||||
$query.= " WHERE tag='".$tag."'";
|
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
||||||
$query.= " ORDER BY cdDatetime DESC";
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
|
if (!($dbresult =& $this->db->sql_query($sql))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
$this->db->sql_transaction('rollback');
|
||||||
return false;
|
message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
return true;
|
||||||
return $row;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAllTagsDescription($tag) {
|
|
||||||
$query = "SELECT *";
|
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE tag='".$tag."'";
|
|
||||||
$query.= " ORDER BY cdDatetime DESC";
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDescriptionById($cdId) {
|
|
||||||
$query = "SELECT *";
|
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE cdId='".$cdId."'";
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
|
||||||
return $row;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function addBookmarkDescription($bHash, $title, $desc, $uId, $time) {
|
|
||||||
// Check if no modification
|
|
||||||
$lastDesc = $this->getLastBookmarkDescription($bHash);
|
|
||||||
if($lastDesc['cdTitle'] == $title && $lastDesc['cdDescription'] == $desc) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If modification
|
function getLastTagDescription($tag) {
|
||||||
$datetime = gmdate('Y-m-d H:i:s', $time);
|
$query = "SELECT *";
|
||||||
$values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
$query.= " WHERE tag='".$tag."'";
|
||||||
|
$query.= " ORDER BY cdDatetime DESC";
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($sql))) {
|
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
|
||||||
$this->db->sql_transaction('rollback');
|
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db);
|
return false;
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
return $row;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLastBookmarkDescription($bHash) {
|
function getAllTagsDescription($tag) {
|
||||||
$query = "SELECT *";
|
$query = "SELECT *";
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
$query.= " WHERE bHash='".$bHash."'";
|
$query.= " WHERE tag='".$tag."'";
|
||||||
$query.= " ORDER BY cdDatetime DESC";
|
$query.= " ORDER BY cdDatetime DESC";
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
return $this->db->sql_fetchrowset($dbresult);
|
||||||
return $row;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAllBookmarksDescription($bHash) {
|
}
|
||||||
$query = "SELECT *";
|
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE bHash='".$bHash."'";
|
|
||||||
$query.= " ORDER BY cdDatetime DESC";
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
function getDescriptionById($cdId) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
$query = "SELECT *";
|
||||||
return false;
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
}
|
$query.= " WHERE cdId='".$cdId."'";
|
||||||
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
return $row;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBookmarkDescription($bHash, $title, $desc, $uId, $time) {
|
||||||
|
// Check if no modification
|
||||||
|
$lastDesc = $this->getLastBookmarkDescription($bHash);
|
||||||
|
if($lastDesc['cdTitle'] == $title && $lastDesc['cdDescription'] == $desc) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If modification
|
||||||
|
$datetime = gmdate('Y-m-d H:i:s', $time);
|
||||||
|
$values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
|
||||||
|
$sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
||||||
|
|
||||||
|
if (!($dbresult =& $this->db->sql_query($sql))) {
|
||||||
|
$this->db->sql_transaction('rollback');
|
||||||
|
message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLastBookmarkDescription($bHash) {
|
||||||
|
$query = "SELECT *";
|
||||||
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE bHash='".$bHash."'";
|
||||||
|
$query.= " ORDER BY cdDatetime DESC";
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
return $row;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllBookmarksDescription($bHash) {
|
||||||
|
$query = "SELECT *";
|
||||||
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE bHash='".$bHash."'";
|
||||||
|
$query.= " ORDER BY cdDatetime DESC";
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->db->sql_fetchrowset($dbresult);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function deleteAll() {
|
function deleteAll() {
|
||||||
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
||||||
$this->db->sql_query($query);
|
$this->db->sql_query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
function getTableName() { return $this->tablename; }
|
function getTableName() { return $this->tablename; }
|
||||||
function setTableName($value) { $this->tablename = $value; }
|
function setTableName($value) { $this->tablename = $value; }
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,297 +1,297 @@
|
||||||
<?php
|
<?php
|
||||||
class Tag2TagService {
|
class Tag2TagService {
|
||||||
var $db;
|
var $db;
|
||||||
var $tablename;
|
var $tablename;
|
||||||
|
|
||||||
function &getInstance(&$db) {
|
function &getInstance(&$db) {
|
||||||
static $instance;
|
static $instance;
|
||||||
if (!isset($instance))
|
if (!isset($instance))
|
||||||
$instance =& new Tag2TagService($db);
|
$instance =& new Tag2TagService($db);
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Tag2TagService(&$db) {
|
function Tag2TagService(&$db) {
|
||||||
$this->db =& $db;
|
$this->db =& $db;
|
||||||
$this->tablename = $GLOBALS['tableprefix'] .'tags2tags';
|
$this->tablename = $GLOBALS['tableprefix'] .'tags2tags';
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLinkedTags($tag1, $tag2, $relationType, $uId) {
|
function addLinkedTags($tag1, $tag2, $relationType, $uId) {
|
||||||
if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
|
if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
|
||||||
|| ($relationType != ">" && $relationType != "=")
|
|| ($relationType != ">" && $relationType != "=")
|
||||||
|| ($this->existsLinkedTags($tag1, $tag2, $relationType, $uId))) {
|
|| ($this->existsLinkedTags($tag1, $tag2, $relationType, $uId))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
$values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> $relationType, 'uId'=> $uId);
|
|
||||||
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
|
||||||
//die($query);
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
|
||||||
$this->db->sql_transaction('rollback');
|
|
||||||
message_die(GENERAL_ERROR, 'Could not attach tag to tag', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->db->sql_transaction('commit');
|
|
||||||
|
|
||||||
// Update stats
|
|
||||||
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
|
||||||
$tsts->updateStat($tag1, $relationType, $uId);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the target linked tags. If inverseRelation is true, return the source linked tags.
|
|
||||||
function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
|
|
||||||
// Set up the SQL query.
|
|
||||||
if($inverseRelation) {
|
|
||||||
$queriedTag = "tag1";
|
|
||||||
$givenTag = "tag2";
|
|
||||||
} else {
|
|
||||||
$queriedTag = "tag2";
|
|
||||||
$givenTag = "tag1";
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "SELECT DISTINCT ". $queriedTag ." as 'tag'";
|
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE 1=1";
|
|
||||||
if($tag !=null) {
|
|
||||||
$query.= " AND ". $givenTag ." = '". $tag ."'";
|
|
||||||
}
|
|
||||||
if($relationType) {
|
|
||||||
$query.= " AND relationType = '". $relationType ."'";
|
|
||||||
}
|
|
||||||
if($uId != null) {
|
|
||||||
$query.= " AND uId = '".$uId."'";
|
|
||||||
}
|
|
||||||
//die($query);
|
|
||||||
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowset = $this->db->sql_fetchrowset($dbresult);
|
|
||||||
$output = array();
|
|
||||||
foreach($rowset as $row) {
|
|
||||||
if(!in_array($row['tag'], $stopList)) {
|
|
||||||
|
|
||||||
$output[] = $row['tag'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//bijective case for '='
|
|
||||||
if($relationType == '=' && $inverseRelation == false) {
|
|
||||||
//$stopList[] = $tag;
|
|
||||||
$bijectiveOutput = $this->getLinkedTags($tag, $relationType, $uId, true, $stopList);
|
|
||||||
$output = array_merge($output, $bijectiveOutput);
|
|
||||||
//$output = array_unique($output); // remove duplication
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: clean the outputs to obtain homogenous ones*/
|
|
||||||
function getAllLinkedTags($tag1, $relationType, $uId, $asFlatList=true, $stopList=array()) {
|
|
||||||
$asFlatList = true; //we disable the tree list parameter for the moment
|
|
||||||
|
|
||||||
if(in_array($tag1, $stopList)) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$stopList[] = $tag1;
|
|
||||||
$linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList);
|
|
||||||
|
|
||||||
if($relationType != '=') {
|
|
||||||
$linkedTags = array_merge($linkedTags, $this->getLinkedTags($tag1, '=', $uId, false, $stopList));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($linkedTags) == 0) {
|
|
||||||
return array();
|
|
||||||
} else {
|
|
||||||
$output = array();
|
|
||||||
if($asFlatList == true) {
|
|
||||||
//$output[$tag1] = $tag1;
|
|
||||||
} else {
|
|
||||||
$output = array('node'=>$tag1);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($linkedTags as $linkedTag) {
|
|
||||||
$allLinkedTags = $this->getAllLinkedTags($linkedTag, $relationType, $uId, $asFlatList, $stopList);
|
|
||||||
|
|
||||||
if($asFlatList == true) {
|
|
||||||
$output[] = $linkedTag;
|
|
||||||
if(is_array($allLinkedTags)) {
|
|
||||||
|
|
||||||
$output = array_merge($output, $allLinkedTags);
|
|
||||||
} else {
|
|
||||||
$output[] = $allLinkedTags;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$output[] = $allLinkedTags;
|
|
||||||
}
|
}
|
||||||
}
|
$values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> $relationType, 'uId'=> $uId);
|
||||||
}
|
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
||||||
//$output = array_unique($output); // remove duplication
|
//die($query);
|
||||||
return $output;
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
}
|
$this->db->sql_transaction('rollback');
|
||||||
|
message_die(GENERAL_ERROR, 'Could not attach tag to tag', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->db->sql_transaction('commit');
|
||||||
|
|
||||||
function getOrphewTags($relationType, $uId = 0, $limit = null, $orderBy = null) {
|
// Update stats
|
||||||
$query = "SELECT DISTINCT tts.tag1 as tag";
|
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
$query.= " FROM `". $this->getTableName() ."` tts";
|
$tsts->updateStat($tag1, $relationType, $uId);
|
||||||
if($orderBy != null) {
|
|
||||||
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
return true;
|
||||||
$query.= ", ".$tsts->getTableName() ." tsts";
|
|
||||||
}
|
|
||||||
$query.= " WHERE tts.tag1 <> ALL";
|
|
||||||
$query.= " (SELECT DISTINCT tag2 FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE relationType = '".$relationType."'";
|
|
||||||
if($uId > 0) {
|
|
||||||
$query.= " AND uId = '".$uId."'";
|
|
||||||
}
|
|
||||||
$query.= ")";
|
|
||||||
if($uId > 0) {
|
|
||||||
$query.= " AND tts.uId = '".$uId."'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($orderBy) {
|
// Return the target linked tags. If inverseRelation is true, return the source linked tags.
|
||||||
|
function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
|
||||||
|
// Set up the SQL query.
|
||||||
|
if($inverseRelation) {
|
||||||
|
$queriedTag = "tag1";
|
||||||
|
$givenTag = "tag2";
|
||||||
|
} else {
|
||||||
|
$queriedTag = "tag2";
|
||||||
|
$givenTag = "tag1";
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "SELECT DISTINCT ". $queriedTag ." as 'tag'";
|
||||||
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE 1=1";
|
||||||
|
if($tag !=null) {
|
||||||
|
$query.= " AND ". $givenTag ." = '". $tag ."'";
|
||||||
|
}
|
||||||
|
if($relationType) {
|
||||||
|
$query.= " AND relationType = '". $relationType ."'";
|
||||||
|
}
|
||||||
|
if($uId != null) {
|
||||||
|
$query.= " AND uId = '".$uId."'";
|
||||||
|
}
|
||||||
|
//die($query);
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowset = $this->db->sql_fetchrowset($dbresult);
|
||||||
|
$output = array();
|
||||||
|
foreach($rowset as $row) {
|
||||||
|
if(!in_array($row['tag'], $stopList)) {
|
||||||
|
|
||||||
|
$output[] = $row['tag'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//bijective case for '='
|
||||||
|
if($relationType == '=' && $inverseRelation == false) {
|
||||||
|
//$stopList[] = $tag;
|
||||||
|
$bijectiveOutput = $this->getLinkedTags($tag, $relationType, $uId, true, $stopList);
|
||||||
|
$output = array_merge($output, $bijectiveOutput);
|
||||||
|
//$output = array_unique($output); // remove duplication
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: clean the outputs to obtain homogenous ones*/
|
||||||
|
function getAllLinkedTags($tag1, $relationType, $uId, $asFlatList=true, $stopList=array()) {
|
||||||
|
$asFlatList = true; //we disable the tree list parameter for the moment
|
||||||
|
|
||||||
|
if(in_array($tag1, $stopList) || $tag1 == '') {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$stopList[] = $tag1;
|
||||||
|
$linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList);
|
||||||
|
|
||||||
|
if($relationType != '=') {
|
||||||
|
$linkedTags = array_merge($linkedTags, $this->getLinkedTags($tag1, '=', $uId, false, $stopList));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($linkedTags) == 0) {
|
||||||
|
return array();
|
||||||
|
} else {
|
||||||
|
$output = array();
|
||||||
|
if($asFlatList == true) {
|
||||||
|
//$output[$tag1] = $tag1;
|
||||||
|
} else {
|
||||||
|
$output = array('node'=>$tag1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($linkedTags as $linkedTag) {
|
||||||
|
$allLinkedTags = $this->getAllLinkedTags($linkedTag, $relationType, $uId, $asFlatList, $stopList);
|
||||||
|
|
||||||
|
if($asFlatList == true) {
|
||||||
|
$output[] = $linkedTag;
|
||||||
|
if(is_array($allLinkedTags)) {
|
||||||
|
|
||||||
|
$output = array_merge($output, $allLinkedTags);
|
||||||
|
} else {
|
||||||
|
$output[] = $allLinkedTags;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$output[] = $allLinkedTags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$output = array_unique($output); // remove duplication
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOrphewTags($relationType, $uId = 0, $limit = null, $orderBy = null) {
|
||||||
|
$query = "SELECT DISTINCT tts.tag1 as tag";
|
||||||
|
$query.= " FROM `". $this->getTableName() ."` tts";
|
||||||
|
if($orderBy != null) {
|
||||||
|
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
|
$query.= ", ".$tsts->getTableName() ." tsts";
|
||||||
|
}
|
||||||
|
$query.= " WHERE tts.tag1 <> ALL";
|
||||||
|
$query.= " (SELECT DISTINCT tag2 FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE relationType = '".$relationType."'";
|
||||||
|
if($uId > 0) {
|
||||||
|
$query.= " AND uId = '".$uId."'";
|
||||||
|
}
|
||||||
|
$query.= ")";
|
||||||
|
if($uId > 0) {
|
||||||
|
$query.= " AND tts.uId = '".$uId."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($orderBy) {
|
||||||
case "nb":
|
case "nb":
|
||||||
$query.= " AND tts.tag1 = tsts.tag1";
|
$query.= " AND tts.tag1 = tsts.tag1";
|
||||||
$query.= " AND tsts.relationType = '".$relationType."'";
|
$query.= " AND tsts.relationType = '".$relationType."'";
|
||||||
if($uId > 0) {
|
if($uId > 0) {
|
||||||
$query.= " AND tsts.uId = ".$uId;
|
$query.= " AND tsts.uId = ".$uId;
|
||||||
}
|
}
|
||||||
$query.= " ORDER BY tsts.nb DESC";
|
$query.= " ORDER BY tsts.nb DESC";
|
||||||
break;
|
break;
|
||||||
case "depth": // by nb of descendants
|
case "depth": // by nb of descendants
|
||||||
$query.= " AND tts.tag1 = tsts.tag1";
|
$query.= " AND tts.tag1 = tsts.tag1";
|
||||||
$query.= " AND tsts.relationType = '".$relationType."'";
|
$query.= " AND tsts.relationType = '".$relationType."'";
|
||||||
if($uId > 0) {
|
if($uId > 0) {
|
||||||
$query.= " AND tsts.uId = ".$uId;
|
$query.= " AND tsts.uId = ".$uId;
|
||||||
}
|
}
|
||||||
$query.= " ORDER BY tsts.depth DESC";
|
$query.= " ORDER BY tsts.depth DESC";
|
||||||
break;
|
break;
|
||||||
case "nbupdate":
|
case "nbupdate":
|
||||||
$query.= " AND tts.tag1 = tsts.tag1";
|
$query.= " AND tts.tag1 = tsts.tag1";
|
||||||
$query.= " AND tsts.relationType = '".$relationType."'";
|
$query.= " AND tsts.relationType = '".$relationType."'";
|
||||||
if($uId > 0) {
|
if($uId > 0) {
|
||||||
$query.= " AND tsts.uId = ".$uId;
|
$query.= " AND tsts.uId = ".$uId;
|
||||||
}
|
}
|
||||||
$query.= " ORDER BY tsts.nbupdate DESC";
|
$query.= " ORDER BY tsts.nbupdate DESC";
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($limit != null) {
|
||||||
|
$query.= " LIMIT 0,".$limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->db->sql_fetchrowset($dbresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($limit != null) {
|
function getMenuTags($uId) {
|
||||||
$query.= " LIMIT 0,".$limit;
|
if(strlen($GLOBALS['menuTag']) < 1) {
|
||||||
|
return array();
|
||||||
|
} else {
|
||||||
|
// we don't use the getAllLinkedTags function in order to improve performance
|
||||||
|
$query = "SELECT tag2 as 'tag', COUNT(tag2) as 'count'";
|
||||||
|
$query.= " FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE tag1 = '".$GLOBALS['menuTag']."'";
|
||||||
|
$query.= " AND relationType = '>'";
|
||||||
|
if($uId > 0) {
|
||||||
|
$query.= " AND uId = '".$uId."'";
|
||||||
|
}
|
||||||
|
$query.= " GROUP BY tag2";
|
||||||
|
$query.= " ORDER BY count DESC";
|
||||||
|
$query.= " LIMIT 0, ".$GLOBALS['maxSizeMenuBlock'];
|
||||||
|
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->db->sql_fetchrowset($dbresult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMenuTags($uId) {
|
function existsLinkedTags($tag1, $tag2, $relationType, $uId) {
|
||||||
if(strlen($GLOBALS['menuTag']) < 1) {
|
$query = "SELECT tag1, tag2, relationType, uId FROM `". $this->getTableName() ."`";
|
||||||
return array();
|
$query.= " WHERE tag1 = '" .$tag1 ."'";
|
||||||
} else {
|
$query.= " AND tag2 = '".$tag2."'";
|
||||||
// we don't use the getAllLinkedTags function in order to improve performance
|
$query.= " AND relationType = '". $relationType ."'";
|
||||||
$query = "SELECT tag2 as 'tag', COUNT(tag2) as 'count'";
|
$query.= " AND uId = '".$uId."'";
|
||||||
$query.= " FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE tag1 = '".$GLOBALS['menuTag']."'";
|
|
||||||
$query.= " AND relationType = '>'";
|
|
||||||
if($uId > 0) {
|
|
||||||
$query.= " AND uId = '".$uId."'";
|
|
||||||
}
|
|
||||||
$query.= " GROUP BY tag2";
|
|
||||||
$query.= " ORDER BY count DESC";
|
|
||||||
$query.= " LIMIT 0, ".$GLOBALS['maxSizeMenuBlock'];
|
|
||||||
|
|
||||||
if (! ($dbresult =& $this->db->sql_query($query)) ){
|
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
|
||||||
message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function existsLinkedTags($tag1, $tag2, $relationType, $uId) {
|
|
||||||
$query = "SELECT tag1, tag2, relationType, uId FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE tag1 = '" .$tag1 ."'";
|
|
||||||
$query.= " AND tag2 = '".$tag2."'";
|
|
||||||
$query.= " AND relationType = '". $relationType ."'";
|
|
||||||
$query.= " AND uId = '".$uId."'";
|
|
||||||
|
|
||||||
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLinks($uId) {
|
|
||||||
$query = "SELECT tag1, tag2, relationType, uId FROM `". $this->getTableName() ."`";
|
|
||||||
$query.= " WHERE 1=1";
|
|
||||||
if($uId > 0) {
|
|
||||||
$query.= " AND uId = '".$uId."'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->sql_fetchrowset($this->db->sql_query($query));
|
function getLinks($uId) {
|
||||||
}
|
$query = "SELECT tag1, tag2, relationType, uId FROM `". $this->getTableName() ."`";
|
||||||
|
$query.= " WHERE 1=1";
|
||||||
|
if($uId > 0) {
|
||||||
|
$query.= " AND uId = '".$uId."'";
|
||||||
|
}
|
||||||
|
|
||||||
function removeLinkedTags($tag1, $tag2, $relationType, $uId) {
|
return $this->db->sql_fetchrowset($this->db->sql_query($query));
|
||||||
if(($tag1 != '' && $tag1 == $tag2) ||
|
|
||||||
($relationType != ">" && $relationType != "=" && $relationType != "") ||
|
|
||||||
($tag1 == '' && $tag2 == '' && $relationType == '' && $uId == '')) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
$query = 'DELETE FROM '. $this->getTableName();
|
|
||||||
$query.= ' WHERE 1=1';
|
|
||||||
$query.= strlen($tag1)>0 ? ' AND tag1 = "'. $tag1 .'"' : '';
|
|
||||||
$query.= strlen($tag2)>0 ? ' AND tag2 = "'. $tag2 .'"' : '';
|
|
||||||
$query.= strlen($relationType)>0 ? ' AND relationType = "'. $relationType .'"' : '';
|
|
||||||
$query.= strlen($uId)>0 ? ' AND uId = "'. $uId .'"' : '';
|
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
function removeLinkedTags($tag1, $tag2, $relationType, $uId) {
|
||||||
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
|
if(($tag1 != '' && $tag1 == $tag2) ||
|
||||||
return false;
|
($relationType != ">" && $relationType != "=" && $relationType != "") ||
|
||||||
}
|
($tag1 == '' && $tag2 == '' && $relationType == '' && $uId == '')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$query = 'DELETE FROM '. $this->getTableName();
|
||||||
|
$query.= ' WHERE 1=1';
|
||||||
|
$query.= strlen($tag1)>0 ? ' AND tag1 = "'. $tag1 .'"' : '';
|
||||||
|
$query.= strlen($tag2)>0 ? ' AND tag2 = "'. $tag2 .'"' : '';
|
||||||
|
$query.= strlen($relationType)>0 ? ' AND relationType = "'. $relationType .'"' : '';
|
||||||
|
$query.= strlen($uId)>0 ? ' AND uId = "'. $uId .'"' : '';
|
||||||
|
|
||||||
// Update stats
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
$tsts->updateStat($tag1, $relationType, $uId);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
// Update stats
|
||||||
}
|
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
|
$tsts->updateStat($tag1, $relationType, $uId);
|
||||||
|
|
||||||
function renameTag($uId, $oldName, $newName) {
|
return true;
|
||||||
$query = 'UPDATE `'. $this->getTableName() .'`';
|
}
|
||||||
$query.= ' SET tag1="'.$newName.'"';
|
|
||||||
$query.= ' WHERE tag1="'.$oldName.'"';
|
|
||||||
$query.= ' AND uId="'.$uId.'"';
|
|
||||||
$this->db->sql_query($query);
|
|
||||||
|
|
||||||
$query = 'UPDATE `'. $this->getTableName() .'`';
|
function renameTag($uId, $oldName, $newName) {
|
||||||
$query.= ' SET tag2="'.$newName.'"';
|
$query = 'UPDATE `'. $this->getTableName() .'`';
|
||||||
$query.= ' WHERE tag2="'.$oldName.'"';
|
$query.= ' SET tag1="'.$newName.'"';
|
||||||
$query.= ' AND uId="'.$uId.'"';
|
$query.= ' WHERE tag1="'.$oldName.'"';
|
||||||
$this->db->sql_query($query);
|
$query.= ' AND uId="'.$uId.'"';
|
||||||
|
$this->db->sql_query($query);
|
||||||
|
|
||||||
// Update stats
|
$query = 'UPDATE `'. $this->getTableName() .'`';
|
||||||
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
$query.= ' SET tag2="'.$newName.'"';
|
||||||
$tsts->updateStat($oldName, '=', $uId);
|
$query.= ' WHERE tag2="'.$oldName.'"';
|
||||||
$tsts->updateStat($oldName, '>', $uId);
|
$query.= ' AND uId="'.$uId.'"';
|
||||||
$tsts->updateStat($newName, '=', $uId);
|
$this->db->sql_query($query);
|
||||||
$tsts->updateStat($newName, '>', $uId);
|
|
||||||
|
|
||||||
return true;
|
// Update stats
|
||||||
|
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
|
$tsts->updateStat($oldName, '=', $uId);
|
||||||
|
$tsts->updateStat($oldName, '>', $uId);
|
||||||
|
$tsts->updateStat($newName, '=', $uId);
|
||||||
|
$tsts->updateStat($newName, '>', $uId);
|
||||||
|
|
||||||
}
|
return true;
|
||||||
|
|
||||||
function deleteAll() {
|
}
|
||||||
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
|
||||||
$this->db->sql_query($query);
|
|
||||||
|
|
||||||
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
function deleteAll() {
|
||||||
$tsts->deleteAll();
|
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
||||||
}
|
$this->db->sql_query($query);
|
||||||
|
|
||||||
// Properties
|
$tsts =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
function getTableName() { return $this->tablename; }
|
$tsts->deleteAll();
|
||||||
function setTableName($value) { $this->tablename = $value; }
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
function getTableName() { return $this->tablename; }
|
||||||
|
function setTableName($value) { $this->tablename = $value; }
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,89 +1,90 @@
|
||||||
<?php
|
<?php
|
||||||
class TagService {
|
class TagService {
|
||||||
var $db;
|
var $db;
|
||||||
var $tablename;
|
var $tablename;
|
||||||
|
|
||||||
function &getInstance(&$db) {
|
function &getInstance(&$db) {
|
||||||
static $instance;
|
static $instance;
|
||||||
if (!isset($instance))
|
if (!isset($instance))
|
||||||
$instance =& new TagService($db);
|
$instance =& new TagService($db);
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
|
||||||
|
|
||||||
function TagService(&$db) {
|
|
||||||
$this->db =& $db;
|
|
||||||
$this->tablename = $GLOBALS['tableprefix'] .'tags';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDescription($tag, $uId) {
|
|
||||||
$query = 'SELECT tag, uId, tDescription';
|
|
||||||
$query.= ' FROM '.$this->getTableName();
|
|
||||||
$query.= ' WHERE tag = "'.$tag.'"';
|
|
||||||
$query.= ' AND uId = "'.$uId.'"';
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
|
||||||
return $row;
|
|
||||||
} else {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAllDescriptions($tag) {
|
|
||||||
$query = 'SELECT tag, uId, tDescription';
|
|
||||||
$query.= ' FROM '.$this->getTableName();
|
|
||||||
$query.= ' WHERE tag = "'.$tag.'"';
|
|
||||||
|
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
|
||||||
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->db->sql_fetchrowset($dbresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateDescription($tag, $uId, $desc) {
|
|
||||||
if(count($this->getDescription($tag, $uId))>0) {
|
|
||||||
$query = 'UPDATE '.$this->getTableName();
|
|
||||||
$query.= ' SET tDescription="'.$this->db->sql_escape($desc).'"';
|
|
||||||
$query.= ' WHERE tag="'.$tag.'" AND uId="'.$uId.'"';
|
|
||||||
} else {
|
|
||||||
$values = array('tag'=>$tag, 'uId'=>$uId, 'tDescription'=>$desc);
|
|
||||||
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->sql_transaction('begin');
|
function TagService(&$db) {
|
||||||
if (!($dbresult = & $this->db->sql_query($query))) {
|
$this->db =& $db;
|
||||||
$this->db->sql_transaction('rollback');
|
$this->tablename = $GLOBALS['tableprefix'] .'tags';
|
||||||
message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->db->sql_transaction('commit');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renameTag($uId, $oldName, $newName) {
|
function getDescription($tag, $uId) {
|
||||||
$query = 'UPDATE `'. $this->getTableName() .'`';
|
$query = 'SELECT tag, uId, tDescription';
|
||||||
$query.= ' SET tag="'.$newName.'"';
|
$query.= ' FROM '.$this->getTableName();
|
||||||
$query.= ' WHERE tag="'.$oldName.'"';
|
$query.= ' WHERE tag = "'.$tag.'"';
|
||||||
$query.= ' AND uId="'.$uId.'"';
|
$query.= ' AND uId = "'.$uId.'"';
|
||||||
$this->db->sql_query($query);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function deleteAll() {
|
if ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
return $row;
|
||||||
$this->db->sql_query($query);
|
} else {
|
||||||
}
|
return array('tDescription'=>'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Properties
|
function getAllDescriptions($tag) {
|
||||||
function getTableName() { return $this->tablename; }
|
$query = 'SELECT tag, uId, tDescription';
|
||||||
function setTableName($value) { $this->tablename = $value; }
|
$query.= ' FROM '.$this->getTableName();
|
||||||
|
$query.= ' WHERE tag = "'.$tag.'"';
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->db->sql_fetchrowset($dbresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateDescription($tag, $uId, $desc) {
|
||||||
|
$objectTag = $this->getDescription($tag, $uId);
|
||||||
|
if(count($objectTag)>0 && $objectTag['tDescription'] != '') {
|
||||||
|
$query = 'UPDATE '.$this->getTableName();
|
||||||
|
$query.= ' SET tDescription="'.$this->db->sql_escape($desc).'"';
|
||||||
|
$query.= ' WHERE tag="'.$tag.'" AND uId="'.$uId.'"';
|
||||||
|
} else {
|
||||||
|
$values = array('tag'=>$tag, 'uId'=>$uId, 'tDescription'=>$desc);
|
||||||
|
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->sql_transaction('begin');
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
$this->db->sql_transaction('rollback');
|
||||||
|
message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->db->sql_transaction('commit');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renameTag($uId, $oldName, $newName) {
|
||||||
|
$query = 'UPDATE `'. $this->getTableName() .'`';
|
||||||
|
$query.= ' SET tag="'.$newName.'"';
|
||||||
|
$query.= ' WHERE tag="'.$oldName.'"';
|
||||||
|
$query.= ' AND uId="'.$uId.'"';
|
||||||
|
$this->db->sql_query($query);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
|
||||||
|
$this->db->sql_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
function getTableName() { return $this->tablename; }
|
||||||
|
function setTableName($value) { $this->tablename = $value; }
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -76,6 +76,22 @@ class UserService {
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function & getObjectUsers($nb=0) {
|
||||||
|
$query = 'SELECT * FROM '. $this->getTableName() .' ORDER BY `uId` DESC';
|
||||||
|
if($nb>0) {
|
||||||
|
$query .= ' LIMIT 0, '.$nb;
|
||||||
|
}
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($row = & $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
$users[] = new User($row[$this->getFieldName('primary')], $row[$this->getFieldName('username')]);
|
||||||
|
}
|
||||||
|
return $users;
|
||||||
|
}
|
||||||
|
|
||||||
function _randompassword() {
|
function _randompassword() {
|
||||||
$seed = (integer) md5(microtime());
|
$seed = (integer) md5(microtime());
|
||||||
mt_srand($seed);
|
mt_srand($seed);
|
||||||
|
@ -109,10 +125,15 @@ class UserService {
|
||||||
return $this->_getuser($this->getFieldName('username'), $username);
|
return $this->_getuser($this->getFieldName('username'), $username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getObjectUserByUsername($username) {
|
||||||
|
$user = $this->_getuser($this->getFieldName('username'), $username);
|
||||||
|
return new User($user[$this->getFieldName('primary')], $username);
|
||||||
|
}
|
||||||
|
|
||||||
function getUser($id) {
|
function getUser($id) {
|
||||||
return $this->_getuser($this->getFieldName('primary'), $id);
|
return $this->_getuser($this->getFieldName('primary'), $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Momentary useful in order to go to object code
|
// Momentary useful in order to go to object code
|
||||||
function getObjectUser($id) {
|
function getObjectUser($id) {
|
||||||
$user = $this->_getuser($this->getFieldName('primary'), $id);
|
$user = $this->_getuser($this->getFieldName('primary'), $id);
|
||||||
|
@ -136,7 +157,7 @@ class UserService {
|
||||||
}
|
}
|
||||||
return $currentuser;
|
return $currentuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Momentary useful in order to go to object code
|
// Momentary useful in order to go to object code
|
||||||
function getCurrentObjectUser($refresh = FALSE, $newval = NULL) {
|
function getCurrentObjectUser($refresh = FALSE, $newval = NULL) {
|
||||||
static $currentObjectUser;
|
static $currentObjectUser;
|
||||||
|
@ -152,6 +173,22 @@ class UserService {
|
||||||
return $currentObjectUser;
|
return $currentObjectUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function existsUserWithUsername($username) {
|
||||||
|
if($this->getUserByUsername($username) != '') {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function existsUser($id) {
|
||||||
|
if($this->getUser($id) != '') {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isAdmin($userid) {
|
function isAdmin($userid) {
|
||||||
$user = $this->getUser($userid);
|
$user = $this->getUser($userid);
|
||||||
|
|
||||||
|
@ -446,27 +483,84 @@ class UserService {
|
||||||
function setCookieKey($value) { $this->cookiekey = $value; }
|
function setCookieKey($value) { $this->cookiekey = $value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Defines a user. Rare fields are filled if required. */
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $username;
|
var $username;
|
||||||
|
var $name;
|
||||||
|
var $email;
|
||||||
|
var $homepage;
|
||||||
|
var $content;
|
||||||
|
var $datetime;
|
||||||
var $isAdmin;
|
var $isAdmin;
|
||||||
|
|
||||||
function User($id, $username) {
|
function User($id, $username) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
function getId() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsername() {
|
function getUsername() {
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getName() {
|
||||||
|
// Look for value only if not already set
|
||||||
|
if(!isset($this->name)) {
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$user = $userservice->getUser($this->id);
|
||||||
|
$this->name = $user['name'];
|
||||||
|
}
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEmail() {
|
||||||
|
// Look for value only if not already set
|
||||||
|
if(!isset($this->email)) {
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$user = $userservice->getUser($this->id);
|
||||||
|
$this->email = $user['email'];
|
||||||
|
}
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHomepage() {
|
||||||
|
// Look for value only if not already set
|
||||||
|
if(!isset($this->homepage)) {
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$user = $userservice->getUser($this->id);
|
||||||
|
$this->homepage = $user['homepage'];
|
||||||
|
}
|
||||||
|
return $this->homepage;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContent() {
|
||||||
|
// Look for value only if not already set
|
||||||
|
if(!isset($this->content)) {
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$user = $userservice->getUser($this->id);
|
||||||
|
$this->content = $user['uContent'];
|
||||||
|
}
|
||||||
|
return $this->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDatetime() {
|
||||||
|
// Look for value only if not already set
|
||||||
|
if(!isset($this->content)) {
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
$user = $userservice->getUser($this->id);
|
||||||
|
$this->datetime = $user['uDatetime'];
|
||||||
|
}
|
||||||
|
return $this->datetime;
|
||||||
|
}
|
||||||
|
|
||||||
function isAdmin() {
|
function isAdmin() {
|
||||||
// Look for value if not already set
|
// Look for value only if not already set
|
||||||
if(!isset($this->isAdmin)) {
|
if(!isset($this->isAdmin)) {
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$this->isAdmin = $userservice->isAdmin($this->id);
|
$this->isAdmin = $userservice->isAdmin($this->id);
|
||||||
|
|
|
@ -20,43 +20,52 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['tag1']) ? define('POST_TAG1', $_POST['tag1']): define('POST_TAG1', '');
|
||||||
|
isset($_POST['linkType']) ? define('POST_LINKTYPE', $_POST['linkType']): define('POST_LINKTYPE', '');
|
||||||
|
isset($_POST['tag2']) ? define('POST_TAG2', $_POST['tag2']): define('POST_TAG2', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if(!$userservice->isLoggedOn()) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
if (POST_CONFIRM != '') {
|
||||||
$tag1 = $_POST['tag1'];
|
$tag1 = POST_TAG1;
|
||||||
$linkType = $_POST['linkType'];
|
$linkType = POST_LINKTYPE;
|
||||||
$tag2 = $_POST['tag2'];
|
$tag2 = POST_TAG2;
|
||||||
if ($tag2tagservice->addLinkedTags($tag1, $tag2, $linkType, $userservice->getCurrentUserId())) {
|
if ($tag2tagservice->addLinkedTags($tag1, $tag2, $linkType, $currentObjectUser->getId())) {
|
||||||
$tplVars['msg'] = T_('Tag link created');
|
$tplVars['msg'] = T_('Tag link created');
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('Failed to create the link');
|
$tplVars['error'] = T_('Failed to create the link');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} elseif ($_POST['cancel']) {
|
} elseif (POST_CANCEL) {
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername() .'/'. $tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
|
$tplVars['links'] = $tag2tagservice->getLinks($currentObjectUser->getId());
|
||||||
|
|
||||||
$tplVars['tag1'] = $tag1;
|
$tplVars['tag1'] = $tag1;
|
||||||
|
$tplVars['tag2'] = '';
|
||||||
$tplVars['subtitle'] = T_('Add Tag Link') .': '. $tag1;
|
$tplVars['subtitle'] = T_('Add Tag Link') .': '. $tag1;
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag1;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag1;
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||||
|
|
|
@ -1,62 +1,87 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2006 Scuttle project
|
Copyright (C) 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['tag1']) ? define('POST_TAG1', $_POST['tag1']): define('POST_TAG1', '');
|
||||||
|
isset($_POST['linkType']) ? define('POST_LINKTYPE', $_POST['linkType']): define('POST_LINKTYPE', '');
|
||||||
|
isset($_POST['tag2']) ? define('POST_TAG2', $_POST['tag2']): define('POST_TAG2', '');
|
||||||
|
|
||||||
|
isset($_SERVER['HTTP_REFERER']) ? define('HTTP_REFERER', $_SERVER['HTTP_REFERER']): define('HTTP_REFERER', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if(!$userservice->isloggedOn()) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
|
/* Managing path info */
|
||||||
|
if(isset($_SERVER['PATH_INFO'])) {
|
||||||
if ($_POST['confirm']) {
|
$exploded = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$tag = $_POST['tag1'];
|
if(count($exploded) == 3) {
|
||||||
$linkType = $_POST['linkType'];
|
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$newTag = $_POST['tag2'];
|
} else {
|
||||||
if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], $linkType, $userservice->getCurrentUserId())) {
|
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$tplVars['msg'] = T_('Tag link deleted');
|
$tag2 = '';
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')].'/'.$tag));
|
}
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('Failed to delete the link');
|
$url = $tag1 = $tag2 = '';
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
} elseif ($_POST['cancel']) {
|
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
|
|
||||||
|
|
||||||
|
if (POST_CONFIRM) {
|
||||||
|
$tag = POST_TAG1;
|
||||||
|
$linkType = POST_LINKTYPE;
|
||||||
|
$newTag = POST_TAG2;
|
||||||
|
if ($tag2tagservice->removeLinkedTags(POST_TAG1, POST_TAG2, POST_LINKTYPE, $currentUser->getId())) {
|
||||||
|
$tplVars['msg'] = T_('Tag link deleted');
|
||||||
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername().'/'.$tag));
|
||||||
|
} else {
|
||||||
|
$tplVars['error'] = T_('Failed to delete the link');
|
||||||
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
} elseif (POST_CANCEL) {
|
||||||
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
|
||||||
|
}
|
||||||
|
|
||||||
|
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
|
||||||
|
|
||||||
$tplVars['tag1'] = $tag1;
|
$tplVars['tag1'] = $tag1;
|
||||||
$tplVars['tag2'] = $tag2;
|
$tplVars['tag2'] = $tag2;
|
||||||
$tplVars['subtitle'] = T_('Delete Link Between Tags') .': '. $tag1.' > '.$tag2;
|
$tplVars['subtitle'] = T_('Delete Link Between Tags') .': '. $tag1.' > '.$tag2;
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'];
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = HTTP_REFERER;
|
||||||
$templateservice->loadTemplate('tag2tagdelete.tpl', $tplVars);
|
$templateservice->loadTemplate('tag2tagdelete.tpl', $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,12 +20,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_SERVER['HTTP_REFERER']) ? define('HTTP_REFERER', $_SERVER['HTTP_REFERER']): define('HTTP_REFERER', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
$logged_on_user = $userservice->getCurrentUser();
|
||||||
|
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if($logged_on_user == null) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
|
@ -33,23 +40,18 @@ if($logged_on_user == null) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
|
/* Managing path info */
|
||||||
|
if(isset($_SERVER['PATH_INFO'])) {
|
||||||
/*if ($_POST['confirm']) {
|
$exploded = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$tag = $_POST['tag1'];
|
if(count($exploded) == 3) {
|
||||||
$linkType = $_POST['linkType'];
|
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$newTag = $_POST['tag2'];
|
} else {
|
||||||
if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], $linkType, $userservice->getCurrentUserId())) {
|
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$tplVars['msg'] = T_('Tag link deleted');
|
$tag2 = '';
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
}
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('Failed to delete the link');
|
$url = $tag1 = $tag2 = '';
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
}
|
||||||
exit();
|
|
||||||
}
|
|
||||||
} elseif ($_POST['cancel']) {
|
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
|
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
|
||||||
|
|
||||||
|
@ -58,6 +60,6 @@ $tplVars['tag2'] = $tag2;
|
||||||
$tplVars['subtitle'] = T_('Edit Link Between Tags') .': '. $tag1.' > '.$tag2;
|
$tplVars['subtitle'] = T_('Edit Link Between Tags') .': '. $tag1.' > '.$tag2;
|
||||||
$tplVars['formaddaction'] = createUrl('tag2tagadd');
|
$tplVars['formaddaction'] = createUrl('tag2tagadd');
|
||||||
$tplVars['formdeleteaction'] = createUrl('tag2tagdelete');
|
$tplVars['formdeleteaction'] = createUrl('tag2tagdelete');
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = HTTP_REFERER;
|
||||||
$templateservice->loadTemplate('tag2tagedit.tpl', $tplVars);
|
$templateservice->loadTemplate('tag2tagedit.tpl', $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,62 +1,73 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2006 - 2007 Scuttle project
|
Copyright (C) 2006 - 2007 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
|
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
|
||||||
|
|
||||||
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
/* Managing all possible inputs */
|
||||||
$template = 'tagcommondescriptionedit.tpl';
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
|
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
|
||||||
|
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
|
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if(!$userservice->isLoggedOn()) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
$template = 'tagcommondescriptionedit.tpl';
|
||||||
|
|
||||||
if ( strlen($tag)>0 &&
|
if (POST_CONFIRM) {
|
||||||
$cdservice->addTagDescription($tag, stripslashes($_POST['description']), $logged_on_user['uId'], time())
|
|
||||||
) {
|
if ( strlen($tag)>0 &&
|
||||||
$tplVars['msg'] = T_('Tag common description updated');
|
$cdservice->addTagDescription($tag, stripslashes(POST_DESCRIPTION), $currentUser->getId(), time())
|
||||||
header('Location: '. $_POST['referrer']);
|
) {
|
||||||
} else {
|
$tplVars['msg'] = T_('Tag common description updated');
|
||||||
$tplVars['error'] = T_('Failed to update the tag common description');
|
header('Location: '. POST_REFERRER);
|
||||||
$template = 'error.500.tpl';
|
} else {
|
||||||
}
|
$tplVars['error'] = T_('Failed to update the tag common description');
|
||||||
} elseif ($_POST['cancel']) {
|
$template = 'error.500.tpl';
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
}
|
||||||
header('Location: '. $_POST['referrer']);
|
} elseif (POST_CANCEL) {
|
||||||
|
header('Location: '. POST_REFERRER);
|
||||||
} else {
|
} else {
|
||||||
$tplVars['subtitle'] = T_('Edit Tag Common Description') .': '. $tag;
|
$tplVars['subtitle'] = T_('Edit Tag Common Description') .': '. $tag;
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||||
$tplVars['tag'] = $tag;
|
$tplVars['tag'] = $tag;
|
||||||
$tplVars['description'] = $cdservice->getLastTagDescription($tag);
|
$tplVars['description'] = $cdservice->getLastTagDescription($tag);
|
||||||
}
|
}
|
||||||
$templateservice->loadTemplate($template, $tplVars);
|
$templateservice->loadTemplate($template, $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,25 +20,36 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
|
||||||
if ($b2tservice->deleteTag($logged_on_user['uId'], $tag)) {
|
|
||||||
|
if (POST_CONFIRM) {
|
||||||
|
if ($b2tservice->deleteTag($currentUser->getId(), $tag)) {
|
||||||
$tplVars['msg'] = T_('Tag deleted');
|
$tplVars['msg'] = T_('Tag deleted');
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('Failed to delete the tag');
|
$tplVars['error'] = T_('Failed to delete the tag');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} elseif ($_POST['cancel']) {
|
} elseif (POST_CANCEL) {
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
header('Location: '. POST_REFERRER);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['subtitle'] = T_('Delete Tag') .': '. $tag;
|
$tplVars['subtitle'] = T_('Delete Tag') .': '. $tag;
|
||||||
|
|
89
tagedit.php
89
tagedit.php
|
@ -1,61 +1,70 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2006 - 2007 Scuttle project
|
Copyright (C) 2006 - 2007 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
$tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
|
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
$template = 'tagedit.tpl';
|
$template = 'tagedit.tpl';
|
||||||
|
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
if($logged_on_user == null) {
|
if(!$userservice->isLoggedOn()) {
|
||||||
$tplVars['error'] = T_('Permission denied.');
|
$tplVars['error'] = T_('Permission denied.');
|
||||||
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
$templateservice->loadTemplate('error.500.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
if (POST_CONFIRM) {
|
||||||
|
if ( strlen($tag)>0 &&
|
||||||
if ( strlen($tag)>0 &&
|
$tagservice->updateDescription($tag, $currentUser->getId(), POST_DESCRIPTION)
|
||||||
$tagservice->updateDescription($tag, $logged_on_user['uId'], $_POST['description'])
|
) {
|
||||||
) {
|
$tplVars['msg'] = T_('Tag description updated');
|
||||||
$tplVars['msg'] = T_('Tag description updated');
|
header('Location: '. POST_REFERRER);
|
||||||
header('Location: '. $_POST['referrer']);
|
} else {
|
||||||
} else {
|
$tplVars['error'] = T_('Failed to update the tag description');
|
||||||
$tplVars['error'] = T_('Failed to update the tag description');
|
$template = 'error.500.tpl';
|
||||||
$template = 'error.500.tpl';
|
}
|
||||||
}
|
} elseif (POST_CANCEL) {
|
||||||
} elseif ($_POST['cancel']) {
|
header('Location: '. POST_REFERRER);
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
header('Location: '. $_POST['referrer']);
|
|
||||||
} else {
|
} else {
|
||||||
$tplVars['subtitle'] = T_('Edit Tag Description') .': '. $tag;
|
$tplVars['subtitle'] = T_('Edit Tag Description') .': '. $tag;
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||||
$tplVars['tag'] = $tag;
|
$tplVars['tag'] = $tag;
|
||||||
$tplVars['description'] = $tagservice->getDescription($tag, $logged_on_user['uId']);
|
$tplVars['description'] = $tagservice->getDescription($tag, $currentUser->getId());
|
||||||
}
|
}
|
||||||
$templateservice->loadTemplate($template, $tplVars);
|
$templateservice->loadTemplate($template, $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
102
tagrename.php
102
tagrename.php
|
@ -1,68 +1,80 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2006 - 2007 Scuttle project
|
Copyright (C) 2006 - 2007 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
|
||||||
$tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
$tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
||||||
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2tagService');
|
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2tagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
|
||||||
|
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']): define('POST_CANCEL', '');
|
||||||
|
isset($_POST['old']) ? define('POST_OLD', $_POST['old']): define('POST_OLD', '');
|
||||||
|
isset($_POST['new']) ? define('POST_NEW', $_POST['new']): define('POST_NEW', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
//$tag = isset($_GET['query']) ? $_GET['query'] : NULL;
|
//$tag = isset($_GET['query']) ? $_GET['query'] : NULL;
|
||||||
$template = 'tagrename.tpl';
|
$template = 'tagrename.tpl';
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
if (POST_CONFIRM) {
|
||||||
if (isset($_POST['old']) && trim($_POST['old']) != '')
|
if (trim(POST_OLD) != '') {
|
||||||
$old = trim($_REQUEST['old']);
|
$old = trim(POST_OLD);
|
||||||
else
|
} else {
|
||||||
$old = NULL;
|
$old = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST['new']) && trim($_POST['new']) != '')
|
if (trim(POST_NEW) != '') {
|
||||||
$new = trim($_POST['new']);
|
$new = trim(POST_NEW);
|
||||||
else
|
} else {
|
||||||
$new = NULL;
|
$new = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!is_null($old) &&
|
!is_null($old) &&
|
||||||
!is_null($new) &&
|
!is_null($new) &&
|
||||||
$tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) &&
|
$tagservice->renameTag($currentUser->getId(), $old, $new) &&
|
||||||
$b2tservice->renameTag($userservice->getCurrentUserId(), $old, $new) &&
|
$b2tservice->renameTag($currentUser->getId(), $old, $new) &&
|
||||||
$tag2tagservice->renameTag($userservice->getCurrentUserId(), $old, $new)
|
$tag2tagservice->renameTag($currentUser->getId(), $old, $new)
|
||||||
) {
|
) {
|
||||||
$tplVars['msg'] = T_('Tag renamed');
|
$tplVars['msg'] = T_('Tag renamed');
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
} else {
|
||||||
} else {
|
$tplVars['error'] = T_('Failed to rename the tag');
|
||||||
$tplVars['error'] = T_('Failed to rename the tag');
|
$template = 'error.500.tpl';
|
||||||
$template = 'error.500.tpl';
|
}
|
||||||
}
|
} elseif (POST_CANCEL) {
|
||||||
} elseif ($_POST['cancel']) {
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
|
||||||
} else {
|
} else {
|
||||||
$tplVars['subtitle'] = T_('Rename Tag') .': '. $tag;
|
$tplVars['subtitle'] = T_('Rename Tag') .': '. $tag;
|
||||||
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
||||||
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||||
$tplVars['old'] = $tag;
|
$tplVars['old'] = $tag;
|
||||||
}
|
}
|
||||||
$templateservice->loadTemplate($template, $tplVars);
|
$templateservice->loadTemplate($template, $tplVars);
|
||||||
?>
|
?>
|
||||||
|
|
81
tags.php
81
tags.php
|
@ -1,69 +1,80 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2004 - 2006 Scuttle project
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
|
list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
|
|
||||||
list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
|
||||||
if (!$cat) {
|
if (!$cat) {
|
||||||
header('Location: '. createURL('populartags'));
|
header('Location: '. createURL('populartags'));
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$cattitle = str_replace('+', ' + ', $cat);
|
$cattitle = str_replace('+', ' + ', $cat);
|
||||||
}
|
}
|
||||||
$pagetitle = T_('Tags') .': '. $cattitle;
|
$pagetitle = T_('Tags') .': '. $cattitle;
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$hash = md5($_SERVER['REQUEST_URI'] . $userservice->getCurrentUserID());
|
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
|
||||||
} else {
|
} else {
|
||||||
$hash = md5($_SERVER['REQUEST_URI']);
|
$hash = md5($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache for 30 minutes
|
// Cache for 30 minutes
|
||||||
$cacheservice->Start($hash, 1800);
|
$cacheservice->Start($hash, 1800);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header variables
|
// Header variables
|
||||||
$tplVars['pagetitle'] = $pagetitle;
|
$tplVars['pagetitle'] = $pagetitle;
|
||||||
$tplVars['loadjs'] = true;
|
$tplVars['loadjs'] = true;
|
||||||
$tplVars['rsschannels'] = array(
|
$tplVars['rsschannels'] = array(
|
||||||
array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder())
|
array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
$perpage = getPerPageCount();
|
$perpage = getPerPageCount();
|
||||||
if (isset($_GET['page']) && intval($_GET['page']) > 1) {
|
if (intval(GET_PAGE) > 1) {
|
||||||
$page = $_GET['page'];
|
$page = GET_PAGE;
|
||||||
$start = ($page - 1) * $perpage;
|
$start = ($page - 1) * $perpage;
|
||||||
} else {
|
} else {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$start = 0;
|
$start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tplVars['page'] = $page;
|
$tplVars['page'] = $page;
|
||||||
|
@ -82,7 +93,7 @@ $tplVars['nav_url'] = createURL('tags', '%2$s%3$s');
|
||||||
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Cache output if existing copy has expired
|
// Cache output if existing copy has expired
|
||||||
$cacheservice->End($hash);
|
$cacheservice->End($hash);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
$this->includeTemplate($GLOBALS['top_include']);
|
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$currentUser = $userservice->getCurrentUser();
|
//$currentUser = $userservice->getCurrentUser();
|
||||||
$currentUserId = $userservice->getCurrentUserId();
|
//$currentUserId = $userservice->getCurrentUserId();
|
||||||
|
|
||||||
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
$this->includeTemplate($GLOBALS['top_include']);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -20,9 +24,10 @@ $currentUserId = $userservice->getCurrentUserId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php if(!is_null($currentUser) && $userservice->isAdmin($currentUserId)): ?>
|
<?php if(!is_null($currentObjectUser) && $currentObjectUser->isAdmin()): ?>
|
||||||
<li>SemanticScuttle v0.91</li>
|
<li>SemanticScuttle v0.91</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
$this->includeTemplate($GLOBALS['top_include']);
|
/* Service creation: only useful services are created */
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
$this->includeTemplate($GLOBALS['top_include']);
|
||||||
|
|
||||||
list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
|
|
@ -6,8 +6,6 @@ $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$tagservice =& ServiceFactory::getServiceInstance('TagService');
|
$tagservice =& ServiceFactory::getServiceInstance('TagService');
|
||||||
$cdservice =& ServiceFactory::getServiceInstance('CommonDescriptionService');
|
$cdservice =& ServiceFactory::getServiceInstance('CommonDescriptionService');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$logged_on_userid = $userservice->getCurrentUserId();
|
//$logged_on_userid = $userservice->getCurrentUserId();
|
||||||
//$currentUser = $userservice->getCurrentUser();
|
//$currentUser = $userservice->getCurrentUser();
|
||||||
//$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
//$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
|
@ -28,10 +26,13 @@ include('search.inc.php');
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if((isset($currenttag) && $GLOBALS['enableCommonTagDescription'])
|
// common tag description
|
||||||
|
if((isset($currenttag) && $currenttag!= '' && $GLOBALS['enableCommonTagDescription'])
|
||||||
|| (isset($hash) && $GLOBALS['enableCommonBookmarkDescription'])):?>
|
|| (isset($hash) && $GLOBALS['enableCommonBookmarkDescription'])):?>
|
||||||
|
|
||||||
|
|
||||||
<p class="commondescription"><?php
|
<p class="commondescription"><?php
|
||||||
if(isset($currenttag) && $cdservice->getLastTagDescription($currenttag)) {
|
if(isset($currenttag) && $currenttag!= '' && $cdservice->getLastTagDescription($currenttag)) {
|
||||||
$description = $cdservice->getLastTagDescription($currenttag);
|
$description = $cdservice->getLastTagDescription($currenttag);
|
||||||
echo nl2br(filter($description['cdDescription']));
|
echo nl2br(filter($description['cdDescription']));
|
||||||
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
|
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
|
||||||
|
@ -40,8 +41,9 @@ if(isset($currenttag) && $cdservice->getLastTagDescription($currenttag)) {
|
||||||
echo nl2br(filter($description['cdDescription'])). "<br/>";
|
echo nl2br(filter($description['cdDescription'])). "<br/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//common tag description edit
|
||||||
if($userservice->isLoggedOn()) {
|
if($userservice->isLoggedOn()) {
|
||||||
if(isset($currenttag)) {
|
if(isset($currenttag) && $currenttag!= '') {
|
||||||
echo ' (<a href="'. createURL('tagcommondescriptionedit', $currenttag).'">';
|
echo ' (<a href="'. createURL('tagcommondescriptionedit', $currenttag).'">';
|
||||||
echo T_('edit common description').'</a>)';
|
echo T_('edit common description').'</a>)';
|
||||||
} elseif(isset($hash)) {
|
} elseif(isset($hash)) {
|
||||||
|
@ -55,7 +57,7 @@ if($userservice->isLoggedOn()) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
/* Private tag description */
|
/* Private tag description */
|
||||||
if(isset($currenttag) && isset($user)) {
|
if(isset($currenttag) && $currenttag!= '' && isset($user)) {
|
||||||
$userObject = $userservice->getUserByUsername($user);
|
$userObject = $userservice->getUserByUsername($user);
|
||||||
if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
|
if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ if (!isset($hash)) {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?> <?php
|
?> <?php
|
||||||
if(isset($currenttag)) {
|
if(isset($currenttag) && $currenttag!= '') {
|
||||||
if(isset($user)) {
|
if(isset($user)) {
|
||||||
echo ' - ';
|
echo ' - ';
|
||||||
echo '<a href="'. createURL('tags', $currenttag) .'">';
|
echo '<a href="'. createURL('tags', $currenttag) .'">';
|
||||||
|
@ -216,8 +218,8 @@ if(isset($currenttag)) {
|
||||||
|
|
||||||
// Ordering
|
// Ordering
|
||||||
$sortOrder = '';
|
$sortOrder = '';
|
||||||
if (isset($_GET['sort'])) {
|
if (GET_SORT != '') {
|
||||||
$sortOrder = 'sort='. $_GET['sort'];
|
$sortOrder = 'sort='. GET_SORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
|
$sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
|
||||||
|
|
|
@ -47,8 +47,6 @@ switch ($row['bStatus']) {
|
||||||
<input type="text" dojoType="dojox.form.MultiComboBox" id="tags" name="tags" size="75" value="<?php echo filter(implode(', ', $row['tags']), 'xml'); ?>" store="memberTagStore" delimiter="," searchAttr="tag" hasDownArrow="false"/></td>
|
<input type="text" dojoType="dojox.form.MultiComboBox" id="tags" name="tags" size="75" value="<?php echo filter(implode(', ', $row['tags']), 'xml'); ?>" store="memberTagStore" delimiter="," searchAttr="tag" hasDownArrow="false"/></td>
|
||||||
<td>← <?php echo T_('Comma-separated'); ?></td>
|
<td>← <?php echo T_('Comma-separated'); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
|
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
|
||||||
|
@ -73,7 +71,7 @@ switch ($row['bStatus']) {
|
||||||
<td>
|
<td>
|
||||||
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
|
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
|
||||||
<?php
|
<?php
|
||||||
if ($showdelete) {
|
if (isset($showdelete) && $showdelete) {
|
||||||
?>
|
?>
|
||||||
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
|
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
|
||||||
<?php
|
<?php
|
||||||
|
@ -82,7 +80,7 @@ switch ($row['bStatus']) {
|
||||||
?>
|
?>
|
||||||
<input type="hidden" name="popup" value="1" />
|
<input type="hidden" name="popup" value="1" />
|
||||||
<?php
|
<?php
|
||||||
} elseif ($referrer) {
|
} elseif (isset($referrer)) {
|
||||||
?>
|
?>
|
||||||
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
|
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
|
||||||
<?php
|
<?php
|
||||||
|
@ -99,7 +97,7 @@ switch ($row['bStatus']) {
|
||||||
$this->includeTemplate('dynamictags.inc');
|
$this->includeTemplate('dynamictags.inc');
|
||||||
|
|
||||||
// Bookmarklets and import links
|
// Bookmarklets and import links
|
||||||
if (empty($_REQUEST['popup']) && !$showdelete) {
|
if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h3><?php echo T_('Bookmarklet'); ?></h3>
|
<h3><?php echo T_('Bookmarklet'); ?></h3>
|
||||||
|
|
|
@ -27,7 +27,7 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left"><?php echo T_('E-mail'); ?></th>
|
<th align="left"><?php echo T_('E-mail'); ?></th>
|
||||||
<td><input type="text" name="pMail" size="75" value="<?php echo filter($row['email'], 'xml'); ?>" /></td>
|
<td><input type="text" name="pMail" size="75" value="<?php echo filter($objectUser->getEmail(), 'xml'); ?>" /></td>
|
||||||
<td>← <?php echo T_('Required'); ?></td>
|
<td>← <?php echo T_('Required'); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -37,15 +37,15 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||||
<table class="profile">
|
<table class="profile">
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left"><?php echo T_('Name'); ?></th>
|
<th align="left"><?php echo T_('Name'); ?></th>
|
||||||
<td><input type="text" name="pName" size="75" value="<?php echo filter($row['name'], 'xml'); ?>" /></td>
|
<td><input type="text" name="pName" size="75" value="<?php echo filter($objectUser->getName(), 'xml'); ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left"><?php echo T_('Homepage'); ?></th>
|
<th align="left"><?php echo T_('Homepage'); ?></th>
|
||||||
<td><input type="text" name="pPage" size="75" value="<?php echo filter($row['homepage']); ?>" /></td>
|
<td><input type="text" name="pPage" size="75" value="<?php echo filter($objectUser->getHomepage()); ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left"><?php echo T_('Description'); ?></th>
|
<th align="left"><?php echo T_('Description'); ?></th>
|
||||||
<td><textarea name="pDesc" cols="75" rows="10"><?php echo $row['uContent']; ?></textarea></td>
|
<td><textarea name="pDesc" cols="75" rows="10"><?php echo $objectUser->getContent(); ?></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
|
|
@ -7,26 +7,26 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||||
<dt><?php echo T_('Username'); ?></dt>
|
<dt><?php echo T_('Username'); ?></dt>
|
||||||
<dd><?php echo $user; ?></dd>
|
<dd><?php echo $user; ?></dd>
|
||||||
<?php
|
<?php
|
||||||
if ($row['name'] != "") {
|
if ($objectUser->getName() != "") {
|
||||||
?>
|
?>
|
||||||
<dt><?php echo T_('Name'); ?></dt>
|
<dt><?php echo T_('Name'); ?></dt>
|
||||||
<dd><?php echo filter($row['name']); ?></dd>
|
<dd><?php echo filter($objectUser->getName()); ?></dd>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($row['homepage'] != "") {
|
if ($objectUser->getHomepage() != "") {
|
||||||
?>
|
?>
|
||||||
<dt><?php echo T_('Homepage'); ?></dt>
|
<dt><?php echo T_('Homepage'); ?></dt>
|
||||||
<dd><a href="<?php echo filter($row['homepage']); ?>"><?php echo filter($row['homepage']); ?></a></dd>
|
<dd><a href="<?php echo filter($objectUser->getHomepage()); ?>"><?php echo filter($objectUser->getHomepage()); ?></a></dd>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<dt><?php echo T_('Member Since'); ?></dt>
|
<dt><?php echo T_('Member Since'); ?></dt>
|
||||||
<dd><?php echo date($GLOBALS['longdate'], strtotime($row['uDatetime'])); ?></dd>
|
<dd><?php echo date($GLOBALS['longdate'], strtotime($objectUser->getDatetime())); ?></dd>
|
||||||
<?php
|
<?php
|
||||||
if ($row['uContent'] != "") {
|
if ($objectUser->getContent() != "") {
|
||||||
?>
|
?>
|
||||||
<dt><?php echo T_('Description'); ?></dt>
|
<dt><?php echo T_('Description'); ?></dt>
|
||||||
<dd><?php echo $row['uContent']; ?></dd>
|
<dd><?php echo $objectUser->getContent(); ?></dd>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
$watching = $userservice->getWatchNames($userid);
|
$watching = $userservice->getWatchNames($userid);
|
||||||
|
|
|
@ -1,28 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
||||||
$commonTags =& $b2tservice->getRelatedTagsByHash($hash);
|
$commonTags =& $b2tservice->getRelatedTagsByHash($hash);
|
||||||
$commonTags =& $b2tservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
|
$commonTags =& $b2tservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
|
||||||
|
|
||||||
if ($commonTags && count($commonTags) > 0) {
|
if ($commonTags && count($commonTags) > 0) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h2><?php echo T_('Popular Tags'); ?></h2>
|
<h2><?php echo T_('Popular Tags'); ?></h2>
|
||||||
<div id="common">
|
<div id="common">
|
||||||
<p class="tags">
|
<p class="tags"><?php
|
||||||
<?php
|
$contents = '';
|
||||||
$contents = '';
|
|
||||||
|
|
||||||
if(strlen($user)==0) {
|
if(strlen($user)==0) {
|
||||||
$cat_url = createURL('tags', '%2$s');
|
$cat_url = createURL('tags', '%2$s');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($commonTags as $row) {
|
foreach ($commonTags as $row) {
|
||||||
$entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
|
$entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
|
||||||
$contents .= '<a href="'. sprintf($cat_url, $user, filter($row['tag'], 'url')) .'" title="'. $row['bCount'] .' '. $entries .'" rel="tag" style="font-size:'. $row['size'] .'">'. filter($row['tag']) .'</a> ';
|
$contents .= '<a href="'. sprintf($cat_url, $user, filter($row['tag'], 'url')) .'" title="'. $row['bCount'] .' '. $entries .'" rel="tag" style="font-size:'. $row['size'] .'">'. filter($row['tag']) .'</a> ';
|
||||||
}
|
}
|
||||||
echo $contents ."\n";
|
echo $contents ."\n";
|
||||||
?>
|
?></p>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
|
if(!isset($user)) {
|
||||||
|
$user = '';
|
||||||
|
}
|
||||||
|
if(!isset($userid)) {
|
||||||
|
$userid = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$logged_on_userid = $userservice->getCurrentUserId();
|
$logged_on_userid = $userservice->getCurrentUserId();
|
||||||
if ($logged_on_userid === false) {
|
if ($logged_on_userid === false) {
|
||||||
$logged_on_userid = NULL;
|
$logged_on_userid = NULL;
|
||||||
|
|
|
@ -20,7 +20,7 @@ if ($recentTags && count($recentTags) > 0) {
|
||||||
<?php
|
<?php
|
||||||
$contents = '<p class="tags">';
|
$contents = '<p class="tags">';
|
||||||
|
|
||||||
if(!isset($user)) {
|
if(!isset($user) || $user == '') {
|
||||||
$user = '';
|
$user = '';
|
||||||
$cat_url = createURL('tags', '%2$s');
|
$cat_url = createURL('tags', '%2$s');
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,12 @@ $logged_on_userid = $userservice->getCurrentUserId();
|
||||||
if ($logged_on_userid === false) {
|
if ($logged_on_userid === false) {
|
||||||
$logged_on_userid = NULL;
|
$logged_on_userid = NULL;
|
||||||
}
|
}
|
||||||
if(strlen($user)==0) {
|
|
||||||
|
if(!isset($userid)) {
|
||||||
|
$userid = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($user) && strlen($user)==0) {
|
||||||
$cat_url = createURL('tags', '%2$s');
|
$cat_url = createURL('tags', '%2$s');
|
||||||
}
|
}
|
||||||
if ($currenttag) {
|
if ($currenttag) {
|
||||||
|
|
|
@ -22,13 +22,14 @@ if(isset($rsschannels)) {
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="<?php echo ROOT ?>jsScuttle.php"></script>
|
src="<?php echo ROOT ?>jsScuttle.php"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css"
|
<link rel="stylesheet" type="text/css"
|
||||||
href="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dijit/themes/nihilo/nihilo.css">
|
href="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dijit/themes/nihilo/nihilo.css">
|
||||||
|
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dojo/dojo.xd.js"
|
src="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dojo/dojo.xd.js"
|
||||||
djConfig="parseOnLoad:true, isDebug:false, usePlainJson:true"></script>
|
djConfig="parseOnLoad:true, isDebug:false, usePlainJson:true"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
dojo.require("dojo.parser");
|
dojo.require("dojo.parser");
|
||||||
dojo.require("dojo.data.ItemFileReadStore");
|
dojo.require("dojo.data.ItemFileReadStore");
|
||||||
|
|
|
@ -1,27 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||||
$currentUserID = $userservice->getCurrentUserId();
|
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
|
|
||||||
|
|
||||||
$this->includeTemplate($GLOBALS['top_include']);
|
$this->includeTemplate($GLOBALS['top_include']);
|
||||||
|
|
||||||
echo '<ol id="bookmarks">';
|
echo '<ol id="bookmarks">';
|
||||||
|
|
||||||
foreach(array_keys($users) as $key) {
|
foreach($users as $user) {
|
||||||
|
|
||||||
echo '<li class="xfolkentry">'."\n";
|
echo '<li class="xfolkentry">'."\n";
|
||||||
|
|
||||||
echo '<div class="link">';
|
echo '<div class="link">';
|
||||||
echo '<a href="'.createURL('profile', $users[$key][$userservice->getFieldname('username')]).'">'.$users[$key][$userservice->getFieldName('username')].'</a>';
|
echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
if($users[$key][$userservice->getFieldName('username')] != $currentUsername) {
|
if($user->getUsername() != $currentObjectUser->getUsername()) {
|
||||||
echo '<div class="meta">';
|
echo '<div class="meta">';
|
||||||
echo '<a href="'.createURL('admin','delete/'.$users[$key][$userservice->getFieldname('username')]).'" onclick="return confirm(\''.T_('Are you sure?').'\');">'.T_('Delete').'</a>';
|
echo '<a href="'.createURL('admin','delete/'.$user->getUsername()).'" onclick="return confirm(\''.T_('Are you sure?').'\');">'.T_('Delete').'</a>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,21 +21,26 @@
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
$tplVars = array();
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
|
$tplVars = array();
|
||||||
|
|
||||||
$pagetitle = T_('Users');
|
$pagetitle = T_('Users');
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
if ($userservice->isLoggedOn()) {
|
if ($userservice->isLoggedOn()) {
|
||||||
$hash = md5($_SERVER['REQUEST_URI'] . $userservice->getCurrentUserID());
|
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
|
||||||
} else {
|
} else {
|
||||||
$hash = md5($_SERVER['REQUEST_URI']);
|
$hash = md5($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
84
watch.php
84
watch.php
|
@ -1,56 +1,62 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Copyright (C) 2004 - 2006 Scuttle project
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
http://sourceforge.net/projects/scuttle/
|
http://sourceforge.net/projects/scuttle/
|
||||||
http://scuttle.org/
|
http://scuttle.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||||
|
|
||||||
|
|
||||||
if ($userservice->isLoggedOn() && $user) {
|
if ($userservice->isLoggedOn() && $user) {
|
||||||
$tplVars = array();
|
$tplVars = array();
|
||||||
$pagetitle = '';
|
$pagetitle = '';
|
||||||
|
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if (!($userinfo = $userservice->getUserByUsername($user))) {
|
$userinfo = $userservice->getObjectUserByUsername($user);
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
if ($userinfo == '') {
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
exit();
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
} else {
|
exit();
|
||||||
$userid =& $userinfo['uId'];
|
} else {
|
||||||
}
|
$userid =& $userinfo->getId();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$watched = $userservice->getWatchStatus($userid, $userservice->getCurrentUserId());
|
$watched = $userservice->getWatchStatus($userid, $currentUser->getId());
|
||||||
$changed = $userservice->setWatchStatus($userid);
|
$changed = $userservice->setWatchStatus($userid);
|
||||||
|
|
||||||
if ($watched) {
|
if ($watched) {
|
||||||
$tplVars['msg'] = T_('User removed from your watchlist');
|
$tplVars['msg'] = T_('User removed from your watchlist');
|
||||||
} else {
|
} else {
|
||||||
$tplVars['msg'] = T_('User added to your watchlist');
|
$tplVars['msg'] = T_('User added to your watchlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
header('Location: '. createURL('watchlist', $currentUser->getUsername()));
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
|
|
||||||
header('Location: '. createURL('watchlist', $currentUsername));
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,27 +20,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
require_once('header.inc.php');
|
require_once('header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
|
||||||
|
|
||||||
$tplVars = array();
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
|
||||||
|
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
|
||||||
|
|
||||||
|
/* Managing current logged user */
|
||||||
|
$currentUser = $userservice->getCurrentObjectUser();
|
||||||
|
|
||||||
|
/* Managing path info */
|
||||||
@list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
@list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||||
|
|
||||||
$loggedon = false;
|
$tplVars = array();
|
||||||
if ($userservice->isLoggedOn()) {
|
|
||||||
$loggedon = true;
|
|
||||||
$currentUser = $userservice->getCurrentUser();
|
|
||||||
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Generate hash for caching on
|
// Generate hash for caching on
|
||||||
if ($loggedon) {
|
if ($userservice->isLoggedOn()) {
|
||||||
if ($currentUsername != $user) {
|
if ($currentUser->getUsername() != $user) {
|
||||||
$cachehash = md5($_SERVER['REQUEST_URI'] . $currentUsername);
|
$cachehash = md5($_SERVER['REQUEST_URI'] . $currentUser->getUsername());
|
||||||
|
|
||||||
// Cache for 5 minutes
|
// Cache for 5 minutes
|
||||||
$cacheservice->Start($cachehash);
|
$cacheservice->Start($cachehash);
|
||||||
|
@ -56,13 +58,14 @@ if ($user) {
|
||||||
if (is_int($user)) {
|
if (is_int($user)) {
|
||||||
$userid = intval($user);
|
$userid = intval($user);
|
||||||
} else {
|
} else {
|
||||||
if (!($userinfo = $userservice->getUserByUsername($user) ) ) {
|
$userinfo = $userservice->getObjectUserByUsername($user);
|
||||||
|
if ($userinfo == '' ) {
|
||||||
// Throw a 404 error
|
// Throw a 404 error
|
||||||
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$userid =& $userinfo['uId'];
|
$userid =& $userinfo->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +80,8 @@ if ($user) {
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
$perpage = getPerPageCount();
|
$perpage = getPerPageCount();
|
||||||
if (isset($_GET['page']) && intval($_GET['page']) > 1) {
|
if (intval(GET_PAGE) > 1) {
|
||||||
$page = $_GET['page'];
|
$page = GET_PAGE;
|
||||||
$start = ($page - 1) * $perpage;
|
$start = ($page - 1) * $perpage;
|
||||||
} else {
|
} else {
|
||||||
$page = 0;
|
$page = 0;
|
||||||
|
@ -86,6 +89,7 @@ if ($user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set template vars
|
// Set template vars
|
||||||
|
$tplVars['currenttag'] = '';
|
||||||
$tplVars['page'] = $page;
|
$tplVars['page'] = $page;
|
||||||
$tplVars['start'] = $start;
|
$tplVars['start'] = $start;
|
||||||
$tplVars['bookmarkCount'] = $start + 1;
|
$tplVars['bookmarkCount'] = $start + 1;
|
||||||
|
@ -99,7 +103,7 @@ if ($user) {
|
||||||
$tplVars['cat_url'] = createURL('tags', '%2$s');
|
$tplVars['cat_url'] = createURL('tags', '%2$s');
|
||||||
$tplVars['nav_url'] = createURL('watchlist', '%s/%s%s');
|
$tplVars['nav_url'] = createURL('watchlist', '%s/%s%s');
|
||||||
|
|
||||||
if ($user == $currentUsername) {
|
if ($userservice->isLoggedOn() && $user == $currentUser->getUsername()) {
|
||||||
$title = T_('My Watchlist');
|
$title = T_('My Watchlist');
|
||||||
} else {
|
} else {
|
||||||
$title = T_('Watchlist') .': '. $user;
|
$title = T_('Watchlist') .': '. $user;
|
||||||
|
|
Loading…
Reference in a new issue