示例#1
0
 /**
  * Function to send new task email to the particepants
  */
 function eventSendNewTaskEmail(EventControler $event_controler)
 {
     if ($event_controler->insertid > 0) {
         $this->getId($event_controler->insertid);
         $co_workers = $_SESSION["do_project"]->getProjectCoWorkers();
         if ($co_workers !== false) {
             $emailer = new Radria_Emailer();
             $emailer->setEmailTemplate(new EmailTemplate("ofuz_new_project_task"));
             $project_task_url = $GLOBALS['cfg_ofuz_site_http_base'] . 'Task/' . $this->idproject_task;
             $project_url = $GLOBALS['cfg_ofuz_site_http_base'] . 'Project/' . $this->idproject;
             $email_data = array('project-name' => $_SESSION['do_project']->name, 'task-owner' => $_SESSION['do_User']->getFullName(), 'task-name' => $this->task_description, 'project-task-link' => $project_task_url, 'project-link' => $project_url);
             foreach ($co_workers as $co_worker) {
                 $email_data['firstname'] = $co_worker['firstname'];
                 $emailer->mergeArray($email_data);
                 //$this->setLog("\n Sending email to:".$co_worker['email']);
                 $emailer->addTo($co_worker['email']);
                 $emailer->send();
                 $emailer->cleanup();
             }
         }
     }
 }
 /** 
  * eventSendDiscussMessageByEmail
  * This will send an email to all the project participant 
  * Using Radria_Emailer and an email template stored in the emailtemplate table.
  * This method uses the currently open project persistant object. 
  * @param Eventcontroler
  */
 function eventSendDiscussMessageByEmail(EventControler $event_controler)
 {
     $this->setLog("\n eventSendDiscussMessageByEmail: starting (" . date("Y/m/d H:i:s"));
     try {
         $co_workers = $_SESSION["do_project"]->getProjectCoWorkers();
         // print_r($co_workers);exit;
         if ($co_workers !== false) {
             $email_template = new EmailTemplate("ofuz_project_discussion");
             $email_nudge = new EmailTemplate("ofuz_project_discussion_nudge");
             $project_task_url = $GLOBALS['cfg_ofuz_site_http_base'] . 'Task/' . $_SESSION['do_project_task']->idproject_task;
             $project_link = $GLOBALS['cfg_ofuz_site_http_base'] . 'Project/' . $_SESSION['do_project']->idproject;
             if ($event_controler->fields['document'] != '') {
                 // If a file is attached
                 $doc_link = $GLOBALS['cfg_ofuz_site_http_base'] . 'files/' . $event_controler->fields['document'];
                 $doc_text = '<br />' . _('Attachment') . ': <a href="' . $doc_link . '"> ' . $event_controler->fields['document'] . '</a>';
             } else {
                 $doc_text = '';
             }
             $message_html = nl2br(stripslashes($event_controler->fields['discuss'] . $doc_text));
             $message_txt = stripslashes($event_controler->fields['discuss'] . $doc_text);
             $email_data = array('project-name' => $_SESSION['do_project']->name, 'project-link' => $project_link, 'discussion-owner' => $_SESSION['do_User']->getFullName(), 'task_name' => $_SESSION['do_project_task']->task_description, 'task_category' => $_SESSION['do_project_task']->task_category, 'message_txt' => $message_txt, 'message_html' => $message_html, 'project-task-link' => $project_task_url);
             $do_discussion_email_setting = new DiscussionEmailSetting();
             if ($_SESSION['do_project_task']->drop_box_code < 10 || count($co_workers) > 19) {
                 foreach ($co_workers as $co_worker) {
                     $global_email_alert = $_SESSION['UserSettings']->getSettingValue('task_discussion_alert', $co_worker['idcoworker']);
                     $global_email_alert_on = true;
                     if (!$global_email_alert) {
                         $global_email_alert_on = true;
                         // means user has not set on/off in the settings and on by default
                     } else {
                         if (is_array($global_email_alert)) {
                             if ($global_email_alert["setting_value"] == 'Yes') {
                                 $global_email_alert_on = true;
                             } else {
                                 $global_email_alert_on = false;
                             }
                         }
                     }
                     //if($_SESSION['UserSettings']->global_task_discussion_alert  != 'No' && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject,'Project',$co_worker['idcoworker']) ){
                     if ($global_email_alert_on && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject_task, 'Project', $co_worker['idcoworker'])) {
                         $emailer = new Radria_Emailer('UTF-8');
                         $emailer->setEmailTemplate($email_template);
                         //$emailer->cleanup();
                         //$emailer->setFrom('*****@*****.**' , 'Ofuz.net');
                         $email_data['firstname'] = $co_worker['firstname'];
                         $emailer->mergeArray($email_data);
                         $this->setLog("\n Sending email to:" . $co_worker['email']);
                         $emailer->addTo($co_worker['email']);
                         $emailer->send();
                     }
                 }
             } else {
                 $co_workers_nudged = array();
                 $co_workers_nudged_emails = array();
                 foreach ($co_workers as $co_worker) {
                     if (preg_match("/@" . $co_worker['firstname'] . "/i", $event_controler->fields['discuss']) || preg_match("/@" . $co_worker['lastname'] . "/i", $event_controler->fields['discuss'])) {
                         //$co_workers_nudged[] = $co_worker;
                         $co_workers_nudged_emails[] = $co_worker['email'];
                         $this->setLog("\n Is nudged:" . $co_worker['firstname'] . " " . $co_worker['lastname'] . " " . $co_worker['email']);
                     }
                 }
                 $emailer = new Radria_Emailer('UTF-8');
                 $email_template->setSenderName($_SESSION['do_User']->getFullName());
                 $email_template->setSenderEmail($_SESSION['do_User']->email);
                 $emailer->setEmailTemplate($email_template);
                 $emailer->addCc($_SESSION['do_project_task']->getDropBoxEmail());
                 $emailer->addHeader("X-ofuz-emailer", $_SESSION['do_User']->iduser);
                 $emailer->mergeArray($email_data);
                 $this->setLog("\n Sending email to:" . $co_workers[0]['email']);
                 $someone_note_nudged = false;
                 foreach ($co_workers as $to_worker) {
                     /*
                         Check if the Co-Worker is supposed to get the email
                     */
                     $global_email_alert = $_SESSION['UserSettings']->getSettingValue('task_discussion_alert', $to_worker['idcoworker']);
                     $global_email_alert_on = true;
                     if (!$global_email_alert) {
                         $global_email_alert_on = true;
                         //means user has not set on/off in the settings and on by default
                     } else {
                         if (is_array($global_email_alert)) {
                             if ($global_email_alert["setting_value"] == 'Yes') {
                                 $global_email_alert_on = true;
                             } else {
                                 $global_email_alert_on = false;
                             }
                         }
                     }
                     /* if($_SESSION['UserSettings']->global_task_discussion_alert  != 'No' 
                        && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject_task,$to_worker['idcoworker']) 
                        && !in_array($to_worker['email'], $co_workers_nudged_emails)){*/
                     if ($global_email_alert_on && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject, 'Project', $to_worker['idcoworker']) && !in_array($to_worker['email'], $co_workers_nudged_emails)) {
                         $email_to = $to_worker['email'];
                         $emailer->addTo($email_to);
                         $someone_note_nudged = true;
                         break;
                     }
                 }
                 //$emailer->addTo($co_workers[0]['email']);
                 foreach ($co_workers as $cc_worker) {
                     /*
                     Check if the Co-Worker is supposed to get the email
                     */
                     $global_email_alert_on = true;
                     $global_email_alert = $_SESSION['UserSettings']->getSettingValue('task_discussion_alert', $cc_worker['idcoworker']);
                     if (!$global_email_alert) {
                         $global_email_alert_on = true;
                         //means user has not set on/off in the settings and on by default
                     } else {
                         if (is_array($global_email_alert)) {
                             if ($global_email_alert["setting_value"] == 'Yes') {
                                 $global_email_alert_on = true;
                             } else {
                                 $global_email_alert_on = false;
                             }
                         }
                     }
                     if ($email_to != $cc_worker['email']) {
                         /*  if($_SESSION['UserSettings']->global_task_discussion_alert  != 'No' 
                             && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject_task,$cc_worker['idcoworker']) 
                             && !in_array($cc_worker['email'], $co_workers_nudged_emails)){*/
                         if ($global_email_alert_on && !$do_discussion_email_setting->isDiscussionAlertSet($_SESSION['do_project_task']->idproject, 'Project', $cc_worker['idcoworker']) && !in_array($cc_worker['email'], $co_workers_nudged_emails)) {
                             $emailer->addCc($cc_worker['email']);
                             $someone_note_nudged = true;
                         }
                     }
                 }
                 if ($someone_note_nudged) {
                     $emailer->send();
                 }
                 if (count($co_workers_nudged_emails) > 0) {
                     $email_nudge->setSenderName($_SESSION['do_User']->getFullName());
                     $email_nudge->setSenderEmail($_SESSION['do_User']->email);
                     $emailer_nudge = new Radria_Emailer();
                     $emailer_nudge->setEmailTemplate($email_nudge);
                     $emailer_nudge->addCc($_SESSION['do_project_task']->getDropBoxEmail());
                     $emailer_nudge->addHeader("X-ofuz-emailer", $_SESSION['do_User']->iduser);
                     $emailer_nudge->mergeArray($email_data);
                     $emailer_nudge->addTo($co_workers_nudged_emails[0]);
                     $this->setLog("\n Sending Nudge to:" . $co_workers_nudged_emails[0]);
                     for ($i = 1; $i < count($co_workers_nudged_emails); $i++) {
                         $this->setLog("\n Sending Nudge to:" . $co_workers_nudged_emails[$i]);
                         $emailer_nudge->addCc($co_workers_nudged_emails[$i]);
                     }
                     $emailer_nudge->send();
                     $emailer_nudge->cleanup();
                 }
                 $emailer->cleanup();
             }
         }
     } catch (Exception $e) {
         $this->setError('ProjectDiscuss Could not send email: ' . $e->getMessage());
     }
     $this->setLog("\n eventSendDiscussMessageByEmail: ending (" . date("Y/m/d H:i:s"));
 }
            } else {
                $text .= '<b> 0:00</b>  Hrs  By ' . $name . '.<br/>';
            }
        }
    }
}
//echo $text;
// send mails to the ofuz users with their respective worklog
foreach ($admin_emails as $email) {
    $do_template = new EmailTemplate();
    $do_template->senderemail = "*****@*****.**";
    $do_template->sendername = "Ofuz";
    $do_template->subject = "Worklog Summay Of 2 days :";
    $do_template->bodytext = $text;
    $do_template->bodyhtml = $do_template->bodytext;
    //echo $text.'<br />';
    $values = array();
    //Use for sending email here for general users
    $emailer = new Radria_Emailer('UTF-8');
    $emailer->setEmailTemplate($do_template);
    $emailer->mergeArray($values);
    //required even if there is nothig to merge
    $emailer->addTo($email);
    $message_sent = (int) $emailer->send();
    $emailer->cleanup();
    //$text = '';
}
/*if($message_sent==1) 
 {
     echo "Notification Sent Successfully";
 }*/
