Commit 5252cbae authored by Tobias Haider's avatar Tobias Haider
Browse files

allow hiding of navigational sections/elements for visitors who do not belong...

allow hiding of navigational sections/elements for visitors who do not belong to any of the specified groups
parent 6c1497e6
......@@ -578,6 +578,8 @@ class TweekiTemplate extends BaseTemplate {
) &&
!$this->checkVisibilitySetting( $item, $this->config->get( 'TweekiSkinHideAll' ) ) // not hidden for all
&&
!$this->checkVisibilityGroups( $item ) // not hidden for all OR user is in exempted group
&&
false !== Hooks::run( 'SkinTweekiCheckVisibility', [ $this, $item ] ) // not hidden via hook
) {
return true;
......@@ -588,7 +590,7 @@ class TweekiTemplate extends BaseTemplate {
/**
* Check if an element has an entry in a configuration option and if it's set to true
* (i.e. the element should be hidden to the corresponding group)
* (i.e. the element should be hidden)
*
* @param $item Element to be tested
* @param $setting Configuration option to be searched
......@@ -607,6 +609,38 @@ class TweekiTemplate extends BaseTemplate {
}
/**
* Check if an element has an entry in $wgTweekiSkinExcept or if the user is
* in the corresponding group
*
* @param $item Element to be tested
*
* @return Boolean returns true, if the element is hidden
*/
public function checkVisibilityGroups( $item ) {
// has the option been used?
if( !$this->config->has( 'TweekiSkinHideExcept' ) ) {
return false;
}
$group_settings = $this->config->get( 'TweekiSkinHideExcept' );
// has the option been set for this item?
if( isset( $group_settings[$item] ) && is_array( $group_settings[$item] ) ) {
$groups = $this->getSkin()->getUser()->getEffectiveGroups();
// is the user in the exempted group?
if( count( array_intersect( $group_settings[$item], $groups ) ) > 0 ) {
return false;
}
return true;
}
return false;
}
/**
* Render Subnavigation
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment