User:Fcarpani
Appearance
Some Personal Data
[edit]I live in Uruguay and I'm a teacher at the state university (Universidad de la República) in the Computer Institute of Ingeneering School (Instituto de Computación, Facultad de Ingeniería).
Why I use MediaWiki
[edit]I'm trying to use MediaWiki as communication way for several projects. As an effective replacement to BSCW.
Extension in Use
[edit]I'm using extension:PageSecurity and User:Hex2bit/Calendar. Also I have a "dirty" extensions to protect SpecialPages based on groups.
I need...
[edit]- Lean php, a lot more.
- An english course! (yes, I know !!!! sorry :-) )
- A lot of other things...
Contributions
[edit]- A modified version of PageSecurity which allows a user if he belongs to an allowed group... or not... If the variable $wgPageSecurityAllowGroupAccept is false or not set, then is the normal PageSecurity. If the variable is true then a user is allow if belongs to an allowed group. The modified code is here.
- An extension that can control the access to SpecialPages based on groups. The code is here.
I need help pls, where shall I paste this? end of specialpage.php?
I am trying to access the specail page but say
Thanks Dean
<?php
include_once('GlobalFunctions.php');
// This is an attempt to control which SpecialPages can run each group
//
// The intention is set the SpecialPageExecuteBeforePage and if some conditions are not verified, display an error page.
//
//
$pageSpecialSecurityVersion = '0.0.1';
$wgExtensionFunctions[] = "wfSetSpecialPageSecurity";
global $wgExtensionCredits,$wgHooks;
$wgExtensionCredits['parserhook'][] = array(
'name'=>'PageSpecialSecurity',
'version'=>$pageSpecialSecurityVersion,
'author'=>'Fernando Carpani',
'url'=>'http://www.mediawiki.org/wiki/User:Fcarpani/SpecialPageSecurity',
'description' => 'Restricts access to special pages according to security definitions'
);
$wgHooks['SpecialPageAuthCheck'][]="SpecialPageAuthCheck"; /* Must be a boolean function. */
// The array $wgSpecialPageAuth have list of group that can execute this special page.
// The variable $wgSpecialPageAuthEnable control de check (if true, then the do the check
// global $wgSpecialPageAuth; is an array indexed by group and has a regular expression of allowed special page names.
// global $wgSpecialPageAuthEnable;
function wfSetSpecialPageSecurity() {
global $wgSpecialPageAuth,$wgSpecialPageAuthEnable;
if ($wgSpecialPageAuth==NULL){
$wgSpecialPageAuth=array();
}
if ($wgSpecialPageAuthEnable==NULL){
$wgSpecialPageAuthEnable=false;
}
wfDebug("=====>SetSpecialPageSecurity\n");
}
// The implementation is based on a new hook SpecialPageAuthCheck
function SpecialPageAuthCheck(){
global $wgSpecialPageAuthErrorPage,$wgUser,$wgTitle,$wgOut;
if (!SpecialPageAuthTest($wgTitle,$wgUser)){
if (empty($wgSpecialPageAuthErrorPage)) return false;
$title = Title::newFromText($wgSpecialPageAuthErrorPage);
$redirectURL = $title->getFullURL();
$wgOut->redirect($redirectURL);
wfDebug(sprintf("====>SpecialPageAuthCheck: %s user=%d no permitida\n",$wgTitle->mDbkeyform,$wgUser->mId));
return false;
}
return true;
}
function SpecialPageAuthTest(&$title,&$user){
global $wgSpecialPageAuthEnable,$wgSpecialPageAuth;
//$user=$wgUser;
//$title=$wgTitle;
wfDebug(sprintf("===>SpecialPageAuthTest: title=%s , user=%d\n",$title->mDbkeyform,$user->mId));
if($wgSpecialPageAuthEnable){
// get user groups
wfDebug(sprintf("===>SpecialPageAuthCheck: AuthEnable title=%s,user=%d\n",$title->mDbkeyform,$user->mId));
$user_groups=$user->getEffectiveGroups();
// Sysops can execute with basis in other checks.
if (in_array("sysop", $user_groups)) {
return true; // sysop access override granted
} else {
// if the user has a group that is allowed to execute this page, then true, else false.
foreach($user_groups as $group){
wfDebug(sprintf("===>SpecialPageAuthCheck: user %d in group=%s\n",$user->mId,$group));
#if(preg_match("$wgSpecialPageAuth[$group]",$title->mDbkeyform)){
if(preg_match($wgSpecialPageAuth[$group], $title->mDbkeyform, $matches, PREG_OFFSET_CAPTURE)){
wfDebug(sprintf("===>SpecialPageAuthCheck: return Allowed by group=%s\n",$group));
return true;
}
}
return false;
}
} else {
return true;
}
}