Improvements in the system emailing, refactoring part 1
This commit is contained in:
@@ -4820,44 +4820,10 @@ class Cases
|
||||
$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 (!class_exists('System')) {
|
||||
G::LoadClass('system');
|
||||
}
|
||||
$aConfiguration = System::getEmailConfiguration();
|
||||
|
||||
if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
|
||||
return false;
|
||||
@@ -5022,22 +4988,8 @@ class Cases
|
||||
|
||||
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->setConfig($aConfiguration);
|
||||
$oSpool->create(array(
|
||||
"msg_uid" => "",
|
||||
"app_uid" => $sApplicationUID,
|
||||
|
||||
@@ -169,6 +169,30 @@ class spoolRun
|
||||
*/
|
||||
public function setConfig ($aConfig)
|
||||
{
|
||||
// Processing password
|
||||
$passwd = isset($aConfig['MESS_PASSWORD']) ? $aConfig['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);
|
||||
}
|
||||
}
|
||||
$aConfig['MESS_PASSWORD'] = $passwd;
|
||||
|
||||
// Validating authorization flag
|
||||
if (isset($aConfig['MESS_RAUTH'])) {
|
||||
if ($aConfig['MESS_RAUTH'] == false || (is_string($aConfig['MESS_RAUTH']) && $aConfig['MESS_RAUTH'] == 'false')) {
|
||||
$aConfig['MESS_RAUTH'] = 0;
|
||||
} else {
|
||||
$aConfig['MESS_RAUTH'] = 1;
|
||||
}
|
||||
} else {
|
||||
$aConfig['MESS_RAUTH'] = 0;
|
||||
}
|
||||
$this->config = $aConfig;
|
||||
}
|
||||
|
||||
@@ -564,41 +588,15 @@ class spoolRun
|
||||
*/
|
||||
public function resendEmails ($dateResend = null, $cron = 0)
|
||||
{
|
||||
require_once ("classes/model/Configuration.php");
|
||||
|
||||
$oConfiguration = new Configuration();
|
||||
|
||||
$aConfiguration = $oConfiguration->load( "Emails", "", "", "", "" );
|
||||
|
||||
$aConfiguration = unserialize( $aConfiguration["CFG_VALUE"] );
|
||||
if (!isset($aConfiguration["MESS_ENABLED"])) {
|
||||
$aConfiguration["MESS_ENABLED"] = 0;
|
||||
if (!class_exists('System')) {
|
||||
G::LoadClass('system');
|
||||
}
|
||||
$passwd = isset($aConfiguration["MESS_PASSWORD"]) ? $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;
|
||||
$aConfiguration = System::getEmailConfiguration();
|
||||
|
||||
if ($aConfiguration["MESS_ENABLED"] == "1") {
|
||||
require_once ("classes/model/AppMessage.php");
|
||||
if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) {
|
||||
$aConfiguration['MESS_RAUTH'] = 0;
|
||||
} else {
|
||||
$aConfiguration['MESS_RAUTH'] = 1;
|
||||
}
|
||||
|
||||
$this->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"],"SMTPSecure" => $aConfiguration["SMTPSecure"]
|
||||
) );
|
||||
$this->setConfig($aConfiguration);
|
||||
|
||||
$criteria = new Criteria( "workflow" );
|
||||
$criteria->add( AppMessagePeer::APP_MSG_STATUS, "sent", Criteria::NOT_EQUAL );
|
||||
|
||||
@@ -915,42 +915,17 @@ class wsBase
|
||||
$delIndex = 0
|
||||
) {
|
||||
try {
|
||||
G::LoadClass("system");
|
||||
|
||||
if (!class_exists('System')) {
|
||||
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']
|
||||
)
|
||||
);
|
||||
|
||||
$oSpool->setConfig($aSetup);
|
||||
|
||||
$oCase = new Cases();
|
||||
|
||||
$oldFields = $oCase->loadCase( $caseId );
|
||||
|
||||
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP;
|
||||
|
||||
@@ -130,38 +130,10 @@ class AppNotes extends BaseAppNotes
|
||||
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 (!class_exists('System')) {
|
||||
G::LoadClass('system');
|
||||
}
|
||||
$aConfiguration = System::getEmailConfiguration();
|
||||
|
||||
if (! isset( $aConfiguration['MESS_ENABLED'] ) || $aConfiguration['MESS_ENABLED'] != '1') {
|
||||
return false;
|
||||
@@ -214,13 +186,8 @@ class AppNotes extends BaseAppNotes
|
||||
|
||||
$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->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();
|
||||
|
||||
@@ -36,13 +36,13 @@ if ($actionAjax == 'messageHistoryGridList_JXP') {
|
||||
|
||||
G::LoadClass( 'case' );
|
||||
G::LoadClass( "BasePeer" );
|
||||
|
||||
$dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'ASC';
|
||||
|
||||
$dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'ASC';
|
||||
$sort = isset( $_POST['sort'] ) ? $_POST['sort'] : '';
|
||||
|
||||
global $G_PUBLISH;
|
||||
$oCase = new Cases();
|
||||
$oCase->dir = $dir;
|
||||
$oCase->dir = $dir;
|
||||
$oCase->sort = $sort;
|
||||
|
||||
$appMessageArray = $oCase->getHistoryMessagesTrackerExt( $_SESSION['APPLICATION'], true, $_REQUEST['start'], $_REQUEST['limit']);
|
||||
@@ -179,41 +179,13 @@ if ($actionAjax == 'sendMailMessage_JXP') {
|
||||
$oCase = new Cases();
|
||||
$data = $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] );
|
||||
|
||||
G::LoadClass("system");
|
||||
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']
|
||||
)
|
||||
);
|
||||
|
||||
$oSpool->setConfig($aSetup);
|
||||
$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();
|
||||
|
||||
@@ -12,7 +12,7 @@ $user = new Users();
|
||||
$userData = $rbacUser->getByUsername($data['USR_USERNAME']);
|
||||
|
||||
if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'] && $userData['USR_AUTH_TYPE'] === '' ) {
|
||||
$aSetup = getEmailConfiguration();
|
||||
$aSetup = System::getEmailConfiguration();
|
||||
if (count($aSetup) == 0 || !isset($aSetup['MESS_ENGINE'])) {
|
||||
G::SendTemporalMessage ('ID_EMAIL_ENGINE_IS_NOT_ENABLED', "warning");
|
||||
G::header('location: forgotPassword');
|
||||
@@ -27,7 +27,7 @@ if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'
|
||||
$rbacUser->update($aData);
|
||||
$user->update($aData);
|
||||
*/
|
||||
|
||||
|
||||
if (trim($aSetup["MESS_FROM_NAME"]) === '') {
|
||||
$aSetup["MESS_FROM_NAME"] = 'PROCESSMAKER';
|
||||
}
|
||||
@@ -40,7 +40,7 @@ if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'
|
||||
$sFrom = $aSetup["MESS_FROM_NAME"] . " <" . $aSetup["MESS_ACCOUNT"] . ">";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sSubject = G::LoadTranslation('ID_RESET_PASSWORD').' - ProcessMaker' ;
|
||||
$msg = '<h3>ProcessMaker Forgot password Service</h3>';
|
||||
$msg .='<p>'.G::LoadTranslation('ID_YOUR_USERMANE_IS').' : <strong>'.$userData['USR_USERNAME'].'</strong></p>';
|
||||
@@ -67,36 +67,10 @@ if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'
|
||||
</tr></tbody></table>";
|
||||
|
||||
G::LoadClass('spool');
|
||||
|
||||
$oSpool = new spoolRun();
|
||||
if ($aSetup['MESS_RAUTH'] == false || (is_string($aSetup['MESS_RAUTH']) && $aSetup['MESS_RAUTH'] == 'false')) {
|
||||
$aSetup['MESS_RAUTH'] = 0;
|
||||
} else {
|
||||
$aSetup['MESS_RAUTH'] = 1;
|
||||
}
|
||||
$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'],
|
||||
'SMTPSecure' => $aSetup['SMTPSecure']
|
||||
));
|
||||
|
||||
$passwd = $oSpool->config['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);
|
||||
}
|
||||
}
|
||||
|
||||
$oSpool->config['MESS_PASSWORD'] = $passwd;
|
||||
|
||||
$oSpool->setConfig($aSetup);
|
||||
$oSpool->create(array(
|
||||
'msg_uid' => '',
|
||||
'app_uid' => '',
|
||||
|
||||
Reference in New Issue
Block a user