Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file block.securityutil_checkpermission_block.php

Documentation is available at block.securityutil_checkpermission_block.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: block.securityutil_checkpermission_block.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Blocks
  11.  */
  12.  
  13. /**
  14.  * Smarty block to implement PN permissions checks in a template
  15.  *
  16.  * available parameters:
  17.  *  - component   the component under test
  18.  *  - instance    the instance under test
  19.  *  - level       the level of access required
  20.  *
  21.  * Example
  22.  * <!--[securityutil_checkpermission_block component='News::' instance='1::' level=ACCESS_COMMENT]-->
  23.  * do some stuff now we have permission
  24.  * <!--[/securityutil_checkpermission_block]-->
  25.  *
  26.  * @author   Mark West
  27.  * @since    16 Feb 06
  28.  * @param    array    $params     All attributes passed to this function from the template
  29.  * @param    string   $content    The content between the block tags
  30.  * @param    object   $smarty     Reference to the Smarty object
  31.  * @return   mixed    the content if permission is held, null if no permissions is held (or on the opening tag), false on an error
  32.  */
  33. function smarty_block_securityutil_checkpermission_block($params$content&$smarty)
  34. {
  35.     if (is_null($content)) {
  36.         return;
  37.     }
  38.  
  39.     // check our input
  40.     if (!isset($params['component'])) {
  41.         $smarty->trigger_error('securityutil_checkpermission_block: attribute component required');
  42.         return false;
  43.     }
  44.     if (!isset($params['instance'])) {
  45.         $smarty->trigger_error('securityutil_checkpermission_block: attribute instance required');
  46.         return false;
  47.     }
  48.     if (!isset($params['level'])) {
  49.         $smarty->trigger_error('securityutil_checkpermission_block: attribute level required');
  50.         return false;
  51.     }
  52.  
  53.     if (!SecurityUtil::checkPermission($params['component']$params['instance']constant($params['level']))) return;
  54.  
  55.     return $content;
  56. }

Documentation generated on Fri, 18 Jul 2008 21:43:13 +0200 by phpDocumentor 1.4.1