1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00
DanieL 2022-10-03 10:46:59 -03:00
parent 5ac8883fb5
commit b2cc0a89a2
25 changed files with 584 additions and 369 deletions

View file

@ -517,6 +517,7 @@ Allow: .css";
}
public static function saveVideosAddNew($post, $videos_id) {
self::setDoNotShowAdsOnChannel($videos_id, !_empty($post['doNotShowAdsOnThisChannel']));
self::setDoNotShowAds($videos_id, !_empty($post['doNotShowAdsOnThisVideo']));
self::setRedirectVideo($videos_id, @$post['redirectVideoCode'], @$post['redirectVideoURL']);
self::setShortSummaryAndMetaDescriptionVideo($videos_id,@$post['ShortSummary'], @$post['MetaDescription']);
@ -532,6 +533,19 @@ Allow: .css";
$video->setExternalOptions(json_encode($externalOptions));
return $video->save();
}
public static function setDoNotShowAdsOnChannel($videos_id, $doNotShowAdsOnThisChannel) {
if (!Permissions::canAdminVideos()) {
return false;
}
$video = new Video('', '', $videos_id);
$users_id = $video->getUsers_id();
$user = new User($users_id);
$externalOptions = object_to_array(_json_decode(User::decodeExternalOption($user->_getExternalOptions())));
$externalOptions['doNotShowAdsOnThisChannel'] = $doNotShowAdsOnThisChannel;
$user->setExternalOptions(json_encode($externalOptions));
return $user->save();
}
public static function getDoNotShowAds($videos_id): bool {
$video = new Video('', '', $videos_id);
@ -539,6 +553,14 @@ Allow: .css";
return !empty($externalOptions->doNotShowAdsOnThisVideo);
}
public static function getDoNotShowAdsChannel($videos_id): bool {
$video = new Video('', '', $videos_id);
$users_id = $video->getUsers_id();
$user = new User($users_id);
$externalOptions = object_to_array(_json_decode(User::decodeExternalOption($user->_getExternalOptions())));
return !empty($externalOptions['doNotShowAdsOnThisChannel']);
}
public static function setRedirectVideo($videos_id, $code, $url) {
if (!Permissions::canAdminVideos()) {
return false;
@ -574,7 +596,7 @@ Allow: .css";
}
public function showAds($videos_id): bool {
return !self::getDoNotShowAds($videos_id);
return !self::getDoNotShowAdsChannel($videos_id) && !self::getDoNotShowAds($videos_id);
}
}