Пример #1
0
 function eventVCardImport(EventControler $evtcl)
 {
     $msg = "";
     $goto = $evtcl->getParam("goto");
     $uploaded_file = $_FILES['fields']['name']['contact_vcard'];
     if ($uploaded_file) {
         $target_path = 'files/' . $uploaded_file;
         if (!move_uploaded_file($_FILES['fields']['tmp_name']['contact_vcard'], $target_path)) {
             $msg = "There was an error uploading the file, please try again!";
         } else {
             chmod($target_path, 0755);
             $_SESSION['vcard_file'] = $uploaded_file;
             $_SESSION['import_tag'] = trim($evtcl->fields['import_tag']);
             $retVal = $this->print_vcard_address_book($target_path, 'ofuz vCard Import', '', '', '');
             if ($retVal) {
                 $msg = "Your vCard contacts have been imported successfully.";
             } else {
                 $msg = $this->errMsg;
             }
         }
     } else {
         $msg = "Please select a file to be imported.";
     }
     $disp = new Display($goto);
     $disp->addParam("msg", $msg);
     if ($evtcl->getParam("fromReg") == 'Yes') {
         //if importing while registration
         $_SESSION["page_from"] = 'reg';
     }
     $evtcl->setDisplayNext($disp);
 }
Пример #2
0
 /**
  * Event method sharing the contacts with the Co-Workers
  * @param object $evtcl
  */
 function eventShareContactsMultiple(EventControler $evtcl)
 {
     $contacts = $evtcl->getParam("idcontacts");
     $co_workers = $evtcl->getParam("cwid");
     $count = 0;
     $no_coworker = 0;
     if (is_array($contacts) && is_array($co_workers)) {
         $do_tag = new Tag();
         foreach ($co_workers as $co) {
             foreach ($contacts as $cont) {
                 if (!$this->checkCoWorkerContactRel($cont, $co)) {
                     $this->addContactSharings($cont, $co);
                     $do_tag->addTagOnContactSharing($cont, $co);
                     $count++;
                 }
             }
         }
     }
     if ($count) {
         $msg = 'Sharing Updated succesfully';
     } else {
         $msg = 'No Data updated,you may be trying to duplicate some contact access';
     }
     $goto = $evtcl->goto;
     $dispError = new Display($goto);
     $dispError->addParam("message", $msg);
     $evtcl->setDisplayNext($dispError);
 }
Пример #3
0
 /**
  * eventSetUsers()
  * Grab the users ids from the contacts multi select and 
  * store the object in the session
  */
 function eventSetUsers(EventControler $event_controler)
 {
     if (strlen($event_controler->tags) == 0) {
         $this->setLog("\n Not tags Adding users to the MailMerge");
         $contacts = $event_controler->getParam("ck");
         if (is_array($contacts)) {
             $this->contacts = $contacts;
         }
     }
     $_SESSION['MailMerge_Contacts'] = $this;
 }
Пример #4
0
 public function eventImportCSV(EventControler $evctl)
 {
     $this->setLog(true);
     $this->setLog("\n Importing: expenses 2010");
     $goto = $evctl->getParam("goto");
     $import_file = $evctl->getParam("import_file");
     if (empty($import_file)) {
         $import_file = $this->import_file;
     }
     $import_file = $GLOBALS['cfg_plugin_expense_path'] . $import_file;
     $this->setLog("\n With File: " . $import_file);
     //   amount  Float Number (Float)
     //   category  One Line text
     //   debit_date  Date (SQL)
     //   description  One Line text
     //   idexpense_import  Simple Number (Integer)
     //   payment_method  One Line text
     if (file_exists($import_file)) {
         $fp = fopen($import_file, "r");
         $i = 0;
         $total = 0;
         while ($fields = fgetcsv($fp)) {
             $i++;
             $this->newRecord();
             $this->category = $fields[0];
             $this->debit_date = $this->format_sql_date($fields[1]);
             $this->description = $fields[3];
             $this->payment_method = $fields[4];
             $this->amount = $this->money2float($fields[5]);
             $this->iduser = $_SESSION['do_User']->iduser;
             $this->add();
             $total += $this->money2float($fields[5]);
             $this->setLog("\n insert with: " . $this->getSqlQuery());
         }
     }
     $this->setLog("\n imported a total of: " . $total);
     $disp = new Display($goto);
     $disp->addParam("message", "Import completed");
     $evctl->setDisplayNext($disp);
 }
Пример #5
0
 /**
  * Event Function used while updating a company
  * Checks if the updated Company is already in the database
  * If there then do not update and set doSave = mo
  * Else continue with other events from the called page
  * 
  */
 function eventCheckDuplicateCompanyInUpdate(EventControler $evtcl)
 {
     $fields = $evtcl->getParam('fields');
     $q_company = new sqlQuery($this->getDbCon());
     $q_company->query("select name from company where idcompany = " . $this->getPrimaryKeyValue());
     $q_company->fetch();
     $comp_name = $q_company->getData("name");
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from company where name='" . trim($fields['name']) . "' \r\n      AND name <> '" . trim($comp_name) . "'");
     // need to have the iduser as well
     if ($q->getNumRows() > 0) {
         $dispError = new Display($evtcl->goto);
         $dispError->addParam("message", "This company is already in the database");
         $evtcl->addParam("doSave", "no");
         $evtcl->setDisplayNext($dispError);
     }
 }
Пример #6
0
 /**
  * eventGetForMailMerge
  * Get the list of contact for mailmerge
  * load in the current contact object the list of
  * selected contacts from the contacts.php
  * Then redirect to the SendMessage page.
  * 
  * In here we are doing something not very elegant but to grab the proper
  * information from the Contacts object we linked it with this new Object.
  * @Note this assignment may need to be revisited in the future.
  */
 function eventGetForMailMerge(EventControler $event_controler)
 {
     $idcontacts = $event_controler->getParam("ck");
     $sql_in = "(";
     foreach ($idcontacts as $idcontact) {
         $sql_in .= $idcontact . ",";
     }
     $sql_in = substr($sql_in, 0, -1);
     $sql_in .= ")";
     $tag_search = $_SESSION['do_Contacts']->getSearchTags();
     if (is_array($tag_search) && count($tag_search > 0)) {
         $_SESSION['searched_tags'] = $tag_search;
     }
     $this->clearSearch();
     $this->setSqlQuery("SELECT * FROM contact WHERE idcontact in " . $sql_in);
     $this->sessionPersistent("do_ContactMailing", "contacts.php", 36000);
     $event_controler->goto = $GLOBALS['cfg_plugin_mkt_path'] . "SendMessage";
     //$event_controler->setDisplayNext(new Display($GLOBALS['cfg_plugin_mkt_path']."SendMessage/"));
 }
Пример #7
0
 /**
  * Event registration log out
  * Logout the user and clear off all the session variable currently set.
  * This event can be triggered with an link event like:
  * <?php
  *   $e = new Event("RegisteredUser->eventLogout");
  *   $e->goto = "home.php";
  *   $e->full_sign_off = true;
  *   echo $e->getLink("Logout");
  * ?>
  * The full_sign_off param to true will kill the entire session  
  * It redirect to the goto page with a param in the url: 
  *  $_GET['loginmessage']; can be use to display the message 
  * 
  * @package registration
  * @author Philippe Lewicki
  * @version 1.0
  */
 function eventLogout(EventControler $eventControler)
 {
     $goto = $eventControler->getParam("goto");
     $full_sign_off = $eventControler->getParam("full_sign_off");
     if (empty($goto)) {
         $goto = "index.php";
     }
     if (empty($full_sign_off)) {
         $full_sign_off = false;
     }
     if ($full_sign_off) {
         session_unregister('userdata');
         unset($_SESSION['userdata']);
         $this->setFree();
         $this->free();
     } else {
         // Unset all of the session variables.
         $_SESSION = array();
         // If it's desired to kill the session, also delete the session cookie.
         // Note: This will destroy the session, and not just the session data!
         if (isset($_COOKIE[session_name()])) {
             setcookie(session_name(), '', time() - 42000, '/');
         }
         // Finally, destroy the session.
         session_destroy();
     }
     $dispError = new Display($goto);
     $dispError->addParam("message", _('Log out successful'));
     $eventControler->setDisplayNext($dispError);
     /*  if (class_exists("AuditLog")) {
             $log = new AuditLog();
             $log->init();
             $log->action = "logout";
             $log->user = $this->{$this->getUsernameField()};
             $log->object = $this->getObjectName();
             $log->add();
         } */
 }
Пример #8
0
 /**
  * Shares Co-Worker/s with Team
  *
  * @param Object : EventControler
  */
 function eventShareCWsWithTeam(EventControler $evtcl)
 {
     $idteams = $evtcl->getParam("team");
     $idcoworkers = $evtcl->getParam("cwid");
     if (is_array($idteams) && is_array($idcoworkers)) {
         foreach ($idteams as $idteam) {
             foreach ($idcoworkers as $idcoworker) {
                 $sql = "SELECT count(*) count_team\n\t\t  FROM team_users\n\t\t  WHERE idteam = {$idteam} AND idco_worker = {$idcoworker}\n                 ";
                 $this->query($sql);
                 $this->fetch();
                 if (!$this->getData("count_team")) {
                     $con = new sqlQuery($this->getDbCon());
                     $sql = "INSERT INTO team_users\n\t\t    VALUES(null,{$idteam},{$idcoworker})\n                   ";
                     $con->query($sql);
                     $con->free();
                 }
             }
         }
     }
 }
Пример #9
0
 /**
  * Event method to delete a project discussion
  * @param $event_controler -- Object
  */
 function eventDelProjectDiscussionNoteById(EventControler $event_controler)
 {
     $idnote = $event_controler->getParam('id');
     $this->deleteProjectDiscussionNote($idnote);
 }
Пример #10
0
 /**
  * Contact is shared with selected Team/s and Co-Worker/s
  *
  * @param Object : EventControler
  * 
  */
 function eventShareExistingContactWithTeamCw(EventControler $evtcl)
 {
     $idteams = $evtcl->getParam("team");
     $idcoworkers = $evtcl->getParam("cwid");
     $contacts = $evtcl->getParam("idcontacts");
     if (is_array($idteams) && is_array($idcoworkers)) {
         foreach ($idteams as $idteam) {
             foreach ($idcoworkers as $idcoworker) {
                 foreach ($contacts as $contact) {
                     $sql = "SELECT count(*) AS count_team\n\t\t    FROM {$this->table}\n\t\t    WHERE idcontact = {$contact} AND idteam = {$idteam} AND idcoworker = {$idcoworker}\n                   ";
                     $this->query($sql);
                     $this->fetch();
                     if (!$this->getData("count_team")) {
                         $this->addNew();
                         $this->idcontact = $contact;
                         $this->idteam = $idteam;
                         $this->idcoworker = $idcoworker;
                         $this->add();
                     }
                 }
             }
         }
     }
 }
Пример #11
0
 function eventMergeContacts(EventControler $evtcl)
 {
     $contact_ids = $evtcl->getParam("contact_ids");
     $idcontact = $evtcl->getParam("cont_id");
     $idcontact_phone = $evtcl->getParam("cont_phone");
     $idcontact_email = $evtcl->getParam("cont_email");
     $contact_instant_message = $evtcl->getParam("cont_im");
     $idcontact_website = $evtcl->getParam("cont_website");
     $idcontact_address = $evtcl->getParam("cont_addr");
     $idcontact_rss_feed = $evtcl->getParam("cont_rss");
     $del_cont_ids = array();
     /* if(count($idcontact)){
            foreach($contact_ids as $mergeid){
                if($mergeid != $idcontact){
                    $del_cont_ids[] = $mergeid             
                }
            }
            if(is_array($idcontact_phone)){
                
            }
            
        }else{
        }*/
 }
Пример #12
0
 /**
  * Event method to remove a Co-Worker himself/herself from a project  (self removal from project)
  */
 function eventSelfDelProjectCoWorker(EventControler $evtcl)
 {
     $idcoworker = $evtcl->getParam("idcoworker");
     $idproject = $evtcl->getParam("idproject");
     $iduser = $this->getProjectOwner($idproject);
     //echo '<br />Please dont delete me :( ';exit;
     $q = new sqlQuery($this->getDbCon());
     $q->query("delete from project_sharing where idproject = " . $idproject . "\n                   AND iduser = "******" AND idcoworker = " . $idcoworker . " Limit 1");
     /* Once the Co-Worker is removed from the project assign all the open tasks for that user
           back to the owner
        */
     $do_project_task = new ProjectTask();
     $do_project_task->getAllProjectTasksForUser($idproject, $idcoworker);
     if ($do_project_task->getNumRows()) {
         $q = new sqlQuery($this->getDbCon());
         while ($do_project_task->next()) {
             $q->query("update task set iduser = "******"do_User"]->iduser . " where idtask = " . $do_project_task->idtask . " Limit 1");
         }
     }
 }
Пример #13
0
 function eventCsvUpload(EventControler $eventcontroler)
 {
     /* echo $_FILES['fields']['name']['contact_csv'];
        exit();*/
     $msg = "";
     $uploaded_file = $_FILES['fields']['name']['contact_csv'];
     $target_path = 'files/' . $uploaded_file;
     if (!move_uploaded_file($_FILES['fields']['tmp_name']['contact_csv'], $target_path)) {
         $msg = "There was an error uploading the file, please try again!";
     }
     chmod($target_path, 0755);
     $_SESSION['csv_file'] = $_FILES['fields']['name']['contact_csv'];
     $_SESSION['import_tag'] = $eventcontroler->fields['import_tag'];
     $goto = $eventcontroler->getParam("goto");
     $disp = new Display($goto);
     if ($eventcontroler->getParam("fromReg") == 'Yes') {
         //if importing while registration
         $_SESSION["page_from"] = 'reg';
     }
     $eventcontroler->setDisplayNext($disp);
 }
Пример #14
0
 function eventSetUserId(EventControler $evtcl)
 {
     $fields = $evtcl->getParam("fields");
     $idcontact = $evtcl->getParam("idcontact");
     $q = new sqlQuery($this->getDbCon());
     //$iduser = 17;
     $fields["iduser"] = 0;
     $fields["idcontact"] = $idcontact;
     $evtcl->updateParam("fields", $fields);
     //print_r($fields); exit;
 }
Пример #15
0
 /**
  * Event Controller that will take the form data for the task
  * The due date here is a string so that string will be
  * converted to Mysql date format Y-m-d with cool PHP 
  * strtotime() method 
  * Finally the field array will be updated
  * with the modified data.
  * 
  */
 function eventSetDateInFormat(EventControler $evtcl)
 {
     $fields = $evtcl->getParam("fields");
     $dutedate = $fields["due_date"];
     $sp_date_sel_hidden = $_POST["sp_date_selected"];
     if ($sp_date_sel_hidden == "") {
         if ($dutedate != 'Later') {
             switch ($dutedate) {
                 case "Today":
                     $formated_date = date("Y-m-d");
                     break;
                 case "Tomorrow":
                     $formated_date = date("Y-m-d", strtotime("+1 day"));
                     break;
                 case "This week":
                     $formated_date = date("Y-m-d", strtotime("next Friday"));
                     break;
                 case "Next week":
                     $formated_date = date("Y-m-d", strtotime("next Friday", strtotime("+1 week")));
                     break;
                 case "This month":
                     $formated_date = date('Y-m-d', strtotime('-1 second', strtotime('+1 month', strtotime(date('m') . '/01/' . date('Y') . ' 00:00:00'))));
                     break;
             }
             $fields["due_date_dateformat"] = $formated_date;
             //print_r($fields);exit;
             $evtcl->updateParam("fields", $fields);
         } else {
             $fields["due_date_dateformat"] = '0000-00-00';
             $evtcl->updateParam("fields", $fields);
         }
     } elseif ($sp_date_sel_hidden == "Yes") {
         $formated_date = $fields["due_date_dateformat"];
         $today = date("Y-m-d");
         if ($formated_date == '0000-00-00' || $formated_date == '' || empty($formated_date)) {
             $return_string = 'Later';
         } else {
             $difference = strtotime($formated_date) - strtotime($today);
             $date_diff = round($difference / 60 / 60 / 24, 0);
             if ($date_diff < 0) {
                 $return_string = 'Today';
             } elseif ($date_diff == 0) {
                 $return_string = 'Today';
             } elseif ($date_diff == 1) {
                 $return_string = 'Tomorrow';
             } elseif ($date_diff >= 2 && $date_diff < 8) {
                 $return_string = 'This week';
             } elseif ($date_diff > 7 && $date_diff < 15) {
                 $return_string = 'Next week';
             } elseif ($date_diff > 15) {
                 $return_string = 'Later';
             }
         }
         $fields["is_sp_date_set"] = "Yes";
         $fields["due_date"] = $return_string;
         //print_r($fields);exit;
         $evtcl->updateParam("fields", $fields);
     }
 }