本文整理汇总了PHP中Acl::hasPrivilege方法的典型用法代码示例。如果您正苦于以下问题:PHP Acl::hasPrivilege方法的具体用法?PHP Acl::hasPrivilege怎么用?PHP Acl::hasPrivilege使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Acl
的用法示例。
在下文中一共展示了Acl::hasPrivilege方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_DELETE);
SettingsEmailTemplate::model()->loadModel($id)->delete();
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
}
}
示例2: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_VIEW);
$model = UserRoles::model()->loadModel($id);
$this->pageTitle = $model->name;
$this->showPageTitle = TRUE;
$this->pageDescription = $model->description;
$forbidden_resources = Acl::getForbiddenResources(UserLevels::LEVEL_ENGINEER);
$resources = UserResources::model()->getResources($forbidden_resources);
if (isset($_POST['RolesOnResources'])) {
$roles_on_resources = $_POST['RolesOnResources'];
foreach ($roles_on_resources as $key => $rr) {
UserRolesOnResources::model()->set($key, $id, $rr);
}
Yii::app()->user->setFlash('success', Lang::t('SUCCESS_MESSAGE'));
$this->refresh();
}
$this->render('view', array('model' => $model, 'resources' => $resources));
}
示例3:
?>
<li <?php
if ($this->activeTab == 2) {
echo 'class="active"';
}
?>
><a href="<?php
echo $this->createUrl('documentation/admin');
?>
">Manage <?php
echo CHtml::encode($this->homeTitle);
?>
</a></li><?php
}
?>
<?php
if (Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_VIEW, false)) {
?>
<li <?php
if ($this->activeTab == 3) {
echo 'class="active"';
}
?>
><a href="<?php
echo $this->createUrl('documentation/helpCategory');
?>
">Manage Help Category</a></li><?php
}
?>
</ul>
示例4: array
<div class="widget">
<div class="widget-header"><h3><?php
echo CHtml::encode($this->pageTitle);
?>
</h3></div> <!-- /widget-header -->
<div class="widget-content mainpage">
<?php
echo $this->renderPartial('//documentation/_tab');
?>
<?php
$this->renderPartial('//widgets/_statusMessages');
?>
<div class="row-fluid">
<div class="span4">
<?php
if (Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_CREATE, FALSE)) {
?>
<a class="btn btn-default show-colorbox" href="<?php
echo $this->createUrl('createHelpCategory');
?>
"><i class="icon-plus-sign"></i> Add Help Category</a><?php
}
?>
</div>
<div class="span8">
<?php
$form = $this->beginWidget('ext.activeSearch.ActiveSearch', array('model' => $model, 'action' => Yii::app()->createUrl($this->route, $this->actionParams), 'textName' => '_search', 'formHtmlOptions' => array('class' => 'form-search pull-right', 'id' => 'active-search-form'), 'textHtmlOptions' => array('class' => 'input-large search-query', 'placeholder' => 'Search...')));
?>
<?php
$this->endWidget();
?>
示例5: array
<?php
$can_delete = Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_DELETE, FALSE);
$can_update = Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_UPDATE, FALSE);
$grid_id = 'help-category-grid';
Yii::app()->clientScript->registerScript('search', "\n\$('#active-search-form').submit(function(){\n\t\$.fn.yiiGridView.update('" . $grid_id . "', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
$this->widget('zii.widgets.grid.CGridView', array('id' => $grid_id, 'dataProvider' => $model->search($this->settings[Constants::KEY_PAGINATION], '`name` asc'), 'cssFile' => false, 'itemsCssClass' => 'style2', 'pagerCssClass' => 'pagination', 'pager' => array('cssFile' => false, 'header' => ''), 'summaryText' => Lang::t('summary_text'), 'columns' => array('id', 'name', 'description', array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'deleteConfirmation' => Lang::t('DELETE_CONFIRM'), 'htmlOptions' => array('style' => 'width:100px', 'class' => 'center-align'), 'buttons' => array('update' => array('imageUrl' => false, 'label' => '<i class="icon-pencil"></i>', 'visible' => '"' . $can_update . '"?true:false', 'url' => 'Yii::app()->controller->createUrl("updateHelpCategory",array("id"=>$data->id))', 'options' => array('class' => 'btn btn-mini btn-info', 'title' => 'Update', 'onclick' => 'return MyColorBox.showColorbox($(this).attr("href"));')), 'delete' => array('imageUrl' => false, 'label' => '<i class="icon-remove"></i>', 'visible' => '"' . $can_delete . '"?true:false', 'url' => 'Yii::app()->controller->createUrl("deleteHelpCategory",array("id"=>$data->id))', 'options' => array('class' => 'btn btn-mini btn-danger', 'title' => 'Delete')))))));
示例6: actionDeleteHelpCategory
public function actionDeleteHelpCategory($id)
{
Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_DELETE);
HelpCategory::model()->loadModel($id)->delete();
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('helpCategory'));
}
}
示例7: hasPrivilege
/**
* Should be called before any action the require ACL
* @param string $action
*/
public function hasPrivilege($action = NULL)
{
if (NULL === $action) {
$action = Acl::ACTION_VIEW;
}
Acl::hasPrivilege($this->privileges, $this->resource, $action);
}