[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Tags Editor module: restore add/remove actions

"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a271b7d2fcd3_38194ba0974ee@gitlab-sidekiq-low-urgency-cpu-bound-v2-5d4745456c-2hcsg.mail>

MAGENE Sem Joel pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
5f28b43a by MAGENE Sem Joel at 2026-06-08T19:37:49+00:00
[BP][FIX] Tags Editor module: restore add/remove actions
---
* [FIX] Tags Editor module: restore add/remove actions
---
* [FIX] Tags Editor module: restore add/remove actions

See merge request tikiwiki/tiki!10432

(cherry picked from commit ceb6cee7e1d38cb51de318d68017198e39576bef)

See merge request tikiwiki/tiki!10468

- - - - -


4 changed files:

- lib/freetag/freetaglib.php
- lib/setup/freetags.php
- tiki-read_article.php
- tiki-setup.php


Changes:

=====================================
lib/freetag/freetaglib.php
=====================================
@@ -82,6 +82,8 @@ class FreetagLib extends ObjectLib
 
     public $multilingual = false;
 
+    private bool $currentObjectTagRequestHandled = false;
+
 
     /**
      * FreetagLib
@@ -472,6 +474,54 @@ class FreetagLib extends ObjectLib
         return ['data' => $ret, 'count' => $count];
     }
 
+    /**
+     * Process add/remove tag requests for the current section object.
+     */
+    public function handleCurrentObjectTagRequest(): void
+    {
+        global $captchalib, $prefs, $smarty, $tiki_p_admin, $tiki_p_freetags_tag, $tiki_p_unassign_freetags, $tikilib, $user, $userlib;
+
+        if ($this->currentObjectTagRequestHandled) {
+            return;
+        }
+
+        $hasAddRequest = $tiki_p_freetags_tag === 'y' && trim($_POST['addtags'] ?? '') !== '';
+        $hasDeleteRequest = ($tiki_p_admin === 'y' || $tiki_p_unassign_freetags === 'y') && isset($_REQUEST['delTag']);
+        if (! $hasAddRequest && ! $hasDeleteRequest) {
+            return;
+        }
+
+        $object = \Tiki\Sections::currentObject();
+        if (! $object) {
+            return;
+        }
+        $this->currentObjectTagRequestHandled = true;
+
+        if ($hasAddRequest) {
+            if (empty($user)) {
+                $userid = 0;
+            } else {
+                $userid = $userlib->get_user_id($user);
+            }
+
+            if (empty($user) && $prefs['feature_antibot'] === 'y' && ! $captchalib->validate()) {
+                $smarty->assign('freetag_error', $captchalib->getErrors());
+                $smarty->assign_by_ref('freetag_msg', $_POST['addtags']);
+            } else {
+                $this->tag_object($userid, $object['object'], $object['type'], $_POST['addtags']);
+                $tikilib->refresh_index($object['type'], $object['object']);
+            }
+        }
+
+        if ($hasDeleteRequest) {
+            $this->delete_object_tag($object['object'], $object['type'], $_REQUEST['delTag']);
+            $tikilib->refresh_index($object['type'], $object['object']);
+
+            $url = $tikilib->httpPrefix() . preg_replace('/[?&]delTag=' . preg_quote(urlencode($_REQUEST['delTag']), '/') . '/', '', $_SERVER['REQUEST_URI']);
+            TikiLib::lib('access')->redirect($url);
+        }
+    }
+
     /**
      * Assign tags for the current object to Smarty as $tags.
      *


=====================================
lib/setup/freetags.php
=====================================
@@ -10,35 +10,7 @@ if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
 
 if (isset($section) and isset($sections[$section])) {
     $freetaglib = TikiLib::lib('freetag');
-    $here = $sections[$section];
-    if ($tiki_p_freetags_tag == 'y' && isset($_POST['addtags']) && trim($_POST['addtags']) != '') {
-        if (! isset($user)) {
-            $userid = 0;
-        } else {
-            $userid = $userlib->get_user_id($user);
-        }
-
-        if (empty($user) && $prefs['feature_antibot'] == 'y' && ! $captchalib->validate()) {
-            $smarty->assign('freetag_error', $captchalib->getErrors());
-            $smarty->assign_by_ref('freetag_msg', $_POST['addtags']);
-        } elseif ($object = current_object()) {
-            $freetaglib->tag_object($userid, $object['object'], $object['type'], $_POST['addtags']);
-            require_once 'lib/search/refresh-functions.php';
-            refresh_index($object['type'], $object['object']);
-        }
-    }
-
-    if (($tiki_p_admin == 'y' || $tiki_p_unassign_freetags == 'y') && isset($_REQUEST['delTag'])) {
-        if ($object = current_object()) {
-            $freetaglib->delete_object_tag($object['object'], $object['type'], $_REQUEST['delTag']);
-            require_once 'lib/search/refresh-functions.php';
-            refresh_index($object['type'], $object['object']);
-        }
-
-        $url = $tikilib->httpPrefix() . preg_replace('/[?&]delTag=' . preg_quote(urlencode($_REQUEST['delTag']), '/') . '/', '', $_SERVER['REQUEST_URI']);
-        header("Location: $url");
-        die;
-    }
+    $freetaglib->handleCurrentObjectTagRequest();
 
     $tags = [];
     if ($object = current_object()) {


=====================================
tiki-read_article.php
=====================================
@@ -12,8 +12,6 @@ use Tiki\Lib\Image\Image;
 use Tiki\Wiki\WikiPaginationUtils;
 use Tiki\Sections;
 
-$here = [];
-
 $inputConfiguration = [
     [
         'staticKeyFilters'         => [


=====================================
tiki-setup.php
=====================================
@@ -223,7 +223,9 @@ Sections::onSectionChange(function ($section) use ($prefs) {
         return;
     }
 
-    TikiLib::lib('freetag')->assignCurrentObjectTagsToSmarty();
+    $freetaglib = TikiLib::lib('freetag');
+    $freetaglib->handleCurrentObjectTagRequest();
+    $freetaglib->assignCurrentObjectTagsToSmarty();
 });
 
 require_once('lib/setup/wiki.php');



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5f28b43a65b6fff6725cbd52a6b1c556c518b492

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5f28b43a65b6fff6725cbd52a6b1c556c518b492
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.