[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] tiki-invite.php & tiki-invited.php: invitation service bugs

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69383f3fd8da5_2a17ddc4668a0@gitlab-sidekiq-low-urgency-cpu-bound-v2-565846999f-69kfs.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
3c60e5fc by Landry Bitege at 2025-12-09T15:16:16+00:00
[FIX] tiki-invite.php & tiki-invited.php: invitation service bugs
---
* [FIX] tiki-invite.php & tiki-invited.php: invitation service bugs

See merge request tikiwiki/tiki!9174

- - - - -


4 changed files:

- templates/tiki-invite.tpl
- templates/tiki-invited.tpl
- tiki-invite.php
- tiki-invited.php


Changes:

=====================================
templates/tiki-invite.tpl
=====================================
@@ -1,4 +1,5 @@
 {title url="tiki-invite.php"}{tr}Invitation{/tr}{/title}
+{assign var=invite_action value="{$base_url}tiki-invite.php"}
 
 <div class="t_navbar mb-4">
     {button href="tiki-list_invite.php" _type="link" _icon_name="list" _text="{tr}Invitations List{/tr}"}
@@ -11,6 +12,9 @@
             <li>{$mail.email|escape}</li>
         {/foreach}
     </ul>
+    <form method='POST' action="{$invite_action}">
+        <input type='submit' name='return' value="{tr}Ok{/tr}" class="btn btn-primary">
+    </form>
 {elseif $smarty.request.send && !$smarty.request.confirm && !$smarty.request.back}
     <div class="highlight mt-2">{tr}You are about to send an invitation to theses people, please confirm :{/tr}</div>
     <ul>
@@ -18,7 +22,7 @@
             <li>{$mail.email|escape}</li>
         {/foreach}
     </ul>
-    <form method='POST' action='tiki-invite.php'>
+    <form method='POST' action="{$invite_action}">
         <input type='hidden' name='emailslist' value='{$smarty.request.emailslist|escape}'>
         <input type='hidden' name='emailslist_format' value='{$smarty.request.emailslist_format|escape}'>
         <input type='hidden' name='emailsubject' value='{$smarty.request.emailsubject|escape}'>
@@ -36,7 +40,7 @@
 
 {else}
     <hr>
-    <form method='POST' action='tiki-invite.php'>
+    <form method='POST' action="{$invite_action}">
         <div class="mb-3 row">
             <label class="col-form-label col-sm-5" for="loadprevious">{tr}Load a previous invitation settings{/tr}</label>
             <div class="col-sm-7">
@@ -103,7 +107,6 @@ You are here because you have just clicked on the link from my invitation email.
 {/if}{/tr}</textarea>
             </div>
         </div>
-
         {if count($invitegroups) > 0 && count($usergroups) > 0}
             <div class="mb-3 row">
                 <label class="col-form-label col-sm-5" for="invitegroups">{tr}Choose one or more groups that you want these subscriptions to be in. Don't choose any if you don't want anything special{/tr}</label>
@@ -121,7 +124,7 @@ You are here because you have just clicked on the link from my invitation email.
         <div class="mb-3 row">
             <label class="col-form-label col-sm-5" for="wikipageafter">{tr}Redirect to this wiki page after invitation acceptance (leave it blank if unwanted){/tr}</label>
             <div class="col-sm-7">
-                <input type='text' name='wikipageafter' value='{$smarty.request.wikipageafter|escape}'>
+                <input type='text' class="form-control" name='wikipageafter' value='{$smarty.request.wikipageafter|escape}'>
             </div>
         </div>
 


=====================================
templates/tiki-invited.tpl
=====================================
@@ -1,4 +1,4 @@
-<h1 class="pagetitle"><a href="tiki-invited.php">{tr}Invitation{/tr}</a></h1>
+{title url="tiki-invited.php"}{tr}Invitation{/tr}{/title}
 
 {if $error}
     {$error|escape}
@@ -8,13 +8,13 @@
 
     {if $user}
         You are currently logged as "{$user|escape}", if you want to validate this invitation on this account, click here :
-        <form method='POST'><input type='submit' name='validate-existing-account' value='Validate'></form>
+        <form method='POST'><input type='submit' name='validate-existing-account' class="btn btn-primary" value='Validate'></form>
     {else}
         <div>
