/** * Function getPlaylistVideosByAjax is used to get current user playlist videos and bind it existing videos * This function has userId to hold current user id * This function has startOffset arguments to hold start offset * This function has playlistId arguments to hold playlist id * This function call getPlaylistVideoDetails method to get required set of playlist video details * This function pass userid,playlistid,startoffset and current object as parameter to getPlaylistVideoDetails method * This function call getVideoByAjax to get required json details to bind next set of videos to existing videos * This function has exit statement to stop flow * @param int $userId user id * @param int $startOffset start offset * @param int $playlistId playlist id * @return array */ public function getPlaylistVideosByAjax($userId, $startOffset, $playlistId) { global $wpdb; $result = array(); $videoResults = getPlaylistVideoDetails($userId, $playlistId, $startOffset, $this); if (empty($videoResults)) { echo json_encode(array()); exitAction(''); } $result = getVideoByAjax($videoResults, '', $this->thumbPath . 'nothumbimage.jpg', $this->ratearray); array_push($result, $this->playlistVideoCount); echo json_encode($result); exitAction(''); }
/** * Function get_watch_history_details used to get required sets of watch history video details * This function has userId to hold current user id * This function has startOffset to hold start offset * This function has totalHistoryCount to hold current user total videos count * This function has ratearray to hold video rate class to display video rate on front page * This function has videoArray to hold current user video ids list as a array * This function has videoResults to hold current user video details * This function store current offset list in session * This function return next set of videos detail as a json encoded format * This function has exit statement to stop flow * @param int $userId user id * @param int $startOffset start offset * @return string watch history video details */ public function getWatchHistoryVideoDetails($userId, $startOffset) { global $wpdb; $historyResult = array(); /** totalHistoryCount to hold current user total videos count */ $totalHistoryCount = get_watch_video_count($userId, $this->watchDetailsTable, $this->hdvideoshareTable); /** videoArray to hold current user video ids list as a array */ $videoArray = $wpdb->get_col($wpdb->prepare("SELECT vid FROM " . WVG_WATCH_HISTORY_DETAILS . " WHERE userid=%d ORDER BY date DESC", $userId)); if (!empty($videoArray)) { /** videoResults to hold current user video details */ $videoResults = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "hdflvvideoshare WHERE vid IN (" . implode(',', $videoArray) . ") ORDER BY field(vid," . implode(',', $videoArray) . ") LIMIT 10 OFFSET " . $startOffset); } $historyResult = getVideoByAjax($videoResults, '', $this->thumbPath . 'nothumbimage.jpg', $this->ratearray); $_SESSION['watchoffset'] = $_SESSION['watchoffset'] + count($videoResults); array_push($historyResult, $totalHistoryCount); echo json_encode($historyResult); exitAction(''); }