diff --git a/core/models/playlists_model.php b/core/models/playlists_model.php index 86649a37..58264028 100644 --- a/core/models/playlists_model.php +++ b/core/models/playlists_model.php @@ -299,7 +299,40 @@ public function search($query, $limit, $offset, $sort_by, $sort_dir, $my = false $where_strings = []; if ($query !== '' && $query !== false && $query !== null) { - $where_strings[] = '(name LIKE "%' . $this->db->escape($query) . '%" OR description LIKE "%' . $this->db->escape($query) . '%")'; + $query = trim($query); + $query_escape = $this->db->escape($query); + + $type_query = null; + $type_query_map = [ + 'b' => 'standard', + 'basic' => 'standard', + 'standard' => 'standard', + 'pl b' => 'standard', + 'playlist basic' => 'standard', + 'playlist standard' => 'standard', + 'a' => 'advanced', + 'advanced' => 'advanced', + 'pl a' => 'advanced', + 'playlist advanced' => 'advanced', + 'la' => 'live_assist', + 'live assist' => 'live_assist', + 'liveassist' => 'live_assist', + 'live_assist' => 'live_assist', + 'pl la' => 'live_assist', + 'playlist live assist' => 'live_assist', + ]; + + $query_normalized = strtolower($query); + if (isset($type_query_map[$query_normalized])) { + $type_query = $this->db->escape($type_query_map[$query_normalized]); + } + + $where = '(name LIKE "%' . $query_escape . '%" OR description LIKE "%' . $query_escape . '%")'; + if ($type_query !== null) { + $where .= ' OR type = "' . $type_query . '"'; + } + + $where_strings[] = '(' . $where . ')'; } if (!$this->user->check_permission('manage_playlists')) { $where_strings[] = '(status = "public" or status = "visible" or owner_id = "' . $this->db->escape($this->user->param('id')) . '")'; diff --git a/public/js/sidebar.js b/public/js/sidebar.js index 7565691b..299777b8 100644 --- a/public/js/sidebar.js +++ b/public/js/sidebar.js @@ -10,6 +10,7 @@ OB.Sidebar.init = function () { OB.Sidebar.mediaSearchQuery = ""; OB.Sidebar.playlistSearchQuery = ""; + OB.Sidebar.sidebarInit = function () { if (parseInt(OB.Account.userdata.sidebar_display_left)) { $("body").addClass("sidebar-left"); @@ -850,6 +851,29 @@ OB.Sidebar.playlistSearchSort = function (sortby) { OB.Sidebar.playlistSearch(); }; +OB.Sidebar.playlistTypeBadges = function (playlistType) { + if (!playlistType) playlistType = "standard"; + + var iconClass = "fa-list"; + var title = "Standard Playlist"; + + if (playlistType == "advanced") { + iconClass = "fa-cogs"; + title = "Advanced Playlist"; + } else if (playlistType == "live_assist") { + iconClass = "fa-microphone"; + title = "Live Assist Playlist"; + } + + return ( + '" + ); +}; + OB.Sidebar.playlistSearch = function (more) { // if not the result of pagination (new search), reset offset to 0 if (!more) { @@ -913,7 +937,10 @@ OB.Sidebar.playlistSearch = function (more) { playlist[i]["id"] + '" data-mode="playlist">\