From 8db8d44a9252c119e8a843ba95b2debc8ccd7f9f Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Fri, 11 Jul 2025 12:52:02 -0300 Subject: [PATCH] Refactor Video Status Constants - Updated references from Video::$status* to Video::STATUS_* for consistency across multiple files. - Ensured that all instances of video status checks and assignments utilize the new constant format. - This change improves code readability and maintainability by standardizing the way video statuses are referenced throughout the codebase. --- .../changeUnlistedToUnlistedSearchable.php | 22 +- install/deleteUselessVideos.php | 80 ++--- install/importChannel.php | 10 +- install/importSiteFromAPI.php | 20 +- install/populateForTest.php | 4 +- install/recheckEncodingFolders.php | 2 +- install/recoverFilesToVideos.php | 2 +- install/recoverOrphanFolders.php | 2 +- install/reviewBrokenVideos.php | 108 +++--- objects/aVideoEncoder.json.php | 4 +- objects/aVideoEncoderNotifyIsDone.json.php | 2 +- objects/aVideoQueueEncoder.json.php | 2 +- objects/functionTags.php | 20 +- objects/playlist.php | 2 +- objects/user.php | 4 +- objects/video.php | 313 ++++++++++-------- objects/videoAddNew.json.php | 4 +- objects/videos.json.php | 2 +- plugin/AI/AI.php | 2 +- plugin/CDN/tools/downloadAllFilesFromCDN.php | 2 +- plugin/CDN/tools/fixDummyFiles.php | 8 +- plugin/CDN/tools/fixIndexMP4.php | 2 +- plugin/CDN/tools/fixM3U8DummyFiles.php | 162 ++++----- plugin/CDN/tools/moveFilesToCDN.php | 2 +- plugin/CDN/tools/moveMissingFiles.php | 10 +- .../CustomizeAdvanced/CustomizeAdvanced.php | 16 +- plugin/MobileManager/upload.php | 4 +- plugin/PlayerSkins/epg.php | 4 +- plugin/Scheduler/Scheduler.php | 8 +- view/managerVideos_body.php | 6 +- view/mini-upload-form/upload.php | 8 +- view/modeYoutube.php | 6 +- 32 files changed, 442 insertions(+), 401 deletions(-) diff --git a/install/changeUnlistedToUnlistedSearchable.php b/install/changeUnlistedToUnlistedSearchable.php index ea9f472c0c..f337e3c262 100644 --- a/install/changeUnlistedToUnlistedSearchable.php +++ b/install/changeUnlistedToUnlistedSearchable.php @@ -1,11 +1,11 @@ - $row) { - $count++; - if(!in_array($row['status'], $arrayStatusToDelete)){ - echo "{$total}/{$count} Deleteuseless skip status={$row['status']} title={$row['title']}".PHP_EOL; - continue; - } - $v = new Video('', '', $row['id']); - if ($v->delete(true)) { - echo "{$total}/{$count} Deleteuseless deleted from status={$row['status']} title={$row['title']}".PHP_EOL; - } else { - echo "{$total}/{$count} Deleteuseless ERROR status={$row['status']} title={$row['title']}".PHP_EOL; - } - } -} \ No newline at end of file + $row) { + $count++; + if(!in_array($row['status'], $arrayStatusToDelete)){ + echo "{$total}/{$count} Deleteuseless skip status={$row['status']} title={$row['title']}".PHP_EOL; + continue; + } + $v = new Video('', '', $row['id']); + if ($v->delete(true)) { + echo "{$total}/{$count} Deleteuseless deleted from status={$row['status']} title={$row['title']}".PHP_EOL; + } else { + echo "{$total}/{$count} Deleteuseless ERROR status={$row['status']} title={$row['title']}".PHP_EOL; + } + } +} diff --git a/install/importChannel.php b/install/importChannel.php index ef6b755bdc..ce7b477f5b 100644 --- a/install/importChannel.php +++ b/install/importChannel.php @@ -93,8 +93,8 @@ $channelName = $info['channelName']; $channelURL = $info['channelURL']; echo ("importChannel: start {$siteURL} {$channelName}").PHP_EOL; - - + + $users_id = 0; while (empty($users_id)) { $_GET['searchPhrase'] = ''; @@ -161,7 +161,7 @@ while ($hasNewContent && !empty($users_id)) { $video->setUsers_id($users_id); $video->setRrating($value->rrating); $video->setExternalOptions($value->externalOptions); - $video->setStatus(Video::$statusTranfering); + $video->setStatus(Video::STATUS_TRANFERING); echo ("importChannel: Saving video").PHP_EOL; $id = $video->save(false, true); @@ -184,10 +184,10 @@ while ($hasNewContent && !empty($users_id)) { download($value->videos->mp3, $value->filename, $path); } - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); } else { echo ("importChannel: ERROR Video NOT saved").PHP_EOL; - $video->setStatus(Video::$statusBrokenMissingFiles); + $video->setStatus(Video::STATUS_BROKEN_MISSING_FILES); } $video->save(false, true); //exit; diff --git a/install/importSiteFromAPI.php b/install/importSiteFromAPI.php index ad6cfde7e3..bfe01b04d9 100644 --- a/install/importSiteFromAPI.php +++ b/install/importSiteFromAPI.php @@ -4,7 +4,7 @@ * php importSiteFromAPI.php https://yoursiteURL.com/ APISecret [users_id] [categories_id] * if does not pass users_id it will also import users * if does not pass categories id it will also import categories - * + * */ $siteURL = trim(@$argv[1]); @@ -205,7 +205,7 @@ if ($type !== 'm3u8') { //wget($value->background, "{$global['systemRootPath']}videos/userPhoto/photo{$id}.png", true); } else { _error_log("importUsers: ERROR NOT saved"); - $video->setStatus(Video::$statusBrokenMissingFiles); + $video->setStatus(Video::STATUS_BROKEN_MISSING_FILES); } //exit; } @@ -289,22 +289,22 @@ while ($hasNewContent) { $video->setDescription($value->description); $video->setUsers_id($users_id); $video->setCategories_id($categories_id); - + $path = getVideosDir() . $value->filename . DIRECTORY_SEPARATOR; $size = getDirSize($path); if ($size < 10000000) { if(empty($videos_id)){ - $video->setStatus(Video::$statusTranfering); + $video->setStatus(Video::STATUS_TRANFERING); _error_log("importVideo status: transfering ($size) " . humanFileSize($size)); }else{ if ($size > 1000000) { - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); } _error_log("importVideo status: else ($size) " . humanFileSize($size)); } } if(empty($videos_id)){ - $video->setStatus(Video::$statusTranfering); + $video->setStatus(Video::STATUS_TRANFERING); } _error_log("importVideo: Saving video"); @@ -327,16 +327,16 @@ while ($hasNewContent) { download($value->videos->mp3, $value->filename, $path); } - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); if (!empty($value->videos->m3u8)) { if ($size < 10000000) { if(empty($videos_id)){ _error_log("importVideo m3u8: {$value->videos->m3u8->url} APIURL = $APIURL ($size) " . humanFileSize($size)); sendToEncoder($id, $value->videos->m3u8->url); } - + if(empty($videos_id)){ - $video->setStatus(Video::$statusEncoding); + $video->setStatus(Video::STATUS_ENCODING); } } else { _error_log("importVideo m3u8 NOT SEND: ($size) " . humanFileSize($size)); @@ -354,7 +354,7 @@ while ($hasNewContent) { } } else { _error_log("importVideo: ERROR Video NOT saved"); - $video->setStatus(Video::$statusBrokenMissingFiles); + $video->setStatus(Video::STATUS_BROKEN_MISSING_FILES); } $video->save(false, true); //exit; diff --git a/install/populateForTest.php b/install/populateForTest.php index 56c456a679..37734c1998 100644 --- a/install/populateForTest.php +++ b/install/populateForTest.php @@ -131,7 +131,7 @@ for ($i = 0; $i < $totalVideos; $i++) { $index = array_rand($cats); $video->setCategories_id($cats[$index]['id']); - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); $video->setFilesize(2858747); $video->setLikes(rand(0, 1000)); $video->setDislikes(rand(0, 1000)); @@ -200,4 +200,4 @@ foreach ($pls as $key => $value) { echo "[{$total}/{$key}/{$j}] pupulating done [$videos_id] Video added in a Playlist" . PHP_EOL; } } -*/ \ No newline at end of file +*/ diff --git a/install/recheckEncodingFolders.php b/install/recheckEncodingFolders.php index 38ed9daf6e..c825cdd64b 100644 --- a/install/recheckEncodingFolders.php +++ b/install/recheckEncodingFolders.php @@ -32,7 +32,7 @@ foreach ($folders as $folder) { if (is_dir($fullPath) && (str_starts_with($folder, 'v_') || str_starts_with($folder, 'video_'))) { $video = Video::getVideoFromFileNameLight($folder); if (!empty($video)) { - if ($video['status'] === Video::$statusEncoding) { + if ($video['status'] === Video::STATUS_ENCODING) { if (strtotime($video['created']) < strtotime('-2 days')) { if (getDirSize($fullPath) > $_500MB) { $v = new Video('', '', $video['id']); diff --git a/install/recoverFilesToVideos.php b/install/recoverFilesToVideos.php index 46339289ae..8b8fb21734 100644 --- a/install/recoverFilesToVideos.php +++ b/install/recoverFilesToVideos.php @@ -61,7 +61,7 @@ if (!empty($confirm) && strtolower($confirm) === 'y') { $count++; $title = "Video recovered: ".date("Y-m-d H:i:s", filectime($value[1])); $video = new Video($title, $value[0]); - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); $video->setUsers_id(1); if ($video->save(false, true)) { echo "{$count}/{$total} {$title} created\n"; diff --git a/install/recoverOrphanFolders.php b/install/recoverOrphanFolders.php index 32a1b3ef45..18902df433 100644 --- a/install/recoverOrphanFolders.php +++ b/install/recoverOrphanFolders.php @@ -52,7 +52,7 @@ foreach ($folders as $folder) { $new_video->setCreated($mysqlDate); $new_video->setCategories_id(1); $new_video->setUsers_id(1); - $new_video->setStatus(Video::$statusActive); + $new_video->setStatus(Video::STATUS_ACTIVE); $new_video->setType(Video::$videoTypeVideo); $id = $new_video->save(false, true); diff --git a/install/reviewBrokenVideos.php b/install/reviewBrokenVideos.php index 9b43a8dcaa..eb6637be4e 100644 --- a/install/reviewBrokenVideos.php +++ b/install/reviewBrokenVideos.php @@ -1,54 +1,54 @@ - $value) { - if (!empty($index) && $key<$index) { - continue; - } - $video = new Video('', '', $value); - $filename = $video->getFilename(); - - echo "{$key}/{$total} Start check {$filename} " . PHP_EOL; - if (Video::isMediaFileMissing($filename)) { - $sources = getVideosURL_V2($filename); - echo "{$key}/{$total} is missing ". json_encode($sources) . PHP_EOL; - } else if($video->getStatus()===Video::$statusBrokenMissingFiles){ - $video->setStatus(Video::$statusActive); - echo "{$key}/{$total} is set to active " . PHP_EOL; - } -} - -echo PHP_EOL . " Done! " . PHP_EOL; -die(); + $value) { + if (!empty($index) && $key<$index) { + continue; + } + $video = new Video('', '', $value); + $filename = $video->getFilename(); + + echo "{$key}/{$total} Start check {$filename} " . PHP_EOL; + if (Video::isMediaFileMissing($filename)) { + $sources = getVideosURL_V2($filename); + echo "{$key}/{$total} is missing ". json_encode($sources) . PHP_EOL; + } else if($video->getStatus()===Video::STATUS_BROKEN_MISSING_FILES){ + $video->setStatus(Video::STATUS_ACTIVE); + echo "{$key}/{$total} is set to active " . PHP_EOL; + } +} + +echo PHP_EOL . " Done! " . PHP_EOL; +die(); diff --git a/objects/aVideoEncoder.json.php b/objects/aVideoEncoder.json.php index e6c36d7d77..64d919778a 100644 --- a/objects/aVideoEncoder.json.php +++ b/objects/aVideoEncoder.json.php @@ -203,8 +203,8 @@ if (!empty($_FILES['video']['tmp_name'])) { } else { $obj->lines[] = __LINE__; // set encoding - $video->setStatus(Video::$statusEncoding); - //$video->setAutoStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ENCODING); + //$video->setAutoStatus(Video::STATUS_ACTIVE); } if (!empty($_FILES['image']['tmp_name']) && !file_exists("{$destination_local}.jpg")) { $obj->lines[] = __LINE__; diff --git a/objects/aVideoEncoderNotifyIsDone.json.php b/objects/aVideoEncoderNotifyIsDone.json.php index 64096acdda..cd08641cbc 100644 --- a/objects/aVideoEncoderNotifyIsDone.json.php +++ b/objects/aVideoEncoderNotifyIsDone.json.php @@ -50,7 +50,7 @@ $video = new Video("", "", $_REQUEST['videos_id'], true); $obj->video_id = $_REQUEST['videos_id']; -$video->setAutoStatus(Video::$statusActive); +$video->setAutoStatus(Video::STATUS_ACTIVE); $video_id = $video->save(); diff --git a/objects/aVideoQueueEncoder.json.php b/objects/aVideoQueueEncoder.json.php index ebaf000539..f6bd5e3afb 100644 --- a/objects/aVideoQueueEncoder.json.php +++ b/objects/aVideoQueueEncoder.json.php @@ -76,7 +76,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $video = new Video(preg_replace("/_+/", " ", $path_parts['filename']), $filename, @$_FILES['upl']['videoId'], true); $video->setDuration($duration); $video->setType($type); - $video->setStatus(Video::$statusEncoding); + $video->setStatus(Video::STATUS_ENCODING); $id = $video->save($updateVideoGroups); _error_log("AddQueueEncoder Video saved with ID: " . $id); diff --git a/objects/functionTags.php b/objects/functionTags.php index 448bda2b1b..5cf27a7bc1 100644 --- a/objects/functionTags.php +++ b/objects/functionTags.php @@ -31,7 +31,7 @@ function getVideoTagsFromVideo($video, $type) } } else { $ppv = AVideoPlugin::getObjectDataIfEnabled("PayPerView"); - if ($video->getStatus() === Video::$statusFansOnly) { + if ($video->getStatus() === Video::STATUS_FANS_ONLY) { $objTag->type = "warning"; $objTag->text = ''; $objTag->tooltip = __("Fans Only"); @@ -84,31 +84,31 @@ function getVideoTagVideoStatus($video, $type) $status = $video->getStatus(); $objTag->text = __(Video::$statusDesc[$status]); switch ($status) { - case Video::$statusActive: + case Video::STATUS_ACTIVE: $objTag->type = "success"; break; - case Video::$statusActiveAndEncoding: + case Video::STATUS_ACTIVE_AND_ENCODING: $objTag->type = "success"; break; - case Video::$statusInactive: + case Video::STATUS_INACTIVE: $objTag->type = "warning"; break; - case Video::$statusEncoding: + case Video::STATUS_ENCODING: $objTag->type = "info"; break; - case Video::$statusDownloading: + case Video::STATUS_DOWNLOADING: $objTag->type = "info"; break; - case Video::$statusUnlisted: + case Video::STATUS_UNLISTED: $objTag->type = "info"; break; - case Video::$statusUnlistedButSearchable: + case Video::STATUS_UNLISTED_BUT_SEARCHABLE: $objTag->type = "info"; break; - case Video::$statusRecording: + case Video::STATUS_RECORDING: $objTag->type = "danger isRecording isRecordingIcon"; break; - case Video::$statusDraft: + case Video::STATUS_DRAFT: $objTag->type = "primary"; break; default: diff --git a/objects/playlist.php b/objects/playlist.php index e37447411e..c4feaae620 100644 --- a/objects/playlist.php +++ b/objects/playlist.php @@ -558,7 +558,7 @@ class PlayList extends ObjectYPT if (empty($playlists_id)) { $sql = "SELECT 0 as playlists_id, id as videos_id FROM videos p WHERE status = ? ORDER BY `created` DESC "; $formats = 's'; - $values = [Video::$statusActive]; + $values = [Video::STATUS_ACTIVE]; } else { $sql = "SELECT * FROM playlists_has_videos p WHERE playlists_id = ? " . self::getOrderBy('p.'); $formats = 'i'; diff --git a/objects/user.php b/objects/user.php index a3114cc39b..34eac87d9c 100644 --- a/objects/user.php +++ b/objects/user.php @@ -1003,7 +1003,7 @@ if (typeof gtag !== \"function\") { } $video = new Video("", "", $videos_id); - if ($video->getStatus() === Video::$statusInactive) { + if ($video->getStatus() === Video::STATUS_INACTIVE) { $global['canWatchVideoReason'] = "Video is inactive"; _error_log("User::canWatchVideo Video is inactive ({$videos_id})"); self::setCacheWatchVideo($cacheName, false); @@ -1088,7 +1088,7 @@ if (typeof gtag !== \"function\") { } $video = new Video("", "", $videos_id); - if ($video->getStatus() === Video::$statusInactive) { + if ($video->getStatus() === Video::STATUS_INACTIVE) { $global['canWatchVideoReason'] = "canWatchVideoWithAds: Video is inactive"; _error_log("User::canWatchVideoWithAds Video is inactive ({$videos_id})"); return false; diff --git a/objects/video.php b/objects/video.php index 51567f5530..ae4aabe918 100644 --- a/objects/video.php +++ b/objects/video.php @@ -71,55 +71,7 @@ if (!class_exists('Video')) { protected $publish_datetime; protected $notification_datetime; protected $made_for_kids; - public static $statusDesc = [ - 'a' => 'Active', - 'k' => 'Active and Encoding', - 'i' => 'Inactive', - 'h' => 'Scheduled Release Date', - 'e' => 'Encoding', - 'x' => 'Encoding Error', - 'd' => 'Downloading', - 't' => 'Transferring', - 'u' => 'Unlisted', - 's' => 'Unlisted but Searchable', - 'r' => 'Recording', - 'f' => 'FansOnly', - 'b' => 'Broken Missing files', - 'p' => 'Unpublished', - 'c' => 'Draft' - ]; - public static $statusIcons = [ - 'a' => '', - 'k' => '', - 'i' => '', - 'h' => '', - 'e' => '', - 'x' => '', - 'd' => '', - 't' => '', - 'u' => '', - 's' => '', - 'r' => '', - 'f' => '', - 'b' => '', - 'p' => '', - 'c' => '' - ]; - public static $statusActive = 'a'; - public static $statusActiveAndEncoding = 'k'; - public static $statusInactive = 'i'; - public static $statusScheduledReleaseDate = 'h'; - public static $statusEncoding = 'e'; - public static $statusEncodingError = 'x'; - public static $statusDownloading = 'd'; - public static $statusTranfering = 't'; - public static $statusUnlisted = 'u'; - public static $statusUnlistedButSearchable = 's'; - public static $statusRecording = 'r'; - public static $statusFansOnly = 'f'; - public static $statusBrokenMissingFiles = 'b'; - public static $statusUnpublished = 'p'; - public static $statusDraft = 'c'; + public static $rratingOptions = ['', 'g', 'pg', 'pg-13', 'r', 'nc-17', 'ma']; public static $rratingOptionsText = [ 'g' => 'General Audience', @@ -174,6 +126,95 @@ if (!class_exists('Video')) { const SORT_TYPE_SHORTS = 'shorts'; const SORT_TYPE_DATEADDED = 'dateadded'; + // Status constants + const STATUS_ACTIVE = 'a'; + const STATUS_ACTIVE_AND_ENCODING = 'k'; + const STATUS_INACTIVE = 'i'; + const STATUS_SCHEDULED_RELEASE_DATE = 'h'; + const STATUS_ENCODING = 'e'; + const STATUS_ENCODING_ERROR = 'x'; + const STATUS_DOWNLOADING = 'd'; + const STATUS_TRANFERING = 't'; + const STATUS_UNLISTED = 'u'; + const STATUS_UNLISTED_BUT_SEARCHABLE = 's'; + const STATUS_RECORDING = 'r'; + const STATUS_FANS_ONLY = 'f'; + const STATUS_BROKEN_MISSING_FILES = 'b'; + const STATUS_UNPUBLISHED = 'p'; + const STATUS_DRAFT = 'c'; + + // Reuse constants in static arrays + public static $statusDesc = [ + self::STATUS_ACTIVE => 'Active', + self::STATUS_ACTIVE_AND_ENCODING => 'Active and Encoding', + self::STATUS_INACTIVE => 'Inactive', + self::STATUS_SCHEDULED_RELEASE_DATE => 'Scheduled Release Date', + self::STATUS_ENCODING => 'Encoding', + self::STATUS_ENCODING_ERROR => 'Encoding Error', + self::STATUS_DOWNLOADING => 'Downloading', + self::STATUS_TRANFERING => 'Transferring', + self::STATUS_UNLISTED => 'Unlisted', + self::STATUS_UNLISTED_BUT_SEARCHABLE => 'Unlisted but Searchable', + self::STATUS_RECORDING => 'Recording', + self::STATUS_FANS_ONLY => 'FansOnly', + self::STATUS_BROKEN_MISSING_FILES => 'Broken Missing files', + self::STATUS_UNPUBLISHED => 'Unpublished', + self::STATUS_DRAFT => 'Draft' + ]; + + public static $statusDescriptions = [ + self::STATUS_ACTIVE => 'Active: The video is published and visible to users.', + self::STATUS_ACTIVE_AND_ENCODING => 'Active and Encoding: The video is published but still being processed/encoded.', + self::STATUS_INACTIVE => 'Inactive: The video is hidden and not available to users.', + self::STATUS_SCHEDULED_RELEASE_DATE => 'Scheduled Release Date: The video is scheduled to be published at a future date/time.', + self::STATUS_ENCODING => 'Encoding: The video is currently being encoded and is not yet available.', + self::STATUS_ENCODING_ERROR => 'Encoding Error: There was an error during encoding; the video is not available.', + self::STATUS_DOWNLOADING => 'Downloading: The video is being downloaded from an external source.', + self::STATUS_TRANFERING => 'Transferring: The video is being transferred between servers or locations.', + self::STATUS_UNLISTED => 'Unlisted: The video is not listed publicly but can be accessed via direct link.', + self::STATUS_UNLISTED_BUT_SEARCHABLE => 'Unlisted but Searchable: The video is not listed but can be found via search.', + self::STATUS_RECORDING => 'Recording: The video is currently being recorded (e.g., live stream).', + self::STATUS_FANS_ONLY => 'FansOnly: The video is restricted to fans or subscribers only.', + self::STATUS_BROKEN_MISSING_FILES => 'Broken Missing Files: The video is missing files or is corrupted.', + self::STATUS_UNPUBLISHED => 'Unpublished: The video is not published and not visible to users.', + self::STATUS_DRAFT => 'Draft: The video is a draft and not yet published.', + ]; + + public static $statusIcons = [ + self::STATUS_ACTIVE => '', + self::STATUS_ACTIVE_AND_ENCODING => '', + self::STATUS_INACTIVE => '', + self::STATUS_SCHEDULED_RELEASE_DATE => '', + self::STATUS_ENCODING => '', + self::STATUS_ENCODING_ERROR => '', + self::STATUS_DOWNLOADING => '', + self::STATUS_TRANFERING => '', + self::STATUS_UNLISTED => '', + self::STATUS_UNLISTED_BUT_SEARCHABLE => '', + self::STATUS_RECORDING => '', + self::STATUS_FANS_ONLY => '', + self::STATUS_BROKEN_MISSING_FILES => '', + self::STATUS_UNPUBLISHED => '', + self::STATUS_DRAFT => '' + ]; + + // this block will be removed in the future + public static $statusActive = self::STATUS_ACTIVE; + public static $statusActiveAndEncoding = self::STATUS_ACTIVE_AND_ENCODING; + public static $statusInactive = self::STATUS_INACTIVE; + public static $statusScheduledReleaseDate = self::STATUS_SCHEDULED_RELEASE_DATE; + public static $statusEncoding = self::STATUS_ENCODING; + public static $statusEncodingError = self::STATUS_ENCODING_ERROR; + public static $statusDownloading = self::STATUS_DOWNLOADING; + public static $statusTranfering = self::STATUS_TRANFERING; + public static $statusUnlisted = self::STATUS_UNLISTED; + public static $statusUnlistedButSearchable = self::STATUS_UNLISTED_BUT_SEARCHABLE; + public static $statusRecording = self::STATUS_RECORDING; + public static $statusFansOnly = self::STATUS_FANS_ONLY; + public static $statusBrokenMissingFiles = self::STATUS_BROKEN_MISSING_FILES; + public static $statusUnpublished = self::STATUS_UNPUBLISHED; + public static $statusDraft = self::STATUS_DRAFT; + public function __construct($title = "", $filename = "", $id = 0, $refreshCache = false) { @@ -511,9 +552,9 @@ if (!class_exists('Video')) { if (empty($this->status) || empty(self::$statusDesc[$this->status])) { _error_log("Video::save status is empty or not valid {$this->status} " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))); if ($this->type != self::$videoTypeVideo) { - $this->status = Video::$statusActive; + $this->status = Video::STATUS_ACTIVE; } else { - $this->status = Video::$statusEncoding; + $this->status = Video::STATUS_ENCODING; } } @@ -873,8 +914,8 @@ if (!class_exists('Video')) { public function setStatus($status) { - if ($status === Video::$statusBrokenMissingFiles) { - if (empty($this->status) || $this->status !== Video::$statusBrokenMissingFiles) { + if ($status === Video::STATUS_BROKEN_MISSING_FILES) { + if (empty($this->status) || $this->status !== Video::STATUS_BROKEN_MISSING_FILES) { _error_log("Video::setStatus({$status}) set to statusBrokenMissingFiles id = {$this->id} " . json_encode(debug_backtrace()), AVideoLog::$WARNING); } } @@ -883,14 +924,14 @@ if (!class_exists('Video')) { global $global; if (empty($status)) { - $status = Video::$statusActive; + $status = Video::STATUS_ACTIVE; } if (empty(Video::$statusDesc[$status])) { _error_log("Video::setStatus({$status}) NOT found " . json_encode(debug_backtrace()), AVideoLog::$WARNING); return false; } - if ($this->status == Video::$statusUnpublished) { + if ($this->status == Video::STATUS_UNPUBLISHED) { if (!User::isAdmin() && !Permissions::canModerateVideos()) { _error_log("Video::setStatus({$status}) Only modetrators can publish videos ", AVideoLog::$WARNING); return false; @@ -910,17 +951,17 @@ if (!class_exists('Video')) { return false; } self::clearCache($this->id); - if ($this->status == Video::$statusActive || $status == Video::$statusActive && ($this->status != $status)) { + if ($this->status == Video::STATUS_ACTIVE || $status == Video::STATUS_ACTIVE && ($this->status != $status)) { $doNotNotify = array( - Video::$statusInactive, - Video::$statusUnlisted, - Video::$statusUnlistedButSearchable, - Video::$statusFansOnly, - Video::$statusBrokenMissingFiles, - Video::$statusDraft + Video::STATUS_INACTIVE, + Video::STATUS_UNLISTED, + Video::STATUS_UNLISTED_BUT_SEARCHABLE, + Video::STATUS_FANS_ONLY, + Video::STATUS_BROKEN_MISSING_FILES, + Video::STATUS_DRAFT ); - if (!in_array($this->status, $doNotNotify) && $status == Video::$statusActive) { + if (!in_array($this->status, $doNotNotify) && $status == Video::STATUS_ACTIVE) { _error_log("Video::setStatus({$status}) AVideoPlugin::onNewVideo "); $notTriggerOnNewVideo = array( 'aVideoEncoder.json.php', @@ -962,25 +1003,25 @@ if (!class_exists('Video')) { $advancedCustom = AVideoPlugin::getDataObject('CustomizeAdvanced'); } if (!empty($_POST['fail'])) { - return $this->setStatus(Video::$statusEncodingError); + return $this->setStatus(Video::STATUS_ENCODING_ERROR); } else { if ($advancedCustom->enableVideoModeration) { - return $this->setStatus(Video::$statusUnpublished); + return $this->setStatus(Video::STATUS_UNPUBLISHED); } else if ($this->isScheduledForRelease()) { - return $this->setStatus(Video::$statusScheduledReleaseDate); + return $this->setStatus(Video::STATUS_SCHEDULED_RELEASE_DATE); } else if (!empty($_REQUEST['overrideStatus'])) { return $this->setStatus($_REQUEST['overrideStatus']); } else if (!empty($_REQUEST['releaseDate']) && $_REQUEST['releaseDate'] !== 'now') { - return $this->setStatus(Video::$statusScheduledReleaseDate); + return $this->setStatus(Video::STATUS_SCHEDULED_RELEASE_DATE); } else { // encoder did not provide a status AVideoPlugin::loadPlugin('Scheduler'); $row = Scheduler::isActiveFromVideosId($this->id); if (!empty($row)) { // there is a schedule to activate the video - return $this->setStatus(Video::$statusScheduledReleaseDate); + return $this->setStatus(Video::STATUS_SCHEDULED_RELEASE_DATE); } else { if (!empty($_REQUEST['keepEncoding'])) { - return $this->setStatus(Video::$statusActiveAndEncoding); + return $this->setStatus(Video::STATUS_ACTIVE_AND_ENCODING); } else { if ($this->getTitle() !== "Video automatically booked") { $typesToBeAutoDraft = array( @@ -991,14 +1032,14 @@ if (!class_exists('Video')) { Video::$videoTypeZip, Video::$videoTypeGallery, ); - if (in_array($this->type, $typesToBeAutoDraft)){ - return $this->setStatus(Video::$statusDraft); - }else{ + if (in_array($this->type, $typesToBeAutoDraft)) { + return $this->setStatus(Video::STATUS_DRAFT); + } else { _error_log("Video::setAutoStatus({$this->type}) set to default status " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))); return $this->setStatus($advancedCustom->defaultVideoStatus->value); } } else { - return $this->setStatus(Video::$statusInactive); + return $this->setStatus(Video::STATUS_INACTIVE); } } } @@ -1147,26 +1188,26 @@ if (!class_exists('Video')) { if ($status == Video::SORT_TYPE_VIEWABLE) { if (User::isLogged()) { $sql .= " AND ((v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') "; - $sql .= " OR ((v.status='" . Video::$statusUnlisted . "' OR v.status='" . Video::$statusUnlistedButSearchable . "') "; + $sql .= " OR ((v.status='" . Video::STATUS_UNLISTED . "' OR v.status='" . Video::STATUS_UNLISTED_BUT_SEARCHABLE . "') "; if (!User::isAdmin() && !Permissions::canAdminVideos()) { $sql .= " AND (v.users_id ='" . User::getId() . "' OR v.users_id_company = '" . User::getId() . "')"; } $sql .= " ))"; - $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::$statusUnlisted . "' OR v.status='" . Video::$statusUnlistedButSearchable . "') )"; + $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::STATUS_UNLISTED . "' OR v.status='" . Video::STATUS_UNLISTED_BUT_SEARCHABLE . "') )"; $sql .= " )"; } else { $sql .= " AND ( v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')"; - $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::$statusUnlisted . "' OR v.status='" . Video::$statusUnlistedButSearchable . "') )"; + $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::STATUS_UNLISTED . "' OR v.status='" . Video::STATUS_UNLISTED_BUT_SEARCHABLE . "') )"; $sql .= " )"; } } elseif ($status == Video::SORT_TYPE_VIEWABLENOTUNLISTED) { $sql .= " AND ( v.status IN ('" . implode("','", Video::getViewableStatus(false)) . "')"; - $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::$statusUnlisted . "' OR v.status='" . Video::$statusUnlistedButSearchable . "') )"; + $sql .= " OR (v.`order` IS NOT NULL AND (v.status='" . Video::STATUS_UNLISTED . "' OR v.status='" . Video::STATUS_UNLISTED_BUT_SEARCHABLE . "') )"; $sql .= " )"; } elseif ($status == Video::SORT_TYPE_PUBLICONLY) { - $sql .= " AND v.status IN ('" . Video::$statusActive . "', '" . Video::$statusActiveAndEncoding . "') AND (SELECT count(id) FROM videos_group_view as gv WHERE gv.videos_id = v.id ) = 0"; + $sql .= " AND v.status IN ('" . Video::STATUS_ACTIVE . "', '" . Video::STATUS_ACTIVE_AND_ENCODING . "') AND (SELECT count(id) FROM videos_group_view as gv WHERE gv.videos_id = v.id ) = 0"; } elseif ($status == Video::SORT_TYPE_PRIVATEONLY) { - $sql .= " AND v.status IN ('" . Video::$statusActive . "', '" . Video::$statusActiveAndEncoding . "') AND (SELECT count(id) FROM videos_group_view as gv WHERE gv.videos_id = v.id ) > 0"; + $sql .= " AND v.status IN ('" . Video::STATUS_ACTIVE . "', '" . Video::STATUS_ACTIVE_AND_ENCODING . "') AND (SELECT count(id) FROM videos_group_view as gv WHERE gv.videos_id = v.id ) > 0"; } elseif ($status == Video::SORT_TYPE_SHORTS) { $ShortsObj = AVideoPlugin::getDataObject("Shorts"); if (!empty($ShortsObj)) { @@ -1197,7 +1238,7 @@ if (!class_exists('Video')) { switch ($sortType) { case Video::SORT_TYPE_SUGGESTED: - $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; + $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::STATUS_ACTIVE . "' "; $sql .= " ORDER BY RAND() "; $sql .= BootGrid::getSqlFromPost([], empty($_POST['sort']['likes']) ? "v." : "", "", true); if (strpos(mb_strtolower($sql), 'limit') === false) { @@ -1390,9 +1431,9 @@ if (!class_exists('Video')) { $sql .= " v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')"; /* If I keep the code below it will appear on first page if (User::isAdmin()) { - $sql .= " OR v.status = '" . Video::$statusUnpublished . "' "; + $sql .= " OR v.status = '" . Video::STATUS_UNPUBLISHED . "' "; } else if (User::isLogged()) { - $sql .= " OR (v.status = '" . Video::$statusUnpublished . "' AND v.users_id = '" . User::getId() . "' )"; + $sql .= " OR (v.status = '" . Video::STATUS_UNPUBLISHED . "' AND v.users_id = '" . User::getId() . "' )"; } */ $sql .= " )"; @@ -1401,9 +1442,9 @@ if (!class_exists('Video')) { $sql .= " v.status IN ('" . implode("','", Video::getViewableStatus(false)) . "')"; /*If I keep the code below it will appear on first page if (User::isAdmin()) { - $sql .= " OR v.status = '" . Video::$statusUnpublished . "' "; + $sql .= " OR v.status = '" . Video::STATUS_UNPUBLISHED . "' "; } else if (User::isLogged()) { - $sql .= " OR (v.status = '" . Video::$statusUnpublished . "' AND v.users_id = '" . User::getId() . "' )"; + $sql .= " OR (v.status = '" . Video::STATUS_UNPUBLISHED . "' AND v.users_id = '" . User::getId() . "' )"; } */ $sql .= " )"; @@ -1467,7 +1508,7 @@ if (!class_exists('Video')) { $firstClauseLimit = ''; if (empty($id)) { if ($suggestedOnly) { - $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; + $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::STATUS_ACTIVE . "' "; } if (empty($random) && !empty($_GET['videoName'])) { $videoName = addcslashes($_GET['videoName'], "'"); @@ -1486,7 +1527,7 @@ if (!class_exists('Video')) { //var_dump($rand, $numRows); //$sql .= " ORDER BY RAND() "; } elseif ($suggestedOnly && empty($_GET['videoName']) && empty($_GET['search']) && empty($_GET['searchPhrase'])) { - $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; + $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::STATUS_ACTIVE . "' "; $numRows = self::getTotalVideos($status, false, $ignoreGroup, $showUnlisted, $activeUsersOnly, $suggestedOnly); if ($numRows <= 2) { $rand = 0; @@ -1708,10 +1749,10 @@ if (!class_exists('Video')) { } $serie_playlists_id = $video['serie_playlists_id']; - if(empty($serie_playlists_id) && !empty($_REQUEST['serie_playlists_id'])){ + if (empty($serie_playlists_id) && !empty($_REQUEST['serie_playlists_id'])) { $serie_playlists_id = intval($video['serie_playlists_id']); } - if(!empty($serie_playlists_id)){ + if (!empty($serie_playlists_id)) { unset($_REQUEST['serie_playlists_id']); $videosArrayId = PlayList::getVideosIdFromPlaylist($serie_playlists_id); $rows = Video::getAllVideos("viewable", false, true, $videosArrayId, false, true); @@ -2597,7 +2638,7 @@ if (!class_exists('Video')) { if ($status == Video::SORT_TYPE_VIEWABLE) { if (User::isLogged()) { $sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') "; - $sql .= " OR (v.status='" . Video::$statusUnlisted . "' "; + $sql .= " OR (v.status='" . Video::STATUS_UNLISTED . "' "; if (!User::isAdmin() && !Permissions::canAdminVideos()) { $sql .= " AND (v.users_id ='" . User::getId() . "' OR v.users_id_company = '" . User::getId() . "')"; } @@ -2633,7 +2674,7 @@ if (!class_exists('Video')) { $sql .= AVideoPlugin::getVideoWhereClause(); if ($suggestedOnly) { - $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; + $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::STATUS_ACTIVE . "' "; $sql .= " ORDER BY RAND() "; } else if ($with_order_only) { $sql .= " ORDER BY v.`order` ASC "; @@ -2861,7 +2902,7 @@ if (!class_exists('Video')) { } if ($suggestedOnly) { - $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; + $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::STATUS_ACTIVE . "' "; } /* @@ -2961,18 +3002,18 @@ if (!class_exists('Video')) { public static function getViewableStatus($showUnlisted = false) { - $viewable = [Video::$statusActive, Video::$statusActiveAndEncoding, Video::$statusFansOnly]; + $viewable = [Video::STATUS_ACTIVE, Video::STATUS_ACTIVE_AND_ENCODING, Video::STATUS_FANS_ONLY]; if ($showUnlisted) { - $viewable[] = Video::$statusUnlisted; - $viewable[] = Video::$statusUnlistedButSearchable; + $viewable[] = Video::STATUS_UNLISTED; + $viewable[] = Video::STATUS_UNLISTED_BUT_SEARCHABLE; } else { $search = getSearchVar(); if (!empty($search)) { - $viewable[] = Video::$statusUnlistedButSearchable; + $viewable[] = Video::STATUS_UNLISTED_BUT_SEARCHABLE; } } if (User::isAdmin()) { - $viewable[] = Video::$statusScheduledReleaseDate; + $viewable[] = Video::STATUS_SCHEDULED_RELEASE_DATE; } /* * Cannot do that otherwise it will list videos on the list videos menu @@ -3693,7 +3734,7 @@ if (!class_exists('Video')) { $response = array('videos_id' => $videos_id); $video = new Video("", "", $videos_id); $ppv = AVideoPlugin::getObjectDataIfEnabled("PayPerView"); - $response['fans_only'] = $video->getStatus() === self::$statusFansOnly; + $response['fans_only'] = $video->getStatus() === self::STATUS_FANS_ONLY; if ($response['fans_only'] && AVideoPlugin::isEnabledByName("FansSubscriptions")) { $response['fans_only_info'] = FansSubscriptions::getPlansFromUsersID($video->getUsers_id()); } @@ -4835,7 +4876,7 @@ if (!class_exists('Video')) { if ($v['type'] !== 'video') { return []; } - if ($v['status'] !== self::$statusActive && $v['status'] !== self::$statusUnlisted && $v['status'] !== self::$statusUnlistedButSearchable) { + if ($v['status'] !== self::STATUS_ACTIVE && $v['status'] !== self::STATUS_UNLISTED && $v['status'] !== self::STATUS_UNLISTED_BUT_SEARCHABLE) { return []; } $video = new Video('', '', $v['id']); @@ -6133,22 +6174,22 @@ if (!class_exists('Video')) { return $response; } - if ($video->getStatus() == Video::$statusInactive) { + if ($video->getStatus() == Video::STATUS_INACTIVE) { $response->canWatch = false; $response->why[] = "This video is inactive"; } - if ($video->getStatus() == Video::$statusBrokenMissingFiles) { + if ($video->getStatus() == Video::STATUS_BROKEN_MISSING_FILES) { $response->canWatch = false; $response->why[] = "This video is broken"; } - if ($video->getStatus() == Video::$statusEncoding) { + if ($video->getStatus() == Video::STATUS_ENCODING) { $response->canWatch = false; $response->why[] = "This video is encoding, please wait"; } - if ($video->getStatus() == Video::$statusTranfering) { + if ($video->getStatus() == Video::STATUS_TRANFERING) { $response->canWatch = false; $response->why[] = "This video is still transfering, please wait"; } @@ -7137,12 +7178,12 @@ if (!class_exists('Video')) { $_checkIfIsBrokenList[$videos_id] = false; return $_checkIfIsBrokenList[$videos_id]; } - if ($video->getStatus() == Video::$statusActive || $video->getStatus() == Video::$statusUnlisted || $video->getStatus() == Video::$statusUnlistedButSearchable) { + if ($video->getStatus() == Video::STATUS_ACTIVE || $video->getStatus() == Video::STATUS_UNLISTED || $video->getStatus() == Video::STATUS_UNLISTED_BUT_SEARCHABLE) { if ($video->getType() == Video::$videoTypeAudio || $video->getType() == Video::$videoTypeVideo) { $checkIfIsBroken++; if (self::isMediaFileMissing($video->getFilename())) { _error_log("Video::checkIfIsBroken($videos_id) true " . $video->getFilename() . ' status=[' . $video->getStatus() . ']' . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))); - $video->setStatus(Video::$statusBrokenMissingFiles); + $video->setStatus(Video::STATUS_BROKEN_MISSING_FILES); Video::clearCache($videos_id); $_checkIfIsBrokenList[$videos_id] = true; return $_checkIfIsBrokenList[$videos_id]; @@ -7150,7 +7191,7 @@ if (!class_exists('Video')) { } } - $_checkIfIsBrokenList[$videos_id] = $video->getStatus() == Video::$statusBrokenMissingFiles; + $_checkIfIsBrokenList[$videos_id] = $video->getStatus() == Video::STATUS_BROKEN_MISSING_FILES; return $_checkIfIsBrokenList[$videos_id]; } @@ -7296,7 +7337,7 @@ if (!class_exists('Video')) { static public function getAllActiveEPGs() { global $config; - $sql = "SELECT * FROM `videos` WHERE status = '" . Video::$statusActive . "' " + $sql = "SELECT * FROM `videos` WHERE status = '" . Video::STATUS_ACTIVE . "' " . "AND `type` = 'linkVideo' " . "AND epg_link IS NOT NULL " . "AND epg_link != ''"; @@ -7400,11 +7441,11 @@ if (!class_exists('Video')) { static function deleteUselessOldVideos($days) { $arrayStatusToDelete = array( - Video::$statusBrokenMissingFiles, - Video::$statusDownloading, - Video::$statusEncoding, - Video::$statusEncodingError, - Video::$statusTranfering, + Video::STATUS_BROKEN_MISSING_FILES, + Video::STATUS_DOWNLOADING, + Video::STATUS_ENCODING, + Video::STATUS_ENCODING_ERROR, + Video::STATUS_TRANFERING, ); $daysAgo = date("Y-m-d H:i:s", strtotime("-{$days} days")); $sql = "SELECT * FROM videos WHERE status IN ('" . implode("', '", $arrayStatusToDelete) . "') AND created < ? "; @@ -7615,40 +7656,40 @@ if (!empty($_GET['v']) && empty($_GET['videoName'])) { } global $statusThatShowTheCompleteMenu, $statusSearchFilter, $statusThatTheUserCanUpdate; $statusThatShowTheCompleteMenu = [ - Video::$statusActive, - Video::$statusInactive, - Video::$statusScheduledReleaseDate, - Video::$statusActiveAndEncoding, - Video::$statusUnlistedButSearchable, - Video::$statusUnlisted, - Video::$statusFansOnly, - Video::$statusUnpublished, - Video::$statusDraft, + Video::STATUS_ACTIVE, + Video::STATUS_INACTIVE, + Video::STATUS_SCHEDULED_RELEASE_DATE, + Video::STATUS_ACTIVE_AND_ENCODING, + Video::STATUS_UNLISTED_BUT_SEARCHABLE, + Video::STATUS_UNLISTED, + Video::STATUS_FANS_ONLY, + Video::STATUS_UNPUBLISHED, + Video::STATUS_DRAFT, ]; $statusSearchFilter = [ - Video::$statusActive, - Video::$statusInactive, - Video::$statusScheduledReleaseDate, - Video::$statusEncoding, - Video::$statusTranfering, - Video::$statusUnlisted, - Video::$statusUnlistedButSearchable, - Video::$statusBrokenMissingFiles, - Video::$statusUnpublished, - Video::$statusDraft, + Video::STATUS_ACTIVE, + Video::STATUS_INACTIVE, + Video::STATUS_SCHEDULED_RELEASE_DATE, + Video::STATUS_ENCODING, + Video::STATUS_TRANFERING, + Video::STATUS_UNLISTED, + Video::STATUS_UNLISTED_BUT_SEARCHABLE, + Video::STATUS_BROKEN_MISSING_FILES, + Video::STATUS_UNPUBLISHED, + Video::STATUS_DRAFT, ]; $statusThatTheUserCanUpdate = [ - [Video::$statusDraft, '#00B'], - [Video::$statusActive, '#0A0'], - [Video::$statusInactive, '#B00'], - [Video::$statusUnlisted, '#AAA'], - [Video::$statusUnlistedButSearchable, '#888'], + [Video::STATUS_DRAFT, '#00B'], + [Video::STATUS_ACTIVE, '#0A0'], + [Video::STATUS_INACTIVE, '#B00'], + [Video::STATUS_UNLISTED, '#AAA'], + [Video::STATUS_UNLISTED_BUT_SEARCHABLE, '#888'], ]; AVideoPlugin::loadPlugin('Permissions'); if (User::isAdmin() || Permissions::canModerateVideos()) { - $statusThatTheUserCanUpdate[] = [Video::$statusUnpublished, '#B00']; + $statusThatTheUserCanUpdate[] = [Video::STATUS_UNPUBLISHED, '#B00']; } //Video::videoMadeForKidsExists();exit; diff --git a/objects/videoAddNew.json.php b/objects/videoAddNew.json.php index 19fe6e2ed2..b4713419d4 100644 --- a/objects/videoAddNew.json.php +++ b/objects/videoAddNew.json.php @@ -154,7 +154,7 @@ if (empty($_POST['id'])) { $obj->setType($_POST['videoLinkType']); } $rowsPath[] = array('line' => __LINE__, 'ElapsedTime' => getElapsedTime()); - $obj->setAutoStatus(Video::$statusDraft); + $obj->setAutoStatus(Video::STATUS_DRAFT); } TimeLogEnd(__FILE__, __LINE__); @@ -286,7 +286,7 @@ $obj->infoObj = json_encode($infoObj); $obj->videos_id = intval($resp); $obj->video = Video::getVideoLight($obj->videos_id, true); $obj->isNewVideo = $isNewVideo; -if ($obj->video['status'] == Video::$statusActive) { +if ($obj->video['status'] == Video::STATUS_ACTIVE) { $rowsPath[] = array('line' => __LINE__, 'ElapsedTime' => getElapsedTime()); _error_log('clearFirstPageCache start'); $obj->clearFirstPageCache = clearFirstPageCache(); diff --git a/objects/videos.json.php b/objects/videos.json.php index c82c68ac70..b70c59e165 100644 --- a/objects/videos.json.php +++ b/objects/videos.json.php @@ -45,7 +45,7 @@ TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit); foreach ($videos as $key => $value) { /* $video = new Video('', '', $value['id']); - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); Video::clearCache($value['id']);continue; */ unset($value['password'], $value['recoverPass']); diff --git a/plugin/AI/AI.php b/plugin/AI/AI.php index 520c62be15..a00e606c06 100644 --- a/plugin/AI/AI.php +++ b/plugin/AI/AI.php @@ -739,7 +739,7 @@ class AI extends PluginAbstract $video = new Video('', '', $newVideos_id); if (file_exists($outputFile)) { - $video->setAutoStatus(Video::$statusActive); + $video->setAutoStatus(Video::STATUS_ACTIVE); AVideoPlugin::onUploadIsDone($newVideos_id); AVideoPlugin::afterNewVideo($newVideos_id); _error_log('AI:videoCut create file success ' . $outputFile); diff --git a/plugin/CDN/tools/downloadAllFilesFromCDN.php b/plugin/CDN/tools/downloadAllFilesFromCDN.php index 4d5d95a214..b09879783f 100644 --- a/plugin/CDN/tools/downloadAllFilesFromCDN.php +++ b/plugin/CDN/tools/downloadAllFilesFromCDN.php @@ -35,7 +35,7 @@ foreach ($videos as $value) { //echo "sites_id is not empty {$value['sites_id']}" . PHP_EOL; continue; } - if ($value['status'] !== Video::$statusActive) { + if ($value['status'] !== Video::STATUS_ACTIVE) { $countStatusNotActive++; //echo "The video status is not active {$value['status']}" . PHP_EOL; continue; diff --git a/plugin/CDN/tools/fixDummyFiles.php b/plugin/CDN/tools/fixDummyFiles.php index e9a45eac0b..fe0f85e70a 100644 --- a/plugin/CDN/tools/fixDummyFiles.php +++ b/plugin/CDN/tools/fixDummyFiles.php @@ -27,13 +27,13 @@ $videos = sqlDAL::fetchAllAssoc($res); $total = count($videos); sqlDAL::close($res); foreach ($videos as $key => $value) { - if ($value['status'] === Video::$statusActive) { + if ($value['status'] === Video::STATUS_ACTIVE) { if (empty($value['sites_id'])) { continue; } - + $dir = "{$path}{$value['filename']}/"; - + $dirsize = getDirSize($dir); if($dirsize<$tenMB){ echo "Directory too small {$dir} $dirsize<$tenMB ". humanFileSize($dirsize) . PHP_EOL; @@ -41,7 +41,7 @@ foreach ($videos as $key => $value) { }else{ echo "Directory size is {$dir} $dirsize ". humanFileSize($dirsize) . PHP_EOL; } - + $filesAffected = CDNStorage::createDummyFiles($value['id']); if (empty($filesAffected)) { echo "{$key}/{$total} ERROR " . PHP_EOL; diff --git a/plugin/CDN/tools/fixIndexMP4.php b/plugin/CDN/tools/fixIndexMP4.php index 93d34a4acf..398d225a4d 100644 --- a/plugin/CDN/tools/fixIndexMP4.php +++ b/plugin/CDN/tools/fixIndexMP4.php @@ -39,7 +39,7 @@ foreach ($videos as $key => $value) { $videos_id = $value['id']; $filename = $value['filename']; - if ($value['status'] === Video::$statusActive) { + if ($value['status'] === Video::STATUS_ACTIVE) { echo "[videos_id: {$videos_id}] Processing '{$filename}'" . PHP_EOL; if (empty($value['sites_id'])) { diff --git a/plugin/CDN/tools/fixM3U8DummyFiles.php b/plugin/CDN/tools/fixM3U8DummyFiles.php index f49bdd6ac9..7af2f89d32 100644 --- a/plugin/CDN/tools/fixM3U8DummyFiles.php +++ b/plugin/CDN/tools/fixM3U8DummyFiles.php @@ -1,81 +1,81 @@ -getUUID()); if (!empty($dbObject->makeVideosInactiveAfterEncode)) { - $o->value = Video::$statusInactive; + $o->value = Video::STATUS_INACTIVE; } elseif (!empty($dbObject->makeVideosUnlistedAfterEncode)) { - $o->value = Video::$statusUnlisted; + $o->value = Video::STATUS_UNLISTED; }else{ - $o->value = Video::$statusActive; + $o->value = Video::STATUS_ACTIVE; } $obj->defaultVideoStatus = $o; self::addDataObjectHelper('defaultVideoStatus', 'Default video status', 'When you submit a video that will be the default status'); @@ -840,11 +840,11 @@ Disallow: *action=tagsearch* $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $transferStatus = []; - $transferStatus[] = Video::$statusActive; - $transferStatus[] = Video::$statusFansOnly; - $transferStatus[] = Video::$statusScheduledReleaseDate; - $transferStatus[] = Video::$statusUnlisted; - $transferStatus[] = Video::$statusUnlistedButSearchable; + $transferStatus[] = Video::STATUS_ACTIVE; + $transferStatus[] = Video::STATUS_FANS_ONLY; + $transferStatus[] = Video::STATUS_SCHEDULED_RELEASE_DATE; + $transferStatus[] = Video::STATUS_UNLISTED; + $transferStatus[] = Video::STATUS_UNLISTED_BUT_SEARCHABLE; if ($res != false) { foreach ($fullData as $key => $row) { diff --git a/plugin/MobileManager/upload.php b/plugin/MobileManager/upload.php index 4da406e2c0..1aa6221a6a 100644 --- a/plugin/MobileManager/upload.php +++ b/plugin/MobileManager/upload.php @@ -100,7 +100,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $video->setVideo_password($_REQUEST['video_password']); } if ($type == "image") { - $video->setStatus(Video::$statusActive); + $video->setStatus(Video::STATUS_ACTIVE); make_path($paths['path']); $file = "{$paths['path']}{$paths['filename']}.{$extension}"; if (!move_uploaded_file($_FILES['upl']['tmp_name'], $file)) { @@ -112,7 +112,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $object->msg = "your image was posted"; $object->videos_id = $video->save(); } else { - $video->setStatus(Video::$statusEncoding); + $video->setStatus(Video::STATUS_ENCODING); if (!move_uploaded_file($_FILES['upl']['tmp_name'], Video::getStoragePath() . "original_" . $filename)) { $object->msg = "Error on move_uploaded_file(" . $_FILES['upl']['tmp_name'] . ", " . Video::getStoragePath() . "original_" . $filename . ")"; diff --git a/plugin/PlayerSkins/epg.php b/plugin/PlayerSkins/epg.php index 0292161664..5a4f2ec733 100644 --- a/plugin/PlayerSkins/epg.php +++ b/plugin/PlayerSkins/epg.php @@ -42,7 +42,7 @@ $videos_id = intval(@$_REQUEST['videos_id']); $_GET['rowCount'] = $_REQUEST['rowCount'] = 500; $videos = Video::getAllActiveEPGs(); foreach ($videos as $video) { - if ($video['status'] !== Video::$statusActive || !isValidURL($video['epg_link'])) { + if ($video['status'] !== Video::STATUS_ACTIVE || !isValidURL($video['epg_link'])) { continue; } //if($video['id']=='3847'){ var_dump($video['status']);exit;} @@ -312,7 +312,7 @@ function createEPG($channel) { if($_stopTime<$nowTime){ continue; } - * + * */ $minutes = getDurationInMinutes($program['start'], $program['stop']); /** diff --git a/plugin/Scheduler/Scheduler.php b/plugin/Scheduler/Scheduler.php index 95004d0d97..be224d095a 100644 --- a/plugin/Scheduler/Scheduler.php +++ b/plugin/Scheduler/Scheduler.php @@ -411,7 +411,7 @@ class Scheduler extends PluginAbstract $e->setExecuted($videos_id); } - //$status = $video->setStatus(Video::$statusActive); + //$status = $video->setStatus(Video::STATUS_ACTIVE); $status = $video->setStatus($advancedCustom->defaultVideoStatus->value); return $status; @@ -456,11 +456,11 @@ class Scheduler extends PluginAbstract $video = new Video('', '', $videos_id); if ($releaseTime > time()) { $releaseDateTime = date('Y-m-d H:i:s', $releaseTime); - $video->setStatus(Video::$statusScheduledReleaseDate); + $video->setStatus(Video::STATUS_SCHEDULED_RELEASE_DATE); self::setReleaseDateTime($videos_id, $releaseDateTime, $releaseTime); self::addVideoToRelease($releaseDateTime, $releaseTime, $videos_id); return true; - } else if ($video->getStatus() == Video::$statusScheduledReleaseDate) { + } else if ($video->getStatus() == Video::STATUS_SCHEDULED_RELEASE_DATE) { self::releaseVideosNow($videos_id); } } @@ -562,7 +562,7 @@ class Scheduler extends PluginAbstract function executeEveryMinute() { - $rows = Video::getAllVideosLight(Video::$statusScheduledReleaseDate); + $rows = Video::getAllVideosLight(Video::STATUS_SCHEDULED_RELEASE_DATE); foreach ($rows as $key => $value) { $releaseDate = self::getReleaseDateTime($value['id']); if (empty($releaseDate) || strtotime($releaseDate) <= time()) { diff --git a/view/managerVideos_body.php b/view/managerVideos_body.php index 360b25c243..8790401244 100644 --- a/view/managerVideos_body.php +++ b/view/managerVideos_body.php @@ -458,10 +458,10 @@ if (empty($advancedCustom)) { $statusSearchFilter = array(); } if (AVideoPlugin::isEnabled('FansSubscriptions')) { - $statusSearchFilter[] = Video::$statusFansOnly; + $statusSearchFilter[] = Video::STATUS_FANS_ONLY; } if (AVideoPlugin::isEnabled('SendRecordedToEncoder')) { - $statusSearchFilter[] = Video::$statusRecording; + $statusSearchFilter[] = Video::STATUS_RECORDING; } foreach (Video::$statusDesc as $key => $value) { if (!in_array($key, $statusSearchFilter)) { @@ -1277,7 +1277,7 @@ if (empty($advancedCustom->disableHTMLDescription)) { $('#videoStartSeconds').val('00:00:00'); $('#videoSkipIntroSecond').val('00:00:00'); $('#inputVideoPassword').val(""); - $('#videoStatus').val(''); + $('#videoStatus').val(''); $('#inputCleanTitle').val(""); $('#created').val(""); $('#inputDescription').val(""); diff --git a/view/mini-upload-form/upload.php b/view/mini-upload-form/upload.php index 34cab6aba3..e9f08f4341 100644 --- a/view/mini-upload-form/upload.php +++ b/view/mini-upload-form/upload.php @@ -46,7 +46,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $filename = $video->getFilename(); if ($video->getTitle() === "Video automatically booked") { $video->setTitle($title); - $video->setStatus(Video::$statusInactive); + $video->setStatus(Video::STATUS_INACTIVE); } } //var_dump($videos_id, $_FILES['upl']['name'], $title, $video->getTitle());exit; @@ -101,7 +101,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $video->setType("zip", true); } - $video->setAutoStatus(Video::$statusInactive); + $video->setAutoStatus(Video::STATUS_INACTIVE); $id = $video->save(); if ($id) { @@ -113,7 +113,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $tmp_name = $_FILES['upl']['tmp_name']; $filenameMP4 = $filename . "." . $extension; decideMoveUploadedToVideos($tmp_name, $filenameMP4, $video->getType()); - + $obj->title = $video->getTitle(); $obj->error = false; $obj->filename = $filename; @@ -139,7 +139,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { if (!empty($_FILES['upl']['tmp_name'])) { $obj->lines[] = __LINE__; - $video->setAutoStatus(Video::$statusActive); + $video->setAutoStatus(Video::STATUS_ACTIVE); AVideoPlugin::onUploadIsDone($obj->videos_id); AVideoPlugin::afterNewVideo($obj->videos_id); } diff --git a/view/modeYoutube.php b/view/modeYoutube.php index 5100a43569..67d3437b54 100644 --- a/view/modeYoutube.php +++ b/view/modeYoutube.php @@ -344,9 +344,9 @@ TimeLogEnd($timeLogNameMY, __LINE__, $TimeLogLimitMY); if (empty($video)) { if (!empty($_GET['v'])) { $vid = new Video('', '', $_GET['v']); - if ($vid->getStatus() === Video::$statusBrokenMissingFiles) { + if ($vid->getStatus() === Video::STATUS_BROKEN_MISSING_FILES) { if (!Video::isMediaFileMissing($vid->getFilename())) { - $vid->setStatus(Video::$statusActive); + $vid->setStatus(Video::STATUS_ACTIVE); $vid->save(); _error_log('Missing files recovered ' . $_GET['v']); } else { @@ -359,7 +359,7 @@ if (empty($video)) { } exit; } - } else if ($vid->getStatus() === Video::$statusUnpublished) { + } else if ($vid->getStatus() === Video::STATUS_UNPUBLISHED) { $msg = 'This video is currently unpublished. Please contact an administrator to review and approve it for publication. Thank you for your patience and understanding.'; videoNotFound($msg); exit;