function update(Contact $contact) { $id = $contact->getId(); if ($id == "" && $contact->getEmail() != "") { /* on va rechercher par rapport à l'adresse Email */ $id = $this->recherche_email($contact->getEmail()); if ($id === false) { } else { $contact->setId($id); } } if ($contact->getId() == '') { /* Il faut faire une création et pas un update */ } else { $elt = $contact->toAdd(); $response = $this->mySforceConnection->update(array($elt), 'Contact'); if ($response[0]->success) { } else { print_r($response); $msg = implode(';', $response[0]->errors); return $msg; } } return true; }
public function __construct($arrayAccounts) { // browse through list $collection = array(); if ($arrayAccounts) { foreach ($arrayAccounts as $arrayAccount) { if (empty($arrayAccount['name_value_list']['account_name'])) { $arrayAccount['name_value_list']['account_name'] = ""; } $contact = new Contact(); $contact->setId($arrayAccount['name_value_list']['id']); $contact->setGroup($arrayAccount['name_value_list']['account_name']); $contact->setFirstname(htmlspecialchars_decode($arrayAccount['name_value_list']['first_name'], ENT_QUOTES)); $contact->setLastname($arrayAccount['name_value_list']['last_name']); $contact->setWorkPhone($arrayAccount['name_value_list']['phone_work']); $contact->setWorkMobile($arrayAccount['name_value_list']['phone_mobile']); $contact->sethomePhone(''); $contact->sethomeMobile(''); $collection[$contact->getId()] = $contact; } // Sort accounts by name usort($collection, function ($a, $b) { return strcmp($a->getFirstname(), $b->getFirstname()); }); } // build ArrayObject using collection return parent::__construct($collection); }
public function testDeleteContacts() { for ($i = 0; $i < MAX_CONTACTS; $i++) { $contact = new Contact(); $contact->setId($i); $this->agenda->deleteContact($contact); } }
protected function modify(Contact $contact) { $q = $this->dao->prepare('UPDATE ' . $this->table() . ' SET USER_ID_1 = :userId1, USER_ID_2 = :userId2, CONTACT_GROUP_ID = :contactGroupId WHERE ID=:id'); $q->bindValue(':userId1', $contact->getUserId1(), PDO::PARAM_INT); $q->bindValue(':userId2', $contact->getUserId2(), PDO::PARAM_INT); $q->bindValue(':contactGroupId', $contact->getContactGroupId(), PDO::PARAM_INT); $q->bindValue(':id', $contact->id(), PDO::PARAM_INT); $q->execute(); $contact->setId($this->dao->lastInsertId()); }
/** * Finish the installation - create owner company and administrator * * @param void * @return null */ function complete_installation() { if (Companies::getOwnerCompany() instanceof Company) { die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists } // if $this->setLayout('complete_install'); $form_data = array_var($_POST, 'form'); tpl_assign('form_data', $form_data); if (array_var($form_data, 'submitted') == 'submitted') { try { $admin_password = trim(array_var($form_data, 'admin_password')); $admin_password_a = trim(array_var($form_data, 'admin_password_a')); if (trim($admin_password) == '') { throw new Error(lang('password value required')); } // if if ($admin_password != $admin_password_a) { throw new Error(lang('passwords dont match')); } // if DB::beginWork(); Users::delete(); // clear users table Companies::delete(); // clear companies table // Create the administrator user $administrator = new User(); $administrator->setId(1); $administrator->setUsername(array_var($form_data, 'admin_username')); $administrator->setEmail(array_var($form_data, 'admin_email')); $administrator->setPassword($admin_password); $administrator->setIsAdmin(true); $administrator->setAutoAssign(true); $administrator->save(); // Create the contact for administrator $administrator_contact = new Contact(); $administrator_contact->setId(1); $administrator_contact->setCompanyId(1); $administrator_contact->setEmail(array_var($form_data, 'admin_email')); $administrator_contact->setUserId($administrator->getId()); $administrator_contact->setDisplayName($administrator->getUsername()); $administrator_contact->save(); // Create a company $company = new Company(); $company->setId(1); $company->setClientOfId(0); $company->setName(array_var($form_data, 'company_name')); $company->setCreatedById(1); $company->save(); DB::commit(); $this->redirectTo('access', 'login'); } catch (Exception $e) { tpl_assign('error', $e); DB::rollback(); } // try } // if }
public function parseContact($data) { $contact = new Contact(); if (isset($data['id'])) { $contact->setId($data['id']); } if (isset($data['firstName'])) { $contact->setFirstName($data['firstName']); } if (isset($data['name'])) { $contact->setName($data['name']); } if (isset($data['mail'])) { $contact->setMail($data['mail']); } if (isset($data['company'])) { $contact->setCompany($data['company']); } if (isset($data['phone'])) { $contact->setPhone($data['phone']); } if (isset($data['phone2'])) { $contact->setPhone2($data['phone2']); } if (isset($data['phone3'])) { $contact->setPhone3($data['phone3']); } if (isset($data['address'])) { $contact->setAddress($this->addressService->getAddress($data['address'])); } if (isset($data['type'])) { $contact->setType($this->typeService->getType($data['type'])); } if (isset($data['exchangeId'])) { $contact->setExchangeId($data['exchangeId']); } return $contact; }
/** * Public function that gets list members of a single list object passed to it. * * @param object $list - a valid list object with a valid list link * @return array $List - returns first 50 contact objects that are part of that list, and a link to next 50 */ public function getListMembers($list) { $utility = new Utility(); $call = $utility->getApiPath() . $list->getLink() . '/members'; $return = $utility->httpGet($call); $parsedReturn = simplexml_load_string($return['xml']); $List = array(); $listMembers = array(); $pages = array(); foreach ($parsedReturn->entry as $item) { $contact = new Contact(); $contact->setLink($item->link->Attributes()->href); $contact->setId($item->id); $contact->setFullName($item->content->ContactListMember->Name); $contact->setEmailAddress($item->content->ContactListMember->EmailAddress); $listMembers[] = $contact; } $pages[] = $parsedReturn->link[2]->Attributes(); $pages[] = $parsedReturn->link[3]->Attributes(); //$pages[] = $parsedReturn->link[4]->Attributes(); $List = array($listMembers, $pages); if (!$return) { return false; } else { return $List; } }
function contactParser($data) { $contact = new Contact(); if (isset($data['id'])) { $contact->setId($data['id']); } if (isset($data['firstName'])) { $contact->setFirstName($data['firstName']); } if (isset($data['name'])) { $contact->setName($data['name']); } if (isset($data['mail'])) { $contact->setMail($data['mail']); } if (isset($data['phone'])) { $contact->setPhone($data['phone']); } if (isset($data['phone2'])) { $contact->setPhone2($data['phone2']); } if (isset($data['phone3'])) { $contact->setPhone3($data['phone3']); } if (isset($data['company'])) { $contact->setCompany($data['company']); } if (isset($data['address'])) { $dataAddress = $data['address']; $address = new Address(); if (isset($dataAddress['id'])) { $address->setId($dataAddress['id']); } if (isset($dataAddress['line1'])) { $address->setLine1($dataAddress['line1']); } if (isset($dataAddress['line2'])) { $address->setLine2($dataAddress['line2']); } if (isset($dataAddress['zipCode'])) { $address->setZipCode($dataAddress['zipCode']); } if (isset($dataAddress['city'])) { $address->setCity($dataAddress['city']); } if (isset($dataAddress['latitude']) && isset($dataAddress['longitude'])) { $address->setLatitude($dataAddress['latitude']); $address->setLongitude($dataAddress['longitude']); } else { $mapService = new GoogleMapService(); $latlng = $mapService->getLatLong($address); if ($latlng != [] && sizeof($latlng) == 2) { $address->setLatitude($latlng[0]); $address->setLongitude($latlng[1]); } } $contact->setAddress($address); } if (isset($data['type'])) { if (isset($data['type']['id']) && isset($data['type']['name'])) { $type = new Type($data['type']['id'], $data['type']['name']); } elseif (isset($data['type']['name'])) { $type = new Type(null, $data['type']['name']); } else { $type = null; } $contact->setType($type); } if (isset($data['exchangeId'])) { $contact->setExchangeId($data['exchangeId']); } return $contact; }
function getAllContact() { $contactRequete = "SELECT * FROM contact WHERE ID_QUESTIONNAIRE"; $contactResultat = $GLOBALS['bdd']->query($contactRequete); $listeContacts = new ArrayObject(); while ($unContact = $contactResultat->fetch()) { $contact = new Contact(); $contact->setId($unContact['ID_CONTACT']); $contact->setIdQuestionnaire($unContact['ID_QUESTIONNAIRE']); $contact->setNom($unContact['NOM_CONTACT']); $contact->setPrenom($unContact['PRENOM_CONTACT']); $contact->setDateNaissance($unContact['DATENAISSANCE_CONTACT']); $contact->setNumero($unContact['NUMTEL_CONTACT']); $contact->setRegion($unContact['IDREGION_CONTACT']); $contact->setARepondu($unContact['aRepondu']); $contact->setNotes($unContact['notes']); $listeContacts->append($contact); } return $listeContacts; }
/** * Create object with given data * * @param array $data * @param static $instance * @return static */ public static function _create($data, $instance = null) { if (null === $instance || !is_object($instance)) { $instance = new static(); } $instance->created = true; foreach ($data as $key => $value) { $key = trim($key); switch ($key) { // Skip some -other- elements case 'language_name': case 'contact_or_company': break; case substr($key, 0, 3) == 'cf_': $id = substr($key, 3); $instance->addCustomField($id, $value); break; case 'for_id': case 'contact_or_company_id': $target = isset($data['for']) ? $data['for'] : $data['contact_or_company']; $id = isset($data['for_id']) ? $data['for_id'] : $data['contact_or_company_id']; switch ($target) { case 'company': $value = new Company(); $value->setId($id); break; case 'contact': $value = new Contact(); $value->setId($id); break; default: exit('SHOULD STILL MAP: ' . $target . '! Please report at https://github.com/bmoex/teamleader!'); break; } if (method_exists($instance, 'setClient')) { $instance->setClient($value); } break; case 'deleted': $instance->setDeleted($value == 1); break; default: $key = str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); $methodName = 'set' . $key; if (method_exists($instance, $methodName)) { call_user_func(array($instance, $methodName), $value); } else { // Ignore empty values if (empty($value)) { continue; } $key = lcfirst($key); // Always try to set the key if (!isset($instance->{$key})) { $instance->{$key} = $value; } } } } return $instance; }