public function setActiveInactiveTag($iduser, $idcontact) { $phil_iduser = "******"; $login_status = $this->GetUserLoginStatus($iduser); $do_contact_view = new ContactView(); $do_contact_view->setUser($phil_iduser); $do_tag = new TagInternalMarketing(); if ($login_status == "Active") { $do_contact_view->deleteTag("Inactive", $idcontact); $do_contact_view->addTag("Active", $idcontact); $do_tag->deleteContactTag("Inactive", $phil_iduser, $idcontact); $do_tag->setContactTag("Active", $phil_iduser, $idcontact); } if ($login_status == "Inactive") { $do_contact_view->deleteTag("Active", $idcontact); $do_contact_view->addTag("Inactive", $idcontact); $do_tag->deleteContactTag("Active", $phil_iduser, $idcontact); $do_tag->setContactTag("Inactive", $phil_iduser, $idcontact); } }
$friends = $ofuz_twitter->userFriends(array('id' => $tw_user_id)); if (count($friends->user) > 0) { foreach ($friends->user as $user) { $user_id = $user->id; $name = $user->name; // will contain the first and last name $screen_name = $user->screen_name; $description = $user->description; $profile_image_url = $user->profile_image_url; $url = $user->url; $friend_data = array('user_id' => $user_id, 'name' => $name, 'screen_name' => $screen_name, 'description' => $description, 'profile_image_url' => $profile_image_url, 'url' => $url); $do_twitter->importTwitterFriend($friend_data); } //rebuilding the userXX_contact table $contact_view = new ContactView(); $contact_view->setUser($_SESSION['do_User']->iduser); $contact_view->rebuildContactUserTable(); echo _('Your Twitter contacts have been successfully imported.'); echo ' <a href="contacts.php">', _('Go to the Contacts Page'), '</a>'; } ?> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { $("#waitimage").hide(0); }); //]]> </script> <div class="spacerblock_80"></div><div class="spacerblock_80"></div> </div> </td><td class="layout_rmargin"></td></tr></table>
/** * Function to unshare a contact * @param integer $idcontact * @param interger $idcoworker */ function unshareContact($idcontact, $idcoworker) { $q = new sqlQuery($this->getDbCon()); $q->query("delete from " . $this->table . " where idcontact = " . $idcontact . " AND idcoworker = " . $idcoworker . " AND iduser ="******" LIMIT 1"); $do_contact_view = new ContactView(); $do_contact_view->setUser($idcoworker); $do_contact_view->deleteFromContact($idcontact); }
/** * 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')); } }
<?php /** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/ // Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com /** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/ /** * Rebuild the user contacts table * User contacts are accessed from the tables by userid<iduser>_contact * The contact table is updated for all the contact related operation and also the user contact table is getting updated on * add/edit/delete operation of contact, tag etc. * To make it more reliable the following script is used. This is rebuilt all the user contact tables. * This script is intensive as the volume of contact and user increases. * Wise to set the script once in a week. Also we can ignore rebuiling of user contact tables who have not logged in in certain period by passing the parameter * in getUserLoggedInWithinPeriod() default is 7 days * @see class/Contact.class.php * @see class/ContactView.class.php * */ include_once "config.php"; $contact_view = new ContactView(); set_time_limit(36000); $user = new User(); $user->getUserLoggedInWithinPeriod(); while ($user->next()) { // if($user->iduser == 20 ){ echo "\n<br>User id:" . $user->iduser . " Name:" . $user->firstname . " " . $user->lastname; $contact_view->setUser($user->iduser); $contact_view->rebuildContactUserTable(); // } }
$message = 'already_unsub_from_list'; } $do_cont_note = new ContactNotes(); $do_cont_note->addNew(); $do_cont_note->idcontact = $idcontact; $do_cont_note->note = $firstname . " " . $lastname . " has unsubscribed from the autoresponder series called " . $responder; $do_cont_note->date_added = date("Y-m-d"); $do_cont_note->iduser = $iduser; $do_cont_note->add(); $do_workfeed_uns = new WorkFeedContactUnsubscibeEmails(); $do_workfeed_uns->addUnsubscribeEmailWorkfeed($do_cont_note, $responder); $q = new sqlQuery($GLOBALS['conx']); $sql = "DELETE FROM `tag` WHERE iduser={$iduser} AND idreference={$idcontact} AND idtag={$idtag}"; $q->query($sql); $do_contact_view = new ContactView(); $do_contact_view->setUser($iduser); $do_contact_view->deleteTag($do_tag->tag_name, $idcontact); //$message = $firstname." ".$lastname.' '._('you have successfully unsubscribed from the autoresponder series called').' '.$responder; $message = 'unsub_list_message'; $data = array("firstname" => $firstname, "lastname" => $lastname, "responder" => $responder); $do_contact->sendMessage(new EmailTemplate("unsubscribe_auto_responder"), $data); } else { $message = 'already_unsub_from_list'; } //header("Location: http://ofuz.com"); //exit(); ?> <div class="loginbg1"> <!--<div class="loginheader"><a href="/index.php"><img src="/images/ofuz_logo2.jpg" width="170" height="90" alt="" /></a></div>--> <div style = "width:500px;margin: 0 auto; padding: 10px; text-align:left;"> <?php
/** * 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); }
/** Method to re-create the tags associated with a contact with the shared Co-Workers @param integer idcontact @param integer idcoworker */ function addTagOnContactSharing($idcontact, $idcoworker, $iduser = 0) { if ($iduser == 0) { $iduser = $_SESSION['do_User']->iduser; } $tags = $this->getAllTagNamesForReferer($idcontact, $iduser); $comma_separated_tags = ''; if (is_array($tags) && count($tags) > 0) { $do_contact_view = new ContactView(); foreach ($tags as $tag) { $this->addTagAssociation($idcontact, $tag, "", $idcoworker); } $do_contact_view->setUser($idcoworker); $do_contact_view->addTag(implode(",", $tags), $idcontact); } }
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); $do_Contact_View->updateFromContact($do_api_contact); if ($this->tags != '') { $do_Contact_View->addTag($this->tags, $this->idcontact); } $this->setValues(array("msg" => "Contact Added", "stat" => "ok", "code" => "600", "idcontact" => $this->idcontact)); return true; } }
/** * 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(); }
/** * 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 array $fb_friend_id * @param integer $iduser */ function importFacebookFriends($friends_data, $iduser = '') { $do_tag = new Tag(); $do_company = new Company(); $do_cont_view = new ContactView(); if ($iduser == '') { $iduser = $_SESSION['do_User']->iduser; } else { $do_cont_view->setUser($iduser); } $tag_list_names = ''; $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 = $iduser; if ($idcontact) { //update the data $this->checkFbProfileUrlOnUpdate($idcontact, $profile_url); $this->updateFbProfilePic($idcontact, $profile_pic); $do_tag->addTagAssociation($idcontact, "Facebook", "contact", $iduser); if (is_array($list_name) && count($list_name) > 0) { $tag_list_names = implode(",", $list_name); foreach ($list_name as $list_name) { $do_tag->addTagAssociation($idcontact, $list_name, "contact", $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 = $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); } $this->getId($idcontact); $do_cont_view->updateFromContact($this); // Added the method call updateFromContact() so that the child data is updated $do_cont_view->addTag('Facebook', $this->idcontact); // Update the contact view for tags. $do_cont_view->addTag($tag_list_names, $this->idcontact); // Update the contact view for tags. } 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", $iduser); if (is_array($list_name) && count($list_name) > 0) { $tag_list_names = implode(",", $list_name); foreach ($list_name as $list_name) { $do_tag->addTagAssociation($idcontact, $list_name, "contact", $iduser); } } } else { $do_company->name = trim($company); $do_company->iduser = $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", $iduser); if (is_array($list_name) && count($list_name) > 0) { $tag_list_names = implode(",", $list_name); foreach ($list_name as $list_name) { $do_tag->addTagAssociation($idcontact, $list_name, "contact", $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", $iduser); if (is_array($list_name) && count($list_name) > 0) { $tag_list_names = implode(",", $list_name); foreach ($list_name as $list_name) { $do_tag->addTagAssociation($idcontact, $list_name, "contact", $iduser); } } } $this->getId($idcontact); $do_cont_view->addFromContact($this); $do_cont_view->updateFromContact($this); // Added the method call updateFromContact() so that the child data is updated just after insert $do_cont_view->addTag('Facebook', $this->idcontact); // Update the contact view for tags. $do_cont_view->addTag($tag_list_names, $this->idcontact); // Update the contact view for tags. } $do_tag->free(); }