Extension talk:CategoryPermissions

Please add comments or suggestions

Special pages (well.. namespaces)
Hey there. A category-bases permission system is just what I need, so I am trying to get this one working on my Mediawiki installation (now if only I could find out its version, but think it's 1.6'ish). I use the proposed default rule to deny for all categories in CustomPermission.php. Unfortunately, it doesn't allow anonymous users to access the "meta-namespace" (sorry for lacking the appropriate term here) even though $wgGroupDefaultAllow == true. The start page for example doesn't have a category (at least none that I can see) and neither has the login page, amongst others. So, I cannot even log on to alter my access level. Does this work as expected? --Carp 08:39, 20 April 2007 (UTC)
 * Got a running version - I changed quite a bit, so I'm posting a diff instead of editing the code on the main site. It had nothing to do with namespace, instead I found that a few variables and properties where never checked. I'm running it on a production site now. Seems to work smoothly. Thanks for your work! --Carp 13:03, 20 April 2007 (UTC)

--- extensions/CustomPermissions.php Fri Apr 20 14:51:21 2007 +++ extensions/CustomPermissions.php   Fri Apr 20 12:14:58 2007 @@ -52,35 +52,47 @@  }   //scan list of categories, if any - if($parentCategories){ + if(is_array($parentCategories)) { foreach( $parentCategories as $category=>$dd){ - -     $temp_result = $user->isAllowed("{$category}_{$action}"); -     if($temp_result){ +   if ($user->isAnon or sizeof($user->mGroups) == 0) { +       $groups = array( '*' ); +     } +      else { +       $groups = $user->mGroups; +     } +      // Search permissions groups (or '*') +     foreach ($groups as $group) { +            // Don't overwrite if already found a permissive group +            if (!$temp_result) +              $temp_result = $wgGroupPermissions[$group]["{$category}_{$action}"]; +     } +      if($temp_result) { wfDebug("checkCategoryPermissions:{$category}_{$action} allowed on {$title->mPrefixedText} to {$user->mName}\n"); -       if($user->isAnon){ -         $result=true; -         return true; -       } -        else{ -         return null; -       }       } +      else { +       wfDebug("checkCategoryPermissions:{$category}_{$action} DENIED on {$title->mPrefixedText} to {$user->mName}\n"); +     } +      $result = $temp_result; +     return $result; }  }   else { wfDebug("checkCategoryPermissions:{$action} DENIED on {$title->mPrefixedText} to {$user->mName} : No Categories\n"); -   $result=false; -   return false; +   $result= $wgGroupDefaultAllow; +   return $result; }  //default action=deny wfDebug("checkCategoryPermissions:{$action} DENIED on {$title->mPrefixedText} to {$user->mName}\n"); - $result=false; - return false; + $result=true; + return $result; }