public function reLinkObjects()
 {
     // to be written
     reLinkObjs($this->src, $this);
     reLinkObjs($this->dst, $this);
     reLinkObjs($this->snathosts, $this);
     if ($this->dnathost) {
         $this->dnathost->addReference($this);
     }
     if ($this->service) {
         $this->service->addReference($this);
     }
 }
 public function displayValueDiff(AddressGroup $otherObject, $indent = 0, $toString = false)
 {
     $retString = '';
     $indent = str_pad(' ', $indent);
     if (!$toString) {
         print $indent . "Diff for between " . $this->toString() . " vs " . $otherObject->toString() . "\n";
     } else {
         $retString .= $indent . "Diff for between " . $this->toString() . " vs " . $otherObject->toString() . "\n";
     }
     $diff = $this->getValueDiff($otherObject);
     if (count($diff['minus']) != 0) {
         foreach ($diff['minus'] as $d) {
             if (!$toString) {
                 print $indent . " - {$d->name()}\n";
             } else {
                 $retString .= $indent . " - {$d->name()}\n";
             }
         }
     }
     if (count($diff['plus']) != 0) {
         foreach ($diff['plus'] as $d) {
             if (!$toString) {
                 print $indent . " + {$d->name()}\n";
             } else {
                 $retString .= $indent . " + {$d->name()}\n";
             }
         }
     }
     if ($toString) {
         return $retString;
     }
 }
 /**
  * Creates a new Address Group named '$name' . Will exit with error if a group with that 
  * name already exists
  * @param $name string
  * @return AddressGroup
  **/
 public function newAddressGroup($name)
 {
     $found = $this->find($name, null, true);
     if ($found !== null) {
         derr("cannot create AddressGroup named '" . $name . "' as this name is already in use");
     }
     $newGroup = new AddressGroup($name, $this, true);
     $newGroup->setName($name);
     $this->add($newGroup);
     return $newGroup;
 }
 function DoUpdateGroup()
 {
     $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null;
     $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId);
     if (!$_settings->AllowContacts) {
         CXmlProcessing::PrintErrorAndExit(PROC_CANT_UPDATE_CONT, $_xmlRes);
     }
     $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, false, false);
     $contactManager =& ContactCreator::CreateContactStorage($_account, $_settings);
     $_groupNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('group');
     $_group = new AddressGroup();
     $_group->Id = $_groupNode->GetAttribute('id', -1);
     $_group->IdUser = $_account->IdUser;
     $_group->Name = $_groupNode->GetChildValueByTagName('name', true);
     $_group->IsOrganization = (bool) $_groupNode->GetAttribute('organization', false);
     $_group->Email = $_groupNode->GetChildValueByTagName('email', true);
     $_group->Company = $_groupNode->GetChildValueByTagName('company', true);
     $_group->Street = $_groupNode->GetChildValueByTagName('street', true);
     $_group->City = $_groupNode->GetChildValueByTagName('city', true);
     $_group->State = $_groupNode->GetChildValueByTagName('state', true);
     $_group->Zip = $_groupNode->GetChildValueByTagName('zip', true);
     $_group->Country = $_groupNode->GetChildValueByTagName('country', true);
     $_group->Phone = $_groupNode->GetChildValueByTagName('phone', true);
     $_group->Fax = $_groupNode->GetChildValueByTagName('fax', true);
     $_group->Web = $_groupNode->GetChildValueByTagName('web', true);
     $_contactsNode =& $_groupNode->GetChildNodeByTagName('contacts');
     $_contactsKeys = array_keys($_contactsNode->Children);
     foreach ($_contactsKeys as $_key) {
         $_cc =& $_contactsNode->Children[$_key];
         $_group->ContactsIds[] = $_cc->GetAttribute('id', -1);
         unset($_cc);
     }
     $_result = false;
     $_validatedError = $_group->validateData();
     if (true !== $_validatedError) {
         CXmlProcessing::PrintErrorAndExit($_validatedError, $_xmlRes);
     } else {
         if ($contactManager->UpdateGroup($_group)) {
             $_result = true;
             $_contactsNode =& $_groupNode->GetChildNodeByTagName('new_contacts');
             $_contactsKeys = array_keys($_contactsNode->Children);
             foreach ($_contactsKeys as $_key) {
                 $_cc =& $_contactsNode->Children[$_key];
                 $_personalNode =& $_cc->GetChildNodeByTagName('personal');
                 $_addressBookRecord = new AddressBookRecord();
                 $_addressBookRecord->IdUser = $_account->IdUser;
                 $_addressBookRecord->HomeEmail = $_personalNode->GetChildValueByTagName('email');
                 $_addressBookRecord->PrimaryEmail = PRIMARYEMAIL_Home;
                 $_result &= $contactManager->CreateContact($_addressBookRecord);
                 $_result &= $contactManager->InsertContactToGroup($_addressBookRecord->IdAddress, $_group->Id);
                 unset($_cc, $_personalNode, $_addressBookRecord);
             }
         }
     }
     if ($_result) {
         CXmlProcessing::GetContactList($_account, $_settings, $_xmlObj, $_xmlRes);
         $log =& CLog::CreateInstance();
         $log->WriteEvent('User edit PAB (group "' . $_group->Name . '")', $_account);
     } else {
         CXmlProcessing::PrintErrorAndExit(PROC_CANT_INS_NEW_CONTS, $_xmlRes);
     }
 }