[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Update href generation in module_since_last_visit_new to remove unnecessary query parameters

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68ca866f9056c_2c7d31ec370a9@gitlab-sidekiq-low-urgency-cpu-bound-v2-5dd8cccbbd-f524w.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
34dd97af by Joseph Lwanzo Kausi at 2025-09-17T09:51:31+00:00
[FIX] Update href generation in module_since_last_visit_new to remove unnecessary query parameters
---
* fix comment issue

* [FIX] Enhance SEF URL generation for items

* [FIX] Update href generation in module_since_last_visit_new to remove unnecessary query parameters

See merge request tikiwiki/tiki!8526

- - - - -


3 changed files:

- lib/smarty_tiki/Modifier/Sefurl.php
- modules/mod-func-since_last_visit_new.php
- route.php


Changes:

=====================================
lib/smarty_tiki/Modifier/Sefurl.php
=====================================
@@ -94,6 +94,19 @@ class Sefurl
 
                 break;
 
+            case 'filedetails':
+                // For file details page with galleryId and fileId
+                // Source format: "galleryId:fileId" (e.g., "5:34")
+                $parts = explode(':', $source);
+                if (count($parts) == 2) {
+                    $galleryId = $parts[0];
+                    $fileId = $parts[1];
+                    $href = $sefurl ? "filedetails$galleryId-$fileId" : "tiki-list_file_gallery.php?galleryId=$galleryId&fileId=$fileId&view=page";
+                } else {
+                    $href = "tiki-list_file_gallery.php?galleryId=$source&view=page";
+                }
+                break;
+
             case 'draft':
                 $href = 'tiki-download_file.php?fileId=' . $source . '&amp;draft';
                 break;
@@ -115,7 +128,7 @@ class Sefurl
                         $title = $trklib->get_title_sefurl($source);
                     }
                 } else {
-                    $href = 'tiki-view_tracker_item.php?itemId=' . $source;
+                    $href = $sefurl ? "item$source" : "tiki-view_tracker_item.php?itemId=$source";
                 }
                 break;
 
@@ -172,10 +185,22 @@ class Sefurl
             case 'survey':
                 $href = "tiki-take_survey.php?surveyId=" . urlencode($source);
                 break;
+
+            case 'poll':
+            case 'pollresults':
+                $href = $sefurl ? "pollresults$source" : "tiki-poll_results.php?pollId=$source";
+                break;
+            case 'user':
+                $href = $sefurl ? "profile-" . urlencode($source) : "tiki-user_information.php?view_user=" . urlencode($source);
+                break;
+            case 'assignuser':
+                $href = $sefurl ? "assign-user-" . urlencode($source) : "tiki-assignuser.php?assign_user=" . urlencode($source);
+                break;
+
             case 'faq':
             case 'faqs':
                 $type = 'faq';
-                $href = 'tiki-list_faqs.php?galleryId=' . $source;
+                $href = $sefurl ? "faq$source" : "tiki-view_faq.php?faqId=$source";
                 break;
             default:
                 $href = $source;


