public function actionLimitContent()
 {
     $contentId = Yii::app()->request->getParam('content_id');
     $contentType = Yii::app()->request->getParam('content_type');
     $userType = Yii::app()->request->getParam('user_type');
     $per = ContentLimitModel::getPermision($contentId, $contentType, $userType, "WEB");
     $this->render("limitContent", compact("per"));
 }
 /**
  * function actionView
  * call to render detail VideoPlaylist page
  */
 public function actionView()
 {
     $id = (int) Yii::app()->request->getParam('id');
     $video_id = Yii::app()->request->getParam('video_id', null);
     $videoPlaylist = WapVideoPlaylistModel::model()->published()->with('video_playlist_artist')->findByPk($id);
     $playPrice = $videoPlaylist->price;
     if (!$videoPlaylist) {
         $this->forward("/site/error", true);
     }
     $list_video_playlist = WapVideoModel::model()->getVideosOfVideoPlaylist($id);
     //check noi dung doc quyen
     $userType = "GUEST";
     $phone = Yii::app()->user->getState('phone');
     if ($phone) {
         $userType = "MEMBER";
     }
     $userSub = Yii::app()->user->getState('userSub');
     $packageCode = Yii::app()->user->getState('packageCode');
     if ($userSub) {
         $userType = "SUB_" . $packageCode;
     }
     $content_limit = ContentLimitModel::model()->getIdByType('video', 'WAP', $userType);
     $list_video = array();
     for ($i = 0; $i < count($list_video_playlist); $i++) {
         if (!in_array($list_video_playlist[$i]->id, $content_limit)) {
             $list_video[] = $list_video_playlist[$i];
         }
     }
     $phone = Yii::app()->user->getState('msisdn');
     $like = null;
     if ($phone) {
         $like = FavouriteVideoPlaylistModel::model()->findByAttributes(array('video_playlist_id' => $id, 'msisdn' => $phone));
     }
     $video = WapVideoModel::model()->with("video_extra")->findByPk($video_id);
     $video = isset($video) ? $video : $list_video[0];
     $artist_id = $videoPlaylist->video_playlist_artist[0]->artist_id;
     $count = VideoPlaylistArtistModel::model()->countVideoPlaylistByArtist($artist_id);
     $pager = new CPagination($count);
     $pager->setPageSize(Yii::app()->params['numberPerPage']);
     $videoPlaylistSameArtist = WapVideoPlaylistModel::model()->getVideoPlaylistsSameArtists($artist_id, $pager->getOffset(), $pager->getLimit());
     $callBackLink = Yii::app()->createUrl("videoPlaylist/loadAjax", array('s' => 'artist', 'artist_id' => $artist_id));
     $this->render('view', compact('video', 'list_video', 'videoPlaylist', 'pager', 'videoPlaylistSameArtist', 'callBackLink', 'like', 'artist_id'));
 }
