diff options
author | Christian Klinger | 2016-08-05 12:06:50 +0200 |
---|---|---|
committer | Christian Klinger | 2016-08-05 12:06:50 +0200 |
commit | 5773e599f142ea1b1106dbdbda219dfb14986878 (patch) | |
tree | 8986f3cba65b12cbd5450d5dcd34b32ffea735d1 /modules-available/roomplanner/page.inc.php | |
parent | added jqueryui module (diff) | |
download | slx-admin-5773e599f142ea1b1106dbdbda219dfb14986878.tar.gz slx-admin-5773e599f142ea1b1106dbdbda219dfb14986878.tar.xz slx-admin-5773e599f142ea1b1106dbdbda219dfb14986878.zip |
grobe Integration vom Raumplaner.
Diffstat (limited to 'modules-available/roomplanner/page.inc.php')
-rw-r--r-- | modules-available/roomplanner/page.inc.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/modules-available/roomplanner/page.inc.php b/modules-available/roomplanner/page.inc.php new file mode 100644 index 00000000..b533cf2f --- /dev/null +++ b/modules-available/roomplanner/page.inc.php @@ -0,0 +1,53 @@ +<?php + +class Page_Roomplanner extends Page +{ + protected function doPreprocess() + { + User::load(); + + if (!User::hasPermission('superadmin')) { + Message::addError('main.no-permission'); + Util::redirect('?do=Main'); + } + + } + + protected function doRender() + { + Render::addTemplate('page', []); + } + + protected function doAjax() + { + $action = Request::get('action', null, 'string'); + + if ($action === 'getmachines') { + $query = Request::get('query', null, 'string'); + + /* the query could be anything: UUID, IP or macaddr */ +// $result = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, hostname ' +// . ', MATCH (machineuuid, macaddr, clientip, hostname) AGAINST (:query) AS relevance ' +// . 'FROM machine ' +// . 'WHERE MATCH (machineuuid, macaddr, clientip, hostname) AGAINST (:query) ' +// . 'ORDER BY relevance DESC ' +// . 'LIMIT 5' +// , ['query' => $query]); +// + $result = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, hostname ' + . 'FROM machine ' + . "WHERE machineuuid LIKE :query " + . " OR macaddr LIKE :query " + . " OR clientip LIKE :query " + . " OR hostname LIKE :query ", ['query' => "%$query%"]); + + $returnObject = ['machines' => []]; + + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $returnObject['machines'][] = $row; + } + echo json_encode($returnObject, JSON_PRETTY_PRINT); + + } + } +} |