BUG 8438 8341 " $from parameter for the PMFSendMessage() function .." SOLVED
- Now the user can set from account for PMFSendMessage() function.
This commit is contained in:
@@ -96,18 +96,22 @@ class Configurations // extends Configuration
|
|||||||
{
|
{
|
||||||
if (!(is_object($object) || is_array($object)))
|
if (!(is_object($object) || is_array($object)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!isset($from))
|
if (!isset($from))
|
||||||
$from = &$this->aConfig;
|
$from = &$this->aConfig;
|
||||||
|
|
||||||
foreach($from as $k => $v ) {
|
foreach($from as $k => $v ) {
|
||||||
if (isset($v) && array_key_exists($k,$object)) {
|
if (isset($v) && array_key_exists($k,$object)) {
|
||||||
if (is_object($v))
|
if (is_object($v))
|
||||||
throw new Exception( 'Object is not permited inside configuration array.' );
|
throw new Exception( 'Object is not permited inside configuration array.' );
|
||||||
|
|
||||||
if (is_object($object)) {
|
if (is_object($object)) {
|
||||||
if (is_array($v))
|
if (is_array($v))
|
||||||
$this->configObject($object->{$k}, $v);
|
$this->configObject($object->{$k}, $v);
|
||||||
else
|
else
|
||||||
$object->{$k} = $v;
|
$object->{$k} = $v;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
if (is_array($v))
|
if (is_array($v))
|
||||||
$this->configObject($object[$k], $v);
|
$this->configObject($object[$k], $v);
|
||||||
@@ -130,18 +134,38 @@ class Configurations // extends Configuration
|
|||||||
* @param string $app
|
* @param string $app
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function loadConfig(&$object, $cfg, $obj, $pro = '', $usr = '', $app = '')
|
function loadConfig(&$object, $cfg, $obj='', $pro = '', $usr = '', $app = '')
|
||||||
|
{
|
||||||
|
$this->load($cfg, $obj, $pro, $usr, $app);
|
||||||
|
$this->configObject($object, $this->aConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadConf
|
||||||
|
*
|
||||||
|
* @param string $cfg
|
||||||
|
* @param object $obj
|
||||||
|
* @param string $pro
|
||||||
|
* @param string $usr
|
||||||
|
* @param string $app
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function load($cfg, $obj='', $pro = '', $usr = '', $app = '')
|
||||||
{
|
{
|
||||||
$this->Fields = array();
|
$this->Fields = array();
|
||||||
if ($this->Configuration->exists( $cfg, $obj, $pro, $usr, $app ))
|
|
||||||
$this->Fields = $this->Configuration->load( $cfg, $obj, $pro, $usr, $app );
|
try {
|
||||||
$aConfig = $this->aConfig;
|
$this->Fields = $this->Configuration->load($cfg, $obj, $pro, $usr, $app);
|
||||||
|
}
|
||||||
|
catch(Exception $e) {} // the configuration does not exist
|
||||||
|
|
||||||
if (isset($this->Fields['CFG_VALUE']))
|
if (isset($this->Fields['CFG_VALUE']))
|
||||||
$aConfig = unserialize($this->Fields['CFG_VALUE']);
|
$this->aConfig = unserialize($this->Fields['CFG_VALUE']);
|
||||||
if (!is_array($aConfig))
|
|
||||||
$aConfig = $this->aConfig;
|
if (!is_array($this->aConfig))
|
||||||
$this->aConfig = $aConfig;
|
$this->aConfig = Array();
|
||||||
$this->configObject($object,$this->aConfig);
|
|
||||||
|
return $this->aConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -724,32 +724,10 @@ function WSProcessList() {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//private function to get current email configuration
|
//private function to get current email configuration
|
||||||
function getEmailConfiguration () {
|
function getEmailConfiguration()
|
||||||
require_once 'classes/model/Configuration.php';
|
{
|
||||||
$oConfiguration = new Configuration();
|
G::loadClass('system');
|
||||||
$sDelimiter = DBAdapter::getStringDelimiter();
|
return System::getEmailConfiguration();
|
||||||
$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' => ''));
|
|
||||||
$aFields = array();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$aFields = $oConfiguration->load('Emails', '', '', '', '');
|
|
||||||
if ($aFields['CFG_VALUE'] != '') {
|
|
||||||
$aFields = unserialize($aFields['CFG_VALUE']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$aFields = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $aFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -782,7 +760,8 @@ function PMFSendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplat
|
|||||||
|
|
||||||
if ( $result->status_code == 0) {
|
if ( $result->status_code == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ class spoolRun {
|
|||||||
$this->ExceptionCode['WARNING'] = 2;
|
$this->ExceptionCode['WARNING'] = 2;
|
||||||
$this->ExceptionCode['NOTICE'] = 3;
|
$this->ExceptionCode['NOTICE'] = 3;
|
||||||
|
|
||||||
$this->longMailEreg = '/([\"\w\W\s]*\s*)?(<([\w\-\.]+@[\.-\w]+\.\w{2,3})+>)/';
|
$this->longMailEreg = '/(.*)(<([\w\-\.]+@[\w\-_\.]+\.\w{2,3})+>)/';
|
||||||
$this->mailEreg = '/^([\w\-_\.]+@[\.-\w]+\.\w{2,3}+)$/';
|
$this->mailEreg = '/^([\w\-_\.]+@[\w\-_\.]+\.\w{2,3}+)$/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,8 +220,9 @@ class spoolRun {
|
|||||||
if( isset($matches[1]) && $matches[1] != '' ) {
|
if( isset($matches[1]) && $matches[1] != '' ) {
|
||||||
//drop the " characters if they exist
|
//drop the " characters if they exist
|
||||||
$this->fileData['from_name'] = trim(str_replace('"', '', $matches[1]));
|
$this->fileData['from_name'] = trim(str_replace('"', '', $matches[1]));
|
||||||
} else { //if the from name was not set
|
}
|
||||||
$this->fileData['from_name'] = 'Processmaker';
|
else { //if the from name was not set
|
||||||
|
$this->fileData['from_name'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! isset($matches[3]) ) {
|
if( ! isset($matches[3]) ) {
|
||||||
@@ -229,7 +230,8 @@ class spoolRun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->fileData['from_email'] = trim($matches[3]);
|
$this->fileData['from_email'] = trim($matches[3]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
//to validate simple email address i.e. erik@colosa.com
|
//to validate simple email address i.e. erik@colosa.com
|
||||||
preg_match($this->mailEreg, $this->fileData['from'], $matches);
|
preg_match($this->mailEreg, $this->fileData['from'], $matches);
|
||||||
|
|
||||||
@@ -237,7 +239,7 @@ class spoolRun {
|
|||||||
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
|
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fileData['from_name'] = 'Processmaker Web boot';
|
$this->fileData['from_name'] = '';
|
||||||
$this->fileData['from_email'] = $matches[0];
|
$this->fileData['from_email'] = $matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,10 +329,10 @@ class spoolRun {
|
|||||||
$oPHPMailer->Host = $this->config['MESS_SERVER'];
|
$oPHPMailer->Host = $this->config['MESS_SERVER'];
|
||||||
$oPHPMailer->Port = $this->config['MESS_PORT'];
|
$oPHPMailer->Port = $this->config['MESS_PORT'];
|
||||||
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
|
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
|
||||||
$passwd = $this->config['MESS_PASSWORD'];
|
$passwd = $this->config['MESS_PASSWORD'];
|
||||||
if(strpos( $passwd, 'hush:' ) !== false){
|
if(strpos( $passwd, 'hush:' ) !== false){
|
||||||
list($hush, $pass) = explode(":", $passwd);
|
list($hush, $pass) = explode(":", $passwd);
|
||||||
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
||||||
}
|
}
|
||||||
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
||||||
$oPHPMailer->From = $this->fileData['from_email'];
|
$oPHPMailer->From = $this->fileData['from_email'];
|
||||||
@@ -380,10 +382,10 @@ class spoolRun {
|
|||||||
$oPHPMailer->Host = $this->config['MESS_SERVER'];
|
$oPHPMailer->Host = $this->config['MESS_SERVER'];
|
||||||
$oPHPMailer->Port = $this->config['MESS_PORT'];
|
$oPHPMailer->Port = $this->config['MESS_PORT'];
|
||||||
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
|
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
|
||||||
$passwd = $this->config['MESS_PASSWORD'];
|
$passwd = $this->config['MESS_PASSWORD'];
|
||||||
if(strpos( $passwd, 'hush:' ) !== false){
|
if(strpos( $passwd, 'hush:' ) !== false){
|
||||||
list($hush, $pass) = explode(":", $passwd);
|
list($hush, $pass) = explode(":", $passwd);
|
||||||
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
||||||
}
|
}
|
||||||
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
||||||
$oPHPMailer->From = $this->fileData['from_email'];
|
$oPHPMailer->From = $this->fileData['from_email'];
|
||||||
@@ -465,10 +467,10 @@ class spoolRun {
|
|||||||
$send->setPort($this->config['MESS_PORT']);
|
$send->setPort($this->config['MESS_PORT']);
|
||||||
$send->setUsername($this->config['MESS_ACCOUNT']);
|
$send->setUsername($this->config['MESS_ACCOUNT']);
|
||||||
|
|
||||||
$passwd = $this->config['MESS_PASSWORD'];
|
$passwd = $this->config['MESS_PASSWORD'];
|
||||||
if(strpos( $passwd, 'hush:' ) !== false){
|
if(strpos( $passwd, 'hush:' ) !== false){
|
||||||
list($hush, $pass) = explode(":", $passwd);
|
list($hush, $pass) = explode(":", $passwd);
|
||||||
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
$this->config['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
||||||
}
|
}
|
||||||
$send->setPassword($this->config['MESS_PASSWORD']);
|
$send->setPassword($this->config['MESS_PASSWORD']);
|
||||||
$send->setReturnPath($this->fileData['from_email']);
|
$send->setReturnPath($this->fileData['from_email']);
|
||||||
@@ -498,10 +500,10 @@ class spoolRun {
|
|||||||
$oConfiguration = new Configuration();
|
$oConfiguration = new Configuration();
|
||||||
$aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
|
$aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
|
||||||
$aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
|
$aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
|
||||||
$passwd = $aConfiguration['MESS_PASSWORD'];
|
$passwd = $aConfiguration['MESS_PASSWORD'];
|
||||||
if(strpos( $passwd, 'hush:' ) !== false){
|
if(strpos( $passwd, 'hush:' ) !== false){
|
||||||
list($hush, $pass) = explode(":", $passwd);
|
list($hush, $pass) = explode(":", $passwd);
|
||||||
$aConfiguration['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
$aConfiguration['MESS_PASSWORD'] = G::decrypt($pass,'EMAILENCRYPT');
|
||||||
}
|
}
|
||||||
if( $aConfiguration['MESS_ENABLED'] == '1' ) {
|
if( $aConfiguration['MESS_ENABLED'] == '1' ) {
|
||||||
$this->setConfig(array (
|
$this->setConfig(array (
|
||||||
|
|||||||
@@ -913,4 +913,14 @@ class System {
|
|||||||
return $aChanges;
|
return $aChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getEmailConfiguration()
|
||||||
|
{
|
||||||
|
G::LoadClass('configuration');
|
||||||
|
$conf = new Configurations();
|
||||||
|
$config = $conf->load('Emails');
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
}// end System class
|
}// end System class
|
||||||
|
|||||||
@@ -623,7 +623,10 @@ class wsBase
|
|||||||
*/
|
*/
|
||||||
public function sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null ) {
|
public function sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null ) {
|
||||||
try {
|
try {
|
||||||
$aSetup = getEmailConfiguration();
|
G::loadClass('system');
|
||||||
|
|
||||||
|
$aSetup = System::getEmailConfiguration();
|
||||||
|
|
||||||
$passwd =$aSetup['MESS_PASSWORD'];
|
$passwd =$aSetup['MESS_PASSWORD'];
|
||||||
if(strpos( $passwd, 'hush:' ) !== false)
|
if(strpos( $passwd, 'hush:' ) !== false)
|
||||||
{
|
{
|
||||||
@@ -656,7 +659,8 @@ class wsBase
|
|||||||
|
|
||||||
if ( $appFields == null ) {
|
if ( $appFields == null ) {
|
||||||
$Fields = $oldFields['APP_DATA'];
|
$Fields = $oldFields['APP_DATA'];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$Fields = $appFields;
|
$Fields = $appFields;
|
||||||
}
|
}
|
||||||
$templateContents = file_get_contents ( $fileTemplate );
|
$templateContents = file_get_contents ( $fileTemplate );
|
||||||
@@ -683,11 +687,9 @@ class wsBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sBody = G::replaceDataField( $templateContents, $Fields);
|
$sBody = G::replaceDataField( $templateContents, $Fields);
|
||||||
|
$hasEmailFrom = preg_match('/(.+)@(.+)\.(.+)/', $sFrom, $match);
|
||||||
|
|
||||||
if ($sFrom != '') {
|
if (!$hasEmailFrom) {
|
||||||
$sFrom = $sFrom . ' <' . $aSetup['MESS_ACCOUNT'] . '>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sFrom = $aSetup['MESS_ACCOUNT'];
|
$sFrom = $aSetup['MESS_ACCOUNT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -706,8 +708,10 @@ class wsBase
|
|||||||
'app_msg_template' => '',
|
'app_msg_template' => '',
|
||||||
'app_msg_status' => 'pending'
|
'app_msg_status' => 'pending'
|
||||||
);
|
);
|
||||||
|
|
||||||
$oSpool->create( $messageArray );
|
$oSpool->create( $messageArray );
|
||||||
$oSpool->sendMail();
|
$oSpool->sendMail();
|
||||||
|
|
||||||
if ( $oSpool->status == 'sent' )
|
if ( $oSpool->status == 'sent' )
|
||||||
$result = new wsResponse (0, G::loadTranslation ('ID_MESSAGE_SENT') . ": ". $sTo );
|
$result = new wsResponse (0, G::loadTranslation ('ID_MESSAGE_SENT') . ": ". $sTo );
|
||||||
else
|
else
|
||||||
@@ -716,8 +720,7 @@ class wsBase
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
catch ( Exception $e ) {
|
catch ( Exception $e ) {
|
||||||
$result = new wsResponse (100, $e->getMessage());
|
return new wsResponse (100, $e->getMessage());
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,11 @@
|
|||||||
</MESS_RAUTH>
|
</MESS_RAUTH>
|
||||||
|
|
||||||
<MESS_ACCOUNT type="text" size="35" maxlength="50" validate="Email">
|
<MESS_ACCOUNT type="text" size="35" maxlength="50" validate="Email">
|
||||||
<en>Account From</en>
|
<en>SMTP Username</en>
|
||||||
</MESS_ACCOUNT>
|
</MESS_ACCOUNT>
|
||||||
|
|
||||||
<MESS_PASSWORD type="password" size="35" maxlength="50">
|
<MESS_PASSWORD type="password" size="35" maxlength="50">
|
||||||
<en>Password</en>
|
<en>SMTP Password</en>
|
||||||
</MESS_PASSWORD>
|
</MESS_PASSWORD>
|
||||||
|
|
||||||
<MESS_TEST_MAIL type="checkbox" value="1">
|
<MESS_TEST_MAIL type="checkbox" value="1">
|
||||||
|
|||||||
Reference in New Issue
Block a user