/** * Enable comments for indicated extension * * @param string $name Extension name * * @return boolean Whether extension is saved or not */ public static function enableExtension($name) { if (isset(self::$extensions[$name])) { $model = new Model(); $model->name = self::$extensions[$name]; return $model->save(); } return false; }
/** * Comments list page. */ public function actionIndex() { $searchModel = new CommentSearch(); $dataProvider = $searchModel->search(Yii::$app->request->get()); $statusArray = Comment::getStatusArray(); $modelArray = Model::getModelArray(); return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'statusArray' => $statusArray, 'modelArray' => $modelArray]); }
$boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null; ?> <?php if (Yii::$app->user->can('BManageCommentsModule')) { ?> <div class="row"> <div class="col-sm-12"> <?php Box::begin(['title' => Module::t('comments-models', 'BACKEND_INDEX_TITLE_ENABLING'), 'options' => ['class' => 'box-primary']]); ?> <?php if (Yii::$app->base->hasExtension('blogs')) { ?> <?php if (Model::isExtensionEnabled('blogs')) { ?> <?php echo Html::a(Html::tag('span', Html::tag('i', '', ['class' => 'fa fa-check']), ['class' => 'badge bg-green']) . Html::tag('i', '', ['class' => 'fa fa-book']) . Module::t('comments-models', 'BACKEND_INDEX_MODULE_BLOGS'), ['/comments/models/disable', 'name' => 'blogs'], ['class' => 'btn btn-app', 'data-method' => 'post', 'data-confirm' => Module::t('comments-models', 'BACKEND_INDEX_MODULES_DISABLE_CONFIRMATION')]); ?> <?php } else { ?> <?php echo Html::a(Html::tag('span', Html::tag('i', '', ['class' => 'fa fa-times']), ['class' => 'badge bg-red']) . Html::tag('i', '', ['class' => 'fa fa-book']) . Module::t('comments-models', 'BACKEND_INDEX_MODULE_BLOGS'), ['/comments/models/enable', 'name' => 'blogs'], ['class' => 'btn btn-app', 'data-method' => 'post']); ?> <?php } ?> <?php }
/** * Find model by ID. * * @param integer|array $id Model ID * * @return \vova07\comments\models\backend\Model Model * * @throws HttpException 404 error if model not found */ protected function findModel($id) { if (is_array($id)) { /** @var \vova07\comments\models\backend\Model $model */ $model = Model::findAll($id); } else { /** @var \vova07\comments\models\backend\Model $model */ $model = Model::findOne($id); } if ($model !== null) { return $model; } else { throw new HttpException(404); } }