1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/objects/videoSuggest.php
2023-02-15 23:22:37 +08:00

35 lines
859 B
PHP

<?php
header('Content-Type: application/json');
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
$obj = new stdClass();
$obj->msg = '';
$obj->error = true;
$obj->idsToSave = [];
$obj->idSaved = [];
require_once $global['systemRootPath'] . 'objects/user.php';
if (!Permissions::canModerateVideos()) {
forbiddenPage('Permission denied');
}
require_once $global['systemRootPath'] . 'objects/video.php';
if (!is_array($_POST['id'])) {
$obj->idsToSave = [$_POST['id']];
}else{
$obj->idsToSave = $_POST['id'];
}
foreach ($obj->idsToSave as $value) {
$video = new Video('', '', $value);
$video->setIsSuggested($_POST['isSuggested']);
$obj->idSaved[] = $video->save();
}
if(!empty($obj->idSaved)){
$obj->error = false;
clearCache(true);
}
echo _json_encode($obj);