2014-10-11 14:09:10 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
/**
|
|
|
|
* Update to version 2.7.0
|
|
|
|
*/
|
2014-10-11 14:09:10 +00:00
|
|
|
|
2016-01-30 22:07:59 +00:00
|
|
|
use Lychee\Modules\Database;
|
|
|
|
|
2015-02-08 14:29:06 +00:00
|
|
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Add medium to photos
|
2016-01-31 14:44:54 +00:00
|
|
|
$query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
|
2016-01-31 17:49:31 +00:00
|
|
|
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
|
|
|
|
|
2016-01-31 14:44:54 +00:00
|
|
|
if ($result===false) {
|
2016-01-31 17:49:31 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
|
2016-01-31 17:49:31 +00:00
|
|
|
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
|
|
|
|
|
|
|
|
if ($result===false) return false;
|
|
|
|
|
2014-10-11 14:09:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Create medium folder
|
2014-11-06 22:21:33 +00:00
|
|
|
if (is_dir(LYCHEE_UPLOADS_MEDIUM)===false) {
|
2016-01-31 17:49:31 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Only create the folder when it is missing
|
|
|
|
if (@mkdir(LYCHEE_UPLOADS_MEDIUM)===false) {
|
2016-01-31 17:49:31 +00:00
|
|
|
Log::error($connection, 'update_020700', __LINE__, 'Could not create medium-folder');
|
2016-01-30 20:43:57 +00:00
|
|
|
}
|
2016-01-31 17:49:31 +00:00
|
|
|
|
2014-11-06 22:21:33 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Add medium to settings
|
|
|
|
$query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'medium' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
2016-01-31 17:49:31 +00:00
|
|
|
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
|
|
|
|
|
2014-10-11 14:09:10 +00:00
|
|
|
if ($result->num_rows===0) {
|
2016-01-31 17:49:31 +00:00
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('medium', '1')", array(LYCHEE_TABLE_SETTINGS));
|
2016-01-31 17:49:31 +00:00
|
|
|
$result = Database::execute($connection, $query, 'update_020700', __LINE__);
|
|
|
|
|
|
|
|
if ($result===false) return false;
|
|
|
|
|
2014-10-11 14:09:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:43:57 +00:00
|
|
|
// Set version
|
2016-01-24 21:14:20 +00:00
|
|
|
if (Database::setVersion($connection, '020700')===false) return false;
|
2014-10-11 14:09:10 +00:00
|
|
|
|
|
|
|
?>
|