histogram: Make histograms crash less
[ninja.git] / application / controllers / configuration.php
blob00f87265c7f5a68524becd671d4a19a7a29a2ead
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * Configuration controller used to connect to Nacoma
4 * Requires authentication
6 * op5, and the op5 logo are trademarks, servicemarks, registered servicemarks
7 * or registered trademarks of op5 AB.
8 * All other trademarks, servicemarks, registered trademarks, and registered
9 * servicemarks mentioned herein may be the property of their respective owner(s).
10 * The information contained herein is provided AS IS with NO WARRANTY OF ANY
11 * KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A
12 * PARTICULAR PURPOSE.
14 class Configuration_Controller extends Authenticated_Controller {
16 public $model = false;
18 /**
19 * Enable links from Ninja to Nacoma
21 * If 'service' is passed as GET, it will be used
22 * Checks are also made that NACOMA is configured in config file
24 * @param string $type
25 * @param string $name
27 public function configure($type=false, $name=false)
29 if( !Auth::instance()->authorized_for('configuration_information')) {
30 $this->template->content = $this->add_view('unauthorized');
31 $this->template->content->error_message = _("It appears as though you aren't authorized to access the configuration interface.");
32 $this->template->content->error_description = _('Read the section of the documentation that deals with authentication and authorization in the CGIs for more information.');
33 return false;
35 $scan = $this->input->get('scan', null);
36 $type = $this->input->get('type', $type);
37 $name = $this->input->get('name', $name);
38 $service = $this->input->get('service', false);
39 $page = $this->input->get('page', false);
40 if (Kohana::config('config.nacoma_path')===false) {
41 return false;
43 $type = trim($type);
44 $name = trim($name);
46 $target_link = null;
48 if ($page)
49 $target_link = $page;
50 if (!empty($type) && !empty($name)) {
51 if (strstr($type, 'group')) {
52 $target_link = 'edit.php?obj_type='.$type.'&obj_name='.urlencode($name);
53 } else {
54 if (!empty($service)) {
55 $target_link = 'edit.php?obj_type='.$type.'&host='.urlencode($name).'&service='.urlencode($service);
56 } else {
57 $target_link = 'edit.php?obj_type='.$type.'&'.$type.'='.urlencode($name);
60 } elseif (!empty($type)) {
61 $target_link = 'edit.php?obj_type='.$type;
62 } elseif (!empty($scan)) {
63 $target_link = 'host_wizard.php?action='.$scan;
66 # set the username so Nacoma can pick it up
67 $this->template->disable_refresh = true;
68 $this->template->content = '<iframe src="'.Kohana::config('config.nacoma_path').'/'.$target_link.'" style="width: 100%; height: 768px" frameborder="0" id="iframe"></iframe>';
69 $this->template->title = _('Configuration ยป Configure');
70 $this->template->nacoma = true;
71 $this->xtra_js[] = $this->add_path('/js/iframe-adjust.js');
72 $this->xtra_js[] = $this->add_path('/js/nacoma-urls.js');