Merge pull request #208 from electerious/downloadable

v2.6.1
This commit is contained in:
Tobias Reich 2014-08-22 20:31:09 +02:00
commit 91159a5062
17 changed files with 121 additions and 52 deletions

View File

@ -287,11 +287,12 @@ album = {
var params,
password = "",
listed = false;
listed = false,
downloadable = false;
if (!visible.message()&&album.json.public==0) {
modal.show("Share Album", "This album will be shared with the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]], -160);
modal.show("Share Album", "This album will be shared with the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='downloadable' value='downloadable'><h2>Downloadable</h2><p>Visitors of your Lychee can download this album.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]], -170);
$(".message .choice input[name='password']").on("change", function() {
@ -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()) {

View File

@ -309,13 +309,13 @@ build = {
switch (photoJSON.public) {
case "0":
public = "Private";
public = "No";
break;
case "1":
public = "Public";
public = "Yes";
break;
case "2":
public = "Public (Album)";
public = "Yes (Album)";
break;
default:
public = "-";
@ -354,7 +354,7 @@ build = {
infos = infos.concat([
["", "Share"],
["Visibility", public]
["Public", public]
]);
$.each(infos, function(index) {
@ -401,8 +401,9 @@ build = {
if (!albumJSON) return "";
var infobox = "",
public,
password,
public = "-",
password = "-",
downloadable = "-",
editTitleHTML,
editDescriptionHTML,
infos;
@ -412,13 +413,10 @@ build = {
switch (albumJSON.public) {
case "0":
public = "Private";
public = "No";
break;
case "1":
public = "Public";
break;
default:
public = "-";
public = "Yes";
break;
}
@ -429,8 +427,14 @@ build = {
case true:
password = "Yes";
break;
default:
password = "-";
}
switch (albumJSON.downloadable) {
case "0":
downloadable = "No";
break;
case "1":
downloadable = "Yes";
break;
}
@ -445,7 +449,8 @@ build = {
["Created", albumJSON.sysdate],
["Images", albumJSON.num],
["", "Share"],
["Visibility", public],
["Public", public],
["Downloadable", downloadable],
["Password", password]
];

View File

@ -223,10 +223,8 @@ contextMenu = {
function() { photo.getArchive(photoID) }
];
items = [
["<a class='icon-resize-full'></a> Full Photo", 0],
["<a class='icon-circle-arrow-down'></a> Download", 1]
];
items = [["<a class='icon-resize-full'></a> Full Photo", 0]];
if ((album.json&&album.json.downloadable&&album.json.downloadable==="1"&&lychee.publicMode)||!lychee.publicMode) items.push(["<a class='icon-circle-arrow-down'></a> Download", 1]);
contextMenu.show(items, mouse_x, mouse_y, "right");

View File

@ -8,8 +8,8 @@
var lychee = {
title: "",
version: "2.6",
version_code: "020600",
version: "2.6.1",
version_code: "020601",
api_path: "php/api.php",
update_path: "http://lychee.electerious.com/version/index.php",
@ -157,8 +157,11 @@ var lychee = {
goto: function(url) {
if (url===undefined) url = "";
document.location.hash = url;
if (url===undefined) url = "#";
else url = "#" + url;
history.pushState(null, null, url);
lychee.load();
},

View File

@ -64,6 +64,7 @@ view = {
$("#tools_albums, #tools_photo").hide();
$("#tools_album").show();
album.json.content === false ? $("#button_archive").hide() : $("#button_archive").show();
if (lychee.publicMode&&album.json.downloadable==="0") $("#button_archive").hide();
if (albumID==="s"||albumID==="f"||albumID==="r") {
$("#button_info_album, #button_trash_album, #button_share_album").hide();
} else if (albumID==="0") {
@ -237,12 +238,6 @@ view = {
},
description: function() {
$("#infobox .attr_description").html(album.json.description + " " + build.editIcon("edit_description_album"));
},
content: {
init: function() {
@ -307,6 +302,12 @@ view = {
},
description: function() {
$("#infobox .attr_description").html(album.json.description + " " + build.editIcon("edit_description_album"));
},
num: function() {
$("#infobox .attr_images").html(album.json.num);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "Lychee",
"dependencies": {
"jQuery": "~2.1.0",
"jQuery": "~2.1.1",
"js-md5": "~1.1.0",
"mousetrap": "~1.4.6"
}

View File

@ -1,6 +1,6 @@
{
"name": "Lychee",
"version": "2.6.0",
"version": "2.6.1",
"description": "Self-hosted photo-management done right.",
"authors": "Tobias Reich <tobias.reich.ich@gmail.com>",
"license": "MIT",

View File

@ -1,3 +1,11 @@
## v2.6.1
Released August ??, 2014
- `New` Support for IE >= 11 (#148)
- `New` Choose if public album is downloadable or not (#191)
- `Improved` Albums gradient overlay is less harsh (#200)
## v2.6
Released August 16, 2014

View File

@ -16,7 +16,7 @@ If possible, change these settings directly in your `php.ini`. We recommend to i
memory_limit = 256M
#### Which browsers are supported?
Lychee supports the latest versions of Google Chrome, Apple Safari, Mozilla Firefox and Opera. Photos you share with others can be viewed from every browser.
Lychee supports the latest versions of Google Chrome, Apple Safari, Mozilla Firefox, Opera and Microsoft Internet Explorer. Make sure you are always running the newest version.
#### What is new?
Take a look at the [Changelog](Changelog.md) to see what's new.

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

@ -136,7 +136,7 @@ class Guest extends Access {
Module::dependencies(isset($_GET['albumID'], $_GET['password']));
$album = new Album($this->database, $this->plugins, $this->settings, $_GET['albumID']);
if ($album->getPublic()) {
if ($album->getPublic()&&$album->getDownloadable()) {
# Album Public
if ($album->checkPassword($_GET['password'])) $album->getArchive();

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,29 @@ class Album extends Module {
}
public function setPublic($password, $visible) {
public function getDownloadable() {
# Check dependencies
self::dependencies(isset($this->database, $this->albumIDs));
# Call plugins
$this->plugins(__METHOD__, 0, func_get_args());
if ($this->albumIDs==='0'||$this->albumIDs==='s'||$this->albumIDs==='f') return false;
# Execute query
$albums = $this->database->query("SELECT downloadable FROM lychee_albums WHERE id = '$this->albumIDs' LIMIT 1;");
$album = $albums->fetch_object();
# Call plugins
$this->plugins(__METHOD__, 1, func_get_args());
if ($album->downloadable==1) return true;
return false;
}
public function setPublic($password, $visible, $downloadable) {
# Check dependencies
self::dependencies(isset($this->database, $this->albumIDs));
@ -460,8 +482,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