Commit ac2678d5 authored by thiaramus's avatar thiaramus
Browse files

Nodelist API endpoint to search SysOp name by AKA

parent 620a3f53
...@@ -68,4 +68,12 @@ Expected GET data: ...@@ -68,4 +68,12 @@ Expected GET data:
* search: Sysop name to search for (String) * search: Sysop name to search for (String)
```
GET: /nodelist/akasearch
```
Expected GET data:
* search: AKA to look up SysOp name by (String)
(*) - Not yet implemented. Syntax might be slightly changed. (*) - Not yet implemented. Syntax might be slightly changed.
\ No newline at end of file
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
private function nameSearch($name) { private function nameSearch($name) {
if (!$name) { if (!$name) {
$this->syntaxErrorMessage('Search query is undefined'); $this->syntaxErrorMessage('Sysop name is undefined');
} }
$nodelist = new nodelist(); $nodelist = new nodelist();
$ret = array(); $ret = array();
foreach ($this->config['nodelists'] as $n) { foreach ($this->config['nodelists'] as $n) {
$nodelist->readFile($nodelist->getLatest($n)); $nodelist->readFile($nodelist->getLatest($n));
$add = $nodelist->findName($name); $add = $nodelist->findName($name);
...@@ -40,6 +40,22 @@ ...@@ -40,6 +40,22 @@
return $ret; return $ret;
} }
private function akaSearch($aka) {
if (!$aka) {
$this->syntaxErrorMessage('Aka is undefined');
}
$nodelist = new nodelist();
$result = array();
foreach ($this->config['nodelists'] as $n) {
$nodelist->readFile($nodelist->getLatest($n));
$result []= $nodelist->findAka($aka);
}
return $result;
}
public function run() { public function run() {
if (!array_key_exists(1, $this->apiCallPath)) { if (!array_key_exists(1, $this->apiCallPath)) {
$this->syntaxErrorMessage('Nodelist function is undefined'); $this->syntaxErrorMessage('Nodelist function is undefined');
...@@ -48,6 +64,9 @@ ...@@ -48,6 +64,9 @@
if ($this->apiCallPath[1] === 'namesearch') { if ($this->apiCallPath[1] === 'namesearch') {
$name = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING); $name = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
$this->response($this->nameSearch($name)); $this->response($this->nameSearch($name));
} elseif ($this->apiCallPath[1] === 'akasearch') {
$aka = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
$this->response($this->akaSearch($aka));
} else { } else {
$this->syntaxErrorMessage('Unknown Nodelist function'); $this->syntaxErrorMessage('Unknown Nodelist function');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment