Skip to content

Commit

Permalink
think we good now
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed Dec 14, 2022
1 parent b30bd95 commit 8293fa8
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 39 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Expand Up @@ -18,6 +18,8 @@ There will probably not be another big change to Ampache 5 as work has moved to
* Missing translation on preferences sidebar
* Default catalog_filter group could be missing on a new install
* Gather genre tags when not an array
* Display webp images
* Check for a valid image extensions when uploading art

## API 5.5.6

Expand Down
4 changes: 2 additions & 2 deletions public/templates/show_artist_info.inc.php
Expand Up @@ -48,8 +48,8 @@
</div>
</div>
<div id="item_summary">
<?php if (array_key_exists('summary', $biography) && !empty(trim($biography['summary']))) { ?>
<?php echo nl2br($biography['summary']); ?>
<?php if (array_key_exists('summary', $biography) && !empty($biography['summary'])) { ?>
<?php echo nl2br(trim($biography['summary'])); ?>
<?php
}?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/sql/ampache.sql
Expand Up @@ -18,7 +18,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 192.168.1.20
-- Generation Time: Nov 19, 2022 at 05:49 PM
-- Generation Time: Dec 08, 2022 at 08:40 AM
-- Server version: 10.5.15-MariaDB-0+deb11u1
-- PHP Version: 8.1.11

Expand All @@ -34,7 +34,7 @@ SET time_zone = "+00:00";
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `ampache554`
-- Database: `ampache556`
--

-- --------------------------------------------------------
Expand Down
12 changes: 1 addition & 11 deletions src/Module/Art/Collector/FolderCollectorModule.php
Expand Up @@ -85,16 +85,6 @@ public function collect(
$artist_filename = $this->configContainer->get('artist_art_preferred_filename');
$artist_art_folder = $this->configContainer->get('artist_art_folder');

// Array of valid extensions
$image_extensions = [
'bmp',
'gif',
'jp2',
'jpeg',
'jpg',
'png'
];

$dirs = array();
if ($art->type == 'album') {
$media = new Album($art->uid);
Expand Down Expand Up @@ -154,7 +144,7 @@ public function collect(
$extension = $extension['extension'] ?? '';

// Make sure it looks like an image file
if (!in_array($extension, $image_extensions)) {
if (!in_array($extension, Art::VALID_TYPES)) {
continue;
}

Expand Down
1 change: 0 additions & 1 deletion src/Module/Playback/Localplay/Mpd/AmpacheMpd.php
Expand Up @@ -374,7 +374,6 @@ public function pause()
return $this->_mpd->Pause();
} // pause


/**
* volume
* This tells MPD to set the volume to the parameter
Expand Down
1 change: 0 additions & 1 deletion src/Module/Playback/Localplay/Upnp/UPnPDevice.php
Expand Up @@ -35,7 +35,6 @@ class UPnPDevice
"eventURLs" => array()
);


/**
* UPnPDevice constructor.
* @param $descriptionUrl
Expand Down
1 change: 0 additions & 1 deletion src/Module/Playback/Localplay/Vlc/VlcPlayer.php
Expand Up @@ -292,7 +292,6 @@ public function fullstate()
return $results;
} // fullstate


/**
* volume_up
* This increases the volume of VLC, set to +20 can be changed to your preference
Expand Down
1 change: 0 additions & 1 deletion src/Module/Playback/Stream_Playlist.php
Expand Up @@ -760,7 +760,6 @@ private function create_download()
return false;
} // create_download


/**
* create_ram
*this functions creates a RAM file for use by Real Player
Expand Down
2 changes: 0 additions & 2 deletions src/Module/System/Update.php
Expand Up @@ -2368,8 +2368,6 @@ public static function update_370027(): bool
return $retval;
}



/**
* update_370028
*
Expand Down
42 changes: 29 additions & 13 deletions src/Repository/Model/Art.php
Expand Up @@ -49,6 +49,7 @@
class Art extends database_object
{
protected const DB_TABLENAME = 'art';
public const VALID_TYPES = array('bmp', 'gif', 'jp2', 'jpeg', 'jpg', 'png', 'webp');

/**
* @var integer $id
Expand Down Expand Up @@ -403,8 +404,12 @@ public function insert($source, $mime = '')
/* is the file flac or mp3? */
$apic_typeid = ($fileformat == 'flac' || $fileformat == 'ogg') ? 'typeid' : 'picturetypeid';
$apic_mimetype = ($fileformat == 'flac' || $fileformat == 'ogg') ? 'image_mime' : 'mime';
$new_pic = array('data' => $source, 'mime' => $mime,
'picturetypeid' => $current_picturetypeid, 'description' => $description);
$new_pic = array(
'data' => $source,
'mime' => $mime,
'picturetypeid' => $current_picturetypeid,
'description' => $description
);

if (is_null($apics)) {
$ndata['attached_picture'][] = $new_pic;
Expand All @@ -414,8 +419,12 @@ public function insert($source, $mime = '')
$idx = $this->check_for_duplicate($apics, $ndata, $new_pic, $apic_typeid);
if (is_null($idx)) {
$ndata['attached_picture'][] = $new_pic;
$ndata['attached_picture'][] = array('data' => $apics[0]['data'], 'description' => $apics[0]['description'],
'mime' => $apics[0]['mime'], 'picturetypeid' => $apics[0]['picturetypeid']);
$ndata['attached_picture'][] = array(
'data' => $apics[0]['data'],
'description' => $apics[0]['description'],
'mime' => $apics[0]['mime'],
'picturetypeid' => $apics[0]['picturetypeid']
);
}
break;
case 2:
Expand All @@ -428,8 +437,12 @@ public function insert($source, $mime = '')
$ndata['attached_picture'][0] = $new_pic;
} else {
$apicsId = ($idx == 0) ? 1 : 0;
$ndata['attached_picture'][$apicsId] = array('data' => $apics[$apicsId]['data'], 'mime' => $apics[$apicsId][$apic_mimetype],
'picturetypeid' => $apics[$apicsId][$apic_typeid], 'description' => $apics[$apicsId]['description']);
$ndata['attached_picture'][$apicsId] = array(
'data' => $apics[$apicsId]['data'],
'mime' => $apics[$apicsId][$apic_mimetype],
'picturetypeid' => $apics[$apicsId][$apic_typeid],
'description' => $apics[$apicsId]['description']
);
}

break;
Expand Down Expand Up @@ -511,10 +524,10 @@ public static function check_dimensions($dimensions)
$height = (int)($dimensions['height']);

if ($width > 0 && $height > 0) {
$minw = (AmpConfig::get('album_art_min_width')) ? AmpConfig::get('album_art_min_width') : 0;
$maxw = (AmpConfig::get('album_art_max_width')) ? AmpConfig::get('album_art_max_width') : 0;
$minh = (AmpConfig::get('album_art_min_height')) ? AmpConfig::get('album_art_min_height') : 0;
$maxh = (AmpConfig::get('album_art_max_height')) ? AmpConfig::get('album_art_max_height') : 0;
$minw = AmpConfig::get('album_art_min_width', 0);
$maxw = AmpConfig::get('album_art_max_width', 0);
$minh = AmpConfig::get('album_art_min_height', 0);
$maxh = AmpConfig::get('album_art_max_height', 0);

// minimum width is set and current width is too low
if ($minw > 0 && $width < $minw) {
Expand Down Expand Up @@ -627,9 +640,8 @@ private static function write_to_dir($source, $sizetext, $type, $uid, $kind, $mi

/**
* read_from_images
* @param string $name
*/
private static function read_from_images($name = 'blankalbum.png')
private static function read_from_images()
{
$path = __DIR__ . '/../../../public/images/blankalbum.png';
if (!Core::is_readable($path)) {
Expand Down Expand Up @@ -926,6 +938,10 @@ public function generate_thumb($image, $size, $mime)
imagepng($thumbnail);
$mime_type = image_type_to_mime_type(IMAGETYPE_PNG);
break;
case 'webp':
imagewebp($thumbnail);
$mime_type = image_type_to_mime_type(IMAGETYPE_WEBP);
break;
default:
$mime_type = null;
} // resized
Expand Down Expand Up @@ -1498,7 +1514,7 @@ public static function display(
$class_name = ObjectTypeToClassNameMapper::map($object_type);
$libitem = new $class_name($object_id);
echo "<div class=\"item_art_actions\">";
if (Core::get_global('user')->has_access(50) || (Core::get_global('user')->has_access(25) && Core::get_global('user')->id == $libitem->get_user_owner())) {
if ((!empty(Core::get_global('user')) && Core::get_global('user')->has_access(50)) || (Core::get_global('user')->has_access(25) && Core::get_global('user')->id == $libitem->get_user_owner())) {
echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=show_art_dlg&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\">";
echo Ui::get_icon('edit', T_('Edit/Find Art'));
echo "</a>";
Expand Down
1 change: 1 addition & 0 deletions src/Repository/Model/Catalog.php
Expand Up @@ -3821,6 +3821,7 @@ public static function garbage_collect_mapping()
$sql = "DELETE FROM `catalog_map` WHERE `catalog_id` = 0";
Dba::write($sql);
}

/**
* Delete catalog filters that might have gone missing
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/Model/TVShow_Season.php
Expand Up @@ -115,7 +115,7 @@ private function _get_extra_info()
if (parent::is_cached('tvshow_extra', $this->id)) {
$row = parent::get_from_cache('tvshow_extra', $this->id);
} else {
$sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` AS `catalog_id` FROM `tvshow_episode` LEFT JOIN `video` ON `video`.`id` = `tvshow_episode`.`id` WHERE `tvshow_episode`.`season` = ?GROUP BY `catalog_id`";
$sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` AS `catalog_id` FROM `tvshow_episode` LEFT JOIN `video` ON `video`.`id` = `tvshow_episode`.`id` WHERE `tvshow_episode`.`season` = ? GROUP BY `catalog_id`";

$db_results = Dba::read($sql, array($this->id));
$row = Dba::fetch_assoc($db_results);
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/Model/Tag.php
Expand Up @@ -553,7 +553,7 @@ public static function get_top_tags($type, $object_id, $limit = 10)
$object_id = (int)($object_id);

$limit = (int)($limit);
$sql = "SELECT `tag_map`.`id`, `tag_map`.`tag_id`, `tag`.`name`, `tag_map`.`user` FROM `tag` LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` WHERE `tag`.`is_hidden` = false AND `tag_map`.`object_type` = ? AND `tag_map`.`object_id` = ?LIMIT $limit";
$sql = "SELECT `tag_map`.`id`, `tag_map`.`tag_id`, `tag`.`name`, `tag_map`.`user` FROM `tag` LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` WHERE `tag`.`is_hidden` = false AND `tag_map`.`object_type` = ? AND `tag_map`.`object_id` = ? LIMIT $limit";

$db_results = Dba::read($sql, array($type, $object_id));
$results = array();
Expand Down
7 changes: 4 additions & 3 deletions src/Repository/Model/User.php
Expand Up @@ -354,7 +354,6 @@ public static function get_user_catalogs($userid)
return $catalogs;
} // get_catalogs


/**
* get_catalogs
* This returns the catalogs as an array of ids that this user is allowed to access
Expand All @@ -365,7 +364,6 @@ public function get_catalogs()
return self::get_user_catalogs($this->id);
} // get_catalogs


/**
* get_preferences
* This is a little more complicate now that we've got many types of preferences
Expand Down Expand Up @@ -1440,8 +1438,11 @@ public function upload_avatar()
$path_info = pathinfo($_FILES['avatar']['name']);
$upload['file'] = $_FILES['avatar']['tmp_name'];
$upload['mime'] = 'image/' . $path_info['extension'];
$image_data = Art::get_from_source($upload, 'user');
if (!in_array(strtolower($path_info['extension']), Art::VALID_TYPES)) {
return false;
}

$image_data = Art::get_from_source($upload, 'user');
if ($image_data !== '') {
return $this->update_avatar($image_data, $upload['mime']);
}
Expand Down

0 comments on commit 8293fa8

Please sign in to comment.