From 146c63e90cd46b727fdc34acb1b224656d81efc5 Mon Sep 17 00:00:00 2001 From: mensonge Date: Fri, 14 Mar 2008 15:18:01 +0000 Subject: [PATCH] Feature improvement: make rename tags more consistent (with regards to linked tags) git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@85 b3834d28-1941-0410-a4f8-b48e95affb8f --- locales/fr_FR/LC_MESSAGES/messages.mo | Bin 18918 -> 18915 bytes locales/fr_FR/LC_MESSAGES/messages.po | 8 +++---- services/tag2tagservice.php | 24 +++++++++++++++++++++ tagrename.php | 9 +++++--- tests/tag2TagTest.php | 30 +++++++++++++++++--------- 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/locales/fr_FR/LC_MESSAGES/messages.mo b/locales/fr_FR/LC_MESSAGES/messages.mo index 2d4eba52d48d2dc3016d60cc3f6e57e417612591..ab44a15ef565360863e1e37a59185ae549f81e32 100644 GIT binary patch delta 1205 zcmXZb&r8%n7{~EvbN&4zt+W->wbCMuT0>Uzw`pz*StJ=$mKki8V1kf&D86>^7Ig3+ z;-Q0wei9_^QEKOvYcBiobCm`l`*2U>;^+J?_Etco4fWAD>_jPGTCq#ccfG`4KbZ#l`u-*RT?`!8254#*v(D+8bX-&ELcV+(re?sy8dc z0#pUt92yGLiOtx9?Kp)h^%f>!puwyJgQ!GXQ5$xk0(avnoWOis#=W?XyKx5S$(>(> ziqnL=4aXuh4lvMxeK>$xu!1V>8t%tGcn-5EljdK=2RMXE=qH}U9n^u!&bSo|qx#oT z`}ATE9n2uUJ*VMkU>Yyt4C?XuTFkNY6t(^-R^gkd#TPSQ7y83Bq43nb@{IIY@nG!!K!1NvZ!A7k6-?X}>xqxo MO(euCn&wjf16rVxSO5S3 delta 1199 zcmXZb%}bO~6vy#nGivHsPF8A@npqlInxiqL@TwvIydlZ&t)uSJ)LSYFpL3g!gB1z0lb7N@B?naCC>!rGEZqROU6P}0lQIgYEUoO z-r$%GGw5X@6KC-xzCa}oHM(z5iazFHJb^W+05?&cnL%o{Id6Rx^?U+DxQ0rc6*b$7 z`KS(dISiC&5LPEd;pEo~_I-(I&3(uemm_(iVHE;e9%a|{qo?FJ9xQ5!F)8fu| zpz^dMcf+wB2HRN}z;V2Q+VC0G+7-;fU)Y7&v`Nno;RH^i3i^f>_y_eu``g@()uHCY zs5s+Th*vQ{e!IuO&%!(&#iyvt=WpknaUY(>G0#OLhgEgBPM|K?0us*Npbw)5-7{`Q z71oE9IE9M;1cTbJ#6Y+DE9y)`om>#yg9_A%Q`mz#<3&7xe^G%d4w)6>AZq zW0*i)x;EOU-_N5ua2K5{25%YYHoiywoxWfyuA&M^AZKN3Sb+b~j|JWCSr?-cRHIrw zf@<|S)N|9Ag4a>|Z(s!Hx-I@Hb2i^!Szlds|7=+xmJtcYFGfPi>qbw-Z#B;NlKSK2 IEzi>a1K*~Qod5s; diff --git a/locales/fr_FR/LC_MESSAGES/messages.po b/locales/fr_FR/LC_MESSAGES/messages.po index 3c1a96a..714236e 100644 --- a/locales/fr_FR/LC_MESSAGES/messages.po +++ b/locales/fr_FR/LC_MESSAGES/messages.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Scuttle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2008-03-14 11:42+0100\n" -"PO-Revision-Date: 2008-03-14 11:43+0100\n" +"PO-Revision-Date: 2008-03-14 16:06+0100\n" "Last-Translator: BenjaminHKB \n" "Language-Team: fr-FR \n" "MIME-Version: 1.0\n" @@ -490,14 +490,14 @@ msgstr "Tag renommé" #: ../../../tagrename.php:50 msgid "Failed to rename the tag" -msgstr "Erreur dans la suppression du tag" +msgstr "Erreur dans le renommage du tag" #: ../../../tagrename.php:57 #: ../../../templates/sidebar.block.tagactions.php:11 msgid "Rename Tag" msgid_plural "Rename Tags" msgstr[0] "Renommer le tag" -msgstr[1] "TRenommer les tags" +msgstr[1] "Renommer les tags" #: ../../../tags.php:38 #: ../../../templates/editbookmark.tpl.php:44 @@ -1043,7 +1043,7 @@ msgstr "Ancien" #: ../../../templates/tagrename.tpl.php:17 msgid "New" -msgstr "Nouvaeu" +msgstr "Nouveau" #: ../../../templates/tagrename.tpl.php:24 msgid "Rename" diff --git a/services/tag2tagservice.php b/services/tag2tagservice.php index d3a4a77..ee26a11 100644 --- a/services/tag2tagservice.php +++ b/services/tag2tagservice.php @@ -231,6 +231,30 @@ class Tag2TagService { return true; } + function renameTag($uId, $oldName, $newName) { + $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() .'`'; + $query.= ' SET tag2="'.$newName.'"'; + $query.= ' WHERE tag2="'.$oldName.'"'; + $query.= ' AND uId="'.$uId.'"'; + $this->db->sql_query($query); + + // 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); diff --git a/tagrename.php b/tagrename.php index 2d611a7..18e9675 100644 --- a/tagrename.php +++ b/tagrename.php @@ -21,10 +21,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require_once('header.inc.php'); $tagservice = & ServiceFactory :: getServiceInstance('TagService'); +$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2tagService'); $templateservice = & ServiceFactory :: getServiceInstance('TemplateService'); $userservice = & ServiceFactory :: getServiceInstance('UserService'); -$tag = isset($_GET['query']) ? $_GET['query'] : NULL; +list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']); +//$tag = isset($_GET['query']) ? $_GET['query'] : NULL; $template = 'tagrename.tpl'; if ($_POST['confirm']) { @@ -41,7 +43,8 @@ if ($_POST['confirm']) { if ( !is_null($old) && !is_null($new) && - $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) + $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) && + $tag2tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) ) { $tplVars['msg'] = T_('Tag renamed'); $logged_on_user = $userservice->getCurrentUser(); @@ -60,4 +63,4 @@ if ($_POST['confirm']) { $tplVars['old'] = $tag; } $templateservice->loadTemplate($template, $tplVars); -?> \ No newline at end of file +?> diff --git a/tests/tag2TagTest.php b/tests/tag2TagTest.php index ea0adf0..c356be8 100644 --- a/tests/tag2TagTest.php +++ b/tests/tag2TagTest.php @@ -430,24 +430,34 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase $tsts = $this->tsts; // with classic tags (users 10 & 20) - $tags = array('a', 'b', 'c'); - $bs->addBookmark("http://site1.com", "title", "description", "status", $tags, null, false, false, 10); + $bs->addBookmark("http://site1.com", "title", "description", "status", array('tag1', 'tag11', 'tag111'), null, false, false, 1); + $bs->addBookmark("http://site1.com", "title2", "description2", "status", array('tag2', 'tag22', 'tag222'), null, false, false, 2); - $tags = array('a', 'b', 'c'); - $bs->addBookmark("http://site2.com", "title", "description", "status", $tags, null, false, false, 20); + $bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0, $dtend); + $this->assertEquals(1, $bookmarks['total']); - $bookmarks = $bs->getBookmarks(0, NULL, 10, 'a'); - $this->assertSame(array(), $bookmarks); - - $ts->renameTag(10, 'a', 'ddd'); + $ts->renameTag(1, 'tag1', 'newtag1'); $tags1 = $ts->getTagsForBookmark(1); - $this->assertSame(array('b', 'c', 'ddd'), $tags1); + $this->assertSame(array('newtag1', 'tag11', 'tag111'), $tags1); + $tags1 = $ts->getTagsForBookmark(2); + $this->assertSame(array('tag2', 'tag22', 'tag222'), $tags1); //should not be changed // with linked tags $tts->addLinkedTags('b', 'c', '>', 1); - $tts->addLinkedTags('a', 'd', '>', 1); + $tts->addLinkedTags('a', 'b', '>', 1); + $tts->addLinkedTags('b', 'a', '>', 2); // should not be modified because of userid + + $tts->renameTag(1, 'b', 'e'); + $linkedTags = $tts->getLinkedTags('e', '>', 1); + $this->assertSame(array('c'), $linkedTags); + $linkedTags = $tts->getLinkedTags('a', '>', 1); + $this->assertSame(array('e'), $linkedTags); + $linkedTags = $tts->getLinkedTags('b', '>', 2); + $this->assertSame(array('a'), $linkedTags); + + //with stats