Fix user profile add bugs
This commit is contained in:
parent
1c157ba2e4
commit
2251062d30
|
@ -489,6 +489,10 @@ if ($create_user) {
|
|||
if (!empty($json_profile)) {
|
||||
$json_profile = json_decode(io_safe_output($json_profile), true);
|
||||
foreach ($json_profile as $key => $profile) {
|
||||
if (is_array($profile) === false) {
|
||||
$profile = json_decode($profile, true);
|
||||
}
|
||||
|
||||
if (!empty($profile)) {
|
||||
$group2 = $profile['group'];
|
||||
$profile2 = $profile['profile'];
|
||||
|
@ -806,6 +810,10 @@ if ($add_profile && empty($json_profile)) {
|
|||
'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
|
||||
);
|
||||
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
|
||||
if ($return === false) {
|
||||
$is_err = true;
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
__('Profile added successfully'),
|
||||
|
@ -1439,7 +1447,7 @@ if ($config['admin_can_add_user']) {
|
|||
|
||||
echo '</div>';
|
||||
|
||||
html_print_input_hidden('json_profile', '');
|
||||
html_print_input_hidden('json_profile', $json_profile);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
@ -1566,7 +1574,12 @@ $(document).ready (function () {
|
|||
var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
|
||||
var is_err = '<?php echo $is_err; ?>';
|
||||
var data = [];
|
||||
var aux = 0;
|
||||
|
||||
if(json_profile.val() != '') {
|
||||
var data = JSON.parse(json_profile.val());
|
||||
}
|
||||
|
||||
$('input:image[name="add"]').click(function (e) {
|
||||
e.preventDefault();
|
||||
var profile = $('#assign_profile').val();
|
||||
|
@ -1588,10 +1601,14 @@ $(document).ready (function () {
|
|||
return;
|
||||
}
|
||||
|
||||
if (id_user === '' || is_err === 1) {
|
||||
if (id_user == '' || is_err == 1) {
|
||||
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
|
||||
data.push(new_json);
|
||||
json_profile.val('['+data+']');
|
||||
json_profile.val(JSON.stringify(data));
|
||||
profile_text = `<a href="index.php?sec2=godmode/users/configure_profile&id=${profile}">${profile_text}</a>`;
|
||||
group_img = `<img id="img_group_${aux}" src="" data-title="${group_text}" data-use_title_for_force_title="1" class="bot forced_title" alt="${group_text}"/>`;
|
||||
group_text = `<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=${group}">${group_img}${group_text}</a>`;
|
||||
|
||||
$('#table_profiles tr:last').before(
|
||||
`<tr>
|
||||
<td>${profile_text}</td>
|
||||
|
@ -1601,6 +1618,10 @@ $(document).ready (function () {
|
|||
<td>${img_delete}</td>
|
||||
</tr>`
|
||||
);
|
||||
|
||||
getGroupIcon(group, $(`#img_group_${aux}`));
|
||||
aux++;
|
||||
|
||||
} else {
|
||||
this.form.submit();
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
|
|||
* @param int User id
|
||||
* @param bool Show the tags select or not
|
||||
*/
|
||||
function profile_print_profile_table($id, $json_profile=false)
|
||||
function profile_print_profile_table($id, $json_profile=false, $return=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -246,6 +246,10 @@ function profile_print_profile_table($id, $json_profile=false)
|
|||
if ($json_profile !== false && empty($json_profile) !== true) {
|
||||
$profile_decoded = json_decode($json_profile);
|
||||
foreach ($profile_decoded as $profile) {
|
||||
if (is_object($profile) === false) {
|
||||
$profile = json_decode($profile);
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'id_grupo' => $profile->group,
|
||||
'id_perfil' => $profile->profile,
|
||||
|
@ -293,10 +297,10 @@ function profile_print_profile_table($id, $json_profile=false)
|
|||
$data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No');
|
||||
|
||||
$data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
|
||||
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
|
||||
$data['actions'] .= html_print_input_hidden('delete_profile', 1, true);
|
||||
$data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true);
|
||||
$data['actions'] .= html_print_input_hidden('id_user', $id, true);
|
||||
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
|
||||
$data['actions'] .= '</form>';
|
||||
|
||||
array_push($table->data, $data);
|
||||
|
@ -362,8 +366,7 @@ function profile_print_profile_table($id, $json_profile=false)
|
|||
$data['actions'] .= '</form>';
|
||||
|
||||
array_push($table->data, $data);
|
||||
|
||||
html_print_table($table);
|
||||
html_print_table($table, $return);
|
||||
if (!is_metaconsole()) {
|
||||
echo '</div>';
|
||||
}
|
||||
|
|
|
@ -740,3 +740,26 @@ function reveal_password(name) {
|
|||
revealElement.attr("src", imagesPath + "eye_show.png");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html img group icon.
|
||||
* @param {int} $id_group
|
||||
*/
|
||||
function getGroupIcon(id_group, img_container) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
dataType: "json",
|
||||
data: {
|
||||
page: "godmode/groups/group_list",
|
||||
get_group_json: 1,
|
||||
id_group: id_group
|
||||
},
|
||||
success: function(data) {
|
||||
img_container.attr("src", "images/groups_small/" + data["icon"] + ".png");
|
||||
},
|
||||
error: function() {
|
||||
img_container.attr("src", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue