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']));
|
Module::dependencies(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']));
|
||||||
$album = new Album($this->database, $this->plugins, $this->settings, $_POST['albumID']);
|
$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
|
# Check dependencies
|
||||||
self::dependencies(isset($this->database, $this->albumIDs));
|
self::dependencies(isset($this->database, $this->albumIDs));
|
||||||
@ -506,23 +506,13 @@ class Album extends Module {
|
|||||||
# Call plugins
|
# Call plugins
|
||||||
$this->plugins(__METHOD__, 0, func_get_args());
|
$this->plugins(__METHOD__, 0, func_get_args());
|
||||||
|
|
||||||
# Get public
|
# Convert values
|
||||||
$query = Database::prepare($this->database, "SELECT id, public FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
|
$public = ($public==='1' ? 1 : 0);
|
||||||
$albums = $this->database->query($query);
|
$visible = ($visible==='1' ? 1 : 0);
|
||||||
|
$downloadable = ($downloadable==='1' ? 1 : 0);
|
||||||
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);
|
|
||||||
|
|
||||||
# Set public
|
# 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);
|
$result = $this->database->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
||||||
@ -531,7 +521,7 @@ class Album extends Module {
|
|||||||
|
|
||||||
# Reset permissions for photos
|
# Reset permissions for photos
|
||||||
if ($public===1) {
|
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);
|
$result = $this->database->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
||||||
@ -539,8 +529,6 @@ class Album extends Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Call plugins
|
# Call plugins
|
||||||
$this->plugins(__METHOD__, 1, func_get_args());
|
$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,
|
var params,
|
||||||
password = '',
|
password = '';
|
||||||
listed = false,
|
|
||||||
downloadable = false;
|
|
||||||
|
|
||||||
albums.refresh();
|
albums.refresh();
|
||||||
|
|
||||||
if (!basicModal.visible()&&album.json.public==='0') {
|
if (modal===true) {
|
||||||
|
|
||||||
var msg = '',
|
let msg = '',
|
||||||
action;
|
text = '',
|
||||||
|
action = {};
|
||||||
|
|
||||||
action = function() {
|
action.fn = function() {
|
||||||
|
|
||||||
basicModal.close();
|
// Current function without showing the modal
|
||||||
album.setPublic(album.getID(), e);
|
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 = `
|
msg = `
|
||||||
<p class='less'>This album will be shared with the following properties:</p>
|
<p class='less'>${ text }</p>
|
||||||
<form>
|
<form>
|
||||||
<div class='choice'>
|
<div class='choice'>
|
||||||
<label>
|
<label>
|
||||||
<input type='checkbox' name='listed' checked>
|
<input type='checkbox' name='visible'>
|
||||||
<span class='checkbox'>${ build.iconic('check') }</span>
|
<span class='checkbox'>${ build.iconic('check') }</span>
|
||||||
<span class='label'>Visible</span>
|
<span class='label'>Visible</span>
|
||||||
</label>
|
</label>
|
||||||
@ -431,8 +439,8 @@ album.setPublic = function(albumID, e) {
|
|||||||
body: msg,
|
body: msg,
|
||||||
buttons: {
|
buttons: {
|
||||||
action: {
|
action: {
|
||||||
title: 'Share Album',
|
title: action.title,
|
||||||
fn: action
|
fn: action.fn
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
title: '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() {
|
$('.basicModal .choice input[name="password"]').on('change', function() {
|
||||||
|
|
||||||
if ($(this).prop('checked')===true) $('.basicModal .choice input[data-name="password"]').show().focus();
|
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()) {
|
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
|
// Set password
|
||||||
if ($('.basicModal .choice input[name="password"]:checked').length===1) {
|
if ($('.basicModal .choice input[name="password"]:checked').length===1) {
|
||||||
password = $('.basicModal .choice input[data-name="password"]').val();
|
password = $('.basicModal .choice input[data-name="password"]').val();
|
||||||
@ -463,28 +488,26 @@ album.setPublic = function(albumID, e) {
|
|||||||
album.json.password = '0';
|
album.json.password = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set downloadable
|
// Modal input has been processed, now it can be closed
|
||||||
if ($('.basicModal .choice input[name="downloadable"]:checked').length===1) {
|
basicModal.close();
|
||||||
downloadable = true;
|
|
||||||
album.json.downloadable = '1';
|
|
||||||
} else {
|
} 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()) {
|
if (visible.album()) {
|
||||||
|
|
||||||
album.json.public = (album.json.public==='0') ? '1' : '0';
|
album.json.visible = (album.json.public==='0') ? '0' : album.json.visible;
|
||||||
album.json.password = (album.json.public==='0') ? '0' : album.json.password;
|
|
||||||
album.json.downloadable = (album.json.public==='0') ? '0' : album.json.downloadable;
|
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.public();
|
||||||
view.album.password();
|
|
||||||
view.album.downloadable();
|
view.album.downloadable();
|
||||||
|
view.album.password();
|
||||||
|
|
||||||
if (album.json.public==='1') contextMenu.shareAlbum(albumID, e);
|
if (album.json.public==='1') contextMenu.shareAlbum(albumID, e);
|
||||||
|
|
||||||
@ -492,9 +515,10 @@ album.setPublic = function(albumID, e) {
|
|||||||
|
|
||||||
params = {
|
params = {
|
||||||
albumID,
|
albumID,
|
||||||
password,
|
public: album.json.public,
|
||||||
visible: listed,
|
password: password,
|
||||||
downloadable
|
visible: album.json.visible,
|
||||||
|
downloadable: album.json.downloadable
|
||||||
}
|
}
|
||||||
|
|
||||||
api.post('Album::setPublic', params, function(data) {
|
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('facebook', file, file) + 'Facebook', fn: function() { album.share(1) } },
|
||||||
{ type: 'item', title: build.iconic('envelope-closed') + 'Mail', fn: function() { album.share(2) } },
|
{ type: 'item', title: build.iconic('envelope-closed') + 'Mail', fn: function() { album.share(2) } },
|
||||||
{ type: 'separator' },
|
{ 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);
|
basicContext.show(items, e);
|
||||||
|
Loading…
Reference in New Issue
Block a user