New sharing dialog

Choose if album should be listed public or not #177
pull/208/head
Tobias Reich 10 years ago
parent abc7c9233d
commit cf9ad486f0

@ -179,7 +179,8 @@
/* Radio Buttons ------------------------------------------------*/
.message .choice {
float: left;
padding: 12px 5% 15px;
margin: 12px 5%;
width: 90%;
color: #fff;
}

@ -285,15 +285,17 @@ album = {
setPublic: function(albumID, e) {
var params;
var params,
password = "",
listed = false;
if (!visible.message()&&album.json.public==0) {
modal.show("Share Album", "This album will be shared with one of the following properties:</p><form><div class='choice'><input type='radio' value='public' name='choice' checked><h2>Public</h2><p>Visible and accessible for everyone.</p></div><div class='choice'><input type='radio' value='password' name='choice'><h2>Password protected</h2><p>Not visible to visitors and 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 one of 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);
$(".message .choice input:radio").on("change", function() {
$(".message .choice input[name='password']").on("change", function() {
if ($(this).val()==="password") $(".message .choice input.text").show();
if ($(this).prop('checked')===true) $(".message .choice input.text").show();
else $(".message .choice input.text").hide();
});
@ -302,18 +304,22 @@ album = {
}
if (visible.message()&&$(".message .choice input:checked").val()==="password") {
params = "setAlbumPublic&albumID=" + albumID + "&password=" + md5($(".message input.text").val());
album.json.password = true;
if (visible.message()) {
} else {
if ($(".message .choice input[name='password']:checked").val()==="password") {
password = md5($(".message input.text").val());
album.json.password = true;
} else {
password = "";
album.json.password = false;
}
params = "setAlbumPublic&albumID=" + albumID + "&password=";
album.json.password = false;
if ($(".message .choice input[name='listed']:checked").val()==="listed") listed = true;
}
params = "setAlbumPublic&albumID=" + albumID + "&password=" + password + "&visible=" + listed;
if (visible.album()) {
album.json.public = (album.json.public==0) ? 1 : 0;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

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

Loading…
Cancel
Save