function loadItems()
 {
     $items = array();
     $contacts = $this->contact->getColumnsFromMySQL(array($this->contact->myKeyColumn, $this->contact->nameColumn), null, $this->contact->nameColumn);
     if (count($contacts)) {
         foreach ($contacts as $contact) {
             $items[$contact[$this->contact->myKeyColumn]] = $contact[$this->contact->nameColumn];
         }
     }
     return $items;
 }
 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')));
     }
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEService|IEHost $holder
  */
 public function __construct($holder)
 {
     $contactsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Cíle notifikací'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($holder->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $holder->getName();
         $contact = new IEContact();
         $allContacts = $contact->getListing(null, true, array('alias', 'parent_id'));
         foreach ($holder->getDataValue('contacts') as $contactId => $contactName) {
             if (isset($allContacts[$contactId])) {
                 $contactsAssigned[$contactId] = $allContacts[$contactId];
             }
         }
         foreach ($allContacts as $contactID => $contactInfo) {
             if ($contactInfo['register'] != 1) {
                 unset($allContacts[$contactID]);
             }
             if (!$contactInfo['parent_id']) {
                 unset($allContacts[$contactID]);
             }
         }
         foreach ($contactsAssigned as $contactID => $contactInfo) {
             unset($allContacts[$contactID]);
         }
         if (count($allContacts)) {
             foreach ($allContacts as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat')))));
             }
         }
         if (count($contactsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($contactsAssigned as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
Example #4
0
<?php

/**
 * Icinga Editor - nový kontakt
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEContact.php';
$oPage->onlyForLogged();
$contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
$name = $oPage->getRequestValue('name');
if ($oPage->isPosted()) {
    $contact->setData(array('contact_name' => $name, 'use' => 'generic-contact', $contact->userColumn => $oUser->getUserID(), 'generate' => true, 'host_notifications_enabled' => true, 'service_notifications_enabled' => true, 'host_notification_period' => '24x7', 'service_notification_period' => '24x7', 'service_notification_options' => ' w,u,c,r', 'host_notification_options' => 'd,u,r', 'service_notification_commands' => 'notify-service-by-email', 'host_notification_commands' => 'notify-host-by-email', 'register' => 1));
    $contactID = $contact->saveToMySQL();
    if (is_null($contactID)) {
        $oUser->addStatusMessage(_('Kontakt nebyl založen'), 'warning');
    } else {
        $oUser->addStatusMessage(_('Kontakt byl založen'), 'success');
        $oPage->redirect('contacttweak.php?contact_id=' . $contact->getId());
        exit;
    }
}
$autoCreate = $oPage->getRequestValue('autocreate');
if ($autoCreate == 'default') {
    $contact->setData(IEContact::ownContactData());
    $contactID = $contact->saveToMySQL();
}
Example #5
0
<?php

/**
 * Icinga Editor - titulní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEContact.php';
require_once 'classes/IECfgEditor.php';
$oPage->onlyForLogged();
$contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
if ($oPage->isPosted()) {
    $contact->takeData($_POST);
    $contactID = $contact->saveToMySQL();
    if (is_null($contactID)) {
        $oUser->addStatusMessage(_('Kontakt nebyl uložen'), 'warning');
    } else {
        $oUser->addStatusMessage(_('Kontakt byl uložen'), 'success');
    }
}
$contact->saveMembers();
$delete = $oPage->getGetValue('delete', 'bool');
if ($delete == 'true') {
    $contact->delete();
    $oPage->redirect('contacts.php');
    exit;
}
Example #6
0
 /**
  * Smazaže kontakt i jeho subkontakty
  *
  * @return boolean
  */
 public function rename($newname)
 {
     $oldname = $this->getName();
     $this->setDataValue($this->nameColumn, $newname);
     if ($this->saveToMySQL()) {
         $childs = $this->getChilds();
         $subcontact = new IEContact();
         $service = new IEService();
         foreach ($childs as $childID => $childInfo) {
             $subcontact->loadFromMySQL($childID);
             $type = $subcontact->getDataValue('alias');
             $subcontact->setDataValue($subcontact->nameColumn, $newname . ' ' . $type);
             $services = $this->myDbLink->queryTo2DArray('SELECT ' . $service->getmyKeyColumn() . ' FROM ' . $service->myTable . ' WHERE contacts LIKE \'%' . $oldname . ' ' . $type . '%\'');
             if (count($services)) {
                 foreach ($services as $serviceID) {
                     $service->loadFromMySQL((int) $serviceID);
                     if ($service->delMember('contacts', $id)) {
                         $service->addMember('contacts', $id, $newname . ' ' . $type);
                         $service->saveToMySQL();
                     }
                 }
             }
             $subcontact->saveToMySQL();
         }
     } else {
         $this->addStatusMessage(_('Kontakt nelze přejmenovat'), 'warning');
     }
 }
Example #7
0
 public function delete($id = null)
 {
     if (is_null($id)) {
         $id = $this->getId();
     }
     if ($id != $this->getId()) {
         $this->loadFromMySQL($id);
     }
     $userGroup = new IEUserGroup();
     $userGroup->delUser($id);
     $command = new IECommand();
     $myCommand = $command->getOwned($id);
     if ($myCommand) {
         foreach ($myCommand as $command_id => $cmd) {
             $command->loadFromMySQL((int) $command_id);
             $command->delete();
         }
     }
     $contact = new IEContact();
     $myContact = $contact->getOwned($id);
     if ($myContact) {
         foreach ($myContact as $contact_id => $cmd) {
             if ($contact->loadFromMySQL((int) $contact_id)) {
                 $contact->delete();
             }
         }
     }
     $contactgroup = new IEContactgroup();
     $myContactgroup = $contactgroup->getOwned($id);
     if ($myContactgroup) {
         foreach ($myContactgroup as $contactgroup_id => $cmd) {
             $contactgroup->loadFromMySQL((int) $contactgroup_id);
             $contactgroup->delete();
         }
     }
     $hostgroup = new IEHostgroup();
     $myHostgroup = $hostgroup->getOwned($id);
     if ($myHostgroup) {
         foreach ($myHostgroup as $hostgroup_id => $cmd) {
             $hostgroup->loadFromMySQL((int) $hostgroup_id);
             $hostgroup->delete();
         }
     }
     $host = new IEHost();
     $myHost = $host->getOwned($id);
     if ($myHost) {
         foreach ($myHost as $host_id => $cmd) {
             $host->loadFromMySQL((int) $host_id);
             $host->delete();
         }
     }
     $servicegroup = new IEServicegroup();
     $myServicegroup = $servicegroup->getOwned($id);
     if ($myServicegroup) {
         foreach ($myServicegroup as $servicegroup_id => $cmd) {
             $servicegroup->loadFromMySQL((int) $servicegroup_id);
             $servicegroup->delete();
         }
     }
     $service = new IEService();
     $myService = $service->getOwned($id);
     if ($myService) {
         foreach ($myService as $service_id => $cmd) {
             $service->loadFromMySQL((int) $service_id);
             $service->delete();
         }
     }
     $timeperiod = new IETimeperiod();
     $myTimeperiod = $timeperiod->getOwned($id);
     if ($myTimeperiod) {
         foreach ($myTimeperiod as $timeperiod_id => $cmd) {
             $timeperiod->loadFromMySQL((int) $timeperiod_id);
             $timeperiod->delete();
         }
     }
     $cfgfile = constant('CFG_GENERATED') . '/' . $this->getUserLogin() . '.cfg';
     if (file_exists($cfgfile)) {
         if (unlink($cfgfile)) {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s byla smazána'), $this->getUserLogin()), 'success');
         } else {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s nebyla smazána'), $this->getUserLogin()), 'error');
         }
     }
     if ($this->deleteFromMySQL()) {
         $this->addStatusMessage(sprintf(_('Uživatel %s byl smazán'), $this->getUserLogin()));
         require_once 'Ease/EaseMail.php';
         $email = new EaseMail($this->getDataValue('email'), _('Oznámení o zrušení účtu'));
         $email->setMailHeaders(array('From' => EMAIL_FROM));
         $email->addItem(new EaseHtmlDivTag(null, "Právě jste byl/a smazán/a z Aplikace VSMonitoring s těmito přihlašovacími údaji:\n"));
         $email->addItem(new EaseHtmlDivTag(null, ' Login: ' . $this->GetUserLogin() . "\n"));
         $email->send();
         return true;
     } else {
         return FALSE;
     }
 }
Example #8
0
require_once 'classes/IEHostgroup.php';
require_once 'classes/IETimeperiod.php';
require_once 'classes/IECommand.php';
require_once 'classes/IEServicegroup.php';
$oPage->onlyForLogged();
$oPage->addItem(new IEPageTop(_('Icinga Editor')));
$oPage->addPageColumns();
$Timeperiod = new IETimeperiod();
$pocTimeperiods = $Timeperiod->getMyRecordsCount();
if ($pocTimeperiods) {
    $success = $oPage->columnIII->addItem(new EaseHtmlDivTag('Timeperiod', new EaseTWBLinkButton('timeperiods.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s časových period'), $pocTimeperiods)), array('class' => 'alert alert-success')));
} else {
    $warning = $oPage->columnIII->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádné časové periody'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('timeperiod.php', _('Založit první časovou periodu <i class="icon-edit"></i>')));
}
$contact = new IEContact();
$pocContact = $contact->getMyRecordsCount();
if ($pocContact) {
    $success = $oPage->columnII->addItem(new EaseHtmlDivTag('Contact', new EaseTWBLinkButton('contacts.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s kontaktů'), $pocContact)), array('class' => 'alert alert-success')));
} else {
    if ($pocTimeperiods) {
        $warning = $oPage->columnII->addItem(new EaseHtmlDivTag('Contact', _('Nemáte definovaný kontakt'), array('class' => 'alert alert-info')));
        $warning->addItem(new EaseTWBLinkButton('contact.php', _('Založit první kontakt ' . EaseTWBPart::GlyphIcon('edit'))));
    } else {
        $oPage->columnII->addItem(new EaseHtmlDivTag('Contact', _('Kontakty vyžadují časovou periodu'), array('class' => 'alert alert-danger')));
    }
}
$contactgroup = new IEContactgroup();
$pocContactgroup = $contactgroup->getMyRecordsCount();
if ($pocContactgroup) {
    $success = $oPage->columnII->addItem(new EaseHtmlDivTag('Contactgroup', new EaseTWBLinkButton('contactgroups.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s skupin kontaktů'), $pocContactgroup)), array('class' => 'alert alert-success')));
