Index: trunk/extensions/GroupsSidebar/GroupsSidebar.php |
— | — | @@ -0,0 +1,20 @@ |
| 2 | +<?php |
| 3 | +# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
| 4 | +if (!defined('MEDIAWIKI')) { |
| 5 | + exit( 1 ); |
| 6 | +} |
| 7 | + |
| 8 | +$wgExtensionCredits['parserhook'][] = array( |
| 9 | + 'name' => 'GroupsSidebar', |
| 10 | + 'author' => 'Church of emacs', |
| 11 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:GroupsSidebar', |
| 12 | + 'description' => 'Add sidebar element for specific user groups', |
| 13 | + 'descriptionmsg' => 'myextension-desc', |
| 14 | + 'version' => '0.1', |
| 15 | +); |
| 16 | + |
| 17 | +$dir = dirname(__FILE__) . '/'; |
| 18 | + |
| 19 | +$wgAutoloadClasses['GroupsSidebar'] = $dir . 'GroupsSidebar.body.php'; # Tell MediaWiki to load the extension body. |
| 20 | +$wgHooks['SkinBuildSidebar'][] = array(new GroupsSidebar(), 'efHideSidebar'); |
| 21 | + |
Property changes on: trunk/extensions/GroupsSidebar/GroupsSidebar.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 22 | + native |
Index: trunk/extensions/GroupsSidebar/GroupsSidebar.body.php |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class GroupsSidebar { |
| 5 | + /* |
| 6 | + * Gets called by Hook SkinBuildSidebar |
| 7 | + */ |
| 8 | + function efHideSidebar( $skin, &$bar ) { |
| 9 | + global $wgGroupsSidebar, $wgUser; |
| 10 | + if ( is_null($wgGroupsSidebar) ) |
| 11 | + return true; |
| 12 | + foreach ( $wgGroupsSidebar as $group => $sectiontitle ) { |
| 13 | + if (in_array($group, $wgUser->getEffectiveGroups())) { |
| 14 | + $message = 'sidebar-'.$sectiontitle; |
| 15 | + $skin->addToSidebar( &$bar, $message ); |
| 16 | + } |
| 17 | + } |
| 18 | + return true; |
| 19 | + } |
| 20 | +} |
Property changes on: trunk/extensions/GroupsSidebar/GroupsSidebar.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 21 | + native |