Feature: Edit sharing properties of album
This commit is contained in:
parent
389142385d
commit
87537eba2d
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -111,7 +111,7 @@ class Admin extends Access {
|
||||
|
||||
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'], $_POST['downloadable']);
|
||||
echo $album->setPublic($_POST['public'], $_POST['password'], $_POST['visible'], $_POST['downloadable']);
|
||||
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ class Album extends Module {
|
||||
|
||||
}
|
||||
|
||||
public function setPublic($password, $visible, $downloadable) {
|
||||
public function setPublic($public, $password, $visible, $downloadable) {
|
||||
|
||||
# Check dependencies
|
||||
self::dependencies(isset($this->database, $this->albumIDs));
|
||||
@ -506,23 +506,13 @@ class Album extends Module {
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get public
|
||||
$query = Database::prepare($this->database, "SELECT id, public FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
|
||||
$albums = $this->database->query($query);
|
||||
|
||||
while ($album = $albums->fetch_object()) {
|
||||
|
||||
# Invert public
|
||||
$public = ($album->public=='0' ? 1 : 0);
|
||||
|
||||
# Convert visible
|
||||
$visible = ($visible==='true' ? 1 : 0);
|
||||
|
||||
# Convert downloadable
|
||||
$downloadable = ($downloadable==='true' ? 1 : 0);
|
||||
# Convert values
|
||||
$public = ($public==='1' ? 1 : 0);
|
||||
$visible = ($visible==='1' ? 1 : 0);
|
||||
$downloadable = ($downloadable==='1' ? 1 : 0);
|
||||
|
||||
# Set public
|
||||
$query = Database::prepare($this->database, "UPDATE ? SET public = '?', visible = '?', downloadable = '?', password = NULL WHERE id = '?'", array(LYCHEE_TABLE_ALBUMS, $public, $visible, $downloadable, $album->id));
|
||||
$query = Database::prepare($this->database, "UPDATE ? SET public = '?', visible = '?', downloadable = '?', password = NULL WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $public, $visible, $downloadable, $this->albumIDs));
|
||||
$result = $this->database->query($query);
|
||||
if (!$result) {
|
||||
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
||||
@ -531,7 +521,7 @@ class Album extends Module {
|
||||
|
||||
# Reset permissions for photos
|
||||
if ($public===1) {
|
||||
$query = Database::prepare($this->database, "UPDATE ? SET public = 0 WHERE album = '?'", array(LYCHEE_TABLE_PHOTOS, $album->id));
|
||||
$query = Database::prepare($this->database, "UPDATE ? SET public = 0 WHERE album IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
|
||||
$result = $this->database->query($query);
|
||||
if (!$result) {
|
||||
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
||||
@ -539,8 +529,6 @@ class Album extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
|
||||
|
@ -375,33 +375,41 @@ album.setDescription = function(albumID) {
|
||||
|
||||
}
|
||||
|
||||
album.setPublic = function(albumID, e) {
|
||||
album.setPublic = function(albumID, modal, e) {
|
||||
|
||||
var params,
|
||||
password = '',
|
||||
listed = false,
|
||||
downloadable = false;
|
||||
password = '';
|
||||
|
||||
albums.refresh();
|
||||
|
||||
if (!basicModal.visible()&&album.json.public==='0') {
|
||||
if (modal===true) {
|
||||
|
||||
var msg = '',
|
||||
action;
|
||||
let msg = '',
|
||||
text = '',
|
||||
action = {};
|
||||
|
||||
action = function() {
|
||||
action.fn = function() {
|
||||
|
||||
basicModal.close();
|
||||
album.setPublic(album.getID(), e);
|
||||
// Current function without showing the modal
|
||||
album.setPublic(album.getID(), false, e);
|
||||
|
||||
};
|
||||
|
||||
// Album public = Editing a shared album
|
||||
if (album.json.public==='1') {
|
||||
action.title = 'Edit Sharing';
|
||||
text = 'The sharing-properties of this album will be changed to the following:';
|
||||
} else {
|
||||
action.title = 'Share Album';
|
||||
text = 'This album will be shared with the following properties:';
|
||||
}
|
||||
|
||||
msg = `
|
||||
<p class='less'>This album will be shared with the following properties:</p>
|
||||
<p class='less'>${ text }</p>
|
||||
<form>
|
||||
<div class='choice'>
|
||||
<label>
|
||||
<input type='checkbox' name='listed' checked>
|
||||
<input type='checkbox' name='visible'>
|
||||
<span class='checkbox'>${ build.iconic('check') }</span>
|
||||
<span class='label'>Visible</span>
|
||||
</label>
|
||||
@ -431,8 +439,8 @@ album.setPublic = function(albumID, e) {
|
||||
body: msg,
|
||||
buttons: {
|
||||
action: {
|
||||
title: 'Share Album',
|
||||
fn: action
|
||||
title: action.title,
|
||||
fn: action.fn
|
||||
},
|
||||
cancel: {
|
||||
title: 'Cancel',
|
||||
@ -441,6 +449,11 @@ album.setPublic = function(albumID, e) {
|
||||
}
|
||||
});
|
||||
|
||||
// Active visible by default (public = 0)
|
||||
if ((album.json.public==='1'&&album.json.visible==='1')||
|
||||
(album.json.public==='0')) $('.basicModal .choice input[name="visible"]').click();
|
||||
if (album.json.downloadable==='1') $('.basicModal .choice input[name="downloadable"]').click();
|
||||
|
||||
$('.basicModal .choice input[name="password"]').on('change', function() {
|
||||
|
||||
if ($(this).prop('checked')===true) $('.basicModal .choice input[data-name="password"]').show().focus();
|
||||
@ -452,8 +465,20 @@ album.setPublic = function(albumID, e) {
|
||||
|
||||
}
|
||||
|
||||
// Set data
|
||||
if (basicModal.visible()) {
|
||||
|
||||
// Visible modal => Set album public
|
||||
album.json.public = '1';
|
||||
|
||||
// Set visible
|
||||
if ($('.basicModal .choice input[name="visible"]:checked').length===1) album.json.visible = '1';
|
||||
else album.json.visible = '0';
|
||||
|
||||
// Set downloadable
|
||||
if ($('.basicModal .choice input[name="downloadable"]:checked').length===1) album.json.downloadable = '1';
|
||||
else album.json.downloadable = '0';
|
||||
|
||||
// Set password
|
||||
if ($('.basicModal .choice input[name="password"]:checked').length===1) {
|
||||
password = $('.basicModal .choice input[data-name="password"]').val();
|
||||
@ -463,28 +488,26 @@ album.setPublic = function(albumID, e) {
|
||||
album.json.password = '0';
|
||||
}
|
||||
|
||||
// Set downloadable
|
||||
if ($('.basicModal .choice input[name="downloadable"]:checked').length===1) {
|
||||
downloadable = true;
|
||||
album.json.downloadable = '1';
|
||||
// Modal input has been processed, now it can be closed
|
||||
basicModal.close();
|
||||
|
||||
} else {
|
||||
downloadable = false;
|
||||
album.json.downloadable = '0';
|
||||
}
|
||||
|
||||
if ($('.basicModal .choice input[name="listed"]:checked').length===1) listed = true;
|
||||
// Modal not visible => Set album private
|
||||
album.json.public = '0';
|
||||
|
||||
}
|
||||
|
||||
// Set data and refresh view
|
||||
if (visible.album()) {
|
||||
|
||||
album.json.public = (album.json.public==='0') ? '1' : '0';
|
||||
album.json.password = (album.json.public==='0') ? '0' : album.json.password;
|
||||
album.json.visible = (album.json.public==='0') ? '0' : album.json.visible;
|
||||
album.json.downloadable = (album.json.public==='0') ? '0' : album.json.downloadable;
|
||||
album.json.password = (album.json.public==='0') ? '0' : album.json.password;
|
||||
|
||||
view.album.public();
|
||||
view.album.password();
|
||||
view.album.downloadable();
|
||||
view.album.password();
|
||||
|
||||
if (album.json.public==='1') contextMenu.shareAlbum(albumID, e);
|
||||
|
||||
@ -492,9 +515,10 @@ album.setPublic = function(albumID, e) {
|
||||
|
||||
params = {
|
||||
albumID,
|
||||
password,
|
||||
visible: listed,
|
||||
downloadable
|
||||
public: album.json.public,
|
||||
password: password,
|
||||
visible: album.json.visible,
|
||||
downloadable: album.json.downloadable
|
||||
}
|
||||
|
||||
api.post('Album::setPublic', params, function(data) {
|
||||
|
@ -274,7 +274,8 @@ contextMenu.shareAlbum = function(albumID, e) {
|
||||
{ type: 'item', title: build.iconic('facebook', file, file) + 'Facebook', fn: function() { album.share(1) } },
|
||||
{ type: 'item', title: build.iconic('envelope-closed') + 'Mail', fn: function() { album.share(2) } },
|
||||
{ type: 'separator' },
|
||||
{ type: 'item', title: build.iconic('ban') + 'Make Private', fn: function() { album.setPublic(albumID) } }
|
||||
{ type: 'item', title: build.iconic('pencil') + 'Edit Sharing', fn: function() { album.setPublic(albumID, true, e) } },
|
||||
{ type: 'item', title: build.iconic('ban') + 'Make Private', fn: function() { album.setPublic(albumID, false) } }
|
||||
];
|
||||
|
||||
basicContext.show(items, e);
|
||||
|
Loading…
Reference in New Issue
Block a user