Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD plugin 1.0//EN" "http://dev.joomla.org/xml/1.5/plugin-install.dtd">
<install version="1.5" type="plugin" group="system">
<name>System - restrict</name>
<author>Barnum</author>
<authorUrl>http://www.domain.tld</authorUrl>
<authorEmail>kontakt[at]domain.tld</authorEmail>
<copyright>Copyright (C) 2010 - Barnum</copyright>
<license>GNU General Public License, http://www.gnu.org/licenses/gpl-2.0.html</license>
<creationDate>January 2010</creationDate>
<version>1.0</version>
<description>Plugin Description</description>
<files>
<filename plugin="restrict">restrict.php</filename>
</files>
<languages>
<language tag="de-DE">de-DE.plg_system_restrict.ini</language>
<language tag="en-GB">en-GB.plg_system_restrict.ini</language>
</languages>
<params>
<param name="id" type="text" default="" label="User IDs" description="User Ids Description" />
<param name="component" type="text" default="" label="Component" description="Name Of The Component" />
<param name="show_message" type="radio" default="0" label="Show Info Message" description="Show Info Message Description">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="message" type="text" default="" label="Info Message" description="Info Message Description" />
</params>
</install>
PHP-Code:
<?php
defined( '_JEXEC' ) or die( 'Restricted Access' );
jimport( 'joomla.plugin.plugin' );
class plgSystemRestrict extends JPlugin {
public function onAfterRoute() {
$application = JFactory::getApplication();
$option = JRequest::getWord( 'option' );
$user = JFactory::getUser();
$plugin = JPluginHelper::getPlugin( 'system', 'restrict' );
$pluginParams = new JParameter( $plugin->params );
$component = $pluginParams->get( 'component' );
$component = trim( $component );
$show_message = $pluginParams->get( 'show_message' );
$message = $pluginParams->get( 'message' );
unset( $plugin );
if ( !$application->isAdmin() || $component == '' || $option == 'com_login' || $option == $component || $user->get( 'usertype' ) == 'Super Administrator' ) {
return true;
}
$id = $pluginParams->get( 'id' );
unset( $pluginParams );
$tmp = str_replace( ' ', '', $id );
$list = explode( ',', $tmp );
$users = Array();
foreach ( $list as $item ) {
if ( is_numeric( $item ) ) {
$users[] = intval( $item );
} else {
continue;
}
}
if ( in_array( intval( $user->get( 'id' ) ), $users ) ) {
$msg = '';
if ( $show_message && $message ) {
$msg = $message;
}
$application->redirect( 'index.php?option='.$component, $msg );
}
unset( $user );
return true;
}
}
Plugin befindet sich im Anhang.
Lesezeichen