/** * Displays the assignments for the user with the given id. * @param string $id the user id. */ 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)); }
/** * Fetches the data from the persistent data storage. * @return array list of data items */ public function fetchData() { $this->items = Rights::getAuthorizer()->getAuthItemParents($this->parent->name, $this->type, null, true); return parent::fetchData(); }
/** * Fetches the data from the persistent data storage. * @return array list of data items */ public function fetchData() { $this->items = Rights::getAuthorizer()->getAuthItemChildren($this->parent->name, $this->type); return parent::fetchData(); }