Commit 952e758e505e119cbb070464f928bebdb77324d8

Authored by jjordaan
1 parent 011e9656

KTS-4239 Displays a single message after email failure

Committed By : Jarrett Jordaan

Reviewed by : Paul Barrett
plugins/ktstandard/KTEmail.php
@@ -66,6 +66,7 @@ function sendGroupEmails($aGroupIDs, &$aUserEmails, &$aEmailErrors) { @@ -66,6 +66,7 @@ function sendGroupEmails($aGroupIDs, &$aUserEmails, &$aEmailErrors) {
66 $default->log->info('sendingEmail to group ' . $oDestGroup->getName()); 66 $default->log->info('sendingEmail to group ' . $oDestGroup->getName());
67 // for each group, retrieve all the users 67 // for each group, retrieve all the users
68 foreach($aDestinationGroups as $oGroup){ 68 foreach($aDestinationGroups as $oGroup){
  69 + // Need to only retrieve users that are not diabled.
69 $aUsers = kt_array_merge($aUsers, $oGroup->getUsers()); 70 $aUsers = kt_array_merge($aUsers, $oGroup->getUsers());
70 } 71 }
71 72
@@ -441,7 +442,6 @@ class KTDocumentEmailAction extends KTDocumentAction { @@ -441,7 +442,6 @@ class KTDocumentEmailAction extends KTDocumentAction {
441 function json_getGroups() { 442 function json_getGroups() {
442 $oConfig = KTConfig::getSingleton(); 443 $oConfig = KTConfig::getSingleton();
443 $bOnlyOwnGroup = $oConfig->get('email/onlyOwnGroups', false); 444 $bOnlyOwnGroup = $oConfig->get('email/onlyOwnGroups', false);
444 -  
445 $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false); 445 $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false);
446 $aGroupList = array('off'=> _kt('-- Please filter --')); 446 $aGroupList = array('off'=> _kt('-- Please filter --'));
447 447
@@ -452,7 +452,6 @@ class KTDocumentEmailAction extends KTDocumentAction { @@ -452,7 +452,6 @@ class KTDocumentEmailAction extends KTDocumentAction {
452 } else { 452 } else {
453 $aGroups = GroupUtil::listGroupsForUser($this->oUser, array('where' => $sWhere)); 453 $aGroups = GroupUtil::listGroupsForUser($this->oUser, array('where' => $sWhere));
454 } 454 }
455 -  
456 $aGroupList = array(); 455 $aGroupList = array();
457 foreach($aGroups as $g) { 456 foreach($aGroups as $g) {
458 $aGroupList[$g->getId()] = $g->getName(); 457 $aGroupList[$g->getId()] = $g->getName();
@@ -545,13 +544,12 @@ class KTDocumentEmailAction extends KTDocumentAction { @@ -545,13 +544,12 @@ class KTDocumentEmailAction extends KTDocumentAction {
545 $this->errorRedirectToMain(_kt('No recipients set'), sprintf('fDocumentId=%d', $this->oDocument->getId())); 544 $this->errorRedirectToMain(_kt('No recipients set'), sprintf('fDocumentId=%d', $this->oDocument->getId()));
546 exit(0); 545 exit(0);
547 } 546 }
548 - 547 +
549 $iDocumentID = $this->oDocument->getID(); 548 $iDocumentID = $this->oDocument->getID();
550 $sDocumentName = $this->oDocument->getName(); 549 $sDocumentName = $this->oDocument->getName();
551 550
552 $aEmailErrors = array(); 551 $aEmailErrors = array();
553 $aUserEmails = array(); 552 $aUserEmails = array();
554 -  
555 // send group emails 553 // send group emails
556 sendGroupEmails($aGroupIDs, $aUserEmails, $aEmailErrors); 554 sendGroupEmails($aGroupIDs, $aUserEmails, $aEmailErrors);
557 // send user emails 555 // send user emails
@@ -569,12 +567,12 @@ class KTDocumentEmailAction extends KTDocumentAction { @@ -569,12 +567,12 @@ class KTDocumentEmailAction extends KTDocumentAction {
569 $aListEmails = array_keys($aUserEmails); 567 $aListEmails = array_keys($aUserEmails);
570 sendEmail($aListEmails, $iDocumentID, $sDocumentName, $fComment, (boolean)$fAttachDocument, $aEmailErrors); 568 sendEmail($aListEmails, $iDocumentID, $sDocumentName, $fComment, (boolean)$fAttachDocument, $aEmailErrors);
571 } 569 }
572 - 570 + // Display success or error
573 if (count($aEmailErrors)) { 571 if (count($aEmailErrors)) {
574 $_SESSION['KTErrorMessage'][] = join('<br />\n', $aEmailErrors); 572 $_SESSION['KTErrorMessage'][] = join('<br />\n', $aEmailErrors);
  573 + } else {
  574 + $_SESSION['KTInfoMessage'][] = _kt('Email sent');
575 } 575 }
576 -  
577 - $_SESSION['KTInfoMessage'][] = _kt('Email sent');  
578 //go back to the document view page 576 //go back to the document view page
579 controllerRedirect('viewDocument', sprintf("fDocumentId=%d", $this->oDocument->getId())); 577 controllerRedirect('viewDocument', sprintf("fDocumentId=%d", $this->oDocument->getId()));
580 } 578 }