Code refactoring: rename getNbUpdate(s); clean delete() parameters
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@51 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
50863e8fee
commit
73cf2a6898
3 changed files with 14 additions and 11 deletions
|
@ -146,11 +146,14 @@ class TagService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTag($tag) {
|
function deleteTag($uId, $tag) {
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
$logged_on_user = $userservice->getCurrentUserId();
|
|
||||||
|
|
||||||
$query = 'DELETE FROM '. $this->getTableName() .' USING '. $GLOBALS['tableprefix'] .'tags, '. $GLOBALS['tableprefix'] .'bookmarks WHERE '. $GLOBALS['tableprefix'] .'tags.bId = '. $GLOBALS['tableprefix'] .'bookmarks.bId AND '. $GLOBALS['tableprefix'] .'bookmarks.uId = '. $logged_on_user .' AND '. $GLOBALS['tableprefix'] .'tags.tag = "'. $this->db->sql_escape($tag) .'"';
|
$query = 'DELETE FROM '. $this->getTableName();
|
||||||
|
$query.= ' USING '. $this->getTableName() .', '. $bs->getTableName();
|
||||||
|
$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))) {
|
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);
|
||||||
|
@ -349,7 +352,7 @@ class TagService {
|
||||||
$bookmarks =& $bookmarksInfo['bookmarks'];
|
$bookmarks =& $bookmarksInfo['bookmarks'];
|
||||||
|
|
||||||
// Delete old tag
|
// Delete old tag
|
||||||
$this->deleteTag($old);
|
$this->deleteTag($userid, $old);
|
||||||
|
|
||||||
// Attach new tags
|
// Attach new tags
|
||||||
foreach(array_keys($bookmarks) as $key) {
|
foreach(array_keys($bookmarks) as $key) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TagStatService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNbUpdate($tag1, $relationType, $uId) {
|
function getNbUpdates($tag1, $relationType, $uId) {
|
||||||
$query = "SELECT nbupdate FROM `". $this->getTableName() ."`";
|
$query = "SELECT nbupdate FROM `". $this->getTableName() ."`";
|
||||||
$query.= " WHERE tag1 = '" .$tag1 ."'";
|
$query.= " WHERE tag1 = '" .$tag1 ."'";
|
||||||
$query.= " AND relationType = '". $relationType ."'";
|
$query.= " AND relationType = '". $relationType ."'";
|
||||||
|
|
|
@ -24,12 +24,13 @@ $tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
||||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
|
||||||
|
$logged_on_user = $userservice->getCurrentUser();
|
||||||
|
|
||||||
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
||||||
|
|
||||||
if ($_POST['confirm']) {
|
if ($_POST['confirm']) {
|
||||||
if ($tagservice->deleteTag($tag)) {
|
if ($tagservice->deleteTag($logged_on_user['uId'], $tag)) {
|
||||||
$tplVars['msg'] = T_('Tag deleted');
|
$tplVars['msg'] = T_('Tag deleted');
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
||||||
} else {
|
} else {
|
||||||
$tplVars['error'] = T_('Failed to delete the tag');
|
$tplVars['error'] = T_('Failed to delete the tag');
|
||||||
|
@ -37,7 +38,6 @@ if ($_POST['confirm']) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} elseif ($_POST['cancel']) {
|
} elseif ($_POST['cancel']) {
|
||||||
$logged_on_user = $userservice->getCurrentUser();
|
|
||||||
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue