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; }
function eventAddContactToTeamCW(Contact $contact) { $do_teams = new Teams(); //gets user's teams which are marked as auto-shared $do_teams->getUserTeamsAutoShared(); if ($do_teams->getNumRows()) { while ($do_teams->next()) { //gets Co-Workers of the team $do_teams_cw = new Teams(); $do_teams_cw->getCoWorkersOfTheTeam($do_teams->idteam); if ($do_teams_cw->getNumRows()) { while ($do_teams_cw->next()) { $this->addNew(); $this->idcontact = $contact->idcontact; $this->idteam = $do_teams->idteam; $this->idcoworker = $do_teams_cw->idco_worker; $this->add(); $this->free(); //building contact view table $do_cv = new ContactView(); $do_cv->table = "userid" . $do_teams_cw->idco_worker . "_contact"; $do_cv->getId($contact->idcontact); if (!$do_cv->hasData()) { $do_cv->addNew(); $do_cv->idcontact = $contact->idcontact; $do_cv->firstname = $contact->firstname; $do_cv->lastname = $contact->lastname; $do_cv->company = $contact->company; $do_cv->idcompany = $contact->idcompany; $do_cv->position = $contact->position; $do_cv->picture = $contact->picture; $do_cv->last_activity = date('Y-m-d h:i:s'); $do_cv->last_update = date('Y-m-d h:i:s'); $do_cv->first_created = date('Y-m-d h:i:s'); $do_cv->add(); $do_cv->free(); } //Conact sharing with Co-Worker $do_cs_check = new ContactSharing(); $contact_shared = $do_cs_check->checkCoWorkerContactRel($contact->idcontact, $do_teams_cw->idco_worker); if (!$contact_shared) { $do_cs = new ContactSharing(); $do_cs->addNew(); $do_cs->iduser = $_SESSION['do_User']->iduser; $do_cs->idcontact = $contact->idcontact; $do_cs->idcoworker = $do_teams_cw->idco_worker; $do_cs->add(); $do_cs->free(); } $do_cs_check->free(); } } else { $this->addNew(); $this->idcontact = $_SESSION['ContactEditSave']->idcontact; $this->idteam = $do_teams->idteam; $this->add(); $this->free(); } $do_teams_cw->free(); } } $do_teams->free(); }
/** Method to delete tags from multiple contacts Reset the query to NULL if no more tag found by the same, otherwise searching by tag and then deleting will result error due to the query in the session */ function eventDeleteMultipleContactsTag(EventControler $evtcl) { $tagname = $evtcl->delTagMul; $contacts = $evtcl->getParam("ck"); if ($tagname != '') { $do_tag = new Tag(); $contact_view = new ContactView(); foreach ($contacts as $idcontact) { $contact_view->getId($idcontact); $contact_view->deleteTag($tagname); $idtag = $do_tag->isTagExistsForReferer($tagname, $idcontact); $do_tag->delTagById($idtag); } $q = new sqlQuery($this->getDbCon()); $q->query("select * from tag where tag_name = '" . trim($tagname) . "' AND iduser = "******""); } $contact_view->free(); // When deleting contact by uisng search by tag and if all the contacts are deleted then we must set the query as empty $this->query($this->getSqlQuery()); if ($this->getNumRows() == 0) { $this->clearSearch(); $this->setSqlQuery(""); } } $_SESSION['tag_refresh_now'] = true; }