From cb94692491b1d0100ce3dbe6e89170a08955d142 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Feb 2019 14:30:03 +0100 Subject: [PATCH] Added function addBreadcrum in Wizard main Former-commit-id: ac40c2fd49ff02a84dc6752c4ea99309a3d4440f --- pandora_console/godmode/servers/discovery.php | 10 + .../godmode/wizards/Cloud.class.php | 267 ------------------ .../godmode/wizards/Wizard.main.php | 18 ++ 3 files changed, 28 insertions(+), 267 deletions(-) delete mode 100755 pandora_console/godmode/wizards/Cloud.class.php diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 235ae01e78..489293c862 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -49,6 +49,16 @@ function get_wiz_class($str) // Dynamic class loader. $classes = glob($config['homedir'].'/godmode/wizards/*.class.php'); +if (enterprise_installed()) { + $ent_classes = glob( + $config['homedir'].'/enterprise/godmode/wizards/*.class.php' + ); + if ($ent_classes === false) { + $ent_classes = []; + } + $classes = array_merge($classes, $ent_classes); +} + foreach ($classes as $classpath) { include_once $classpath; } diff --git a/pandora_console/godmode/wizards/Cloud.class.php b/pandora_console/godmode/wizards/Cloud.class.php deleted file mode 100755 index 1de88c2ca7..0000000000 --- a/pandora_console/godmode/wizards/Cloud.class.php +++ /dev/null @@ -1,267 +0,0 @@ -setBreadcrum([]); - - $this->task = []; - $this->msg = $msg; - $this->icon = $icon; - $this->label = $label; - $this->page = $page; - $this->url = ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=cloud' - ); - - return $this; - } - - - /** - * Run AmazonWS class. Entry point. - * - * @return void - */ - public function run() - { - global $config; - - // Load styles. - parent::run(); - - $mode = get_parameter('mode', null); - - if ($mode === null) { - $this->setBreadcrum(['Cloud']); - $this->printHeader(); - - echo 'Amazon WS'; - - return; - } - - if ($mode == 'amazonws') { - $this->setBreadcrum( - [ - 'Cloud', - 'Amazon AWS', - ] - ); - $this->printHeader(); - return $this->runAmazonAWS(); - } - - return null; - } - - - /** - * Checks if environment is ready, - * returns array - * icon: icon to be displayed - * label: label to be displayed - * - * @return array With data. - **/ - public function load() - { - return [ - 'icon' => $this->icon, - 'label' => $this->label, - 'url' => $this->url, - ]; - } - - - // ///////////////////////////////////////////////////////////////////////// - // Extra methods. - // ///////////////////////////////////////////////////////////////////////// - - - /** - * Amazon AWS pages manager. - * - * @return void - */ - public function runAmazonAWS() - { - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Agent Management' - ); - include 'general/noaccess.php'; - return; - } - - // -------------------------------. - // Page 0. wizard starts HERE. - // -------------------------------. - if (!isset($this->page) || $this->page == 0) { - if (isset($this->page) === false - || $this->page == 0 - ) { - $this->printForm( - [ - 'form' => [ - 'action' => '#', - 'method' => 'POST', - ], - 'inputs' => [ - [ - 'label' => __('AWS access key ID'), - 'arguments' => [ - 'name' => 'aws_id', - 'value' => '', - 'type' => 'text', - ], - ], - [ - 'label' => __('AWS secret access key'), - 'arguments' => [ - 'name' => 'aws_id', - 'value' => '', - 'type' => 'text', - ], - ], - [ - 'arguments' => [ - 'name' => 'page', - 'value' => ($this->page + 1), - 'type' => 'hidden', - 'return' => true, - ], - ], - [ - 'arguments' => [ - 'name' => 'submit', - 'label' => __('Validate'), - 'type' => 'submit', - 'attributes' => 'class="sub wand"', - 'return' => true, - ], - ], - ], - ] - ); - } - } - - if ($this->page == 1) { - echo 'TODO'; - // TODOS. - } - - if ($this->page == 100) { - return [ - 'result' => $this->result, - 'id' => $this->id, - 'msg' => $this->msg, - ]; - } - } - - -} diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 709e601fa5..288a32fc47 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -78,6 +78,22 @@ class Wizard { return $this->breadcrum; } + + + /** + * Add an element to breadcrum array. + * + * @param string $string Element to add to breadcrum. + * + * @return void + */ + protected function addBreadcrum($string) { + if (empty($string)) { + return; + } + + array_push($this->breadcrum, $string); + } /** @@ -507,4 +523,6 @@ class Wizard array_map('self::printBigButtonElement', $list_data); echo ''; } + + }