aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php35
1 files changed, 3 insertions, 32 deletions
diff --git a/index.php b/index.php
index 50c0634a..00e4a40b 100644
--- a/index.php
+++ b/index.php
@@ -519,38 +519,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
519 519
520 // -------- User wants to rename a tag or delete it 520 // -------- User wants to rename a tag or delete it
521 if ($targetPage == Router::$PAGE_CHANGETAG) { 521 if ($targetPage == Router::$PAGE_CHANGETAG) {
522 if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) { 522 header('./manage-tags');
523 $PAGE->assign('fromtag', ! empty($_GET['fromtag']) ? escape($_GET['fromtag']) : '');
524 $PAGE->assign('pagetitle', t('Manage tags') .' - '. $conf->get('general.title', 'Shaarli'));
525 $PAGE->renderPage('changetag');
526 exit;
527 }
528
529 if (!$sessionManager->checkToken($_POST['token'])) {
530 die(t('Wrong token.'));
531 }
532
533 $toTag = isset($_POST['totag']) ? escape($_POST['totag']) : null;
534 $fromTag = escape($_POST['fromtag']);
535 $count = 0;
536 $bookmarks = $bookmarkService->search(['searchtags' => $fromTag], BookmarkFilter::$ALL, true);
537 foreach ($bookmarks as $bookmark) {
538 if ($toTag) {
539 $bookmark->renameTag($fromTag, $toTag);
540 } else {
541 $bookmark->deleteTag($fromTag);
542 }
543 $bookmarkService->set($bookmark, false);
544 $history->updateLink($bookmark);
545 $count++;
546 }
547 $bookmarkService->save();
548 $delete = empty($_POST['totag']);
549 $redirect = $delete ? './do=changetag' : 'searchtags='. urlencode(escape($_POST['totag']));
550 $alert = $delete
551 ? sprintf(t('The tag was removed from %d link.', 'The tag was removed from %d bookmarks.', $count), $count)
552 : sprintf(t('The tag was renamed in %d link.', 'The tag was renamed in %d bookmarks.', $count), $count);
553 echo '<script>alert("'. $alert .'");document.location=\'?'. $redirect .'\';</script>';
554 exit; 523 exit;
555 } 524 }
556 525
@@ -1380,6 +1349,8 @@ $app->group('', function () {
1380 $this->post('/password', '\Shaarli\Front\Controller\Admin\PasswordController:change')->setName('changePassword'); 1349 $this->post('/password', '\Shaarli\Front\Controller\Admin\PasswordController:change')->setName('changePassword');
1381 $this->get('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:index')->setName('configure'); 1350 $this->get('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:index')->setName('configure');
1382 $this->post('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:save')->setName('saveConfigure'); 1351 $this->post('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:save')->setName('saveConfigure');
1352 $this->get('/manage-tags', '\Shaarli\Front\Controller\Admin\ManageTagController:index')->setName('manageTag');
1353 $this->post('/manage-tags', '\Shaarli\Front\Controller\Admin\ManageTagController:save')->setName('saveManageTag');
1383 1354
1384 $this 1355 $this
1385 ->get('/links-per-page', '\Shaarli\Front\Controller\Admin\SessionFilterController:linksPerPage') 1356 ->get('/links-per-page', '\Shaarli\Front\Controller\Admin\SessionFilterController:linksPerPage')