credential_store

This commit is contained in:
fbsanchez 2019-06-21 19:34:47 +02:00
parent 6682bad19f
commit e9ef9b64a3
8 changed files with 968 additions and 22 deletions

View File

@ -50,9 +50,105 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
ui_require_css_file('credential_store');
require_once $config['homedir'].'/include/functions_credential_store.php';
if (is_ajax()) {
$draw = get_parameter('draw', 0);
$filter = get_parameter('filter', []);
$get_key = get_parameter('get_key', 0);
$new_key = get_parameter('new_key', 0);
$update_key = get_parameter('update_key', 0);
$delete_key = get_parameter('delete_key', 0);
if ($delete_key) {
$identifier = get_parameter('identifier', null);
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (db_process_sql_delete(
'tcredential_store',
['identifier' => $identifier]
) === false
) {
ajax_msg('error', $config['dbconnection']->error, true);
} else {
ajax_msg('result', $identifier, true);
}
}
if ($update_key) {
$data = get_parameter('values', null);
if ($data === null || !is_array($data)) {
echo json_encode(['error' => __('Invalid parameters, please retry')]);
exit;
}
$values = [];
foreach ($data as $key => $value) {
if ($key == 'identifier') {
$identifier = base64_decode($value);
} else {
$values[$key] = base64_decode($value);
}
}
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (db_process_sql_update(
'tcredential_store',
$values,
['identifier' => $identifier]
) === false
) {
ajax_msg('error', $config['dbconnection']->error);
} else {
ajax_msg('result', $identifier);
}
exit;
}
if ($new_key) {
$data = get_parameter('values', null);
if ($data === null || !is_array($data)) {
echo json_encode(['error' => __('Invalid parameters, please retry')]);
exit;
}
$values = [];
foreach ($data as $key => $value) {
$values[$key] = base64_decode($value);
}
$identifier = $values['identifier'];
if (empty($identifier)) {
ajax_msg('error', __('identifier cannot be empty'));
}
if (db_process_sql_insert('tcredential_store', $values) === false) {
ajax_msg('error', $config['dbconnection']->error);
} else {
ajax_msg('result', $identifier);
}
exit;
}
if ($get_key) {
$identifier = get_parameter('identifier', null);
$key = get_key($identifier);
echo print_inputs($key);
exit;
}
if ($draw) {
// Datatables offset, limit and order.
@ -97,6 +193,13 @@ if (is_ajax()) {
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->username = io_safe_output($tmp->username);
if (empty($tmp->group)) {
$tmp->group = __('All');
} else {
$tmp->group = io_safe_output($tmp->group);
}
$carry[] = $tmp;
return $carry;
}
@ -129,15 +232,13 @@ if (is_ajax()) {
}
return;
exit;
}
return;
exit;
}
// Load interface.
// Datatables list.
try {
$columns = [
'group',
@ -158,27 +259,299 @@ try {
],
];
$table_id = 'keystore';
// Load datatables user interface.
ui_print_datatable(
[
'class' => 'info_table events',
'id' => $table_id,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/groups/credential_store',
'ajax_postprocess' => 'process_datatables_item(item)',
'no_sortable_columns' => [-1],
'order' => [
'field' => 'identifier',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Group'),
'type' => 'select',
'id' => 'filter_id_group',
'name' => 'filter_id_group',
'options' => users_get_groups_for_select(
$config['id_user'],
'AR',
true,
true,
false
),
],
[
'label' => __('Free search'),
'type' => 'text',
'class' => 'mw250px',
'id' => 'free_search',
'name' => 'free_search',
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
// Auxiliar div.
$new = '<div id="new_key" style="display: none"><form id="form_new">';
$new .= print_inputs();
$new .= '</form> </div>';
$details = '<div id="info_key" style="display: none"><form id="form_update">';
$details .= '</form></div>';
$aux = '<div id="aux" style="display: none"></div>';
echo $new.$details.$aux;
// Create button.
echo '<div class="w100p flex-content-right">';
html_print_submit_button(
__('Add key'),
'create',
false,
'class="sub next"'
);
echo '</div>';
?>
<script type="text/javascript">
function process_datatables_item(item) {
item.options = 'aa';
item.options = '<a href="javascript:" onclick="display_key(\'';
item.options += item.identifier;
item.options += '\')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show')]); ?></a>';
item.options += '<a href="javascript:" onclick="delete_key(\'';
item.options += item.identifier;
item.options += '\')" ><?php echo html_print_image('images/cross.png', true, ['title' => __('Delete')]); ?></a>';
}
function handle_response(data) {
var title = "<?php echo __('Success'); ?>";
var text = '';
var failed = 0;
try {
data = JSON.parse(data);
text = data['result'];
} catch (err) {
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
}
if (!failed && data['error']) {
title = "<?php echo __('Failed'); ?>";
text = data['error'];
failed = 1;
}
$('#aux').empty();
$('#aux').html(text);
$('#aux').dialog({
width: 450,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: title,
buttons: [
{
text: 'OK',
click: function(e) {
if (!failed) {
dt_<?php echo $table_id; ?>.draw(0);
$(".ui-dialog-content").dialog("close");
} else {
$(this).dialog('close');
}
}
}
]
});
}
function delete_key(id) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Delete'); ?> ' + id,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Delete',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
delete_key: 1,
identifier: id
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
}
]
});
}
function display_key(id) {
$('#form_update').empty();
$('#form_update').html('Loading...');
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
get_key: 1,
identifier: id
},
success: function (data) {
$('#info_key').dialog({
width: 580,
height: 400,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: id,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Update',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
var values = {};
$('#form_update :input').each(function() {
values[this.name] = btoa($(this).val());
});
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
update_key: 1,
values: values
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
}
]
});
$('#form_update').html(data);
}
})
}
function add_key() {
// Clear form.
$('#form_new :input').each(function() {
$(this).val('')
});
$('#group').val(0);
// Show form.
$('#new_key').dialog({
width: 580,
height: 400,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: "<?php echo __('Register new key into keystore'); ?>",
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: "<?php echo __('Cancel'); ?>",
click: function(e) {
$(this).dialog('close');
}
},
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
text: 'OK',
click: function(e) {
var values = {};
$('#form_new :input').each(function() {
values[this.name] = btoa($(this).val());
});
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'godmode/groups/credential_store',
new_key: 1,
values: values
},
datatype: "json",
success: function (data) {
handle_response(data);
},
error: function(e) {
handle_response(e);
}
});
}
},
]
});
}
$(document).ready(function(){
$("#submit-create").on('click', function(){
add_key();
});
});
</script>

