示例#1
0
 /**
  * Třída pro hromadné operace s konfigurací
  *
  * @param null $ItemID
  */
 public function __construct($table = null, $column = null)
 {
     $this->table = $table;
     $this->column = $column;
     parent::__construct();
     $this->registerClass('IETimeperiod');
     $this->registerClass('IECommand');
     $this->registerClass('IEService');
     $this->registerClass('IEServicegroup');
     $this->registerClass('IEContact');
     $this->registerClass('IEContactgroup');
     $this->registerClass('IEHost');
     $this->registerClass('IEHostgroup');
 }
示例#2
0
 /**
  * Vypíše výsledek SQL dotazu v požadovaném tvaru
  *
  * @param type $queryRaw
  */
 public function output($queryRaw = null)
 {
     if (is_null($queryRaw)) {
         $queryRaw = 'SELECT * FROM `' . $this->handledObejct->getMyTable() . '`';
     }
     switch (EaseShared::webPage()->getRequestValue('export')) {
         case 'csv':
             $this->getCsv($queryRaw);
             break;
         case 'pdf':
             $this->getPdf($queryRaw);
             break;
         default:
             // header("Content-type: application/json");
             echo $this->getJson($queryRaw);
             break;
     }
 }
示例#3
0
<?php

/**
 * Icinga Editor - hlavní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEcfg.php';
$oPage->onlyForLogged();
$oPage->addItem(new IEPageTop(_('Icinga Editor')));
IECfg::reloadIcinga();
$oPage->addItem(new IEPageBottom());
$oPage->draw();
示例#4
0
 /**
  * Smaže kontakt i jeho subkontakty
  *
  * @return boolean
  */
 public function delete($id = null)
 {
     if (is_null($id)) {
         $id = $this->getId();
     } else {
         if ($id != $this->getId()) {
             $this->loadFromMySQL($id);
         }
     }
     $childs = $this->getChilds();
     if ($childs) {
         $parent = $id;
         foreach ($childs as $child_id => $child) {
             $this->delete($child_id);
         }
         $this->loadFromMySQL($parent);
         $id = $parent;
     }
     $contactgroup = new IEContactgroup();
     $contactgroups = $this->myDbLink->queryTo2DArray('SELECT ' . $contactgroup->getmyKeyColumn() . ' FROM ' . $contactgroup->myTable . ' WHERE members LIKE \'%' . $this->getName() . '%\'');
     if (count($contactgroups)) {
         foreach ($contactgroups as $contactgroupID) {
             $contactgroup->loadFromMySQL((int) $contactgroupID);
             if ($contactgroup->delMember('members', null, $this->getName())) {
                 if ($contactgroup->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán ze skupiny <strong>%s</strong>'), $this->getName(), $contactgroup->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán ze skupiny <strong>%s</strong>'), $this->getName(), $contactgroup->getName()), 'warning');
             }
         }
     }
     $service = new IEService();
     $services = $this->myDbLink->queryTo2DArray('SELECT ' . $service->getmyKeyColumn() . ' FROM ' . $service->myTable . ' WHERE contacts LIKE \'%' . $this->getName() . '%\'');
     if (count($services)) {
         foreach ($services as $serviceID) {
             $service->loadFromMySQL((int) $serviceID);
             if ($service->delMember('contacts', $id)) {
                 if ($service->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán ze služby <strong>%s</strong>'), $this->getName(), $service->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán ze služby <strong>%s</strong>'), $this->getName(), $service->getName()), 'warning');
             }
         }
     }
     $host = new IEHost();
     $hosts = $this->myDbLink->queryTo2DArray('SELECT ' . $host->getmyKeyColumn() . ' FROM ' . $host->myTable . ' WHERE contacts LIKE \'%' . $this->getName() . '%\'');
     if (count($hosts)) {
         foreach ($hosts as $hostID) {
             $host->loadFromMySQL((int) $hostID);
             if ($host->delMember('contacts', $id)) {
                 if ($host->saveToMySQL()) {
                     $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> byl odebrán z hosta <strong>%s</strong>'), $this->getName(), $host->getName()), 'success');
                 }
             } else {
                 $this->addStatusMessage(sprintf(_('Kontakt <strong>%s</strong> nebyl odebrán z hosta <strong>%s</strong>'), $this->getName(), $host->getName()), 'warning');
             }
         }
     }
     $this->myDbLink->exeQuery('DELETE FROM `' . $this->myTable . '` WHERE `parent_id`=' . $id);
     return parent::delete($id);
 }
