Skip to content

Commit

Permalink
allow download per category
Browse files Browse the repository at this point in the history
add an option to decide what category can be downloaded and what can not
  • Loading branch information
daniel authored and daniel committed Oct 31, 2019
1 parent 1df01c9 commit 7d90140
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion install/checkConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
exit;
}

$installationVersion = "7.7";
$installationVersion = "7.8";


header('Content-Type: application/json');
Expand Down
1 change: 1 addition & 0 deletions install/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ CREATE TABLE IF NOT EXISTS `categories` (
`iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder',
`users_id` INT(11) NOT NULL DEFAULT 1,
`private` TINYINT(1) NULL DEFAULT 0,
`allow_download` TINYINT(1) NULL DEFAULT 1,
PRIMARY KEY (`id`),
INDEX `fk_categories_users1_idx` (`users_id` ASC),
UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC),
Expand Down
23 changes: 17 additions & 6 deletions objects/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Category {
private $type;
private $users_id;
private $private;
private $allow_download;

function getUsers_id() {
if (empty($this->users_id)) {
Expand Down Expand Up @@ -157,9 +158,9 @@ function save($allowOfflineUser = false) {
. "parentId = ?,"
. "iconClass = ?,"
. "users_id = ?,"
. "`private` = ?, modified = now() WHERE id = ?";
$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(), $this->id);
. "`private` = ?, allow_download = ?, modified = now() WHERE id = ?";
$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->getAllow_download(), $this->id);
} else {
$sql = "INSERT INTO categories ( "
. "name,"
Expand All @@ -169,9 +170,9 @@ function save($allowOfflineUser = false) {
. "parentId,"
. "iconClass, "
. "users_id, "
. "`private`, created, modified) VALUES (?, ?,?,?,?,?,?,?,now(), now())";
$format = "sssiisii";
$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());
. "`private`, allow_download, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,now(), now())";
$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(), $this->getAllow_download());
}

$insert_row = sqlDAL::writeSql($sql, $format, $values);
Expand Down Expand Up @@ -527,5 +528,15 @@ function getClean_name() {
function getDescription() {
return $this->description;
}

function getAllow_download() {
return $this->allow_download;
}

function setAllow_download($allow_download) {
$this->allow_download = intval($allow_download);
}



}
1 change: 1 addition & 0 deletions objects/categoryAddNew.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$obj->setNextVideoOrder($_POST['nextVideoOrder']);
$obj->setParentId($_POST['parentId']);
$obj->setPrivate($_POST['private']);
$obj->setAllow_download($_POST['allow_download']);



Expand Down
4 changes: 4 additions & 0 deletions plugin/CustomizeUser/CustomizeUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ static function canDownloadVideosFromVideo($videos_id) {
if (!self::canDownloadVideosFromUser($users_id)) {
return false;
}
$category = new Category($video->getCategories_id());
if(is_object($category) && !$category->getAllow_download()){
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
if (empty($video->getCan_download())) {
Expand Down
Empty file modified plugin/TheaterButton/TheaterButton.php
100755 → 100644
Empty file.
14 changes: 14 additions & 0 deletions updatedb/updateDb.v7.8.sql
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 8 additions & 1 deletion view/managerCategories_body.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<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="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>
</tr>
</thead>
Expand All @@ -42,6 +43,11 @@
<option value="0"><?php echo __("Public"); ?></option>
<option value="1"><?php echo __("Private"); ?></option>
</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>
<select class="form-control" id="inputNextVideoOrder">
<option value="0"><?php echo __("Random"); ?></option>
Expand Down Expand Up @@ -192,6 +198,7 @@ function refreshSubCategoryList() {
$('#inputDescription').val(row.description);
$('#inputNextVideoOrder').val(row.nextVideoOrder);
$('#inputPrivate').val(row.private);
$('#allow_download').val(row.allow_download);
$('#inputParentId').val(row.parentId);
$('#inputType').val(row.type);
$(".iconCat i").attr("class", row.iconClass);
Expand Down Expand Up @@ -260,7 +267,7 @@ function () {
modal.showPleaseWait();
$.ajax({
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',
success: function (response) {
if (response.status) {
Expand Down

0 comments on commit 7d90140

Please sign in to comment.