Esempio n. 1
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);
 }
Esempio n. 2
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;
     }
 }
Esempio n. 3
0
<?php

/**
 * Icinga Editor - skupina kontaktů
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$oPage->addItem(new IEPageTop(_('Editace skupiny kontaktu')));
$contactgroup = new IEContactgroup($oPage->getRequestValue('contactgroup_id', 'int'));
if ($oPage->isPosted()) {
    $contactgroup->takeData($_POST);
    $ContactgroupID = $contactgroup->saveToMySQL();
    if (is_null($ContactgroupID)) {
        $oUser->addStatusMessage(_('Skupina kontaktů nebyla uložena'), 'warning');
    } else {
        $oUser->addStatusMessage(_('Skupina kontaktů byla uložena'), 'success');
    }
}
$contactgroup->saveMembers();
$delete = $oPage->getGetValue('delete', 'bool');
if ($delete == 'true') {
    $contactgroup->delete();
}
$contactgroupEdit = new IECfgEditor($contactgroup);
$form = new EaseTWBForm('Contactgroup', 'contactgroup.php', 'POST', $contactgroupEdit, array('class' => 'form-horizontal'));
$form->setTagID($form->getTagName());
Esempio n. 4
0
    $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')));
} else {
    $warning = $oPage->columnII->addItem(new EaseHtmlDivTag('Contactgroup', _('Nemáte definovanou skupinu kontaktů'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('contactgroup.php', _('Založit první skupinu kontaktů ' . EaseTWBPart::GlyphIcon('edit'))));
}
$host = new IEHost();
$pocHostu = $host->getMyRecordsCount();
if ($pocHostu) {
    $success = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', new EaseTWBLinkButton('hosts.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s hostů'), $pocHostu)), array('class' => 'alert alert-success')));
} else {
    if ($pocTimeperiods) {
        $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádný host'), array('class' => 'alert alert-info')));
        $warning->addItem(new EaseTWBLinkButton('host.php', _('Založit první host') . ' ' . EaseTWBPart::GlyphIcon('edit')));
Esempio n. 5
0
 EaseShared::user($newOUser)->loginSuccess();
 $contact = new IEContact();
 $contact->setData(array('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));
 $contactGroup->addMember('members', $contactID, $login);
 $contactGroup->addMember('members', $mailID, $contact->getName());
 $cgID = $contactGroup->saveToMySQL();
 if ($cgID) {
     $oUser->addStatusMessage(_('Prvotní kontaktní skupina byla založena'), 'success');
 } else {
     $oUser->addStatusMessage(_('Prvotní kontaktní skupina nebyla založena'), 'warning');
 }
 $hostGroup = new IEHostgroup();
 $hostGroup->setName($newOUser->getUserLogin());
 $hostGroup->setDataValue('alias', _('Výchozí skupina') . ' ' . $newOUser->getUserLogin());
 $hostGroup->setDataValue('generate', true);
 $hostGroup->setUpUser($newOUser);
 $hostGroup->insertToMySQL();