-            If you want to validate this invitation on an already existing account, please login first: : <a href='tiki-login_scr.php'>login</a>
+            If you want to validate this invitation on an already existing account, please login first: <a href='tiki-login_scr.php'>login</a>
         </div>
         <div>
-            If you don't have any account yet, you can create one <a href="tiki-register.php?invit={$invit|escape:'url'}&amp;email={$email|escape:'url'}{if !empty($prefs.registerKey)}&amp;key={$prefs.registerKey|escape:'url'}{/if}"{if !empty($prefs.registerKey)} rel="nofollow"{/if}>here</a>
+            If you don't have any account yet, you can create one <a href="tiki-register.php?invit={$invite|escape:'url'}&amp;email={$email|escape:'url'}{if !empty($prefs.registerKey)}&amp;key={$prefs.registerKey|escape:'url'}{/if}"{if !empty($prefs.registerKey)} rel="nofollow"{/if}>here</a>
         </div>
     {/if}
 {/if}


=====================================
tiki-invite.php
=====================================
@@ -141,7 +141,7 @@ if (isset($_REQUEST['send'])) {
 
     $igroups = $_REQUEST['invitegroups'] ?? [];
 
-    if (! empty($_REQUEST['confirm']) && isset($_REQUEST['invitegroups'])) {
+    if (! empty($_REQUEST['confirm'])) {
         $tikilib->query(
             "INSERT INTO `tiki_invite` (inviter, `groups`, ts, emailsubject,emailcontent,wikicontent,wikipageafter) VALUES (?,?,?,?,?,?,?)",
             [
@@ -168,13 +168,11 @@ if (isset($_REQUEST['send'])) {
             );
         }
 
-        $_SERVER['SCRIPT_URI'] = empty($_SERVER['SCRIPT_URI']) ? 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_URI'];
         foreach ($emails as $m) {
             $mail = new TikiMail();
             $mail->setFrom($prefs['sender_email']);
             $mail->setSubject($_REQUEST["emailsubject"]);
-            $url = str_replace('tiki-invite.php', 'tiki-invited.php', $_SERVER['SCRIPT_URI'])
-                . '?invite=' . $id . '&email=' . urlencode($m['email']);
+            $url = TikiLib::tikiUrl('tiki-invited.php', ['invite' => $id, 'email' => $m['email']]);
             $text = $_text;
             $text = str_replace('{link}', $url, $text);
             $text = str_replace('{email}', $m['email'], $text);
@@ -185,11 +183,6 @@ if (isset($_REQUEST['send'])) {
         }
 
         $smarty->assign('sentresult', true);
-    } elseif (! isset($_REQUEST['invitegroups'])) {
-        Feedback::error(tr("You must select an invite group"));
-        $smarty->assign('mid', 'tiki-invite.tpl');
-        $smarty->display("tiki.tpl");
-         die();
     }
     $smarty->assign('emails', $emails);
 }


=====================================
tiki-invited.php
=====================================
@@ -65,16 +65,16 @@ function tiki_invited()
         );
         $groups = explode(',', $groups);
         foreach ($groups as $group) {
-            $userlib->assign_user_to_group($user, trim($group));
+            if (! empty(trim($group))) {
+                $userlib->assign_user_to_group($user, trim($group));
+            }
         }
 
         $tikilib->query("UPDATE tiki_invited SET used=?, used_on_user=? WHERE id=?", ["logged", $user, $invited['id']]);
 
         if (! empty($inviterow['wikipageafter'])) {
-            $_SERVER['SCRIPT_URI'] = empty($_SERVER['SCRIPT_URI']) ? 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_URI'];
-            $redirect = str_replace('tiki-invited.php', 'tiki-index.php?page=', $_SERVER['SCRIPT_URI']) . urlencode($inviterow['wikipageafter']);
-            header('Location: ' . $redirect);
-            exit;
+            $redirect = TikiLib::tikiUrl('tiki-index.php', ['page' => $inviterow['wikipageafter']]);
+            TikiLib::lib('access')->redirect($redirect);
         }
 
         $error = tra("Congratulations! You are now part of this invitation group(s)");



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/3c60e5fca03f10628c37ca73522f2ab62326c10e

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/3c60e5fca03f10628c37ca73522f2ab62326c10e
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.