Skip to content

Commit

Permalink
filter to allow users to filter movies by ratings
Browse files Browse the repository at this point in the history
Now you can sort categories
  • Loading branch information
daniel authored and daniel committed Jan 29, 2020
1 parent 3d1c2ed commit e68fc94
Show file tree
Hide file tree
Showing 25 changed files with 751 additions and 730 deletions.
2 changes: 2 additions & 0 deletions install/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ CREATE TABLE IF NOT EXISTS `categories` (
`users_id` INT(11) NOT NULL DEFAULT 1,
`private` TINYINT(1) NULL DEFAULT 0,
`allow_download` TINYINT(1) NULL DEFAULT 1,
`order` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_categories_users1_idx` (`users_id` ASC),
INDEX `clean_name_INDEX2` (`clean_name` ASC),
INDEX `sortcategoryOrderIndex` (`order` ASC),
UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC),
CONSTRAINT `fk_categories_users1`
FOREIGN KEY (`users_id`)
Expand Down
2 changes: 1 addition & 1 deletion objects/ajaxErrorCatcher.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
ini_set('error_log', '../videos/avideo.js.log');
if(!empty($_GET['error'])){
_error_log("[aEC] ".$_GET['error']);
error_log("[aEC] ".$_GET['error']);
}

?>
3 changes: 3 additions & 0 deletions objects/bootGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ static function getSqlFromPost($searchFieldsNames = array(), $keyPrefix = "", $a
$direction = "DESC";
}
$key = preg_replace("/[^A-Za-z0-9._ ]/", '', $key);
if($key=='order'){
$key = '`order`';
}
$orderBy[] = " {$keyPrefix}{$key} {$direction} ";
}
$sql .= " ORDER BY ".implode(",", $orderBy);
Expand Down
29 changes: 19 additions & 10 deletions objects/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ class Category {
private $users_id;
private $private;
private $allow_download;
private $order;

function getOrder() {
return intval($this->order);
}

function setOrder($order) {
$this->order = intval($order);
}

function getUsers_id() {
if (empty($this->users_id)) {
$this->users_id == User::getId();
Expand Down Expand Up @@ -158,9 +167,9 @@ function save($allowOfflineUser = false) {
. "parentId = ?,"
. "iconClass = ?,"
. "users_id = ?,"
. "`private` = ?, allow_download = ?, modified = now() WHERE id = ?";
$format = "sssiisiiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->id);
. "`private` = ?, allow_download = ?, `order` = ?, modified = now() WHERE id = ?";
$format = "sssiisiiiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder(), $this->id);
} else {
$sql = "INSERT INTO categories ( "
. "name,"
Expand All @@ -170,9 +179,9 @@ function save($allowOfflineUser = false) {
. "parentId,"
. "iconClass, "
. "users_id, "
. "`private`, allow_download, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,now(), now())";
$format = "sssiisiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download());
. "`private`, allow_download, `order`, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,?,now(), now())";
$format = "sssiisiiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder());
}

$insert_row = sqlDAL::writeSql($sql, $format, $values);
Expand Down Expand Up @@ -325,7 +334,7 @@ static function getSiteCategoryDefaultID() {

static function getAllCategories($filterCanAddVideoOnly = false) {
global $global, $config;
if ($config->currentVersionLowerThen('5.01')) {
if ($config->currentVersionLowerThen('8.4')) {
return false;
}
$sql = "SELECT * FROM categories WHERE 1=1 ";
Expand All @@ -346,7 +355,7 @@ static function getAllCategories($filterCanAddVideoOnly = false) {
if (isset($_POST['sort']['title'])) {
unset($_POST['sort']['title']);
}
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY name ASC ");
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC ");
$res = sqlDAL::readSql($sql);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
Expand Down Expand Up @@ -455,7 +464,7 @@ static function canCreateCategory() {

static function getChildCategories($parentId, $filterCanAddVideoOnly = false) {
global $global, $config;
if ($config->currentVersionLowerThen('5.01')) {
if ($config->currentVersionLowerThen('8.4')) {
return false;
}
$sql = "SELECT * FROM categories WHERE parentId=? AND id!=? ";
Expand All @@ -470,7 +479,7 @@ static function getChildCategories($parentId, $filterCanAddVideoOnly = false) {
$sql .= " AND (private=0 OR users_id = '{$users_id}') ";
}
}
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY name ASC ");
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC ");
$res = sqlDAL::readSql($sql, "ii", array($parentId, $parentId));
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
Expand Down
1 change: 1 addition & 0 deletions objects/categoryAddNew.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$obj->setParentId($_POST['parentId']);
$obj->setPrivate($_POST['private']);
$obj->setAllow_download($_POST['allow_download']);
$obj->setOrder($_POST['order']);



Expand Down
2 changes: 1 addition & 1 deletion objects/include_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$global['webSiteRootURL'] .= (substr($global['webSiteRootURL'], -1) == '/' ? '' : '/');
$global['systemRootPath'] .= (substr($global['systemRootPath'], -1) == '/' ? '' : '/');

session_name(preg_replace( '/[\W]/', '', $global['webSiteRootURL']));
ini_set('error_log', $global['systemRootPath'] . 'videos/avideo.log');
global $global, $config, $advancedCustom, $advancedCustomUser;

Expand Down
90 changes: 49 additions & 41 deletions objects/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,15 @@ function getSites_id() {
function setSites_id($sites_id) {
$this->sites_id = $sites_id;
}

function getVideo_password() {
return $this->video_password;
return trim($this->video_password);
}

function setVideo_password($video_password) {
$this->video_password = $video_password;
$this->video_password = trim($video_password);
}


function save($updateVideoGroups = false, $allowOfflineUser = false) {
global $advancedCustom;
global $global;
Expand Down Expand Up @@ -525,7 +524,7 @@ function setStatus($status) {
}

function setType($type) {
if(empty($this->type)){
if (empty($this->type)) {
$this->type = $type;
}
}
Expand Down Expand Up @@ -754,7 +753,7 @@ static function getVideoFromFileName($fileName, $ignoreGroup = false, $ignoreTag
return false;
}
$parts = explode("/", $fileName);
if(!empty($parts[0])){
if (!empty($parts[0])) {
$fileName = $parts[0];
}
$sql = "SELECT id FROM videos WHERE filename = ? LIMIT 1";
Expand Down Expand Up @@ -954,10 +953,10 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
foreach ($fullData as $row) {
unset($row['password']);
unset($row['recoverPass']);
if(!self::canEdit($row['id'])){
if(!empty($row['video_password'])){
if (!self::canEdit($row['id'])) {
if (!empty($row['video_password'])) {
$row['video_password'] = 1;
}else{
} else {
$row['video_password'] = 0;
}
}
Expand Down Expand Up @@ -995,7 +994,7 @@ static function getAllVideosAsync($status = "viewable", $showOnlyLoggedUserVideo
$get = json_encode(@$_GET);
$post = json_encode(@$_POST);
$md5 = md5("{$users_id}{$get}{$post}{$status}{$showOnlyLoggedUserVideos}{$ignoreGroup}" . implode("_", $videosArrayId) . "{$getStatistcs}{$showUnlisted}{$activeUsersOnly}");
$path = getCacheDir()."getAllVideosAsync/";
$path = getCacheDir() . "getAllVideosAsync/";
make_path($path);
$cacheFileName = "{$path}{$md5}";
if (empty($advancedCustom->AsyncJobs) || !file_exists($cacheFileName) || filesize($cacheFileName) === 0) {
Expand Down Expand Up @@ -1173,7 +1172,7 @@ static function getTotalVideosInfo($status = "viewable", $showOnlyLoggedUserVide

static function getTotalVideosInfoAsync($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false) {
global $global, $advancedCustom;
$path = getCacheDir()."getTotalVideosInfo/";
$path = getCacheDir() . "getTotalVideosInfo/";
make_path($path);
$cacheFileName = "{$path}_{$status}_{$showOnlyLoggedUserVideos}_{$ignoreGroup}_" . implode($videosArrayId) . "_{$getStatistcs}";
$return = array();
Expand Down Expand Up @@ -1688,24 +1687,33 @@ static function getTags($video_id, $type = "") {
} else {
$tags = self::getTagsAsync($video_id, $type);
foreach ($tags as $key => $value) {
if(is_array($value)){
$tags[$key] = (object)$value;
if (is_array($value)) {
$tags[$key] = (object) $value;
}
}
return $tags;
}
}

static function getTags_($video_id, $type = "") {
global $advancedCustom;
global $advancedCustom, $advancedCustomUser;
$video = new Video("", "", $video_id);
$tags = array();

if (empty($type) || $type === "paid") {
if (!empty($advancedCustom->paidOnlyShowLabels)) {
$objTag = new stdClass();
$objTag->label = __("Paid Content");
if (!empty($video->getOnly_for_paid())) {
if ($advancedCustomUser->userCanProtectVideosWithPassword && !empty($video->getVideo_password())) {
$objTag->type = "danger";
$objTag->text = '<i class="fas fa-lock" title="'.__("Password Protected").'" ></i>';
} else if (AVideoPlugin::isEnabledByName("PayPerView") && PayPerView::isVideoPayPerView($video_id)) {
$objTag->type = "warning";
$objTag->text = "PPV";
} else if (!Video::isPublic($video_id)) {
$objTag->type = "warning";
$objTag->text = __("Private");
} else if (!empty($video->getOnly_for_paid())) {
$objTag->type = "warning";
$objTag->text = $advancedCustom->paidOnlyLabel;
} else {
Expand Down Expand Up @@ -1804,7 +1812,7 @@ static function getTags_($video_id, $type = "") {
foreach ($groups as $value) {
$objTag = new stdClass();
$objTag->label = __("Group");
$objTag->type = "warning";
$objTag->type = "info";
$objTag->text = "{$value['group_name']}";
$tags[] = $objTag;
$objTag = new stdClass();
Expand Down Expand Up @@ -1860,7 +1868,7 @@ static function deleteTagsAsync($video_id) {
session_start();
}
unset($_SESSION['getVideoTags'][$video_id]);
$path = getCacheDir()."getTagsAsync/";
$path = getCacheDir() . "getTagsAsync/";
if (!is_dir($path)) {
return false;
}
Expand All @@ -1875,7 +1883,7 @@ static function deleteTagsAsync($video_id) {

static function getTagsAsync($video_id, $type = "video") {
global $global, $advancedCustom;
$path = getCacheDir()."getTagsAsync/";
$path = getCacheDir() . "getTagsAsync/";
make_path($path);
$cacheFileName = "{$path}_{$video_id}_{$type}";

Expand Down Expand Up @@ -2029,7 +2037,7 @@ static function getVideoQueryFileter() {
function getTitle() {
return $this->title;
}

function getClean_title() {
return $this->clean_title;
}
Expand Down Expand Up @@ -2367,8 +2375,8 @@ static function getPoster($videos_id) {
}

static function getImageFromFilename_($filename, $type = "video") {
$cache = ObjectYPT::getCache($filename.$type, 0);
if(!empty($cache)){
$cache = ObjectYPT::getCache($filename . $type, 0);
if (!empty($cache)) {
return $cache;
}
global $global, $advancedCustom;
Expand Down Expand Up @@ -2490,16 +2498,16 @@ static function getImageFromFilename_($filename, $type = "video") {
if (!empty($advancedCustom->disableAnimatedGif)) {
$obj->thumbsGif = false;
}
ObjectYPT::setCache($filename.$type, $obj);

ObjectYPT::setCache($filename . $type, $obj);

return $obj;
}

static function getImageFromFilenameAsync($filename, $type = "video") {
global $global, $advancedCustom;
$return = array();
$path = getCacheDir()."getImageFromFilenameAsync/";
$path = getCacheDir() . "getImageFromFilenameAsync/";
make_path($path);
$cacheFileName = "{$path}_{$filename}_{$type}";
if (empty($advancedCustom->AsyncJobs) || !file_exists($cacheFileName)) {
Expand Down Expand Up @@ -2569,14 +2577,14 @@ static function get_id_from_clean_title($clean_title) {
return false;
}

function getChannelName(){
function getChannelName() {
return User::_getChannelName($this->getUsers_id());
}
function getChannelLink(){

function getChannelLink() {
return User::getChannelLink($this->getUsers_id());
}

/**
*
* @global type $global
Expand All @@ -2587,16 +2595,16 @@ function getChannelLink(){
* @return String a web link
*/
static function getLinkToVideo($videos_id, $clean_title = "", $embed = false, $type = "URLFriendly", $get = array()) {
global $global, $advancedCustomUser;
global $global, $advancedCustomUser;
if (empty($videos_id) && !empty($clean_title)) {
$videos_id = self::get_id_from_clean_title($clean_title);
}
$video = new Video("", "", $videos_id);
if($advancedCustomUser->addChannelNameOnLinks){

if ($advancedCustomUser->addChannelNameOnLinks) {
$get['channelName'] = $video->getChannelName();
}

unset($get['v']);
unset($get['videoName']);
unset($get['videoName']);
Expand All @@ -2608,7 +2616,7 @@ static function getLinkToVideo($videos_id, $clean_title = "", $embed = false, $t
} else {
$get_http = "?{$get_http}";
}

if ($type == "URLFriendly") {
$cat = "";
if (!empty($_GET['catName'])) {
Expand All @@ -2618,7 +2626,7 @@ static function getLinkToVideo($videos_id, $clean_title = "", $embed = false, $t
if (empty($clean_title)) {
$clean_title = $video->getClean_title();
}

if ($embed) {
//return "{$global['webSiteRootURL']}videoEmbed/{$clean_title}{$get_http}";
return "{$global['webSiteRootURL']}videoEmbed/{$videos_id}/{$clean_title}{$get_http}";
Expand Down Expand Up @@ -2732,9 +2740,9 @@ static function deleteThumbs($filename) {
}
}
ObjectYPT::deleteCache($filename);
ObjectYPT::deleteCache($filename."article");
ObjectYPT::deleteCache($filename."pdf");
ObjectYPT::deleteCache($filename."video");
ObjectYPT::deleteCache($filename . "article");
ObjectYPT::deleteCache($filename . "pdf");
ObjectYPT::deleteCache($filename . "video");
clearVideosURL($filename);
}

Expand Down Expand Up @@ -2848,11 +2856,11 @@ static function userGroupAndVideoGroupMatch($users_id, $videos_id) {
if (empty($rows)) {
return true;
}

if (empty($users_id) || empty($videos_id)) {
return false;
}

$rowsUser = UserGroups::getUserGroups(User::getId());
if (empty($rowsUser)) {
return false;
Expand Down Expand Up @@ -2889,7 +2897,7 @@ function getSerie_playlists_id() {
function setSerie_playlists_id($serie_playlists_id) {
$this->serie_playlists_id = $serie_playlists_id;
}

static function getVideoFromSeriePlayListsId($serie_playlists_id) {
global $global, $config;
$serie_playlists_id = intval($serie_playlists_id);
Expand Down
Loading

0 comments on commit e68fc94

Please sign in to comment.