protected function _ProcessParsedContact($IdUser, ContactContainerWithSingleGroup $contactContainer) { $ll =& CLog::CreateInstance(); $contactContainer->SetValue('IdUser', $IdUser, 'int'); $contactStrId = $contactContainer->GetValue('StrId'); $groupStrId = $contactContainer->GetValue('GroupStrId'); $groupName = $contactContainer->GetValue('GroupName'); $contact = new ContactContainer($contactContainer); $contact->SetValue('IdUser', $IdUser, 'int'); $ContactId = $this->_GetContactIdByStrId($IdUser, $contactStrId); if (0 < $ContactId) { $contact->SetValue('IdAddress', $ContactId, 'int'); } if (!empty($groupName)) { $groupContainer = $this->_GetGroupByStrId($IdUser, $groupStrId); if ($groupContainer) { $groupId = $groupContainer->GetValue('GroupId'); $groupContainer->MassSetValue($contactContainer->GetContainer()); $groupContainer->SetValue('GroupId', $groupId, 'int'); $groupContainer->SetValue('IdUser', $IdUser, 'int'); $this->_UpdateGroup($groupContainer); } else { $groupContainer = new GroupContainer($contactContainer); $groupContainer->SetValue('IdUser', $IdUser, 'int'); $this->_CreateGroup($groupContainer); } $contact->SetValue('Groups', array($groupContainer)); } if (0 < $contact->GetValue('IdAddress', 'int')) { $this->_UpdateVCardContact($contact); } else { $this->_CreateContact($contact); } }
/** * * @param <type> $fnContactContainer * @return <type> */ private function ConvertFunambolToWMContactContainer(&$fnContactContainer, $user_id, $updateDate = FALSE) { $wmContactContainer = new ContactContainer(); $wmContactContainer->SetValue('IdUser', $user_id); $wmContactContainer->SetValue('FunambolContactId', $fnContactContainer->GetValue('id')); $wmContactContainer->SetValue('Title', $fnContactContainer->GetValue('title')); $subject = $fnContactContainer->GetValue('subject'); if (empty($subject)) { $fname = $fnContactContainer->GetValue('first_name'); if (is_null($fname)) { $fname = ''; } $lname = $fnContactContainer->GetValue('last_name'); if (is_null($lname)) { $lname = ''; } $wmContactContainer->SetValue('FullName', $fname . ' ' . $lname); } else { $wmContactContainer->SetValue('FullName', $subject); } if ($fnContactContainer->GetValue('status') == FUNAMBOL_STATUS_DELETED) { $wmContactContainer->SetValue('Deleted', 1); } else { $wmContactContainer->SetValue('Deleted', 0); } $wmContactContainer->SetValue('FirstName', $fnContactContainer->GetValue('first_name')); $wmContactContainer->SetValue('SurName', $fnContactContainer->GetValue('last_name')); $wmContactContainer->SetValue('NickName', $fnContactContainer->GetValue('nickname')); $wmContactContainer->SetValue('Notes', $fnContactContainer->GetValue('body')); $wmContactContainer->SetValue('UseFriendlyName', 1); $wmContactContainer->SetValue('HomeStreet', $fnContactContainer->GetValue('HomeStreet')); $wmContactContainer->SetValue('HomeCity', $fnContactContainer->GetValue('HomeCity')); $wmContactContainer->SetValue('HomeState', $fnContactContainer->GetValue('HomeState')); $wmContactContainer->SetValue('HomeZip', $fnContactContainer->GetValue('HomeZip')); $wmContactContainer->SetValue('HomeCountry', $fnContactContainer->GetValue('HomeCountry')); $wmContactContainer->SetValue('HomePhone', $fnContactContainer->GetValue('HomePhone')); $wmContactContainer->SetValue('HomeFax', $fnContactContainer->GetValue('HomeFax')); $wmContactContainer->SetValue('HomeMobile', $fnContactContainer->GetValue('HomeMobile')); $wmContactContainer->SetValue('HomeEmail', $fnContactContainer->GetValue('HomeEmail')); $wmContactContainer->SetValue('HomeWeb', $fnContactContainer->GetValue('HomeWeb')); $wmContactContainer->SetValue('BusinessEmail', $fnContactContainer->GetValue('BusinessEmail')); $wmContactContainer->SetValue('BusinessCompany', $fnContactContainer->GetValue('company')); $wmContactContainer->SetValue('BusinessStreet', $fnContactContainer->GetValue('BusinessStreet')); $wmContactContainer->SetValue('BusinessCity', $fnContactContainer->GetValue('BusinessCity')); $wmContactContainer->SetValue('BusinessState', $fnContactContainer->GetValue('BusinessState')); $wmContactContainer->SetValue('BusinessZip', $fnContactContainer->GetValue('BusinessZip')); $wmContactContainer->SetValue('BusinessCountry', $fnContactContainer->GetValue('BusinessCountry')); $wmContactContainer->SetValue('BusinessJobTitle', $fnContactContainer->GetValue('job_title')); $wmContactContainer->SetValue('BusinessDepartment', $fnContactContainer->GetValue('department')); $wmContactContainer->SetValue('BusinessOffice', $fnContactContainer->GetValue('office_location')); $wmContactContainer->SetValue('BusinessPhone', $fnContactContainer->GetValue('BusinessPhone')); // $wmContactContainer->SetValue('BusinessMobile'); $wmContactContainer->SetValue('BusinessFax', $fnContactContainer->GetValue('BusinessFax')); // $wmContactContainer->SetValue('BusinessWeb',); $wmContactContainer->SetValue('OtherEmail', $fnContactContainer->GetValue('OtherEmail')); // $wmContactContainer->SetValue('PrimaryEmail',); // $this->_container['IdPreviousAddress'] = null; // $this->_container['Temp'] = null; if (strlen($fnContactContainer->GetValue('birthday')) >= 10) { // we have sufficient length $ts = strtotime($fnContactContainer->GetValue('birthday')); $wmContactContainer->SetValue('BirthdayDay', date('d', $ts)); // 01 through 31 $wmContactContainer->SetValue('BirthdayMonth', date('m', $ts)); // 01 through 12 $wmContactContainer->SetValue('BirthdayYear', date('Y', $ts)); // 2010 } else { // birthday looks like bad } if ($updateDate) { // as seconds from Epoch $fnTimestampModified = $this->ConvertFNtoWMTimestamp($fnContactContainer->GetValue('last_update'), TRUE); $fnDateModified = date('Y-m-d H:i:s', $fnTimestampModified); $wmContactContainer->SetValue('DateCreated', $fnDateModified); //FIXIT $wmContactContainer->SetValue('DateModified', $fnDateModified); } else { //$wmContactContainer->_container['DateCreated'] = null; //$wmContactContainer->_container['DateModified'] = null; } return $wmContactContainer; }