Example #1
0
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'except' => ['view', 'index'], 'rules' => [['actions' => ['create', 'delete', 'update'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return OvcUser::isUserAdmin();
     }], ['actions' => ['update'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return OvcUser::isUserLecturer();
     }], ['actions' => ['my-courses'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
 }
Example #2
0
 /**
  * get User Courses
  * @param type $userId
  * @return type
  */
 public static function getUserCourses($userId = null)
 {
     if (empty($userId)) {
         $userId = \app\components\OvcUser::getCurrentUser()->id;
     }
     $userCourseIds = self::getCourseIdsByUserId($userId);
     return Course::findAll(['id' => $userCourseIds]);
 }
 public function init()
 {
     parent::init();
     if ($this->latestVideos === null) {
         $User = OvcUser::getCurrentUser();
         $courseIds = OvcCourse::getUserCourseIds($User->id);
         $this->latestVideos = \app\models\Video::find()->where(['course_id' => $courseIds])->orderBy('id DESC')->limit(16)->all();
     }
 }
Example #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function studentSearch($params)
 {
     $courseIds = \app\components\OvcCourse::getUserCourseIds();
     $userIds = \app\components\OvcUser::getUserIdsByCourseIds($courseIds);
     $query = User::find()->joinWith('role')->where(['user.id' => $userIds, 'user.role_id' => \app\components\OvcRole::STUDENT]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     $this->load($params);
     /**
      * sortin related columns
      */
     $dataProvider->sort->attributes['roleName'] = ['asc' => ['role.name' => SORT_ASC], 'desc' => ['role.name' => SORT_DESC]];
     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;
     }
     $query->andFilterWhere(['user.id' => $this->id, 'user.active' => $this->active, 'user.role_id' => $this->role_id, 'user.created_at' => $this->created_at, 'user.modified_at' => $this->modified_at]);
     $query->andFilterWhere(['like', 'user.first_name', $this->first_name])->andFilterWhere(['like', 'user.last_name', $this->last_name])->andFilterWhere(['like', 'user.username', $this->username])->andFilterWhere(['like', 'user.password', $this->password])->andFilterWhere(['like', 'user.email', $this->email])->andFilterWhere(['like', 'user.auth_key', $this->auth_key])->andFilterWhere(['like', 'user.access_token', $this->access_token])->andFilterWhere(['like', 'role.name', $this->roleName]);
     return $dataProvider;
 }
Example #5
0
 public static function getUserActionTemplate()
 {
     if (\app\components\OvcUser::isUserAdmin()) {
         return '<div class="width-50">{view}&nbsp;{update}&nbsp;{delete}</div>';
     } else {
         return '';
     }
 }
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
         return OvcUser::isUserAdmin();
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]]];
 }
Example #7
0
 public function actionIndex()
 {
     $courseIds = \app\components\OvcCourse::getUserCourseIds();
     $msg = \app\components\OvcUser::getUserIdsByCourseIds($courseIds);
     return $this->render('index', ['msg' => $msg]);
 }
Example #8
0
            <?php 
if (app\components\OvcUser::getCurrentUser()->id == $comment->user_id) {
    ?>
                <span class="glyphicon glyphicon-edit comment-edit" title="edit" data-comment-id="<?php 
    echo $comment->id;
    ?>
" data-url='<?php 
    echo yii\helpers\Url::to(['comment/inline-update', 'id' => $comment->id]);
    ?>
'></span>
            <?php 
}
?>
            &nbsp;
            <?php 
if (app\components\OvcUser::getCurrentUser()->id == $comment->user_id || \app\components\OvcUser::isUserAdmin()) {
    ?>
                <span class="glyphicon glyphicon-trash comment-delete" data-url='<?php 
    echo yii\helpers\Url::to(['comment/delete', 'id' => $comment->id, 'video_id' => $comment->video_id]);
    ?>
' data-comment-id='<?php 
    echo $comment->id;
    ?>
' title="trash"></span>
            <?php 
}
?>
        </div>

        <p>
            <strong class="ucfirst"><?php 
Example #9
0
 /**
  * inline update comment
  */
 public function actionInlineUpdateComment()
 {
     $id = Yii::$app->request->get('id');
     $comment = \app\models\Comment::findOne($id);
     $currentUserId = \app\components\OvcUser::getCurrentUser()->id;
     echo $this->renderPartial('_edit_comment_on_video', ['comment' => $comment, 'currentUserId' => $currentUserId]);
 }