Fix unescessary use of non portable 'replace' sql and add loging when GD not installed

This commit is contained in:
Brice Maron 2011-10-22 11:01:06 +02:00
parent 0d4240e196
commit 9d46c378b9
2 changed files with 5 additions and 2 deletions

View File

@ -5,6 +5,9 @@ OC_JSON::checkAppEnabled('gallery');
function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource.
//getting the image dimensions
if(! function_exists('imagecreatefromjpeg'))
OC_Log::write('gallery','GD module not installed',OC_Log::ERROR);
list($width_orig, $height_orig) = getimagesize($imgSrc);
switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) {
case "jpeg":

View File

@ -31,7 +31,7 @@ class OC_GALLERY_SCANNER {
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
$result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
if ($result->numRows() == 0 && count($current_album['images'])) {
$stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)');
$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)');
$stmt->execute(array(OC_User::getUser(), $current_album['name']));
}
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
@ -42,7 +42,7 @@ class OC_GALLERY_SCANNER {
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ? AND `file_path` = ?');
$result = $stmt->execute(array($albumId, $img));
if ($result->numRows() == 0) {
$stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
$stmt->execute(array($albumId, $img));
}
}