Exemple #3
0
        $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone));
    }
    $this->renderPartial('_albumView', compact('content', 'perLimit', 'songsOfAlbum', 'like'));
} elseif ($topContent->type == 'video_playlist') {
    $list_video_playlist = WapVideoModel::model()->getVideosOfVideoPlaylist($topContent->content_id);
    //check noi dung doc quyen
    $userType = "GUEST";
    $phone = Yii::app()->user->getState('phone');
    if ($phone) {
        $userType = "MEMBER";
    }
    $userSub = Yii::app()->user->getState('userSub');
    $packageCode = Yii::app()->user->getState('packageCode');
    if ($userSub) {
        $userType = "SUB_" . $packageCode;
    }
    $content_limit = ContentLimitModel::model()->getIdByType('video', 'WAP', $userType);
    $list_video = array();
    for ($i = 0; $i < count($list_video_playlist); $i++) {
        if (!in_array($list_video_playlist[$i]->id, $content_limit)) {
            $list_video[] = $list_video_playlist[$i];
        }
    }
    $phone = Yii::app()->user->getState('msisdn');
    $like = null;
    if ($phone) {
        $like = FavouriteVideoPlaylistModel::model()->findByAttributes(array('video_playlist_id' => $topContent->content_id, 'msisdn' => $phone));
    }
    $video = $list_video[0];
    $this->renderPartial('_videoplaylistView', compact('content', 'list_video_playlist', 'songsOfAlbum', 'like', 'video', 'list_video'));
}
 public function actionView()
 {
     $id = (int) Yii::app()->request->getParam('id', 0);
     $playUrl = Yii::app()->request->getParam('url', null);
     $lyric = (int) Yii::app()->request->getParam('lyric', 0);
     $song = WapSongModel::model()->available()->findByPk($id);
     $isDeactive = false;
     if (!$song || $song->status == SongModel::DELETED) {
         $this->forward("/site/error", true);
     } elseif ($song->status == SongModel::DEACTIVE) {
         $isDeactive = true;
     }
     $artistId = SongArtistModel::model()->getArtistBySong($id, 'id');
     if ($artistId) {
         $artistId = $artistId[0];
     } else {
         $artistId = 0;
     }
     $genreId = SongGenreModel::model()->getCatBySong($song->id, false, true);
     if ($genreId) {
         $genreId = $genreId[0];
     } else {
         $genreId = 0;
     }
     //--- Check quyền nghe bài hát này
     $userType = "GUEST";
     if (Yii::app()->user->getState('msisdn')) {
         $userType = "MEMBER";
     }
     if (!empty($this->userSub)) {
         if (isset($this->userSub->package) && !empty($this->userSub->package)) {
             $package = $this->userSub->package->code;
         }
         $package = strtoupper($package);
         $userType = "SUB_" . $package;
     }
     $per = ContentLimitModel::getPermision($song->id, "song", $userType, "WAP");
     //---End check quyền nghe bài hát này
     $count = WapSongModel::model()->countSongsSameSinger($song->id, $artistId);
     $pager = new CPagination($count);
     $limit = Yii::app()->params['numberPerPage'];
     if ($this->layout == 'application.views.wap.layouts.main') {
         $limit = Yii::app()->params['numberSongPerPageWap'];
     }
     $pager->setPageSize($limit);
     $songArtist = WapSongModel::model()->getSongsSameSinger($song->id, $artistId, $pager->getOffset(), $pager->getLimit());
     $callBackLink = Yii::app()->createUrl("song/artist", array('song_id' => $song->id, 'artist_id' => $artistId));
     // check like
     $like = null;
     $favourite = Yii::app()->request->getParam('favourite', null);
     $user_id = Yii::app()->user->id;
     $phone = yii::app()->user->getState('msisdn');
     $artist_name = Common::makeFriendlyUrl($song->artist_name);
     $back_url = Yii::app()->params['base_url'] . Yii::app()->createUrl('song/view', array('id' => $song->id, 'url_key' => Common::makeFriendlyUrl($song->name), 'artist' => $artist_name));
     if (isset($favourite) && $favourite == 1) {
         //yeu thich video
         if (!empty($phone)) {
             $fav = WapFavouriteSongModel::model()->favouriteSong($id, $phone, $phone);
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     } elseif (isset($favourite) && $favourite == 0) {
         if (!empty($user_id)) {
             $res = WapFavouriteSongModel::model()->deleteAll("song_id={$id} AND msisdn={$phone}");
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     }
     if ($phone) {
         $like = WapFavouriteSongModel::model()->findByAttributes(array('song_id' => $song->id, 'msisdn' => $phone));
     }
     // Get Song Meta Data
     $Artist = ArtistModel::model()->findByPk($song->song_artist[0]->artist_id);
     $this->url = URLHelper::buildFriendlyURL("song", $song->id, $song->url_key);
     $this->itemName = $song->name;
     $this->artist = $Artist ? $Artist->name : 'Music';
     $this->thumb = ArtistModel::model()->getAvatarUrl($song->song_artist[0]->artist_id, 's1');
     $userSub = $this->userSub;
     $this->render('view', compact('song', 'songArtist', 'pager', 'callBackLink', 'artistId', 'genreId', 'like', 'per', 'lyric', 'playUrl', 'isDeactive'));
 }
 /**
  * function actionView
  * call to render detail album page
  */
 public function actionView()
 {
     $albumId = (int) Yii::app()->request->getParam('id');
     $album = WapAlbumModel::model()->available()->findByPk($albumId);
     if (!$album) {
         $this->forward("/site/error", true);
     } else {
         if ($album->status == 0) {
             $deactive = true;
         }
     }
     $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
     //samge artist
     $countAlbumsSameArtist = WapAlbumModel::model()->countAlbumsSameArtist($album->id, $album->artist_id);
     $albumPages = new CPagination($countAlbumsSameArtist);
     $pageSize = Yii::app()->params['pageSize'];
     $albumPages->setPageSize($pageSize);
     $currentPage = $albumPages->getCurrentPage();
     /* NEW */
     $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
     $artistIds = '';
     if ($artists) {
         foreach ($artists as $artist) {
             $artistIds .= ',' . $artist->artist_id;
         }
     }
     $artistIds = $artistIds != '' ? substr($artistIds, 1) : '';
     $albumsSameArtist = WapAlbumModel::model()->getAlbumbyArtists($artistIds, $pageSize, $currentPage * $pageSize);
     /* END */
     $phone = yii::app()->user->getState('msisdn');
     $errorCode = 'success';
     $errorDescription = '';
     //for show price
     $favourite = Yii::app()->request->getParam('favourite', null);
     $phone = yii::app()->user->getState('msisdn');
     $user_id = Yii::app()->user->id;
     if (isset($favourite) && $favourite == 0) {
         if (!empty($user_id)) {
             $res = WapFavouriteAlbumModel::model()->deleteAllByAttributes(array('msisdn' => $phone, 'album_id' => $albumId));
         } else {
             $this->redirect($this->createUrl("/account/login"));
         }
     }
     if (isset($favourite) && $favourite == 1) {
         if (!empty($phone)) {
             $res = WapFavouriteAlbumModel::model()->favouriteAlbum($phone, $albumId);
         } else {
             $this->redirect($this->createUrl("/account/login"));
         }
     }
     $like = null;
     if ($phone) {
         $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone));
     }
     $userType = "GUEST";
     $phone = Yii::app()->user->getState('phone');
     if ($phone) {
         $userType = "MEMBER";
     }
     $userSub = Yii::app()->user->getState('userSub');
     $packageCode = Yii::app()->user->getState('packageCode');
     if ($userSub) {
         $userType = "SUB_" . $packageCode;
     }
     $perLimit = ContentLimitModel::getPermision($albumId, "album", $userType, "WAP");
     ///meta tag
     $AlbumDetail = AlbumModel::model()->findByPk($albumId);
     $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
     $ArtistInfo = ArtistModel::model()->findByPk($artistId);
     $this->itemName = $AlbumDetail->name;
     $this->artist = $ArtistInfo->name;
     $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
     $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
     $this->description = strip_tags($AlbumDetail->description);
     $this->render('view', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'albumsSameArtist' => $albumsSameArtist, 'albumPages' => $albumPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'like' => $like, 'perLimit' => $perLimit, 'deactive' => $deactive));
 }
 public function actionView()
 {
     $id = (int) Yii::app()->request->getParam('id', 0);
     $playUrl = Yii::app()->request->getParam('url', null);
     $video = WapVideoModel::model()->available()->findByPk($id);
     $deactive = false;
     if (!$video || $video->status == VideoModel::DELETED) {
         $this->forward("/site/error", true);
     } else {
         if ($video->status == VideoModel::DEACTIVE) {
             $deactive = true;
         }
     }
     $genreId = $video->genre_id;
     $artistId = VideoArtistModel::model()->getArtistByVideo($video->id, 'id');
     $genreId = isset($genreId[0]) ? $genreId[0] : 0;
     $artistId = isset($artistId[0]) ? $artistId[0] : 0;
     $count = WapVideoModel::model()->countVideosSameArtist($id, $artistId);
     $pager = new CPagination($count);
     $pager->setPageSize(Yii::app()->params['numberPerPage']);
     $videoSameArtist = WapVideoModel::model()->getVideosSameArtist($id, $artistId, $pager->getOffset(), $pager->getLimit());
     $callBackLink = Yii::app()->createUrl("video/loadAjax", array('s' => 'artist', 'artist_id' => $artistId));
     //--- Check quyền nghe bài hát này
     $userType = "GUEST";
     if (Yii::app()->user->getState('msisdn')) {
         $userType = "MEMBER";
     }
     if (!empty($this->userSub)) {
         if (isset($this->userSub->package) && !empty($this->userSub->package)) {
             $package = $this->userSub->package->code;
         }
         $package = strtoupper($package);
         $userType = "SUB_" . $package;
     }
     $per = ContentLimitModel::getPermision($video->id, "video", $userType, "WAP");
     //---End check quyền nghe bài hát này
     // check like
     $like = null;
     $favourite = Yii::app()->request->getParam('favourite', null);
     $user_id = Yii::app()->user->id;
     $phone = yii::app()->user->getState('msisdn');
     $back_url = Yii::app()->params['base_url'] . Yii::app()->createUrl('video/view', array('id' => $id, 'url_key' => Common::makeFriendlyUrl($video->name)));
     if (isset($favourite) && $favourite == 1) {
         //yeu thich video
         if (!empty($user_id)) {
             $fav = WapFavouriteVideoModel::model()->favouriteVideo($id, $phone);
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     } elseif (isset($favourite) && $favourite == 0) {
         if (!empty($user_id)) {
             $res = WapFavouriteVideoModel::model()->deleteAllByAttributes(array('msisdn' => $phone, 'video_id' => $id));
         } else {
             $this->redirect($this->createUrl("/account/login", array('back_url' => $back_url)));
         }
     }
     if ($phone) {
         $like = WapFavouriteVideoModel::model()->findByAttributes(array('video_id' => $video->id, 'msisdn' => $phone));
     }
     //meta data
     $this->itemName = $video->name;
     $this->artist = $video->artist_name;
     $this->thumb = VideoModel::model()->getAvatarUrl($video->id, 's1');
     $this->lyric = "";
     $videourl = URLHelper::buildFriendlyURL("video/view", $video->id, Common::makeFriendlyUrl($video->name));
     $this->url = $videourl;
     $this->render('view', compact('video', 'genreId', 'artistId', 'videoSameArtist', 'pager', 'callBackLink', 'like', 'collectionCode', 'per', 'playUrl', 'deactive'));
 }