/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Blog::find();
     $query->joinWith(['author']);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $dataProvider->sort->attributes['fullname'] = ['asc' => ['{{%core_account}}.fullname' => SORT_ASC], 'desc' => ['{{%core_account}}.fullname' => SORT_DESC]];
     /* user's blog */
     if (Core::checkMCA(null, 'blog', 'manage')) {
         $query->andFilterWhere(['{{%core_blog}}.created_by' => Yii::$app->user->id]);
     }
     /* list all public blog */
     if (Core::checkMCA(null, 'blog', 'index')) {
         $query->andFilterWhere(['{{%core_blog}}.status' => Blog::STATUS_PUBLISHED]);
     }
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['{{%core_blog}}.id' => $this->id, '{{%core_blog}}.created_by' => $this->created_by, '{{%core_blog}}.views' => $this->views, '{{%core_blog}}.status' => $this->status]);
     $query->andFilterWhere(['like', '{{%core_blog}}.title', $this->title])->andFilterWhere(['like', '{{%core_account}}.fullname', $this->fullname])->andFilterWhere(['like', '{{%core_blog}}.desc', $this->desc])->andFilterWhere(['like', '{{%core_blog}}.content', $this->content])->andFilterWhere(['like', '{{%core_blog}}.tags', $this->tags]);
     $query->andFilterWhere(['DATE(FROM_UNIXTIME(`{{%core_blog}}.updated_at`))' => $this->updated_at]);
     return $dataProvider;
 }
 /**
  * Finds the Blog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Blog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $condition = ['id' => $id];
     if (Core::checkMCA(null, 'blog', 'view')) {
         $condition = ['id' => $id, 'status' => Blog::STATUS_PUBLISHED];
     }
     if (($model = Blog::find()->where($condition)->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
 }
Example #3
0
 /**
  * account default items
  * @return array
  */
 protected function accountItems()
 {
     return [['label' => Yii::t('app', 'Personal settings')], ['icon' => 'user', 'label' => Yii::t('app', 'Profile'), 'url' => ['/account/index'], 'active' => Core::checkMCA(null, 'account', 'index')], ['icon' => 'envelope', 'label' => Yii::t('app', 'Email'), 'url' => ['/account/email'], 'active' => Core::checkMCA(null, 'account', 'email')], ['icon' => 'lock', 'label' => Yii::t('app', 'Password'), 'url' => ['/account/password'], 'active' => Core::checkMCA(null, 'account', 'password')], ['icon' => 'puzzle-piece', 'label' => Yii::t('app', 'Linked Accounts'), 'url' => ['/account/linked'], 'active' => Core::checkMCA(null, 'account', 'linked')], ['label' => Yii::t('app', 'Blog'), 'enabled' => Yii::$app->params['enableBlog']], ['icon' => 'rss-square', 'label' => Yii::t('app', 'My Blog'), 'url' => ['/blog/manage'], 'active' => Core::checkMCA(null, 'blog', 'manage'), 'enabled' => Yii::$app->params['enableBlog']], ['icon' => 'pencil-square', 'label' => Yii::t('app', 'Write'), 'url' => ['/blog/create'], 'active' => Core::checkMCA(null, 'blog', 'create'), 'enabled' => Yii::$app->params['enableBlog']]];
 }
Example #4
0
                <?php 
}
?>
            </div>
            <!-- /.navbar-collapse -->



            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <?php 
if (!Yii::$app->user->isGuest) {
    ?>
                        <li class="<?php 
    echo Core::checkMCA('', 'account', '*') ? 'active' : '';
    ?>
">
                            <a href="<?php 
    echo Yii::$app->urlManager->createUrl(['/account']);
    ?>
">
                                <?php 
    echo Icon::widget(['icon' => 'user']);
    ?>
                                <span><?php 
    echo Yii::$app->user->identity->fullname;
    ?>
</span>
                            </a>
                        </li>
Example #5
0
 /**
  * get menu active status
  * @return bool|null
  */
 public function getActiveStatus()
 {
     $path = $this->_path;
     if (!empty($this->active_route)) {
         $path = $this->active_route;
     }
     if (!empty($path)) {
         $count = substr_count($path, '/');
         $m = null;
         $c = null;
         $a = null;
         if ($count == 1) {
             list($c, $a) = explode('/', $path);
         } elseif ($count == 2) {
             list($m, $c, $a) = explode('/', $path);
         } else {
             return null;
         }
         $params = null;
         if (empty($this->active_route) && !empty($this->_query)) {
             parse_str($this->_query, $params);
         }
         return Core::checkMCA(explode('|', $m), explode('|', $c), explode('|', $a), $params);
     }
     return false;
 }