aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-01-15 17:46:24 +0100
committerArthurHoaro <arthur@hoa.ro>2017-01-15 17:46:24 +0100
commitd6327389fc5cbb659e7f32fb61b2f1d5c86b02ee (patch)
tree865401a30e53852eba1a32b50cc50d00f94efd48 /index.php
parent9977c418d6d0de9e22e4ec276e7d476e184b5d01 (diff)
downloadShaarli-d6327389fc5cbb659e7f32fb61b2f1d5c86b02ee.tar.gz
Shaarli-d6327389fc5cbb659e7f32fb61b2f1d5c86b02ee.tar.zst
Shaarli-d6327389fc5cbb659e7f32fb61b2f1d5c86b02ee.zip
Prevent tag duplicate when renaming
Fixes #757
Diffstat (limited to 'index.php')
-rw-r--r--index.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/index.php b/index.php
index beb1cbca..55767562 100644
--- a/index.php
+++ b/index.php
@@ -1207,15 +1207,15 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1207 $needle = trim($_POST['fromtag']); 1207 $needle = trim($_POST['fromtag']);
1208 // True for case-sensitive tag search. 1208 // True for case-sensitive tag search.
1209 $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true); 1209 $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true);
1210 foreach($linksToAlter as $key=>$value) 1210 foreach($linksToAlter as $key=>$value) {
1211 { 1211 $tags = preg_split('/\s+/', trim($value['tags']));
1212 $tags = explode(' ',trim($value['tags'])); 1212 // Replace tags value.
1213 $tags[array_search($needle,$tags)] = trim($_POST['totag']); // Replace tags value. 1213 $tags[array_search($needle, $tags)] = trim($_POST['totag']);
1214 $value['tags']=trim(implode(' ',$tags)); 1214 $value['tags'] = implode(' ', array_unique($tags));
1215 $LINKSDB[$key]=$value; 1215 $LINKSDB[$key] = $value;
1216 } 1216 }
1217 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. 1217 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
1218 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; 1218 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>';
1219 exit; 1219 exit;
1220 } 1220 }
1221 } 1221 }