Views: 11372
Last Modified: 14.07.2014
Quite often, when creating a site template, access to certain elements must be limited. An access right verification mechanism included in the system can be used while creating a site template for the following purposes:
- To Control Menu Option View
When editing the menu in an extended mode, a viewing condition may be set for each menu option. For example:
- To control the menu template
The level of users’ access rights may affect the menu template structure, elements, and images used, etc. An example of the verification of a user’s access right level for a menu template is provided below:
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<div class="blue-tabs-menu">
<ul>
<?foreach($arResult as $arItem):?>
<?if ($arItem["PERMISSION"] > "D"):?>
<li><a href="<?=$arItem["LINK"]?>"><nobr><?=$arItem["TEXT"]?></nobr></a></li>
<?endif?>
<?endforeach?>
</ul>
</div>
<div class="menu-clear-left"></div>
<?endif?>
Important! The conditions that include the verification of a value of the $PERMISSION variable are used only for the site menu.
- To control site template
A condition of use of a design template can be set up for each design template. The setup shall be made on the site parameter control page (Control Panel > Settings > System settings > Websites > Websites). E.g.:
The most flexible tool to setup display conditions is the PHP Condition. Examples of php conditions to display the site template:
$USER->IsAuthorized() | Checks if a current user is authorized in the system. |
$USER->IsAdmin() | Checks if a current user is the administrator. |
in_array('5',$USER-> GetUserGroupArray()) | Checks if a current user belongs to the specified group (in this case to a group with the ID equal to 5). |
|
- To control design template elements
Control of display of site template elements, their form, color, and other parameters may also be effected based on the level of access rights of site users. For more details, please refer to the lesson Design Template Development.
- Control of specific elements of the site
The use of the access rights check feature permits to organize control of specific site elements (pages, sections, advertising, fora, etc.) by different users. Please see the relevant section of the course System administration.