mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 16:32:20 +00:00
- Added JSON post parameter check in controllers/components/SearchBar->search
- Expanded search capabilities for organization units and employees
This commit is contained in:
@@ -11,37 +11,41 @@ class SearchBar extends FHC_Controller
|
||||
const TYPES_PARAM = 'types';
|
||||
|
||||
/**
|
||||
*
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//
|
||||
// Load the library SearchBarLib
|
||||
$this->load->library('SearchBarLib');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('test');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
//$searchstr = $this->input->post(self::SEARCHSTR_PARAM);
|
||||
//$types = $this->input->post(self::TYPES_PARAM);
|
||||
|
||||
$json = json_decode($this->input->raw_input_stream, true);
|
||||
$searchstr = $json[self::SEARCHSTR_PARAM];
|
||||
$types = $json[self::TYPES_PARAM];
|
||||
$json = json_decode($this->input->raw_input_stream);
|
||||
|
||||
$this->outputJson($this->searchbarlib->search($searchstr, $types));
|
||||
// Checks if the searchstr and the types parameters are in the POSTed JSON
|
||||
if (isset($json->{self::SEARCHSTR_PARAM}) && isset($json->{self::TYPES_PARAM}))
|
||||
{
|
||||
// Convert to json the result from searchbarlib->search
|
||||
$this->outputJson(
|
||||
$this->searchbarlib->search(
|
||||
$json->{self::SEARCHSTR_PARAM},
|
||||
$json->{self::TYPES_PARAM}
|
||||
)
|
||||
);
|
||||
}
|
||||
else // otherwise return an error in JSON format
|
||||
{
|
||||
$this->outputJsonError(SearchBarLib::ERROR_WRONG_JSON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user