Exemple #1
0
    $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($topContent->content_id, "album", $userType, "WAP");
    $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($topContent->content_id);
    $like = null;
    if ($phone) {
        $userId = WapUserModel::model()->findByAttributes(array('phone' => $phone))->id;
        $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;
    }
 public function actionDislike()
 {
     $this->layout = false;
     $type = htmlspecialchars(Yii::app()->request->getparam('type', 'song'));
     $id = (int) Yii::app()->request->getparam('id', 0);
     $phone = Formatter::formatPhone(Yii::app()->user->getState('msisdn'));
     if (empty($phone)) {
         echo 'phone_not_detect';
         Yii::app()->end();
     }
     $criteria = new CDbCriteria();
     $criteria->condition = "phone=:phone";
     $criteria->params = array(':phone' => $phone);
     switch ($type) {
         case 'video':
             $videoModelDel = WapFavouriteVideoModel::model()->deleteAll("video_id={$id} AND msisdn={$phone}");
             if ($videoModelDel) {
                 echo 'deleted success';
             } else {
                 echo 'deleted fail';
             }
             break;
         case 'videoPlaylist':
             $videoModelDel = FavouriteVideoPlaylistModel::model()->deleteAll("video_playlist_id={$id} AND msisdn={$phone}");
             if ($videoModelDel) {
                 echo 'deleted success';
             } else {
                 echo 'deleted fail';
             }
             break;
         case 'album':
             $albumModelDel = FavouriteAlbumModel::model()->deleteAll("album_id={$id} AND msisdn={$phone}");
             if ($albumModelDel) {
                 echo 'deleted success';
             } else {
                 echo 'deleted fail';
             }
             break;
         default:
             //song
             $songModelDel = WapFavouriteSongModel::model()->deleteAll("song_id={$id} AND msisdn={$phone}");
             if ($songModelDel) {
                 echo 'deleted success';
             } else {
                 echo 'deleted fail';
             }
             break;
     }
     Yii::app()->end();
 }
 /**
  * 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));
 }