View File

@ -51,7 +51,7 @@ function credentials_get_all(
$sort_field=null
) {
$sql_filters = [];
$group_by = '';
$order_by = '';
$pagination = '';
global $config;
@ -72,6 +72,80 @@ function credentials_get_all(
throw new Exception('[credential_get_all] Fields must be an array or "count".');
}
if (isset($order)) {
$dir = 'asc';
if ($order == 'desc') {
$dir = 'desc';
};
if (in_array(
$sort_field,
[
'group',
'identifier',
'product',
'username',
'options',
]
)
) {
$order_by = sprintf(
'ORDER BY `%s` %s',
$sort_field,
$dir
);
}
}
if (isset($limit) && $limit > 0
&& isset($offset) && $offset >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$limit,
$offset
);
}
if (isset($filter['free_search']) && !empty($filter['free_search'])) {
$sql_filters[] = vsprintf(
' AND (lower(cs.username) like lower("%%%s%%")
OR cs.identifier like "%%%s%%"
OR lower(cs.product) like lower("%%%s%%"))',
array_fill(0, 3, $filter['free_search'])
);
}
if (isset($filter['filter_id_group']) && $filter['filter_id_group'] > 0) {
$propagate = db_get_value(
'propagate',
'tgrupo',
'id_grupo',
$filter['filter_id_group']
);
if (!$propagate) {
$sql_filters[] = sprintf(
' AND cs.id_group = %d ',
$filter['filter_id_group']
);
} else {
$groups = [ $filter['filter_id_group'] ];
$childrens = groups_get_childrens($id_group, null, true);
if (!empty($childrens)) {
foreach ($childrens as $child) {
$groups[] = (int) $child['id_grupo'];
}
}
$filter['filter_id_group'] = $groups;
$sql_filters[] = sprintf(
' AND cs.id_group IN (%s) ',
join(',', $filter['filter_id_group'])
);
}
}
$sql = sprintf(
'SELECT %s
FROM tcredential_store cs
@ -83,7 +157,7 @@ function credentials_get_all(
%s',
join(',', $fields),
join(',', $sql_filters),
$group_by,
$order_by,
$pagination
);
@ -95,3 +169,163 @@ function credentials_get_all(
return db_get_all_rows_sql($sql);
}
/**
* Retrieves target key from keystore or false in case of error.
*
* @param string $identifier Key identifier.
*
* @return array Key or false if error.
*/
function get_key($identifier)
{
return db_get_row_filter(
'tcredential_store',
[ 'identifier' => $identifier ]
);
}
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
* @param boolean $delete Deletion messages.
*
* @return void
*/
function ajax_msg($type, $msg, $delete=false)
{
$msg_err = 'Failed while saving: %s';
$msg_ok = 'Successfully saved into keystore ';
if ($delete) {
$msg_err = 'Failed while removing: %s';
$msg_ok = 'Successfully deleted ';
}
if ($type == 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__(
$msg_err,
$msg
),
'',
true
),
]
);
} else {
echo json_encode(
[
$type => ui_print_success_message(
__(
$msg_ok,
$msg
),
'',
true
),
]
);
}
exit;
}
/**
* Generates inputs for new/update forms.
*
* @param array $values Values or null.
*
* @return string Inputs.
*/
function print_inputs($values=null)
{
if (!is_array($values)) {
$values = [];
}
$return = '';
$return .= html_print_input(
[
'label' => __('Identifier'),
'name' => 'identifier',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['identifier'],
'disabled' => (bool) $values['identifier'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => __('Group'),
'name' => 'id_group',
'id' => 'id_group',
'input_class' => 'flex-row',
'type' => 'select_groups',
'selected' => $values['id_grupo'],
'return' => true,
'class' => 'w50p',
]
);
$return .= html_print_input(
[
'label' => __('Product'),
'name' => 'product',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['product'],
'disabled' => (bool) $values['product'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => __('Username'),
'name' => 'username',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['username'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => __('Password'),
'name' => 'password',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['password'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => __('Extra'),
'name' => 'extra_1',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['extra_1'],
'return' => true,
]
);
$return .= html_print_input(
[
'label' => __('Extra (2)'),
'name' => 'extra_2',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['extra_2'],
'return' => true,
]
);
return $return;
}

View File

@ -3066,3 +3066,289 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='')
return $html;
}
/**
* Print input using functions html lib.
*
* @param array $data Input definition.
*
* @return string HTML code for desired input.
*/
function html_print_input($data)
{
if (is_array($data) === false) {
return '';
}
$output = '';
if ($data['label']) {
$output = '<div class="'.$data['input_class'].'">';
$output .= '<label class="'.$data['label_class'].'">';
$output .= $data['label'];
$output .= '</label>';
if (!$data['return']) {
echo $output;
}
}
switch ($data['type']) {
case 'text':
$output .= html_print_input_text(
$data['name'],
$data['value'],
((isset($data['alt']) === true) ? $data['alt'] : ''),
((isset($data['size']) === true) ? $data['size'] : 50),
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
((isset($data['return']) === true) ? $data['return'] : true),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['function']) === true) ? $data['function'] : ''),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
);
break;
case 'image':
$output .= html_print_input_image(
$data['name'],
$data['src'],
$data['value'],
((isset($data['style']) === true) ? $data['style'] : ''),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['options']) === true) ? $data['options'] : false)
);
break;
case 'text_extended':
$output .= html_print_input_text_extended(
$data['name'],
$data['value'],
$data['id'],
$data['alt'],
$data['size'],
$data['maxlength'],
$data['disabled'],
$data['script'],
$data['attributes'],
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['password']) === true) ? $data['password'] : false),
((isset($data['function']) === true) ? $data['function'] : '')
);
break;
case 'password':
$output .= html_print_input_password(
$data['name'],
$data['value'],
((isset($data['alt']) === true) ? $data['alt'] : ''),
((isset($data['size']) === true) ? $data['size'] : 50),
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['class']) === true) ? $data['class'] : '')
);
break;
case 'text':
$output .= html_print_input_text(
$data['name'],
$data['value'],
((isset($data['alt']) === true) ? $data['alt'] : ''),
((isset($data['size']) === true) ? $data['size'] : 50),
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['function']) === true) ? $data['function'] : ''),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
);
break;
case 'image':
$output .= html_print_input_image(
$data['name'],
$data['src'],
$data['value'],
((isset($data['style']) === true) ? $data['style'] : ''),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['options']) === true) ? $data['options'] : false)
);
break;
case 'hidden':
$output .= html_print_input_hidden(
$data['name'],
$data['value'],
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['class']) === true) ? $data['class'] : false)
);
break;
case 'hidden_extended':
$output .= html_print_input_hidden_extended(
$data['name'],
$data['value'],
$data['id'],
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['class']) === true) ? $data['class'] : false)
);
break;
case 'color':
$output .= html_print_input_color(
$data['name'],
$data['value'],
((isset($data['class']) === true) ? $data['class'] : false),
((isset($data['return']) === true) ? $data['return'] : false)
);
break;
case 'file':
$output .= html_print_input_file(
$data['name'],
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['options']) === true) ? $data['options'] : false)
);
break;
case 'select':
$output .= html_print_select(
$data['fields'],
$data['name'],
((isset($data['selected']) === true) ? $data['selected'] : ''),
((isset($data['script']) === true) ? $data['script'] : ''),
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['multiple']) === true) ? $data['multiple'] : false),
((isset($data['sort']) === true) ? $data['sort'] : true),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['style']) === true) ? $data['style'] : false),
((isset($data['option_style']) === true) ? $data['option_style'] : false),
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['modal']) === true) ? $data['modal'] : false),
((isset($data['message']) === true) ? $data['message'] : ''),
((isset($data['select_all']) === true) ? $data['select_all'] : false)
);
break;
case 'select_from_sql':
$output .= html_print_select_from_sql(
$data['sql'],
$data['name'],
((isset($data['selected']) === true) ? $data['selected'] : ''),
((isset($data['script']) === true) ? $data['script'] : ''),
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['multiple']) === true) ? $data['multiple'] : false),
((isset($data['sort']) === true) ? $data['sort'] : true),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['style']) === true) ? $data['style'] : false),
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
);
break;
case 'select_groups':
$output .= html_print_select_groups(
((isset($data['id_user']) === true) ? $data['id_user'] : false),
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
$data['name'],
((isset($data['selected']) === true) ? $data['selected'] : ''),
((isset($data['script']) === true) ? $data['script'] : ''),
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['multiple']) === true) ? $data['multiple'] : false),
((isset($data['sort']) === true) ? $data['sort'] : true),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['style']) === true) ? $data['style'] : false),
((isset($data['option_style']) === true) ? $data['option_style'] : false),
((isset($data['id_group']) === true) ? $data['id_group'] : false),
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
((isset($data['include_groups']) === true) ? $data['include_groups'] : false),
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false)
);
break;
case 'submit':
$output .= '<div class="action-buttons" style="width: 100%">'.html_print_submit_button(
((isset($data['label']) === true) ? $data['label'] : 'OK'),
((isset($data['name']) === true) ? $data['name'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
((isset($data['return']) === true) ? $data['return'] : false)
).'</div>';
break;
case 'checkbox':
$output .= html_print_checkbox(
$data['name'],
$data['value'],
((isset($data['checked']) === true) ? $data['checked'] : false),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['script']) === true) ? $data['script'] : ''),
((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false)
);
break;
case 'switch':
$output .= html_print_switch($data);
break;
case 'interval':
$output .= html_print_extended_select_for_time(
$data['name'],
$data['value'],
((isset($data['script']) === true) ? $data['script'] : ''),
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['style']) === true) ? $data['selected'] : false),
((isset($data['unique']) === true) ? $data['unique'] : false)
);
break;
case 'textarea':
$output .= html_print_textarea(
$data['name'],
$data['rows'],
$data['columns'],
((isset($data['value']) === true) ? $data['value'] : ''),
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['class']) === true) ? $data['class'] : '')
);
default:
// Ignore.
break;
}
if ($data['label']) {
$output .= '</div>';
if (!$data['return']) {
echo '</div>';
}
}
return $output;
}

