Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
    ?>
<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
0
<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
0
<?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}&nbsp;&nbsp;{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
0
 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
0
 /**
  * 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);
 }