. * * @file * @ingroup Skins */ namespace Skins\Chameleon\Components\Modifications; use Skins\Chameleon\Components\Silent; use Skins\Chameleon\PermissionsHelper; /** * HideFor class * * @author Stephan Gambke * @since 1.1 * @ingroup Skins */ class HideFor extends Modification { private $permissionsHelper; /** * This method checks if the restriction is applicable and if necessary * replaces the decorated component by a Silent component */ protected function applyModification() { if ( $this->isHidden() ) { $c = $this->getComponent(); $this->setComponent( new Silent( $c->getSkinTemplate(), $c->getDomElement(), $c->getIndent() ) ); } } /** * @return bool */ private function isHidden() { $p = $this->getPermissionsHelper(); return $p->userHasGroup( 'group' ) && $p->userHasPermission( 'permission' ) && $p->pageIsInNamespace( 'namespace' ) && $p->pageHasCategory( 'category' ); } /** * @return PermissionsHelper */ private function getPermissionsHelper() { if ( $this->permissionsHelper === null ) { $this->permissionsHelper = new PermissionsHelper( $this->getSkinTemplate()->getSkin(), $this->getDomElementOfModification(), true ); } return $this->permissionsHelper; } }