]> git.mjollnir.org Git - s9y.git/commitdiff
* RFE #1231423: Allow to change the author of an entry with the
authorgarvinhicking <garvinhicking>
Fri, 8 Jul 2005 14:28:17 +0000 (14:28 +0000)
committergarvinhicking <garvinhicking>
Fri, 8 Jul 2005 14:28:17 +0000 (14:28 +0000)
      "entryproperties" plugin. (garvinhicking)

docs/NEWS
plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php

index d81629ce4d851d2b007b2d7e692f1e3a8dc38067..1869b94f96a7528e12a1e783bf337a80f98671fb 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * RFE #1231423: Allow to change the author of an entry with the
+      "entryproperties" plugin. (garvinhicking)
+
     * Templates can now be handled via Spartacus (garvinhicking)        
     
     * Plugin Manager: Improve Spartacus interface and include plugin      
index f6ec04b449b4b3f935ad7474e6a5b9f1ca68b42e..1f78013d33c1f8aafb820518b32dfaf251da60ab 100644 (file)
@@ -142,6 +142,21 @@ class serendipity_event_entryproperties extends serendipity_event
         serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
     }
 
+    function &getValidAuthors() {
+        global $serendipity;
+
+        if (serendipity_checkPermission('adminUsersMaintainOthers')) {
+            $users = serendipity_fetchUsers('');
+        } elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
+            $users = serendipity_fetchUsers('', serendipity_getGroups($serendipity['authorid'], true));
+        } else {
+            $users = serendipity_fetchUsers($serendipity['authorid']);
+        }
+        
+        return $users;
+    }
+
+
     function updateCache(&$entry) {
         global $serendipity;
 
@@ -252,7 +267,7 @@ class serendipity_event_entryproperties extends serendipity_event
                                 <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>" for="properties_no_nl2br">&nbsp;<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NL2BR; ?>&nbsp;&nbsp;</label><br />
 
 <?php } ?>
-
+                            
                             <br />
                             <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?>:<br />
                             <div style="margin-left: 10px">
@@ -274,11 +289,31 @@ class serendipity_event_entryproperties extends serendipity_event
                                 <option value="<?php echo $group['id']; ?>" <?php echo (in_array($group['id'], $access_groups) ? 'selected="selected"' : ''); ?>><?php echo htmlspecialchars($group['name']); ?></option>
 <?php
                         }
+                        echo '</select>';
                     }
 ?>
-                            </select>
                             </div>
                             <br />
+                            <?php echo AUTHOR; ?>:<br />
+                            <div style="margin-left: 10px">
+                                <select name="serendipity[change_author]">
+                                <?php
+                                if (isset($serendipity['POST']['change_author'])) {
+                                    $selected_user = $serendipity['POST']['change_author'];
+                                } elseif (!empty($eventData['authorid'])) {
+                                    $selected_user = $eventData['authorid'];
+                                } else {
+                                    $selected_user = $serendipity['authorid'];
+                                }
+                                
+                                $avail_users =& $this->getValidAuthors();
+
+                                foreach($avail_users AS $user) {
+                                    echo '<option value="' . $user['authorid'] . '" ' . ($selected_user == $user['authorid'] ? ' selected="selected"' : '') . '>' . $user['realname'] . '</option>' . "\n";
+                                }
+                                ?>
+                                </select>
+                            </div>
                     </fieldset>
 <?php
                     return true;
@@ -381,6 +416,17 @@ class serendipity_event_entryproperties extends serendipity_event
                     if (!isset($serendipity['POST']['properties']) || !is_array($serendipity['POST']['properties']) || !isset($eventData['id'])) {
                         return true;
                     }
+                    
+                    if (!empty($serendipity['POST']['change_author']) && $serendipity['POST']['change_author'] != $eventData['id']) {
+                        // Check again if the POSTed value is an author that the current user has "access" to.
+                        $avail_users =& $this->getValidAuthors();
+                        $new_authorid = (int)$serendipity['POST']['change_author'];
+                        foreach($avail_users AS $user) {
+                            if ($new_authorid == $user['authorid']) {
+                                serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET authorid = " . $new_authorid . " WHERE id = " . (int)$eventData['id']);
+                            }
+                        }
+                    }
 
                     if ($is_cache) {
                         $serendipity['POST']['properties']['cache_body']     = $eventData['body'];