wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
block.if_authorized.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: block.if_authorized.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 
20 /*
21 * Smarty plugin
22 * -------------------------------------------------------------
23 * File: block.if_authorized.php
24 * Type: block
25 * Name: if_authorized
26 * Purpose: render content based on authorization
27 * Parameters: resource The resource to authorize (e.g. class name of the Controller or OID).
28 * context The context in which the action takes place.
29 * action The action to process.
30 * alternative_content The content to display if not authorized
31 * Usage: {if_authorized resource="Category" action="delete"}
32 * ... content only visible
33 * for authorized users ...
34 * {/if_authorized}
35 *
36 * Author: Ingo Herwig <ingo@wemove.com>
37 * -------------------------------------------------------------
38 */
39 function smarty_block_if_authorized($params, $content, &$smarty)
40 {
41  if(!$repeat)
42  {
43  $rightsManager = &RightsManager::getInstance();
44  if ($rightsManager->authorize($params['resource'], $params['context'], $params['action']))
45  {
46  return $content;
47  }
48  else
49  {
50  return $params['alternative_content'];
51  }
52  }
53 }
54 ?>
smarty_block_if_authorized($params, $content, &$smarty)