1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 17:59:55 +02:00

allow download per category

add an option to decide what category can be downloaded and what can not
This commit is contained in:
daniel 2019-10-31 13:46:31 -03:00
parent 1df01c93e4
commit 7d90140d8a
8 changed files with 46 additions and 8 deletions

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit; exit;
} }
$installationVersion = "7.7"; $installationVersion = "7.8";
header('Content-Type: application/json'); header('Content-Type: application/json');

View file

@ -73,6 +73,7 @@ CREATE TABLE IF NOT EXISTS `categories` (
`iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder', `iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder',
`users_id` INT(11) NOT NULL DEFAULT 1, `users_id` INT(11) NOT NULL DEFAULT 1,
`private` TINYINT(1) NULL DEFAULT 0, `private` TINYINT(1) NULL DEFAULT 0,
`allow_download` TINYINT(1) NULL DEFAULT 1,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `fk_categories_users1_idx` (`users_id` ASC), INDEX `fk_categories_users1_idx` (`users_id` ASC),
UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC), UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC),

View file

@ -21,6 +21,7 @@ class Category {
private $type; private $type;
private $users_id; private $users_id;
private $private; private $private;
private $allow_download;
function getUsers_id() { function getUsers_id() {
if (empty($this->users_id)) { if (empty($this->users_id)) {
@ -157,9 +158,9 @@ class Category {
. "parentId = ?," . "parentId = ?,"
. "iconClass = ?," . "iconClass = ?,"
. "users_id = ?," . "users_id = ?,"
. "`private` = ?, modified = now() WHERE id = ?"; . "`private` = ?, allow_download = ?, modified = now() WHERE id = ?";
$format = "sssiisiii"; $format = "sssiisiiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->id); $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->id);
} else { } else {
$sql = "INSERT INTO categories ( " $sql = "INSERT INTO categories ( "
. "name," . "name,"
@ -169,9 +170,9 @@ class Category {
. "parentId," . "parentId,"
. "iconClass, " . "iconClass, "
. "users_id, " . "users_id, "
. "`private`, created, modified) VALUES (?, ?,?,?,?,?,?,?,now(), now())"; . "`private`, allow_download, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,now(), now())";
$format = "sssiisii"; $format = "sssiisiii";
$values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate()); $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download());
} }
$insert_row = sqlDAL::writeSql($sql, $format, $values); $insert_row = sqlDAL::writeSql($sql, $format, $values);
@ -528,4 +529,14 @@ class Category {
return $this->description; return $this->description;
} }
function getAllow_download() {
return $this->allow_download;
}
function setAllow_download($allow_download) {
$this->allow_download = intval($allow_download);
}
} }

View file

@ -19,6 +19,7 @@ $obj->setIconClass($_POST['iconClass']);
$obj->setNextVideoOrder($_POST['nextVideoOrder']); $obj->setNextVideoOrder($_POST['nextVideoOrder']);
$obj->setParentId($_POST['parentId']); $obj->setParentId($_POST['parentId']);
$obj->setPrivate($_POST['private']); $obj->setPrivate($_POST['private']);
$obj->setAllow_download($_POST['allow_download']);

View file

@ -216,6 +216,10 @@ class CustomizeUser extends PluginAbstract {
if (!self::canDownloadVideosFromUser($users_id)) { if (!self::canDownloadVideosFromUser($users_id)) {
return false; return false;
} }
$category = new Category($video->getCategories_id());
if(is_object($category) && !$category->getAllow_download()){
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) { if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
if (empty($video->getCan_download())) { if (empty($video->getCan_download())) {

0
plugin/TheaterButton/TheaterButton.php Executable file → Normal file
View file

View file

@ -0,0 +1,14 @@
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
ALTER TABLE `categories`
ADD COLUMN `allow_download` TINYINT(1) NULL DEFAULT 1;
UPDATE configurations SET version = '7.8', modified = now() WHERE id = 1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

View file

@ -16,6 +16,7 @@
<th data-column-id="private" data-formatter="private"><?php echo __("Private"); ?></th> <th data-column-id="private" data-formatter="private"><?php echo __("Private"); ?></th>
<th data-column-id="owner"><?php echo __("Owner"); ?></th> <th data-column-id="owner"><?php echo __("Owner"); ?></th>
<th data-column-id="total" data-sortable="false"><?php echo __("Total Videos"); ?></th> <th data-column-id="total" data-sortable="false"><?php echo __("Total Videos"); ?></th>
<th data-column-id="allow_download" ><?php echo __("Can Download"); ?></th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false"></th> <th data-column-id="commands" data-formatter="commands" data-sortable="false"></th>
</tr> </tr>
</thead> </thead>
@ -42,6 +43,11 @@
<option value="0"><?php echo __("Public"); ?></option> <option value="0"><?php echo __("Public"); ?></option>
<option value="1"><?php echo __("Private"); ?></option> <option value="1"><?php echo __("Private"); ?></option>
</select> </select>
<label><?php echo __("Allow Download"); ?></label>
<select class="form-control" id="allow_download">
<option value="1"><?php echo __("Yes"); ?></option>
<option value="0"><?php echo __("No"); ?></option>
</select>
<label><?php echo __("Autoplay next-video-order"); ?></label> <label><?php echo __("Autoplay next-video-order"); ?></label>
<select class="form-control" id="inputNextVideoOrder"> <select class="form-control" id="inputNextVideoOrder">
<option value="0"><?php echo __("Random"); ?></option> <option value="0"><?php echo __("Random"); ?></option>
@ -192,6 +198,7 @@
$('#inputDescription').val(row.description); $('#inputDescription').val(row.description);
$('#inputNextVideoOrder').val(row.nextVideoOrder); $('#inputNextVideoOrder').val(row.nextVideoOrder);
$('#inputPrivate').val(row.private); $('#inputPrivate').val(row.private);
$('#allow_download').val(row.allow_download);
$('#inputParentId').val(row.parentId); $('#inputParentId').val(row.parentId);
$('#inputType').val(row.type); $('#inputType').val(row.type);
$(".iconCat i").attr("class", row.iconClass); $(".iconCat i").attr("class", row.iconClass);
@ -260,7 +267,7 @@
modal.showPleaseWait(); modal.showPleaseWait();
$.ajax({ $.ajax({
url: '<?php echo $global['webSiteRootURL'] . "objects/categoryAddNew.json.php"; ?>', url: '<?php echo $global['webSiteRootURL'] . "objects/categoryAddNew.json.php"; ?>',
data: {"id": $('#inputCategoryId').val(), "name": $('#inputName').val(), "clean_name": $('#inputCleanName').val(), "description": $('#inputDescription').val(), "nextVideoOrder": $('#inputNextVideoOrder').val(), "private": $('#inputPrivate').val(), "parentId": $('#inputParentId').val(), "type": $('#inputType').val(), "iconClass": $(".iconCat i").attr("class")}, data: {"id": $('#inputCategoryId').val(), "name": $('#inputName').val(), "clean_name": $('#inputCleanName').val(), "description": $('#inputDescription').val(), "nextVideoOrder": $('#inputNextVideoOrder').val(), "private": $('#inputPrivate').val(), "allow_download": $('#allow_download').val(), "parentId": $('#inputParentId').val(), "type": $('#inputType').val(), "iconClass": $(".iconCat i").attr("class")},
type: 'post', type: 'post',
success: function (response) { success: function (response) {
if (response.status) { if (response.status) {