Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Dec 16, 2024
1 parent 59ae783 commit b613240
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 48 deletions.
47 changes: 22 additions & 25 deletions objects/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWit

if (!empty($_REQUEST['doNotShowCats'])) {
$doNotShowCats = $_REQUEST['doNotShowCats'];
if(!is_array($_REQUEST['doNotShowCats'])){
if (!is_array($_REQUEST['doNotShowCats'])) {
$doNotShowCats = array($_REQUEST['doNotShowCats']);
}
foreach ($doNotShowCats as $key => $value) {
$doNotShowCats[$key] = str_replace("'", '', $value);
}
$sql .= " AND (c.clean_name NOT IN ('".implode("', '", $doNotShowCats)."') )";
$sql .= " AND (c.clean_name NOT IN ('" . implode("', '", $doNotShowCats) . "') )";
}

if ($filterCanAddVideoOnly && !User::isAdmin()) {
Expand All @@ -403,8 +403,8 @@ public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWit
}

if ($onlyWithVideos) {
$sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if(isForKidsSet()){
$sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if (isForKidsSet()) {
$sql .= " AND v.made_for_kids = 1 ";
}
$sql .= " AND v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id AND id != c.id)) > 0 ";
Expand All @@ -425,7 +425,7 @@ public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWit
}
$sql .= ")";
}

if ($sameUserGroupAsMe) {
//_error_log('getAllCategories getUserGroups');
$users_groups = UserGroups::getUserGroups($sameUserGroupAsMe);
Expand Down Expand Up @@ -453,9 +453,9 @@ public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWit
}

$sql .= BootGrid::getSqlFromPost(['name'], "", " ORDER BY `order`, name ASC ");
if(!empty($_GET['debug'])){
if (!empty($_GET['debug'])) {
//echo $sql;exit;
}
}

$timeLogName = TimeLogStart("getAllCategories");
$cacheSuffix = md5($sql);
Expand Down Expand Up @@ -674,10 +674,10 @@ public static function getTotalFromCategory($categories_id, $showUnlisted = fals
{
global $global;
$cacheSuffix = "getTotalFromCategory_{$categories_id}_" . intval($showUnlisted) . intval($getAllVideos);
if(isset($global[$cacheSuffix])){
if (isset($global[$cacheSuffix])) {
return $global[$cacheSuffix];
}

$timeLogName = TimeLogStart($cacheSuffix);
$cacheHandler = new CategoryCacheHandler(0);
TimeLogEnd($timeLogName, __LINE__);
Expand Down Expand Up @@ -785,7 +785,7 @@ public static function getTotalVideosFromCategory($categories_id, $showUnlisted
$cacheHandler = new CategoryCacheHandler($categories_id);

$suffix = "totalVideos_" . intval($showUnlisted) . "_" . intval($getAllVideos);

$timeLogName = TimeLogStart($suffix);
$total = $cacheHandler->getCache($suffix);
TimeLogEnd($timeLogName, __LINE__);
Expand Down Expand Up @@ -867,38 +867,35 @@ public static function getTotalLivesFromCategory($categories_id, $showUnlisted =
$cacheHandler = new CategoryCacheHandler($categories_id);
$suffix = "totalLives_" . intval($showUnlisted);
$total = $cacheHandler->getCache($suffix);
//$renew = true;

if ($renew || (empty($total) && $total !== 0)) {
$sql = "SELECT count(id) as total FROM live_transmitions v WHERE 1=1 AND categories_id = ? ";
$sql = "
SELECT COUNT(DISTINCT v.id) AS total
FROM live_transmitions v
INNER JOIN live_transmitions_history h ON v.id = h.key
WHERE v.categories_id = ? ";

if (empty($showUnlisted)) {
$sql .= " AND public = 1 ";
$sql .= " AND v.public = 1 ";
}

//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']);

$rows = self::getChildCategories($categories_id);
foreach ($rows as $value) {
$total += self::getTotalLivesFromCategory($value['id'], $showUnlisted, $renew);
}

$cacheHandler->setCache(intval($total));
/*
AVideoPlugin::getEnd();
echo PHP_EOL.PHP_EOL.PHP_EOL.'---------'.PHP_EOL.PHP_EOL;
$total2 = $cacheHandler->getCache($suffix);
echo 'total=';
var_dump($total, $total2, $suffix);
echo PHP_EOL.PHP_EOL.PHP_EOL.'---------'.PHP_EOL.PHP_EOL;
exit;
*/
}

return intval($total);
}


public static function clearCacheCount($categories_id = 0)
{
// clear category count cache
Expand Down Expand Up @@ -965,8 +962,8 @@ public static function getTotalCategories($filterCanAddVideoOnly = false, $onlyW
$sql .= "AND parentId = 0 OR parentId = -1 ";
}
if ($onlyWithVideos) {
$sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if(isForKidsSet()){
$sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if (isForKidsSet()) {
$sql .= " AND v.made_for_kids = 1 ";
}
$sql .= " AND v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id AND id != c.id) ) > 0 ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ static function getInfo($row)
$msg[] = "<a href='{$link}' target='_blank'>{$link}</a>";
}
break;
case SocialMediaPublisher::SOCIAL_TYPE_FACEBOOK["name"]:
if (!empty($row['json']->response->VideoUploadResponse) && !empty($row['json']->response->VideoUploadResponse->id)) {
$link = "https://www.facebook.com/watch/?v=" . $row['json']->response->VideoUploadResponse->id;
$msg[] = "<a href='{$link}' target='_blank'>{$link}</a>";
}
break;
}
$row['msg'] = implode('<br>', $msg);
}
Expand Down
Loading

0 comments on commit b613240

Please sign in to comment.