2011-01-14 63 views

回答

0

这可能是一个有点洁癖的你想要什么,但我认为你可以使用SimpleSecurity这一点,但也可能确保人民未经许可不得视图类别无论是。

+0

SimpleSecurity将允许你做起来很只有某些人可以编辑某些类别的,但我不认为这是什么,他们想做。 – 2011-01-14 16:02:45

0

不太可能,因为添加一个类别与添加一些文本一样简单,这不是一个可以通过默认安装或我可以找到的扩展来限制的操作。

我想如果您没有权限添加该类别,则可以编写和扩展程序来删除文本。

1

我相信你可以检查该类别是否被添加到ArticleSave钩子的页面中,并且如果用户没有所需的权限则发出错误。

编辑:沿着这些线路东西(快速&脏):

$wgForbiddenCats = array('Forbidden' => 'sysop'); 

$wgHooks['ArticleSave'][] = 'checkForbiddenCats'; 
function checkForbiddenCats($article, $user, $text, $summary, $minor, 
    $_, $_, $flags, $status) 
{ 
    global $wgForbiddenCats, $wgParser; 

    // Firstly, get categories in the new text 
    $parser_output = $wgParser->parse($text, $article->getTitle(), 
     $article->getParserOptions()); 
    $new_cats = array_keys($parser_output->getCategories()); 

    // For now, the only added categories are the ones in the submitted text 
    $added_cats = $new_cats; 

    // If the page already exists, it can have some categories already 
    if(!($flags & EDIT_NEW)) { 
     $dbr = wfGetDB(DB_SLAVE); 
     $query_result = $dbr->select(
      'categorylinks', 
      'cl_to', 
      array('cl_from' => $article->getID())); 

     $old_cats = array(); 
     while($row = $query_result->fetchRow()) 
      $old_cats[] = $row[0]; 
     $dbr->freeResult($query_result); 

     $added_cats = array_diff($new_cats, $old_cats); 
    } 

    $user_groups = $user->getGroups(); 
    foreach($wgForbiddenCats as $category => $group) { 
     if(array_search($category, $added_cats) !== false && 
      array_search($group, $user_groups) === false) 
     { 
      $status->fatal('forbidden-cat'); 
      return false; 
     } 
    } 

    return true; 
}