Example #9
0
 /**
  * Vložení menu
  */
 public function afterAdd()
 {
     $nav = $this->addItem(new IEBootstrapMenu());
     $user = EaseShared::user();
     $userID = $user->getUserID();
     if ($userID) {
         //Authenticated user
         $nav->addMenuItem(new IENavBarSearchBox('search', 'search.php'));
         if ($user->getSettingValue('admin')) {
             $users = $user->getColumnsFromMySQL(array('id', 'login'), array('id' => '!0'), 'login', $user->getmyKeyColumn());
             $userList = array();
             if ($users) {
                 foreach ($users as $uID => $uInfo) {
                     $userList['userinfo.php?user_id=' . $uInfo['id']] = EaseTWBPart::GlyphIcon('user') . '&nbsp;' . $uInfo['login'];
                 }
                 if (count($userList)) {
                     $userList[] = '';
                 }
             }
             //                $usergroups = $this->myDbLink->queryToArray('SELECT * FROM user_groups' . 'usergroup_id');
             $nav->addDropDownMenu(_('Uživatelé'), array_merge($userList, array('createaccount.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový uživatel'), 'users.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled uživatelů'), 'usergroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina uživatelů'), 'usergroups.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled skupin uživatelů'))));
         }
         $this->changesButton($nav);
         $this->groupsHostsMenu($nav);
         //            $nav->addDropDownMenu(_('Hosti'), $hostGroupHostsMenuItem);
         if (EaseShared::user()->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Služby'), array('wizard-service.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením služby'), 'service.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová služba'), 'services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'), 'servicegroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina služeb'), 'servicegroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin služeb'), '' => '', 'stemplate.php?action=new' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová předloha sledované služby'), 'stemplates.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled předloh sled. sl.')));
         } else {
             $service = new IEService();
             $services = $service->getListing(null, null, array('icon_image', 'platform'));
             if (count($services)) {
                 $services_menu = array('services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'));
                 foreach ($services as $serviceID => $serviceInfo) {
                     $services_menu['servicetweak.php?service_id=' . $serviceID] = $serviceInfo[$service->nameColumn];
                 }
                 $nav->addDropDownMenu(_('Služby'), $services_menu);
             }
         }
         $contact = new IEContact();
         $contacts = $contact->getListing(null, null, array('parent_id'));
         foreach ($contacts as $contactID => $contactInfo) {
             //Vyfiltrovat pouze primární kontakty
             if ($contactInfo['parent_id']) {
                 unset($contacts[$contactID]);
             }
         }
         if (count($contacts)) {
             $contacts_menu = array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled Kontaktů'));
             foreach ($contacts as $contactID => $contactInfo) {
                 $contacts_menu['contacttweak.php?contact_id=' . $contactID] = $contactInfo[$contact->nameColumn];
             }
             $contacts_menu[] = '';
         } else {
             $contacts_menu = array();
         }
         $nav->addDropDownMenu(_('Kontakty'), array_merge($contacts_menu, array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled kontaktů'), 'newcontact.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový kontakt'), 'contactgroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin kontaktů'), 'contactgroup.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nová skupina kontaktů'))));
         if ($user->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Příkaz'), array('command.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový příkaz'), 'commands.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled příkazů'), 'importcommand.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat'), '', 'script.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový skript'), 'scripts.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skriptů')));
             $nav->addDropDownMenu(_('Rozšířené'), array('timeperiods.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled časových period'), 'timeperiod.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová časová perioda'), 'preferences.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Nastavení icingy'), 'regenall.php' => EaseTWBPart::GlyphIcon('ok') . ' ' . _('Přegenerovat všechny konfiguráky'), 'reset.php' => EaseTWBPart::GlyphIcon('cog') . ' ' . _('Reset Objektů'), 'dbrecreate.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Reinicializovat databázi'), 'fixer.php' => EaseTWBPart::GlyphIcon('ok-circle') . ' ' . _('Opravit databázi'), 'import.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat')));
         }
         $results = array('nagstamon.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('PC Lin/Win/Mac'), 'anag.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('Android'), 'wpnag.php' => EaseTWBPart::GlyphIcon('Info') . ' ' . _('Win Phone'));
         if (file_exists('/etc/apache2/conf-enabled/icinga-web.conf')) {
             $results['/icinga-web/'] = EaseTWBPart::GlyphIcon('Info') . ' ' . _('Web');
         }
         $nav->addDropDownMenu(_('Výsledky testů'), $results);
     }
 }
