Browse Source

New sharing dialog
Choose if album should be listed public or not #177

Tobias Reich 9 years ago
parent
commit
cf9ad486f0
6 changed files with 28 additions and 18 deletions
  1. 2 1
      assets/css/message.css
  2. 17 11
      assets/js/album.js
  3. 0 0
      assets/min/main.css
  4. 0 0
      assets/min/main.js
  5. 2 2
      php/access/Admin.php
  6. 7 4
      php/modules/Album.php

+ 2 - 1
assets/css/message.css

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

+ 17 - 11
assets/js/album.js

@@ -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 it is too large
+ 0 - 0
assets/min/main.css


File diff suppressed because it is too large
+ 0 - 0
assets/min/main.js


+ 2 - 2
php/access/Admin.php

@@ -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']);
 
 	}
 

+ 7 - 4
php/modules/Album.php

@@ -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');");
 
 		}
 

Some files were not shown because too many files changed in this diff