/** * 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'); } }