Browse Source

Added row `visible`

Tobias Reich 11 years ago
parent
commit
5cce602a05
3 changed files with 7 additions and 5 deletions
  1. 4 4
      php/modules/album.php
  2. 2 1
      php/modules/db.php
  3. 1 0
      php/modules/misc.php

+ 4 - 4
php/modules/album.php

@@ -9,14 +9,14 @@
 
 if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
 
-function addAlbum($title, $public = 0) {
+function addAlbum($title = '', $public = 0, $visible = 1) {
 
 	global $database;
 
-	if (strlen($title)<1||strlen($title)>50) return false;
+	if (strlen($title)>50) $title = substr($title, 0, 50);
 
 	$sysdate	= date("d.m.Y");
-	$result		= $database->query("INSERT INTO lychee_albums (title, sysdate, public) VALUES ('$title', '$sysdate', '$public');");
+	$result		= $database->query("INSERT INTO lychee_albums (title, sysdate, public, visible) VALUES ('$title', '$sysdate', '$public', '$visible');");
 
 	if (!$result) return false;
 	return $database->insert_id;
@@ -31,7 +31,7 @@ function getAlbums($public) {
 	if (!$public) $return = getSmartInfo();
 
 	// Albums
-	if ($public) $query = "SELECT id, title, public, sysdate, password FROM lychee_albums WHERE public = 1";
+	if ($public) $query = "SELECT id, title, public, sysdate, password FROM lychee_albums WHERE public = 1 AND visible <> 0";
 	else $query = "SELECT id, title, public, sysdate, password FROM lychee_albums";
 
 	$result	= $database->query($query) OR exit("Error: $result <br>".$database->error);

+ 2 - 1
php/modules/db.php

@@ -119,7 +119,8 @@ function dbCreateTables($database) {
 				`title` varchar(50) NOT NULL,
 				`description` varchar(1000) DEFAULT '',
 				`sysdate` varchar(10) NOT NULL,
-				`public` tinyint(1) DEFAULT '0',
+				`public` tinyint(1) NOT NULL DEFAULT '0',
+				`visible` tinyint(1) NOT NULL DEFAULT '1',
 				`password` varchar(100) DEFAULT '',
 				PRIMARY KEY (`id`)
 			) ENGINE=MyISAM DEFAULT CHARSET=latin1;

+ 1 - 0
php/modules/misc.php

@@ -87,6 +87,7 @@ function update($version = '') {
 	// Albums
 	if(!$database->query("SELECT `description` FROM `lychee_albums` LIMIT 1;"))	$database->query("ALTER TABLE `lychee_albums` ADD `description` VARCHAR( 1000 ) NULL DEFAULT ''"); // v2.0
 	if($database->query("SELECT `password` FROM `lychee_albums` LIMIT 1;"))		$database->query("ALTER TABLE `lychee_albums` CHANGE `password` `password` VARCHAR( 100 ) NULL DEFAULT ''"); // v2.0
+	if(!$database->query("SELECT `visible` FROM `lychee_albums` LIMIT 1;"))		$database->query("ALTER TABLE `lychee_albums` ADD `visible` TINYINT(1) NOT NULL DEFAULT 1"); // v2.2
 
 	// Photos
 	if($database->query("SELECT `description` FROM `lychee_photos` LIMIT 1;"))	$database->query("ALTER TABLE `lychee_photos` CHANGE `description` `description` VARCHAR( 1000 ) NULL DEFAULT ''"); // v2.0