Exemplo n.º 1
0
 function emailMessage()
 {
     Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
     $email_to_arr = $this->getEmailMessageAddresses();
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
     global $current_user, $config_vars;
     if (is_object($current_user) and $current_user->getWorkEmail() != '') {
         $reply_to = $current_user->getWorkEmail();
     }
     Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
     $to = array_shift($email_to_arr);
     Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
     $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
     $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
     if ($this->getSubject() != '') {
         $email_body .= TTi18n::gettext('Subject:') . ' ' . $this->getSubject() . "\n";
     }
     $protocol = 'http';
     if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
         $protocol .= 's';
     }
     $email_body .= TTi18n::gettext('Link') . ': <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::getText('Login') . '</a>';
     //Define subject/body variables here.
     $search_arr = array('#employee_first_name#', '#employee_last_name#');
     $replace_arr = array(NULL, NULL);
     $subject = str_replace($search_arr, $replace_arr, $email_subject);
     Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
         return TRUE;
     }
     return TRUE;
     //Always return true
 }
Exemplo n.º 2
0
 function emailException($u_obj, $user_date_obj, $punch_obj = NULL, $schedule_obj = NULL, $ep_obj = NULL)
 {
     global $config_vars;
     if (!is_object($u_obj)) {
         return FALSE;
     }
     if (!is_object($user_date_obj)) {
         return FALSE;
     }
     if (!is_object($ep_obj)) {
         $ep_obj = $this->getExceptionPolicyObject();
     }
     //Only email on active exceptions.
     if ($this->getType() != 50) {
         return FALSE;
     }
     $email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj);
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     $from = 'DoNotReply@' . Misc::getHostName(FALSE);
     $to = array_shift($email_to_arr);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     Debug::Text('To: ' . $to . ' Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
     $protocol = 'http';
     if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
         $protocol .= 's';
     }
     //Define subject/body variables here.
     $search_arr = array('#employee_first_name#', '#employee_last_name#', '#employee_default_branch#', '#employee_default_department#', '#employee_group#', '#employee_title#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#company_name#', '#link#', '#schedule_start_time#', '#schedule_end_time#', '#schedule_branch#', '#schedule_department#', '#punch_time#');
     $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getStartTime()) : NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getEndTime()) : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getBranchObject())) ? $schedule_obj->getBranchObject()->getName() : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getDepartmentObject())) ? $schedule_obj->getDepartmentObject()->getName() : NULL, is_object($punch_obj) ? TTDate::getDate('TIME', $punch_obj->getTimeStamp()) : NULL);
     $exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#';
     $exception_email_body = TTi18n::gettext('Employee') . ': #employee_first_name# #employee_last_name#' . "\n";
     $exception_email_body .= TTi18n::gettext('Date') . ': #date#' . "\n";
     $exception_email_body .= TTi18n::gettext('Exception') . ': #exception_name# (#exception_code#)' . "\n";
     $exception_email_body .= TTi18n::gettext('Severity') . ': #exception_severity#' . "\n";
     $exception_email_body .= ($replace_arr[12] != '' or $replace_arr[13] != '' or $replace_arr[14] != '' or $replace_arr[15] != '' or $replace_arr[16] != '') ? "\n" : NULL;
     $exception_email_body .= ($replace_arr[12] != '' and $replace_arr[13] != '') ? TTi18n::gettext('Schedule') . ': #schedule_start_time# - #schedule_end_time#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[14] != '' ? TTi18n::gettext('Schedule Branch') . ': #schedule_branch#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[15] != '' ? TTi18n::gettext('Schedule Department') . ': #schedule_department#' . "\n" : NULL;
     if ($replace_arr[16] != '') {
         $exception_email_body .= TTi18n::gettext('Punch') . ': #punch_time#' . "\n";
     } elseif ($replace_arr[12] != '' and $replace_arr[13] != '') {
         $exception_email_body .= TTi18n::gettext('Punch') . ': ' . TTi18n::gettext('None') . "\n";
     }
     $exception_email_body .= ($replace_arr[2] != '' or $replace_arr[3] != '' or $replace_arr[4] != '' or $replace_arr[5] != '') ? "\n" : NULL;
     $exception_email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #employee_default_branch#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #employee_default_department#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #employee_group#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #employee_title#' . "\n" : NULL;
     $exception_email_body .= "\n";
     $exception_email_body .= TTi18n::gettext('Link:') . ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
     $exception_email_body .= $replace_arr[10] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
     //Always put at the end
     $exception_email_body .= "\n\n" . TTi18n::gettext('Email sent') . ': ' . TTDate::getDate('DATE+TIME', time()) . "\n";
     $subject = str_replace($search_arr, $replace_arr, $exception_email_subject);
     //Debug::Text('Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception') . ': ' . Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')) . ' To: ' . $to . ' Bcc: ' . $headers['Bcc'], $u_obj->getID(), $this->getTable());
         //Make sure this log entry is assigned to the user triggering the exception so it can be viewed in the audit log.
     }
     return TRUE;
 }
 function emailMessage()
 {
     Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
     $email_to_arr = $this->getEmailMessageAddresses();
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     //Get from User Object so we can include more information in the message.
     if (is_object($this->getFromUserObject())) {
         $u_obj = $this->getFromUserObject();
     } else {
         Debug::Text('From object does not exist: ' . $this->getFromUserID(), __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
     global $current_user, $config_vars;
     if (is_object($current_user) and $current_user->getWorkEmail() != '') {
         $reply_to = $current_user->getWorkEmail();
     }
     Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
     $to = array_shift($email_to_arr);
     Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     Debug::Text('Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
     //Define subject/body variables here.
     $search_arr = array('#from_employee_first_name#', '#from_employee_last_name#', '#from_employee_default_branch#', '#from_employee_default_department#', '#from_employee_group#', '#from_employee_title#', '#company_name#', '#link#');
     $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL);
     $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
     $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
     $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
     $email_body .= $this->getSubject() != '' ? TTi18n::gettext('Subject') . ': ' . $this->getSubject() . "\n" : NULL;
     $email_body .= TTi18n::gettext('From') . ': #from_employee_first_name# #from_employee_last_name#' . "\n";
     $email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #from_employee_default_branch#' . "\n" : NULL;
     $email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #from_employee_default_department#' . "\n" : NULL;
     $email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #from_employee_group#' . "\n" : NULL;
     $email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #from_employee_title#' . "\n" : NULL;
     $email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
     $email_body .= $replace_arr[6] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
     //Always put at the end
     $subject = str_replace($search_arr, $replace_arr, $email_subject);
     Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
         return TRUE;
     }
     return TRUE;
     //Always return true
 }
Exemplo n.º 4
0
     $ulf = TTnew('UserListFactory');
     $ulf->getByPasswordResetKey($key);
     if ($ulf->getRecordCount() == 1) {
         Debug::Text('FOUND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10);
         $user_obj = $ulf->getCurrent();
         $user_name = $user_obj->getUserName();
         //Make sure passwords match
         if ($password == $password2) {
             //Change password
             $user_obj->setPassword($password);
             $user_obj->setPasswordResetKey('');
             $user_obj->setPasswordResetDate('');
             if ($user_obj->isValid()) {
                 $user_obj->Save();
                 Debug::Text('Password Change succesful!', __FILE__, __LINE__, __METHOD__, 10);
                 Redirect::Page(URLBuilder::getURL(array('password_reset' => 1), Environment::getDefaultInterfaceBaseURL()));
             }
         } else {
             $validator->isTrue('password', FALSE, TTi18n::getText('Passwords do not match'));
         }
     } else {
         Debug::Text('DID NOT FIND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10);
         $action = 'reset_password';
     }
     break;
 case 'password_reset':
     //Debug::setVerbosity( 11 );
     Debug::Text('Key: ' . $key, __FILE__, __LINE__, __METHOD__, 10);
     $ulf = TTnew('UserListFactory');
     $ulf->getByPasswordResetKey($key);
     if ($ulf->getRecordCount() == 1) {