controllers/AuthItemController.php
public function actionCreate()
    {
        $model = new AuthItemForm('create');

        if (isset($_POST['AuthItemForm'])) {
            $model->attributes = $_POST['AuthItemForm'];
            if ($model->validate()) {
                /* @var $am CAuthManager|AuthBehavior */
                $am = Yii::app()->getAuthManager();

                if (($item = $am->getAuthItem($model->name)) === null) {
                    $item = $am->createAuthItem($model->name, $model->type, $model->description);
                    if ($am instanceof CPhpAuthManager) {
                        $am->save();
                    }
                }

                $this->redirect(array('view', 'name' => $item->name));
            }
        }

        $model->type = $this->type;

        $this->render(
            'create',
            array(
                'model' => $model,
            )
        );
    }
public function actionCreate()
    {
        $model = new AuthItemForm('create');

        if (isset($_POST['AuthItemForm'])) {
            $model->attributes = $_POST['AuthItemForm'];
            if ($model->validate()) {
                /* @var $am CAuthManager|AuthBehavior */
                $am = Yii::app()->getAuthManager();

                if (($item = $am->getAuthItem($model->name)) === null) {
                    $item = $am->createAuthItem($model->name, $model->type, $model->description);
                    if ($am instanceof CPhpAuthManager) {
                        $am->save();
                    }
                }

                $this->redirect(array('view', 'name' => $item->name));
            }
        }

        $model->type = $this->type;

        $this->render(
            'create',
            array(
                'model' => $model,
            )
        );
    }
public function actionCreate ( ) { $ model = new AuthItemForm ( 'create' ) ; if ( isset ( $ _POST [ 'AuthItemForm' ] ) ) { $ model -> attributes = $ _POST [ 'AuthItemForm' ] ; if ( $ model -> validate ( ) ) { /* @var $am CAuthManager|AuthBehavior */ $ am = Yii :: app ( ) -> getAuthManager ( ) ; if ( ( $ item = $ am -> getAuthItem ( $ model -> name ) ) === null ) { $ item = $ am -> createAuthItem ( $ model -> name , $ model -> type , $ model -> description ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ; } } $ this -> redirect ( array ( 'view' , 'name' => $ item -> name ) ) ; } } $ model -> type = $ this -> type ; $ this -> render ( 'create' , array ( 'model' => $ model , ) ) ; }
Displays a form for creating a new item of the given type.
Displays a form for creating a new item of the given type .