public function finalize() { parent::finalize(); reset($this->platforms); foreach ($this->pageParts as $optionName => $option) { $platform = current($this->platforms); if (isset($platform['image'])) { $this->pageParts[$optionName]->setTagProperties(array('data-image' => $platform['image'])); } next($this->platforms); } EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true); EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").change(function() { var oDropdown = $("#' . $this->getTagID() . '").msDropdown().data("dd"); var text = oDropdown.get("selectedText"); console.log(text); var saverClass = $("[name=\'class\']").val(); var keyId = $(".keyId").val(); var columnName = $(this).attr("name"); var jqxhr = $.post( "datasaver.php?SaverClass=" + saverClass , { Field: columnName, Value: text, Key: keyId } , function() { console.log( "success" ); }) .done(function() { console.log( "second success" ); }) .fail(function() { console.log( "error" ); }); });', null, true); EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js'); EaseShared::webPage()->includeCss('css/msdropdown/dd.css'); }
function afterAdd() { $this->addItem(new EaseTWBFormGroup(_('Jméno'), new EaseHtmlInputTextTag('host_name', EaseShared::webPage()->getRequestValue('host_name')), _('hostname'), _('DOMAIN\\machine'), _('Název sledovaného stroje'))); $this->addItem(new EaseTWBFormGroup(_('Platforma'), new IEPlatformSelector('platform'), null, _('Platforma sledovaného stroje'))); $this->addItem(new EaseTWSubmitButton(_('Založit') . ' ' . EaseTWBPart::GlyphIcon('forward'), 'success')); $this->addItem(new EaseHtmlInputHiddenTag('host_group', EaseShared::webPage()->getRequestValue('host_group'))); }
/** * Nastavuje titulek * * @param string $pageTitle */ public function __construct($pageTitle = null) { parent::__construct('header'); if (!is_null($pageTitle)) { EaseShared::webPage()->setPageTitle($pageTitle); } }
/** * Zpracování formuláře * * @return boolean */ public function reconfigureService() { $config = array(); $page = EaseShared::webPage(); foreach ($page->getRequestValues() as $key => $value) { switch ($key) { case 'ShowAll': if ($value) { $config[] = 'ShowAll'; } break; case 'MaxWarn': case 'MaxCrit': case 'MinWarn': case 'MinCrit': case 'warn': case 'crit': case 'type': if ($value) { $config[] = $key . '=' . $value; } break; default: break; } } if (count($config)) { $this->tweaker->service->setDataValue('check_command-params', implode(' ', $config)); return parent::reconfigureService(); } return FALSE; }
public function finalize() { parent::finalize(); EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true); EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js'); EaseShared::webPage()->includeCss('css/msdropdown/dd.css'); }
/** * Formulář cíle cesty pro hosta * @param IEHost $host * @return \EaseTWBPanel */ function endRouteForm($host) { $form = new EaseTWBForm('traceto'); $form->addInput(new IEHostSelect('dest_host_id'), _('Gateway'), null, _('Zvolte již definovanou gateway, nabo zadejte konkrétní adresu.')); $form->addInput(new EaseHtmlInputTextTag('ip'), _('IP Adresa'), null, _('První pingnutelná veřejá adresa po cestě z hostu na monitorovací server')); $form->addItem(new EaseTWSubmitButton(_('Sledovat cestu'), 'success', array('onClick' => "\$('#preload').css('visibility', 'visible');"))); EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux'))); return new EaseTWBPanel(_('Volba cíle sledování') . ': ' . $host->getName(), 'default', $form, _('Vyberte hosta nebo zadejte IP adresu')); }
/** * Zpracování formuláře * * @return boolean */ public function reconfigureService() { $config = array(); $page = EaseShared::webPage(); foreach ($page->getRequestValues() as $key => $value) { switch ($key) { case 'NetDrive': case 'Drive': if ($value == 'CheckAll') { $config['Drive'] = 'CheckAll'; $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Všechny jednotky')); } else { if (strlen(trim($value)) && $value != '\\\\') { if (strstr($value, '\\\\')) { $config['Drive'] = 'Drive=' . $value; $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, IENSCPConfigGenerator::stripServiceName(_('NetDisk') . ' ' . $value)); $this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo síťové jednotky %s: '), $value)); } else { $config['Drive'] = 'Drive=' . $value . ':'; $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Disk') . ' ' . strtoupper($value) . ':'); $this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo disku %s: '), strtoupper($value))); } } } break; case 'ShowAll': if ($value) { $config[] = 'ShowAll'; } break; case 'MaxWarn': case 'MaxCrit': case 'MinWarn': case 'MinCrit': case 'MaxWarnFree': case 'MaxCritFree': case 'MinWarnFree': case 'MinCritFree': case 'MaxWarnUsed': case 'MaxCritUsed': case 'MinWarnUsed': case 'MinCritUsed': if ($value) { $config[] = $key . '=' . $value; } break; default: break; } } if (count($config)) { $this->tweaker->service->setDataValue('check_command-params', implode(' ', $config)); return parent::reconfigureService(); } return FALSE; }
function finalize() { EaseShared::webPage()->includeCss('css/slider.css'); EaseShared::webPage()->includeJavaScript('js/bootstrap-slider.js'); $id = $this->getTagID(); if ($id) { $me = '#' . $id; } else { $me = "input[name='" . $this->getTagName() . "']"; } $this->addJavaScript('$("' . $me . '").slider();', null, true); }
/** * Zpracování formuláře * * @return boolean */ public function reconfigureService() { $page = EaseShared::webPage(); $wt = $page->getRequestValue('wt', 'float'); $ct = $page->getRequestValue('ct', 'float'); $wp = str_replace('%', '', $page->getRequestValue('wp')); $cp = str_replace('%', '', $page->getRequestValue('cp')); if ($wt && $ct && $wp && $cp) { $command = $wt . ',' . $wp . '%!' . $ct . ',' . $cp . '%'; $this->tweaker->service->setDataValue('check_command-params', $command); return parent::reconfigureService(); } return FALSE; }
public function finalize() { parent::finalize(); reset($this->services); foreach ($this->pageParts as $optionName => $option) { $platform = current($this->services); if (isset($platform['image'])) { $this->pageParts[$optionName]->setTagProperties(array('data-image' => $platform['image'])); } next($this->services); } EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true); EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js'); EaseShared::webPage()->includeCss('css/msdropdown/dd.css'); }
public function finalize() { EaseShared::webPage()->includeCss('twitter-bootstrap/css/fuelux.css', true); EaseShared::webPage()->includeJavascript("/javascript/twitter-bootstrap/fuelux.js"); EaseShared::webPage()->addJavascript("\$('#" . $this->getTagID() . "').loader();"); EaseShared::webPage()->addCSS(' #' . $this->getTagID() . '{ position: absolute; top: 50%; left: 50%; margin-top: -50px; margin-left: -50px; width: 100px; height: 100px; visibility: hidden; } '); }
public function finalize() { $subcontatcts = $this->contact->getChilds(); foreach ($subcontatcts as $subcontatctID => $subcontatctInfo) { $this->addItem(new EaseTWBButtonDropdown($subcontatctInfo['type'] . ' ' . $subcontatctInfo['contact'], 'success', 'xs', array(new EaseHtmlATag('contact.php?parent_id=' . $this->contact->getId() . '&contact_id=' . $subcontatctID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Vlastnosti')), new EaseHtmlATag('?contact_id=' . $this->contact->getId() . '&delsubcont_id=' . $subcontatctID, EaseTWBPart::GlyphIcon('minus') . ' ' . _('smazat') . ' ' . $subcontatctInfo['type'])))); unset($this->subcontactTypes[$subcontatctInfo['type']]); $this->addItem('<br/>'); } if (count($this->subcontactTypes)) { $form = new EaseTWBForm('ContatctTweak', 'contacttweak.php'); $form->addItem(new EaseHtmlSelect('contact', $this->subcontactTypes)); $form->addItem(new EaseHtmlInputHiddenTag('contact_id', $this->contact->getId())); $form->addItem(new EaseTWBFormGroup(_('Kontakt'), new EaseHtmlInputTextTag('cnt', $this->cnt), EaseShared::webPage()->getRequestValue('cnt'), _('telefonní číslo, email či jabberová adresa dle druhu kontaktu'))); $form->addItem(new EaseTWSubmitButton(_('Uložit'), 'success')); $this->addItem(new EaseTWBPanel(_('Přidat kontaktní údaj'), 'default', $form)); } else { $this->addItem(new EaseHtmlDivTag('plno', _('K tomuto kontaktu již není možné přidávat další údaje.'), array('class' => 'well warning', 'style' => 'margin: 10px'))); } }
/** * Zpracování formuláře * * @return boolean */ public function reconfigureService() { $page = EaseShared::webPage(); $testUrl = $page->getRequestValue('testUrl'); $reqText = $page->getRequestValue('reqText'); $errText = $page->getRequestValue('errText'); if ($testUrl && $reqText) { if (substr($testUrl, 0, 4) != 'http') { $testUrl = 'http://' . $testUrl; } $regex = "((https?|ftp)\\:\\/\\/)?"; // SCHEME $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass $regex .= "([a-z0-9-.]*)\\.([a-z]{2,3})"; // Host or IP $regex .= "(\\:[0-9]{2,5})?"; // Port $regex .= "(\\/([a-z0-9+\$_-]\\.?)+)*\\/?"; // Path $regex .= "(\\?[a-z+&\$_.-][a-z0-9;:@&%=+\\/\$_.-]*)?"; // GET Query $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor if (!preg_match("/^{$regex}\$/", $testUrl)) { $page->addStatusMessage(_('Neplatné url'), 'error'); return false; } $command = $testUrl . '!' . $reqText; $command .= '!' . $errText; $command .= '!10'; //Timeout $this->tweaker->service->setDataValue('check_command-params', $command); return parent::reconfigureService(); } return FALSE; }
/** * Přehled hostů bez potvrzeného senzoru, nebo se zastaralou konf. senzoru. * * @param array $hosts */ public function __construct($hosts) { $ok = 0; $noSensor = array(); $oldSensor = array(); $noParents = array(); $noIcon = array(); $noContacts = array(); EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux'))); foreach ($hosts as $host_id => $host_info) { if (is_null($host_info['host_name']) || !strlen($host_info['host_name'])) { unset($hosts[$host_id]); continue; } if (isset($host_info['config_hash'])) { $host = new IEHost((int) $host_id); if ($host->getConfigHash() == $host_info['config_hash']) { unset($hosts[$host_id]); $ok++; } else { //Zastaralá konfigurace $oldSensor[$host_id] = $host_info; } } else { $noSensor[$host_id] = $host_info; //senzor neregistrován } if (!isset($host_info['parents']) || !count($host_info['parents'])) { $noParents[$host_id] = $host_info; //Host bez rodičů } if (!isset($host_info['icon_image']) || !strlen(trim($host_info['icon_image']))) { $noIcon[$host_id] = $host_info; //Host bez ikony } if (!isset($host_info['contacts']) || !count($host_info['contacts']) || (!isset($host_info['contact_groups']) || !count($host_info['contact_groups']))) { $noContacts[$host_id] = $host_info; //Host bez kontaktů } } $hostsTabs = new EaseTWBTabs('hostsTabs'); if (count($oldSensor)) { $oldHostsTable = new EaseHtmlTableTag(null, array('class' => 'table')); foreach ($oldSensor as $host_id => $host_info) { $row = $oldHostsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('sensor.php?host_id=' . $host_id, _('aktualizovat senzor')))); $row->setTagClass('warning'); } $hostsTabs->addTab(sprintf(_('Neakt. Senzor <span class="badge">%s</span>'), count($oldSensor)), $oldHostsTable); } if (count($noSensor)) { $noSensorTable = new EaseHtmlTableTag(null, array('class' => 'table')); foreach ($noSensor as $host_id => $host_info) { $row = $noSensorTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('sensor.php?host_id=' . $host_id, _('nasadit senzor')))); $row->setTagClass('danger'); } $hostsTabs->addTab(sprintf(_('Bez senzoru <span class="badge">%s</span>'), count($noSensor)), $noSensorTable); } if (count($noParents)) { $noParentsTable = new EaseHtmlTableTag(null, array('class' => 'table')); foreach ($noParents as $host_id => $host_info) { $row = $noParentsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?action=parent&host_id=' . $host_id, _('přiřadit rodiče')), new EaseTWBLinkButton('watchroute.php?action=parent&host_id=' . $host_id, _('sledovat celou cestu'), 'warning', array('onClick' => "\$('#preload').css('visibility', 'visible');")))); $row->setTagClass('info'); } $hostsTabs->addTab(sprintf(_('Bez rodičů <span class="badge">%s</span>'), count($noParents)), $noParentsTable); } if (count($noIcon)) { $noIconTable = new EaseHtmlTableTag(null, array('class' => 'table')); foreach ($noIcon as $host_id => $host_info) { $row = $noIconTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?action=icon&host_id=' . $host_id, _('přiřadit ikonu')))); $row->setTagClass('default'); } $hostsTabs->addTab(sprintf(_('Bez ikony <span class="badge">%s</span>'), count($noIcon)), $noIconTable); } if (count($noContacts)) { $noContactsTable = new EaseHtmlTableTag(null, array('class' => 'table')); foreach ($noContacts as $host_id => $host_info) { $row = $noContactsTable->addRowColumns(array(new EaseHtmlATag('host.php?host_id=' . $host_id, $host_info['host_name']), new EaseTWBLinkButton('host.php?host_id=' . $host_id, _('přiřadit kontakty')))); $row->setTagClass('default'); } $hostsTabs->addTab(sprintf(_('Bez kontaktů <span class="badge">%s</span>'), count($noContacts)), $noContactsTable); } parent::__construct(_('Hosty dle stavu konfigurace'), 'info', $hostsTabs, sprintf(_('Celkem %s hostů bez aktuální konfigurace. (%s aktuální)'), count($hosts), $ok)); }
/** * Vypíše výsledek SQL dotazu v požadovaném tvaru * * @param type $queryRaw */ public function output($queryRaw) { 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; } }
function finalize() { EaseShared::webPage()->includeJavaScript('js/handlebars.js'); EaseShared::webPage()->includeJavaScript('js/typeahead.bundle.js'); EaseShared::webPage()->addCss(' .tt-hint { } .tt-input { } .tt-hint { color: #999 } .tt-dropdown-menu { width: 422px; margin-top: 12px; padding: 8px 0; background-color: #fff; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 8px; box-shadow: 0 5px 10px rgba(0,0,0,.2); overflow-y: auto; max-height: 500px; } .tt-suggestion { padding: 3px 20px; } .tt-suggestion.tt-cursor { color: #fff; background-color: #0097cf; } .tt-suggestion.tt-cursor a { color: black; } .tt-suggestion p { margin: 0; } '); EaseShared::webPage()->addJavaScript(' var bestPictures = new Bloodhound({ limit: 1000, datumTokenizer: Bloodhound.tokenizers.obj.whitespace(\'value\'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: \'searcher.php?q=%QUERY\' }); bestPictures.initialize(); $(\'input[name="search"]\').css("top","2px").typeahead(null, { name: \'best-pictures\', displayKey: \'name\', source: bestPictures.ttAdapter(), templates: { suggestion: Handlebars.compile(\'<p><small>{{type}}</small><br><a href="{{url}}"><strong>{{name}}</strong> – {{what}}</a></p>\') } }); ', null, true); }
$host = new IEHost(); $allHosts = $host->getListing(); foreach ($allHosts as $hostId => $hostInfo) { $host->dataReset(); $host->loadFromMySQL((int) $hostId); $host->setDataValue('config_hash', $host->getConfigHash()); $host->saveToMySQL(); } $oPage->addStatusMessage(sprintf(_('Stavy %s senzorů byly nastaveny'), count($allHosts)), 'success'); } } $oPage->addItem(new IEPageTop(_('Reset objekt'))); $resetForm = new EaseTWBForm('reset'); $resetForm->addInput(new IEYesNoSwitch('host', FALSE), _('Hosti'), null, _('Smaže hosty, ale nechá předlohy')); $resetForm->addInput(new IEYesNoSwitch('hostgroup', FALSE), _('Skupiny hostů'), null, _('Smaže skupiny hostů')); $resetForm->addInput(new IEYesNoSwitch('contact', FALSE), _('Kontakty'), null, _('Smaže kontakty')); $resetForm->addInput(new IEYesNoSwitch('contactgroup', FALSE), _('Skupiny kontaktů'), null, _('Smaže skupiny kontaktů')); $resetForm->addInput(new IEYesNoSwitch('service', FALSE), _('Služby'), null, _('Smaže služby')); $resetForm->addInput(new IEYesNoSwitch('servicegroup', FALSE), _('Skupiny služeb'), null, _('Smaže skupiny služeb')); $resetForm->addItem(new EaseTWSubmitButton(_('Vymazat všechna data'), 'danger')); $toolRow = new EaseTWBRow(); $toolRow->addColumn(6, new EaseTWBWell($resetForm)); $resyncForm = new EaseTWBForm('resync'); $resyncForm->addInput(new IEYesNoSwitch('desync', FALSE), _('Rozhodit Hash'), null, _('Všechny hosty s nasazeným senzorem budou hlásat zastaralou konfiguraci')); $resyncForm->addInput(new IEYesNoSwitch('sync', FALSE), _('Nastavit Hash'), null, _('Všechny hosty s nasazeným senzorem budou hlásat aktuální konfiguraci')); $resyncForm->addItem(new EaseTWSubmitButton(_('Provést operaci'), 'warning', array('onClick' => "\$('#preload').css('visibility', 'visible');"))); $toolRow->addColumn(6, new EaseTWBWell($resyncForm)); $oPage->container->addItem(new EaseTWBPanel(_('Pročištění databáze'), 'danger', $toolRow)); EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux'))); $oPage->addItem(new IEPageBottom()); $oPage->draw();
/** * Zkontroluje splnění podmínek pro smazání záznamu * * @return boolean */ public function controlDeleteColumns() { $id = EaseShared::webPage()->getRequestValue('id'); if ($id) { $this->setMyKey($id); return true; } return false; }
/** * 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); }
/** * Add Groups/Hosts into menu * * @param IEBootstrapMenu $nav */ private function groupsHostsMenu($nav) { EaseShared::webPage()->addCss('.dropdown-menu { overflow-y: auto } '); EaseShared::webPage()->addJavaScript("\$('.dropdown-menu').css('max-height',\$(window).height()-100);", null, true); $user = EaseShared::user(); $host = new IEHost(); $hosts = $host->getListing(null, null, array('icon_image', 'platform')); $hostsNotInGroup = array(); $hnames = array(); foreach ($hosts as $hID => $hInfo) { $hnames[$hInfo['host_name']] =& $hosts[$hID]; $hostsNotInGroup[$hInfo['host_name']] = $hInfo; } $topItems = array('wizard-host.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením hostu')); $topItems['wizard-active-host.php'] = EaseTWBPart::GlyphIcon('star') . ' ' . _('Nový aktivní Host'); $hostgroup = new IEHostgroup(); $topItems['hostgroup.php'] = EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina hostů'); /* , 'exthostinfo.php' => _('Rozšířené informace hostů'), 'hostdependency.php' => _('Závislosti hostů'), 'hostescalation.php' => _('Eskalace hostů') */ $pocHostgroup = $hostgroup->getMyRecordsCount(); $hostGroupMenuItem = array(); if ($pocHostgroup) { //$hostgroups = $hostgroup->myDbLink->queryToArray('SELECT ' . $hostgroup->getmyKeyColumn() . ', hostgroup_name, DatSave FROM ' . $hostgroup->myTable . ' WHERE user_id=' . $user->getUserID(), 'hostgroup_id'); $hostgroups = $hostgroup->getListing(null, null, array('members')); foreach ($hostgroups as $cID => $hgInfo) { $hostGroupMenuItem['hostgroup.php?hostgroup_id=' . $hgInfo['hostgroup_id']] = EaseTWBPart::GlyphIcon('cloud') . ' ' . $hgInfo['hostgroup_name']; if (count($hgInfo['members'])) { foreach ($hgInfo['members'] as $hgMember) { if ($hgMember == '*') { $image = null; } else { $hInfo =& $hnames[$hgMember]; $image = $hInfo['icon_image']; unset($hostsNotInGroup[$hgMember]); } if (!$image) { $image = 'unknown.gif'; } if (isset($hInfo) && !is_null($hInfo)) { $hostGroupMenuItem['host.php?host_id=' . $hInfo['host_id']] = ' ' . new IEHostIcon($hInfo) . ' ' . $hInfo['host_name'] . ' ' . new IEPlatformIcon($hInfo['platform']); } } } } $topItems['hostgroups.php'] = EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skupin hostů'); } else { if (count($hostGroupMenuItem)) { $hostGroupMenuItem[] = ''; } } if (count($hostsNotInGroup)) { foreach ($hostsNotInGroup as $menuHost) { $hostGroupMenuItem['host.php?host_id=' . $menuHost['host_id']] = ' ' . new IEHostIcon($menuHost) . ' ' . $menuHost['host_name'] . ' ' . new IEPlatformIcon($menuHost['platform']); } } $topItems['hosts.php'] = EaseTWBPart::GlyphIcon('list') . ' ' . _('Detailní přehled hostů'); $topItems['map.php'] = EaseTWBPart::GlyphIcon('globe') . ' ' . _('Topologie'); $nav->addDropDownMenu(_('Hosti'), array_merge($topItems, array('' => ''), $hostGroupMenuItem)); }
function finalize() { EaseShared::webPage()->includeJavaScript('js/groupmembers.js'); }
$oPage->Redirect('LogOut.php'); // already got some credentials stored? } elseif (isset($_SESSION['access_token'])) { $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token']; $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret']; $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials')); if ($code == 200) { $resp = json_decode($tmhOAuth->response['response']); EaseShared::user(new LQTwitterUser($resp->id, $resp->screen_name)); if (!EaseShared::user()->getSettingValue('icon')) { EaseShared::user()->setSettingValue('icon', $resp->profile_image_url); EaseShared::user()->UserLogin = $resp->screen_name; EaseShared::user()->save(); } EaseShared::user()->LoginSuccess(); EaseShared::webPage()->Redirect('index.php'); exit; } else { outputError($tmhOAuth); } // we're being called back by Twitter } elseif (isset($_REQUEST['oauth_verifier'])) { $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token']; $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret']; $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), ['oauth_verifier' => $_REQUEST['oauth_verifier']]); if ($code == 200) { $_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']); unset($_SESSION['oauth']); header("Location: {$here}"); exit; } else {
/** * Zjistí ikonu, stahne jí z netu, zkonvertuje a použije jako ikonu hosta */ public function favToIcon() { $icoUrl = false; $baseUrl = 'http://' . $this->getDataValue('host_name') . '/'; $indexpage = @file_get_contents($baseUrl); $icoUrls = array(); if (strlen($indexpage)) { $dom = new DOMDocument(); @$dom->loadHTML($indexpage); $links = $dom->getElementsByTagName('link'); foreach ($links as $link) { $urlLink = false; if (isset($link->attributes)) { foreach ($link->attributes as $atribut) { if (isset($atribut->name)) { if ($atribut->name == 'rel' && stristr($atribut->value, 'icon')) { $urlLink = true; $rel = $atribut->value; } if ($atribut->name == 'href') { $url = $atribut->value; } } } if ($urlLink) { if (strstr($url, '://')) { $icoUrls[$rel] = $url; } else { $icoUrls[$rel] = $baseUrl . $url; } } } } } if (!count($icoUrls)) { $icoUrls[] = $baseUrl . '/favicon.ico'; } else { if (count($icoUrls) == 1) { $icoUrl = current($icoUrls); } else { foreach ($icoUrls as $ico) { if (strstr($ico, '.png')) { $icoUrl = $ico; } } if (!$icoUrl) { foreach ($icoUrls as $ico) { if (strstr($ico, '.gif')) { $icoUrl = $ico; } } } if (!$icoUrl) { foreach ($icoUrls as $ico) { if (strstr($ico, '.jpg')) { $icoUrl = $ico; } } } if (!$icoUrl) { $icoUrl = current($icoUrls); } } } $tmpfilename = sys_get_temp_dir() . '/' . EaseSand::randomString(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $icoUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $downloaded = curl_exec($ch); curl_close($ch); file_put_contents($tmpfilename, $downloaded); if (IEIconSelector::imageTypeOK($tmpfilename)) { EaseShared::webPage()->addStatusMessage(sprintf(_('Nalezena ikona %s'), $icoUrl), 'success'); $newicon = IEIconSelector::saveIcon($tmpfilename, $this); if ($newicon) { $this->setDataValue('icon_image', $newicon); $this->setDataValue('statusmap_image', $newicon); return true; } } else { unlink($tmpfilename); } return false; }
/** * Vrací mazací tlačítko * * @param string $name jméno objektu * @param string $urlAdd Předávaná část URL * @return \EaseJQConfirmedLinkButton */ public function deleteButton($name = null, $urlAdd = '') { // return new EaseJQConfirmedLinkButton('?user_id=' . $this->getID() . '&delete=true' . '&' . $urlAdd, _('Smazat ') . ' ' . $this->getUserLogin() . ' ' . EaseTWBPart::GlyphIcon('remove-sign')); EaseShared::webPage()->addItem(new IEConfirmationDialog('delete' . $this->getId(), '?user_id=' . $this->getID() . '&delete=true' . '&' . $urlAdd, _('Smazat') . ' ' . $name, sprintf(_('Opravdu smazat %s ?'), '<strong>' . $this->getUserName() . '</strong>'))); return new EaseHtmlButtonTag(array(EaseTWBPart::GlyphIcon('remove'), _('Smazat') . ' ' . $this->keyword . ' ' . $this->getUserName()), array('style' => 'cursor: default', 'class' => 'btn btn-danger', 'id' => 'triggerdelete' . $this->getId(), 'data-id' => $this->getId())); }
/** * Editor běžného uživatele */ public function lightEditor() { if (!(int) $this->objectEdited->getDataValue('generate')) { $this->addStatusMessage(_('tento záznam se nebude generovat do konfigurace')); } if ($this->objectEdited->publicRecords) { if ((int) $this->objectEdited->getDataValue('public')) { $this->addStatusMessage(_('tento záznam je veřejný')); } } $this->addItem('<div class="error" style=""><span></span><br clear="all"></div>'); $use = $this->objectEdited->getDataValue('use'); if (!is_null($use)) { $template = clone $this->objectEdited; $template->loadFromMySQL((int) $use); } foreach ($this->objectEdited->useKeywords as $fieldName => $fieldType) { $keywordInfo = $this->objectEdited->keywordsInfo[$fieldName]; if ($fieldName == $this->objectEdited->nameColumn) { if ($this->objectEdited->getId()) { continue; } } if (!count($keywordInfo)) { continue; } if (isset($keywordInfo['hidden'])) { continue; } if (!strlen($keywordInfo['title'])) { continue; } if (isset($keywordInfo['required']) && $keywordInfo['required']) { $this->reqFields[$fieldName] = $fieldType; $required = true; } else { if (!isset($keywordInfo['mandatory']) || !$keywordInfo['mandatory']) { $required = false; continue; } } $value = $this->objectEdited->getDataValue($fieldName); if (is_null($value)) { if (!EaseShared::webPage()->isPosted()) { $value = ''; } else { continue; } } if ($value == 'NULL') { $value = null; } if ($this->objectEdited->allowTemplating) { if ($this->objectEdited->isTemplate()) { if (EaseShared::webPage()->isPosted() && is_null($value) && $required) { $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning'); } } } else { if (EaseShared::webPage()->isPosted() && is_null($value) && $required) { $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning'); } } $mainFieldBlock = $this->addItem(new EaseHtmlDivTag($fieldName . '-block', null, array('class' => 'fieldblock'))); /* $fieldLabel = $mainFieldBlock->addItem(new EaseHtmlDivTag(null, '<a name="' . $fieldName . '">' . $fieldName . '</a> ', array('class' => 'FieldLabel mandatory', 'onClick' => "$('#" . $fieldName . "-controls').toggle('slow');"))); if (!$required || !(int) $this->objectEdited->getDataValue('register')) { $fieldLabel->addItem(new EaseHtmlATag('#', EaseTWBPart::GlyphIcon('icon-remove'), array('onClick' => '$(\'#' . $fieldName . '-block\').empty().html(\'<input type=hidden name=' . $fieldName . ' value=NULL><div class=FieldLabel>' . $fieldName . '</div>\'); return false;'))); $fieldLabel->setTagClass('FieldLabel'); } else { $mainFieldBlock->setTagClass('fieldblock req'); } */ $fieldBlock = $mainFieldBlock->addItem(new EaseHtmlDivTag($fieldName . '-controls')); if (!$this->objectEdited->isOwnedBy() && !EaseShared::user()->getSettingValue('admin')) { //Editovat může pouze vlastník if ($this->objectEdited->getId()) { if (is_array($value)) { $value = implode(',', $value); } $fieldBlock->addItem($value); continue; } } if (isset($template)) { $tempValue = $template->getDataValue($fieldName); if (!is_null($tempValue) && $fieldName != $this->objectEdited->nameColumn && !$required) { //Skrýt nedůležité položky EaseShared::webPage()->addJavaScript("\$('#" . $fieldName . "-controls').hide();", null, true); } } $this->insertWidget($fieldBlock, $fieldName, $value); } }
/** * Uloží položky * * @param array $request */ public static function saveMembers($request) { $service = new IEService(); if (isset($request[$service->myKeyColumn])) { if ($service->loadFromMySQL((int) $request[$service->myKeyColumn])) { if (isset($request['addservice']) || isset($request['delservice'])) { if (isset($request['addservice'])) { $service->addMember('host_name', $request['host_id'], $request['host_name']); if ($service->saveToMySQL()) { $service->addStatusMessage(sprintf(_('položka %s byla přidána'), $request['addservice']), 'success'); if ($service->getDataValue('autocfg') == '1') { $service->addStatusMessage(sprintf(_('Službu %s je nutné nejprve zkonfigurovat'), $request['addservice']), 'warning'); EaseShared::webPage()->redirect('servicetweak.php?host_id=' . $request['host_id'] . '&service_id=' . $request[$service->myKeyColumn]); exit; } } else { $service->addStatusMessage(sprintf(_('položka %s nebyla přidána'), $request['addservice']), 'warning'); } } if (isset($request['delservice'])) { $service->delMember('host_name', $request['host_id'], $request['host_name']); if ($service->saveToMySQL()) { $service->addStatusMessage(sprintf(_('položka %s byla odebrána'), $request['delservice']), 'success'); } else { $service->addStatusMessage(sprintf(_('položka %s nebyla odebrána'), $request['delservice']), 'warning'); } } } } } }