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

index cf8ff8cf640c127a9a48fa246642d15857d0e7e4..175c88f7425866592622a13659a51bd6ecd13ace 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,11 @@
 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 2e64a53aaa7a8f927a103c49a5d57dee8a9a1020..77e1dbba33ec764b77560f372f0e89f3679d6339 100644 (file)
@@ -182,6 +182,7 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
     }
 
     serendipity_plugin_api::hook_event('fetchcomments', $comments);
+
     return $comments;
 }
 
index 5e69e485b5c29f7fcc614ce01ca386b42309380c..1a3ba4cc9cc7d89805885a768ce9084b4fb10780 100644 (file)
@@ -1862,7 +1862,7 @@ function &serendipity_loadThemeOptions(&$template_config) {
     return $template_vars;
 }
 
-function serendipity_hasPluginPermissions($plugin) {
+function serendipity_hasPluginPermissions($plugin, $groupid = null) {
     static $forbidden = null;
     global $serendipity;
 
@@ -1870,22 +1870,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;