示例#4
0
 /**
  * Send email for the User Object
  * @param $template -- STRING
  * @param $values -- Array
  * @return Boolean
  */
 function sendMessage($template, $values = array())
 {
     if (!is_object($template)) {
         return false;
     }
     if (empty($values)) {
         $values = $this->getValues();
     }
     $message_sent = false;
     if (strlen($this->email) > 4) {
         //Use for sending email here for general users
         $emailer = new Radria_Emailer('UTF-8');
         $emailer->setEmailTemplate($template);
         $emailer->mergeArray($values);
         //required even if there is nothig to merge
         $emailer->addTo($this->email);
         $emailer->send();
         $emailer->cleanup();
         $message_sent = true;
     } elseif ($this->fb_user_id && $this->global_fb_connected) {
         //echo 'here';
         //echo $template->subject;
         include_once 'facebook_client/facebook.php';
         include_once 'class/OfuzFacebook.class.php';
         $facebook = new Facebook(FACEBOOK_API_KEY, FACEBOOK_APP_SECRET);
         //$do_ofuz_fb =  new OfuzFacebook($facebook);
         try {
             //$facebook->api_client->notifications_sendEmail($this->fb_user_id, $template->subject,'', $template->bodyhtml);
             $message_sent = true;
         } catch (Exception $e) {
         }
     }
     if ($message_sent) {
         return true;
     } else {
         return false;
     }
 }