Variables: List view updates.
This commit is contained in:
+19
-19
@@ -221,25 +221,25 @@ $text['header-variables']['ru-ru'] = "Параметры FreeSwitch";
|
|||||||
$text['header-variables']['sv-se'] = "Switch Variabler";
|
$text['header-variables']['sv-se'] = "Switch Variabler";
|
||||||
$text['header-variables']['uk-ua'] = "Задання змінних";
|
$text['header-variables']['uk-ua'] = "Задання змінних";
|
||||||
|
|
||||||
$text['header-variable_edit']['en-us'] = "Variable";
|
$text['header-variable']['en-us'] = "Variable";
|
||||||
$text['header-variable_edit']['ar-eg'] = "";
|
$text['header-variable']['ar-eg'] = "";
|
||||||
$text['header-variable_edit']['de-at'] = "Variable"; //copied from de-de
|
$text['header-variable']['de-at'] = "Variable"; //copied from de-de
|
||||||
$text['header-variable_edit']['de-ch'] = "Variable"; //copied from de-de
|
$text['header-variable']['de-ch'] = "Variable"; //copied from de-de
|
||||||
$text['header-variable_edit']['de-de'] = "Variable";
|
$text['header-variable']['de-de'] = "Variable";
|
||||||
$text['header-variable_edit']['es-cl'] = "Editar Variable";
|
$text['header-variable']['es-cl'] = "Editar Variable";
|
||||||
$text['header-variable_edit']['es-mx'] = "Editar Variable"; //copied from es-cl
|
$text['header-variable']['es-mx'] = "Editar Variable"; //copied from es-cl
|
||||||
$text['header-variable_edit']['fr-ca'] = "Editer la Variable"; //copied from fr-fr
|
$text['header-variable']['fr-ca'] = "Editer la Variable"; //copied from fr-fr
|
||||||
$text['header-variable_edit']['fr-fr'] = "Editer la Variable";
|
$text['header-variable']['fr-fr'] = "Editer la Variable";
|
||||||
$text['header-variable_edit']['he-il'] = "";
|
$text['header-variable']['he-il'] = "";
|
||||||
$text['header-variable_edit']['it-it'] = "Variabile";
|
$text['header-variable']['it-it'] = "Variabile";
|
||||||
$text['header-variable_edit']['nl-nl'] = "Variabelen";
|
$text['header-variable']['nl-nl'] = "Variabelen";
|
||||||
$text['header-variable_edit']['pl-pl'] = "Zmienna";
|
$text['header-variable']['pl-pl'] = "Zmienna";
|
||||||
$text['header-variable_edit']['pt-br'] = "Editar variável"; //copied from pt-pt
|
$text['header-variable']['pt-br'] = "Editar variável"; //copied from pt-pt
|
||||||
$text['header-variable_edit']['pt-pt'] = "Editar variável";
|
$text['header-variable']['pt-pt'] = "Editar variável";
|
||||||
$text['header-variable_edit']['ro-ro'] = "";
|
$text['header-variable']['ro-ro'] = "";
|
||||||
$text['header-variable_edit']['ru-ru'] = "Переменная";
|
$text['header-variable']['ru-ru'] = "Переменная";
|
||||||
$text['header-variable_edit']['sv-se'] = "Variabel";
|
$text['header-variable']['sv-se'] = "Variabel";
|
||||||
$text['header-variable_edit']['uk-ua'] = "Змінна";
|
$text['header-variable']['uk-ua'] = "Змінна";
|
||||||
|
|
||||||
$text['header-hostname']['en-us'] = "Hostname";
|
$text['header-hostname']['en-us'] = "Hostname";
|
||||||
$text['header-hostname']['ar-eg'] = "";
|
$text['header-hostname']['ar-eg'] = "";
|
||||||
|
|||||||
@@ -0,0 +1,273 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
FusionPBX
|
||||||
|
Version: MPL 1.1
|
||||||
|
|
||||||
|
The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
for the specific language governing rights and limitations under the
|
||||||
|
License.
|
||||||
|
|
||||||
|
The Original Code is FusionPBX
|
||||||
|
|
||||||
|
The Initial Developer of the Original Code is
|
||||||
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
||||||
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
|
Contributor(s):
|
||||||
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
//define the vars class
|
||||||
|
if (!class_exists('vars')) {
|
||||||
|
class vars {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* declare private variables
|
||||||
|
*/
|
||||||
|
private $app_name;
|
||||||
|
private $app_uuid;
|
||||||
|
private $permission_prefix;
|
||||||
|
private $list_page;
|
||||||
|
private $table;
|
||||||
|
private $uuid_prefix;
|
||||||
|
private $toggle_field;
|
||||||
|
private $toggle_values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when the object is created
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
//assign private variables
|
||||||
|
$this->app_name = 'vars';
|
||||||
|
$this->app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
|
||||||
|
$this->permission_prefix = 'var_';
|
||||||
|
$this->list_page = 'vars.php';
|
||||||
|
$this->table = 'vars';
|
||||||
|
$this->uuid_prefix = 'var_';
|
||||||
|
$this->toggle_field = 'var_enabled';
|
||||||
|
$this->toggle_values = ['true','false'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when there are no references to a particular object
|
||||||
|
* unset the variables used in the class
|
||||||
|
*/
|
||||||
|
public function __destruct() {
|
||||||
|
foreach ($this as $key => $value) {
|
||||||
|
unset($this->$key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete records
|
||||||
|
*/
|
||||||
|
public function delete($records) {
|
||||||
|
if (permission_exists($this->permission_prefix.'delete')) {
|
||||||
|
|
||||||
|
//add multi-lingual support
|
||||||
|
$language = new text;
|
||||||
|
$text = $language->get();
|
||||||
|
|
||||||
|
//validate the token
|
||||||
|
$token = new token;
|
||||||
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
|
message::add($text['message-invalid_token'],'negative');
|
||||||
|
header('Location: '.$this->list_page);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete multiple records
|
||||||
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
|
//build the delete array
|
||||||
|
foreach ($records as $x => $record) {
|
||||||
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
|
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete the checked rows
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//execute delete
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->delete($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//unset the user defined variables
|
||||||
|
unset($_SESSION["user_defined_variables"]);
|
||||||
|
|
||||||
|
//rewrite the xml
|
||||||
|
save_var_xml();
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-delete']);
|
||||||
|
}
|
||||||
|
unset($records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toggle records
|
||||||
|
*/
|
||||||
|
public function toggle($records) {
|
||||||
|
if (permission_exists($this->permission_prefix.'edit')) {
|
||||||
|
|
||||||
|
//add multi-lingual support
|
||||||
|
$language = new text;
|
||||||
|
$text = $language->get();
|
||||||
|
|
||||||
|
//validate the token
|
||||||
|
$token = new token;
|
||||||
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
|
message::add($text['message-invalid_token'],'negative');
|
||||||
|
header('Location: '.$this->list_page);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//toggle the checked records
|
||||||
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
|
//get current toggle state
|
||||||
|
foreach ($records as $x => $record) {
|
||||||
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
|
$uuids[] = "'".$record['uuid']."'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||||
|
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||||
|
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||||
|
$database = new database;
|
||||||
|
$rows = $database->select($sql, $parameters, 'all');
|
||||||
|
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$states[$row['uuid']] = $row['toggle'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($sql, $parameters, $rows, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
//build update array
|
||||||
|
$x = 0;
|
||||||
|
foreach ($states as $uuid => $state) {
|
||||||
|
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||||
|
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//save the changes
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//save the array
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->save($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//unset the user defined variables
|
||||||
|
unset($_SESSION["user_defined_variables"]);
|
||||||
|
|
||||||
|
//rewrite the xml
|
||||||
|
save_var_xml();
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-toggle']);
|
||||||
|
}
|
||||||
|
unset($records, $states);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copy records
|
||||||
|
*/
|
||||||
|
public function copy($records) {
|
||||||
|
if (permission_exists($this->permission_prefix.'add')) {
|
||||||
|
|
||||||
|
//add multi-lingual support
|
||||||
|
$language = new text;
|
||||||
|
$text = $language->get();
|
||||||
|
|
||||||
|
//validate the token
|
||||||
|
$token = new token;
|
||||||
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
|
message::add($text['message-invalid_token'],'negative');
|
||||||
|
header('Location: '.$this->list_page);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//copy the checked records
|
||||||
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
|
//get checked records
|
||||||
|
foreach ($records as $x => $record) {
|
||||||
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
|
$uuids[] = "'".$record['uuid']."'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//create insert array from existing data
|
||||||
|
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||||
|
$sql = "select * from v_".$this->table." ";
|
||||||
|
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||||
|
$database = new database;
|
||||||
|
$rows = $database->select($sql, $parameters, 'all');
|
||||||
|
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||||
|
foreach ($rows as $x => $row) {
|
||||||
|
|
||||||
|
//copy data
|
||||||
|
$array[$this->table][$x] = $row;
|
||||||
|
|
||||||
|
//overwrite
|
||||||
|
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = uuid();
|
||||||
|
$array[$this->table][$x]['var_description'] = trim($row['var_description'].' ('.$text['label-copy'].')');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($sql, $parameters, $rows, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
//save the changes and set the message
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//save the array
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->save($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//unset the user defined variables
|
||||||
|
unset($_SESSION["user_defined_variables"]);
|
||||||
|
|
||||||
|
//rewrite the xml
|
||||||
|
save_var_xml();
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-copy']);
|
||||||
|
|
||||||
|
}
|
||||||
|
unset($records);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -193,12 +193,7 @@
|
|||||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||||
|
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
if ($action == "add") {
|
echo "<td width='30%' align='left'nowrap><b>".$text['header-variable']."</b><br><br></td>\n";
|
||||||
echo "<td width='30%' align='left'nowrap><b>".$text['header-variable_add']."</b><br><br></td>\n";
|
|
||||||
}
|
|
||||||
if ($action == "update") {
|
|
||||||
echo "<td width='30%' align='left' nowrap><b>".$text['header-variable_edit']."</b><br><br></td>\n";
|
|
||||||
}
|
|
||||||
echo "<td width='70%' align='right'>";
|
echo "<td width='70%' align='right'>";
|
||||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='vars.php'\" value='".$text['button-back']."'>";
|
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='vars.php'\" value='".$text['button-back']."'>";
|
||||||
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
|
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
|
||||||
|
|||||||
+179
-126
@@ -23,10 +23,13 @@
|
|||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//includes
|
//includes
|
||||||
include "root.php";
|
include "root.php";
|
||||||
require_once "resources/require.php";
|
require_once "resources/require.php";
|
||||||
require_once "resources/check_auth.php";
|
require_once "resources/check_auth.php";
|
||||||
|
require_once "resources/paging.php";
|
||||||
|
|
||||||
|
|
||||||
//check permissions
|
//check permissions
|
||||||
if (permission_exists('var_view')) {
|
if (permission_exists('var_view')) {
|
||||||
@@ -41,165 +44,215 @@
|
|||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//toggle enabled state
|
//get posted data
|
||||||
if (is_uuid($_REQUEST['id']) && (strtolower($_REQUEST['enabled']) == 'true' || strtolower($_REQUEST['enabled']) == 'false')) {
|
if (is_array($_POST['vars'])) {
|
||||||
//build array
|
$action = $_POST['action'];
|
||||||
$array['vars'][0]['var_uuid'] = $_REQUEST['id'];
|
$search = $_POST['search'];
|
||||||
$array['vars'][0]['var_enabled'] = strtolower($_REQUEST['enabled']);
|
$vars = $_POST['vars'];
|
||||||
|
|
||||||
//grant temporary permissions
|
|
||||||
$p = new permissions;
|
|
||||||
$p->add('var_edit', 'temp');
|
|
||||||
|
|
||||||
//execute update
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'vars';
|
|
||||||
$database->app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
|
|
||||||
$database->save($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//revoke temporary permissions
|
|
||||||
$p->delete('var_edit', 'temp');
|
|
||||||
|
|
||||||
//unset the user defined variables
|
|
||||||
$_SESSION["user_defined_variables"] = "";
|
|
||||||
|
|
||||||
//synchronize the configuration
|
|
||||||
save_var_xml();
|
|
||||||
|
|
||||||
//set message
|
|
||||||
message::add($text['message-update']);
|
|
||||||
|
|
||||||
//redirect
|
|
||||||
header("Location: vars.php?id=".$_REQUEST['id']);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//include the header
|
//process the http post data by action
|
||||||
require_once "resources/header.php";
|
if ($action != '' && is_array($vars) && @sizeof($vars) != 0) {
|
||||||
$document['title'] = $text['title-variables'];
|
switch ($action) {
|
||||||
|
case 'copy':
|
||||||
|
if (permission_exists('var_add')) {
|
||||||
|
$obj = new vars;
|
||||||
|
$obj->copy($vars);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'toggle':
|
||||||
|
if (permission_exists('var_edit')) {
|
||||||
|
$obj = new vars;
|
||||||
|
$obj->toggle($vars);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
if (permission_exists('var_delete')) {
|
||||||
|
$obj = new vars;
|
||||||
|
$obj->delete($vars);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//set http values as php variables
|
header('Location: vars.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get order and order by
|
||||||
$order_by = $_GET["order_by"];
|
$order_by = $_GET["order_by"];
|
||||||
$order = $_GET["order"];
|
$order = $_GET["order"];
|
||||||
|
|
||||||
//show the content
|
//add the search string
|
||||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
$search = strtolower($_GET["search"]);
|
||||||
echo " <tr>\n";
|
if (strlen($search) > 0) {
|
||||||
echo " <td align='left'><b>".$text['header-variables']."</b><br>\n";
|
$sql_search = "where (";
|
||||||
echo " ".$text['description-variables']."\n";
|
$sql_search .= " lower(var_category) like :search ";
|
||||||
echo " </td>\n";
|
$sql_search .= " or lower(var_name) like :search ";
|
||||||
echo " </tr>\n";
|
$sql_search .= " or lower(var_value) like :search ";
|
||||||
echo "</table>\n";
|
$sql_search .= " or lower(var_hostname) like :search ";
|
||||||
|
$sql_search .= " or lower(var_enabled) like :search ";
|
||||||
|
$sql_search .= " or lower(var_description) like :search ";
|
||||||
|
$sql_search .= ") ";
|
||||||
|
$parameters['search'] = '%'.$search.'%';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "select * from v_vars ";
|
//get the count
|
||||||
$sql .= $order_by != '' ? order_by($order_by, $order) : "order by var_category, var_order asc ";
|
$sql = "select count(var_uuid) from v_vars ";
|
||||||
|
$sql .= $sql_search;
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$result = $database->select($sql, null, 'all');
|
$num_rows = $database->select($sql, $parameters, 'column');
|
||||||
|
|
||||||
|
//prepare to page the results
|
||||||
|
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||||
|
$param = $search ? "&search=".$search : null;
|
||||||
|
$param = $order_by ? "&order_by=".$order_by."&order=".$order : null;
|
||||||
|
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
|
||||||
|
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
||||||
|
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
|
||||||
|
$offset = $rows_per_page * $page;
|
||||||
|
|
||||||
|
//get the list
|
||||||
|
$sql = str_replace('count(var_uuid)', '*', $sql);
|
||||||
|
$sql .= $order_by != '' ? order_by($order_by, $order) : " order by var_category, var_order asc, var_name asc ";
|
||||||
|
$sql .= limit_offset($rows_per_page, $offset);
|
||||||
|
$database = new database;
|
||||||
|
$vars = $database->select($sql, $parameters, 'all');
|
||||||
unset($sql);
|
unset($sql);
|
||||||
|
|
||||||
$c = 0;
|
//create token
|
||||||
$row_style["0"] = "row_style0";
|
$object = new token;
|
||||||
$row_style["1"] = "row_style1";
|
$token = $object->create($_SERVER['PHP_SELF']);
|
||||||
|
|
||||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
//include the header
|
||||||
|
$document['title'] = $text['title-variables'];
|
||||||
|
require_once "resources/header.php";
|
||||||
|
|
||||||
$tmp_var_header = "<tr>\n";
|
//show the content
|
||||||
$tmp_var_header .= th_order_by('var_name', $text['label-name'], $order_by, $order);
|
echo "<div class='action_bar' id='action_bar'>\n";
|
||||||
$tmp_var_header .= th_order_by('var_value', $text['label-value'], $order_by, $order);
|
echo " <div class='heading'><b>".$text['header-variables']." (".$num_rows.")</b></div>\n";
|
||||||
$tmp_var_header .= th_order_by('var_hostname', $text['label-hostname'], $order_by, $order);
|
echo " <div class='actions'>\n";
|
||||||
$tmp_var_header .= th_order_by('var_enabled', $text['label-enabled'], $order_by, $order);
|
|
||||||
$tmp_var_header .= "<th>".$text['label-description']."</th>\n";
|
|
||||||
$tmp_var_header .= "<td class='list_control_icons'>";
|
|
||||||
if (permission_exists('var_add')) {
|
if (permission_exists('var_add')) {
|
||||||
$tmp_var_header .= "<a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'var_edit.php']);
|
||||||
}
|
}
|
||||||
$tmp_var_header .= "</td>\n";
|
if (permission_exists('var_add') && $vars) {
|
||||||
$tmp_var_header .= "<tr>\n";
|
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||||
|
}
|
||||||
|
if (permission_exists('var_edit') && $vars) {
|
||||||
|
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||||
|
}
|
||||||
|
if (permission_exists('var_delete') && $vars) {
|
||||||
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||||
|
}
|
||||||
|
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||||
|
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
|
||||||
|
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
|
||||||
|
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'vars.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||||
|
if ($paging_controls_mini != '') {
|
||||||
|
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
||||||
|
}
|
||||||
|
echo " </form>\n";
|
||||||
|
echo " </div>\n";
|
||||||
|
echo " <div style='clear: both;'></div>\n";
|
||||||
|
echo "</div>\n";
|
||||||
|
|
||||||
if (is_array($result) && @sizeof($result) != 0) {
|
echo $text['description-variables']."\n";
|
||||||
$prev_var_category = '';
|
echo "<br /><br />\n";
|
||||||
foreach($result as $row) {
|
|
||||||
$var_value = $row['var_value'];
|
echo "<form id='form_list' method='post'>\n";
|
||||||
$var_value = substr($var_value, 0, 50);
|
echo "<input type='hidden' id='action' name='action' value=''>\n";
|
||||||
if ($prev_var_category != $row['var_category']) {
|
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
|
||||||
$c=0;
|
|
||||||
if (strlen($prev_var_category) > 0) {
|
echo "<table class='list'>\n";
|
||||||
|
function write_header($modifier) {
|
||||||
|
global $text, $order_by, $order, $vars;
|
||||||
|
$modifier = str_replace('/', '', $modifier);
|
||||||
|
$modifier = str_replace(' ', ' ', $modifier);
|
||||||
|
$modifier = str_replace(' ', '_', $modifier);
|
||||||
|
$modifier = str_replace(':', '', $modifier);
|
||||||
|
$modifier = strtolower(trim($modifier));
|
||||||
|
echo "\n";
|
||||||
|
echo "<tr class='list-header'>\n";
|
||||||
|
if (permission_exists('var_edit') || permission_exists('var_delete')) {
|
||||||
|
echo " <th class='checkbox'>\n";
|
||||||
|
echo " <input type='checkbox' id='checkbox_all_".$modifier."' name='checkbox_all_".$modifier."' onclick=\"list_all_toggle('".$modifier."');\" ".($vars ?: "style='visibility: hidden;'").">\n";
|
||||||
|
echo " </th>\n";
|
||||||
|
}
|
||||||
|
echo th_order_by('var_name', $text['label-name'], $order_by, $order, null, "class='pct-30'");
|
||||||
|
echo th_order_by('var_value', $text['label-value'], $order_by, $order, null, "class='pct-40'");
|
||||||
|
echo th_order_by('var_hostname', $text['label-hostname'], $order_by, $order, null, "class='hide-sm-dn'");
|
||||||
|
echo th_order_by('var_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
|
||||||
|
echo "<th class='hide-sm-dn'>".$text['label-description']."</th>\n";
|
||||||
|
if (permission_exists('var_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||||
|
echo "<td class='action-button'> </td>\n";
|
||||||
|
}
|
||||||
|
echo "</tr>\n";
|
||||||
|
}
|
||||||
|
if (is_array($vars) && @sizeof($vars) != 0) {
|
||||||
|
$previous_category = '';
|
||||||
|
foreach ($vars as $x => $row) {
|
||||||
|
//write category and column headings
|
||||||
|
if ($previous_category != $row["var_category"]) {
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
echo "<td colspan='6'>\n";
|
echo "<td colspan='7' class='no-link'>\n";
|
||||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
echo ($previous_category != '' ? '<br />' : null)."<b>".$row["var_category"]."</b>";
|
||||||
echo " <tr>\n";
|
|
||||||
echo " <td width='33.3%' nowrap> </td>\n";
|
|
||||||
echo " <td width='33.3%' align='center' nowrap> </td>\n";
|
|
||||||
echo " <td width='33.3%' align='right'>";
|
|
||||||
if (permission_exists('var_add')) {
|
|
||||||
echo "<a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
|
||||||
}
|
|
||||||
echo " </td>\n";
|
|
||||||
echo " </tr>\n";
|
|
||||||
echo " </table>\n";
|
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
write_header($row["var_category"]);
|
||||||
}
|
}
|
||||||
echo "<tr><td colspan='4' align='left'>\n";
|
|
||||||
echo " <br />\n";
|
|
||||||
echo " <br />\n";
|
|
||||||
echo " <b>".$row['var_category']."</b> </td></tr>\n";
|
|
||||||
echo $tmp_var_header;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tr_link = (permission_exists('var_edit')) ? "href='var_edit.php?id=".$row['var_uuid']."'" : null;
|
|
||||||
echo "<tr ".$tr_link.">\n";
|
|
||||||
echo " <td valign='top' align='left' class='".$row_style[$c]."'>";
|
|
||||||
if (permission_exists('var_edit')) {
|
if (permission_exists('var_edit')) {
|
||||||
echo "<a href='var_edit.php?id=".$row['var_uuid']."'>".substr($row['var_name'],0,32)."</a>";
|
$list_row_url = "var_edit.php?id=".urlencode($row['var_uuid']);
|
||||||
|
}
|
||||||
|
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||||
|
if (permission_exists('var_add') || permission_exists('var_edit') || permission_exists('var_delete')) {
|
||||||
|
$modifier = strtolower(trim($row["var_category"]));
|
||||||
|
$modifier = str_replace('/', '', $modifier);
|
||||||
|
$modifier = str_replace(' ', ' ', $modifier);
|
||||||
|
$modifier = str_replace(' ', '_', $modifier);
|
||||||
|
$modifier = str_replace(':', '', $modifier);
|
||||||
|
echo " <td class='checkbox'>\n";
|
||||||
|
echo " <input type='checkbox' name='vars[$x][checked]' id='checkbox_".$x."' class='checkbox_".$modifier."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all_".$modifier."').checked = false; }\">\n";
|
||||||
|
echo " <input type='hidden' name='vars[$x][uuid]' value='".escape($row['var_uuid'])."' />\n";
|
||||||
|
echo " </td>\n";
|
||||||
|
}
|
||||||
|
echo " <td class='overflow'>";
|
||||||
|
if (permission_exists('var_edit')) {
|
||||||
|
echo "<a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['var_name'])."</a>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo substr($row['var_name'],0,32);
|
echo escape($row['var_name']);
|
||||||
}
|
}
|
||||||
echo " </td>\n";
|
echo " </td>\n";
|
||||||
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".substr($var_value,0,30)."</td>\n";
|
echo " <td class='overflow'>".$row['var_value']."</td>\n";
|
||||||
echo " <td valign='top' align='left' class='".$row_style[$c]."'>".$row['var_hostname']." </td>\n";
|
echo " <td class='hide-sm-dn'>".$row['var_hostname']." </td>\n";
|
||||||
echo " <td valign='top' align='left' class='".$row_style[$c]."'>";
|
|
||||||
echo " <a href='?id=".$row['var_uuid']."&enabled=".(($row['var_enabled'] == 'true') ? 'false' : 'true')."'>".(($row['var_enabled'] == 'true') ? $text['option-true'] : $text['option-false'])."</a>";
|
|
||||||
echo " </td>\n";
|
|
||||||
$var_description = str_replace("\n", "<br />", trim(substr(base64_decode($row['var_description']),0,40)));
|
|
||||||
$var_description = str_replace(" ", " ", $var_description);
|
|
||||||
echo " <td valign='top' align='left' class='row_stylebg'>".$var_description." </td>\n";
|
|
||||||
echo " <td valign='top' align='right'>";
|
|
||||||
if (permission_exists('var_edit')) {
|
if (permission_exists('var_edit')) {
|
||||||
echo "<a href='var_edit.php?id=".escape($row['var_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
echo " <td class='no-link center'>\n";
|
||||||
|
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['var_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
|
||||||
}
|
}
|
||||||
if (permission_exists('var_delete')) {
|
else {
|
||||||
echo "<a href='var_delete.php?id=".escape($row['var_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
echo " <td class='center'>\n";
|
||||||
|
echo $text['label-'.$row['var_enabled']];
|
||||||
}
|
}
|
||||||
echo " </td>\n";
|
echo " </td>\n";
|
||||||
|
echo " <td class='description overflow hide-sm-dn'>".escape($row['var_description'])."</td>\n";
|
||||||
|
if (permission_exists('var_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||||
|
echo " <td class='action-button'>\n";
|
||||||
|
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||||
|
echo " </td>\n";
|
||||||
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
$prev_var_category = $row['var_category'];
|
$previous_category = $row["var_category"];
|
||||||
$c = $c ? 0 : 1;
|
|
||||||
|
$x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($result, $row);
|
unset($vars);
|
||||||
|
|
||||||
echo "<tr>\n";
|
echo "</table>\n";
|
||||||
echo "<td colspan='6' align='left'>\n";
|
echo "<br />\n";
|
||||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||||
echo " <tr>\n";
|
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||||
echo " <td width='33.3%' nowrap='nowrap'> </td>\n";
|
echo "</form>\n";
|
||||||
echo " <td align='center' nowrap='nowrap'>$paging_controls</td>\n";
|
|
||||||
echo " <td width='33.3%' class='list_control_icons'>";
|
|
||||||
if (permission_exists('var_add')) {
|
|
||||||
echo "<a href='var_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
|
||||||
}
|
|
||||||
echo " </td>\n";
|
|
||||||
echo " </tr>\n";
|
|
||||||
echo " </table>\n";
|
|
||||||
echo "</td>\n";
|
|
||||||
echo "</tr>\n";
|
|
||||||
|
|
||||||
echo "</table>";
|
|
||||||
echo "<br><br>";
|
|
||||||
|
|
||||||
//include the footer
|
//include the footer
|
||||||
require_once "resources/footer.php";
|
require_once "resources/footer.php";
|
||||||
|
|||||||
Reference in New Issue
Block a user