BUG 6544 "Can't send email notification to next assigned..." SOLVED
- When "Assignment rules" is set to "Self service", do not send notifications - Problem solved, the settings made in "Notifications" on a task, is used to send notifications * Available from version 2.0.44
This commit is contained in:
@@ -4440,9 +4440,12 @@ class Cases
|
|||||||
* @param string $sFrom
|
* @param string $sFrom
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = '')
|
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom="")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$applicationData = $this->loadCase($sApplicationUID);
|
||||||
|
$aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];
|
||||||
|
|
||||||
$oConfiguration = new Configuration();
|
$oConfiguration = new Configuration();
|
||||||
$sDelimiter = DBAdapter::getStringDelimiter();
|
$sDelimiter = DBAdapter::getStringDelimiter();
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
@@ -4528,57 +4531,153 @@ class Cases
|
|||||||
$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
|
$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
|
||||||
$conf = $oConf->aConfig;
|
$conf = $oConf->aConfig;
|
||||||
|
|
||||||
if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE'])
|
$pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;
|
||||||
&& $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') {
|
$swtplDefault = 0;
|
||||||
|
$sBody = null;
|
||||||
|
|
||||||
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
|
if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) &&
|
||||||
$fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! file_exists ( $fileTemplate ) ) {
|
$fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];
|
||||||
throw new Exception("Template file '$fileTemplate' does not exist.");
|
|
||||||
|
if (!file_exists($fileTemplate)) {
|
||||||
|
throw (new Exception("Template file \"$fileTemplate\" does not exist."));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
|
$sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
|
||||||
} else {
|
} else {
|
||||||
$sBody = nl2br(G::replaceDataField($aTaskInfo['TAS_DEF_MESSAGE'], $aFields));
|
$sBody = nl2br(G::replaceDataField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields));
|
||||||
}
|
}
|
||||||
|
|
||||||
G::LoadClass('spool');
|
G::LoadClass("tasks");
|
||||||
|
G::LoadClass("groups");
|
||||||
|
G::LoadClass("spool");
|
||||||
|
|
||||||
|
$task = new Tasks();
|
||||||
|
$group = new Groups();
|
||||||
$oUser = new Users();
|
$oUser = new Users();
|
||||||
|
|
||||||
foreach ($aTasks as $aTask) {
|
foreach ($aTasks as $aTask) {
|
||||||
if (isset($aTask['USR_UID'])) {
|
$sTo = null;
|
||||||
$aUser = $oUser->load($aTask['USR_UID']);
|
$sCc = null;
|
||||||
$sTo = (
|
|
||||||
(($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ?
|
switch ($aTask["TAS_ASSIGN_TYPE"]) {
|
||||||
$aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') .
|
case "SELF_SERVICE":
|
||||||
'<' . $aUser['USR_EMAIL'] . '>';
|
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();
|
$oSpool = new spoolRun();
|
||||||
|
|
||||||
$oSpool->setConfig(array(
|
$oSpool->setConfig(array(
|
||||||
'MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],
|
"MESS_ENGINE" => $aConfiguration["MESS_ENGINE"],
|
||||||
'MESS_SERVER' => $aConfiguration['MESS_SERVER'],
|
"MESS_SERVER" => $aConfiguration["MESS_SERVER"],
|
||||||
'MESS_PORT' => $aConfiguration['MESS_PORT'],
|
"MESS_PORT" => $aConfiguration["MESS_PORT"],
|
||||||
'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],
|
"MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"],
|
||||||
'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],
|
"MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"],
|
||||||
'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,
|
"SMTPAuth" => ($aConfiguration["MESS_RAUTH"] == "1")? true : false,
|
||||||
'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''
|
"SMTPSecure" => (isset($aConfiguration["SMTPSecure"]))? $aConfiguration["SMTPSecure"] : ""
|
||||||
));
|
));
|
||||||
|
|
||||||
$oSpool->create(array(
|
$oSpool->create(array(
|
||||||
'msg_uid' => '',
|
"msg_uid" => "",
|
||||||
'app_uid' => $sApplicationUID,
|
"app_uid" => $sApplicationUID,
|
||||||
'del_index' => $iDelegation,
|
"del_index" => $iDelegation,
|
||||||
'app_msg_type' => 'DERIVATION',
|
"app_msg_type" => "DERIVATION",
|
||||||
'app_msg_subject' => $sSubject,
|
"app_msg_subject" => $sSubject,
|
||||||
'app_msg_from' => $sFrom,
|
"app_msg_from" => $sFrom,
|
||||||
'app_msg_to' => $sTo,
|
"app_msg_to" => $sTo,
|
||||||
'app_msg_body' => $sBody,
|
"app_msg_body" => $sBody,
|
||||||
'app_msg_cc' => '',
|
"app_msg_cc" => $sCc,
|
||||||
'app_msg_bcc' => '',
|
"app_msg_bcc" => "",
|
||||||
'app_msg_attach' => '',
|
"app_msg_attach" => "",
|
||||||
'app_msg_template' => '',
|
"app_msg_template" => "",
|
||||||
'app_msg_status' => 'pending'
|
"app_msg_status" => "pending"
|
||||||
));
|
));
|
||||||
if (($aConfiguration['MESS_BACKGROUND'] == '') ||
|
|
||||||
($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
|
if (($aConfiguration["MESS_BACKGROUND"] == "") ||
|
||||||
|
($aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1")
|
||||||
|
) {
|
||||||
$oSpool->sendMail();
|
$oSpool->sendMail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3468,45 +3468,49 @@ class Processes {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProcessFiles($proUid, $type)
|
public function getProcessFiles($proUid, $type)
|
||||||
{
|
{
|
||||||
$filesList = array();
|
$filesList = array();
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'mail': case 'email':
|
case "mail":
|
||||||
$basePath = PATH_DATA_MAILTEMPLATES;
|
case "email":
|
||||||
break;
|
$basePath = PATH_DATA_MAILTEMPLATES;
|
||||||
|
break;
|
||||||
|
case "public":
|
||||||
|
$basePath = PATH_DATA_PUBLIC;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknow Process Files Type \"$type\".");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'public':
|
$dir = $basePath . $proUid . PATH_SEP;
|
||||||
$basePath = PATH_DATA_PUBLIC;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
G::verifyPath($dir, true); //Create if it does not exist
|
||||||
throw new Exception("Unknow Process Files Type '$type'.");
|
|
||||||
|
//Creating the default template (if not exists)
|
||||||
|
if (!file_exists($dir . "alert_message.html")) {
|
||||||
|
@copy(PATH_TPL . "mails" . PATH_SEP . "alert_message.html", $dir . "alert_message.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($dir . "unassignedMessage.html")) {
|
||||||
|
@copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $dir . "unassignedMessage.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = glob($dir . "*.*");
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$fileName = basename($file);
|
||||||
|
|
||||||
|
if ($fileName != "alert_message.html" && $fileName != "unassignedMessage.html") {
|
||||||
|
$filesList[] = array("filepath" => $file, "filename" => $fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = $basePath . $proUid . PATH_SEP;
|
|
||||||
|
|
||||||
G::verifyPath($dir, true); // create if it does not exist.
|
|
||||||
|
|
||||||
// creating the default template (if not exists)
|
|
||||||
if (!file_exists($dir . 'alert_message.html')) {
|
|
||||||
@copy(PATH_TPL . 'mails' . PATH_SEP . 'alert_message.html', $dir . 'alert_message.html');
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = glob($dir . '*.*');
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$fileName = basename($file);
|
|
||||||
|
|
||||||
if ($fileName !== 'alert_message.html') {
|
|
||||||
$filesList[] = array('filepath' => $file, 'filename' => $fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $filesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//end class processes
|
}//end class processes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
24
workflow/engine/templates/mails/unassignedMessage.html
Normal file
24
workflow/engine/templates/mails/unassignedMessage.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<table width="100%" cellpadding="10" cellspacing="0" style="background: #FFFFFF; font: 11px arial, verdana, helvetica, sans-serif;">
|
||||||
|
<tr>
|
||||||
|
<td style="font-size: 14px;">
|
||||||
|
<strong>UNASSIGNED CASE</strong>
|
||||||
|
<hr />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
The case <strong>#@#APP_NUMBER</strong> is available on the unassigned list.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
Note: If you want to claim the case and it is not available on the list, it might be already taken.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<hr />
|
||||||
|
This Business Process is powered by ProcessMaker.
|
||||||
|
<br />
|
||||||
|
<a href="http://www.processmaker.com" style="color: #C40000;">www.processmaker.com</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
Reference in New Issue
Block a user