/** * send message * * @param string $caseId * @param string $sFrom * @param string $sTo * @param string $sCc * @param string $sBcc * @param string $sSubject * @param string $sTemplate * @param $appFields = null * @param $aAttachment = null * @param boolean $showMessage = true * @param int $delIndex = 0 * @param $config = array * @return $result will return an object */ public function sendMessage( $caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true, $delIndex = 0, $config = array() ) { try { if (!class_exists('System')) { G::LoadClass('system'); } /*----------------------------------********---------------------------------*/ $aSetup = System::getEmailConfiguration(); /*----------------------------------********---------------------------------*/ $msgError = ""; if(sizeof($aSetup) == 0){ $msgError = "The default configuration wasn't defined"; } $oSpool = new spoolRun(); $oSpool->setConfig($aSetup); $oCase = new Cases(); $oldFields = $oCase->loadCase( $caseId ); $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $sTemplate; G::mk_dir( $pathEmail, 0777, true ); if (! file_exists( $fileTemplate )) { $data['FILE_TEMPLATE'] = $fileTemplate; $result = new wsResponse( 28, G::LoadTranslation( 'ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data ) ); return $result; } if ($appFields == null) { $Fields = $oldFields['APP_DATA']; } else { $Fields = array_merge( $oldFields['APP_DATA'], $appFields ); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $Fields, false); $sFrom = G::buildFrom($aSetup, $sFrom); $showMessage = ($showMessage) ? 1 : 0 ; $messageArray = array( "msg_uid" => "", "app_uid" => $caseId, "del_index" => $delIndex, "app_msg_type" => "TRIGGER", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => $sBcc, "app_msg_attach" => $aAttachment, "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_show_message" => $showMessage, "app_msg_error" => $msgError, "contentTypeIsHtml" => (preg_match("/^.+\.html?$/i", $fileTemplate))? true : false ); $oSpool->create( $messageArray ); $oSpool->sendMail(); if ($oSpool->status == 'sent') { $result = new wsResponse( 0, G::loadTranslation( 'ID_MESSAGE_SENT' ) . ": " . $sTo ); } else { $result = new wsResponse( 29, $oSpool->status . ' ' . $oSpool->error . print_r( $aSetup, 1 ) ); } return $result; } catch (Exception $e) { return new wsResponse( 100, $e->getMessage() ); } }
$passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $aSetup['MESS_PASSWORD'] = $passwd; if ($aSetup['MESS_RAUTH'] == false || is_string($aSetup['MESS_RAUTH']) && $aSetup['MESS_RAUTH'] == 'false') { $aSetup['MESS_RAUTH'] = 0; } else { $aSetup['MESS_RAUTH'] = 1; } $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aSetup['MESS_ENGINE'], 'MESS_SERVER' => $aSetup['MESS_SERVER'], 'MESS_PORT' => $aSetup['MESS_PORT'], 'MESS_ACCOUNT' => $aSetup['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aSetup['MESS_PASSWORD'], 'SMTPSecure' => $aSetup['SMTPSecure'], 'SMTPAuth' => $aSetup['MESS_RAUTH'])); $oSpool->create(array('msg_uid' => $data['MSG_UID'], 'app_uid' => $data['APP_UID'], 'del_index' => $data['DEL_INDEX'], 'app_msg_type' => $data['APP_MSG_TYPE'], 'app_msg_subject' => $data['APP_MSG_SUBJECT'], 'app_msg_from' => $data['APP_MSG_FROM'], 'app_msg_to' => $data['APP_MSG_TO'], 'app_msg_body' => $data['APP_MSG_BODY'], 'app_msg_cc' => $data['APP_MSG_CC'], 'app_msg_bcc' => $data['APP_MSG_BCC'], 'app_msg_attach' => $data['APP_MSG_ATTACH'], 'app_msg_template' => $data['APP_MSG_TEMPLATE'], 'app_msg_status' => 'pending')); $oSpool->sendMail(); break; /* @Author Erik Amaru Ortiz <*****@*****.**> */ /* @Author Erik Amaru Ortiz <*****@*****.**> */ case 'showdebug': $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('view', 'cases/showDebugFrame'); G::RenderPage('publish', 'raw'); break; /* @Author Erik Amaru Ortiz <*****@*****.**> */ /* @Author Erik Amaru Ortiz <*****@*****.**> */ case 'reassignByUserList': $APP_UIDS = explode(',', $_POST['APP_UIDS']); $sReassignFromUser = $_POST['FROM_USR_ID']; G::LoadClass('tasks'); G::LoadClass('groups');
public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "") { try { require_once 'classes/model/Configuration.php'; $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration['CFG_VALUE']); $passwd = $aConfiguration['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $aConfiguration['MESS_PASSWORD'] = $passwd; } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } $oUser = new Users(); $aUser = $oUser->load($usrUid); $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; G::LoadClass('case'); $oCase = new Cases(); $aFields = $oCase->loadCase($appUid); $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE "; $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}"; /* if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } */ if (isset($aConfiguration['MESS_FROM_NAME']) && $aConfiguration['MESS_FROM_NAME'] != '') { $sFrom = $aConfiguration['MESS_FROM_NAME']; } $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match); if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) { if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } } $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields); $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields)); G::LoadClass('spool'); $oUser = new Users(); $recipientsArray = explode(",", $noteRecipients); foreach ($recipientsArray as $recipientUid) { $aUser = $oUser->load($recipientUid); $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') { $aConfiguration['MESS_RAUTH'] = 0; } else { $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : '')); $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending')); if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') { $oSpool->sendMail(); } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "") { try { $applicationData = $this->loadCase($sApplicationUID); $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"]; if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); $msgError = ""; if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msgError = "The default configuration wasn't defined"; $aConfiguration['MESS_ENGINE'] = ''; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } $sFrom = G::buildFrom($aConfiguration, $sFrom); if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations; $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "" ) { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { throw (new Exception("Template file \"$fileTemplate\" does not exist.")); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields, false); } else { $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields, false)); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($aTasks as $aTask) { $sTo = null; $sCc = null; switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ( (($row["USR_FIRSTNAME"] != "") || ($row["USR_LASTNAME"] != "")) ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "" ) . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . (($cc != null) ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ( (($aUser["USR_FIRSTNAME"] != "") || ($aUser["USR_LASTNAME"] != "")) ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "" ) . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array( "msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_error" => $msgError )); if ($msgError == '') { if (($aConfiguration["MESS_BACKGROUND"] == "") || ($aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") ) { $oSpool->sendMail(); } } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
/** * * @url POST /forwardMail */ public function forwardMail($params) { if (!isset($_REQUEST['REQ_UID'])) { $_REQUEST['REQ_UID'] = ''; } $criteria = new Criteria(); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID); $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID); $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_UID); $criteria->addSelectColumn(AbeRequestsPeer::APP_UID); $criteria->addSelectColumn(AbeRequestsPeer::DEL_INDEX); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_SENT_TO); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_SUBJECT); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_BODY); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_ANSWERED); $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_STATUS); $criteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $criteria->add(AbeRequestsPeer::ABE_REQ_UID, $_REQUEST['REQ_UID']); $criteria->addJoin(AbeRequestsPeer::ABE_UID, AbeConfigurationPeer::ABE_UID); $criteria->addJoin(AppDelegationPeer::APP_UID, AbeRequestsPeer::APP_UID); $criteria->addJoin(AppDelegationPeer::DEL_INDEX, AbeRequestsPeer::DEL_INDEX); $resultRes = AbeRequestsPeer::doSelectRS($criteria); $resultRes->setFetchmode(ResultSet::FETCHMODE_ASSOC); $resultRes->next(); $dataRes = Array(); if ($dataRes = $resultRes->getRow()) { if (is_null($dataRes['DEL_FINISH_DATE'])) { require_once 'classes/model/Configuration.php'; G::LoadClass('spool'); $configuration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $criteria = new Criteria('workflow'); $criteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $criteria->add(ConfigurationPeer::OBJ_UID, ''); $criteria->add(ConfigurationPeer::PRO_UID, ''); $criteria->add(ConfigurationPeer::USR_UID, ''); $criteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($criteria) == 0) { $configuration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $newConfiguration = array(); } else { $newConfiguration = $configuration->load('Emails', '', '', '', ''); if ($newConfiguration['CFG_VALUE'] != '') { $newConfiguration = unserialize($newConfiguration['CFG_VALUE']); } else { $newConfiguration = array(); } } $spool = new spoolRun(); $spool->setConfig(array( 'MESS_ENGINE' => $newConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $newConfiguration['MESS_SERVER'], 'MESS_PORT' => $newConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $newConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $newConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $newConfiguration['MESS_RAUTH'] )); $spool->create(array( 'msg_uid' => '', 'app_uid' => $dataRes['APP_UID'], 'del_index' => $dataRes['DEL_INDEX'], 'app_msg_type' => 'TEST', 'app_msg_subject' => $dataRes['ABE_REQ_SUBJECT'], 'app_msg_from' => $newConfiguration['MESS_ACCOUNT'], 'app_msg_to' => $dataRes['ABE_REQ_SENT_TO'], 'app_msg_body' => $dataRes['ABE_REQ_BODY'], 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending' )); if ($spool->sendMail()) { $dataRes['ABE_REQ_STATUS'] = 'SENT'; $message = 'The email was resend to: ' . $dataRes['ABE_REQ_SENT_TO']; } else { $dataRes['ABE_REQ_STATUS'] = 'ERROR'; $message = 'There was a problem sending the email to: ' . $dataRes['ABE_REQ_SENT_TO'] . ', please try later.'; } try { $abeRequestsInstance = new AbeRequests(); $abeRequestsInstance->createOrUpdate($dataRes); } catch (Exception $error) { throw $error; } } else { $message = 'Unable to send email, the task is closed.'; } } else { $message = 'An unexpected error occurred please try again later.'; } return $message; }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "") { try { $applicationData = $this->loadCase($sApplicationUID); $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"]; $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]); $passwd = $aConfiguration["MESS_PASSWORD"]; $passwdDec = G::decrypt($passwd, "EMAILENCRYPT"); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $aConfiguration["MESS_PASSWORD"] = $passwd; } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match); if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) { if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } } if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { throw new Exception("Template file \"{$fileTemplate}\" does not exist."); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields); } else { $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields)); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($aTasks as $aTask) { $sTo = null; $sCc = null; switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . "unassignedMessage.html"; if (!file_exists($fileTemplate)) { @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') { $aConfiguration['MESS_RAUTH'] = 0; } else { $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : "")); $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending")); if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") { $oSpool->sendMail(); } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
function sendTestMail() { G::LoadClass("system"); $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>'; $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT'); $msg = G::LoadTranslation('ID_MESS_TEST_BODY'); switch ($_POST['MESS_ENGINE']) { case 'MAIL': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1'); break; case 'PHPMAILER': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2'); break; case 'OPENMAIL': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3'); break; } $sBody = "\n <table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>\n <tbody><tr><td><img id='logo' src='http://" . $_SERVER['SERVER_NAME'] . "/images/processmaker.logo.jpg' /></td></tr>\n <tr><td style='font-size: 14px;'>{$msg} [" . date('H:i:s') . "] - {$engine}</td></tr>\n <tr><td style='vertical-align:middel;'>\n <br /><hr><b>This Business Process is powered by ProcessMaker ver. " . System::getVersion() . ".<b><br />\n <a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>\n </tr></tbody></table>"; G::LoadClass('spool'); $oSpool = new spoolRun(); $passwd = $_POST['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $_POST['MESS_PASSWORD'] = $passwd; $oSpool->setConfig(array('MESS_ENGINE' => $_POST['MESS_ENGINE'], 'MESS_SERVER' => $_POST['MESS_SERVER'], 'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], 'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPSecure' => isset($_POST['SMTPSecure']) ? $_POST['SMTPSecure'] : 'none')); $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $_POST['TO'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => '')); $oSpool->sendMail(); global $G_PUBLISH; $G_PUBLISH = new Publisher(); if ($oSpool->status == 'sent') { $o->status = true; $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS'); } else { $o->status = false; $o->msg = $oSpool->error; } return $o; }
/** * for send email configuration * @autor Alvaro <*****@*****.**> */ public function sendTestMail() { global $G_PUBLISH; G::LoadClass("system"); G::LoadClass('spool'); $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>'; $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT'); $msg = G::LoadTranslation('ID_MESS_TEST_BODY'); switch ($_POST['MESS_ENGINE']) { case 'MAIL': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1'); break; case 'PHPMAILER': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2'); break; case 'OPENMAIL': $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3'); break; } $sBodyPre = new TemplatePower(PATH_TPL . 'admin' . PATH_SEP . 'email.tpl'); $sBodyPre->prepare(); $sBodyPre->assign('server', $_SERVER['SERVER_NAME']); $sBodyPre->assign('date', date('H:i:s')); $sBodyPre->assign('ver', System::getVersion()); $sBodyPre->assign('engine', $engine); $sBodyPre->assign('msg', $msg); $sBody = $sBodyPre->getOutputContent(); $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $_POST['MESS_ENGINE'], 'MESS_SERVER' => $_POST['MESS_SERVER'], 'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], 'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPSecure' => isset($_POST['SMTPSecure']) ? $_POST['SMTPSecure'] : 'none')); $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $_POST['TO'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => '')); $oSpool->sendMail(); $G_PUBLISH = new Publisher(); if ($oSpool->status == 'sent') { $o->status = true; $o->success = true; $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS'); } else { $o->status = false; $o->success = false; $o->msg = $oSpool->error; } return $o; }
public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "") { try { if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } $oUser = new Users(); $aUser = $oUser->load($usrUid); $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; G::LoadClass('case'); $oCase = new Cases(); $aFields = $oCase->loadCase($appUid); $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE "; $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}"; $sFrom = G::buildFrom($aConfiguration, $sFrom); $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields); $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields)); G::LoadClass('spool'); $oUser = new Users(); $recipientsArray = explode(",", $noteRecipients); foreach ($recipientsArray as $recipientUid) { $aUser = $oUser->load($recipientUid); $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending')); if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') { $oSpool->sendMail(); } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
/** * send message * * @param string $caseId * @param string $sFrom * @param string $sTo * @param string $sCc * @param string $sBcc * @param string $sSubject * @param string $sTemplate * @param $appFields = null * @param $aAttachment = null * @param boolean $showMessage = true * @param int $delIndex = 0 * @return $result will return an object */ public function sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true, $delIndex = 0) { try { G::LoadClass("system"); $aSetup = System::getEmailConfiguration(); $passwd = $aSetup['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $aSetup['MESS_PASSWORD'] = $passwd; if ($aSetup['MESS_RAUTH'] == false || is_string($aSetup['MESS_RAUTH']) && $aSetup['MESS_RAUTH'] == 'false') { $aSetup['MESS_RAUTH'] = 0; } else { $aSetup['MESS_RAUTH'] = 1; } $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aSetup['MESS_ENGINE'], 'MESS_SERVER' => $aSetup['MESS_SERVER'], 'MESS_PORT' => $aSetup['MESS_PORT'], 'MESS_ACCOUNT' => $aSetup['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aSetup['MESS_PASSWORD'], 'SMTPSecure' => $aSetup['SMTPSecure'], 'SMTPAuth' => $aSetup['MESS_RAUTH'])); $oCase = new Cases(); $oldFields = $oCase->loadCase($caseId); $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $sTemplate; G::mk_dir($pathEmail, 0777, true); if (!file_exists($fileTemplate)) { $data['FILE_TEMPLATE'] = $fileTemplate; $result = new wsResponse(28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data)); return $result; } if ($appFields == null) { $Fields = $oldFields['APP_DATA']; } else { $Fields = array_merge($oldFields['APP_DATA'], $appFields); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $Fields); $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match); if (!$hasEmailFrom || strpos($sFrom, $aSetup['MESS_ACCOUNT']) === false) { $sFrom = '"' . stripslashes($sFrom) . '" <' . $aSetup['MESS_ACCOUNT'] . ">"; } $showMessage = $showMessage ? 1 : 0; $messageArray = array("msg_uid" => "", "app_uid" => $caseId, "del_index" => $delIndex, "app_msg_type" => "TRIGGER", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => $sBcc, "app_msg_attach" => $aAttachment, "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_show_message" => $showMessage, "contentTypeIsHtml" => preg_match("/^.+\\.html?\$/i", $fileTemplate) ? true : false); $oSpool->create($messageArray); $oSpool->sendMail(); if ($oSpool->status == 'sent') { $result = new wsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $sTo); } else { $result = new wsResponse(29, $oSpool->status . ' ' . $oSpool->error . print_r($aSetup, 1)); } return $result; } catch (Exception $e) { return new wsResponse(100, $e->getMessage()); } }
/** * Send a test email * * @param array $arrayData Data * * return array Return array with result of send test mail */ public function sendTestMail(array $arrayData) { try { \G::LoadClass("system"); \G::LoadClass("spool"); $aConfiguration = array("MESS_ENGINE" => $arrayData["MESS_ENGINE"], "MESS_SERVER" => $arrayData["MESS_SERVER"], "MESS_PORT" => (int) $arrayData["MESS_PORT"], "MESS_ACCOUNT" => $arrayData["MESS_ACCOUNT"], "MESS_PASSWORD" => $arrayData["MESS_PASSWORD"], "MESS_FROM_NAME" => $arrayData["FROM_NAME"], "MESS_FROM_MAIL" => $arrayData["FROM_EMAIL"], "MESS_RAUTH" => (int) $arrayData["MESS_RAUTH"], "SMTPSecure" => isset($arrayData["SMTPSecure"]) ? $arrayData["SMTPSecure"] : "none"); $sFrom = \G::buildFrom($aConfiguration); $sSubject = \G::LoadTranslation("ID_MESS_TEST_SUBJECT"); $msg = \G::LoadTranslation("ID_MESS_TEST_BODY"); switch ($arrayData["MESS_ENGINE"]) { case "MAIL": $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_1"); break; case "PHPMAILER": $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_2"); break; case "OPENMAIL": $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_3"); break; } $sBodyPre = new \TemplatePower(PATH_TPL . "admin" . PATH_SEP . "email.tpl"); $sBodyPre->prepare(); $sBodyPre->assign("server", $_SERVER["SERVER_NAME"]); $sBodyPre->assign("date", date("H:i:s")); $sBodyPre->assign("ver", \System::getVersion()); $sBodyPre->assign("engine", $engine); $sBodyPre->assign("msg", $msg); $sBody = $sBodyPre->getOutputContent(); $oSpool = new \spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array("msg_uid" => "", "app_uid" => "", "del_index" => 0, "app_msg_type" => "TEST", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $arrayData["TO"], "app_msg_body" => $sBody, "app_msg_cc" => "", "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_attach" => "")); $oSpool->sendMail(); //Return $arrayTestMailResult = array(); if ($oSpool->status == "sent") { $arrayTestMailResult["status"] = true; $arrayTestMailResult["success"] = true; $arrayTestMailResult["msg"] = \G::LoadTranslation("ID_MAIL_TEST_SUCCESS"); } else { $arrayTestMailResult["status"] = false; $arrayTestMailResult["success"] = false; $arrayTestMailResult["msg"] = $oSpool->error; } return $arrayTestMailResult; } catch (\Exception $e) { throw $e; } }
/** * send message * @param string $caseId * @param string $sFrom * @param string $sTo * @param string $sCc * @param string $sBcc * @param string $sSubject * @param string $sTemplate * @param $appFields = null * @return $result will return an object */ public function sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null) { try { G::loadClass('system'); $aSetup = System::getEmailConfiguration(); $passwd = $aSetup['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); if (strpos($passwdDec, 'hash:') !== false) { list($hash, $pass) = explode(":", $passwdDec); $arrayFrom['MESS_PASSWORD'] = $pass; } $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aSetup['MESS_ENGINE'], 'MESS_SERVER' => $aSetup['MESS_SERVER'], 'MESS_PORT' => $aSetup['MESS_PORT'], 'MESS_ACCOUNT' => $aSetup['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aSetup['MESS_PASSWORD'], 'SMTPAuth' => $aSetup['MESS_RAUTH'])); $oCase = new Cases(); $oldFields = $oCase->loadCase($caseId); $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $sTemplate; G::mk_dir($pathEmail, 0777, true); if (!file_exists($fileTemplate)) { $data['FILE_TEMPLATE'] = $fileTemplate; $result = new wsResponse(28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data)); return $result; } if ($appFields == null) { $Fields = $oldFields['APP_DATA']; } else { $Fields = array_merge($oldFields['APP_DATA'], $appFields); } $templateContents = file_get_contents($fileTemplate); //$sContent = G::unhtmlentities($sContent); $iAux = 0; $iOcurrences = preg_match_all('/\\@(?:([\\>])([a-zA-Z\\_]\\w*)|([a-zA-Z\\_][\\w\\-\\>\\:]*)\\(((?:[^\\\\\\)]*(?:[\\\\][\\w\\W])?)*)\\))((?:\\s*\\[[\'"]?\\w+[\'"]?\\])+)?/', $templateContents, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); if ($iOcurrences) { for ($i = 0; $i < $iOcurrences; $i++) { preg_match_all('/@>' . $aMatch[2][$i][0] . '([\\w\\W]*)' . '@<' . $aMatch[2][$i][0] . '/', $templateContents, $aMatch2, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); $sGridName = $aMatch[2][$i][0]; $sStringToRepeat = $aMatch2[1][0][0]; if (isset($Fields[$sGridName])) { if (is_array($Fields[$sGridName])) { $sAux = ''; foreach ($Fields[$sGridName] as $aRow) { $sAux .= G::replaceDataField($sStringToRepeat, $aRow); } } } $templateContents = str_replace('@>' . $sGridName . $sStringToRepeat . '@<' . $sGridName, $sAux, $templateContents); } } $sBody = G::replaceDataField($templateContents, $Fields); $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match); if (!$hasEmailFrom) { $sFrom = $aSetup['MESS_ACCOUNT']; } $messageArray = array('msg_uid' => '', 'app_uid' => $caseId, 'del_index' => 0, 'app_msg_type' => 'TRIGGER', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => $sCc, 'app_msg_bcc' => $sBcc, 'app_msg_attach' => $aAttachment, 'app_msg_template' => '', 'app_msg_status' => 'pending'); $oSpool->create($messageArray); $oSpool->sendMail(); if ($oSpool->status == 'sent') { $result = new wsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $sTo); } else { $result = new wsResponse(29, $oSpool->status . ' ' . $oSpool->error . print_r($aSetup, 1)); } return $result; } catch (Exception $e) { return new wsResponse(100, $e->getMessage()); } }
public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "") { try { require_once 'classes/model/Configuration.php'; $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration['CFG_VALUE']); $passwd = $aConfiguration['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); if (strpos($passwdDec, 'hash:') !== false) { list($hash, $pass) = explode(":", $passwdDec); $aConfiguration['MESS_PASSWORD'] = $pass; } } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } $oUser = new Users(); $aUser = $oUser->load($usrUid); $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; G::LoadClass('case'); $oCase = new Cases(); $aFields = $oCase->loadCase($appUid); $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE "; $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}"; if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields); //erik: new behaviour for messages //G::loadClass('configuration'); //$oConf = new Configurations; //$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); //$conf = $oConf->aConfig; /* if( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE']) && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') { $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE']; if ( ! file_exists ( $fileTemplate ) ) { throw new Exception("Template file '$fileTemplate' does not exist."); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } else {*/ $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields)); /*}*/ G::LoadClass('spool'); $oUser = new Users(); $recipientsArray = explode(",", $noteRecipients); foreach ($recipientsArray as $recipientUid) { $aUser = $oUser->load($recipientUid); $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : '')); $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 1, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending')); if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') { $oSpool->sendMail(); } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
public function sendNotifications($taskUid, $arrayTask, $arrayData, $applicationUid, $delIndex, $from = '') { try { $arrayApplicationData = $this->loadCase($applicationUid); $arrayData['APP_NUMBER'] = $arrayApplicationData['APP_NUMBER']; if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); $msgError = ""; if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msgError = "The default configuration wasn't defined"; $aConfiguration['MESS_ENGINE'] = ''; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($taskUid); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } $from = G::buildFrom($aConfiguration, $from); if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $arrayData); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { $tempale = PATH_CORE . "templates" . PATH_SEP . "mails" . PATH_SEP . "alert_message.html"; $copied = @copy($tempale, $fileTemplate); if ($copied) { $dataTemplate = array("prf_filename" => $conf["TAS_DEF_MESSAGE_TEMPLATE"], "prf_path" => $fileTemplate, "pro_uid" => $aTaskInfo["PRO_UID"], "usr_uid" => "00000000000000000000000000000001", "prf_uid" => G::generateUniqueID(), "prf_type" => "file", "prf_create_date" => date("Y-m-d H:i:s")); $filesManager = new ProcessMaker\BusinessModel\FilesManager(); $filesManager->addProcessFilesManagerInDb($dataTemplate); } else { throw new Exception("Template file \"{$fileTemplate}\" does not exist."); } } $sBody = file_get_contents($fileTemplate); } else { $sBody = nl2br($aTaskInfo['TAS_DEF_MESSAGE']); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($arrayTask as $aTask) { $sTo = null; $sCc = null; if (isset($aTask['DEL_INDEX'])) { $arrayData2 = $arrayData; $appDelegation = AppDelegationPeer::retrieveByPK($applicationUid, $aTask['DEL_INDEX']); if (!is_null($appDelegation)) { $arrayData2['TAS_TITLE'] = Content::load('TAS_TITLE', '', $appDelegation->getTasUid(), SYS_LANG); $arrayData2['DEL_TASK_DUE_DATE'] = $appDelegation->getDelTaskDueDate(); } } else { $arrayData2 = $arrayData; } if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) { $user = new \ProcessMaker\BusinessModel\User(); $arrayUserData = $user->getUser($aTask['USR_UID'], true); $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2, trim($arrayUserData['USR_TIME_ZONE']) != '' ? trim($arrayUserData['USR_TIME_ZONE']) : \ProcessMaker\Util\System::getTimeZone()); } else { $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2); } $sBody2 = G::replaceDataGridField($sBody, $arrayData2, false); switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if (!file_exists($fileTemplate) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } $sBody2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE": $to = null; $cc = null; $sw = 1; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($aTask["TAS_UID"])); if (isset($userFields)) { foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE_VALUE_BASED": $aTaskNext = $oTask->load($aTask["TAS_UID"]); if (isset($aTaskNext["TAS_ASSIGN_VARIABLE"]) && !empty($aTaskNext["TAS_ASSIGN_VARIABLE"])) { $to = null; $cc = null; $sw = 1; $nextTaskAssignVariable = trim($aTaskNext["TAS_ASSIGN_VARIABLE"], " @#"); $arrayUsers = $arrayData[$nextTaskAssignVariable]; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($arrayUsers); foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array("msg_uid" => "", 'app_uid' => $applicationUid, 'del_index' => $delIndex, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, 'app_msg_from' => $from, "app_msg_to" => $sTo, 'app_msg_body' => $sBody2, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_error" => $msgError)); if ($msgError == '') { if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") { $oSpool->sendMail(); } } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = '') { try { $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]); $passwd = $aConfiguration["MESS_PASSWORD"]; $passwdDec = G::decrypt($passwd, "EMAILENCRYPT"); if (strpos($passwdDec, "hash:") !== false) { list($hash, $pass) = explode(":", $passwdDec); $passwd = $pass; } $aConfiguration["MESS_PASSWORD"] = $passwd; } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE']) && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') { $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE']; if (!file_exists($fileTemplate)) { throw new Exception("Template file '{$fileTemplate}' does not exist."); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } else { $sBody = nl2br(G::replaceDataField($aTaskInfo['TAS_DEF_MESSAGE'], $aFields)); } G::LoadClass('spool'); $oUser = new Users(); foreach ($aTasks as $aTask) { if (isset($aTask['USR_UID'])) { $aUser = $oUser->load($aTask['USR_UID']); $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : '')); $oSpool->create(array('msg_uid' => '', 'app_uid' => $sApplicationUID, 'del_index' => $iDelegation, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending')); if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') { $oSpool->sendMail(); } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }