controllers/AuthItemController.php
public function actionView($name)
    {
        $formModel = new AddAuthItemForm();

        /* @var $am CAuthManager|AuthBehavior */
        $am = Yii::app()->getAuthManager();

        if (isset($_POST['AddAuthItemForm'])) {
            $formModel->attributes = $_POST['AddAuthItemForm'];
            if ($formModel->validate()) {
                if (!$am->hasItemChild($name, $formModel->items)) {
                    $am->addItemChild($name, $formModel->items);
                    if ($am instanceof CPhpAuthManager) {
                        $am->save();
                    }
                }
            }
        }

        $item = $am->getAuthItem($name);

        $dpConfig = array(
            'pagination' => false,
            'sort' => array('defaultOrder' => 'depth asc'),
        );

        $ancestors = $am->getAncestors($name);
        $ancestorDp = new PermissionDataProvider(array_values($ancestors), $dpConfig);

        $descendants = $am->getDescendants($name);
        $descendantDp = new PermissionDataProvider(array_values($descendants), $dpConfig);

        $childOptions = $this->getItemChildOptions($item->name);
        if (!empty($childOptions)) {
            $childOptions = array_merge(array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $childOptions);
        }

        $this->render(
            'view',
            array(
                'item' => $item,
                'ancestorDp' => $ancestorDp,
                'descendantDp' => $descendantDp,
                'formModel' => $formModel,
                'childOptions' => $childOptions,
            )
        );
    }
public function actionView($name)
    {
        $formModel = new AddAuthItemForm();

        /* @var $am CAuthManager|AuthBehavior */
        $am = Yii::app()->getAuthManager();

        if (isset($_POST['AddAuthItemForm'])) {
            $formModel->attributes = $_POST['AddAuthItemForm'];
            if ($formModel->validate()) {
                if (!$am->hasItemChild($name, $formModel->items)) {
                    $am->addItemChild($name, $formModel->items);
                    if ($am instanceof CPhpAuthManager) {
                        $am->save();
                    }
                }
            }
        }

        $item = $am->getAuthItem($name);

        $dpConfig = array(
            'pagination' => false,
            'sort' => array('defaultOrder' => 'depth asc'),
        );

        $ancestors = $am->getAncestors($name);
        $ancestorDp = new PermissionDataProvider(array_values($ancestors), $dpConfig);

        $descendants = $am->getDescendants($name);
        $descendantDp = new PermissionDataProvider(array_values($descendants), $dpConfig);

        $childOptions = $this->getItemChildOptions($item->name);
        if (!empty($childOptions)) {
            $childOptions = array_merge(array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $childOptions);
        }

        $this->render(
            'view',
            array(
                'item' => $item,
                'ancestorDp' => $ancestorDp,
                'descendantDp' => $descendantDp,
                'formModel' => $formModel,
                'childOptions' => $childOptions,
            )
        );
    }
public function actionView ( $ name ) { $ formModel = new AddAuthItemForm ( ) ; /* @var $am CAuthManager|AuthBehavior */ $ am = Yii :: app ( ) -> getAuthManager ( ) ; if ( isset ( $ _POST [ 'AddAuthItemForm' ] ) ) { $ formModel -> attributes = $ _POST [ 'AddAuthItemForm' ] ; if ( $ formModel -> validate ( ) ) { if ( ! $ am -> hasItemChild ( $ name , $ formModel -> items ) ) { $ am -> addItemChild ( $ name , $ formModel -> items ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ; } } } } $ item = $ am -> getAuthItem ( $ name ) ; $ dpConfig = array ( 'pagination' => false , 'sort' => array ( 'defaultOrder' => 'depth asc' ) , ) ; $ ancestors = $ am -> getAncestors ( $ name ) ; $ ancestorDp = new PermissionDataProvider ( array_values ( $ ancestors ) , $ dpConfig ) ; $ descendants = $ am -> getDescendants ( $ name ) ; $ descendantDp = new PermissionDataProvider ( array_values ( $ descendants ) , $ dpConfig ) ; $ childOptions = $ this -> getItemChildOptions ( $ item -> name ) ; if ( ! empty ( $ childOptions ) ) { $ childOptions = array_merge ( array ( '' => Yii :: t ( 'AuthModule.main' , 'Select item' ) . ' ...' ) , $ childOptions ) ; } $ this -> render ( 'view' , array ( 'item' => $ item , 'ancestorDp' => $ ancestorDp , 'descendantDp' => $ descendantDp , 'formModel' => $ formModel , 'childOptions' => $ childOptions , ) ) ; }
Displays the item with the given name.
@param string $name name of the item.
Displays the item with the given name .