Ejemplo n.º 1
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Function to import the facebook contact to ofuz.
  * Since Facebook does provide limited information on friends so just the basic
  * information will be imported and also keep track of the Facebook user id so that 
  * for the first time it will just add and on next import it will update.
  * @param $fb_friend_id 
  */
 function importFacebookFriends($friends_data)
 {
     $do_tag = new Tag();
     $do_company = new Company();
     $frnd_fb_uid = $friends_data["fb_uid"];
     $idcontact = $this->isFbFriendInContact($frnd_fb_uid);
     $fname = $friends_data["name"]["first_name"];
     $lname = $friends_data["name"]["last_name"];
     $work = $friends_data["work"];
     $work_detail = $work[0];
     $work_history = @$work_detail["work_history"];
     $profile_url = @$friends_data["profile_url"][0]["profile_url"];
     $profile_pic = @$friends_data["pic_with_logo"][0]["pic_with_logo"];
     if (is_array($work_history)) {
         $company = $work_history[0]["company_name"];
         $position = $work_history[0]["position"];
         $desc = $work_history[0]["description"];
     }
     $list_name = $friends_data['listname'];
     $this->firstname = $fname;
     $this->lastname = $lname;
     $this->fb_userid = $frnd_fb_uid;
     $this->iduser = $_SESSION['do_User']->iduser;
     if ($idcontact) {
         //update the data
         $this->checkFbProfileUrlOnUpdate($idcontact, $profile_url);
         $this->updateFbProfilePic($idcontact, $profile_pic);
         $do_tag->addTagAssociation($idcontact, "Facebook", "contact", $_SESSION['do_User']->iduser);
         if (is_array($list_name) && count($list_name) > 0) {
             foreach ($list_name as $list_name) {
                 $do_tag->addTagAssociation($idcontact, $list_name, "contact", $_SESSION['do_User']->iduser);
             }
         }
         $this->getId($idcontact);
         if ($company != '' && !empty($company)) {
             if ($position != '') {
                 $this->position = $position;
             } else {
                 $this->position = '';
             }
             $q = new sqlQuery($this->getDbCon());
             $q->query("select idcompany from company where name = '" . trim($company) . "' AND iduser = "******"idcompany");
                 $this->idcompany = $idcompany;
                 $this->company = trim($company);
                 $this->update();
                 $idcontact = $this->getPrimaryKeyValue();
             } else {
                 $do_company->name = trim($company);
                 $do_company->iduser = $_SESSION['do_User']->iduser;
                 $do_company->add();
                 $idcompany = $do_company->getPrimaryKeyValue();
                 $this->idcompany = $idcompany;
                 $this->company = trim($company);
                 $this->update();
             }
         } else {
             $iduser = $_SESSION['do_User']->iduser;
             $q = new sqlQuery($this->getDbCon());
             $q_upd = "UPDATE contact set firstname = '" . $fname . "',lastname = '" . $lname . "',fb_userid = " . $frnd_fb_uid . ",position = '" . $position . "' where idcontact = " . $idcontact;
             $q->query($q_upd);
         }
     } else {
         // new entry
         $do_company = new Company();
         $do_cont_website = new ContactWebsite();
         if ($company != '' && !empty($company)) {
             if ($position != '') {
                 $this->position = $position;
             } else {
                 $this->position = '';
             }
             $q = new sqlQuery($this->getDbCon());
             $q->query("select idcompany from company where name = '" . trim($company) . "' AND iduser = "******"idcompany");
                 $this->idcompany = $idcompany;
                 $this->company = trim($company);
                 $this->add();
                 $idcontact = $this->getPrimaryKeyValue();
                 $do_cont_website->idcontact = $idcontact;
                 $do_cont_website->website = $profile_url;
                 $do_cont_website->website_type = 'Facebook';
                 $do_cont_website->add();
                 $this->updateFbProfilePic($idcontact, $profile_pic);
                 $do_tag->addTagAssociation($idcontact, "Facebook", "contact", $_SESSION['do_User']->iduser);
                 if (is_array($list_name) && count($list_name) > 0) {
                     foreach ($list_name as $list_name) {
                         $do_tag->addTagAssociation($idcontact, $list_name, "contact", $_SESSION['do_User']->iduser);
                     }
                 }
             } else {
                 $do_company->name = trim($company);
                 $do_company->iduser = $_SESSION['do_User']->iduser;
                 $do_company->add();
                 $idcompany = $do_company->getPrimaryKeyValue();
                 $this->idcompany = $idcompany;
                 $this->company = trim($company);
                 $this->add();
                 $idcontact = $this->getPrimaryKeyValue();
                 $do_cont_website->idcontact = $idcontact;
                 $do_cont_website->website = $profile_url;
                 $do_cont_website->website_type = 'Facebook';
                 $do_cont_website->add();
                 $this->updateFbProfilePic($idcontact, $profile_pic);
                 $do_tag->addTagAssociation($idcontact, "Facebook", "contact", $_SESSION['do_User']->iduser);
                 if (is_array($list_name) && count($list_name) > 0) {
                     foreach ($list_name as $list_name) {
                         $do_tag->addTagAssociation($idcontact, $list_name, "contact", $_SESSION['do_User']->iduser);
                     }
                 }
             }
         } else {
             $iduser = $_SESSION['do_User']->iduser;
             $q = new sqlQuery($this->getDbCon());
             $q_ins = "INSERT into contact (firstname,lastname,fb_userid,iduser,position) values(\n                          '{$fname}','{$lname}',{$frnd_fb_uid},{$iduser},'{$position}')";
             $q->query($q_ins);
             $idcontact = $q->getInsertId();
             $q_website = new sqlQuery($this->getDbCon());
             $q_website->query("INSERT into contact_website (idcontact,website,website_type) VALUES\n                                   ({$idcontact},'{$profile_url}','Facebook')");
             $this->updateFbProfilePic($idcontact, $profile_pic);
             $do_tag->addTagAssociation($idcontact, "Facebook", "contact", $_SESSION['do_User']->iduser);
             if (is_array($list_name) && count($list_name) > 0) {
                 foreach ($list_name as $list_name) {
                     $do_tag->addTagAssociation($idcontact, $list_name, "contact", $_SESSION['do_User']->iduser);
                 }
             }
         }
     }
     $do_tag->free();
 }
