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