| Current Path : /var/www/modules/mod_yendifvideoshare_player/ |
| Current File : /var/www/modules/mod_yendifvideoshare_player/helper.php |
<?php
/**
* @version 1.2.9
* @package Com_YendifVideoShare
* @author PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
* @copyright Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Prevent direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class YendifVideoSharePlayerHelper {
public static function getVideo( $params, $check_publishing_options ) {
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__yendifvideoshare_videos WHERE published=1';
$catid = (int) $params->get( 'catid', 0 );
if ( $catid > 0 ) {
$query .= ' AND catid = ' . $catid;
}
if ( $check_publishing_options ) {
$date = JFactory::getDate();
$nowDate = $db->quote( $date->toSql() );
$nullDate = $db->quote( $db->getNullDate() );
$query .= " AND ( published_up = " . $nullDate . " OR published_up <= " . $nowDate . ' )';
$query .= " AND ( published_down = " . $nullDate . " OR published_down >= " . $nowDate . ' )';
}
switch ( $params->get( 'videoid' ) ) {
case 'latest':
$query .= ' ORDER BY created_date DESC';
break;
case 'random':
$query .= ' ORDER BY RAND()';
break;
default:
$query .= ' AND id=' . (int) $params->get( 'videoid' );
}
$query .= ' LIMIT 1';
$db->setQuery( $query );
$item = $db->loadObject();
return $item;
}
}