Added downloadable to database and backend

This commit is contained in:
Tobias Reich 2014-08-09 17:57:31 +02:00
parent 8f28f99527
commit b23360d6ce
7 changed files with 40 additions and 8 deletions

View File

@ -287,7 +287,8 @@ album = {
var params,
password = "",
listed = false;
listed = false,
downloadable = false;
if (!visible.message()&&album.json.public==0) {
@ -315,10 +316,11 @@ album = {
}
if ($(".message .choice input[name='listed']:checked").val()==="listed") listed = true;
if ($(".message .choice input[name='downloadable']:checked").val()==="downloadable") downloadable = true;
}
params = "setAlbumPublic&albumID=" + albumID + "&password=" + password + "&visible=" + listed;
params = "setAlbumPublic&albumID=" + albumID + "&password=" + password + "&visible=" + listed + "&downloadable=" + downloadable;
if (visible.album()) {

File diff suppressed because one or more lines are too long

View File

@ -109,9 +109,9 @@ class Admin extends Access {
private function setAlbumPublic() {
Module::dependencies(isset($_POST['albumID'], $_POST['password'], $_POST['visible']));
Module::dependencies(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']));
$album = new Album($this->database, $this->plugins, $this->settings, $_POST['albumID']);
echo $album->setPublic($_POST['password'], $_POST['visible']);
echo $album->setPublic($_POST['password'], $_POST['visible'], $_POST['downloadable']);
}

View File

@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `lychee_albums` (
`sysstamp` int(11) NOT NULL,
`public` tinyint(1) NOT NULL DEFAULT '0',
`visible` tinyint(1) NOT NULL DEFAULT '1',
`downloadable` tinyint(1) NOT NULL DEFAULT '0',
`password` varchar(100) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

View File

@ -0,0 +1,25 @@
<?php
###
# @name Update to version 2.6.1
# @author Tobias Reich
# @copyright 2014 by Tobias Reich
###
# Add `downloadable`
if (!$database->query("SELECT `downloadable` FROM `lychee_albums` LIMIT 1;")) {
$result = $database->query("ALTER TABLE `lychee_albums` ADD `downloadable` TINYINT(1) NOT NULL DEFAULT 0");
if (!$result) {
Log::error($database, 'update_020601', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
}
# Set version
$result = $database->query("UPDATE lychee_settings SET value = '020601' WHERE `key` = 'version';");
if (!$result) {
Log::error($database, 'update_020601', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
?>

View File

@ -441,7 +441,7 @@ class Album extends Module {
}
public function setPublic($password, $visible) {
public function setPublic($password, $visible, $downloadable) {
# Check dependencies
self::dependencies(isset($this->database, $this->albumIDs));
@ -460,8 +460,11 @@ class Album extends Module {
# Convert visible
$visible = ($visible==='true' ? 1 : 0);
# Convert downloadable
$downloadable = ($downloadable==='true' ? 1 : 0);
# Set public
$result = $this->database->query("UPDATE lychee_albums SET public = '$public', visible = '$visible', password = NULL WHERE id = '$album->id';");
$result = $this->database->query("UPDATE lychee_albums SET public = '$public', visible = '$visible', downloadable = '$downloadable', password = NULL WHERE id = '$album->id';");
if (!$result) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
return false;

View File

@ -47,7 +47,8 @@ class Database extends Module {
'020101', #2.1.1
'020200', #2.2
'020500', #2.5
'020505' #2.5.5
'020505', #2.5.5
'020601' #2.6.1
);
# For each update