Merged in 3.0.1.7-Gmail (pull request #3823)

BY-95
This commit is contained in:
Julio Cesar Laura Avendaño
2016-03-23 19:47:19 -04:00
8 changed files with 336 additions and 265 deletions

View File

@@ -175,15 +175,17 @@ class AppDocumentDrive
$data = []; $data = [];
while ($rsAppDelegation->next()) { while ($rsAppDelegation->next()) {
$row = $rsAppDelegation->getRow(); $row = $rsAppDelegation->getRow();
if ($user->userExists($row['USR_UID'])) { if (!empty($row['USR_UID'])) {
$data = []; if ($user->userExists($row['USR_UID'])) {
$data[] = $user->load($row['USR_UID']); $data = [];
} else { $data[] = $user->load($row['USR_UID']);
$data = $group->getUsersOfGroup($row['USR_UID']); } else {
} $data = $group->getUsersOfGroup($row['USR_UID']);
}
foreach ($data as $dataUser) { foreach ($data as $dataUser) {
$this->addUserEmail($dataUser["USR_EMAIL"]); $this->addUserEmail($dataUser["USR_EMAIL"]);
}
} }
} }
} catch (Exception $exception) { } catch (Exception $exception) {
@@ -278,18 +280,18 @@ class AppDocumentDrive
error_log("It has not enabled Feature Gmail"); error_log("It has not enabled Feature Gmail");
return; return;
} }
$criteria = new Criteria( 'workflow' ); $criteria = new Criteria('workflow');
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID); $criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION); $criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
$criteria->add( $criteria->add(
$criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL )-> $criteria->getNewCriterion(AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL)->
addOr($criteria->getNewCriterion( AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL )) addOr($criteria->getNewCriterion(AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL))
); );
$criteria->addAscendingOrderByColumn( 'APP_DOC_CREATE_DATE' ); $criteria->addAscendingOrderByColumn('APP_DOC_CREATE_DATE');
$criteria->addAscendingOrderByColumn( 'APP_UID' ); $criteria->addAscendingOrderByColumn('APP_UID');
$rs = AppDocumentPeer::doSelectRS( $criteria ); $rs = AppDocumentPeer::doSelectRS($criteria);
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $rs->setFetchMode(ResultSet::FETCHMODE_ASSOC);
while ($rs->next()) { while ($rs->next()) {
$row = $rs->getRow(); $row = $rs->getRow();
@@ -298,58 +300,57 @@ class AppDocumentDrive
$appDocUid = $appDoc->getAppDocUid(); $appDocUid = $appDoc->getAppDocUid();
$docVersion = $appDoc->getDocVersion(); $docVersion = $appDoc->getDocVersion();
$filename = pathinfo( $appDoc->getAppDocFilename() ); $filename = pathinfo($appDoc->getAppDocFilename());
$name = !empty($filename['basename'])? $filename['basename'] : ''; $name = !empty($filename['basename']) ? $filename['basename'] : '';
$ext = !empty($filename['extension'])? $filename['extension'] : ''; $ext = !empty($filename['extension']) ? $filename['extension'] : '';
$appUid = G::getPathFromUID($appDoc->getAppUid()); $appUid = G::getPathFromUID($appDoc->getAppUid());
$file = G::getPathFromFileUID($appDoc->getAppUid(), $appDocUid ); $file = G::getPathFromFileUID($appDoc->getAppUid(), $appDocUid);
$sw_file_exists_doc = false; $sw_file_exists_doc = false;
$sw_file_exists_pdf = false; $sw_file_exists_pdf = false;
if ($appDoc->getAppDocType() == 'OUTPUT') { $sw_file_exists = false;
//$name = substr($name, 1, -1); $realPath = '';
if ($appDoc->getAppDocType() === 'OUTPUT') {
$realPathDoc = PATH_DOCUMENT . $appUid . '/outdocs/' . $appDocUid . '_' . $docVersion . '.' . 'doc'; $realPathDoc = PATH_DOCUMENT . $appUid . '/outdocs/' . $appDocUid . '_' . $docVersion . '.' . 'doc';
$realPathDoc1 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '_' . $docVersion . '.' . 'doc'; $realPathDoc1 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '_' . $docVersion . '.' . 'doc';
$realPathDoc2 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '.' . 'doc'; $realPathDoc2 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '.' . 'doc';
$sw_file_exists = false; if (file_exists($realPathDoc)) {
if (file_exists( $realPathDoc )) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_doc = true; $sw_file_exists_doc = true;
} elseif (file_exists( $realPathDoc1 )) { } elseif (file_exists($realPathDoc1)) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_doc = true; $sw_file_exists_doc = true;
$realPathDoc = $realPathDoc1; $realPathDoc = $realPathDoc1;
} elseif (file_exists( $realPathDoc2 )) { } elseif (file_exists($realPathDoc2)) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_doc = true; $sw_file_exists_doc = true;
$realPathDoc = $realPathDoc2; $realPathDoc = $realPathDoc2;
} }
$realPathPdf = PATH_DOCUMENT . $appUid . '/outdocs/' . $appDocUid . '_' . $docVersion . '.' . 'pdf'; $realPathPdf = PATH_DOCUMENT . $appUid . '/outdocs/' . $appDocUid . '_' . $docVersion . '.' . 'pdf';
$realPathPdf1 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '_' .$docVersion . '.' . 'pdf'; $realPathPdf1 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '_' . $docVersion . '.' . 'pdf';
$realPathPdf2 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '.' . 'pdf'; $realPathPdf2 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '.' . 'pdf';
if (file_exists( $realPathPdf )) { if (file_exists($realPathPdf)) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_pdf = true; $sw_file_exists_pdf = true;
} elseif (file_exists( $realPathPdf1 )) { } elseif (file_exists($realPathPdf1)) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_pdf = true; $sw_file_exists_pdf = true;
$realPathPdf = $realPathPdf1; $realPathPdf = $realPathPdf1;
} elseif (file_exists( $realPathPdf2 )) { } elseif (file_exists($realPathPdf2)) {
$sw_file_exists = true; $sw_file_exists = true;
$sw_file_exists_pdf = true; $sw_file_exists_pdf = true;
$realPathPdf = $realPathPdf2; $realPathPdf = $realPathPdf2;
} }
} else { } else {
$realPath = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '_' . $docVersion . '.' . $ext; $realPath = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '_' . $docVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '.' . $ext; $realPath1 = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '.' . $ext;
$sw_file_exists = false; if (file_exists($realPath)) {
if (file_exists( $realPath )) {
$sw_file_exists = true; $sw_file_exists = true;
} elseif (file_exists( $realPath1 )) { } elseif (file_exists($realPath1)) {
$sw_file_exists = true; $sw_file_exists = true;
$realPath = $realPath1; $realPath = $realPath1;
} }
@@ -367,34 +368,33 @@ class AppDocumentDrive
if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') { if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') {
if ($log) { if ($log) {
eprintln('upload file:' . $name , 'green'); eprintln('upload file:' . $name, 'green');
} }
$this->drive->setDriveUser($email); $this->drive->setDriveUser($email);
$info = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($info, $realPath);
$type = $appDoc->getAppDocType();
if ($appDoc->getAppDocType() == 'OUTPUT') { if ($appDoc->getAppDocType() == 'OUTPUT') {
if ($sw_file_exists_doc) { if ($sw_file_exists_doc) {
$realPath = $realPathDoc; $result = $this->upload($fields, 'OUTPUT_DOC', 'application/msword', $realPathDoc,
$name = array_pop(explode('/', $realPathDoc)); array_pop(explode('/', $realPathDoc)));
$mime = 'application/msword';
$type = 'OUTPUT_DOC';
} }
if ($sw_file_exists_pdf) { if ($sw_file_exists_pdf) {
$realPath = $realPathPdf; $info = finfo_open(FILEINFO_MIME_TYPE);
$name = array_pop(explode('/', $realPathPdf)); $result = $this->upload($fields, 'OUTPUT_PDF', finfo_file($info, $realPathPdf),
$mime = finfo_file($info, $realPathPdf); $realPathPdf, array_pop(explode('/', $realPathPdf)));
$type = 'OUTPUT_PDF';
} }
} else {
$info = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($info, $realPath);
$type = $appDoc->getAppDocType();
$result = $this->upload($fields, $type, $mime, $realPath, $name);
} }
$result = $this->upload($fields, $type, $mime, $realPath, $name);
} else { } else {
$this->drive->setDriveUser($this->user->getUsrEmail()); $this->drive->setDriveUser($this->user->getUsrEmail());
} }
if ($log) { if ($log) {
eprintln('Set Permission:' . $email , 'green'); eprintln('Set Permission:' . $email, 'green');
} }
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer'); $this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
@@ -407,7 +407,7 @@ class AppDocumentDrive
} else { } else {
$fields['SYNC_WITH_DRIVE'] = 'NO_EXIST_FILE_PM'; $fields['SYNC_WITH_DRIVE'] = 'NO_EXIST_FILE_PM';
if ($log) { if ($log) {
eprintln('File no exists:' . $name , 'red'); eprintln('File no exists:' . $name, 'red');
} }
} }
$appDoc->update($fields); $appDoc->update($fields);