=====================================
modules/mod-func-since_last_visit_new.php
=====================================
@@ -196,24 +196,33 @@ function module_since_last_visit_new($mod_reference, &$module_params)
 
     $count = 0;
     foreach ($result as $res) {
-        $ret['items']['comments']['list'][$count]['href'] = TikiLib::lib('comments')->getHref($res['objectType'], $res['object'], $res['threadId']);
+        global $prefs;
+        if ($prefs['feature_sefurl'] == 'y') {
+            $objectType = $res['objectType'];
+            if ($objectType === 'post') {
+                $objectType = 'blogpost';
+            } elseif ($objectType === 'blog post') {
+                $objectType = 'blogpost';
+            } elseif ($objectType === 'wiki page') {
+                $objectType = 'wiki';
+            }
+
+            $baseUrl = smarty_modifier_sefurl($res['object'], $objectType);
+            $ret['items']['comments']['list'][$count]['href'] = $baseUrl . '#threadId=' . $res['threadId'];
+        } else {
+            $ret['items']['comments']['list'][$count]['href'] = TikiLib::lib('comments')->getHref($res['objectType'], $res['object'], $res['threadId']);
+        }
         switch ($res['objectType']) {
             case 'article':
                 $perm = 'tiki_p_read_article';
-                $ret['items']['comments']['list'][$count]['href'] =
-                            smarty_modifier_sefurl($ret['items']['comments']['list'][$count]['href'], 'article', $res['title']);
                 break;
 
             case 'post':
                 $perm = 'tiki_p_read_blog';
-                $ret['items']['comments']['list'][$count]['href'] =
-                            smarty_modifier_sefurl($ret['items']['comments']['list'][$count]['href'], 'blogpost', $res['title']);
                 break;
 
             case 'blog':
                 $perm = 'tiki_p_read_blog';
-                $ret['items']['comments']['list'][$count]['href'] =
-                            smarty_modifier_sefurl($ret['items']['comments']['list'][$count]['href'], 'blog', $res['title']);
                 break;
 
             case 'faq':
@@ -290,12 +299,10 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['parentId'], 'thread', 'tiki_p_forum_read')) {
-                $ret['items']['posts']['list'][$count]['href']
-                    = 'tiki-view_forum_thread.php?comments_parentId=';
                 if ($res['parentId']) {
-                    $ret['items']['posts']['list'][$count]['href'] .= $res['parentId'] . '#threadId=' . $res['threadId'];
+                    $ret['items']['posts']['list'][$count]['href'] = smarty_modifier_sefurl($res['parentId'], 'forumthread') . '#threadId=' . $res['threadId'];
                 } else {
-                    $ret['items']['posts']['list'][$count]['href'] .= $res['threadId'];
+                    $ret['items']['posts']['list'][$count]['href'] = smarty_modifier_sefurl($res['threadId'], 'forumthread');
                 }
                 $ret['items']['posts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['commentDate']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['userName']);
                 if ($res['parentId'] == 0 || $prefs['forum_reply_notitle'] != 'y') {
@@ -360,7 +367,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         foreach ($rows as $res) {
             if ($userlib->user_has_perm_on_object($user, $res['articleId'], 'article', 'tiki_p_read_article')) {
-                $ret['items']['articles']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-read_article.php?articleId=' . $res['articleId'], 'article', $res['title']);
+                $ret['items']['articles']['list'][$count]['href']  = smarty_modifier_sefurl($res['articleId'], 'article', $res['title']);
                 $ret['items']['articles']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']) . ' ' . tra('by') . ' ' . $res['authorName'];
                 $ret['items']['articles']['list'][$count]['label'] = $res['title'];
                 $count++;
@@ -382,7 +389,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['faqId'], 'faq', 'tiki_p_view_faq')) {
-                $ret['items']['faqs']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-view_faq.php?faqId=' . $res['faqId']);
+                $ret['items']['faqs']['list'][$count]['href']  = smarty_modifier_sefurl($res['faqId'], 'faq');
                 $ret['items']['faqs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']);
                 $ret['items']['faqs']['list'][$count]['label'] = $res['title'];
                 $count++;
@@ -404,7 +411,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['blogId'], 'blog', 'tiki_p_read_blog')) {
-                $ret['items']['blogs']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-view_blog.php?blogId=' . $res['blogId'], 'blog', $res['title']);
+                $ret['items']['blogs']['list'][$count]['href']  = smarty_modifier_sefurl($res['blogId'], 'blog', $res['title']);
                 $ret['items']['blogs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                 $ret['items']['blogs']['list'][$count]['label'] = $res['title'];
                 $count++;
@@ -422,7 +429,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['postId'], 'blog post', 'tiki_p_read_blog')) {
-                $ret['items']['blogPosts']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-view_blog_post.php?postId=' . $res['postId'], 'blogpost', $res['title']);
+                $ret['items']['blogPosts']['list'][$count]['href']  = smarty_modifier_sefurl($res['postId'], 'blogpost', $res['title']);
                 $ret['items']['blogPosts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                 $ret['items']['blogPosts']['list'][$count]['label'] = $res['title'];
                 $count++;
@@ -443,7 +450,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) {
-                $ret['items']['fileGalleries']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'], 'file gallery');
+                $ret['items']['fileGalleries']['list'][$count]['href']  = smarty_modifier_sefurl($res['galleryId'], 'file gallery');
                 $ret['items']['fileGalleries']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                 $ret['items']['fileGalleries']['list'][$count]['label'] = $res['name'];
                 $count++;
@@ -457,8 +464,10 @@ function module_since_last_visit_new($mod_reference, &$module_params)
 
         $files = TikiLib::lib('filegal')->get_files(-1, $resultCount, 'created_desc', null, -2, false, false, true, true, false, false, true, false, '', true, false, false, ['created' => (int) $ret['lastLogin']]);
         foreach ($files['data'] as $res) {
+            // Use sefurl for file details with galleryId:fileId format
+            $source = $res['galleryId'] . ':' . $res['fileId'];
             $ret['items']['files']['list'][] = [
-                'href' => smarty_modifier_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'] . '&fileId=' . $res['fileId'] . '&view=page', 'file gallery'),
+                'href' => smarty_modifier_sefurl($source, 'filedetails'),
                 'title' => $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']),
                 'label' => $res['name'] . ' (' . $res['filename'] . ')'
             ];
@@ -478,7 +487,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
 
         $count = 0;
         while ($res = $result->fetchRow()) {
-            $ret['items']['polls']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-poll_results.php?pollId=' . $res['pollId']);
+            $ret['items']['polls']['list'][$count]['href']  = smarty_modifier_sefurl($res['pollId'], 'pollresults');
             $ret['items']['polls']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']);
             $ret['items']['polls']['list'][$count]['label'] = $res['title'];
             $count++;
@@ -496,9 +505,14 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $result = $tikilib->query($query, [(int) $ret['lastLogin'], ''], $resultCount);
 
         $count = 0;
-        $slvn_tmp_href = $userlib->user_has_permission($user, 'tiki_p_admin') ? 'tiki-assignuser.php?assign_user=' : 'tiki-user_information.php?view_user=';
         while ($res = $result->fetchRow()) {
-            $ret['items']['users']['list'][$count]['href']  = $slvn_tmp_href . rawurlencode($res['login']);
+            if ($userlib->user_has_permission($user, 'tiki_p_admin')) {
+                // For admins, use clean URL to assign user page
+                $ret['items']['users']['list'][$count]['href'] = smarty_modifier_sefurl($res['login'], 'assignuser');
+            } else {
+                // For regular users, use clean URL to user information page
+                $ret['items']['users']['list'][$count]['href'] = smarty_modifier_sefurl($res['login'], 'user');
+            }
             $ret['items']['users']['list'][$count]['title'] = $tikilib->get_short_datetime($res['registrationDate']);
             $ret['items']['users']['list'][$count]['label'] = smarty_modifier_username($res['login']);
             $count++;
@@ -540,7 +554,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
                 $ret['items']['trackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]);
                 $ret['items']['trackers']['tid'][$res['trackerId']]['cname'] = 'slvn_tracker' . $res['trackerId'] . '_menu';
                 $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['href'] = smarty_modifier_sefurl(
-                    'tiki-view_tracker_item.php?itemId=' . $res['itemId'],
+                    $res['itemId'],
                     'trackeritem'
                 );
                 $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['created']);
@@ -600,7 +614,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
                 $ret['items']['utrackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]);
                 $ret['items']['utrackers']['tid'][$res['trackerId']]['cname'] = 'slvn_utracker' . $res['trackerId'] . '_menu';
                 $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['href']  = smarty_modifier_sefurl(
-                    'tiki-view_tracker_item.php?itemId=' . $res['itemId'],
+                    $res['itemId'],
                     'trackeritem'
                 );
                 $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['lastModif']);
@@ -643,7 +657,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_calendar')) {
-                $ret['items']['calendar']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-calendar.php?calIds[]=' . $res['calendarId'], 'calendar', $res['name']);
+                $ret['items']['calendar']['list'][$count]['href']  = smarty_modifier_sefurl($res['calendarId'], 'calendar', $res['name']);
                 $ret['items']['calendar']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                 $ret['items']['calendar']['list'][$count]['label'] = $res['name'];
                 $count++;
@@ -661,7 +675,7 @@ function module_since_last_visit_new($mod_reference, &$module_params)
         $count = 0;
         while ($res = $result->fetchRow()) {
             if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_events')) {
-                $ret['items']['events']['list'][$count]['href']  = smarty_modifier_sefurl('tiki-ajax_services.php?controller=calendar&action=view_item&calitemId=' . $res['calitemId'], 'event', $res['name']);
+                $ret['items']['events']['list'][$count]['href']  = smarty_modifier_sefurl($res['calitemId'], 'calendar event', $res['name']);
                 $ret['items']['events']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']) . ', ' . tra('starting on') . ' ' . $tikilib->get_short_datetime($res['start']);
                 $ret['items']['events']['list'][$count]['label'] = $res['name'];
                 $count++;


=====================================
route.php
=====================================
@@ -104,6 +104,13 @@ function tiki_route($path)
 
     tiki_route_attempt_prefix('faq', 'tiki-view_faq.php', 'faqId');
     tiki_route_attempt_prefix('file', 'tiki-list_file_gallery.php', 'galleryId');
+    tiki_route_attempt(
+        '|^filedetails(\d+)-(\d+)$|',
+        'tiki-list_file_gallery.php',
+        function ($parts) {
+            return ['galleryId' => $parts[1], 'fileId' => $parts[2], 'view' => 'page'];
+        }
+    );
     tiki_route_attempt_prefix('forum', 'tiki-view_forum.php', 'forumId');
     tiki_route_attempt('|^forumthread(\d+)(\-.*)?$|', 'tiki-view_forum_thread.php', tiki_route_single(1, 'comments_parentId'));
     tiki_route_attempt_prefix(
@@ -134,12 +141,29 @@ function tiki_route($path)
     tiki_route_attempt_prefix('newsletter', 'tiki-newsletters.php', 'nlId', ['info' => '1']);
     tiki_route_attempt_prefix('nl', 'tiki-newsletters.php', 'nlId', ['info' => '1']);
     tiki_route_attempt_prefix('poll', 'tiki-poll_form.php', 'pollId');
+    tiki_route_attempt_prefix('pollresults', 'tiki-poll_results.php', 'pollId');
     tiki_route_attempt_prefix('quiz', 'tiki-take_quiz.php', 'quizId');
     tiki_route_attempt_prefix('survey', 'tiki-take_survey.php', 'surveyId');
     tiki_route_attempt_prefix('tracker', 'tiki-view_tracker.php', 'trackerId');
     tiki_route_attempt_prefix('trackerfields', 'tiki-admin_tracker_fields.php', 'trackerId');
     tiki_route_attempt_prefix('sheet', 'tiki-view_sheets.php', 'sheetId');
     tiki_route_attempt_prefix('user', 'tiki-user_information.php', 'userId');
+    tiki_route_attempt(
+        '|^profile-(.+)$|',
+        'tiki-user_information.php',
+        function ($parts) {
+            return ['view_user' => urldecode($parts[1])];
+        }
+    );
+
+    tiki_route_attempt(
+        '|^assign-user-(.+)$|',
+        'tiki-assignuser.php',
+        function ($parts) {
+            return ['assign_user' => urldecode($parts[1])];
+        }
+    );
+    tiki_route_attempt_prefix('item', 'tiki-view_tracker_item.php', 'itemId');
     tiki_route_attempt('|^userinfo$|', 'tiki-view_tracker_item.php', function () {
         return ['view' => ' user'];
     });



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/34dd97af9c304a8a11c44d4210832c28f226cd60

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/34dd97af9c304a8a11c44d4210832c28f226cd60
You're receiving this email because of your account on gitlab.com.

_______________________________________________
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.