/** * 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); }
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()); if (!is_null($contactgroup->getMyKey())) { $form->addItem(new EaseHtmlInputHiddenTag($contactgroup->getmyKeyColumn(), $contactgroup->getMyKey())); } $form->addItem('<br>'); $form->addItem(new EaseTWSubmitButton(_('Uložit'), 'success')); $oPage->addItem(new IEPageBottom()); $infopanel = new IEInfoBox($contactgroup); $tools = new EaseTWBPanel(_('Nástroje'), 'warning'); if ($contactgroup->getId()) { $tools->addItem($contactgroup->deleteButton()); } $pageRow = new EaseTWBRow(); $pageRow->addColumn(2, $infopanel); $pageRow->addColumn(6, new EaseTWBPanel(_('Skupina kontaktů') . ' <strong>' . $contactgroup->getName() . '</strong>', 'default', $form)); $pageRow->addColumn(4, $tools); $oPage->container->addItem($pageRow); $oPage->draw();