Пример #1
0
 /**
  * Sets up all the roles and their hierarchy with all the elements that the
  * module is able to provide in the installation.
  * 
  * @param string $moduleid
  */
 public function actionModule($moduleid)
 {
     $module = YiiPlug::app()->getAutoloadedModule($moduleid);
     if ($module === null) {
         throw new CException(Yii::t('access.install', 'Impossible to find the module {id}.', array('{id}' => $moduleid)));
     }
     /* @var $accessModule AccessModule */
     $accessModule = $this->getModule();
     try {
         $transaction = AccessRole::model()->getDbConnection()->beginTransaction();
         $accessModule->registerAuthHierarchyFromModule($module);
         $transaction->commit();
     } catch (CDbException $e) {
         try {
             $transaction->rollback();
         } catch (CException $e2) {
             /* silent */
         }
         echo "The module hierarchy couldn't be installed.\n";
         echo $e->getMessage() . "\n";
         echo $e->getTraceAsString() . "\n";
         return;
     }
     echo "The module hierarchy is correctly installed.\n";
 }
Пример #2
0
 /**
  * The index action. This view lists the installed modules that are
  * available in the database to see their item hierarchy.
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'module_name';
     $criteria->distinct = true;
     $roles = AccessRole::model()->findAll($criteria);
     $module_names = array();
     foreach ($roles as $role) {
         $module_names[] = $role->module_name;
     }
     $this->title = Yii::t('access.controller.role', 'All registered modules');
     $this->render('index', array('module_names' => $module_names));
 }
 /**
  * {@inheritDoc}
  * @see IPluggableAccessManager::clearAll()
  */
 public function clearAll(IPluggableModule $module)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('module_name', $module->getId());
     return AccessRole::model()->deleteAll($criteria);
 }