Ejemplo n.º 3
0
 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 = "";
         $do_contact = new Contact();
         $do_company = new Company();
         $do_contact_notes = new ContactNotes();
         $num = count($data);
         if ($row > 1) {
             for ($c = 0; $c < $num; $c++) {
                 switch ($eventcontroler->fields[$c]) {
                     case "firstname":
                         $contact_firstname = $data[$c];
                         break;
                     case "lastname":
                         $contact_lastname = $data[$c];
                         break;
                     case "company":
                         $company = $data[$c];
                         $contact_company = $data[$c];
                         break;
                     case "position":
                         $contact_position = $data[$c];
                         break;
                     case "summary":
                         $contact_summary = $data[$c];
                         break;
                     case "birthday":
                         $contact_birthday = $data[$c];
                         break;
                     case "city":
                         $contact_city = $data[$c];
                         break;
                     case "state":
                         $contact_state = $data[$c];
                         break;
                     case "street":
                         $contact_street = $data[$c];
                         break;
                     case "zipcode":
                         $contact_zipcode = $data[$c];
                         break;
                     case "country":
                         $contact_country = $data[$c];
                         break;
                     case "address_hm":
                         $contact_address_hm = $data[$c];
                         $contact_address_hm_type = "Home";
                         break;
                     case "address_wk":
                         $contact_address_wk = $data[$c];
                         $contact_address_wk_type = "Work";
                         break;
                     case "address_ot":
                         $contact_address_ot = $data[$c];
                         $contact_address_ot_type = "Other";
                         break;
                     case "email_hm":
                         $contact_email_hm = $data[$c];
                         $contact_email_hm_type = "Home";
                         break;
                     case "email_wk":
                         $contact_email_wk = $data[$c];
                         $contact_email_wk_type = "Work";
                         break;
                     case "email_ot":
                         $contact_email_ot = $data[$c];
                         $contact_email_ot_type = "Other";
                         break;
                     case "phone_number_hm":
                         $contact_phone_hm = $data[$c];
                         $contact_phone_hm_type = "Home";
                         break;
                     case "phone_number_wk":
                         $contact_phone_wk = $data[$c];
                         $contact_phone_wk_type = "Work";
                         break;
                     case "phone_number_ot":
                         $contact_phone_ot = $data[$c];
                         $contact_phone_ot_type = "Other";
                         break;
                     case "phone_number_mb":
                         $contact_phone_mb = $data[$c];
                         $contact_phone_mb_type = "Mobile";
                         break;
                     case "phone_number_fx":
                         $contact_phone_fx = $data[$c];
                         $contact_phone_fx_type = "Fax";
                         break;
                     case "website_comp":
                         $contact_website_comp = $data[$c];
                         $contact_website_comp_type = "Company";
                         break;
                     case "website_blog":
                         $contact_website_blog = $data[$c];
                         $contact_website_blog_type = "Blog";
                         break;
                     case "website_ot":
                         $contact_website_ot = $data[$c];
                         $contact_website_ot_type = "Other";
                         break;
                     case "website_personal":
                         $contact_website_personal = $data[$c];
                         $contact_website_personal_type = "Personal";
                         break;
                     case "website_twitter":
                         $contact_website_twitter = $data[$c];
                         $contact_website_twitter_type = "Twitter";
                         break;
                     case "website_linkedin":
                         $contact_website_linkedin = $data[$c];
                         $contact_website_linkedin_type = "LinkedIn";
                         break;
                     case "website_fb":
                         $contact_website_fb = $data[$c];
                         $contact_website_fb_type = "Facebook";
                         break;
                     case "im_aim_wk":
                         $contact_im_aim_wk = $data[$c];
                         $im_aim = "AIM";
                         $contact_im_aim_wk_type = "Work";
                         break;
                     case "im_aim_per":
                         $contact_im_aim_per = $data[$c];
                         $im_aim = "AIM";
                         $contact_im_aim_per_type = "Personal";
                         break;
                     case "im_aim_ot":
                         $contact_im_aim_ot = $data[$c];
                         $im_aim = "AIM";
                         $contact_im_aim_ot_type = "Other";
                         break;
                     case "im_msn_wk":
                         $contact_im_msn_wk = $data[$c];
                         $im_msn = "MSN";
                         $contact_im_msn_wk_type = "Work";
                         break;
                     case "im_msn_per":
                         $contact_im_msn_per = $data[$c];
                         $im_msn = "MSN";
                         $contact_im_msn_per_type = "Personal";
                         break;
                     case "im_msn_ot":
                         $contact_im_msn_ot = $data[$c];
                         $im_msn = "MSN";
                         $contact_im_msn_ot_type = "Other";
                         break;
                     case "im_icq_wk":
                         $contact_im_icq_wk = $data[$c];
                         $im_icq = "ICQ";
                         $contact_im_icq_wk_type = "Work";
                         break;
                     case "im_icq_per":
                         $contact_im_icq_per = $data[$c];
                         $im_icq = "ICQ";
                         $contact_im_icq_per_type = "Personal";
                         break;
                     case "im_icq_ot":
                         $contact_im_icq_ot = $data[$c];
                         $im_icq = "ICQ";
                         $contact_im_icq_ot_type = "Other";
                         break;
                     case "im_jabber_wk":
                         $contact_im_jabber_wk = $data[$c];
                         $im_jabber = "Jabber";
                         $contact_im_jabber_wk_type = "Work";
                         break;
                     case "im_jabber_per":
                         $contact_im_jabber_per = $data[$c];
                         $im_jabber = "Jabber";
                         $contact_im_jabber_per_type = "Personal";
                         break;
                     case "im_jabber_ot":
                         $contact_im_jabber_ot = $data[$c];
                         $im_jabber = "Jabber";
                         $contact_im_jabber_ot_type = "Other";
                     case "im_yahoo_wk":
                         $contact_im_yahoo_wk = $data[$c];
                         $im_yahoo = "Yahoo";
                         $contact_im_yahoo_wk_type = "Work";
                         break;
                     case "im_yahoo_per":
                         $contact_im_yahoo_per = $data[$c];
                         $im_yahoo = "Yahoo";
                         $contact_im_yahoo_per_type = "Personal";
                         break;
                     case "im_yahoo_ot":
                         $contact_im_yahoo_ot = $data[$c];
                         $im_yahoo = "Yahoo";
                         $contact_im_yahoo_ot_type = "Other";
                         break;
                     case "im_skype_wk":
                         $contact_im_skype_wk = $data[$c];
                         $im_skype = "Skype";
                         $contact_im_skype_wk_type = "Work";
                         break;
                     case "im_skype_per":
                         $contact_im_skype_per = $data[$c];
                         $im_skype = "Skype";
                         $contact_im_skype_per_type = "Personal";
                         break;
                     case "im_skype_ot":
                         $contact_im_skype_ot = $data[$c];
                         $im_skype = "Skype";
                         $contact_im_skype_ot_type = "Other";
                     case "im_gt_wk":
                         $contact_im_gt_wk = $data[$c];
                         $im_gt = "Google Talk";
                         $contact_im_gt_wk_type = "Work";
                         break;
                     case "im_gt_per":
                         $contact_im_gt_per = $data[$c];
                         $im_gt = "Google Talk";
                         $contact_im_gt_per_type = "Personal";
                         break;
                     case "im_gt_ot":
                         $contact_im_gt_ot = $data[$c];
                         $im_gt = "Google Talk";
                         $contact_im_gt_ot_type = "Other";
                         break;
                     case "note":
                         $contact_note .= "<p>" . $data[$c] . "</p>";
                         break;
                 }
             }
             $do_company->name = $company;
             $do_company->iduser = $iduser;
             $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 != "") {
                 $do_contact->addWebsite($contact_website_personal, $contact_website_personal_type);
             }
             if ($contact_website_twitter != "") {
                 $do_contact->addWebsite($contact_website_twitter, $contact_website_twitter_type);
             }
             if ($contact_website_linkedin != "") {
                 $do_contact->addWebsite($contact_website_linkedin, $contact_website_linkedin_type);
             }
             if ($contact_website_fb != "") {
                 $do_contact->addWebsite($contact_website_fb, $contact_website_fb_type);
             }
             if ($contact_im_aim_wk != "") {
                 $do_contact->addIM($im_aim, $contact_im_aim_wk_type, $contact_im_aim_wk);
             }
             if ($contact_im_aim_per != "") {
                 $do_contact->addIM($im_aim, $contact_im_aim_per_type, $contact_im_aim_per);
             }
             if ($contact_im_aim_ot != "") {
                 $do_contact->addIM($im_aim, $contact_im_aim_ot_type, $contact_im_aim_ot);
             }
             if ($contact_im_msn_wk != "") {
                 $do_contact->addIM($im_msn, $contact_im_msn_wk_type, $contact_im_msn_wk);
             }
             if ($contact_im_msn_per != "") {
                 $do_contact->addIM($im_msn, $contact_im_msn_per_type, $contact_im_msn_per);
             }
             if ($contact_im_msn_ot != "") {
                 $do_contact->addIM($im_msn, $contact_im_msn_ot_type, $contact_im_msn_ot);
             }
             if ($contact_im_icq_wk != "") {
                 $do_contact->addIM($im_icq, $contact_im_icq_wk_type, $contact_im_icq_wk);
             }
             if ($contact_im_icq_per != "") {
                 $do_contact->addIM($im_icq, $contact_im_icq_per_type, $contact_im_icq_per);
             }
             if ($contact_im_icq_ot != "") {
                 $do_contact->addIM($im_icq, $contact_im_icq_ot_type, $contact_im_icq_ot);
             }
             if ($contact_im_jabber_wk != "") {
                 $do_contact->addIM($im_jabber, $contact_im_jabber_wk_type, $contact_im_jabber_wk);
             }
             if ($contact_im_jabber_per != "") {
                 $do_contact->addIM($im_jabber, $contact_im_jabber_per_type, $contact_im_jabber_per);
             }
             if ($contact_im_jabber_ot != "") {
                 $do_contact->addIM($im_jabber, $contact_im_jabber_ot_type, $contact_im_jabber_ot);
             }
             if ($contact_im_yahoo_wk != "") {
                 $do_contact->addIM($im_yahoo, $contact_im_yahoo_wk_type, $contact_im_yahoo_wk);
             }
             if ($contact_im_yahoo_per != "") {
                 $do_contact->addIM($im_yahoo, $contact_im_yahoo_per_type, $contact_im_yahoo_per);
             }
             if ($contact_im_yahoo_ot != "") {
                 $do_contact->addIM($im_yahoo, $contact_im_yahoo_ot_type, $contact_im_yahoo_ot);
             }
             if ($contact_im_skype_wk != "") {
                 $do_contact->addIM($im_skype, $contact_im_skype_wk_type, $contact_im_skype_wk);
             }
             if ($contact_im_skype_per != "") {
                 $do_contact->addIM($im_skype, $contact_im_skype_per_type, $contact_im_skype_per);
             }
             if ($contact_im_skype_ot != "") {
                 $do_contact->addIM($im_skype, $contact_im_skype_ot_type, $contact_im_skype_ot);
             }
             if ($contact_im_gt_wk != "") {
                 $do_contact->addIM($im_gt, $contact_im_gt_wk_type, $contact_im_gt_wk);
             }
             if ($contact_im_gt_per != "") {
                 $do_contact->addIM($im_gt, $contact_im_gt_per_type, $contact_im_gt_per);
             }
             if ($contact_im_gt_ot != "") {
                 $do_contact->addIM($im_gt, $contact_im_gt_ot_type, $contact_im_gt_ot);
             }
             if ($contact_note != "") {
                 $do_contact_notes->idcontact = $idcontact;
                 $do_contact_notes->iduser = $iduser;
                 $do_contact_notes->note = $contact_note;
                 $do_contact_notes->date_added = date('Y-m-d');
                 $do_contact_notes->add();
             }
             $do_cont_view = new ContactView();
             $do_cont_view->addFromContact($do_contact);
             $do_cont_view->updateFromContact($do_contact);
             // Added the method call updateFromContact() so that the child data is updated just after insert
             $do_cont_view->addTag($_SESSION['import_tag'], $do_contact->idcontact);
             // Update the contact view for tags.
             $do_contact->free();
             $do_company->free();
             $do_contact_notes->free();
         }
         $row++;
     }
     fclose($handle);
     $goto = $eventcontroler->getParam("goto");
     $disp = new Display($goto);
     $disp->addParam("message", "Contacts have been imported successfully.");
     $eventcontroler->setDisplayNext($disp);
 }
