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

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

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

                    if ($am instanceof ICachedAuthManager) {
                        $am->flushAccess($formModel->items, $id);
                    }
                }
            }
        }

        $model = CActiveRecord::model($this->module->userClass)->findByPk($id);

        $assignments = $am->getAuthAssignments($id);
        $authItems = $am->getItemsPermissions(array_keys($assignments));
        $authItemDp = new AuthItemDataProvider();
        $authItemDp->setAuthItems($authItems);

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

        $this->render(
            'view',
            array(
                'model' => $model,
                'authItemDp' => $authItemDp,
                'formModel' => $formModel,
                'assignmentOptions' => $assignmentOptions,
            )
        );
    }
public function actionView($id)
    {
        $formModel = new AddAuthItemForm();

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

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

                    if ($am instanceof ICachedAuthManager) {
                        $am->flushAccess($formModel->items, $id);
                    }
                }
            }
        }

        $model = CActiveRecord::model($this->module->userClass)->findByPk($id);

        $assignments = $am->getAuthAssignments($id);
        $authItems = $am->getItemsPermissions(array_keys($assignments));
        $authItemDp = new AuthItemDataProvider();
        $authItemDp->setAuthItems($authItems);

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

        $this->render(
            'view',
            array(
                'model' => $model,
                'authItemDp' => $authItemDp,
                'formModel' => $formModel,
                'assignmentOptions' => $assignmentOptions,
            )
        );
    }
public function actionView ( $ id ) { $ formModel = new AddAuthItemForm ( ) ; /* @var $am CAuthManager|AuthBehavior */ $ am = Yii :: app ( ) -> getAuthManager ( ) ; if ( isset ( $ _POST [ 'AddAuthItemForm' ] ) ) { $ formModel -> attributes = $ _POST [ 'AddAuthItemForm' ] ; if ( $ formModel -> validate ( ) ) { if ( ! $ am -> isAssigned ( $ formModel -> items , $ id ) ) { $ am -> assign ( $ formModel -> items , $ id ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ; } if ( $ am instanceof ICachedAuthManager ) { $ am -> flushAccess ( $ formModel -> items , $ id ) ; } } } } $ model = CActiveRecord :: model ( $ this -> module -> userClass ) -> findByPk ( $ id ) ; $ assignments = $ am -> getAuthAssignments ( $ id ) ; $ authItems = $ am -> getItemsPermissions ( array_keys ( $ assignments ) ) ; $ authItemDp = new AuthItemDataProvider ( ) ; $ authItemDp -> setAuthItems ( $ authItems ) ; $ assignmentOptions = $ this -> getAssignmentOptions ( $ id ) ; if ( ! empty ( $ assignmentOptions ) ) { $ assignmentOptions = array_merge ( array ( '' => Yii :: t ( 'AuthModule.main' , 'Select item' ) . ' ...' ) , $ assignmentOptions ) ; } $ this -> render ( 'view' , array ( 'model' => $ model , 'authItemDp' => $ authItemDp , 'formModel' => $ formModel , 'assignmentOptions' => $ assignmentOptions , ) ) ; }
Displays the assignments for the user with the given id.
@param string $id the user id.
Displays the assignments for the user with the given id .