/**
 * Video Detail Page action Ends Here
 *
 * Function for adding video ends
 *
 * @param unknown $youtube_media
 * @return void|unknown
 */
function hd_getsingleyoutubevideo($youtube_media)
{
    /** Check YouTube video id is exist */
    if ($youtube_media == '') {
        /** If not then return empty */
        return;
    }
    /** Get YouTube Api key form settings */
    $setting_youtube = getPlayerColorArray();
    $youtube_api_key = $setting_youtube['youtube_key'];
    /** Check Api key is applied in settings */
    if (!empty($youtube_api_key)) {
        /** Get URL to get Youtube video details */
        $url = 'https://www.googleapis.com/youtube/v3/videos?id=' . $youtube_media . '&part=contentDetails,snippet,statistics&key=' . $youtube_api_key;
        /** Call function to get detila from the given URL */
        $video_details = hd_getyoutubepage($url);
        /** Decode json data and get details */
        $decoded_data = json_decode($video_details);
        /** return YouTube video details */
        return get_object_vars($decoded_data);
    } else {
        /** If key is not applied, then dipslya error message */
        render_error(__('Could not retrieve Youtube video information. API Key is missing', APPTHA_VGALLERY));
    }
    exitAction('');
}
function videogallery_addpages()
{
    global $wpdb;
    /** Get player color settings from db  */
    $setting_member_upload = getPlayerColorArray();
    /** Set menu icon path */
    $menuIcon = getImagesDirURL() . 'apptha.png';
    /** Define menu constant */
    defineAction('VG_MENU', 'videogallery_menu');
    /** Add menu, videos page for member user */
    if (isset($setting_member_upload['member_upload_enable']) && $setting_member_upload['member_upload_enable'] == 1) {
        add_menu_page(APPTHAVGALLERY, APPTHAVGALLERY, 'read', 'video', VG_MENU, $menuIcon);
        add_submenu_page('video', APPTHAVGALLERY, 'All Videos', 'read', 'video', VG_MENU);
        add_submenu_page('', 'New Videos', '', 'read', 'newvideo', VG_MENU);
    } else {
        /** Add menu, videos page for admin */
        add_menu_page(APPTHAVGALLERY, APPTHAVGALLERY, 'manage_options', 'video', VG_MENU, $menuIcon);
        add_submenu_page('video', APPTHAVGALLERY, 'All Videos', 'manage_options', 'video', VG_MENU);
        add_submenu_page('', 'New Videos', '', 'manage_options', 'newvideo', VG_MENU);
    }
    /** Add menu, Categories page */
    add_submenu_page('video', APPTHAVGALLERY, 'Categories', 'manage_options', 'playlist', VG_MENU);
    /** Add menu, Categories page */
    add_submenu_page('video', APPTHAVGALLERY, 'Playlist', 'manage_options', 'userplaylist', VG_MENU);
    /** Add Ajax Category page */
    add_submenu_page('', APPTHAVGALLERY, 'Ajax Category', 'manage_options', 'ajaxplaylist', VG_MENU);
    /** Add New Category page */
    add_submenu_page('', 'New Category', '', 'manage_options', 'newplaylist', VG_MENU);
    /** Add menu, Video Ads page */
    add_submenu_page('video', 'Video Ads', 'Video Ads', 'manage_options', 'videoads', VG_MENU);
    /** Add New Video Ads page */
    add_submenu_page('', 'New Videos', '', 'manage_options', 'newvideoad', VG_MENU);
    /** Add menu, Google AdSense page */
    add_submenu_page('video', 'Google AdSense', 'Google AdSense', 'manage_options', 'googleadsense', VG_MENU);
    /** Add New Google AdSense page */
    add_submenu_page('', 'New Google AdSense', 'New Google AdSense', 'manage_options', 'addgoogleadsense', VG_MENU);
    /** Add Gallery Settings page */
    add_submenu_page('video', 'GallerySettings', 'Settings', 'manage_options', 'hdflvvideosharesettings', VG_MENU);
    /** Add Video Gallery Instruction page */
    add_submenu_page('', ' Video Gallery Instruction', 'Video Gallery Instruction', 'menu_options', 'videogallery_instruction', VG_MENU);
}
 /** Function for adding video and update status / featured. */
 public function add_newvideo()
 {
     /** Variable declaration and initialization */
     $match = '';
     /** Assign youtube URL without id */
     $youtubeVideoURL = 'http://www.youtube.com/watch?v=';
     /** Check video status is exists  */
     if (isset($this->_status) || isset($this->_featured)) {
         /** Call function to update video status */
         $this->status_update($this->_videoId, $this->_status, $this->_featured);
     }
     /** Check whether to add / update video */
     if ($this->_addnewVideo) {
         /** Get video name parameters from the request */
         $videoName = filter_input(INPUT_POST, 'name');
         /** Get video description parameters from the request */
         $videoDescription = filter_input(INPUT_POST, 'description');
         /** Get embed_code parameters from the request */
         $embedcode = filter_input(INPUT_POST, 'embed_code');
         /** Get publish parameters from the request */
         $videoPublish = filter_input(INPUT_POST, 'publish');
         /** Get feature parameters from the request */
         $videoFeatured = filter_input(INPUT_POST, 'feature');
         /** Get download parameters from the request */
         $videoDownload = filter_input(INPUT_POST, 'download');
         /** Get midrollads parameters from the request */
         $videomidrollads = filter_input(INPUT_POST, 'midrollads');
         /** Get imaad parameters from the request */
         $videoimaad = filter_input(INPUT_POST, 'imaad');
         /** Get postrollads parameters from the request */
         $videoPostrollads = filter_input(INPUT_POST, 'postrollads');
         /** Get prerollads parameters from the request */
         $videoPrerollads = filter_input(INPUT_POST, 'prerollads');
         /** Get googleadsense parameters from the request */
         $google_adsense = filter_input(INPUT_POST, 'googleadsense');
         /** Get google_adsense_value parameters from the request */
         $google_adsense_value = filter_input(INPUT_POST, 'google_adsense_value');
         /**
          * Get member id from request.
          * If not get current user id
          */
         $member_id = filter_input(INPUT_POST, 'member_id');
         if (empty($member_id)) {
             $current_user = wp_get_current_user();
             $member_id = $current_user->ID;
         }
         /** Get upload video form params */
         $video1 = filter_input(INPUT_POST, 'normalvideoform-value');
         /** Get upload hd video form params */
         $video2 = filter_input(INPUT_POST, 'hdvideoform-value');
         /** Get thumb image form params */
         $img1 = filter_input(INPUT_POST, 'thumbimageform-value');
         /** Get preview image form params */
         $img2 = filter_input(INPUT_POST, 'previewimageform-value');
         /**  Get streamer path option for rtmp streaming */
         $islive = filter_input(INPUT_POST, 'islive-value');
         /**  Get is live option for rtmp streaming */
         $streamname = filter_input(INPUT_POST, 'streamerpath-value');
         /** Get Youtube video url from request */
         $videoLinkurl = filter_input(INPUT_POST, 'youtube-value');
         /** Set video duration */
         $duration = '0:00';
         /** Get video added method */
         $video_added_method = filter_input(INPUT_POST, 'filetypevalue');
         /** Get amazon bucket params */
         $amazon_buckets = filter_input(INPUT_POST, 'amazon_buckets');
         /** Check youtbe / youtu.be / dailymotion / viddler video url is exists */
         if ($videoLinkurl != '') {
             /** Attach http with video url */
             if (preg_match('#https?://#', $videoLinkurl) === 0) {
                 $videoLinkurl = 'http://' . $videoLinkurl;
             }
             /** Remove spaces in video url */
             $act_filepath = addslashes(trim($videoLinkurl));
         }
         if ($videoLinkurl != '' && $act_filepath != '') {
             /** Set file type 1 for YouTube/ viddler /dailymotion  */
             $file_type = '1';
             /** Check video url contains youtbe / youtu.be / dailymotion / viddler */
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /** Get youtube video id from plugin helper */
                 $youtubeVideoID = getYoutubeVideoID($act_filepath);
                 /** Get thumb URL for YouTube videos */
                 $act_opimage = $previewurl = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/maxresdefault.jpg';
                 /** Get preview URL for YouTube videos */
                 $act_image = $img = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/mqdefault.jpg';
                 /** Get YouTube video URL and fetch information  */
                 $act_filepath = $youtubeVideoURL . $youtubeVideoID;
                 $ydetails = hd_getsingleyoutubevideo($youtubeVideoID);
                 /** Get youTube video duration */
                 $youtube_time = $ydetails['items'][0]->contentDetails->duration;
                 if (!empty($youtube_time)) {
                     /** Convert duration into h:m:s format */
                     $di = new DateInterval($youtube_time);
                     $string = '';
                     $min = $di->i;
                     if ($di->h > 0) {
                         $string .= $di->h . ':';
                         /** Check if minutes is <= 9 while hours value is exist */
                         if ($min <= 9) {
                             $min = '0' . $min;
                         }
                     }
                     $duration = $string . $min . ':' . $di->s;
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Check video URL is dailymotion
                      * If yes, then get id from the url and get thumb, preview image */
                     $split_id = getDailymotionVideoID($act_filepath);
                     $img = $act_image = $act_opimage = $previewurl = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Check video url is viddler
                          * If yes, then get id from the url and get thumb, preview image */
                         $imgstr = explode('/', $act_filepath);
                         $img = $act_image = $act_opimage = $previewurl = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $img = '';
                     }
                 }
             }
         } else {
             /** Get video upload form value */
             $act_filepath1 = $_REQUEST['normalvideoform-value'];
             /** Combine upload directory path and file name */
             $act_filepath1 = $this->_srt_path . $act_filepath1;
             /**
              * Check whether custom url option is used
              * If yes, then get video url, thumb url and remove spaces
              * Else, set video url, thumb url as empty
              */
             $act_filepath = $act_optimage = '';
             if (isset($_POST['custom_url'])) {
                 $act_filepath = addslashes(trim($_POST['customurl']));
                 $act_optimage = addslashes(trim('thumb_' . $_POST['custom_url']));
             }
             /** Get ffmpeg settings value */
             $ffmpeg_path = $this->_settingsData->ffmpeg_path;
             /** Set file type as 2 for upload method */
             $file_type = '2';
             /** Get uploaded video duration from plugin helper using ffmpeg */
             $ffmpegResult = getVideoDuration($ffmpeg_path, $act_filepath1);
             $duration = $ffmpegResult[0];
             $matches = $ffmpegResult[1];
             if (!empty($duration)) {
                 /** Convert duration into hours:minutes format */
                 $duration_array = explode(':', $matches[1][0]);
                 $sec = ceil($duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2]);
                 $duration = $this->converttime($sec);
             }
         }
         /** If upload new image for existing video, then rename the images name */
         if ($this->_videoId) {
             $newImagePath = $this->_srt_path . $img1;
             $newPreviewImagePath = $this->_srt_path . $img2;
             $newThumbFileName = explode('_', $img1);
             $newPreviewThumbFileName = explode('_', $img2);
             /**
              * Check if added method is upload
              */
             if ($video_added_method == 2) {
                 /**
                  * Check thumb image is exst in the directory
                  * If exit then rename the new thumb image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
                 if (file_exists($newPreviewImagePath) && !empty($newPreviewThumbFileName[1])) {
                     /**
                      * Check preview image is exst in the directory
                      * If exit then rename the new preview image with the video id
                      */
                     $img2 = $this->_videoId . '_' . $newPreviewThumbFileName[1];
                     rename($newPreviewImagePath, $this->_srt_path . $img2);
                 }
             }
             /**
              * Check if video added method is embed code
              */
             if ($video_added_method == 5) {
                 $newThumbFileName = explode('_', $img1);
                 /**
                  * Check image is exst in the directory
                  * If exit then rename the new image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $img2 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
             }
         }
         /**
          * Get Amazon S3 bucket settings from database
          */
         $player_colors = getPlayerColorArray();
         /**
          * Check if bucket option is enabled and name is exist
          */
         if ($player_colors['amazonbuckets_enable'] && $player_colors['amazonbuckets_name']) {
             /**
              * Get bucket name
              */
             $s3bucket_name = $player_colors['amazonbuckets_name'];
             /**
              * Check video is exist
              * If exist then get bucket video for uploaded videos
              */
             $video1 = $this->getAmazonURLOrUploadFile($video1, $s3bucket_name);
             /** Get bucket hd video for uploaded videos */
             $video2 = $this->getAmazonURLOrUploadFile($video2, $s3bucket_name);
             /** Get bucket thumb image for uploaded videos */
             $img1 = $this->getAmazonURLOrUploadFile($img1, $s3bucket_name);
             /** Get bucket preview image for uploaded videos */
             $img2 = $this->getAmazonURLOrUploadFile($img2, $s3bucket_name);
         }
         /** Get customurl parameter */
         $act_image = addslashes(trim($_POST['customurl']));
         $act_hdpath = $act_name = $act_opimage = '';
         /** If video url is not empty then get image and preview image */
         if (!empty($act_filepath)) {
             /** Set file type 1 for YouTube, dailymotion and viddler videos */
             $file_type = '1';
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /**
                  * Get Youtube video id
                  * Based on that get video URL , image, preview image 
                  */
                 $match = getYoutubeVideoID($act_filepath);
                 $act_filepath = $youtubeVideoURL . $match;
                 /** Get thumbimage for youtube video */
                 $act_image = 'http://i3.ytimg.com/vi/' . $match . '/mqdefault.jpg';
                 /** Get previewimage for youtube video */
                 $act_opimage = 'http://i3.ytimg.com/vi/' . $match . '/maxresdefault.jpg';
                 /** Call fucntion to get YouTube video information */
                 $ydetails = hd_getsingleyoutubevideo($match);
                 if ($ydetails) {
                     if ($act_name == '') {
                         /** Get youtube video title */
                         $act_name = addslashes($ydetails['items'][0]->snippet->title);
                     }
                 } else {
                     /** Else display error for youtube videos*/
                     render_error(__('Could not retrieve Youtube video information', APPTHA_VGALLERY));
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Get dailymotion video id */
                     $split_id = getDailymotionVideoID($act_filepath);
                     /** Get dailymotion video and thumb url */
                     $act_image = $act_opimage = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Get viddler video id */
                         $imgstr = explode('/', $act_filepath);
                         /** Get viddler video thumb and preview image */
                         $act_image = $act_opimage = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $imgstr = '';
                     }
                 }
             }
         } else {
             if ($video1 != '') {
                 $act_filepath = $video1;
             }
             if ($video2 != '') {
                 $act_hdpath = $video2;
             }
             if ($img1 != '') {
                 $act_image = $img1;
             }
             if ($img2 != '') {
                 $act_opimage = $img2;
             }
         }
         /** Set filetype as 5 for embed method */
         if (!empty($embedcode)) {
             $video_added_method = $file_type = '5';
         }
         /** Get video details for URL type videos */
         if ($video_added_method == 3) {
             $act_filepath = $_POST['customurl'];
             $act_image = $_POST['customimage'];
             $act_opimage = $_POST['custompreimage'];
             $act_hdpath = $_POST['customhd'];
         }
         /** Get video details for rtmp videos */
         if (!empty($streamname)) {
             $file_type = '4';
             /** Get filepath3 from params */
             $thumb_image = filter_input(INPUT_POST, 'filepath3');
             $act_image = $thumb_image;
             $act_opimage = $thumb_image;
         }
         if ($video_added_method == 4) {
             /** Get custom url from params */
             $act_filepath = filter_input(INPUT_POST, 'customurl');
             /** Get customhd from params */
             $act_hdpath = filter_input(INPUT_POST, 'customhd');
             /** Get customimage from params */
             $act_image = filter_input(INPUT_POST, 'customimage');
             /** Get custompreimage from params */
             $act_opimage = filter_input(INPUT_POST, 'custompreimage');
         }
         /** Store video form values into single array */
         $videoData = array('name' => $videoName, 'description' => $videoDescription, 'embedcode' => $embedcode, 'file' => $act_filepath, 'file_type' => $video_added_method, 'member_id' => $member_id, 'duration' => $duration, 'hdfile' => $act_hdpath, 'streamer_path' => $streamname, 'islive' => $islive, 'image' => $act_image, 'opimage' => $act_opimage, 'link' => $videoLinkurl, 'featured' => $videoFeatured, 'download' => $videoDownload, 'postrollads' => $videoPostrollads, 'midrollads' => $videomidrollads, 'imaad' => $videoimaad, 'prerollads' => $videoPrerollads, 'publish' => $videoPublish, 'google_adsense' => $google_adsense, 'google_adsense_value' => $google_adsense_value, 'amazon_buckets' => $amazon_buckets);
         /**
          * Get current date and assign default value
          * for srt files, language and slug
          */
         //$videoData ['post_date']  = date ( 'Y-m-d H:i:s' );
         if (empty($this->_videoId)) {
             $videoData['ordering'] = getAllVideosCount();
             $videoData['slug'] = $videoData['srtfile1'] = $videoData['srtfile2'] = $videoData['subtitle_lang1'] = $videoData['subtitle_lang2'] = '';
         }
         /** Call funtion to perform add / update action */
         $this->addUpdateVideoData($videoData);
     }
 }
 /**
  * Function is used to display videos in widget
  *
  * @param unknown $args          
  * @param unknown $instance          
  */
 function widget($args, $instance)
 {
     /** Get featured widget title and set default number of videos to be shown as limit 3 */
     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
     $videowidgettype = $instance['videowidgettype'];
     $show = 3;
     /** Get "number of featured videos to be shown" from admin */
     if ($instance['show'] && absint($instance['show'])) {
         $show = $instance['show'];
     }
     if ($instance['videowidgettype']) {
         $videowidgettype = $instance['videowidgettype'];
     }
     /** Before widget functions */
     echo $args['before_widget'];
     $userId = get_current_user_id();
     $watchLaterVideoIds = getWatchLaterVideoIds($userId, $this->watchDetailsTable);
     /** Get video order from settings data
      * Switch condition for each widget */
     switch ($videowidgettype) {
         /** Case featured video widget */
         case 'featured':
             $player_color = getPlayerColorArray();
             $recent_video_order = $player_color['recentvideo_order'];
             /** Get order to fetch featured videos */
             $thumImageorder = getVideoOrder($recent_video_order);
             $features = getWidgetVideos('feature', $thumImageorder, $show, '', '');
             /** Display featured videos */
             echo displayWidgetVideos($title, 'featured', $features, $show, '', '', $watchLaterVideoIds);
             echo $args['after_widget'];
             break;
             /** Case popular video widget */
         /** Case popular video widget */
         case 'popular':
             $thumImageorder = ' w.hitcount DESC ';
             /** Get popular videos from db */
             $populars = getWidgetVideos('popular', $thumImageorder, $show, '', '');
             /** Display popular videos */
             $output = displayWidgetVideos($title, 'popular', $populars, $show, '', '', $watchLaterVideoIds);
             /** echo popular widget closing tag */
             echo $output . $args['after_widget'];
             break;
             /** Case Watch History video widget */
         /** Case Watch History video widget */
         case 'watchhistory':
             /** Get watch history from db */
             $watchHistory = $this->getWatchHistoryVideos($show);
             /** Display watch history videos */
             $output = displayWidgetVideos($title, 'watch history', $watchHistory, $show, '', '', $watchLaterVideoIds);
             /** echo watch history widget closing tag */
             echo $output . $args['after_widget'];
             break;
             /** Case Watch Later video widget */
         /** Case Watch Later video widget */
         case 'watchlater':
             /** Get watch later from db */
             $watchLater = $this->getWatchLaterVideos($show);
             /** Display watch later videos */
             $output = displayWidgetVideos($title, 'watch later', $watchLater, $show, '', '', $watchLaterVideoIds);
             /** echo watch later widget closing tag */
             echo $output . $args['after_widget'];
             break;
             /** Case random video widget */
         /** Case random video widget */
         case 'random':
             $thumImageorder = ' RAND() ';
             $posts = getWidgetVideos('random', $thumImageorder, $show, '', '');
             /** Display random videos */
             $output = displayWidgetVideos($title, 'random', $posts, $show, '', '', $watchLaterVideoIds);
             /** echo random videos widget opening, closing tag */
             echo $output . $args['after_widget'];
             break;
             /** Case recent video widget */
         /** Case recent video widget */
         case 'recent':
             $thumImageorder = ' w.vid DESC ';
             $posts = getWidgetVideos('recent', $thumImageorder, $show, '', '');
             /** Display recent videos */
             echo displayWidgetVideos($title, 'recent', $posts, $show, '', '', $watchLaterVideoIds);
             echo $args['after_widget'];
             break;
             /** Case recent video widget */
         /** Case recent video widget */
         case 'related':
             /** Function call for related videos
              * Show and title params are send for helper */
             $this->related($show, $title);
             /** Related videos widget ends here */
             /** After widget functions */
             echo $args['after_widget'];
             break;
         default:
             break;
     }
 }