Ejemplo n.º 4
0
 /**
  * saveWebForm()
  * this will check if contact exists with firname, lastname, name and email 
  * If exist add to it, if doesn't exists create a new one.
  */
 function posteventAddContact($fid, $fields, $nxturl, $uid, $tags)
 {
     //echo 'hh';die();
     //$fields = $_REQUEST['fields'];
     //$fields = $event_controler->fields;
     $this->setLog("\n eventAddContact, creating new contact from form, using " . count($fields) . " fields. (" . date("Y/m/d H:i:s") . ")");
     //$dropcode = $_POST['dropcode'];
     $do_contact = new Contact();
     $do_contact->iduser = $uid;
     $do_contact->add();
     $this->setLog("\n new contact:" . $do_contact->idcontact . " for user:"******"\n Processing field:" . $field_name . " with value:" . $field_value);
         $do_webform_fields = new WebFormUserField();
         $do_webform_fields->query("SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n\t\t                                   FROM webformfields as wff, webformuserfield as wfu \n\t\t\t\t\t\t\t\t\t\t   WHERE wff.name=wfu.name\n\t\t\t\t\t\t\t\t\t\t     AND wfu.name = '" . $field_name . "'\n\t\t\t\t\t\t\t\t\t\t\t AND wfu.idwebformuser= "******"\n Field information class:" . $do_webform_fields->class_name . " Variable:" . $do_webform_fields->variable);
         $this->setLog("\n rows:" . $do_webform_fields->getNumRows());
         if ($do_webform_fields->getNumRows() == 1) {
             if ($do_webform_fields->class_name == "Contact") {
                 $this->setLog("\n     Updating contact");
                 $do_contact->{$do_webform_fields->variable} = $field_value;
                 $do_contact->update();
             } else {
                 $update = false;
                 if (is_object(${'sub_' . $do_webform_fields->class_name})) {
                     if (${'sub_' . $do_webform_fields->class_name}->getType() == $do_webform_fields->variable_type) {
                         $update = true;
                     }
                 }
                 if ($update) {
                     $this->setLog("\n     Updating class:" . $do_webform_fields->class_name);
                     $obj = ${'sub_' . $do_webform_fields->class_name};
                     $obj->{$do_webform_fields->variable} = $field_value;
                     $obj->update();
                 } else {
                     $class_name = $do_webform_fields->class_name;
                     ${'sub_' . $class_name} = new $class_name();
                     $obj = ${'sub_' . $class_name};
                     $obj->{$do_webform_fields->variable} = $field_value;
                     if (method_exists($obj, "setType") && strlen($do_webform_fields->variable_type) > 0) {
                         $obj->setType($do_webform_fields->variable_type);
                     }
                     $obj->idcontact = $do_contact->getPrimaryKeyValue();
                     $obj->add();
                 }
             }
         }
     }
     $contact_view = new ContactView();
     $contact_view->setUser($uid);
     $contact_view->addFromContact($do_contact);
     $tags = explode(",", $tags);
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $do_tag = new Tag();
         $do_tag->addNew();
         $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $fid);
         $contact_view->addTag($tag);
     }
     if (strlen($nexturl) > 0) {
         //$event_controler->setUrlNext($this->urlnext);
         header("location:{$nxturl}");
     } else {
         //$event_controler->setUrlNext($GLOBALS['cfg_ofuz_site_http_base'].'web_form_thankyou.php');
         $url = $GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php';
         header("location:{$url}");
     }
     //$event_controler->addParam("do_contact", $do_contact);
 }
Ejemplo n.º 5
0
 function add_tag()
 {
     $do_api_contact = new Contact();
     if (!$this->idreference || $this->idreference == '') {
         $this->setMessage("621", "Reference Id Missing");
         return false;
     } elseif ($this->tags == '') {
         $this->setMessage("622", "Tag missing");
         return false;
     } elseif (!$do_api_contact->isContactRelatedToUser($this->idreference, $this->iduser)) {
         $this->setMessage("615", "Contact does not belong to you nor shared by your Co-Worker");
         return false;
     } else {
         $do_api_tags = new Tag();
         $tags = explode(",", $this->tags);
         foreach ($tags as $tag) {
             $do_api_tags->addNew();
             $do_api_tags->addTagAssociation($this->idreference, $tag, $this->reference, $this->iduser);
         }
         $this->setValues(array("msg" => "Tags Added", "stat" => "ok", "code" => "620"));
         return true;
     }
 }
Ejemplo n.º 6
0
 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
         $do_cont_view->addTag($_SESSION['import_tag'], $new_contact->idcontact);
         // Update the contact view for tags.
         $this->imported = true;
     }
 }