View File

@@ -5314,8 +5314,6 @@ class Cases
$oUser = new Users(); $oUser = new Users();
foreach ($arrayTask as $aTask) { foreach ($arrayTask as $aTask) {
$sTo = null;
$sCc = null;
if (isset($aTask['DEL_INDEX'])) { if (isset($aTask['DEL_INDEX'])) {
$arrayData2 = $arrayData; $arrayData2 = $arrayData;
@@ -5342,132 +5340,20 @@ class Cases
$sBody2 = G::replaceDataGridField($sBody, $arrayData2, false); $sBody2 = G::replaceDataGridField($sBody, $arrayData2, false);
switch ($aTask["TAS_ASSIGN_TYPE"]) { $respTo = $this->getTo($aTask["TAS_ASSIGN_TYPE"], $aTask["TAS_UID"], $aTask["USR_UID"], $arrayData);
case "SELF_SERVICE": $sTo = $respTo['to'];
if ($swtplDefault == 1) { $sCc = $respTo['cc'];
G::verifyPath($pathEmail, true); //Create if it does not exist
$fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
if ($swtplDefault == 1) {
if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { G::verifyPath ( $pathEmail, true ); // Create if it does not exist
@copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); $fileTemplate = $pathEmail . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' );
}
if ((! file_exists ( $fileTemplate )) && file_exists ( PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' ) )) {
$sBody2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2); @copy ( PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' ), $fileTemplate );
} }
$sBody2 = G::replaceDataField ( file_get_contents ( $fileTemplate ), $arrayData2 );
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;
case "MULTIPLE_INSTANCE":
$to = null;
$cc = null;
$sw = 1;
$oDerivation = new Derivation();
$userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($aTask["TAS_UID"]));
if(isset($userFields)){
foreach($userFields as $row){
$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;
case "MULTIPLE_INSTANCE_VALUE_BASED":
$aTaskNext = $oTask->load($aTask["TAS_UID"]);
if(isset($aTaskNext["TAS_ASSIGN_VARIABLE"]) && !empty($aTaskNext["TAS_ASSIGN_VARIABLE"])){
$to = null;
$cc = null;
$sw = 1;
$nextTaskAssignVariable = trim($aTaskNext["TAS_ASSIGN_VARIABLE"], " @#");
$arrayUsers = $arrayData[$nextTaskAssignVariable];
$oDerivation = new Derivation();
$userFields = $oDerivation->getUsersFullNameFromArray($arrayUsers);
foreach ($userFields as $row) {
$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) { if ($sTo != null) {
@@ -5504,6 +5390,124 @@ class Cases
} catch (Exception $oException) { } catch (Exception $oException) {
throw $oException; throw $oException;
} }
}
public function getTo($taskType, $taskUid, $taskUsrUid, $arrayData)
{
$sTo = null;
$sCc = null;
$arrayResp = array ();
$task = new Tasks ();
$group = new Groups ();
$oUser = new Users ();
switch ($taskType) {
case "SELF_SERVICE" :
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"];
}
$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;
}
}
$arrayResp ['to'] = $to;
$arrayResp ['cc'] = $cc;
}
break;
case "MULTIPLE_INSTANCE" :
$to = null;
$cc = null;
$sw = 1;
$oDerivation = new Derivation ();
$userFields = $oDerivation->getUsersFullNameFromArray ( $oDerivation->getAllUsersFromAnyTask ( $taskUid ) );
if (isset ( $userFields )) {
foreach ( $userFields as $row ) {
$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;
}
break;
case "MULTIPLE_INSTANCE_VALUE_BASED" :
$oTask = new Task ();
$aTaskNext = $oTask->load ( $taskUid );
if (isset ( $aTaskNext ["TAS_ASSIGN_VARIABLE"] ) && ! empty ( $aTaskNext ["TAS_ASSIGN_VARIABLE"] )) {
$to = null;
$cc = null;
$sw = 1;
$nextTaskAssignVariable = trim ( $aTaskNext ["TAS_ASSIGN_VARIABLE"], " @#" );
$arrayUsers = $arrayData [$nextTaskAssignVariable];
$oDerivation = new Derivation ();
$userFields = $oDerivation->getUsersFullNameFromArray ( $arrayUsers );
foreach ( $userFields as $row ) {
$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;
}
break;
default :
if (isset ( $taskUsrUid ) && ! empty ( $taskUsrUid )) {
$aUser = $oUser->load ( $taskUsrUid );
$sTo = ((($aUser ["USR_FIRSTNAME"] != "") || ($aUser ["USR_LASTNAME"] != "")) ? $aUser ["USR_FIRSTNAME"] . " " . $aUser ["USR_LASTNAME"] . " " : "") . "<" . $aUser ["USR_EMAIL"] . ">";
}
$arrayResp ['to'] = $sTo;
$arrayResp ['cc'] = '';
break;
}
return $arrayResp;
} }
/** /**

View File

@@ -2,6 +2,7 @@
if (typeof window.parent != 'undefined') { if (typeof window.parent != 'undefined') {
<?php <?php
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$pathDerivateGmail = 'derivatedGmail';
$statusPMGmail = false; $statusPMGmail = false;
$licensedFeatures = &PMLicensedFeatures::getSingleton(); $licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
@@ -20,8 +21,10 @@ if (isset( $_GET['ux'] )) {
default: default:
$url = 'casesListExtJs'; $url = 'casesListExtJs';
} }
} else if( key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && $statusPMGmail ){ /*----------------------------------********---------------------------------*/
$url = 'derivatedGmail'; } else if( $statusPMGmail ){
$url = $pathDerivateGmail;
/*----------------------------------********---------------------------------*/
} else { } else {
$url = 'casesListExtJs'; $url = 'casesListExtJs';
} }
@@ -32,7 +35,7 @@ echo " window.parent.location.href = '$url';";
if (isset( $_GET['ux'] )) { if (isset( $_GET['ux'] )) {
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
if(PMLicensedFeatures::getSingleton()->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') && $statusPMGmail){ if(PMLicensedFeatures::getSingleton()->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') && $statusPMGmail){
echo '} else { window.parent.location.href = \'derivatedGmail\'; }'; echo '} else { window.parent.location.href = \''.$pathDerivateGmail.'\'; }';
} else { } else {
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
echo '} else { window.parent.location.href = \'casesListExtJs\'; }'; echo '} else { window.parent.location.href = \'casesListExtJs\'; }';

View File

@@ -271,7 +271,7 @@ function startCase ()
if($pmGoogle->getServiceGmailStatus()){ if($pmGoogle->getServiceGmailStatus()){
require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php'; require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php';
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail(); $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX']); $response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX'], null, null);
} }
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/

View File

@@ -163,7 +163,35 @@ try {
// Send notifications - Start // Send notifications - Start
$oUser = new Users(); $oUser = new Users();
$aUser = $oUser->load( $_SESSION['USER_LOGGED'] ); $aUser = $oUser->load( $_SESSION['USER_LOGGED'] );
$sFromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : ''); $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'] );
}
}
}
}
}
/*----------------------------------********---------------------------------*/
try { try {
$oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName ); $oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName );
} catch (Exception $e) { } catch (Exception $e) {
@@ -223,15 +251,16 @@ try {
// Set users drive - End // Set users drive - End
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$debuggerAvailable = true; $debuggerAvailable = true;
if (isset( $_SESSION['user_experience'] )) { $casesRedirector = 'casesListExtJsRedirector';
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience']; if (isset ( $_SESSION ['user_experience'] ) && $flagGmail === false) {
$debuggerAvailable = false; $aNextStep ['PAGE'] = $casesRedirector . '?ux=' . $_SESSION ['user_experience'];
} else if( isset( $_SESSION['gmail'] ) ){ $debuggerAvailable = false;
$aNextStep['PAGE'] = 'casesListExtJsRedirector?gmail='.$_SESSION['gmail']; } else if ($flagGmail === true) {
} else { $aNextStep ['PAGE'] = $casesRedirector . '?gmail=1';
$aNextStep['PAGE'] = 'casesListExtJsRedirector'; } else {
$aNextStep ['PAGE'] = $casesRedirector;
} }
if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) { if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {

View File

@@ -17,19 +17,6 @@ $appDel = new AppDelegation();
$actualThread = $appDel->Load($caseId, $actualIndex); $actualThread = $appDel->Load($caseId, $actualIndex);
$actualLastIndex = $actualThread['DEL_PREVIOUS']; $actualLastIndex = $actualThread['DEL_PREVIOUS'];
$appDelPrev = $appDel->LoadParallel($caseId);
if($appDelPrev == array()){
$appDelPrev['0'] = $actualThread;
}
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
foreach ($appDelPrev as $app){
if( ($app['DEL_INDEX'] != $actualIndex) && ($app['DEL_PREVIOUS'] != $actualLastIndex) ){ //Sending the email to all threads of the case except the actual thread
$response = $Pmgmail->sendEmail($caseId, "", $app['DEL_INDEX']);
}
}
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();
$oLabels->addRelabelingToQueue($caseId, $actualIndex, $actualLastIndex, false); $oLabels->addRelabelingToQueue($caseId, $actualIndex, $actualLastIndex, false);

View File

@@ -80,16 +80,25 @@ class Pmgmail {
* return uid * return uid
* *
*/ */
public function sendEmail($app_uid, $mail, $index) public function sendEmail($app_uid, $mailToAddresses, $index, $arrayTask = null, $arrayData = null)
{ {
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php"); require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php");
//getting the default email server
$defaultEmail = $this->emailAccount();
if ($defaultEmail === null) {
error_log(G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED'));
return false;
}
$mailCcAddresses = "";
$oApplication = new \Application(); $oApplication = new \Application();
$formData = $oApplication->Load($app_uid); $formData = $oApplication->Load($app_uid);
$frmData = unserialize($formData['APP_DATA']); $frmData = unserialize($formData['APP_DATA']);
$dataFormToShowString = ""; $dataFormToShowString = "";
foreach ($frmData as $field=>$value){
if( ($field != 'SYS_LANG') && foreach ($frmData as $field => $value) {
if (($field != 'SYS_LANG') &&
($field != 'SYS_SKIN') && ($field != 'SYS_SKIN') &&
($field != 'SYS_SYS') && ($field != 'SYS_SYS') &&
($field != 'APPLICATION') && ($field != 'APPLICATION') &&
@@ -99,13 +108,15 @@ class Pmgmail {
($field != 'USER_LOGGED') && ($field != 'USER_LOGGED') &&
($field != 'USR_USERNAME') && ($field != 'USR_USERNAME') &&
($field != 'DYN_CONTENT_HISTORY') && ($field != 'DYN_CONTENT_HISTORY') &&
($field != 'PIN') ){ ($field != 'PIN') &&
(!is_array($value))
) {
$dataFormToShowString .= " " . $field . " " . $value; $dataFormToShowString .= " " . $field . " " . $value;
} }
} }
$appData = $this->getDraftApp($app_uid, $index); $appData = $this->getDraftApp($app_uid, $index);
foreach ($appData as $application){ foreach ($appData as $application) {
$appNumber = $application['APP_NUMBER']; $appNumber = $application['APP_NUMBER'];
$appStatus = $application['APP_STATUS']; $appStatus = $application['APP_STATUS'];
$index = $application['DEL_INDEX']; $index = $application['DEL_INDEX'];
@@ -119,39 +130,69 @@ class Pmgmail {
$tasUid = $application['TAS_UID']; $tasUid = $application['TAS_UID'];
$lastIndex = $application['DEL_LAST_INDEX']; $lastIndex = $application['DEL_LAST_INDEX'];
if($appStatus == "DRAFT"){ if ($appStatus == "DRAFT") {
$labelID = "PMDRFT"; $labelID = "PMDRFT";
} else { } else {
$labelID = "PMIBX"; $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($mail == ""){ if (is_array($targetIds)) {
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php"); foreach ( $targetIds as $user ) {
$oUsers = new \Users(); $usrData = $oUsers->loadDetails ( $user );
$nextMail = $usrData ['USR_EMAIL'];
if($nextUsr == ""){ $mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
//Unassigned: }
$mail = ""; } else {
$group = new \Groups();
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); $users = $group->getUsersOfGroup($targetIds);
$oTaskUsers = new \TaskUser(); foreach ($users as $user) {
$nextMail = $user['USR_EMAIL'];
$taskUsers = $oTaskUsers->getAllUsersTask($tasUid); $mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
foreach ($taskUsers as $user){ }
$usrData = $oUsers->loadDetails($user['USR_UID']); }
$nextMail = $usrData['USR_EMAIL']; }
$mail .= ($mail == '') ? $nextMail : ','. $nextMail;
} }
$labelID = "PMUASS"; }
}else { } else {
$usrData = $oUsers->loadDetails($nextUsr); $oUsers = new \Users ();
$mail = $usrData['USR_EMAIL'];
} $usrData = $oUsers->loadDetails ( $nextUsr );
$mailToAddresses = $usrData ['USR_EMAIL'];
}
} }
//first template //first template
$pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html"; $pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html";
if (!file_exists($pathTemplate)){ if (!file_exists($pathTemplate)) {
$file = @fopen($pathTemplate, "w"); $file = @fopen($pathTemplate, "w");
fwrite($file, '<div>'); fwrite($file, '<div>');
fwrite($file, '<span style="display: none !important;">'); fwrite($file, '<span style="display: none !important;">');
@@ -173,7 +214,8 @@ class Pmgmail {
$change = array('[', ']', '"'); $change = array('[', ']', '"');
$fdata = str_replace($change, ' ', $dataFormToShowString); $fdata = str_replace($change, ' ', $dataFormToShowString);
$aFields = array('proName' => $proName, $aFields = array(
'proName' => $proName,
'appNumber' => $appNumber, 'appNumber' => $appNumber,
'caseUid' => $app_uid, 'caseUid' => $app_uid,
'taskName' => $tasName, 'taskName' => $tasName,
@@ -186,18 +228,15 @@ class Pmgmail {
'oform' => $fdata 'oform' => $fdata
); );
$subject = "[PM] " .$proName. " (" . $index . ") Case: ". $appNumber; $subject = "[PM] " . $proName . " (" . $index . ") Case: " . $appNumber;
//getting the default email server
$defaultEmail = $this->emailAccount();
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.wsBase.php");
$ws = new \wsBase(); $ws = new \wsBase();
$resultMail = $ws->sendMessage( $resultMail = $ws->sendMessage(
$app_uid, $app_uid,
$defaultEmail, //From, $defaultEmail, //From,
$mail,//To, $mailToAddresses,//$To,
'', $mailCcAddresses,//$Cc
'', '',
$subject, $subject,
'pmGmail.html',//template 'pmGmail.html',//template
@@ -279,5 +318,3 @@ class Pmgmail {
} }
} }

View File

@@ -1,6 +1,7 @@
<?php <?php
session_start(); session_start();
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.bootstrap.php'); require_once (dirname(__FILE__) . '/../../../gulliver/system/class.bootstrap.php');
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.g.php');
$gmailToken = $_GET['gmailToken']; $gmailToken = $_GET['gmailToken'];
$gmail = $_GET['gmail']; $gmail = $_GET['gmail'];
@@ -22,28 +23,34 @@ $gCurl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegrat
curl_setopt( $gCurl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $gCurl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) );
curl_setopt( $gCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $gCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($gCurl, CURLOPT_SSL_VERIFYHOST, false);
$gCurl_response = curl_exec( $gCurl );
curl_close($gCurl); if (curl_exec ( $gCurl ) === false) {
$gResp = json_decode($gCurl_response); echo 'Curl error: ' . curl_error ( $gCurl );
error_log(Bootstrap::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR'));
if($gResp == false){ die ();
echo Bootstrap::LoadTranslation( 'ID_NO_LICENSE_FEATURE_ENABLED' ); } else {
die; $gCurl_response = curl_exec ( $gCurl );
curl_close ( $gCurl );
$gResp = G::json_decode ( $gCurl_response );
if ($gResp === false) {
echo Bootstrap::LoadTranslation ( 'ID_NO_LICENSE_FEATURE_ENABLED' );
die ();
}
} }
set_time_limit(60); set_time_limit(60);
$curl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/userexist/' . $gmail ); $curl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/userexist/' . $gmail );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false); curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0);
$curl_response = curl_exec( $curl ); $curl_response = curl_exec( $curl );
curl_close($curl); curl_close($curl);
$decodedResp = json_decode($curl_response); $decodedResp = G::json_decode($curl_response);
if(!is_object($decodedResp) || property_exists($decodedResp,'error')) { if(!is_object($decodedResp) || property_exists($decodedResp,'error')) {
die($decodedResp->error->message); die($decodedResp->error->message);
@@ -67,16 +74,17 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp
// init curl object // init curl object
$ch = curl_init(); $ch = curl_init();
// define options // define options
$optArray = array( $optArray = array(
CURLOPT_URL => $url, CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
); );
// apply those options // apply those options
curl_setopt_array($ch, $optArray); curl_setopt_array($ch, $optArray);
// execute request and get response // execute request and get response
$result = curl_exec($ch); $result = curl_exec($ch);
$response = (json_decode($result)); $response = (G::json_decode($result));
curl_close($ch); curl_close($ch);
//First validate if this user (mail) corresponds to a PM user //First validate if this user (mail) corresponds to a PM user
@@ -118,12 +126,15 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp
if ($action == "draft"){ if ($action == "draft"){
//sending the email //sending the email
$curlApp = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/sendEmail/' . $appUid . '/to/' . $gmail . '/index/' . $delIndex ); $curlApp = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/sendEmail/' . $appUid . '/to/' . $gmail . '/index/' . $delIndex );
curl_setopt( $curlApp, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt ( $curlApp, CURLOPT_HTTPHEADER, array (
curl_setopt( $curlApp, CURLOPT_CUSTOMREQUEST, "POST"); 'Authorization: Bearer ' . $pmtoken
curl_setopt( $curlApp, CURLOPT_RETURNTRANSFER, true); ) );
curl_setopt( $curlApp, CURLOPT_SSL_VERIFYPEER,false); curl_setopt ( $curlApp, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt( $curlApp, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt ( $curlApp, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $curlApp, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $curlApp, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt ( $curlApp, CURLOPT_CONNECTTIMEOUT, 0 );
$curl_response_app = curl_exec( $curlApp ); $curl_response_app = curl_exec( $curlApp );
curl_close( $curlApp ); curl_close( $curlApp );