diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php
index d63595d553..5097054b48 100644
--- a/pandora_console/godmode/menu.php
+++ b/pandora_console/godmode/menu.php
@@ -32,10 +32,11 @@ require_once 'include/functions_menu.php';
check_login();
-$access_console_node = !is_reporting_console_node();
+$access_console_node = is_reporting_console_node() === false;
$menu_godmode = [];
$menu_godmode['class'] = 'godmode';
+$menuGodmode = [];
if ($access_console_node === true) {
enterprise_include('godmode/menu.php');
}
diff --git a/pandora_console/include/class/Menu.class.php b/pandora_console/include/class/Menu.class.php
new file mode 100644
index 0000000000..bce38a89db
--- /dev/null
+++ b/pandora_console/include/class/Menu.class.php
@@ -0,0 +1,126 @@
+ACL_el_que_sea') === true) {
+ haz cosas aqui
+ }
+
+ */
+
+ public function __construct(
+ private string $name,
+ private array $items=[],
+ private array $menu=[]
+ ) {
+
+ }
+
+
+ /**
+ * Create Item function.
+ *
+ * @param MenuItem $menuItem Item for print.
+ *
+ * @return array.
+ */
+ public function generateItem(MenuItem $menuItem)
+ {
+ // Start with empty element.
+ $item = [];
+ if ($menuItem->canBeDisplayed() === true) {
+ // Handle of information.
+ if (empty($menuItem->getUrl()) === false) {
+ $urlPath = $menuItem->getUrl();
+ } else {
+ $urlPath = ui_get_full_url(
+ $menuItem->getSec().'/'.$menuItem->getSec2().'/'.$menuItem->getParameters()
+ );
+ }
+
+ // Creation of the line.
+ $item[] = '
';
+
+ // Create the link if is neccesary.
+ if (empty($urlPath) === false) {
+ $item[] = sprintf(
+ '%s',
+ $urlPath,
+ $menuItem->getText()
+ );
+ }
+
+ // Check if this item has submenu. If is the case, create it.
+ if ($menuItem->hasSubmenu() === true) {
+ $item[] = '';
+ $itemSubMenu = $menuItem->getSubmenu();
+ foreach ($itemSubMenu as $subMenu) {
+ $item[] = $this->generateItem($subMenu);
+ }
+
+ $item[] = '
';
+ }
+
+ $item[] = '';
+ }
+
+ return $item;
+ }
+
+
+ /**
+ * Generate the menu.
+ *
+ * @return void.
+ */
+ public function generateMenu()
+ {
+ $output = [];
+ /*
+ Estructura
+
+ - level0.item1
+ - level0.item2
+
+ - level1.item1
+ - level1.item2
+
+ - level0.item3
+
+ */
+ $output[] = '';
+ foreach ($this->items as $menuItem) {
+ // If the item must be displayed.
+ $this->generateItem($menuItem);
+ }
+
+ $output[] = '
';
+
+ $this->menu[] = $output;
+
+ }
+
+
+ /**
+ * Prints the menu.
+ *
+ * @return void.
+ */
+ public function printMenu()
+ {
+ if (empty($this->menu) === false) {
+ foreach ($this->menu as $element) {
+ echo $element."\n";
+ }
+ }
+ }
+
+
+}
diff --git a/pandora_console/include/class/MenuItem.class.php b/pandora_console/include/class/MenuItem.class.php
new file mode 100644
index 0000000000..3ec088ac72
--- /dev/null
+++ b/pandora_console/include/class/MenuItem.class.php
@@ -0,0 +1,431 @@
+id) === true && empty($this->text) === false) {
+ $this->id = str_replace(' ', '_', $text);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Set Text. The caption of the option.
+ *
+ * @param string $text Text.
+ *
+ * @return void.
+ */
+ public function setText(string $text)
+ {
+ $this->text = $text;
+ }
+
+
+ /**
+ * Get Text
+ *
+ * @return string.
+ */
+ public function getText()
+ {
+ return $this->text;
+ }
+
+
+ /**
+ * Set URL. Raw URL avoid sec and sec2 information.
+ *
+ * @param string $url Url.
+ *
+ * @return void.
+ */
+ public function setUrl(string $url)
+ {
+ $this->url = $url;
+ }
+
+
+ /**
+ * Get URL
+ *
+ * @return string.
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+
+ /**
+ * Set sec
+ *
+ * @param string $sec Sec.
+ *
+ * @return void.
+ */
+ public function setSec(string $sec)
+ {
+ $this->sec = $sec;
+ }
+
+
+ /**
+ * Get sec
+ *
+ * @return string.
+ */
+ public function getSec()
+ {
+ return $this->sec;
+ }
+
+
+ /**
+ * Set sec2
+ *
+ * @param string $sec2 Sec2.
+ *
+ * @return void.
+ */
+ public function setSec2(string $sec2)
+ {
+ $this->sec2 = $sec2;
+ }
+
+
+ /**
+ * Get sec2
+ *
+ * @return string.
+ */
+ public function getSec2()
+ {
+ return $this->sec2;
+ }
+
+
+ /**
+ * Set parameters. Added parameters for builded url (sec + sec2).
+ *
+ * @param string $parameters Parameters.
+ *
+ * @return void.
+ */
+ public function setParameters(string $parameters)
+ {
+ $this->parameters = $parameters;
+ }
+
+
+ /**
+ * Get parameters
+ *
+ * @return string.
+ */
+ public function getParameters()
+ {
+ return $this->parameters;
+ }
+
+
+ /**
+ * Set id. This is useful for identify the option selected.
+ *
+ * @param string $id Id.
+ *
+ * @return void.
+ */
+ public function setId(string $id)
+ {
+ $this->id = $id;
+ }
+
+
+ /**
+ * Get id
+ *
+ * @return string.
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+
+ /**
+ * Set icon. Must be relative path.
+ *
+ * @param string $icon Icon.
+ *
+ * @return void.
+ */
+ public function setIcon(string $icon)
+ {
+ $this->icon = $icon;
+ }
+
+
+ /**
+ * Get icon
+ *
+ * @return string.
+ */
+ public function getIcon()
+ {
+ return $this->icon;
+ }
+
+
+ /**
+ * Set class.
+ *
+ * @param string $class Class.
+ *
+ * @return void.
+ */
+ public function setClass(string $class)
+ {
+ $this->class = $class;
+ }
+
+
+ /**
+ * Get class
+ *
+ * @return string.
+ */
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+
+ /**
+ * Set submenu. Array with options under this selection.
+ *
+ * @param array $submenu Submenu.
+ *
+ * @return void.
+ */
+ public function setSubmenu(array $submenu)
+ {
+ $this->submenu = $submenu;
+ }
+
+
+ /**
+ * Get Submenu
+ *
+ * @return array.
+ */
+ public function getSubmenu()
+ {
+ return $this->submenu;
+ }
+
+
+ /**
+ * Set ACLs. Attach only allowed ACLs in an array.
+ *
+ * @param array $acl ACL.
+ *
+ * @return void.
+ */
+ public function setACL(array $acl)
+ {
+ $this->acl = $acl;
+ }
+
+
+ /**
+ * Get ACLs
+ *
+ * @return array.
+ */
+ public function getACL()
+ {
+ return $this->acl;
+ }
+
+
+ /**
+ * Set activation token.
+ *
+ * @param array $activationToken ACL.
+ *
+ * @return void.
+ */
+ public function setActivationToken(array $activationToken)
+ {
+ $this->activationToken = $activationToken;
+ }
+
+
+ /**
+ * Get activation token.
+ *
+ * @return array.
+ */
+ public function getActivationToken()
+ {
+ return $this->activationToken;
+ }
+
+
+ /**
+ * Set refr
+ *
+ * @param integer $refr Refr.
+ *
+ * @return void.
+ */
+ public function setRefr(int $refr)
+ {
+ $this->refr = $refr;
+ }
+
+
+ /**
+ * Get Refr
+ *
+ * @return integer.
+ */
+ public function getRefr()
+ {
+ return $this->refr;
+ }
+
+
+ /**
+ * Set display. The item will be exists if this value is true.
+ *
+ * @param boolean $display Display.
+ *
+ * @return void.
+ */
+ public function setDisplay(bool $display)
+ {
+ $this->display = $display;
+ }
+
+
+ /**
+ * Get Display
+ *
+ * @return boolean.
+ */
+ public function getDisplay()
+ {
+ return $this->display;
+ }
+
+
+ /**
+ * Set enabled
+ *
+ * @param boolean $enabled Enabled.
+ *
+ * @return void.
+ */
+ public function setEnabled(bool $enabled)
+ {
+ $this->enabled = $enabled;
+ }
+
+
+ /**
+ * Get enabled
+ *
+ * @return boolean.
+ */
+ public function getEnabled()
+ {
+ return $this->enabled;
+ }
+
+
+ /**
+ * Returns true if this object have submenu.
+ *
+ * @return boolean.
+ */
+ public function hasSubmenu()
+ {
+ return empty($this->getSubmenu()) === false;
+ }
+
+
+ /**
+ * Returns true if this object can be displayed.
+ *
+ * @return boolean.
+ */
+ public function canBeDisplayed()
+ {
+ // Global config.
+ global $config;
+ $response = true;
+
+ if ($this->getDisplay() === false) {
+ // Display value is false.
+ $response = false;
+ } else if (empty($this->getACL()) === false) {
+ // Check all the ACLs.
+ $acls = $this->getACL();
+ foreach ($acls as $acl) {
+ $response = check_acl($config['id_user'], 0, $acl);
+ // In false case, end the check.
+ if ($response === false) {
+ break;
+ }
+ }
+ }
+
+ return $response;
+ }
+
+
+}
diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php
index 8b1f1deaae..5ac1239d9f 100644
--- a/pandora_console/include/functions_menu.php
+++ b/pandora_console/include/functions_menu.php
@@ -53,12 +53,12 @@ function menu_print_menu(&$menu)
$sec = (string) get_parameter('sec');
$sec2 = (string) get_parameter('sec2');
- if ($sec2 == 'operation/agentes/ver_agente') {
+ if ($sec2 === 'operation/agentes/ver_agente') {
$sec2 = 'godmode/agentes/configurar_agente';
- } else if ($sec2 == 'godmode/servers/discovery') {
+ } else if ($sec2 === 'godmode/servers/discovery') {
$wiz = (string) get_parameter('wiz');
$sec2 = 'godmode/servers/discovery&wiz='.$wiz;
- } else if ($sec2 == 'godmode/groups/group_list') {
+ } else if ($sec2 === 'godmode/groups/group_list') {
$tab = (string) get_parameter('tab');
if ($tab === 'credbox') {
$sec2 = 'godmode/groups/group_list&tab='.$tab;
@@ -70,58 +70,39 @@ function menu_print_menu(&$menu)
$menu_selected = false;
$allsec2 = explode('sec2=', $_SERVER['REQUEST_URI']);
- if (isset($allsec2[1])) {
+ if (isset($allsec2[1]) === true) {
$allsec2 = $allsec2[1];
} else {
$allsec2 = $sec2;
}
// Open list of menu.
- echo '