BY-237, BY-232, BY-169, BY-170
This commit is contained in:
@@ -414,9 +414,23 @@ class AppDocumentDrive
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUsersDocumentDrive ($appUid)
|
/**
|
||||||
|
* Add users to documents drive to give permissions
|
||||||
|
*
|
||||||
|
* @param $appUid Id application
|
||||||
|
* @param $emails array with emails which can be null
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function addUsersDocumentDrive ($appUid, $emails=null)
|
||||||
{
|
{
|
||||||
$this->getEmailUsersTask($appUid);
|
if (is_array($emails)) {
|
||||||
|
foreach ($emails as $index => $email) {
|
||||||
|
$this->addUserEmail($email);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->getEmailUsersTask($appUid);
|
||||||
|
}
|
||||||
|
|
||||||
$criteria = new Criteria( 'workflow' );
|
$criteria = new Criteria( 'workflow' );
|
||||||
$criteria->add( AppDocumentPeer::APP_UID, $appUid );
|
$criteria->add( AppDocumentPeer::APP_UID, $appUid );
|
||||||
|
|||||||
@@ -235,6 +235,16 @@ class labelsGmail
|
|||||||
$q = "subject:('" . preg_quote($subject, '-') . "') label:('" . $labelsToSearch . "')";
|
$q = "subject:('" . preg_quote($subject, '-') . "') label:('" . $labelsToSearch . "')";
|
||||||
$messageList = $this->listMessages($service, $mail, $q, $labelsToRemove);
|
$messageList = $this->listMessages($service, $mail, $q, $labelsToRemove);
|
||||||
|
|
||||||
|
//if there isn't any message at draft, and lasindex is zero, is a subprocess
|
||||||
|
//and we must search in inbox:
|
||||||
|
if ($actualLastIndex === 0 && count($messageList) ===0) {
|
||||||
|
$labelsToRemove = $labelsIds['Inbox'];
|
||||||
|
$labelsToSearch = "*-inbox";
|
||||||
|
$labelsToAdd = $labelsIds['Participated'];
|
||||||
|
$q = "subject:('" . preg_quote($subject, '-') . "') label:('" . $labelsToSearch . "')";
|
||||||
|
$messageList = $this->listMessages($service, $mail, $q, $labelsToRemove);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($messageList as $message) {
|
foreach ($messageList as $message) {
|
||||||
$messageId = $message->getId();
|
$messageId = $message->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,22 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------********---------------------------------*/
|
||||||
|
$licensedFeatures = &PMLicensedFeatures::getSingleton ();
|
||||||
|
if ($licensedFeatures->verifyfeature ( '7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09' )) {
|
||||||
|
G::LoadClass("pmGoogleApi");
|
||||||
|
try{
|
||||||
|
$pmGoogle = new PMGoogleApi ();
|
||||||
|
if ($pmGoogle->getServiceGmailStatus()) {
|
||||||
|
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
||||||
|
$Pmgmail->gmailsForRouting($sUsrUid, $sTasUid, $sAppUid, $delIndex, $isSubprocess);
|
||||||
|
}
|
||||||
|
} catch (Exception $oError) {
|
||||||
|
error_log($oError->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*----------------------------------********---------------------------------*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($flagActionsByEmail) {
|
if ($flagActionsByEmail) {
|
||||||
|
|||||||
@@ -261,21 +261,6 @@ function startCase ()
|
|||||||
|
|
||||||
$_SESSION['CASES_REFRESH'] = true;
|
$_SESSION['CASES_REFRESH'] = true;
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
|
||||||
//sending the email for gmail integration if the option is available
|
|
||||||
$licensedFeatures = &PMLicensedFeatures::getSingleton();
|
|
||||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
|
||||||
G::LoadClass( "pmGoogleApi" );
|
|
||||||
$pmGoogle = new PMGoogleApi();
|
|
||||||
|
|
||||||
if($pmGoogle->getServiceGmailStatus()){
|
|
||||||
require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php';
|
|
||||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
|
||||||
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX'], null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*----------------------------------********---------------------------------*/
|
|
||||||
|
|
||||||
$oCase = new Cases();
|
$oCase = new Cases();
|
||||||
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,17 @@ if ($aDelegation['USR_UID'] == "") {
|
|||||||
$labGmail->addRelabelingToQueue($sAppUid, $iDelIndex, -1, true);
|
$labGmail->addRelabelingToQueue($sAppUid, $iDelIndex, -1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
|
||||||
|
G::LoadClass("AppDocumentDrive");
|
||||||
|
$drive = new AppDocumentDrive();
|
||||||
|
if ($drive->getStatusDrive()) {
|
||||||
|
//add users email next task
|
||||||
|
$user = new Users();
|
||||||
|
$userInfo = $user->load($_SESSION['USER_LOGGED']);
|
||||||
|
$drive->addUsersDocumentDrive($sAppUid, array($userInfo['USR_EMAIL']));
|
||||||
|
}
|
||||||
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
//changing email labels if the claim comes from gmail
|
//changing email labels if the claim comes from gmail
|
||||||
if(array_key_exists('gmail',$_SESSION) && $_SESSION['gmail'] == 1){
|
if(array_key_exists('gmail',$_SESSION) && $_SESSION['gmail'] == 1){
|
||||||
|
|||||||
@@ -179,13 +179,9 @@ try {
|
|||||||
|
|
||||||
$appDelPrev = $appDel->LoadParallel ( $_SESSION ['APPLICATION'] );
|
$appDelPrev = $appDel->LoadParallel ( $_SESSION ['APPLICATION'] );
|
||||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail ();
|
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail ();
|
||||||
if (! $appDelPrev) {
|
foreach ( $appDelPrev as $app ) {
|
||||||
$Pmgmail->sendEmail ( $_SESSION ['APPLICATION'], "", $_SESSION ['INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA'] );
|
if (($app ['DEL_INDEX'] != $_SESSION ['INDEX']) && ($app ['DEL_PREVIOUS'] != $actualThread ['DEL_PREVIOUS'])) {
|
||||||
} else {
|
$Pmgmail->gmailsIfSelfServiceValueBased ( $_SESSION ['APPLICATION'], $app ['DEL_INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA'] );
|
||||||
foreach ( $appDelPrev as $app ) {
|
|
||||||
if (($app ['DEL_INDEX'] != $_SESSION ['INDEX']) && ($app ['DEL_PREVIOUS'] != $actualThread ['DEL_PREVIOUS'])) {
|
|
||||||
$Pmgmail->sendEmail ( $_SESSION ['APPLICATION'], "", $app ['DEL_INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA'] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\BusinessModel;
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Task.php");
|
||||||
|
|
||||||
use \G;
|
use \G;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copyright Colosa - Bolivia
|
* @copyright Colosa - Bolivia
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +19,7 @@ class Pmgmail {
|
|||||||
*/
|
*/
|
||||||
public function getUserByEmail($usr_gmail)
|
public function getUserByEmail($usr_gmail)
|
||||||
{
|
{
|
||||||
//getting the user data
|
//getting the user data
|
||||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
||||||
$oUsers = new \Users();
|
$oUsers = new \Users();
|
||||||
$response['user'] = $oUsers->loadByUserEmailInArray($usr_gmail);
|
$response['user'] = $oUsers->loadByUserEmailInArray($usr_gmail);
|
||||||
@@ -42,33 +44,118 @@ class Pmgmail {
|
|||||||
*/
|
*/
|
||||||
public function getDraftApp($app_uid, $index=1)
|
public function getDraftApp($app_uid, $index=1)
|
||||||
{
|
{
|
||||||
$c = new \Criteria( 'workflow' );
|
$c = new \Criteria( 'workflow' );
|
||||||
|
|
||||||
$c->clearSelectColumns();
|
$c->clearSelectColumns();
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
|
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
|
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
|
||||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
|
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
|
||||||
|
$c->addSelectColumn( \AppCacheViewPeer::APP_UID );
|
||||||
|
|
||||||
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
|
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
|
||||||
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
|
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
|
||||||
|
|
||||||
$rs = \AppCacheViewPeer::doSelectRS( $c );
|
$rs = \AppCacheViewPeer::doSelectRS( $c );
|
||||||
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||||
|
|
||||||
$rows = Array ();
|
$rows = Array ();
|
||||||
while ($rs->next()) {
|
while ($rs->next()) {
|
||||||
$rows[] = $rs->getRow();
|
$rows[] = $rs->getRow();
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gmailsForRouting($sUsrUid, $sTasUid, $sAppUid, $delIndex, $isSubprocess) {
|
||||||
|
|
||||||
|
$taskProxy = new \Task();
|
||||||
|
$taskData = $taskProxy-> load($sTasUid);
|
||||||
|
|
||||||
|
//guard condition, message events do not need to send emails
|
||||||
|
if ($taskData['TAS_TYPE'] === 'START-MESSAGE-EVENT') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($sUsrUid === "") {
|
||||||
|
$targetEmails = $this->targetEmailsForUnassigned($sTasUid, $sAppUid);
|
||||||
|
if ($targetEmails['to'] !== "" && $targetEmails['to'] !== null ) {
|
||||||
|
$this->sendGmail($sAppUid, $targetEmails['to'].','.$targetEmails['cc'], $delIndex, $isSubprocess, true, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$userObject = new \Users();
|
||||||
|
$userData = $userObject->loadDetails($sUsrUid);
|
||||||
|
if ($userData !== null) {
|
||||||
|
$this->sendGmail($sAppUid, $userData['USR_EMAIL'], $delIndex, $isSubprocess, false, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gmailsIfSelfServiceValueBased($app_uid, $index, $arrayTask, $arrayData)
|
||||||
|
{
|
||||||
|
require_once(PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php");
|
||||||
|
$resultMail = "";
|
||||||
|
foreach ($arrayTask as $aTask) {
|
||||||
|
//just self service tasks are processed in this function
|
||||||
|
if ($aTask ["TAS_ASSIGN_TYPE"] !== "SELF_SERVICE") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$appData = $this->getDraftApp($app_uid, $index);
|
||||||
|
if (count($appData) === 0) {
|
||||||
|
return "appUid not found";
|
||||||
|
}
|
||||||
|
if (!isset ($aTask ["USR_UID"])) {
|
||||||
|
$aTask ["USR_UID"] = "";
|
||||||
|
}
|
||||||
|
$oCases = new \Cases ();
|
||||||
|
$application = $appData[0];
|
||||||
|
|
||||||
|
$respTo = $oCases->getTo($aTask ["TAS_ASSIGN_TYPE"], $aTask ["TAS_UID"], $aTask ["USR_UID"], $arrayData);
|
||||||
|
$mailToAddresses = $respTo ['to'];
|
||||||
|
$mailCcAddresses = $respTo ['cc'];
|
||||||
|
$labelID = "PMUASS";
|
||||||
|
|
||||||
|
if (( string )$mailToAddresses === "") { // Self Service Value Based
|
||||||
|
$isSelfServiceValueBased = true;
|
||||||
|
$criteria = new \Criteria ("workflow");
|
||||||
|
$criteria->addSelectColumn(\AppAssignSelfServiceValuePeer::GRP_UID);
|
||||||
|
$criteria->add(\AppAssignSelfServiceValuePeer::APP_UID, $app_uid);
|
||||||
|
|
||||||
|
$rsCriteria = \AppAssignSelfServiceValuePeer::doSelectRs($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
while ($rsCriteria->next()) {
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
}
|
||||||
|
$targetIds = unserialize($row ['GRP_UID']);
|
||||||
|
$oUsers = new \Users ();
|
||||||
|
|
||||||
|
if (is_array($targetIds)) {
|
||||||
|
foreach ($targetIds as $user) {
|
||||||
|
$usrData = $oUsers->loadDetails($user);
|
||||||
|
$nextMail = $usrData ['USR_EMAIL'];
|
||||||
|
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$group = new \Groups();
|
||||||
|
$users = $group->getUsersOfGroup($targetIds);
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$nextMail = $user['USR_EMAIL'];
|
||||||
|
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$resultMail = $this->sendEmailWithApplicationData($application, $labelID, $mailToAddresses, $mailCcAddresses);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $resultMail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,179 +167,28 @@ class Pmgmail {
|
|||||||
* return uid
|
* return uid
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function sendEmail($app_uid, $mailToAddresses, $index, $arrayTask = null, $arrayData = null)
|
public function sendGmail($app_uid, $mailToAddresses, $index, $isSubprocess = false, $isSelfService = false, $arrayTask = null, $arrayData = null)
|
||||||
{
|
{
|
||||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php");
|
|
||||||
//getting the default email server
|
//getting the default email server
|
||||||
$defaultEmail = $this->emailAccount();
|
$defaultEmail = $this->emailAccount();
|
||||||
|
|
||||||
if ($defaultEmail === null) {
|
if ($defaultEmail === null) {
|
||||||
error_log(G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED'));
|
error_log(G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mailCcAddresses = "";
|
$mailCcAddresses = "";
|
||||||
$oApplication = new \Application();
|
|
||||||
$formData = $oApplication->Load($app_uid);
|
|
||||||
|
|
||||||
$frmData = unserialize($formData['APP_DATA']);
|
$appData = $this->getDraftApp($app_uid, $index);
|
||||||
$dataFormToShowString = "";
|
if (count($appData) === 0) {
|
||||||
|
return;
|
||||||
foreach ($frmData as $field => $value) {
|
|
||||||
if (($field != 'SYS_LANG') &&
|
|
||||||
($field != 'SYS_SKIN') &&
|
|
||||||
($field != 'SYS_SYS') &&
|
|
||||||
($field != 'APPLICATION') &&
|
|
||||||
($field != 'PROCESS') &&
|
|
||||||
($field != 'TASK') &&
|
|
||||||
($field != 'INDEX') &&
|
|
||||||
($field != 'USER_LOGGED') &&
|
|
||||||
($field != 'USR_USERNAME') &&
|
|
||||||
($field != 'DYN_CONTENT_HISTORY') &&
|
|
||||||
($field != 'PIN') &&
|
|
||||||
(!is_array($value))
|
|
||||||
) {
|
|
||||||
$dataFormToShowString .= " " . $field . " " . $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$appData = $this->getDraftApp($app_uid, $index);
|
$application = $appData[0];
|
||||||
|
$this->sendEmailWithApplicationData($application,
|
||||||
foreach ($appData as $application) {
|
$this->getEmailType($index, $isSubprocess, $isSelfService),
|
||||||
$appNumber = $application['APP_NUMBER'];
|
$mailToAddresses,
|
||||||
$appStatus = $application['APP_STATUS'];
|
$mailCcAddresses);
|
||||||
$index = $application['DEL_INDEX'];
|
|
||||||
$prvUsr = $application['APP_DEL_PREVIOUS_USER'];
|
|
||||||
$delegateDate = $application['DEL_DELEGATE_DATE'];
|
|
||||||
$nextUsr = $application['USR_UID'];
|
|
||||||
$proUid = $application['PRO_UID'];
|
|
||||||
$proName = $application['APP_PRO_TITLE'];
|
|
||||||
$tasName = $application['APP_TAS_TITLE'];
|
|
||||||
$threadStatus = $application['DEL_THREAD_STATUS'];
|
|
||||||
$tasUid = $application['TAS_UID'];
|
|
||||||
$lastIndex = $application['DEL_LAST_INDEX'];
|
|
||||||
|
|
||||||
if ($appStatus == "DRAFT") {
|
|
||||||
$labelID = "PMDRFT";
|
|
||||||
} else {
|
|
||||||
$labelID = "PMIBX";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (( string ) $mailToAddresses === "") {
|
|
||||||
if ($arrayTask) {
|
|
||||||
$oCases = new \Cases ();
|
|
||||||
|
|
||||||
foreach ( $arrayTask as $aTask ) {
|
|
||||||
if (! isset ( $aTask ["USR_UID"] )) {
|
|
||||||
$aTask ["USR_UID"] = "";
|
|
||||||
}
|
|
||||||
$respTo = $oCases->getTo ( $aTask ["TAS_ASSIGN_TYPE"], $aTask ["TAS_UID"], $aTask ["USR_UID"], $arrayData );
|
|
||||||
$mailToAddresses = $respTo ['to'];
|
|
||||||
$mailCcAddresses = $respTo ['cc'];
|
|
||||||
|
|
||||||
if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
|
|
||||||
$labelID = "PMUASS";
|
|
||||||
if (( string ) $mailToAddresses === "") { // Self Service Value Based
|
|
||||||
$criteria = new \Criteria ( "workflow" );
|
|
||||||
$criteria->addSelectColumn ( \AppAssignSelfServiceValuePeer::GRP_UID );
|
|
||||||
$criteria->add ( \AppAssignSelfServiceValuePeer::APP_UID, $app_uid );
|
|
||||||
|
|
||||||
$rsCriteria = \AppAssignSelfServiceValuePeer::doSelectRs ( $criteria );
|
|
||||||
$rsCriteria->setFetchmode ( \ResultSet::FETCHMODE_ASSOC );
|
|
||||||
|
|
||||||
while ( $rsCriteria->next () ) {
|
|
||||||
$row = $rsCriteria->getRow ();
|
|
||||||
}
|
|
||||||
$targetIds = unserialize ( $row ['GRP_UID'] );
|
|
||||||
$oUsers = new \Users ();
|
|
||||||
|
|
||||||
if (is_array($targetIds)) {
|
|
||||||
foreach ( $targetIds as $user ) {
|
|
||||||
$usrData = $oUsers->loadDetails ( $user );
|
|
||||||
$nextMail = $usrData ['USR_EMAIL'];
|
|
||||||
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$group = new \Groups();
|
|
||||||
$users = $group->getUsersOfGroup($targetIds);
|
|
||||||
foreach ($users as $user) {
|
|
||||||
$nextMail = $user['USR_EMAIL'];
|
|
||||||
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$oUsers = new \Users ();
|
|
||||||
|
|
||||||
$usrData = $oUsers->loadDetails ( $nextUsr );
|
|
||||||
$mailToAddresses = $usrData ['USR_EMAIL'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//first template
|
|
||||||
$pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html";
|
|
||||||
if (!file_exists($pathTemplate)) {
|
|
||||||
$file = @fopen($pathTemplate, "w");
|
|
||||||
fwrite($file, '<div>');
|
|
||||||
fwrite($file, '<span style="display: none !important;">');
|
|
||||||
fwrite($file, '-**- Process Name: @#proName<br/>');
|
|
||||||
fwrite($file, '-**- Case Number: @#appNumber<br/>');
|
|
||||||
fwrite($file, '-**- Case UID: @#caseUid<br/>');
|
|
||||||
fwrite($file, '-**- Task Name: @#taskName<br/>');
|
|
||||||
fwrite($file, '-**- Index: @#index<br/>');
|
|
||||||
fwrite($file, '-**- Action: @#action<br/>');
|
|
||||||
fwrite($file, '-**- Previous User: @#prevUser<br/>');
|
|
||||||
fwrite($file, '-**- Delegate Date: @#delDate<br/>');
|
|
||||||
fwrite($file, '-**- Process Id: @#proUid<br/>');
|
|
||||||
fwrite($file, '-**- Type: @#type<br/>');
|
|
||||||
fwrite($file, '-**- FormFields: @@oform<br/>');
|
|
||||||
fwrite($file, '</span>');
|
|
||||||
fwrite($file, '</div>');
|
|
||||||
fclose($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
$change = array('[', ']', '"');
|
|
||||||
$fdata = str_replace($change, ' ', $dataFormToShowString);
|
|
||||||
$aFields = array(
|
|
||||||
'proName' => $proName,
|
|
||||||
'appNumber' => $appNumber,
|
|
||||||
'caseUid' => $app_uid,
|
|
||||||
'taskName' => $tasName,
|
|
||||||
'index' => $index,
|
|
||||||
'action' => $appStatus,
|
|
||||||
'prevUser' => $prvUsr,
|
|
||||||
'delDate' => $delegateDate,
|
|
||||||
'proUid' => $proUid,
|
|
||||||
'type' => $labelID,
|
|
||||||
'oform' => $fdata
|
|
||||||
);
|
|
||||||
|
|
||||||
$subject = "[PM] " . $proName . " (" . $index . ") Case: " . $appNumber;
|
|
||||||
|
|
||||||
$ws = new \wsBase();
|
|
||||||
|
|
||||||
$resultMail = $ws->sendMessage(
|
|
||||||
$app_uid,
|
|
||||||
$defaultEmail, //From,
|
|
||||||
$mailToAddresses,//$To,
|
|
||||||
$mailCcAddresses,//$Cc
|
|
||||||
'',
|
|
||||||
$subject,
|
|
||||||
'pmGmail.html',//template
|
|
||||||
$aFields, //fields
|
|
||||||
array(),
|
|
||||||
true,
|
|
||||||
0,
|
|
||||||
array(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
return $resultMail;
|
|
||||||
}
|
|
||||||
return 'The appUid cant be founded';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if the license has the feature
|
* Get if the license has the feature
|
||||||
*
|
*
|
||||||
@@ -295,12 +231,12 @@ class Pmgmail {
|
|||||||
*/
|
*/
|
||||||
public function deleteLabels($mail)
|
public function deleteLabels($mail)
|
||||||
{
|
{
|
||||||
require_once(PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php");
|
require_once(PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php");
|
||||||
$oLabels = new \labelsGmail();
|
$oLabels = new \labelsGmail();
|
||||||
|
|
||||||
$response = $oLabels->deletePMGmailLabels($mail);
|
$response = $oLabels->deletePMGmailLabels($mail);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyMailToPauseCase($appUid, $appDelIndex)
|
public function modifyMailToPauseCase($appUid, $appDelIndex)
|
||||||
@@ -316,5 +252,184 @@ class Pmgmail {
|
|||||||
$oLabels = new \labelsGmail();
|
$oLabels = new \labelsGmail();
|
||||||
$oResponse = $oLabels->setLabelsToUnpauseCase($appUid, $appDelIndex);
|
$oResponse = $oLabels->setLabelsToUnpauseCase($appUid, $appDelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getEmailType($index, $isSubprocess, $isSelfService) {
|
||||||
|
$retval = "";
|
||||||
|
if ($isSelfService) {
|
||||||
|
$retval = "PMUASS";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$retval = ($index === 1 && !$isSubprocess) ? "PMDRFT" : "PMIBX";
|
||||||
|
}
|
||||||
|
if ($retval === "") {
|
||||||
|
throw new Exception('Is not possible to determine the email type');
|
||||||
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createMailTemplateFile()
|
||||||
|
{
|
||||||
|
$pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html";
|
||||||
|
if (!file_exists($pathTemplate)) {
|
||||||
|
$file = @fopen($pathTemplate, "w");
|
||||||
|
fwrite($file, '<div>');
|
||||||
|
fwrite($file, '<span style="display: none !important;">');
|
||||||
|
fwrite($file, '-**- Process Name: @#proName<br/>');
|
||||||
|
fwrite($file, '-**- Case Number: @#appNumber<br/>');
|
||||||
|
fwrite($file, '-**- Case UID: @#caseUid<br/>');
|
||||||
|
fwrite($file, '-**- Task Name: @#taskName<br/>');
|
||||||
|
fwrite($file, '-**- Index: @#index<br/>');
|
||||||
|
fwrite($file, '-**- Action: @#action<br/>');
|
||||||
|
fwrite($file, '-**- Previous User: @#prevUser<br/>');
|
||||||
|
fwrite($file, '-**- Delegate Date: @#delDate<br/>');
|
||||||
|
fwrite($file, '-**- Process Id: @#proUid<br/>');
|
||||||
|
fwrite($file, '-**- Type: @#type<br/>');
|
||||||
|
fwrite($file, '-**- FormFields: @@oform<br/>');
|
||||||
|
fwrite($file, '</span>');
|
||||||
|
fwrite($file, '</div>');
|
||||||
|
fclose($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFormData($appUid, $index) {
|
||||||
|
$oApplication = new \Application();
|
||||||
|
$formData = $oApplication->Load($appUid);
|
||||||
|
|
||||||
|
$frmData = unserialize($formData['APP_DATA']);
|
||||||
|
$dataFormToShowString = "";
|
||||||
|
foreach ($frmData as $field => $value) {
|
||||||
|
if (($field != 'SYS_LANG') &&
|
||||||
|
($field != 'SYS_SKIN') &&
|
||||||
|
($field != 'SYS_SYS') &&
|
||||||
|
($field != 'APPLICATION') &&
|
||||||
|
($field != 'PROCESS') &&
|
||||||
|
($field != 'TASK') &&
|
||||||
|
($field != 'INDEX') &&
|
||||||
|
($field != 'USER_LOGGED') &&
|
||||||
|
($field != 'USR_USERNAME') &&
|
||||||
|
($field != 'DYN_CONTENT_HISTORY') &&
|
||||||
|
($field != 'PIN') &&
|
||||||
|
(!is_array($value))
|
||||||
|
) {
|
||||||
|
$dataFormToShowString .= " " . $field . " " . $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$change = array('[', ']', '"');
|
||||||
|
$fdata = str_replace($change, ' ', $dataFormToShowString);
|
||||||
|
return $fdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendEmailWithApplicationData ($application, $emailTypeLabel, $mailToAddresses, $mailCcAddresses) {
|
||||||
|
$dataFormToShowString = $this->getFormData($application['APP_UID'],$application['DEL_INDEX']);
|
||||||
|
$this->createMailTemplateFile();
|
||||||
|
$change = array('[', ']', '"');
|
||||||
|
$fdata = str_replace($change, ' ', $dataFormToShowString);
|
||||||
|
$aFields = array(
|
||||||
|
'proName' => $application['APP_PRO_TITLE'],
|
||||||
|
'appNumber' => $application['APP_NUMBER'],
|
||||||
|
'caseUid' => $application['APP_UID'],
|
||||||
|
'taskName' => $application['APP_TAS_TITLE'],
|
||||||
|
'index' => $application['DEL_INDEX'],
|
||||||
|
'action' => $application['APP_STATUS'],
|
||||||
|
'prevUser' => $application['APP_DEL_PREVIOUS_USER'],
|
||||||
|
'delDate' => $application['DEL_DELEGATE_DATE'],
|
||||||
|
'proUid' => $application['PRO_UID'],
|
||||||
|
'type' => $emailTypeLabel,
|
||||||
|
'oform' => $fdata
|
||||||
|
);
|
||||||
|
|
||||||
|
$subject = "[PM] " . $application['APP_PRO_TITLE'] . " (" . $application['DEL_INDEX'] . ") Case: " . $application['APP_NUMBER'];
|
||||||
|
|
||||||
|
//getting the default email server
|
||||||
|
$defaultEmail = $this->emailAccount();
|
||||||
|
|
||||||
|
if ($defaultEmail === null) {
|
||||||
|
error_log(G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ws = new \wsBase();
|
||||||
|
$resultMail = $ws->sendMessage(
|
||||||
|
$application['APP_UID'],
|
||||||
|
$defaultEmail, //From,
|
||||||
|
$mailToAddresses,//$To,
|
||||||
|
$mailCcAddresses,//$Cc
|
||||||
|
'',
|
||||||
|
$subject,
|
||||||
|
'pmGmail.html',//template
|
||||||
|
$aFields, //fields
|
||||||
|
array(),
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
array(),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function targetEmailsForUnassigned($taskUid, $appUid)
|
||||||
|
{
|
||||||
|
$sTo = null;
|
||||||
|
$sCc = null;
|
||||||
|
$arrayResp = array ();
|
||||||
|
$task = new \Tasks ();
|
||||||
|
$group = new \Groups ();
|
||||||
|
$oUser = new \Users ();
|
||||||
|
|
||||||
|
$to = null;
|
||||||
|
$cc = null;
|
||||||
|
|
||||||
|
if (isset ( $taskUid ) && ! empty ( $taskUid )) {
|
||||||
|
$arrayTaskUser = array ();
|
||||||
|
|
||||||
|
$arrayAux1 = $task->getGroupsOfTask ( $taskUid, 1 );
|
||||||
|
|
||||||
|
foreach ( $arrayAux1 as $arrayGroup ) {
|
||||||
|
$arrayAux2 = $group->getUsersOfGroup ( $arrayGroup ["GRP_UID"] );
|
||||||
|
|
||||||
|
foreach ( $arrayAux2 as $arrayUser ) {
|
||||||
|
$arrayTaskUser [] = $arrayUser ["USR_UID"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayAux1 = $task->getUsersOfTask ( $taskUid, 1 );
|
||||||
|
|
||||||
|
foreach ( $arrayAux1 as $arrayUser ) {
|
||||||
|
$arrayTaskUser [] = $arrayUser ["USR_UID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayTaskUser = array_unique($arrayTaskUser);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$arrayResp ['to'] = $to;
|
||||||
|
$arrayResp ['cc'] = $cc;
|
||||||
|
}
|
||||||
|
return $arrayResp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class GmailIntegration extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
||||||
$response = $Pmgmail->sendEmail($app_uid, $mail, $index);
|
$response = $Pmgmail->sendGmail($app_uid, $mail, $index);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
|
|||||||
Reference in New Issue
Block a user