View File

@ -3026,27 +3026,35 @@ function ui_print_datatable(array $parameters)
$filter .= $parameters['form']['html'];
}
$filter .= '<ul class="content">';
$filter .= '<ul class="datatable_filter content">';
foreach ($parameters['form']['inputs'] as $input) {
$filter .= '<li>';
$filter .= '<label>'.$input['label'].'</label>';
if ($input['type'] != 'select') {
$filter .= '<input type="'.$input['type'].'" ';
$filter .= ' style="'.$input['style'].'" ';
$filter .= ' class="'.$input['class'].'" ';
$filter .= ' value="'.$input['value'].'" ';
$filter .= ' name="'.$input['name'].'" id="'.$input['id'].'" />';
} else {
// Select.
$filter .= '<select name="'.$input['name'].'" ';
$filter .= '<select class="'.$input['class'].'"';
$filter .= ' style="'.$input['style'].'" ';
$filter .= ' name="'.$input['name'].'" ';
$filter .= 'id="'.$input['id'].'">';
foreach ($input['options'] as $opt => $selected) {
$filter .= '<option value="'.$opt['value'].'"';
if ($selected) {
$filter .= ' selected="yes" >';
}
foreach ($input['options'] as $key => $opt) {
if (is_array($opt)) {
$filter .= '<option value="'.$opt['value'].'"';
if ($opt['selected']) {
$filter .= ' selected="yes" >';
}
$filter .= __($opt['text']).'</option>';
$filter .= __($opt['text']).'</option>';
} else {
$filter .= '<option value="'.$key.'">'.$opt.'</option>';
}
}
$filter .= '</select>';
@ -3074,7 +3082,7 @@ function ui_print_datatable(array $parameters)
$filter .= '</li>';
$filter .= '</ul></form>';
$filter .= '</ul><div style="clear:both"></div></form>';
$filter = ui_toggle(
$filter,
__('Filter'),

View File

@ -0,0 +1,12 @@
#info_key .flex-row,
#new_key .flex-row {
margin: 1em auto;
max-width: 80%;
}
#info_key input,
#info_key select,
#new_key input,
#new_key select {
width: 80%;
}

View File

@ -96,14 +96,12 @@ table.dataTable tbody td {
}
.sorting_desc {
background: url(http://localhost/pandora_console/images/sort_down_green.png)
no-repeat;
background: url(../../images/sort_down_green.png) no-repeat;
background-position-x: left;
background-position-y: center;
}
.sorting_asc {
background: url(http://localhost/pandora_console/images/sort_up_green.png)
no-repeat;
background: url(../../images/sort_up_green.png) no-repeat;
background-position-x: left;
background-position-y: center;
}

View File

@ -502,6 +502,13 @@ select:-internal-list-box {
.no-text-imp {
font-size: 0 !important;
}
.flex-content-right {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-end;
align-content: flex-end;
}
.flex-column {
display: flex;
flex-direction: column;

View File

@ -312,3 +312,31 @@ a.pandora_pagination.current:hover {
border-color: #b6b6b6;
cursor: default;
}
/* Default datatable filter style */
.datatable_filter.content {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
}
.datatable_filter.content label {
margin-right: 1em;
}
.datatable_filter.content li {
flex: 1 1 auto;
margin: 1em auto;
}
.sorting_desc {
background: url(../../images/sort_down_green.png) no-repeat;
background-position-x: left;
background-position-y: center;
cursor: pointer;
}
.sorting_asc {
background: url(../../images/sort_up_green.png) no-repeat;
background-position-x: left;
background-position-y: center;
cursor: pointer;
}