diff --git a/dist/main.js b/dist/main.js index a79f115..c26d095 100644 Binary files a/dist/main.js and b/dist/main.js differ diff --git a/php/database/albums_table.sql b/php/database/albums_table.sql index 4f3b5c5..b949e2e 100644 --- a/php/database/albums_table.sql +++ b/php/database/albums_table.sql @@ -4,12 +4,12 @@ CREATE TABLE IF NOT EXISTS `?` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(50) NOT NULL, + `title` varchar(100) NOT NULL DEFAULT '', `description` varchar(1000) DEFAULT '', `sysstamp` int(11) NOT NULL, `public` tinyint(1) NOT NULL DEFAULT '0', `visible` tinyint(1) NOT NULL DEFAULT '1', `downloadable` tinyint(1) NOT NULL DEFAULT '0', - `password` varchar(100) DEFAULT '', + `password` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; \ No newline at end of file diff --git a/php/database/photos_table.sql b/php/database/photos_table.sql index 058e3b3..b8d5ef9 100644 --- a/php/database/photos_table.sql +++ b/php/database/photos_table.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `?` ( `id` bigint(14) NOT NULL, - `title` varchar(50) NOT NULL, + `title` varchar(100) NOT NULL, `description` varchar(1000) DEFAULT '', `url` varchar(100) NOT NULL, `tags` varchar(1000) NOT NULL DEFAULT '', diff --git a/php/database/settings_content.sql b/php/database/settings_content.sql index 63d9a69..6a1595c 100644 --- a/php/database/settings_content.sql +++ b/php/database/settings_content.sql @@ -9,6 +9,9 @@ VALUES ('password',''), ('thumbQuality','90'), ('checkForUpdates','1'), - ('sorting','ORDER BY id DESC'), + ('sortingPhotos','ORDER BY id DESC'), + ('sortingAlbums','ORDER BY id DESC'), + ('medium','1'), + ('imagick','1'), ('dropboxKey',''), ('plugins',''); \ No newline at end of file diff --git a/php/database/update_030001.php b/php/database/update_030001.php index dd44cdc..9a9d068 100644 --- a/php/database/update_030001.php +++ b/php/database/update_030001.php @@ -35,6 +35,14 @@ if ($result->num_rows===0) { } } +# Rename sorting to sortingPhotos +$query = Database::prepare($database, "UPDATE ? SET `key` = 'sortingPhotos' WHERE `key` = 'sorting' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); +$result = $database->query($query); +if (!$result) { + Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')'); + return false; +} + # Set version if (Database::setVersion($database, '030001')===false) return false; diff --git a/php/modules/Album.php b/php/modules/Album.php index 375e2ea..d91ac04 100644 --- a/php/modules/Album.php +++ b/php/modules/Album.php @@ -94,19 +94,19 @@ class Album extends Module { switch ($this->albumIDs) { case 'f': $return['public'] = '0'; - $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE star = 1 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE star = 1 " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); break; case 's': $return['public'] = '0'; - $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE public = 1 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE public = 1 " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); break; case 'r': $return['public'] = '0'; - $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); break; case '0': $return['public'] = '0'; - $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = 0 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = 0 " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); break; default: $query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs)); @@ -114,7 +114,7 @@ class Album extends Module { $return = $albums->fetch_assoc(); $return['sysdate'] = date('d M. Y', $return['sysstamp']); $return['password'] = ($return['password']=='' ? '0' : '1'); - $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs)); + $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs)); break; } @@ -210,7 +210,7 @@ class Album extends Module { ($public===false)) { # Execute query - $query = Database::prepare($this->database, "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr($this->settings['sorting'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id'])); + $query = Database::prepare($this->database, "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr($this->settings['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id'])); $thumbs = $this->database->query($query); # For each thumb @@ -254,7 +254,7 @@ class Album extends Module { # Unsorted ### - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); $unsorted = $this->database->query($query); $i = 0; @@ -274,7 +274,7 @@ class Album extends Module { # Starred ### - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); $starred = $this->database->query($query); $i = 0; @@ -294,7 +294,7 @@ class Album extends Module { # Public ### - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); $public = $this->database->query($query); $i = 0; @@ -314,7 +314,7 @@ class Album extends Module { # Recent ### - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS)); $recent = $this->database->query($query); $i = 0; diff --git a/php/modules/Session.php b/php/modules/Session.php index 3af7e42..d96c973 100755 --- a/php/modules/Session.php +++ b/php/modules/Session.php @@ -67,8 +67,8 @@ class Session extends Module { # Unset unused vars unset($return['config']['thumbQuality']); - unset($return['config']['sorting']); unset($return['config']['sortingAlbums']); + unset($return['config']['sortingPhotos']); unset($return['config']['dropboxKey']); unset($return['config']['login']); unset($return['config']['location']); diff --git a/php/modules/Settings.php b/php/modules/Settings.php index cf0bb7d..f0f57f4 100755 --- a/php/modules/Settings.php +++ b/php/modules/Settings.php @@ -183,7 +183,7 @@ class Settings extends Module { # Do not prepare $sorting because it is a true statement # Preparing (escaping) the sorting would destroy it # $sorting is save and can't contain user-input - $query = Database::prepare($this->database, "UPDATE ? SET value = '$sorting' WHERE `key` = 'sorting'", array(LYCHEE_TABLE_SETTINGS)); + $query = Database::prepare($this->database, "UPDATE ? SET value = '$sorting' WHERE `key` = 'sortingPhotos'", array(LYCHEE_TABLE_SETTINGS)); $result = $this->database->query($query); if (!$result) { diff --git a/php/modules/misc.php b/php/modules/misc.php index f5b9ba3..f763144 100755 --- a/php/modules/misc.php +++ b/php/modules/misc.php @@ -47,7 +47,7 @@ function search($database, $settings, $term) { $album = Album::prepareData($album); # Thumbs - $query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sorting'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $album['id'])); + $query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sortingPhotos'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $album['id'])); $thumbs = $database->query($query); # For each thumb diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js index 96bac03..e090983 100644 --- a/src/scripts/lychee.js +++ b/src/scripts/lychee.js @@ -18,7 +18,7 @@ lychee = { debugMode: false, checkForUpdates:'1', - sorting: '', + sortingPhotos: '', sortingAlbums: '', location: '', @@ -49,7 +49,7 @@ lychee.init = function() { // Logged in - lychee.sorting = data.config.sorting || ''; + lychee.sortingPhotos = data.config.sortingPhotos || ''; lychee.sortingAlbums = data.config.sortingAlbums || ''; lychee.dropboxKey = data.config.dropboxKey || ''; lychee.location = data.config.location || ''; diff --git a/src/scripts/settings.js b/src/scripts/settings.js index 04bc026..c268b30 100644 --- a/src/scripts/settings.js +++ b/src/scripts/settings.js @@ -310,7 +310,7 @@ settings.setSorting = function() { if (data===true) { lychee.sortingAlbums = 'ORDER BY ' + sortingAlbums[0] + ' ' + sortingAlbums[1]; - lychee.sorting = 'ORDER BY ' + sortingPhotos[0] + ' ' + sortingPhotos[1]; + lychee.sortingPhotos = 'ORDER BY ' + sortingPhotos[0] + ' ' + sortingPhotos[1]; lychee.load(); } else lychee.error(null, params, data); @@ -377,9 +377,9 @@ settings.setSorting = function() { } - if (lychee.sorting!=='') { + if (lychee.sortingPhotos!=='') { - sortingPhotos = lychee.sorting.replace('ORDER BY ', '').split(' '); + sortingPhotos = lychee.sortingPhotos.replace('ORDER BY ', '').split(' '); $('.basicModal select#settings_photos_type').val(sortingPhotos[0]); $('.basicModal select#settings_photos_order').val(sortingPhotos[1]);