示例#5
0
 /**
  * Načte data do objektu
  *
  * @param  array  $data
  * @param  string $dataPrefix
  * @return int    počet převzatých řádek
  */
 public function takeData($data, $dataPrefix = null)
 {
     return parent::takeData($data, $dataPrefix);
 }
    /**
     * Nasazení externích skriptů
     */
    public function deployScripts()
    {
        if (count($this->scriptsToDeploy)) {
            switch ($this->platform) {
                case 'windows':
                    $this->nscBatArray[] = "\n" . 'echo ^<h2^>' . _('Skripty') . '^</h2^> >> %ICIEDIT_HTML%
';
                    break;
            }
            foreach ($this->scriptsToDeploy as $script_name => $script_id) {
                switch ($this->platform) {
                    case 'windows':
                        $this->nscBatArray[] = "\n" . 'echo ^<a data-role="script" href="' . IECfg::getBaseURL() . 'scriptget.php?script_id=' . $script_id . '"^>' . $script_name . '^</a^>^<br^> >> %ICIEDIT_HTML%
';
                        break;
                    case 'linux':
                        $this->nscBatArray[] = "\n" . '
# ' . $script_name . '
curl "' . IECfg::getBaseURL() . 'scriptget.php?script_id=' . $script_id . '"
';
                        break;
                    default:
                        $this->nscBatArray[] = $this->nscBatArray[] = "\n" . '
' . $this->nscvar . ' test
';
                        break;
                }
            }
        }
    }
示例#7
0
 /**
  * Infopanel objektu
  *
  * @param IECfg $subject
  */
 public function __construct($subject)
 {
     parent::__construct(_('informace'), 'info', $subject->getInfoBlock());
 }
示例#8
0
 /**
  * Vytvoří nového hosta patřícího rovnou do výchozí skupiny uživatele
  *
  * @param array $data asiciativní pole dat
  *
  * @return int|null id nově vloženého řádku nebo null, pokud se data
  * nepovede vložit
  */
 public function insertToMySQL($data = null)
 {
     if (!is_null($data)) {
         $this->takeData($data);
     }
     $hostgroup = new IEHostgroup($this->user->getUserLogin());
     $this->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
     return parent::insertToMySQL();
 }
示例#9
0
 /**
  * Načte data do objektu
  *
  * @param  array  $data
  * @param  string $dataPrefix
  * @return int    počet převzatých řádek
  */
 public function takeData($data, $dataPrefix = null)
 {
     if (!isset($data['command_type'])) {
         if (strstr($data[$this->nameColumn], 'notify')) {
             $data['command_type'] = 'notify';
         } else {
             $data['command_type'] = 'check';
         }
     }
     return parent::takeData($data, $dataPrefix);
 }
示例#10
0
 /**
  * Smaže hostgrupu i její použití v hostech
  *
  * @param int $id
  * @return boolean
  */
 function delete($id = null)
 {
     if (isset($id) && $this->getId() != $id) {
         $this->loadFromSQL($id);
     } else {
         $id = $this->getId();
     }
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn), array('hostgroups' => '%' . $this->getName() . '%'));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $hostgroupNames = $host->getDataValue('hostgroups');
         if ($hostgroupNames) {
             foreach ($hostgroupNames as $hostgroupId => $hostgroupName) {
                 if ($hostgroupId == $this->getId()) {
                     if ($host->delMember('hostgroups', $hostgroupId, $hostgroupName)) {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'error');
                     }
                 }
             }
         }
     }
     $subgroup = new IEHostgroup();
     $subgroups = $subgroup->getColumnsFromMySQL(array($subgroup->myKeyColumn), array('hostgroup_members' => '%' . $this->getName() . '%'));
     foreach ($subgroups as $subgroupInfo) {
         $subgroupId = intval(current($subgroupInfo));
         $subgroup->loadFromMySQL($subgroupId);
         $subgroupgroupNames = $subgroup->getDataValue('hostgroup_members');
         if ($subgroupgroupNames) {
             foreach ($subgroupgroupNames as $subgroupgroupId => $subgroupgroupName) {
                 if ($subgroupgroupId == $this->getId()) {
                     if ($subgroup->delMember('hostgroup_members', $subgroupgroupId, $subgroupgroupName)) {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'error');
                     }
                 }
             }
         }
     }
     return parent::delete($id);
 }
