mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Improve the get links
This commit is contained in:
parent
2e3961cc6d
commit
ae65a2aac6
2 changed files with 50 additions and 1 deletions
|
@ -716,8 +716,57 @@ if (!class_exists('Video')) {
|
||||||
return $videos;
|
return $videos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as getAllVideos() method but a lighter query
|
||||||
|
* @global type $global
|
||||||
|
* @global type $config
|
||||||
|
* @param type $showOnlyLoggedUserVideos
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
static function getAllVideosLight($status = "viewable", $showOnlyLoggedUserVideos = false, $showUnlisted = false) {
|
||||||
|
global $global, $config;
|
||||||
|
if ($config->currentVersionLowerThen('5')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$sql = "SELECT v.* "
|
||||||
|
. " FROM videos as v "
|
||||||
|
. " WHERE 1=1 ";
|
||||||
|
|
||||||
|
if ($showOnlyLoggedUserVideos === true && !User::isAdmin()) {
|
||||||
|
$sql .= " AND v.users_id = '" . User::getId() . "'";
|
||||||
|
} elseif (!empty($showOnlyLoggedUserVideos)) {
|
||||||
|
$sql .= " AND v.users_id = '{$showOnlyLoggedUserVideos}'";
|
||||||
|
}
|
||||||
|
if ($status == "viewable") {
|
||||||
|
if(User::isLogged()){
|
||||||
|
$sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') OR (v.status='u' AND v.users_id ='".User::getId()."'))";
|
||||||
|
}else{
|
||||||
|
$sql .= " AND v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')";
|
||||||
|
}
|
||||||
|
} elseif (!empty($status)) {
|
||||||
|
$sql .= " AND v.status = '{$status}'";
|
||||||
|
}
|
||||||
|
$res = sqlDAL::readSql($sql);
|
||||||
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
|
sqlDAL::close($res);
|
||||||
|
$videos = array();
|
||||||
|
if ($res!=false) {
|
||||||
|
foreach ($fullData as $row) {
|
||||||
|
$videos[] = $row;
|
||||||
|
}
|
||||||
|
//$videos = $res->fetch_all(MYSQLI_ASSOC);
|
||||||
|
} else {
|
||||||
|
$videos = false;
|
||||||
|
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
|
||||||
|
}
|
||||||
|
return $videos;
|
||||||
|
}
|
||||||
|
|
||||||
static function getTotalVideos($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $showUnlisted = false) {
|
static function getTotalVideos($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $showUnlisted = false) {
|
||||||
global $global;
|
global $global;
|
||||||
|
if ($config->currentVersionLowerThen('5')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$cn = "";
|
$cn = "";
|
||||||
if (!empty($_GET['catName'])) {
|
if (!empty($_GET['catName'])) {
|
||||||
$cn .= ", c.clean_name as cn";
|
$cn .= ", c.clean_name as cn";
|
||||||
|
|
|
@ -11,7 +11,7 @@ $showOnlyLoggedUserVideos = true;
|
||||||
if (User::isAdmin()) {
|
if (User::isAdmin()) {
|
||||||
$showOnlyLoggedUserVideos = false;
|
$showOnlyLoggedUserVideos = false;
|
||||||
}
|
}
|
||||||
$videos = Video::getAllVideos('', $showOnlyLoggedUserVideos, true);
|
$videos = Video::getAllVideosLight('', $showOnlyLoggedUserVideos, false);
|
||||||
foreach ($videos as $key => $value) {
|
foreach ($videos as $key => $value) {
|
||||||
if(empty($_GET['type'])){
|
if(empty($_GET['type'])){
|
||||||
echo Video::getPermaLink($videos[$key]['id']);
|
echo Video::getPermaLink($videos[$key]['id']);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue