示例#1
0
 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();
 }
示例#2
0
 /**
  * eventAddTagMultiple
  * Triggered form the contacts.php page when assigning multiple tags 
  * to a single contact.
  */
 function eventAddTagMultiple(EventControler $event_controler)
 {
     $this->eventSetFilter($event_controler);
     $tags = explode(",", $event_controler->tags);
     $contacts = $event_controler->getParam("ck");
     if (is_array($tags) && is_array($contacts)) {
         $do_tag = new Tag();
         $contact_view = new ContactView();
         foreach ($contacts as $idcontact) {
             $contact_view->getId($idcontact);
             foreach ($tags as $tag) {
                 $tag = trim($tag);
                 $do_tag->addNew();
                 $do_tag->addTagAssociation($idcontact, $tag, "contact");
                 $contact_view->addTag($tag);
             }
         }
     }
     $_SESSION['tag_refresh_now'] = true;
 }