toArray(); $sec = 'gusuarios'; if (is_metaconsole() === true) { $sec = 'advanced'; } $edit_url = 'index.php?sec='.$sec; $edit_url .= '&sec2=godmode/users/configure_token&pure=0'; $edit_url .= '&id_token='.$itemArray['idToken']; $delete_url = 'index.php?sec='.$sec; $delete_url .= '&sec2=godmode/users/token_list'; $delete_url .= '&pure=0&delete_token=1'; $delete_url .= '&id_token='.$itemArray['idToken']; $itemArray['label'] = html_print_anchor( [ 'href' => $edit_url, 'content' => $itemArray['label'], ], true ); if (empty($itemArray['validity']) === true) { $itemArray['validity'] = __('Never'); } else { $itemArray['validity'] = date($config['date_format'], strtotime($itemArray['validity'])); } if (empty($itemArray['lastUsage']) === true) { $itemArray['lastUsage'] = __('Never'); } else { $itemArray['lastUsage'] = human_time_comparation($itemArray['lastUsage']); } $itemArray['options'] = '
'; $itemArray['options'] .= html_print_anchor( [ 'href' => $edit_url, 'content' => html_print_image( 'images/edit.svg', true, [ 'title' => __('Show'), 'class' => 'main_menu_icon invert_filter', ] ), ], true ); $itemArray['options'] .= html_print_anchor( [ 'href' => $delete_url, 'onClick' => 'if (!confirm(\' '.__('Are you sure?').'\')) return false;', 'content' => html_print_image( 'images/delete.svg', true, [ 'title' => __('Delete'), 'class' => 'invert_filter main_menu_icon', ] ), ], true ); $itemArray['options'] .= '
'; return $itemArray; }, $return['data'] ); } // Datatables format: RecordsTotal && recordsfiltered. echo json_encode( [ 'data' => $return['data'], 'recordsTotal' => $return['paginationData']['totalRegisters'], 'recordsFiltered' => $return['paginationData']['totalRegisters'], ] ); // Capture output. $response = ob_get_clean(); } catch (Exception $e) { echo json_encode(['error' => $e->getMessage()]); return; } // If not valid, show error with issue. json_decode($response); if (json_last_error() == JSON_ERROR_NONE) { // If valid dump. echo $response; } else { echo json_encode( ['error' => $response] ); } return; } // Token for JWT auth in metaconsole. if ($get_jwt_for_login === true) { if (is_metaconsole() === true && ((bool) users_is_admin($config['id_user']) === true || (bool) can_user_access_node() === true) && empty($config['JWT_signature']) === false ) { $jwtRepository = new JWTRepository($config['JWT_signature']); $token = $jwtRepository->create(); echo json_encode(['success' => true, 'data' => $token]); } else { echo json_encode(['success' => false, 'error' => 'User does not have permission or is not a metaconsole.']); } return; }