/** * Umožňuje měnit parametry služeb * * @param IEContact $contact * @param IEHost $host ObjektHostu */ public function __construct($contact) { parent::__construct(); $this->subcontactTypes = array_combine($this->subcontactTypes, $this->subcontactTypes); $this->contact = $contact; $this->addItem(new EaseHtmlDivTag(null, _('Založeno') . ': ' . $this->contact->getDataValue('DatCreate'))); $oPage = EaseShared::webPage(); if ($oPage->isPosted()) { $oldId = $this->contact->getId(); $contactType = $oPage->getRequestValue('contact'); $contactData = $oPage->getRequestValue('cnt'); if (isset($contactType) && strlen($contactData)) { if ($this->contact->fork(array($contactType => $contactData))) { $this->addStatusMessage(sprintf(_('Kontaktní údaj %s %s byl přidán'), $contactType, $contactData), 'success'); $this->cnt = ''; } else { $this->addStatusMessage(sprintf(_('Kontaktní údaj %s %s nebyl přidán'), $contactType, $contactData), 'error'); $this->cnt = EaseShared::webPage()->getRequestValue('cnt'); } } $this->contact->loadFromMySQL($oldId); } }
/** * 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'); } }
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; } }
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(); } } } }