Example #10
0
 function fixContactIDs()
 {
     $contactsOK = array();
     $contactsErr = array();
     $contact = new IEContact();
     $service = new IEService();
     $services = $service->getColumnsFromMySQL(array($service->myKeyColumn));
     foreach ($services as $serviceId => $serviceInfo) {
         $serviceId = intval(current($serviceInfo));
         $service->loadFromMySQL($serviceId);
         $contactNames = $service->getDataValue('contacts');
         if ($contactNames) {
             foreach ($contactNames as $contactId => $contactName) {
                 $contactFound = $contact->loadFromMySQL($contactName);
                 if ($contactId != $contact->getId()) {
                     if ($service->delMember('contacts', $contactId, $contactName) && $service->addMember('contacts', $contact->getId(), $contactName)) {
                         $contactsOK[] = $contactName;
                     } else {
                         $contactsErr[] = $contactName;
                     }
                 }
             }
         }
         if (count($contactsOK)) {
             if ($service->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $service->getName(), implode(',', $contactsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $service->getName(), implode(',', $contactsOK)), 'success');
                 $contactsOK = array();
             }
         }
     }
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $contactNames = $host->getDataValue('contacts');
         if ($contactNames) {
             foreach ($contactNames as $contactId => $contactName) {
                 $contactFound = $contact->loadFromMySQL($contactName);
                 if ($contactId != $contact->getId()) {
                     if ($host->delMember('contacts', $contactId, $contactName) && $host->addMember('contacts', $contact->getId(), $contactName)) {
                         $contactsOK[] = $contactName;
                     } else {
                         $contactsErr[] = $contactName;
                     }
                 }
             }
         }
         if (count($contactsOK)) {
             if ($host->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $host->getName(), implode(',', $contactsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $host->getName(), implode(',', $contactsOK)), 'success');
                 $contactsOK = array();
             }
         }
     }
 }
