Example #1
0
 public function installAll($withUnits = true)
 {
     if (!$this->allowAccess()) {
         return false;
     }
     foreach (Yii::app()->params['coreModels'] as $className) {
         $this->installTable($className);
         $this->installDefaultAccess($className);
     }
     if ($withUnits) {
         ContentUnit::install(array_keys(ContentUnit::getAvailableUnits()));
     }
 }
Example #2
0
 /**
  * Страница инсталляции/деинсталляции блоков
  */
 public function actionInstall()
 {
     $allUnits = ContentUnit::getAvailableUnits();
     $errors = array();
     if (isset($_POST['Units'])) {
         $units = array_keys($_POST['Units']);
         ContentUnit::install($units);
         $uninstall = array_diff(array_keys($allUnits), $units);
         foreach ($uninstall as $i => $className) {
             $sql = 'SELECT count(*) FROM `' . Widget::tableName() . '` WHERE `class` = :class';
             $command = Yii::app()->db->createCommand($sql);
             $command->bindValue(':class', $className, PDO::PARAM_STR);
             $exists = $command->queryScalar();
             if ($exists) {
                 unset($uninstall[$i]);
                 $errors[] = Yii::t('cms', 'Can\\`t unistall "{name}"', array('{name}' => $allUnits[$className]['name']));
             }
         }
         ContentUnit::uninstall($uninstall);
         $allUnits = ContentUnit::getAvailableUnits();
     }
     $this->render('install', array('units' => $allUnits, 'errors' => $errors));
 }