Exemple #5
0
/**
 * Function to get related videos count from settings
 * 
 * @return object
 */
function get_related_video_count()
{
    /** Get player color */
    $playerColors = getPlayerColorArray();
    /** Return relate video count */
    return $playerColors['related_video_count'];
}
Exemple #6
0
 /**
  * Function to get search video results
  *
  * @param unknown $searchValue
  * @param unknown $searchBtn
  * @param unknown $order
  * @param unknown $orderDirection
  */
 public function get_videodata($searchValue, $searchBtn, $order, $orderDirection)
 {
     global $wpdb;
     /** Get current user role and current user
      * Get player color settings and user allowed method */
     $current_user = wp_get_current_user();
     $userDetails = get_user_by('id', $current_user->ID);
     if (isset($userDetails->roles)) {
         $user_role = $userDetails->roles[0];
     }
     $player_colors = getPlayerColorArray();
     $user_allowed_method = explode(',', $player_colors['user_allowed_method']);
     /** Get file types and check whether the method is enabled in user upload option */
     $fileType = '';
     /** Get file type for YouTube action */
     $fileType .= $this->getfileTypes($fileType, 'c', $user_allowed_method, '1');
     /** Get file type for upload action */
     $fileType .= $this->getfileTypes($fileType, 'y', $user_allowed_method, '2');
     /** Get file type for embed action */
     $fileType .= $this->getfileTypes($fileType, 'embed', $user_allowed_method, '5');
     /** Get file type for URL action */
     $fileType .= $this->getfileTypes($fileType, 'url', $user_allowed_method, '3');
     /** Get file type for rtmp action */
     $fileType .= $this->getfileTypes($fileType, 'rmtp', $user_allowed_method, '4');
     /** Get page number and filter option values
      * Set query to select video id */
     $pagenum = absint(filter_input(INPUT_GET, 'pagenum'));
     if (empty($pagenum)) {
         $pagenum = 1;
     }
     $orderFilterlimit = filter_input(INPUT_GET, 'filter');
     $query = 'SELECT DISTINCT ( a.vid ) FROM ' . $this->_videotable . ' a  LEFT JOIN ' . $wpdb->users . ' u ON u.ID=a.member_id  LEFT JOIN ' . $this->_wpdb->prefix . 'hdflvvideoshare_med2play p  ON p.media_id=a.vid LEFT JOIN ' . $this->_wpdb->prefix . 'hdflvvideoshare_playlist pl ON pl.pid=p.playlist_id WHERE pl.is_publish=1';
     /** If search action is done set condition based on name , description
      * Check user role is admin. If not check member id and filetype  */
     if (isset($searchBtn)) {
         $query .= ' AND ( a.name LIKE %s OR a.description LIKE %s )';
     }
     if ($user_role != 'administrator') {
         $query .= ' AND a.member_id=%d AND a.file_type IN(' . $fileType . ')';
     }
     /** Set order by values based on direction */
     if (!isset($orderDirection)) {
         $query .= ' ORDER BY ' . $order . ' DESC';
     } else {
         $query .= ' ORDER BY ' . $order . ' ' . $orderDirection;
     }
     /** Set query based on search values and user role */
     if (isset($searchBtn) && $user_role != 'administrator') {
         $query = $this->_wpdb->prepare($query, '%' . $searchValue . '%', '%' . $searchValue . '%', $current_user->ID);
     } else {
         if ($user_role != 'administrator' && !isset($searchBtn)) {
             $query = $this->_wpdb->prepare($query, $current_user->ID);
         } else {
             if (isset($searchBtn)) {
                 $query = $this->_wpdb->prepare($query, '%' . $searchValue . '%', '%' . $searchValue . '%');
             } else {
                 $query = $query;
             }
         }
     }
     /** Get results to display in all videos section and check filter limit. 
      * If it is not set then display 20 values as default  */
     $total = count($this->_wpdb->get_results($query));
     if (!empty($orderFilterlimit) && $orderFilterlimit !== 'all') {
         $limit = $orderFilterlimit;
     } else {
         if ($orderFilterlimit === 'all') {
             $limit = $total;
         } else {
             $limit = 20;
         }
     }
     $offset = ($pagenum - 1) * $limit;
     /** Get user name with video details to display */
     $sqlQuery = 'SELECT DISTINCT ( a.vid ),a.*,u.display_name FROM ' . $this->_videotable . ' a  LEFT JOIN ' . $wpdb->users . ' u ON u.ID=a.member_id LEFT JOIN ' . $this->_wpdb->prefix . 'hdflvvideoshare_med2play p ON p.media_id=a.vid LEFT JOIN ' . $this->_wpdb->prefix . 'hdflvvideoshare_playlist pl ON pl.pid=p.playlist_id WHERE pl.is_publish=1 ';
     if (isset($searchBtn)) {
         $sqlQuery .= ' AND ( a.name LIKE %s OR a.description LIKE %s )';
     }
     if ($user_role != 'administrator') {
         $sqlQuery .= ' AND a.member_id =%d AND a.file_type IN(' . $fileType . ')';
     }
     if (!isset($orderDirection)) {
         $sqlQuery .= ' ORDER BY ' . $order . ' DESC';
     } else {
         $sqlQuery .= ' ORDER BY ' . $order . ' ' . $orderDirection;
     }
     /** Get the limit to show */
     $sqlQuery .= ' LIMIT ' . $offset . ', ' . $limit;
     /** Search results if not administrator */
     if (isset($searchBtn) && $user_role != 'administrator') {
         $sqlQuery = $this->_wpdb->prepare($sqlQuery, '%' . $searchValue . '%', '%' . $searchValue . '%', $current_user->ID);
     } else {
         if ($user_role != 'administrator' && !isset($searchBtn)) {
             $sqlQuery = $this->_wpdb->prepare($sqlQuery, $current_user->ID);
         } else {
             if (isset($searchBtn)) {
                 $sqlQuery = $this->_wpdb->prepare($sqlQuery, '%' . $searchValue . '%', '%' . $searchValue . '%');
             } else {
                 $sqlQuery = $sqlQuery;
             }
         }
     }
     return $this->_wpdb->get_results($sqlQuery);
 }