Author: Jorg Sowa (jorgsowa)
Committer: Derick Rethans (derickr)
Date: 2026-12-01T13:21:34Z

Commit: 
https://github.com/php/web-wiki/commit/89d66c89dd480c0d602a78823eb8faabf474487d
Raw diff: 
https://github.com/php/web-wiki/commit/89d66c89dd480c0d602a78823eb8faabf474487d.diff

Save an admin's doodle vote edit to the edited entry, not the admin's own

Changed paths:
  M  dokuwiki/lib/plugins/doodle/syntax.php


Diff:

diff --git a/dokuwiki/lib/plugins/doodle/syntax.php 
b/dokuwiki/lib/plugins/doodle/syntax.php
index 88758bd3..da1f9450 100755
--- a/dokuwiki/lib/plugins/doodle/syntax.php
+++ b/dokuwiki/lib/plugins/doodle/syntax.php
@@ -354,7 +354,9 @@ function castVote() {
             return;
         }
 
-        $fullname          = $_SERVER['REMOTE_USER'];
+        $isChange          = empty($_REQUEST['cast__vote']) && 
!empty($_REQUEST['change__vote']);
+        // An admin may change another voter's entry, so the edited entry's 
key comes from the form
+        $fullname          = $isChange ? hsc(trim($_REQUEST['fullname'] ?? 
'')) : $_SERVER['REMOTE_USER'];
         $selected_indexes  = $_REQUEST['selected_indexes'];  // may not be set 
when all checkboxes are deseleted.
 
         if (empty($fullname)) {
@@ -384,7 +386,7 @@ function castVote() {
 
         //if AUTH_IP, then prevent duplicate votes by IP.
         //Exception: If user is logged in he is always allowed to change the 
vote with his fullname, even if he is on another IP.
-        if ($this->params['auth'] == self::AUTH_IP && !$this->isLoggedIn() && 
!isset($_REQUEST['change__vote']) ) {
+        if ($this->params['auth'] == self::AUTH_IP && !$this->isLoggedIn() && 
!$isChange) {
             foreach($this->doodle as $existintFullname => $userData) {
               if (strcmp($userData['ip'], $_SERVER['REMOTE_ADDR']) == 0) {
                 $this->template['msg'] = 
sprintf($this->getLang('ip_has_already_voted'), $_SERVER['REMOTE_ADDR']);
@@ -394,20 +396,19 @@ function castVote() {
         }
 
         //do not vote twice, unless change__vote is set
-        if (isset($this->doodle["$fullname"]) && 
!isset($_REQUEST['change__vote']) ) {
+        if (isset($this->doodle["$fullname"]) && !$isChange) {
             $this->template['msg'] = $this->getLang('you_voted_already');
             return;
         }
 
         //check if change__vote is allowed
-        if (!empty($_REQUEST['change__vote']) &&
-            !$this->isAllowedToEditEntry($fullname))
+        if ($isChange && !$this->isAllowedToEditEntry($fullname))
         {
             $this->template['msg'] = $this->getLang('not_allowed_to_change');
             return;
         }
 
-        if (!empty($_SERVER['REMOTE_USER'])) {
+        if (!$isChange) {
           $this->doodle["$fullname"]['username'] = $_SERVER['REMOTE_USER'];
         }
         $this->doodle["$fullname"]['choices'] = $selected_indexes;
@@ -526,7 +527,7 @@ function getInputTR() {
         $TR .= '<td class="input_caption">';
         if ($fullname) {
             if ($editMode) $TR .= $this->getLang('edit').':&nbsp;';
-            $TR .= $_SERVER['REMOTE_USER'];
+            $TR .= $fullname;
             $TR .= '<input type="hidden" name="fullname" 
value="'.$fullname.'">';
         } else {
             $TR .= '<input type="text" name="fullname" value="">';

Reply via email to