本文整理汇总了PHP中Contact::addEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::addEmail方法的具体用法?PHP Contact::addEmail怎么用?PHP Contact::addEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::addEmail方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eventGetContacts
function eventGetContacts(EventControler $evtcl)
{
$plugType = 'email';
$provider_box = $evtcl->provider_box;
$email_box = $evtcl->email_box;
$password_box = $evtcl->password_box;
$msg = "";
$contacts = "";
$ok = false;
if (empty($email_box)) {
$msg = "Email missing !";
}
if (empty($password_box)) {
$msg = "Password missing !";
}
if (empty($provider_box)) {
$msg = "Provider missing !";
}
if ($msg == "") {
$inviter = new OpenInviter();
$inviter->startPlugin($provider_box);
$internal = $inviter->getInternalError();
if ($internal) {
$msg = $internal;
} elseif (!$inviter->login($email_box, $password_box)) {
$internal = $inviter->getInternalError();
$msg = $internal ? $internal : "Login failed. Please check the email and password you have provided and try again later !";
} elseif (false === ($contacts = $inviter->getMyContacts())) {
$msg = "Unable to get contacts !";
} else {
$msg = "Contacts imported successfully.";
$ok = true;
//$_POST['oi_session_id']=$inviter->plugin->getSessionID();
}
}
if ($ok) {
/*print_r($contacts);
exit();*/
foreach ($contacts as $email => $name) {
$do_contact = new Contact();
$do_contact->firstname = $name;
$do_contact->iduser = $_SESSION['do_User']->iduser;
$do_contact->add();
$lastInsertedContId = $do_contact->getPrimaryKeyValue();
$do_contact->addEmail($email, 'Home');
$do_contact->free();
//contact view
$do_cv = new ContactView();
$do_cv->idcontact = $lastInsertedContId;
$do_cv->firstname = $name;
$do_cv->email_address = $email;
$do_cv->add();
$do_cv->free();
}
}
$_SESSION['in_page_message'] = $msg;
}
示例2: 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);
//.........这里部分代码省略.........
示例3: 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();
//.........这里部分代码省略.........
示例4: create_user
function create_user($user_data, $permissionsString) {
// try to find contact by some properties
$contact_id = array_var($user_data, "contact_id") ;
$contact = Contacts::instance()->findById($contact_id) ;
if (!is_valid_email(array_var($user_data, 'email'))) {
throw new Exception(lang("email value is required"));
}
if (!$contact instanceof Contact) {
// Create a new user
$contact = new Contact();
$contact->setUsername(array_var($user_data, 'username'));
$contact->setDisplayName(array_var($user_data, 'display_name'));
$contact->setCompanyId(array_var($user_data, 'company_id'));
$contact->setUserType(array_var($user_data, 'type'));
$contact->setTimezone(array_var($user_data, 'timezone'));
$contact->setFirstname($contact->getObjectName() != "" ? $contact->getObjectName() : $contact->getUsername());
$contact->setObjectName();
} else {
// Create user from contact
$contact->setUserType(array_var($user_data, 'type'));
if (array_var($user_data, 'company_id')) {
$contact->setCompanyId(array_var($user_data, 'company_id'));
}
$contact->setUsername(array_var($user_data, 'username'));
$contact->setTimezone(array_var($user_data, 'timezone'));
}
$contact->save();
if (is_valid_email(array_var($user_data, 'email'))) {
$contact->addEmail(array_var($user_data, 'email'), 'personal', true);
}
//permissions
$permission_group = new PermissionGroup();
$permission_group->setName('User '.$contact->getId().' Personal');
$permission_group->setContactId($contact->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$contact->setPermissionGroupId($permission_group->getId());
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($contact->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
if ( can_manage_security(logged_user()) ) {
$sp = new SystemPermission();
$rol_permissions=SystemPermissions::getRolePermissions(array_var($user_data, 'type'));
foreach($rol_permissions as $pr){
$sp->setPermission($pr);
}
$sp->setPermissionGroupId($permission_group->getId());
$sp->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
$sp->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
$sp->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
$sp->setCanManageTime(array_var($user_data, 'can_manage_time'));
$sp->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
$sp->setCanManageDimensions(array_var($user_data, 'can_manage_dimensions'));
$sp->setCanManageDimensionMembers(array_var($user_data, 'can_manage_dimension_members'));
$sp->setCanManageTasks(array_var($user_data, 'can_manage_tasks'));
$sp->setCanTasksAssignee(array_var($user_data, 'can_task_assignee'));
$sp->setCanManageBilling(array_var($user_data, 'can_manage_billing'));
$sp->setCanViewBilling(array_var($user_data, 'can_view_billing'));
Hook::fire('add_user_permissions', $sp, $other_permissions);
if (!is_null($other_permissions) && is_array($other_permissions)) {
foreach ($other_permissions as $k => $v) {
$sp->setColumnValue($k, array_var($user_data, $k));
}
}
$sp->save();
if ($contact->isAdminGroup()) {
// allow all un all dimensions if new user is admin
$dimensions = Dimensions::findAll();
$permissions = array();
foreach ($dimensions as $dimension) {
if ($dimension->getDefinesPermissions()) {
$cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = ".$contact->getPermissionGroupId()." AND `dimension_id` = ".$dimension->getId()));
if (!$cdp instanceof ContactDimensionPermission) {
$cdp = new ContactDimensionPermission();
$cdp->setPermissionGroupId($contact->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();
foreach ($ots as $ot) {
//.........这里部分代码省略.........
示例5: 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) {
//.........这里部分代码省略.........
示例6: eventImportContactsFromCsv
//.........这里部分代码省略.........
$do_company->add();
$idcompany = $do_company->getPrimaryKeyValue();
$do_contact->idcompany = $idcompany;
$do_contact->iduser = $iduser;
$do_contact->firstname = $contact_firstname;
$do_contact->lastname = $contact_lastname;
$do_contact->company = $contact_company;
$do_contact->position = $contact_position;
$do_contact->summary = $contact_summary;
$do_contact->birthday = $contact_birthday;
$do_contact->add();
$idcontact = $do_contact->getPrimaryKeyValue();
//In theory this below should not be needed
$do_contact->idcontact = $idcontact;
$do_tag = new Tag();
if (strpos($_SESSION['import_tag'], ",") === false) {
$do_tag->addTagAssociation($idcontact, trim($_SESSION['import_tag']), "contact", $_SESSION['do_User']->iduser);
} else {
$tags = explode(",", $_SESSION['import_tag']);
foreach ($tags as $tag) {
$do_tag->addTagAssociation($idcontact, trim($tag), "contact", $_SESSION['do_User']->iduser);
}
}
if ($contact_address_hm != "" || $contact_city != "" || $contact_state != "" || $contact_street != "" || $contact_zipcode != "" || $contact_country != "") {
$do_contact->addAddress($contact_address_hm, $contact_address_hm_type, $contact_city, $contact_state, $contact_street, $contact_zipcode, $contact_country);
}
if ($contact_address_wk != "" || $contact_city != "" || $contact_state != "" || $contact_street != "" || $contact_zipcode != "" || $contact_country != "") {
$do_contact->addAddress($contact_address_wk, $contact_address_wk_type, $contact_city, $contact_state, $contact_street, $contact_zipcode, $contact_country);
}
if ($contact_address_ot != "" || $contact_city != "" || $contact_state != "" || $contact_street != "" || $contact_zipcode != "" || $contact_country != "") {
$do_contact->addAddress($contact_address_ot, $contact_address_ot_type, $contact_city, $contact_state, $contact_street, $contact_zipcode, $contact_country);
}
if ($contact_email_hm != "") {
$do_contact->addEmail($contact_email_hm, $contact_email_hm_type);
}
if ($contact_email_wk != "") {
$do_contact->addEmail($contact_email_wk, $contact_email_wk_type);
}
if ($contact_email_ot != "") {
$do_contact->addEmail($contact_email_ot, $contact_email_ot_type);
}
if ($contact_phone_hm != "") {
$do_contact->addPhone($contact_phone_hm, $contact_phone_hm_type);
}
if ($contact_phone_wk != "") {
$do_contact->addPhone($contact_phone_wk, $contact_phone_wk_type);
}
if ($contact_phone_ot != "") {
$do_contact->addPhone($contact_phone_ot, $contact_phone_ot_type);
}
if ($contact_phone_mb != "") {
$do_contact->addPhone($contact_phone_mb, $contact_phone_mb_type);
}
if ($contact_phone_fx != "") {
$do_contact->addPhone($contact_phone_fx, $contact_phone_fx_type);
}
if ($contact_website_comp != "") {
$do_contact->addWebsite($contact_website_comp, $contact_website_comp_type);
}
if ($contact_website_blog != "") {
$do_contact->addWebsite($contact_website_blog, $contact_website_blog_type);
}
if ($contact_website_ot != "") {
$do_contact->addWebsite($contact_website_ot, $contact_website_ot_type);
}
if ($contact_website_personal != "") {
示例7: MailContent
//.........这里部分代码省略.........
$body = utf8_safe($body);
if (array_var($mail_data,'format') == 'html') {
$body = preg_replace("/<body*[^>]*>/i",'<body>', $body);
$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()->getObjectName());
$mail->save();
$mail->setIsRead(logged_user()->getId(), true);
// autoclassify sent email
$member_ids = active_context_members(false);
if ($account->getMember() instanceof Member) {
$member_ids[] = $account->getMember()->getId();
}
// if replying a classified email classify on same workspace
if (array_var($mail_data, 'original_id') && user_config_option('classify_mail_with_conversation')) {
$in_reply_to = MailContents::findById(array_var($mail_data, 'original_id'));
if ($in_reply_to instanceof MailContent) {
$member_ids = array_merge($member_ids, $in_reply_to->getMemberIds());
}
}
$object_controller = new ObjectController();
if (count($member_ids) > 0) {
$object_controller->add_to_members($mail, $member_ids);
}
$object_controller->link_to_new_object($mail);
$object_controller->add_subscribers($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 = Objects::findObject($split_object[1]);
if ($object instanceof ContentDataObject){
$mail->linkObject($object);
}
}
}*/
ApplicationLogs::createLog($mail, 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->addEmail($recipient_address, 'personal');
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) {
Logger::log($e->getMessage());
}
}
}
}
$mail->addToSharingTable();
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
} // add_mail
示例8: Contact
function add_contact()
{
$do_api_contact = new Contact();
$do_Contact_View = new ContactView();
$do_api_contact->addNew();
$do_api_contact->firstname = $this->firstname;
$do_api_contact->lastname = $this->lastname;
$do_api_contact->position = $this->position;
$do_api_contact->iduser = $this->iduser;
if ($this->tags != '') {
$tags = explode(",", $this->tags);
}
if ($this->firstname == "" && $this->lastname == "") {
$this->setMessage("610", "First Name OR Last Name is Required");
return false;
} elseif (!$this->iduser) {
$this->setMessage("502", "The User Session is expired");
return false;
} elseif ($idcontact = $do_api_contact->duplicateContact($this->iduser, $this->email_work, $this->email_home, $this->email_other)) {
$this->setMessage("613", "The Contact is duplicated. Contact ID: " . $idcontact);
return false;
} else {
if ($this->company != "") {
$do_api_contact->company = $this->company;
$do_api_company = new Company();
$idcompany = $do_api_company->isDuplicateCompany($this->company, $this->iduser);
if (!$idcompany) {
$do_api_company->addNew();
$do_api_company->iduser = $this->iduser;
$do_api_company->name = trim($this->company);
$do_api_company->add();
$this->idcompany = $do_api_company->getPrimaryKeyValue();
} else {
$this->idcompany = $idcompany;
}
$do_api_contact->idcompany = $this->idcompany;
}
$do_api_contact->add();
$this->idcontact = $do_api_contact->getPrimaryKeyValue();
$do_api_contact->idcontact = $this->idcontact;
//child data starts here
// Phones
if ($this->phone_work != "") {
$do_api_contact->addPhone($this->phone_work, "Work");
}
if ($this->phone_home != "") {
$do_api_contact->addPhone($this->phone_home, "Home");
}
if ($this->mobile_number != "") {
$do_api_contact->addPhone($this->mobile_number, "Mobile");
}
if ($this->fax_number != "") {
$do_api_contact->addPhone($this->fax_number, "Fax");
}
if ($this->phone_other != "") {
$do_api_contact->addPhone($this->phone_other, "Other");
}
//emails
if ($this->email_work != "") {
$do_api_contact->addEmail($this->email_work, "Work");
}
if ($this->email_home != "") {
$do_api_contact->addEmail($this->email_home, "Home");
}
if ($this->email_other != "") {
$do_api_contact->addEmail($this->email_other, "Other");
}
//Website
if ($this->company_website != "") {
$do_api_contact->addWebsite($this->company_website, "Company");
}
if ($this->personal_website != "") {
$do_api_contact->addWebsite($this->personal_website, "Personal");
}
if ($this->blog_url != "") {
$do_api_contact->addWebsite($this->blog_url, "Blog");
}
if ($this->twitter_profile_url != "") {
$do_api_contact->addWebsite($this->twitter_profile_url, "Twitter");
}
if ($this->linkedin_profile_url != "") {
$do_api_contact->addWebsite($this->linkedin_profile_url, "LinkedIn");
}
if ($this->facebook_profile_url != "") {
$do_api_contact->addWebsite($this->facebook_profile_url, "Facebook");
}
// API V.02 will have IM and Address
//Add tags if any
if (is_array($tags)) {
$do_api_tags = new Tag();
foreach ($tags as $tag) {
$do_api_tags->addNew();
$do_api_tags->addTagAssociation($this->idcontact, $tag, "contact", $this->iduser);
}
}
// Ok here the last thing that needs to be done so that the contact should also on the table
$do_Contact_View = new ContactView();
$do_Contact_View->setUser($this->iduser);
$do_api_contact->getId($this->idcontact);
$do_Contact_View->addFromContact($do_api_contact);
//.........这里部分代码省略.........
示例9: insertContactEntry
/**
* inserting a contact entry into ofuz Database.
* @param array : contact details
* @return void
* @see class : Contact, Company
*/
function insertContactEntry($entry)
{
$id_company = $this->checkCompanyExists($entry['org_name']);
if ($id_company) {
$new_contact = new Contact();
$new_contact->company = $entry['org_name'];
$new_contact->firstname = $entry['title'];
$new_contact->idcompany = $id_company;
$new_contact->iduser = $this->id_user;
$new_contact->position = $entry['org_title'];
$new_contact->add();
$lastInsertedContId = $new_contact->getPrimaryKeyValue();
} else {
$new_company = new Company();
$new_company->name = $entry['org_name'];
$new_company->iduser = $this->id_user;
$new_company->add();
$new_company_id = $new_company->getPrimaryKeyValue();
$new_contact = new Contact();
$new_contact->company = $entry['org_name'];
$new_contact->firstname = $entry['title'];
$new_contact->idcompany = $new_company_id;
$new_contact->iduser = $this->id_user;
$new_contact->position = $entry['org_title'];
$new_contact->add();
$lastInsertedContId = $new_contact->getPrimaryKeyValue();
}
if ($entry['ph_mobile']) {
$new_contact->addPhone($entry['ph_mobile'], 'Mobile');
}
if ($entry['ph_home']) {
$new_contact->addPhone($entry['ph_home'], 'Home');
}
if ($entry['ph_work']) {
$new_contact->addPhone($entry['ph_work'], 'Work');
}
if ($entry['address_home']) {
$new_contact->addAddress($entry['address_home'], 'Home');
}
if ($entry['address_other']) {
$new_contact->addAddress($entry['address_other'], 'Other');
}
if ($entry['address_work']) {
$new_contact->addAddress($entry['address_work'], 'Work');
}
if ($entry['em_other']) {
$new_contact->addEmail($entry['em_other'], 'Other');
}
if ($entry['em_home']) {
$new_contact->addEmail($entry['em_home'], 'Home');
}
if ($entry['em_work']) {
$new_contact->addEmail($entry['em_work'], 'Work');
}
$q_ins_contact = new sqlQuery($this->getDbCon());
$sql_ins = "INSERT INTO\n google_contact_info(idcontact,iduser,entry_id,entry_link_edit,entry_link_self)\n VALUES(" . $lastInsertedContId . "," . $this->id_user . ",'" . $entry['id'] . "','" . $entry['link_edit'] . "','" . $entry['link_self'] . "')\n ";
$q_ins_contact->query($sql_ins);
}
示例10: create_user
function create_user($user_data, $permissionsString, $rp_permissions_data = array(), $save_permissions = true)
{
// try to find contact by some properties
$contact_id = array_var($user_data, "contact_id");
$contact = Contacts::instance()->findById($contact_id);
if (!is_valid_email(array_var($user_data, 'email'))) {
throw new Exception(lang("email value is required"));
}
if (!$contact instanceof Contact) {
// Create a new user
$contact = new Contact();
$contact->setUsername(array_var($user_data, 'username'));
$contact->setDisplayName(array_var($user_data, 'display_name'));
$contact->setCompanyId(array_var($user_data, 'company_id'));
$contact->setUserType(array_var($user_data, 'type'));
$contact->setTimezone(array_var($user_data, 'timezone'));
$contact->setFirstname($contact->getObjectName() != "" ? $contact->getObjectName() : $contact->getUsername());
$contact->setObjectName();
$user_from_contact = false;
} else {
// Create user from contact
$contact->setUserType(array_var($user_data, 'type'));
if (array_var($user_data, 'company_id')) {
$contact->setCompanyId(array_var($user_data, 'company_id'));
}
$contact->setUsername(array_var($user_data, 'username'));
$contact->setTimezone(array_var($user_data, 'timezone'));
$user_from_contact = true;
}
$contact->save();
if (is_valid_email(array_var($user_data, 'email'))) {
$user = Contacts::getByEmail(array_var($user_data, 'email'));
if (!$user) {
$contact->addEmail(array_var($user_data, 'email'), 'personal', true);
}
}
//permissions
$additional_name = "";
$tmp_pg = PermissionGroups::findOne(array('conditions' => "`name`='User " . $contact->getId() . " Personal'"));
if ($tmp_pg instanceof PermissionGroup) {
$additional_name = "_" . gen_id();
}
$permission_group = new PermissionGroup();
$permission_group->setName('User ' . $contact->getId() . $additional_name . ' Personal');
$permission_group->setContactId($contact->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$contact->setPermissionGroupId($permission_group->getId());
$null = null;
Hook::fire('on_create_user_perm_group', $permission_group, $null);
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($contact->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
if (can_manage_security(logged_user())) {
$sp = new SystemPermission();
if (!$user_from_contact) {
$rol_permissions = SystemPermissions::getRolePermissions(array_var($user_data, 'type'));
if (is_array($rol_permissions)) {
foreach ($rol_permissions as $pr) {
$sp->setPermission($pr);
}
}
}
$sp->setPermissionGroupId($permission_group->getId());
if (isset($user_data['can_manage_security'])) {
$sp->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
}
if (isset($user_data['can_manage_configuration'])) {
$sp->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
}
if (isset($user_data['can_manage_templates'])) {
$sp->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
}
if (isset($user_data['can_manage_time'])) {
$sp->setCanManageTime(array_var($user_data, 'can_manage_time'));
}
if (isset($user_data['can_add_mail_accounts'])) {
$sp->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
}
if (isset($user_data['can_manage_dimensions'])) {
$sp->setCanManageDimensions(array_var($user_data, 'can_manage_dimensions'));
}
if (isset($user_data['can_manage_dimension_members'])) {
$sp->setCanManageDimensionMembers(array_var($user_data, 'can_manage_dimension_members'));
}
if (isset($user_data['can_manage_tasks'])) {
$sp->setCanManageTasks(array_var($user_data, 'can_manage_tasks'));
}
if (isset($user_data['can_task_assignee'])) {
$sp->setCanTasksAssignee(array_var($user_data, 'can_task_assignee'));
}
if (isset($user_data['can_manage_billing'])) {
$sp->setCanManageBilling(array_var($user_data, 'can_manage_billing'));
}
if (isset($user_data['can_view_billing'])) {
$sp->setCanViewBilling(array_var($user_data, 'can_view_billing'));
}
if (isset($user_data['can_see_assigned_to_other_tasks'])) {
//.........这里部分代码省略.........
示例11: insertContact
function insertContact()
{
if ($this->contact['ORG']) {
$id_company = $this->checkCompanyExists($this->contact['ORG']);
$id_company_flag = $id_company ? true : false;
$flag = true;
} else {
$flag = true;
$id_company = 0;
$id_company_flag = true;
}
if ($flag) {
if ($id_company_flag) {
$new_contact = new Contact();
$new_contact->firstname = $this->contact['FULLNAME'];
$new_contact->position = $this->contact['TITLE'];
if ($this->contact['ORG']) {
$company = $this->contact['ORG'];
} else {
$company = "";
}
$new_contact->company = $company;
$new_contact->idcompany = $id_company;
$new_contact->iduser = $this->iduser;
$new_contact->birthday = $this->contact['BDAY'];
$new_contact->picture = $this->contact['PHOTO'];
$new_contact->add();
$lastInsertedContId = $new_contact->getPrimaryKeyValue();
} else {
$new_company = new Company();
$new_company->name = $this->contact['ORG'];
$new_company->iduser = $this->iduser;
$new_company->add();
$new_company_id = $new_company->getPrimaryKeyValue();
$new_contact = new Contact();
$new_contact->firstname = $this->contact['FULLNAME'];
$new_contact->position = $this->contact['TITLE'];
$new_contact->company = $this->contact['ORG'];
$new_contact->idcompany = $new_company_id;
$new_contact->iduser = $this->iduser;
$new_contact->birthday = $this->contact['BDAY'];
$new_contact->picture = $this->contact['PHOTO'];
$new_contact->add();
$lastInsertedContId = $new_contact->getPrimaryKeyValue();
}
if ($this->contact['TELL_WORK']) {
$new_contact->addPhone($this->contact['TELL_WORK'], 'Work');
}
if ($this->contact['TELL_HOME']) {
$new_contact->addPhone($this->contact['TELL_HOME'], 'Home');
}
if ($this->contact['TELL_FAX']) {
$new_contact->addPhone($this->contact['TELL_FAX'], 'Fax');
}
if ($this->contact['TELL_CELL']) {
$new_contact->addPhone($this->contact['TELL_CELL'], 'Mobile');
}
if ($this->contact['TELL_OTHER']) {
$new_contact->addPhone($this->contact['TELL_OTHER'], 'Other');
}
if ($this->contact['ADR_WORK']) {
$new_contact->addAddress($this->contact['ADR_WORK'], 'Work');
}
if ($this->contact['ADR_HOME']) {
$new_contact->addAddress($this->contact['ADR_HOME'], 'Home');
}
if ($this->contact['ADR_OTHER']) {
$new_contact->addAddress($this->contact['ADR_OTHER'], 'Other');
}
if ($this->contact['EMAIL_WORK']) {
$new_contact->addEmail($this->contact['EMAIL_WORK'], 'Work');
}
if ($this->contact['EMAIL_HOME']) {
$new_contact->addEmail($this->contact['EMAIL_HOME'], 'Home');
}
if ($this->contact['EMAIL_OTHER']) {
$new_contact->addEmail($this->contact['EMAIL_OTHER'], 'Other');
}
$do_tag = new Tag();
if ($this->contact['CATEGORIES']) {
$contact_tag = explode(",", $this->contact['CATEGORIES']);
$arr_import_tags = explode(",", $_SESSION['import_tag']);
foreach ($arr_import_tags as $imp_tag) {
array_push($contact_tag, $imp_tag);
}
foreach ($contact_tag as $tag) {
$tag = trim($tag);
$do_tag->addTagAssociation($lastInsertedContId, $tag, "contact", $this->iduser);
}
} else {
$arr_import_tags = explode(",", $_SESSION['import_tag']);
foreach ($arr_import_tags as $tag) {
$tag = trim($tag);
$do_tag->addTagAssociation($lastInsertedContId, $tag, "contact", $this->iduser);
}
}
$do_cont_view = new ContactView();
$do_cont_view->addFromContact($new_contact);
$do_cont_view->updateFromContact($new_contact);
// Added the method call updateFromContact() so that the child data is updated just after insert
//.........这里部分代码省略.........
示例12: addUserAsContact
/**
* Method adding user as Contact
* @param $firstname -- STRING
* @param $lastname -- STRING
* @param $company -- STRING
* @param $email -- STRING
* @param $iduser -- INT
* FIXME May be no need to rebuilt the contact view but to enter an entry which is faster
*/
function addUserAsContact($firstname, $lastname, $company, $email, $iduser)
{
$idcompany = "";
if ($company != "") {
$do_company = new Company();
$idcompany = $do_company->addNewCompany($company, $iduser);
}
$do_contact = new Contact();
$do_contact->firstname = $firstname;
$do_contact->lastname = $lastname;
$do_contact->iduser = $iduser;
$do_contact->idcompany = $idcompany;
$do_contact->company = $company;
$do_contact->add();
$do_contact->addEmail($email, 'Home');
$lastInsertedContId = $do_contact->getPrimaryKeyValue();
//$this->setRegistry(false);
$this->getId($iduser);
$this->idcontact = $lastInsertedContId;
$this->update();
$contact_view = new ContactView();
$contact_view->setUser($iduser);
//$this->setRegistry(false);
$contact_view->rebuildContactUserTable();
}