@@ -35,6 +35,7 @@ class TicketsController extends Controller
3535 protected $ member ;
3636 protected $ a_search_fields_numeric = ['creator_id ' , 'user_id ' , 'status_id ' , 'priority_id ' , 'category_id ' , 'agent_id ' ];
3737 protected $ a_search_fields_text = ['subject ' , 'content ' , 'intervention ' ];
38+ protected $ a_search_fields_text_special = ['comments ' , 'attachment_name ' , 'any_text_field ' ];
3839 protected $ a_search_fields_date = ['start_date ' , 'limit_date ' , 'created_at ' , 'completed_at ' , 'updated_at ' ];
3940
4041 public function __construct (Ticket $ tickets , \PanicHDMember $ member )
@@ -776,8 +777,9 @@ public function search_form($parameters = null)
776777
777778 // If there are search parameters
778779 if (!is_null ($ parameters )){
779- // Array of the parameters we allow to use via URL
780- $ a_valid_params = array_merge ($ this ->a_search_fields_numeric , ['department_id ' , 'list ' , 'tags ' ]);
780+ // URL allowed parameter arrays
781+ $ a_numeric_params = array_merge ($ this ->a_search_fields_numeric , ['department_id ' , 'list ' , 'tags ' ]);
782+ $ a_text_params = array_merge ($ this ->a_search_fields_text , $ this ->a_search_fields_text_special );
781783
782784 $ a_temp = explode ('/ ' , $ parameters );
783785 $ a_parameters = [];
@@ -789,9 +791,13 @@ public function search_form($parameters = null)
789791 $ key = $ param ;
790792
791793 }else {
792- if (in_array ($ key , $ a_valid_params )){
794+ if (in_array ($ key , $ a_numeric_params )){
793795 // Add param value pair into search_fields array
794796 $ search_fields [$ key ] = $ param ;
797+
798+ }elseif (in_array ($ key , $ a_text_params )){
799+ // Decode strings in URL
800+ $ search_fields [$ key ] = urldecode ($ param );
795801 }
796802
797803 // key reset to look for a new parameter
@@ -873,7 +879,7 @@ public function register_search_fields(Request $request)
873879 session ()->forget ('search_fields ' );
874880
875881 // Check all fields
876- $ a_fields = array_merge ($ this ->a_search_fields_numeric , $ this ->a_search_fields_text , $ this ->a_search_fields_date , ['department_id ' , 'list ' , ' comments ' , ' attachment_name ' , ' any_text_field ' ]);
882+ $ a_fields = array_merge ($ this ->a_search_fields_numeric , $ this ->a_search_fields_text , $ this ->a_search_fields_date , $ this -> a_search_fields_text_special , ['department_id ' , 'list ' ]);
877883 foreach ($ a_fields as $ field ){
878884 if ($ request ->filled ($ field )){
879885 $ search_fields [$ field ] = $ request ->{$ field };
0 commit comments