diff --git a/html/ajax_list.php b/html/ajax_list.php new file mode 100644 index 0000000000..48d84424f7 --- /dev/null +++ b/html/ajax_list.php @@ -0,0 +1,33 @@ + + * Copyright (c) 2017 Tony Murray + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$init_modules = array('web', 'auth'); +require realpath(__DIR__ . '/..') . '/includes/init.php'; + +if (!$_SESSION['authenticated']) { + echo "Unauthenticated\n"; + exit; +} + +set_debug($_REQUEST['debug']); + +$id = mres($_REQUEST['id']); + +if (isset($id)) { + if (file_exists("includes/list/$id.inc.php")) { + header('Content-type: application/json'); + include_once "includes/list/$id.inc.php"; + } +} diff --git a/html/ajax_table.php b/html/ajax_table.php index 03562fdd87..a4d56d13da 100644 --- a/html/ajax_table.php +++ b/html/ajax_table.php @@ -22,18 +22,18 @@ if (!$_SESSION['authenticated']) { set_debug($_REQUEST['debug']); -$current = $_POST['current']; +$current = $_REQUEST['current']; settype($current, 'integer'); -$rowCount = $_POST['rowCount']; +$rowCount = $_REQUEST['rowCount']; settype($rowCount, 'integer'); -if (isset($_POST['sort']) && is_array($_POST['sort'])) { - foreach ($_POST['sort'] as $k => $v) { +if (isset($_REQUEST['sort']) && is_array($_POST['sort'])) { + foreach ($_REQUEST['sort'] as $k => $v) { $sort .= " $k $v"; } } -$searchPhrase = mres($_POST['searchPhrase']); -$id = mres($_POST['id']); +$searchPhrase = mres($_REQUEST['searchPhrase']); +$id = mres($_REQUEST['id']); $response = array(); if (isset($id)) { diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 28d4a964e6..c51f7670a7 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1604,3 +1604,27 @@ function get_dashboards($user_id = null) return $result; } + +/** + * Generate javascript to fill in a select box from an ajax list + * + * @param string $list_type type of list look in html/includes/list/ + * @param string $selector jquery selector for the target select element + * @param int $selected the id of the item to mark as selected + * @return string the javascript (not including