diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index 35bd2cd2c..1f8a491b0 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -2519,11 +2519,13 @@ class wsBase // Send notifications Mobile - Start try { - $oLight = new \ProcessMaker\BusinessModel\Light(); - $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); - $notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], - $appFields, $nextDelegations, $nextIndex, $delIndex); + if ($notificationMobile->checkMobileNotifications()) { + $oLight = new \ProcessMaker\BusinessModel\Light(); + $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex); + $notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], + $appFields, $nextDelegations, $nextIndex, $delIndex); + } } catch (Exception $e) { \G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log"); } diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index f9ef18225..811e078c7 100755 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -163,32 +163,32 @@ try { // Send notifications - Start $oUser = new Users(); $aUser = $oUser->load( $_SESSION['USER_LOGGED'] ); - $sFromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : ''); - - $flagGmail = false; - /*----------------------------------********---------------------------------*/ - $licensedFeatures = &PMLicensedFeatures::getSingleton (); - if ($licensedFeatures->verifyfeature ( '7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09' )) { - G::LoadClass ( "pmGoogleApi" ); - $pmGoogle = new PMGoogleApi (); - if ($pmGoogle->getServiceGmailStatus ()) { - $flagGmail = true; - - $appDel = new AppDelegation (); - $actualThread = $appDel->Load ( $_SESSION ['APPLICATION'], $_SESSION ['INDEX'] ); - - $appDelPrev = $appDel->LoadParallel ( $_SESSION ['APPLICATION'] ); - $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail (); - if (! $appDelPrev) { - $Pmgmail->sendEmail ( $_SESSION ['APPLICATION'], "", $_SESSION ['INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA'] ); - } else { - 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'] ); - } - } - } - } + $sFromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : ''); + + $flagGmail = false; + /*----------------------------------********---------------------------------*/ + $licensedFeatures = &PMLicensedFeatures::getSingleton (); + if ($licensedFeatures->verifyfeature ( '7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09' )) { + G::LoadClass ( "pmGoogleApi" ); + $pmGoogle = new PMGoogleApi (); + if ($pmGoogle->getServiceGmailStatus ()) { + $flagGmail = true; + + $appDel = new AppDelegation (); + $actualThread = $appDel->Load ( $_SESSION ['APPLICATION'], $_SESSION ['INDEX'] ); + + $appDelPrev = $appDel->LoadParallel ( $_SESSION ['APPLICATION'] ); + $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail (); + if (! $appDelPrev) { + $Pmgmail->sendEmail ( $_SESSION ['APPLICATION'], "", $_SESSION ['INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA'] ); + } else { + 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'] ); + } + } + } + } } /*----------------------------------********---------------------------------*/ @@ -201,11 +201,13 @@ try { // Send notifications Mobile - Start try { - $oLight = new \ProcessMaker\BusinessModel\Light(); - $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $appFields['DEL_INDEX']); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); - $notificationMobile->routeCaseNotification($_SESSION['USER_LOGGED'], $_SESSION['PROCESS'], $_SESSION['TASK'], - $appFields, $_POST['form']['TASKS'], $nextIndex, $appFields['DEL_INDEX']); + if ($notificationMobile->checkMobileNotifications()) { + $oLight = new \ProcessMaker\BusinessModel\Light(); + $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $appFields['DEL_INDEX']); + $notificationMobile->routeCaseNotification($_SESSION['USER_LOGGED'], $_SESSION['PROCESS'], $_SESSION['TASK'], + $appFields, $_POST['form']['TASKS'], $nextIndex, $appFields['DEL_INDEX']); + } } catch (Exception $e) { \G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log"); } @@ -251,16 +253,16 @@ try { // Set users drive - End /*----------------------------------********---------------------------------*/ - $debuggerAvailable = true; - - $casesRedirector = 'casesListExtJsRedirector'; - if (isset ( $_SESSION ['user_experience'] ) && $flagGmail === false) { - $aNextStep ['PAGE'] = $casesRedirector . '?ux=' . $_SESSION ['user_experience']; - $debuggerAvailable = false; - } else if ($flagGmail === true) { - $aNextStep ['PAGE'] = $casesRedirector . '?gmail=1'; - } else { - $aNextStep ['PAGE'] = $casesRedirector; + $debuggerAvailable = true; + + $casesRedirector = 'casesListExtJsRedirector'; + if (isset ( $_SESSION ['user_experience'] ) && $flagGmail === false) { + $aNextStep ['PAGE'] = $casesRedirector . '?ux=' . $_SESSION ['user_experience']; + $debuggerAvailable = false; + } else if ($flagGmail === true) { + $aNextStep ['PAGE'] = $casesRedirector . '?gmail=1'; + } else { + $aNextStep ['PAGE'] = $casesRedirector; } if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php index 5f370b989..0004d31de 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php @@ -7,6 +7,18 @@ use G; class NotificationDevice { + + + public function checkMobileNotifications() + { + $conf = \System::getSystemConfiguration('', '', SYS_SYS); + $activeNotifications = true; + if (isset($conf['mobileNotifications'])) { + $activeNotifications = $conf['mobileNotifications'] == 1 ? true : false; + } + return $activeNotifications; + } + /** * Post Create register device with userUid *