コード例 #1
0
        $zipcode = $_POST['updateAddressZip' . $i];
        $country = $_POST['updateAddressCountry' . $i];
        $addressesArr[] = array('preferred' => $pref, 'type' => $type, 'poBox' => $poBox, 'addressLine1' => $addrLine1, 'addressLine2' => $addrLine2, 'city' => $city, 'state' => $state, 'zip' => $zipcode, 'country' => $country);
    }
    $contactArr['addresses'] = array('address' => $addressesArr);
    $emailsArr = array();
    $emailCount = intval($_POST['updateEmailIndex']);
    for ($i = 0; $i < $emailCount; ++$i) {
        $emailAddr = $_POST['updateEmailAddress' . $i];
        $pref = $_POST['updateEmailPref' . $i] === 'True' ? true : false;
        $type = $_POST['updateEmailType' . $i];
        $emailsArr[] = array('emailAddress' => $emailAddr, 'preferred' => $pref, 'type' => $type);
    }
    $contactArr['emails'] = array('email' => $emailsArr);
    $weburlsArr = array();
    $weburlCount = intval($_POST['updateWeburlIndex']);
    for ($i = 0; $i < $weburlCount; ++$i) {
        $url = $_POST['updateWeburl' . $i];
        $pref = $_POST['updateWeburlPref' . $i] === 'True' ? true : false;
        $type = $_POST['updateWeburlType' . $i];
        $weburlsArr[] = array('url' => $url, 'preferred' => $pref, 'type' => $type);
    }
    $contactArr['weburls'] = array('webUrl' => $weburlsArr);
    $contact = Contact::fromArray($contactArr);
    $aabService->updateContact($contact);
    $arr = array('success' => true, 'text' => 'Successfully updated contact.');
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
コード例 #2
0
 private function _handleUpdateContact()
 {
     $scalarVals = array('contactId', 'firstName', 'middleName', 'lastName', 'prefix', 'suffix', 'nickname', 'organization', 'jobTitle', 'anniversary', 'gender', 'spouse', 'children', 'hobby', 'assistant');
     $arrayVals = array('phone', 'phonePref', 'im', 'imPref', 'address', 'addressPref', 'email', 'emailPref', 'weburl', 'weburlPref');
     $vnames = array_merge($scalarVals, $arrayVals);
     $vnames[] = 'updateContact';
     $this->copyToSession($vnames);
     if (!isset($_SESSION['updateContact'])) {
         return;
     }
     $reqParams = $this->_getContactArrayData();
     foreach ($scalarVals as $val) {
         if (isset($_SESSION[$val]) && strlen($_SESSION[$val]) > 0) {
             $reqParams[$val] = $_SESSION[$val];
         }
     }
     try {
         $cc = Contact::fromArray($reqParams);
         $aabSrvc = new AABService($this->apiFQDN, $this->getSessionToken());
         $location = $aabSrvc->updateContact($cc);
         $this->results[C_CONTACT_SUCCESS] = true;
         $this->clearSession($vnames);
     } catch (Exception $e) {
         $this->errors[C_CONTACT_ERROR] = $e->getMessage();
         $this->clearSession($vnames);
     }
 }