本文整理汇总了PHP中Contact::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::add方法的具体用法?PHP Contact::add怎么用?PHP Contact::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postContact
public function postContact()
{
global $smarty, $cookie;
session_start();
if ($_SESSION['validate_code'] == strtolower(Tools::getRequest('validate_code'))) {
if ($cookie->isLogged()) {
$user = new User($cookie->id_user);
$_POST['name'] = $user->first_name . ' ' . $user->last_name;
$_POST['email'] = $user->email;
if (isset($_POST['id_user'])) {
unset($_POST['id_user']);
}
$_POST['id_user'] = $user->id;
}
$contact = new Contact();
$contact->copyFromPost();
if ($contact->add()) {
$vars = array('{name}' => $contact->name, '{subject}' => $contact->subject, '{email}' => $contact->email, '{message}' => $contact->content);
Mail::Send('contact', $contact->subject, $vars, Configuration::get('TM_SHOP_EMAIL'));
$this->_success = 'Your message has been successfully sent to our team.';
} else {
$this->_errors = $contact->_errors;
}
} else {
$this->_errors[] = 'Confirmation code is error!';
}
}
示例2: 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;
}
示例3: contactAction
public function contactAction()
{
$data = $this->data;
if ($this->getProductsData()) {
$input = $this->getProductsData();
$captcha = md5($input['captcha']);
if ($captcha == $this->app['session']->get('captcha_hash', 'null')) {
$getData = array('name' => strip_tags($input['txtName']), 'address' => strip_tags($input['txtAdd']), 'phone' => $input['txtPhone'], 'email' => strip_tags($input['txtEmail']), 'title' => strip_tags($input['txtTitle']), 'content' => $input['txtContent'], 'status' => '1');
if (Contact::add($getData) == true) {
$this->app['session']->getFlashBag()->add('message', 'Success');
return $this->redirect('contact');
} else {
$data['notification'] = 'Erro';
}
} else {
$data['notification'] = 'Erro';
}
}
//var_dump($data['lang']);die();
return $this->render('default/Products/contact.html.twig', $data);
}
示例4: testContact_Supplier
/**
* Check right on CommonDBRelation object
*/
public function testContact_Supplier()
{
global $DB;
$DB->connect();
$ent0 = $this->sharedFixture['entity'][0];
$ent1 = $this->sharedFixture['entity'][1];
$ent2 = $this->sharedFixture['entity'][2];
// Super admin
Session::changeProfile(4);
$this->assertEquals(4, $_SESSION['glpiactiveprofile']['id']);
$this->assertEquals(31, $_SESSION['glpiactiveprofile']['contact_enterprise']);
// See all
$this->assertTrue(Session::changeActiveEntities("all"));
// Create some contacts
$contact = new Contact();
$idc[0] = $contact->add(array('name' => "Contact 1", 'entities_id' => $ent0, 'is_recursive' => 0));
$this->assertGreaterThan(0, $idc[0]);
$idc[1] = $contact->add(array('name' => "Contact 2", 'entities_id' => $ent0, 'is_recursive' => 1));
$this->assertGreaterThan(0, $idc[1]);
$idc[2] = $contact->add(array('name' => "Contact 3", 'entities_id' => $ent1, 'is_recursive' => 1));
$this->assertGreaterThan(0, $idc[2]);
$idc[3] = $contact->add(array('name' => "Contact 4", 'entities_id' => $ent2));
$this->assertGreaterThan(0, $idc[3]);
// Create some suppliers
$supplier = new Supplier();
$ids[0] = $supplier->add(array('name' => "Supplier 1", 'entities_id' => $ent0, 'is_recursive' => 0));
$this->assertGreaterThan(0, $ids[0]);
$ids[1] = $supplier->add(array('name' => "Supplier 2", 'entities_id' => $ent0, 'is_recursive' => 1));
$this->assertGreaterThan(0, $ids[1]);
$ids[2] = $supplier->add(array('name' => "Supplier 3", 'entities_id' => $ent1));
$this->assertGreaterThan(0, $ids[2]);
$ids[3] = $supplier->add(array('name' => "Supplier 4", 'entities_id' => $ent2));
$this->assertGreaterThan(0, $ids[3]);
// Relation
$rel = new Contact_Supplier();
$input = array('contacts_id' => $idc[0], 'suppliers_id' => $ids[0]);
// root
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[0] = $rel->add($input);
$this->assertGreaterThan(0, $idr[0]);
$this->assertTrue($rel->can($idr[0], READ));
$this->assertTrue($rel->canEdit($idr[0]));
$input = array('contacts_id' => $idc[0], 'suppliers_id' => $ids[1]);
// root + rec
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[1] = $rel->add($input);
$this->assertGreaterThan(0, $idr[1]);
$this->assertTrue($rel->can($idr[1], READ));
$this->assertTrue($rel->canEdit($idr[1]));
$input = array('contacts_id' => $idc[0], 'suppliers_id' => $ids[2]);
// child 1
$this->assertFalse($rel->can(-1, CREATE, $input));
$input = array('contacts_id' => $idc[0], 'suppliers_id' => $ids[3]);
// child 2
$this->assertFalse($rel->can(-1, CREATE, $input));
$input = array('contacts_id' => $idc[1], 'suppliers_id' => $ids[0]);
// root
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[2] = $rel->add($input);
$this->assertGreaterThan(0, $idr[2]);
$this->assertTrue($rel->can($idr[2], READ));
$this->assertTrue($rel->canEdit($idr[2]));
$input = array('contacts_id' => $idc[1], 'suppliers_id' => $ids[1]);
// root + rec
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[3] = $rel->add($input);
$this->assertGreaterThan(0, $idr[3]);
$this->assertTrue($rel->can($idr[3], READ));
$this->assertTrue($rel->canEdit($idr[3]));
$input = array('contacts_id' => $idc[1], 'suppliers_id' => $ids[2]);
// child 1
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[4] = $rel->add($input);
$this->assertGreaterThan(0, $idr[4]);
$this->assertTrue($rel->can($idr[4], READ));
$this->assertTrue($rel->canEdit($idr[4]));
$input = array('contacts_id' => $idc[1], 'suppliers_id' => $ids[3]);
// child 2
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[5] = $rel->add($input);
$this->assertGreaterThan(0, $idr[5]);
$this->assertTrue($rel->can($idr[5], READ));
$this->assertTrue($rel->canEdit($idr[5]));
$input = array('contacts_id' => $idc[2], 'suppliers_id' => $ids[0]);
// root
$this->assertFalse($rel->can(-1, CREATE, $input));
$input = array('contacts_id' => $idc[2], 'suppliers_id' => $ids[1]);
// root + rec
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[6] = $rel->add($input);
$this->assertGreaterThan(0, $idr[6]);
$this->assertTrue($rel->can($idr[6], READ));
$this->assertTrue($rel->canEdit($idr[6]));
$input = array('contacts_id' => $idc[2], 'suppliers_id' => $ids[2]);
// Child 1
$this->assertTrue($rel->can(-1, CREATE, $input));
$idr[7] = $rel->add($input);
//.........这里部分代码省略.........
示例5: Contact
</div>-->
</div><br />
<?php
$do_contact = new Contact();
$do_np_contact = new Contact();
if (!empty($_SESSION['do_User']->idcontact) && $_SESSION['do_User']->idcontact != 0) {
$idcontact = $_SESSION['do_User']->idcontact;
$do_contact->getId($_SESSION['do_User']->idcontact);
} else {
// Add a new contact and update the idcontact to the user table for the user
$do_contact->addNew();
$do_contact->firstname = $_SESSION['do_User']->firstname;
$do_contact->lastname = $_SESSION['do_User']->lastname;
$do_contact->iduser = $_SESSION['do_User']->iduser;
$do_contact->add();
$idcontact_inserted = $do_contact->getPrimaryKeyValue();
$do_contact_view = new ContactView();
$_SESSION['do_User']->idcontact = $idcontact_inserted;
$do_contact->getId($idcontact_inserted);
}
$_SESSION['edit_from_page'] = 'settings_myinfo.php';
$do_contact->sessionPersistent("ContactEditSave", "contact.php", OFUZ_TTL);
//$do_contact->sessionPersistent("ContactEditSave", "index.php", 120);
//$do_np_contact->sessionPersistent("ContactPictureSave", "index.php", 120);
$do_np_contact->sessionPersistent("ContactPictureSave", "index.php", OFUZ_TTL);
$_SESSION['ContactPictureSave']->getId($idcontact);
$e_fullContact = new Event("ContactPictureSave->eventValuesFromForm");
$e_fullContact->setLevel(1999);
$e_fullContact->setGotFile(true);
$e_fullContact->addEventAction("ContactPictureSave->update", 2000);
示例6: eventImportContactsFromCsv
function eventImportContactsFromCsv(EventControler $eventcontroler)
{
$iduser = $eventcontroler->iduser;
$handle = fopen($eventcontroler->targetpath, "r");
$row = 1;
while ($data = fgetcsv($handle)) {
$contact_firstname = "";
$contact_lastname = "";
$contact_company = "";
$company = "";
$contact_position = "";
$contact_summary = "";
$contact_birthday = "";
$contact_city = "";
$contact_state = "";
$contact_street = "";
$contact_zipcode = "";
$contact_country = "";
$contact_address_hm = "";
$contact_address_hm_type = "";
$contact_address_wk = "";
$contact_address_wk_type = "";
$contact_address_ot = "";
$contact_address_ot_type = "";
$contact_email_hm = "";
$contact_email_hm_type = "";
$contact_email_wk = "";
$contact_email_wk_type = "";
$contact_email_ot = "";
$contact_email_ot_type = "";
$contact_phone_hm = "";
$contact_phone_hm_type = "";
$contact_phone_wk = "";
$contact_phone_wk_type = "";
$contact_phone_ot = "";
$contact_phone_ot_type = "";
$contact_phone_mb = "";
$contact_phone_mb_type = "";
$contact_phone_fx = "";
$contact_phone_fx_type = "";
$contact_website_comp = "";
$contact_website_comp_type = "";
$contact_website_blog = "";
$contact_website_blog_type = "";
$contact_website_ot = "";
$contact_website_ot_type = "";
$contact_website_personal = "";
$contact_website_personal_type = "";
$contact_website_twitter = "";
$contact_website_twitter_type = "";
$contact_im_aim_wk = "";
$contact_im_aim_wk_type = "";
$contact_im_aim_per = "";
$contact_im_aim_per_type = "";
$contact_im_aim_ot = "";
$contact_im_aim_ot_type = "";
$im_aim = "";
$contact_im_msn_wk = "";
$contact_im_msn_wk_type = "";
$contact_im_msn_per = "";
$contact_im_msn_per_type = "";
$contact_im_msn_ot = "";
$contact_im_msn_ot_type = "";
$im_msn = "";
$contact_im_icq_wk = "";
$contact_im_icq_wk_type = "";
$contact_im_icq_per = "";
$contact_im_icq_per_type = "";
$contact_im_icq_ot = "";
$contact_im_icq_ot_type = "";
$im_icq = "";
$contact_im_jabber_wk = "";
$contact_im_jabber_wk_type = "";
$contact_im_jabber_per = "";
$contact_im_jabber_per_type = "";
$contact_im_jabber_ot = "";
$contact_im_jabber_ot_type = "";
$im_jabber = "";
$contact_im_yahoo_wk = "";
$contact_im_yahoo_wk_type = "";
$contact_im_yahoo_per = "";
$contact_im_yahoo_per_type = "";
$contact_im_yahoo_ot = "";
$contact_im_yahoo_ot_type = "";
$im_yahoo = "";
$contact_im_skype_wk = "";
$contact_im_skype_wk_type = "";
$contact_im_skype_per = "";
$contact_im_skype_per_type = "";
$contact_im_skype_ot = "";
$contact_im_skype_ot_type = "";
$im_skype = "";
$contact_im_gt_wk = "";
$contact_im_gt_wk_type = "";
$contact_im_gt_per = "";
$contact_im_gt_per_type = "";
$contact_im_gt_ot = "";
$contact_im_gt_ot_type = "";
$im_gt = "";
$contact_note = "";
//.........这里部分代码省略.........
示例7: Contact
<?php
if (Tools::P('content')) {
$contact = new Contact();
$contact->copyFromPost();
if ($contact->add()) {
$c = new Contact(Tools::getRequest('id_parent'));
$c->active = 1;
$c->update();
$vars = array('{name}' => $cookie->name, '{subject}' => $contact->subject, '{message}' => $contact->content);
Mail::Send('replay', $c->subject, $vars, $c->email);
if ($c->id_user > 0) {
Alert::Send($c->id_user, $contact->content);
}
}
if (is_array($contact->_errors) and count($contact->_errors) > 0) {
$errors = $contact->_errors;
} else {
echo '<div class="conf">回复成功</div>';
}
}
if (isset($_GET['id'])) {
$id = (int) $_GET['id'];
$obj = new Contact($id);
$subs = $obj->getSubMessage();
if ($obj->id_user > 0) {
$userAllContact = $obj->getContactByUser();
}
}
if (isset($errors)) {
UIAdminAlerts::MError($errors);
示例8: importTwitterFriend
/**
* Import a Twitter friend
*/
function importTwitterFriend($friend_data, $extra_tag = '')
{
$iduser = $_SESSION['do_User']->iduser;
$tw_user_id = $friend_data['user_id'];
$idcontact = $this->isTwFriendInContacts($iduser, $tw_user_id);
list($fname, $lname) = explode(' ', $friend_data['name'], 2);
$screen_name = $friend_data['screen_name'];
$description = $friend_data['description'];
$profile_image_url = $friend_data['profile_image_url'];
$url = $friend_data['url'];
$do_tag = new Tag();
if ($idcontact) {
//update the data
$c = new Contact();
$c->getId($idcontact);
$c->firstname = $fname;
$c->lastname = $lname;
if ($c->picture == "") {
$c->picture = $profile_image_url;
}
$c->tw_user_id = $tw_user_id;
$c->update();
$do_tag->addTagAssociation($idcontact, 'Twitter', 'contact', $iduser);
if ($extra_tag != '') {
$do_tag->addTagAssociation($idcontact, $extra_tag, 'contact', $iduser);
}
} else {
// new entry
$c = new Contact();
$c->firstname = $fname;
$c->lastname = $lname;
$c->iduser = $iduser;
$c->picture = $profile_image_url;
$c->tw_user_id = $tw_user_id;
$c->add();
$idcontact = $c->idcontact;
$w = new ContactWebsite();
$w->idcontact = $idcontact;
$w->website = 'http://twitter.com/' . $screen_name;
$w->website_type = 'Twitter';
$w->feed_auto_fetch = 'Yes';
$w->add();
if ($url != '') {
$w = new ContactWebsite();
$w->idcontact = $idcontact;
$w->website = $url;
$w->website_type = 'Personal';
$w->add();
}
$link = '<br /><a href="http://twitter.com/' . $screen_name . '" target="_blank">Back to the Source of the Article</a><br />';
$do_contact_note = new ContactNotes();
$do_contact_note->idcontact = $idcontact;
$do_contact_note->note = $description . $link;
$do_contact_note->date_added = date('Y-m-d');
$do_contact_note->iduser = $iduser;
$do_contact_note->add();
$do_tag->addTagAssociation($idcontact, 'Twitter', 'contact', $iduser);
if ($extra_tag != '') {
$do_tag->addTagAssociation($idcontact, $extra_tag, 'contact', $iduser);
}
}
}
示例9: generate_entity
/** Generate bigdump : generate items for an entity
*
* @param $ID_entity entity ID
**/
function generate_entity($ID_entity) {
global $MAX, $DB, $percent, $FIRST, $LAST, $MAX_KBITEMS_BY_CAT, $MAX_DISK,
$DOCUMENTS, $NET_PORT, $NET_LOC;
regenerateTreeCompleteName("glpi_entities");
$current_year = date("Y");
// DOMAIN
$items = array("SP2MI", "CAMPUS"," IUT86", "PRESIDENCE", "CEAT", "D'omaine");
$dp = new Domain();
$FIRST["domain"] = getMaxItem("glpi_domains")+1;
for ($i=0 ; $i<$MAX['domain'] ; $i++) {
if (isset($items[$i])) {
$val = $items[$i];
} else {
$val = "domain $ID_entity '$i";
}
$dp->add(toolbox::addslashes_deep(array('name' => $val,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'comment' => "comment $val")));
}
$LAST["domain"] = getMaxItem("glpi_domains");
// STATUS
$items = array("Reparation", "En stock", "En fonction", "Retour SAV", "En attente d'");
$dp = new State();
$FIRST["state"] = getMaxItem("glpi_states")+1;
for ($i=0 ; $i<$MAX['state'] ; $i++) {
if (isset($items[$i])) {
$val = $items[$i];
} else {
$val = "State $ID_entity '$i";
}
$state_id = $dp->add(toolbox::addslashes_deep(array('name' => $val,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'comment' => "comment $val")));
// generate sub status
for ($j=0 ; $j<$MAX['state'] ; $j++) {
$val2 = "Sub $val $j";
$dp->add(toolbox::addslashes_deep(array('name' => $val2,
'entities_id' => $ID_entity,
'is_recursive' => 1,
'states_id' => $state_id,
'comment' => "comment $val")));
}
}
$LAST["state"] = getMaxItem("glpi_states");
// glpi_groups
$FIRST["groups"] = getMaxItem("glpi_groups")+1;
$group = new Group();
for ($i=0 ; $i<$MAX['groups'] ; $i++) {
$gID = $group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_entity,
'name' => "group d'$i",
'comment' => "comment group d'$i",
'is_assign' => 0)));
// Generate sub group
for ($j=0 ; $j<$MAX['groups'] ; $j++) {
$group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_entity,
'name' => "subgroup d'$j",
'comment' => "comment subgroup d'$j of group $i",
'groups_id' => $gID,
'is_assign' => 0)));
}
}
$LAST["groups"] = getMaxItem("glpi_groups");
$FIRST["techgroups"] = $LAST["groups"]+1;
for ($i=0 ; $i<$MAX['groups'] ; $i++) {
$group->add(toolbox::addslashes_deep(
array('entities_id' => $ID_entity,
'name' => "tech group d'$i",
'comment' => "comment tech group d'$i")));
}
$LAST["techgroups"] = getMaxItem("glpi_groups");
regenerateTreeCompleteName("glpi_groups");
// glpi_users
$FIRST["users_sadmin"] = getMaxItem("glpi_users")+1;
//.........这里部分代码省略.........
示例10: addInvoice
/**
* Custom add method to add an invoice. Needs a contact for each invocie else
* do not add the invoice
* @param $evtcl -- Object
*/
function addInvoice(EventControler $evtcl)
{
$_SESSION['in_page_message'] = '';
$rec_value = $evtcl->recurrent;
$add_invoice = false;
$do_contact = new Contact();
$concat_name_in_address = '';
if ($evtcl->fields["due_date"] == '') {
$this->due_date = date('Y-m-d');
} else {
$this->due_date = $evtcl->fields["due_date"];
}
if ($evtcl->idcontact) {
$idcontact = $evtcl->idcontact;
$add_invoice = true;
$do_contact->getId($idcontact);
} else {
$cont_name = $evtcl->contact;
if ($cont_name != '') {
$do_Contact_View = new ContactView();
$do_contact->addNew();
$do_contact->firstname = $cont_name;
$do_contact->iduser = $_SESSION['do_User']->iduser;
$do_contact->add();
$idcontact = $do_contact->getPrimaryKeyValue();
$do_Contact_View->setUser($_SESSION['do_User']->iduser);
$do_contact->getId($idcontact);
$concat_name_in_address = $do_contact->firstname;
$do_Contact_View->addFromContact($do_contact);
$do_Contact_View->updateFromContact($do_contact);
if ($idcontact) {
$add_invoice = true;
$do_cont_addr = new ContactAddress();
$do_cont_addr->addNew();
$do_cont_addr->idcontact = $idcontact;
$do_cont_addr->address = $evtcl->fields["invoice_address"];
$do_cont_addr->address_type = 'Work';
if (strlen($evtcl->fields["invoice_address"]) > 0) {
$do_cont_addr->add();
}
}
}
}
if ($add_invoice) {
// Keep the idcontact in case there is an idcompany
if ($do_contact->idcompany != '' && !empty($do_contact->idcompany)) {
$this->idcompany = $do_contact->idcompany;
}
//$this->num = $this->getUniqueInvoiceNum();
$this->num = time();
$this->iduser = $_SESSION['do_User']->iduser;
$this->idterms = $evtcl->fields["idterms"];
$this->description = $evtcl->fields["description"];
$this->discount = $evtcl->fields["discount"];
$this->tax = $evtcl->fields["tax"];
$this->datecreated = date("Y-m-d");
$this->idcontact = $idcontact;
$this->status = 'Quote';
$this->invoice_note = $evtcl->fields["invoice_note"];
$this->invoice_term = $evtcl->fields["invoice_term"];
if ($concat_name_in_address == '') {
$this->invoice_address = $evtcl->fields["invoice_address"];
} else {
$this->invoice_address = $concat_name_in_address . '<br />' . $evtcl->fields["invoice_address"];
}
$this->add();
$this->idinvoice = $this->getPrimaryKeyValue();
// If the user set to have the ivoice added as recurrent Invoice then add
if ($evtcl->setRec == 'Yes') {
if (!empty($rec_value) && preg_match('/^[0-9]+$/', $rec_value) && $rec_value != 0) {
// Add to recurrent
$_SESSION['RecurrentInvoice']->addRecurrentInvoice($this->getPrimaryKeyValue(), $evtcl->recurrent, $evtcl->frequency, date("Y-m-d"));
} else {
$_SESSION['in_page_message'] = _("Recurrent Value is not correct.To set as Recurrent edit the invoice and enter numeric value");
}
}
} else {
$_SESSION['in_page_message'] = _("Invoice could be created. Possible reason Contact Missing.");
$evtcl->setDisplayNext(new Display('invoices.php'));
}
}
示例11: catch
} catch (Exception $e) {
$disp = new Display("user_login.php");
$disp->addParam("message", "Error with your user record, please sign-in again");
//$disp->addParam("entry", $_SERVER['REQUEST_URI']);
$_SESSION['entry'] = $_SERVER['REQUEST_URI'];
header("Location: /" . $disp->getUrl());
}
}
}
if ($_SESSION['hcard_idcontact'] != '') {
$do_add_cont = new Contact();
$do_add_cont->addNew();
$do_add_cont->firstname = $_SESSION['do_contact']->firstname;
$do_add_cont->lastname = $_SESSION['do_contact']->lastname;
$do_add_cont->iduser = $_SESSION['do_User']->iduser;
$do_add_cont->add();
$idcontact_inserted = $do_add_cont->getPrimaryKeyValue();
$ContactPhone = $_SESSION['do_contact']->getChildContactPhone();
$ContactPhoneAdd = new ContactPhone();
if ($ContactPhone->getNumRows()) {
while ($ContactPhone->next()) {
$ContactPhoneAdd->addNew();
$ContactPhoneAdd->idcontact = $idcontact_inserted;
$ContactPhoneAdd->phone_type = $ContactPhone->phone_type;
$ContactPhoneAdd->phone_number = $ContactPhone->phone_number;
$ContactPhoneAdd->add();
}
}
$ContactEmail = $_SESSION['do_contact']->getChildContactEmail();
$ContactEmailAdd = new ContactEmail();
if ($ContactEmail->getNumRows()) {
示例12: eventImportAccount
function eventImportAccount(EventControler $evtcl)
{
$msg = "";
$uploaded_file = $_FILES['fields']['name']['import_account'];
$target_path = 'files/' . $uploaded_file;
if (!move_uploaded_file($_FILES['fields']['tmp_name']['import_account'], $target_path)) {
$msg = "There was an error uploading the file, please try again!";
} else {
chmod($target_path, 0755);
if (file_exists($target_path)) {
//$xml = simplexml_load_file($_SERVER['DOCUMENT_ROOT']."/".$target_path);
$str_xml = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $target_path);
$str_xml = preg_replace('/[^(\\x20-\\x7F)]*/', '', $str_xml);
$xml = simplexml_load_string($str_xml);
echo '<pre>';
print_r($xml);
echo '</pre>';
die;
if ($xml !== FALSE) {
$c_cnt = count($xml->contact);
if ($c_cnt) {
for ($i = 0; $i < $c_cnt; $i++) {
$do_contact = new Contact();
$contact = $xml->contact[$i];
$do_contact->firstname = $contact->firstname;
$do_contact->lastname = $contact->lastname;
$do_contact->position = $contact->position;
$do_contact->company = $contact->company;
$do_contact->idcompany = $contact->idcompany;
$do_contact->iduser = $_SESSION['do_User']->iduser;
$do_contact->picture = $contact->picture;
$do_contact->summary = $contact->summary;
$do_contact->birthday = $contact->birthday;
$do_contact->portal_code = $contact->portal_code;
$do_contact->fb_userid = $contact->fb_userid;
$do_contact->tw_user_id = $contact->tw_user_id;
$do_contact->email_optout = $contact->email_optout;
$do_contact->add();
$lastInsertedContId = $do_contact->getPrimaryKeyValue();
/**
*Contact Address
*/
$ca_cnt = count($contact->contact_address);
if ($ca_cnt) {
for ($ca_cnt_i = 0; $ca_cnt_i < $ca_cnt; $ca_cnt_i++) {
$do_contact_address = new ContactAddress();
$contact_address = $contact->contact_address[$ca_cnt_i];
$do_contact_address->city = $contact_address->city;
$do_contact_address->country = $contact_address->country;
$do_contact_address->state = $contact_address->state;
$do_contact_address->street = $contact_address->street;
$do_contact_address->zipcode = $contact_address->zipcode;
$do_contact_address->idcontact = $lastInsertedContId;
$do_contact_address->address = $contact_address->address;
$do_contact_address->address_type = $contact_address->address_type;
$do_contact_address->add();
$do_contact_address->free();
}
}
/**
*Contact Email
*/
$ce_cnt = count($contact->contact_email);
if ($ce_cnt) {
for ($ce_cnt_i = 0; $ce_cnt_i < $ce_cnt; $ce_cnt_i++) {
$do_contact_email = new ContactEmail();
$contact_email = $contact->contact_email[$ce_cnt_i];
$do_contact_email->idcontact = $lastInsertedContId;
$do_contact_email->email_address = $contact_email->email_address;
$do_contact_email->email_type = $contact_email->email_type;
$do_contact_email->email_isdefault = $contact_email->email_isdefault;
$do_contact_email->add();
$do_contact_email->free();
}
}
/**
*Contact Phone
*/
$cp_cnt = count($contact->contact_phone);
if ($cp_cnt) {
for ($cp_cnt_i = 0; $cp_cnt_i < $cp_cnt; $cp_cnt_i++) {
$do_contact_phone = new ContactPhone();
$contact_phone = $contact->contact_phone[$cp_cnt_i];
$do_contact_phone->phone_number = $contact_phone->phone_number;
$do_contact_phone->phone_type = $contact_phone->phone_type;
$do_contact_phone->idcontact = $lastInsertedContId;
$do_contact_phone->add();
$do_contact_phone->free();
}
}
/**
*Contact Note
*/
$cn_cnt = count($contact->contact_note);
if ($cn_cnt) {
for ($cn_cnt_i = 0; $cn_cnt_i < $cn_cnt; $cn_cnt_i++) {
$do_contact_note = new ContactNotes();
$contact_note = $contact->contact_note[$cn_cnt_i];
$do_contact_note->idcontact = $lastInsertedContId;
$do_contact_note->note = $contact_note->note;
//.........这里部分代码省略.........
示例13: 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();
}
示例14: importContacts
protected function importContacts()
{
$this->truncateTables(array('contact', 'contact_lang', 'contact_shop'));
$handle = $this->openCsvFile('contacts.csv');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
$res = false;
$fields = $this->filterFields('Contact', $this->contacts_fields, $line);
if (!isset($fields['id'])) {
$contact = new Contact($line[0]);
$contact->id = $line[0];
} else {
$contact = new Contact($fields['id']);
}
foreach ($fields as $key => $field) {
if ($key == 'name' || $key == 'description') {
$contact->{$key} = $this->multilFild($field);
} else {
$contact->{$key} = $field;
}
}
$contact->force_id = true;
if (!$res) {
$res = $contact->add();
}
}
$this->closeCsvFile($handle);
return true;
}
示例15: ldap_storeDetails
//.........这里部分代码省略.........
$usertype = LDAP_USERTYPE_MANAGER;
debug_log("MANAGER", TRUE);
} elseif (ldap_count_entries($ldap_conn, ldap_search($ldap_conn, $CONFIG['ldap_user_group'], $filter))) {
$usertype = LDAP_USERTYPE_USER;
debug_log("USER", TRUE);
} else {
debug_log("INVALID USER", TRUE);
}
} else {
// get back customer group
$result = ldap_search($ldap_conn, $CONFIG['ldap_customer_group'], $filter);
if (ldap_count_entries($ldap_conn, $result)) {
$usertype = LDAP_USERTYPE_CUSTOMER;
debug_log("CUSTOMER", TRUE);
} else {
debug_log("INVALID CUSTOMER", TRUE);
}
}
}
if ($usertype != LDAP_INVALID_USER and $user) {
// get attributes
$user = new User();
$user->username = $user_attributes[$CONFIG['ldap_userattribute']][0];
if ($CONFIG['ldap_cache_passwords']) {
$user->password = $password;
}
$user->realname = $user_attributes[$CONFIG['ldap_realname']][0];
$user->jobtitle = $user_attributes[$CONFIG['ldap_jobtitle']][0];
$user->email = $user_attributes[$CONFIG['ldap_email']][0];
$user->phone = $user_attributes[$CONFIG['ldap_telephone']][0];
$user->mobile = $user_attributes[$CONFIG['ldap_mobile']][0];
$user->fax = $user_attributes[$CONFIG['ldap_fax']][0];
$user->message = $user_attributes[$CONFIG['ldap_description']][0];
$user->holiday_entitlement = $CONFIG['default_entitlement'];
$user->source = 'ldap';
// TODO FIXME this doesn't take into account custom roles'
switch ($usertype) {
case LDAP_USERTYPE_ADMIN:
$user->roleid = 1;
break;
case LDAP_USERTYPE_MANAGER:
$user->roleid = 2;
break;
default:
$user->roleid = 3;
}
if ($id == 0) {
$user->status = $CONFIG['ldap_default_user_status'];
$status = $user->add();
} else {
// Modify
$user->id = $id;
$status = $user->edit();
}
if ($status) {
$toReturn = true;
} else {
$toReturn = false;
}
} elseif ($usertype == LDAP_USERTYPE_CUSTOMER and !$user) {
// Contact
debug_log("Adding contact TYPE {$usertype} USER {$user}", TRUE);
debug_log("User attributes: " . print_r($user_attributes, TRUE), TRUE);
$contact = new Contact();
$contact->username = $user_attributes[$CONFIG['ldap_userattribute']][0];
if ($CONFIG['ldap_cache_passwords']) {
$contact->password = $password;
}
$contact->surname = $user_attributes[$CONFIG['ldap_surname']][0];
$contact->forenames = $user_attributes[$CONFIG['ldap_forenames']][0];
$contact->jobtitle = $user_attributes[$CONFIG['ldap_jobtitle']][0];
$contact->email = $user_attributes[$CONFIG['ldap_email']][0];
$contact->phone = $user_attributes[$CONFIG['ldap_telephone']][0];
$contact->mobile = $user_attributes[$CONFIG['ldap_mobile']][0];
$contact->fax = $user_attributes[$CONFIG['ldap_fax']][0];
$contact->siteid = $CONFIG['ldap_default_customer_siteid'];
$contact->address1 = $user_attributes[$CONFIG['ldap_address1']][0];
$contact->city = $user_attributes[$CONFIG['ldap_city']][0];
$contact->county = $user_attributes[$CONFIG['ldap_county']][0];
$contact->postcode = $user_attributes[$CONFIG['ldap_postcode']][0];
$contact->courtesytitle = $user_attributes[$CONFIG['ldap_courtesytitle']][0];
$contact->source = 'ldap';
if ($id == 0) {
$status = $contact->add();
} else {
debug_log("MODIFY CONTACT {$id}", TRUE);
$contact->id = $id;
$status = $contact->edit();
}
if ($status) {
$toReturn = true;
} else {
$toReturn = false;
}
} else {
$toReturn = false;
}
}
return $toReturn;
}