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

Source for file block.pnsecauthaction_block.php

Documentation is available at block.pnsecauthaction_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.pnsecauthaction_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.  *  - realm       the realm under test
  18.  *  - component   the component under test
  19.  *  - instance    the instance under test
  20.  *  - level       the level of access required
  21.  *
  22.  * Example
  23.  * <!--[pnsecauthaction_block component='News::' instance='1::' level=ACCESS_COMMENT]-->
  24.  * do some stuff now we have permission
  25.  * <!--[/pnsecauthaction_block]-->
  26.  *
  27.  * @author   Mark West
  28.  * @since    16 Feb 06
  29.  * @param    array    $params     All attributes passed to this function from the template
  30.  * @param    string   $content    The content between the block tags
  31.  * @param    object   $smarty     Reference to the Smarty object
  32.  * @return   mixed    the content if permission is held, null if no permissions is held (or on the opening tag), false on an error
  33.  */
  34. function smarty_block_pnsecauthaction_block($params$content&$smarty)
  35. {
  36.     if (is_null($content)) {
  37.         return;
  38.     }
  39.  
  40.     extract($params);
  41.     unset($params);
  42.  
  43.     // check our input
  44.     if (!isset($realm)) $realm 0;
  45.     if (!isset($component)) {
  46.         $smarty->trigger_error('pnsecauthaction_block: attribute component required');
  47.         return false;
  48.     }
  49.     if (!isset($instance)) {
  50.         $smarty->trigger_error('pnsecauthaction_block: attribute instance required');
  51.         return false;
  52.     }
  53.     if (!isset($level)) {
  54.         $smarty->trigger_error('pnsecauthaction_block: attribute level required');
  55.         return false;
  56.     }
  57.  
  58.     if (!SecurityUtil::checkPermission($component$instanceconstant($level))) return;
  59.  
  60.     return $content;
  61. }

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