]> git.mjollnir.org Git - s9y.git/commitdiff
Fix showing proper plugin permissionship plugin
authorgarvinhicking <garvinhicking>
Tue, 13 Feb 2007 08:35:53 +0000 (08:35 +0000)
committergarvinhicking <garvinhicking>
Tue, 13 Feb 2007 08:35:53 +0000 (08:35 +0000)
docs/NEWS
include/admin/groups.inc.php
include/functions_comments.inc.php
include/functions_config.inc.php

index 113421219fcc985c27bff9227352d0d3ea29a537..30a21cdce3cc7d9c8bc053b9323a11579a7a077e 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -60,6 +60,11 @@ Version 1.2 ()
 Version 1.1.1 ()
 ------------------------------------------------------------------------
 
+    * Patch plugin permissionship management to properly indicate
+      forbidden plugins/hooks, even if the admin user is not contained
+      within the configured group. Thanks to ICE!
+      (http://board.s9y.org/viewtopic.php?t=8773) (garvinhicking)
+                
     * Patch pingback receiving function to use proper Regexp, thanks to 
       dhaun from the forums
       
index 7277c9c20dc946ce1110900e97ac8fe03d161bce..4b6d2a586d90a5d206198255774a21575fb93dea 100644 (file)
@@ -193,7 +193,7 @@ foreach($allusers AS $user) {
                     foreach($currentplugin['b']->properties['event_hooks'] AS $hook => $set) {
                         $allhooks[$hook] = true;
                     }
-                    echo '<option value="' . urlencode($plugid) . '" ' . (serendipity_hasPluginPermissions($plugid) ? '' : 'selected="selected"') . '>' . htmlspecialchars($currentplugin['b']->properties['name']) . '</option>' . "\n";
+                    echo '<option value="' . urlencode($plugid) . '" ' . (serendipity_hasPluginPermissions($plugid, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($currentplugin['b']->properties['name']) . '</option>' . "\n";
                 }
                 ksort($allhooks);
             ?>
@@ -210,7 +210,7 @@ foreach($allusers AS $user) {
             <select name="serendipity[forbidden_hooks][]" multiple="multiple" size="5">
             <?php
                 foreach($allhooks AS $hook => $set) {
-                    echo '<option value="' . urlencode($hook) . '" ' . (serendipity_hasPluginPermissions($hook) ? '' : 'selected="selected"') . '>' . htmlspecialchars($hook) . '</option>' . "\n";
+                    echo '<option value="' . urlencode($hook) . '" ' . (serendipity_hasPluginPermissions($hook, $from['id']) ? '' : 'selected="selected"') . '>' . htmlspecialchars($hook) . '</option>' . "\n";
                 }
             ?>
             </select>
index 166a880d795ff4d843085aafd60f9b5b91d24ca5..f09e8355a0e68030f4ff3905915fba4a7587fc44 100644 (file)
@@ -183,6 +183,7 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
     }
 
     serendipity_plugin_api::hook_event('fetchcomments', $comments);
+
     return $comments;
 }
 
index 78f96ca7fc086eebd158ce495a099ecf7060b24a..a49f8cf2362834e20e16b977e7dd58e26088570a 100644 (file)
@@ -1879,7 +1879,7 @@ function &serendipity_loadThemeOptions(&$template_config) {
     return $template_vars;
 }
 
-function serendipity_hasPluginPermissions($plugin) {
+function serendipity_hasPluginPermissions($plugin, $groupid = null) {
     static $forbidden = null;
     global $serendipity;
 
@@ -1887,22 +1887,28 @@ function serendipity_hasPluginPermissions($plugin) {
         return true;
     }
 
-    if ($forbidden === null) {
+    if ($forbidden === null || ($groupid !== null && !isset($forbidden[$groupid]))) {
         $forbidden = array();
-        $groups =& serendipity_checkPermission(null, null, 'all');
+        
+        if ($groupid === null) {
+            $groups =& serendipity_checkPermission(null, null, 'all');
+        } else {
+            $groups = array($groupid => serendipity_fetchGroup($groupid));
+        }
+
         foreach($groups AS $idx => $group) {
             if ($idx == 'membership') {
                 continue;
             }
             foreach($group AS $key => $val) {
                 if (substr($key, 0, 2) == 'f_') {
-                    $forbidden[$key] = true;
+                    $forbidden[$groupid][$key] = true;
                 }
             }
         }
     }
 
-    if (isset($forbidden['f_' . $plugin])) {
+    if (isset($forbidden[$groupid]['f_' . $plugin])) {
         return false;
     } else {
         return true;