本文整理汇总了PHP中Contact::setFirstName方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::setFirstName方法的具体用法?PHP Contact::setFirstName怎么用?PHP Contact::setFirstName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::setFirstName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: console_create_user
function console_create_user($args)
{
$fname = array_shift($args);
$lname = array_shift($args);
$email = array_shift($args);
$admin = array_shift($args) == 'true';
if (is_null($fname) || is_null($lname) || is_null($email)) {
throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
}
$display_name = $fname . " " . $lname;
$username = str_replace(" ", "_", strtolower($display_name));
$user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
// array
try {
DB::beginWork();
$user = create_user($user_data, $admin, '');
if (!$user->getContact() instanceof Contact) {
$contact = new Contact();
$contact->setFirstName($fname);
$contact->setLastName($lname);
$contact->setEmail($email);
$contact->setUserId($user->getId());
$contact->save();
}
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
}
}
示例2: testAddContact
function testAddContact () {
/* Creation du contact */
$contact = new Contact();
$contact->setEmail("test@test.fr");
$contact->setFirstName("erwantest");
$contact->setLastName('dagorntest');
$ret = $this->sales->add($contact);
echo '<pre> testAddContact <br>/';
print_r($contact);
echo '<br/> retour :'.$ret;
$this->assertIdentical($ret, true);
$this->assertIdentical(($contact->getId() != ""), true);
/* Modification du contact */
$contact->setFirstName("erwantestModif");
$ret = $this->sales->update($contact);
$this->assertIdentical($ret, true);
/* Suppression du contact */
$ret = $this->sales->delete($contact->getId());
$this->assertIdentical($ret, true);
}
示例3: trim
/**
* @author Ignacio Vazquez <elpepe.uy at gmail dot com>
* Handle quick add submit
*/
function quick_add() {
if (array_var($_GET, 'current') == 'overview-panel') {
ajx_current("reload");
}else {
ajx_current("empty");
}
//---------- REQUEST PARAMS --------------
// $_POST = Array (
// [member] => Array (
// [name] => pepe 333
// [dimension_id] => 1
// [parent_member_id] => 0
// [dimension_id] => 19
// )
// [contact] => Array (
// [email] => slkdjflksjdflksdf@kldsjflkdf.com
// [user] => Array (
// [create-user]=>on
// [type] => 25
// [first_name] =>
// [surname] =>
// )
//----------------------------------------
// Init variables
$max_users = config_option('max_users');
if ($max_users && (Contacts::count() >= $max_users)) {
flash_error(lang('maximum number of users reached error'));
ajx_current("empty");
return;
}
if (!can_manage_security(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$email = trim(array_var(array_var($_POST, 'contact'),'email')) ;
$member = array_var($_POST, 'member');
$name = array_var($member, 'name');
$firstName = trim(array_var(array_var($_POST, 'contact'),'first_name'));
$surname = trim(array_var(array_var($_POST, 'contact'),'surname'));
$parentMemberId = array_var($member, 'parent_member_id');
$objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName(); // 'person', 'company'
$dimensionId = array_var($member, 'dimension_id');
$company = array_var(array_var(array_var($_POST, 'contact'),'user'),'company_id');
// Create new instance of Contact and set the basic fields
$contact = new Contact();
$contact->setObjectName($name);
if ($firstName) {
$contact->setFirstName($firstName);
}else{
$contact->setFirstName($name);
}
if ($surname) {
$contact->setSurname($surname);
}
$contact->setCompanyId($company);
$contact->setIsCompany($objectType == "company");
if ($parentMemberId){
if ( $companyId = Members::findById($parentMemberId)->getObjectId()) {
$contact->setCompanyId($companyId);
}
}
// Save Contact
try {
DB::beginWork();
$contact->save();
if ($email && is_valid_email($email)) {
if (!Contacts::validateUniqueEmail($email)) {
DB::rollback();
flash_error(lang("email address must be unique"));
return false;
}else{
if (!array_var (array_var(array_var($_POST, 'contact'),'user'), 'create-user')) {
$contact->addEmail($email, 'personal', true);
}
flash_success(lang("success add contact", $contact->getObjectName()));
}
}
// User settings
$user = array_var(array_var($_POST, 'contact'),'user');
$user['username'] = str_replace(" ","",strtolower($name)) ;
$this->createUserFromContactForm($user, $contact->getId(), $email);
// Reload contact again due to 'createUserFromContactForm' changes
Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret);
//.........这里部分代码省略.........
示例4: createContact
private function createContact()
{
$contact = new Contact();
$contact->setEmail($this->getFieldValue('Email'));
$contact->setLastName($this->getFieldValue('LastName'));
$contact->setFirstName($this->getFieldValue('FirstName'));
$contact->setPhone($this->getFieldValue('Telephone'));
$contact->setSujet($this->getFieldValue('Objet'));
$contact->setWhatId($this->getFieldValue('whatId'));
if ($this->getFieldValue('formname') == 'contact_default') {
$contact->setSujet("Contactez nke : " . $contact->getSujet());
}
$corp = "[Origine : " . $this->getCurrentURL() . "]\n" . $this->getFieldValue('Message');
if ($this->getFieldValue('formname') == 'contact_revendeur') {
$corp .= "Ville de Résidence : " . $this->getFieldValue('Ville') . "\n" . "Port d'attache : " . $this->getFieldValue('Port') . "\n";
//"Chantier naval : ".$this->getFieldValue('ChantierNaval')."\n";
}
$contact->setTexte($corp);
return $contact;
}
示例5: die
/**
* Finish the installation - create owner company and administrator
*
* @param void
* @return null
*/
function complete_installation()
{
if (Contacts::getOwnerCompany() instanceof Contact) {
die('Owner company already exists');
// Somebody is trying to access this method even if the user already exists
}
// if
$form_data = array_var($_POST, 'form');
tpl_assign('form_data', $form_data);
if (array_var($form_data, 'submited') == 'submited') {
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();
Contacts::delete();
// clear users table
// Create a company
$company = new Contact();
$company->setFirstName(array_var($form_data, 'company_name'));
$company->setObjectName();
$company->setIsCompany(true);
$company->save();
// Init default colors
set_config_option('brand_colors_head_back', "424242");
set_config_option('brand_colors_tabs_back', "e7e7e7");
set_config_option('brand_colors_head_font', "FFFFFF");
set_config_option('brand_colors_tabs_font', "333333");
// Create the administrator user
$administrator = new Contact();
$pergroup = PermissionGroups::findOne(array('conditions' => "`name`='Super Administrator'"));
$administrator->setUserType($pergroup->getId());
$administrator->setCompanyId($company->getId());
$administrator->setUsername(array_var($form_data, 'admin_username'));
$administrator->setPassword($admin_password);
$administrator->setFirstname(array_var($form_data, 'admin_username'));
$administrator->setObjectName();
$administrator->save();
$user_password = new ContactPassword();
$user_password->setContactId($administrator->getId());
$user_password->password_temp = $admin_password;
$user_password->setPasswordDate(DateTimeValueLib::now());
$user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
$user_password->save();
//Add email after save because is needed.
$administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
//permissions
$permission_group = new PermissionGroup();
$permission_group->setName('Account Owner');
$permission_group->setContactId($administrator->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$administrator->setPermissionGroupId($permission_group->getId());
$administrator->save();
$company->setCreatedById($administrator->getId());
$company->setUpdatedById($administrator->getId());
$company->save();
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($administrator->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
// tab panel permissions
$panels = TabPanels::getEnabled();
foreach ($panels as $panel) {
$tpp = new TabPanelPermission();
$tpp->setPermissionGroupId($administrator->getPermissionGroupId());
$tpp->setTabPanelId($panel->getId());
$tpp->save();
}
// dimension permissions
$dimensions = Dimensions::findAll();
foreach ($dimensions as $dimension) {
if ($dimension->getDefinesPermissions()) {
$cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = " . $administrator->getPermissionGroupId() . " AND `dimension_id` = " . $dimension->getId()));
if (!$cdp instanceof ContactDimensionPermission) {
$cdp = new ContactDimensionPermission();
$cdp->setPermissionGroupId($administrator->getPermissionGroupId());
$cdp->setContactDimensionId($dimension->getId());
}
$cdp->setPermissionType('allow all');
$cdp->save();
// contact member permisssion entries
$members = $dimension->getAllMembers();
foreach ($members as $member) {
$ots = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId());
$ots[] = $member->getObjectId();
//.........这里部分代码省略.........
示例6: MailContent
//.........这里部分代码省略.........
$body = utf8_safe($body);
if (array_var($mail_data, 'format') == 'html') {
$mail->setBodyHtml($body);
$mail->setBodyPlain(utf8_safe(html_to_text($body)));
} else {
$mail->setBodyPlain($body);
$mail->setBodyHtml('');
}
$mail->setFrom($account->getEmailAddress());
$mail->setFromName(logged_user()->getDisplayName());
$mail->save();
$mail->setIsRead(logged_user()->getId(), true);
$mail->setTagsFromCSV(array_var($mail_data, 'tags'));
// autoclassify sent email
// if replying a classified email classify on same workspace
$classified = false;
if (array_var($mail_data, 'original_id')) {
$in_reply_to = MailContents::findById(array_var($mail_data, 'original_id'));
if ($in_reply_to instanceof MailContent) {
$workspaces = $in_reply_to->getWorkspaces();
foreach ($workspaces as $w) {
if ($mail->canAdd(logged_user(), $w)) {
$mail->addToWorkspace($w);
$classified = true;
}
}
}
}
if (!$classified && $account->getWorkspace() instanceof Project) {
$mail->addToWorkspace($account->getWorkspace());
}
if (!$classified && active_project() instanceof Project) {
$mail->addToWorkspace(active_project());
}
$object_controller = new ObjectController();
$object_controller->add_custom_properties($mail);
$object_controller->link_to_new_object($mail);
if (array_var($mail_data, 'link_to_objects') != '') {
$lto = explode('|', array_var($mail_data, 'link_to_objects'));
foreach ($lto as $object_string) {
$split_object = explode('-', $object_string);
$object = get_object_by_manager_and_id($split_object[1], $split_object[0]);
if ($object instanceof ProjectDataObject) {
$mail->linkObject($object);
}
}
}
ApplicationLogs::createLog($mail, $mail->getWorkspaces(), ApplicationLogs::ACTION_ADD);
if (user_config_option('create_contacts_from_email_recipients') && can_manage_contacts(logged_user())) {
// automatically create contacts
foreach ($to as $recipient) {
$recipient_name = trim($recipient[0]);
$recipient_address = trim($recipient[1]);
if (!$recipient_address) {
continue;
}
$contact = Contacts::getByEmail($recipient_address);
if (!$contact instanceof Contact) {
try {
$contact = new Contact();
$contact->setEmail($recipient_address);
if ($recipient_name && $recipient_name != $recipient_address) {
$contact->setFirstName($recipient_name);
} else {
$index = strpos($recipient_address, "@");
$recipient_name = substr($recipient_address, 0, $index);
$contact->setFirstName($recipient_name);
}
$contact->save();
} catch (Exception $e) {
// TODO: show error message?
}
}
}
}
DB::commit();
if (!$autosave) {
if ($isDraft) {
flash_success(lang('success save mail'));
ajx_current("empty");
} else {
evt_add("must send mails", array("account" => $mail->getAccountId()));
//flash_success(lang('mail is being sent'));
ajx_current("back");
}
evt_add("email saved", array("id" => $mail->getId(), "instance" => array_var($_POST, 'instanceName')));
} else {
evt_add("draft mail autosaved", array("id" => $mail->getId(), "hf_id" => $mail_data['hf_id']));
flash_success(lang('success autosave draft'));
ajx_current("empty");
}
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
ajx_current("empty");
}
// try
}
// if
}
示例7: parseContact
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;
}
示例8: trim
/**
* Finish the installation - create owner company and administrator
*
* @param void
* @return null
*/
function complete_installation() {
if(Contacts::getOwnerCompany() instanceof Contact) {
die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists
} // if
$form_data = array_var($_POST, 'form');
tpl_assign('form_data', $form_data);
if(array_var($form_data, 'submited') == 'submited') {
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();
Contacts::delete(); // clear users table
// Create a company
$company = new Contact();
$company->setFirstName(array_var($form_data, 'company_name'));
$company->setObjectName();
$company->setIsCompany(true);
$company->save();
// Init default colors
set_config_option('brand_colors_head_back', "000000");
set_config_option('brand_colors_tabs_back', "14780e");
set_config_option('brand_colors_head_font', "ffffff");
set_config_option('brand_colors_tabs_font', "ffffff");
// Create the administrator user
$administrator = new Contact();
$pergroup = PermissionGroups::findOne(array('conditions'=>"`name`='Super Administrator'"));
$administrator->setUserType($pergroup->getId());
$administrator->setCompanyId($company->getId());
$administrator->setUsername(array_var($form_data, 'admin_username'));
$administrator->setPassword($admin_password);
$administrator->setFirstname(array_var($form_data, 'admin_username'));
$administrator->setObjectName();
$administrator->save();
$user_password = new ContactPassword();
$user_password->setContactId($administrator->getId());
$user_password->password_temp = $admin_password;
$user_password->setPasswordDate(DateTimeValueLib::now());
$user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
$user_password->save();
//Add email after save because is needed.
$administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
//permissions
$permission_group = new PermissionGroup();
$permission_group->setName('Account Owner');
$permission_group->setContactId($administrator->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$administrator->setPermissionGroupId($permission_group->getId());
$administrator->save();
$company->setCreatedById($administrator->getId());
$company->setUpdatedById($administrator->getId());
$company->save();
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($administrator->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
// tab panel permissions
$panels = TabPanels::getEnabled();
foreach ($panels as $panel) {
$tpp = new TabPanelPermission();
$tpp->setPermissionGroupId($administrator->getPermissionGroupId());
$tpp->setTabPanelId($panel->getId());
$tpp->save();
}
// dimension permissions
$dimensions = Dimensions::findAll();
foreach ($dimensions as $dimension) {
//.........这里部分代码省略.........
示例9: ContactsCollection
function signup_user_constant_contact($firstname, $lastname, $email, $list)
{
global $premise_base;
require_once PREMISE_LIB_DIR . 'constant_contact_api/constant_contact_api.php';
$settings = $premise_base->get_settings();
$optin = $settings['optin'];
$premise_base->setup_constant_contact($this->_optin_ConstantContactKey, $optin['constant-contact-username'], $optin['constant-contact-password']);
$collection = new ContactsCollection();
list($search) = $collection->searchByEmail($email);
if (!empty($search)) {
foreach ($search as $possible) {
if ($email == $possible->getEmailAddress()) {
$contact = $collection->getContact($possible->getLink());
break;
}
}
}
$listKey = 'http://api.constantcontact.com/ws/customers/' . $optin['constant-contact-username'] . '/lists/' . $list;
if ($contact) {
$existingLists = $contact->getLists();
if (in_array($listKey, $existingLists)) {
return array('error' => __('You have already subscribed to this mailing list', 'premise'));
} else {
$contact->setLists($listKey);
}
$contact->setFirstName($firstname);
$contact->setLastName($lastname);
$result = $collection->updateContact($contact->getId(), $contact);
} else {
$contact = new Contact();
$contact->setFirstName($firstname);
$contact->setLastName($lastname);
$contact->setEmailAddress($email);
$contact->setLists($listKey);
$result = $collection->createContact($contact);
}
$first = substr((string) $result, 0, 1);
if ($first != 2) {
return array('error' => __('Could not subscribe you to this mailing list', 'premise'));
}
return true;
}
示例10: contactParser
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;
}
示例11: parseContact
public function parseContact($contactObject)
{
$contact = new Contact();
$contact->setPhoneNumber($contactObject->phone_number);
$contact->setFirstName($contactObject->first_name);
if (property_exists($contactObject, 'last_name')) {
$contact->setLastName($contactObject->last_name);
}
if (property_exists($contactObject, 'user_id')) {
$contact->setUserId($contactObject->user_id);
}
return $contact;
}
示例12: getAllContacts
/**
* Used to get all the contacts from Exchange
* @return array of contact
*/
public function getAllContacts()
{
try {
$contactList = [];
$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ContactsView = new EWSType_ContactsViewType();
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CONTACTS;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$response = parent::getEws()->FindItem($request);
if (isset($response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact)) {
$stdContacts = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact;
} else {
return null;
}
foreach ($stdContacts as $c) {
$contact = new Contact();
if (isset($c->ItemId->Id)) {
$contact->setExchangeId($c->ItemId->Id);
}
if (isset($c->CompleteName)) {
if (isset($c->CompleteName->FirstName)) {
$contact->setFirstName($c->CompleteName->FirstName);
}
if (isset($c->CompleteName->LastName)) {
if (strpos($c->CompleteName->LastName, '--') !== false) {
$nameAndType = $this->getTypeFromName($c->CompleteName->LastName);
if (sizeof($nameAndType) == 2) {
$contact->setName($nameAndType[0]);
$typeService = new TypeService();
$type = $typeService->getType($nameAndType[1]);
if ($type != null) {
$contact->setType($type);
} else {
$contact->setType(null);
}
} else {
$contact->setName($c->CompleteName->LastName);
}
} else {
$contact->setName($c->CompleteName->LastName);
}
}
}
if (isset($c->PhoneNumbers->Entry)) {
if (is_array($c->PhoneNumbers->Entry)) {
$contact->setPhone($c->PhoneNumbers->Entry[0]->_);
if (sizeof($c->PhoneNumbers->Entry) > 1) {
if (isset($c->PhoneNumbers->Entry[1])) {
$contact->setPhone2($c->PhoneNumbers->Entry[1]->_);
}
}
if (sizeof($c->PhoneNumbers->Entry) > 2) {
if (isset($c->PhoneNumbers->Entry[2])) {
$contact->setPhone3($c->PhoneNumbers->Entry[2]->_);
}
}
} else {
$contact->setPhone($c->PhoneNumbers->Entry->_);
}
}
if (isset($c->EmailAddresses->Entry)) {
if (is_array($c->EmailAddresses->Entry)) {
$contact->setMail($c->EmailAddresses->Entry[0]->_);
} else {
$contact->setMail($c->EmailAddresses->Entry->_);
}
}
if (isset($c->CompanyName)) {
$contact->setCompany($c->CompanyName);
}
if (isset($c->PhysicalAddresses->Entry)) {
$address = new Address();
$stdAddress = $c->PhysicalAddresses->Entry;
if (is_array($stdAddress)) {
$address->setLine1($stdAddress[0]->Street);
$address->setZipCode($stdAddress[0]->PostalCode);
$address->setCity($stdAddress[0]->City);
} else {
if (isset($stdAddress->Street)) {
$address->setLine1($stdAddress->Street);
}
if (isset($stdAddress->PostalCode)) {
$address->setZipCode($stdAddress->PostalCode);
}
if (isset($stdAddress->City)) {
$address->setCity($stdAddress->City);
}
}
$contact->setAddress($address);
}
array_push($contactList, $contact);
}
//.........这里部分代码省略.........
示例13: submitManagerApplication
private function submitManagerApplication()
{
$request = \Server::getCurrentRequest();
$vars = $request->getVars();
$username = $request->getVar('managerUsername');
$password = $request->getVar('managerPassword');
$first_name = $request->getVar('contactFirstName');
$last_name = $request->getVar('contactLastName');
$email = $request->getVar('emailAddress');
$phone = $request->getVar('phoneNumber');
$hours = $request->getVar('contactHours');
$company_name = $request->getVar('companyName');
$company_url = $request->getVar('companyUrl');
$company_address = $request->getVar('companyAddress');
$private = $request->getVar('managerType');
$contact = new Contact();
try {
$contact->setUsername($username);
$contact->setPassword($password);
$contact->setFirstName($first_name);
$contact->setLastName($last_name);
$contact->setEmailAddress($email);
$contact->setPhone($phone);
$contact->setTimesAvailable($hours);
if ($private == 'false') {
$contact->setPrivate(false);
if (empty($company_name)) {
throw \Exception('Missing company name');
} else {
$contact->setCompanyName($company_name);
}
if (empty($company_address)) {
throw \Exception('Missing company address');
} else {
$contact->setCompanyAddress($company_address);
}
$contact->setCompanyUrl($company_url);
} else {
$contact->setPrivate(true);
$contact->setCompanyName('Private Renter');
}
$contact->setApproved(false);
$contact->save();
$this->emailApprovalNeeded();
} catch (\Exception $ex) {
$address = \PHPWS_Settings::get('properties', 'email');
\Error::log($ex);
$this->title = 'Sorry!';
$this->content = <<<EOF
<p>Your manager submission could not be processed. Please email <a href="mailto:{$address}">{$address}</a> to inform them of your problem.</p>
EOF;
$this->content .= $ex->getMessage();
return;
}
// success
$this->title = 'Thank you';
$this->content = <<<EOF
<p>We will review your manager application and email your confirmation.</p>
<p><a href="./">Return to the home page</a></p>
EOF;
}