/** * Function displayView load the watch history default template file * @return void */ public function displayView() { global $frontViewPath; $userId = get_current_user_id(); $model = $this; $this->videoDetails = get_watch_video_details($userId, $this->watchDetailsTable, $this->hdvideoshareTable); $this->watchHistoryStatus = $model->get_watch_history_status($userId); $this->watchHistoryCount = get_watch_video_count($userId, $this->watchDetailsTable, $this->hdvideoshareTable); $this->showTemplate(); }
/** * 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(''); }