Example #11
0
<?php

/**
 * Icinga Editor - skupina hostů
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$hostgroup = new IEHostgroup($oPage->getRequestValue('hostgroup_id', 'int'));
switch ($oPage->getRequestValue('action')) {
    case 'contactAsign':
        $contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
        if ($contact->getId()) {
            $host = new IEHost();
            $groupMembers = $hostgroup->getMembers();
            foreach ($groupMembers as $gmID => $hostName) {
                $host->loadFromSQL((int) $gmID);
                $host->addMember('contacts', $contact->getId(), $contact->getName());
                if ($host->saveToMySQL()) {
                    $host->addStatusMessage(sprintf(_('<strong>%s</strong> byl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'success');
                } else {
                    $host->addStatusMessage(sprintf(_('<strong>%s</strong> nebyl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'warning');
                }
            }
        } else {
            $hostgroup->addStatusMessage(_('Chyba přiřazení kontaktu'), 'warning');
        }
Example #12
0
$infopanel = new IEInfoBox($command);
$tools = new EaseTWBPanel(_('Nástroje'), 'warning');
if ($command->getId()) {
    $tools->addItem($command->deleteButton());
    $tools->addItem(new EaseTWBPanel(_('Transfer'), 'warning', $command->transferForm()));
    $service = new IEService();
    $usages = $service->getColumnsFromMySQL(array($service->getMyKeyColumn(), $service->nameColumn), array('check_command' => $command->getName()), $service->nameColumn, $service->getMyKeyColumn());
    if (count($usages)) {
        $usedBy = new EaseTWBPanel(_('Používající služby'));
        $listing = $usedBy->addItem(new EaseHtmlUlTag(null, array('class' => 'list-group')));
        foreach ($usages as $usage) {
            $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag('service.php?service_id=' . $usage['service_id'], $usage[$service->nameColumn]), array('class' => 'list-group-item')));
        }
        $infopanel->addItem($usedBy);
    }
    $contact = new IEContact();
    $hostNotify = $contact->getColumnsFromMySQL(array($contact->getMyKeyColumn(), $contact->nameColumn), array('host_notification_commands' => '%' . $command->getName() . '%'), $contact->nameColumn, $contact->getMyKeyColumn());
    $serviceNotify = $contact->getColumnsFromMySQL(array($contact->getMyKeyColumn(), $contact->nameColumn), array('service_notification_commands' => '%' . $command->getName() . '%'), $contact->nameColumn, $contact->getMyKeyColumn());
    $usages = array_merge($hostNotify, $serviceNotify);
    if (count($usages)) {
        $usedBy = new EaseTWBPanel(_('Používající kontakty'));
        $listing = new EaseHtmlUlTag(null, array('class' => 'list-group'));
        foreach ($usages as $usage) {
            if (!isset($usage[$contact->nameColumn])) {
                $usage[$contact->nameColumn] = 'n/a';
            }
            $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag('contact.php?contact_id=' . $usage['contact_id'], $usage[$contact->nameColumn]), array('class' => 'list-group-item')));
        }
        EaseContainer::addItemCustom($listing, $usedBy);
        $infopanel->addItem($usedBy);
    }
Example #13
0
             $errorLine->addItem(' <a href="timeperiods.php">' . _('Notifikační perioda') . '</a> služeb ');
             $errorLine->addItem(new EaseHtmlATag('timeperiod.php?timeperiod_name=' . $keywords[1], $keywords[1]));
             break;
         case 'Host notification period':
             $errorLine->addItem(' <a href="timeperiods.php">' . _('Notifikační perioda') . '</a> hostů');
             $errorLine->addItem(new EaseHtmlATag('timeperiod.php?timeperiod_name=' . $keywords[1], $keywords[1]));
             break;
         default:
             $errorLine->addItem($line);
             break;
     }
     if (isset($keywords[2])) {
         switch (trim($keywords[2])) {
             case 'specified for contact':
                 $errorLine->addItem(' specifikovaná pro kontakt ');
                 $contact = new IEContact($keywords[3]);
                 $errorLine->addItem(new EaseHtmlATag('contact.php?contact_id=' . $contact->getMyKey(), $keywords[3]));
                 break;
             default:
                 break;
         }
     }
     if (isset($keywords[4])) {
         switch (trim($keywords[4])) {
             case 'is not defined anywhere!':
                 $errorLine->addItem(' není nikde definován/a ');
                 break;
         }
     }
     //$OPage->addItem('<pre>' . EaseBrick::printPreBasic($keywords) . '</pre>');
 }
 system('sudo htpasswd -b /etc/icinga/htpasswd.users ' . $newOUser->getUserLogin() . ' ' . $password);
 $newOUser->loginSuccess();
 $email = $oPage->addItem(new EaseMail($newOUser->getDataValue('email'), _('Potvrzení registrace')));
 $email->setMailHeaders(array('From' => EMAIL_FROM));
 $email->addItem(new EaseHtmlDivTag(null, "Právě jste byl/a zaregistrován/a do Aplikace Monitoring s těmito přihlašovacími údaji:\n"));
 $email->addItem(new EaseHtmlDivTag(null, ' Login: '******' Heslo: ' . $_POST['password'] . "\n"));
 $email->send();
 $email = $oPage->addItem(new EaseMail(SEND_INFO_TO, sprintf(_('Nová registrace do Monitoringu: %s'), $newOUser->GetUserLogin())));
 $email->setMailHeaders(array('From' => EMAIL_FROM));
 $email->addItem(new EaseHtmlDivTag(null, _("Právě byl zaregistrován nový uživatel:\n")));
 $email->addItem(new EaseHtmlDivTag('login', ' Login: '******'contact_name' => $login, 'use' => 'generic-contact', $contact->userColumn => $userID, 'generate' => true, 'host_notifications_enabled' => true, 'service_notifications_enabled' => true, 'host_notification_period' => '24x7', 'service_notification_period' => '24x7', 'service_notification_options' => ' w,u,c,r', 'host_notification_options' => 'd,u,r', 'service_notification_commands' => 'notify-service-by-email', 'host_notification_commands' => 'notify-host-by-email', 'register' => 1));
 $contactID = $contact->saveToMySQL();
 if ($contactID) {
     $oUser->addStatusMessage(_('Výchozí kontakt byl založen'), 'success');
 } else {
     $oUser->addStatusMessage(_('Výchozí kontakt nebyl založen'), 'warning');
 }
 $mailID = $contact->fork(array('email' => $emailAddress));
 if ($mailID) {
     $oUser->addStatusMessage(_('Mailový kontakt byl založen'), 'success');
 } else {
     $oUser->addStatusMessage(_('Mailový kontakt nebyl založen'), 'warning');
 }
 $contactGroup = new IEContactgroup();
 $contactGroup->setData(array('contactgroup_name' => _('Skupina') . '_' . $login, 'alias' => _('Skupina') . '_' . $login, 'generate' => true, $contactGroup->userColumn => $userID));
Example #15
0
<?php

/**
 * Icinga Editor služby
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
if (!$contact->getId()) {
    $oPage->redirect('contacts.php');
    exit;
}
switch ($oPage->getRequestValue('action')) {
    case 'rename':
        $newname = $oPage->getRequestValue('newname');
        if (strlen($newname)) {
            if ($contact->rename($newname)) {
                $oUser->addStatusMessage(_('Kontakt byl přejmenován'), 'success');
            } else {
                $oUser->addStatusMessage(_('Kontakt nebyl přejmenován'), 'warning');
            }
        }
        break;
}
$delete = $oPage->getGetValue('delete', 'bool');
if ($delete == 'true') {