示例#11
0
    /**
     * Vložení skriptu
     */
    function finalize()
    {
        $grid_id = $this->getTagID();
        if ($this->getTagProperty('columnsAutoSize')) {
            $this->options['onSuccess'] = 'function() { addGrid($("#' . $grid_id . '"), this)}';
            //Patch Grid Responisive
            $grid_js = '
        var grids=[];
            $(window).resize(function() {
                //Resize all the grids on the page
                //Only resize the ones whoes size has actually changed...
                for(var i in grids) {
                    if(grids[i].width!=grids[i].$grid.width()) {
                        sizeGrid(grids[i]);
                    }
                }
            });';
            $grid_js .= '
            //Keep track of all grid elements and current sizes
            function addGrid($table, grid) {
                var $grid = $table.closest(\'.flexigrid\');
                var data = {$table:$table, $grid:$grid, grid:grid, width:$grid.width()};
                grids.push(data);
                sizeGrid(data);
            }';
            $grid_js .= '
            //Make all cols with auto size fill remaining width..
            function sizeGrid(data) {
                //Auto size the middle col.
                var totalWidth = data.$grid.outerWidth()-15; //15 padding - not found where this is set

                var fixedWidth = 0;
                var fluidCols = [];
                for(var i=0; i<data.grid.colModel.length; i++ ) {
                    if( !isNaN(data.grid.colModel[i].width) ) {
                        fixedWidth+=data.$table.find(\'tr:eq(\'+i+\') td:eq(\'+i+\'):visible\').outerWidth(true);
                    } else {
                        fluidCols.push(i);
                    }
                }

                var newWidth = (totalWidth-fixedWidth)/fluidCols.length;
                for(var i in fluidCols) {
                    data.grid.g.colresize = { n:fluidCols[i], nw:newWidth };
                    data.grid.g.dragEnd( );
                }

                data.width = data.$grid.width();
            }';
        } else {
            $grid_js = '';
        }
        if ($this->select) {
            $this->options['query'] = current($this->select);
            $this->options['qtype'] = key($this->select);
        }
        if ($this->dblclk2edit) {
            $this->options['onDoubleClick'] = 'function(g) {
                    var id = $(g).attr(\'id\');
                    id = id.substring(id.lastIndexOf(\'row\')+3);
                    $(location).attr(\'href\',\'' . $this->dataSource->keyword . '.php?' . $this->dataSource->getMyKeyColumn() . '=\' +id);

            }';
        }
        $this->options['getGridClass'] = 'function(g) { this.g=g; return g; }';
        EaseShared::webPage()->addJavaScript("\n" . '$(\'#' . $grid_id . '\').flexigrid({ ' . EaseJQueryPart::partPropertiesToString($this->options) . ' }); ' . $grid_js, null, true);
    }
示例#12
0
 /**
  * Vrací všechna data
  *
  * @return array
  */
 public function getAllData()
 {
     $allData = parent::getAllData();
     foreach ($allData as $adKey => $AD) {
         $params = $allData[$adKey]['check_command-params'];
         if (strlen($allData[$adKey]['check_command-remote'])) {
             if (!is_null($params)) {
                 $allData[$adKey]['check_command'] .= '!' . $allData[$adKey]['check_command-remote'] . '!' . $params;
             } else {
                 $allData[$adKey]['check_command'] .= '!' . $allData[$adKey]['check_command-remote'];
             }
         } else {
             if (strlen($params)) {
                 $allData[$adKey]['check_command'] .= '!' . $params;
             }
         }
         unset($allData[$adKey]['check_command-remote']);
         unset($allData[$adKey]['check_command-params']);
         unset($allData[$adKey]['tcp_port']);
         unset($allData[$adKey]['configurator']);
         unset($allData[$adKey]['price']);
     }
     return $allData;
 }
示例#13
0
 /**
  * Vrací mazací tlačítko
  *
  * @param  string                     $name
  * @param  string                     $urlAdd Předávaná část URL
  * @return \EaseJQConfirmedLinkButton
  */
 public function deleteButton($name = null, $addUrl = '')
 {
     return parent::deleteButton(_('Časovou periodu'), $addUrl);
 }
示例#14
0
 /**
  * Naimportuje konfiguraci ze souboru
  *
  * @param  string $cfgFile
  * @return int    počet uložených konfigurací
  */
 public function importCfgFile($cfgFile)
 {
     return $this->importCfg(IECfg::readRawConfigFile($cfgFile, $this));
 }
示例#15
0
            list($msg, $WarningCount) = explode(':', $line);
            if (intval(trim($WarningCount))) {
                $oUser->addStatusMessage(sprintf(_('celkem %s varování'), $WarningCount), 'warning');
            } else {
                $oUser->addStatusMessage(_('test proběhl bez varování'), 'success');
            }
        }
        if (strstr($line, 'Total Errors')) {
            list($msg, $errorCount) = explode(':', $line);
            if (intval(trim($errorCount))) {
                $oUser->addStatusMessage(sprintf(_('celkem %s chyb'), $errorCount), 'warning');
            } else {
                $oUser->addStatusMessage(_('test proběhl bez chyb'), 'success');
            }
        }
    }
    fclose($testing);
    if (!intval($errorCount) && !is_null($WarningCount)) {
        if (IECfg::reloadIcinga()) {
            $oPage->container->addItem(_('Všechny vaše konfigurační soubory byly přegenerovány'));
            $oPage->container->addItem(new EaseTWBLinkButton('main.php', _('Hotovo') . ' ' . EaseTWBPart::GlyphIcon('ok-sign'), 'success'));
            EaseShared::user()->setSettingValue('unsaved', false);
        }
    }
}
if ($oUser->getSettingValue('admin') && isset($originalUserID)) {
    EaseShared::user(new EaseUser($originalUserID));
    EaseShared::user()->loginSuccess();
}
$oPage->addItem(new IEPageBottom());
$oPage->draw();
示例#16
0
 /**
  * Sql fragment dotazu specifický pro objekt.
  *
  * @covers IECfg::getWhere
  */
 public function testGetWhere()
 {
     $this->assertEmpty($this->object->getWhere());
 }