From 2afc4183bb5797efa9f21b3154bf00c9b65e8754 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 19 Sep 2012 16:39:56 -0400 Subject: [PATCH] CC-4496: Library -> Contents-feed does not work if advanced search data is invalid -fixed --- airtime_mvc/application/models/Datatables.php | 10 ++++++---- airtime_mvc/public/js/airtime/library/library.js | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index c022f2533..751caa257 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -100,10 +100,12 @@ class Application_Model_Datatables */ $params = array(); - $advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm); - if (!empty($advancedWhere['clause'])) { - $where[] = join(" AND ", $advancedWhere['clause']); - $params = $advancedWhere['params']; + if ($data['advSearch'] === 'true') { + $advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm); + if (!empty($advancedWhere['clause'])) { + $where[] = join(" AND ", $advancedWhere['clause']); + $params = $advancedWhere['params']; + } } if ($data["sSearch"] !== "") { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index f83ddb0fe..aad888006 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -525,8 +525,17 @@ var AIRTIME = (function(AIRTIME) { "sAjaxDataProp": "files", "fnServerData": function ( sSource, aoData, fnCallback ) { + /* The real validation check is done in dataTables.columnFilter.js + * We also need to check it here because datatable is redrawn everytime + * an action is performed in the Library page. + * In order for datatable to redraw the advanced search fields + * MUST all be valid. + */ + var advSearchFields = $("div#advanced_search").children(':visible'); + var advSearchValid = validateAdvancedSearch(advSearchFields); var type; aoData.push( { name: "format", value: "json"} ); + aoData.push( { name: "advSearch", value: advSearchValid} ); //push whether to search files/playlists or all. type = $("#library_display_type").find("select").val();