@@ -175,15 +175,17 @@ class AppDocumentDrive
|
||||
$data = [];
|
||||
while ($rsAppDelegation->next()) {
|
||||
$row = $rsAppDelegation->getRow();
|
||||
if ($user->userExists($row['USR_UID'])) {
|
||||
$data = [];
|
||||
$data[] = $user->load($row['USR_UID']);
|
||||
} else {
|
||||
$data = $group->getUsersOfGroup($row['USR_UID']);
|
||||
}
|
||||
if (!empty($row['USR_UID'])) {
|
||||
if ($user->userExists($row['USR_UID'])) {
|
||||
$data = [];
|
||||
$data[] = $user->load($row['USR_UID']);
|
||||
} else {
|
||||
$data = $group->getUsersOfGroup($row['USR_UID']);
|
||||
}
|
||||
|
||||
foreach ($data as $dataUser) {
|
||||
$this->addUserEmail($dataUser["USR_EMAIL"]);
|
||||
foreach ($data as $dataUser) {
|
||||
$this->addUserEmail($dataUser["USR_EMAIL"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
@@ -278,18 +280,18 @@ class AppDocumentDrive
|
||||
error_log("It has not enabled Feature Gmail");
|
||||
return;
|
||||
}
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL )->
|
||||
addOr($criteria->getNewCriterion( AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL ))
|
||||
$criteria->getNewCriterion(AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL)->
|
||||
addOr($criteria->getNewCriterion(AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL))
|
||||
);
|
||||
|
||||
$criteria->addAscendingOrderByColumn( 'APP_DOC_CREATE_DATE' );
|
||||
$criteria->addAscendingOrderByColumn( 'APP_UID' );
|
||||
$rs = AppDocumentPeer::doSelectRS( $criteria );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$criteria->addAscendingOrderByColumn('APP_DOC_CREATE_DATE');
|
||||
$criteria->addAscendingOrderByColumn('APP_UID');
|
||||
$rs = AppDocumentPeer::doSelectRS($criteria);
|
||||
$rs->setFetchMode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
@@ -298,58 +300,57 @@ class AppDocumentDrive
|
||||
|
||||
$appDocUid = $appDoc->getAppDocUid();
|
||||
$docVersion = $appDoc->getDocVersion();
|
||||
$filename = pathinfo( $appDoc->getAppDocFilename() );
|
||||
$name = !empty($filename['basename'])? $filename['basename'] : '';
|
||||
$ext = !empty($filename['extension'])? $filename['extension'] : '';
|
||||
$filename = pathinfo($appDoc->getAppDocFilename());
|
||||
$name = !empty($filename['basename']) ? $filename['basename'] : '';
|
||||
$ext = !empty($filename['extension']) ? $filename['extension'] : '';
|
||||
$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_pdf = false;
|
||||
if ($appDoc->getAppDocType() == 'OUTPUT') {
|
||||
//$name = substr($name, 1, -1);
|
||||
$sw_file_exists = false;
|
||||
$realPath = '';
|
||||
if ($appDoc->getAppDocType() === 'OUTPUT') {
|
||||
$realPathDoc = PATH_DOCUMENT . $appUid . '/outdocs/' . $appDocUid . '_' . $docVersion . '.' . 'doc';
|
||||
$realPathDoc1 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '_' . $docVersion . '.' . '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_doc = true;
|
||||
} elseif (file_exists( $realPathDoc1 )) {
|
||||
} elseif (file_exists($realPathDoc1)) {
|
||||
$sw_file_exists = true;
|
||||
$sw_file_exists_doc = true;
|
||||
$realPathDoc = $realPathDoc1;
|
||||
} elseif (file_exists( $realPathDoc2 )) {
|
||||
} elseif (file_exists($realPathDoc2)) {
|
||||
$sw_file_exists = true;
|
||||
$sw_file_exists_doc = true;
|
||||
$realPathDoc = $realPathDoc2;
|
||||
}
|
||||
|
||||
$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';
|
||||
|
||||
if (file_exists( $realPathPdf )) {
|
||||
if (file_exists($realPathPdf)) {
|
||||
$sw_file_exists = true;
|
||||
$sw_file_exists_pdf = true;
|
||||
} elseif (file_exists( $realPathPdf1 )) {
|
||||
} elseif (file_exists($realPathPdf1)) {
|
||||
$sw_file_exists = true;
|
||||
$sw_file_exists_pdf = true;
|
||||
$realPathPdf = $realPathPdf1;
|
||||
} elseif (file_exists( $realPathPdf2 )) {
|
||||
} elseif (file_exists($realPathPdf2)) {
|
||||
$sw_file_exists = true;
|
||||
$sw_file_exists_pdf = true;
|
||||
$realPathPdf = $realPathPdf2;
|
||||
}
|
||||
} 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;
|
||||
$sw_file_exists = false;
|
||||
if (file_exists( $realPath )) {
|
||||
if (file_exists($realPath)) {
|
||||
$sw_file_exists = true;
|
||||
} elseif (file_exists( $realPath1 )) {
|
||||
} elseif (file_exists($realPath1)) {
|
||||
$sw_file_exists = true;
|
||||
$realPath = $realPath1;
|
||||
}
|
||||
@@ -367,34 +368,33 @@ class AppDocumentDrive
|
||||
|
||||
if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') {
|
||||
if ($log) {
|
||||
eprintln('upload file:' . $name , 'green');
|
||||
eprintln('upload file:' . $name, 'green');
|
||||
}
|
||||
$this->drive->setDriveUser($email);
|
||||
$info = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mime = finfo_file($info, $realPath);
|
||||
$type = $appDoc->getAppDocType();
|
||||
|
||||
if ($appDoc->getAppDocType() == 'OUTPUT') {
|
||||
|
||||
if ($sw_file_exists_doc) {
|
||||
$realPath = $realPathDoc;
|
||||
$name = array_pop(explode('/', $realPathDoc));
|
||||
$mime = 'application/msword';
|
||||
$type = 'OUTPUT_DOC';
|
||||
$result = $this->upload($fields, 'OUTPUT_DOC', 'application/msword', $realPathDoc,
|
||||
array_pop(explode('/', $realPathDoc)));
|
||||
}
|
||||
if ($sw_file_exists_pdf) {
|
||||
$realPath = $realPathPdf;
|
||||
$name = array_pop(explode('/', $realPathPdf));
|
||||
$mime = finfo_file($info, $realPathPdf);
|
||||
$type = 'OUTPUT_PDF';
|
||||
$info = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$result = $this->upload($fields, 'OUTPUT_PDF', finfo_file($info, $realPathPdf),
|
||||
$realPathPdf, array_pop(explode('/', $realPathPdf)));
|
||||
}
|
||||
} 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 {
|
||||
$this->drive->setDriveUser($this->user->getUsrEmail());
|
||||
}
|
||||
if ($log) {
|
||||
eprintln('Set Permission:' . $email , 'green');
|
||||
eprintln('Set Permission:' . $email, 'green');
|
||||
}
|
||||
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
|
||||
|
||||
@@ -407,7 +407,7 @@ class AppDocumentDrive
|
||||
} else {
|
||||
$fields['SYNC_WITH_DRIVE'] = 'NO_EXIST_FILE_PM';
|
||||
if ($log) {
|
||||
eprintln('File no exists:' . $name , 'red');
|
||||
eprintln('File no exists:' . $name, 'red');
|
||||
}
|
||||
}
|
||||
$appDoc->update($fields);
|
||||
|
||||
@@ -5314,8 +5314,6 @@ class Cases
|
||||
$oUser = new Users();
|
||||
|
||||
foreach ($arrayTask as $aTask) {
|
||||
$sTo = null;
|
||||
$sCc = null;
|
||||
|
||||
if (isset($aTask['DEL_INDEX'])) {
|
||||
$arrayData2 = $arrayData;
|
||||
@@ -5342,132 +5340,20 @@ class Cases
|
||||
|
||||
$sBody2 = G::replaceDataGridField($sBody, $arrayData2, false);
|
||||
|
||||
switch ($aTask["TAS_ASSIGN_TYPE"]) {
|
||||
case "SELF_SERVICE":
|
||||
if ($swtplDefault == 1) {
|
||||
G::verifyPath($pathEmail, true); //Create if it does not exist
|
||||
$fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE');
|
||||
|
||||
if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) {
|
||||
@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;
|
||||
$respTo = $this->getTo($aTask["TAS_ASSIGN_TYPE"], $aTask["TAS_UID"], $aTask["USR_UID"], $arrayData);
|
||||
$sTo = $respTo['to'];
|
||||
$sCc = $respTo['cc'];
|
||||
|
||||
if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
|
||||
if ($swtplDefault == 1) {
|
||||
G::verifyPath ( $pathEmail, true ); // Create if it does not exist
|
||||
$fileTemplate = $pathEmail . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' );
|
||||
|
||||
if ((! file_exists ( $fileTemplate )) && file_exists ( PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' ) )) {
|
||||
@copy ( PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation ( 'ID_UNASSIGNED_MESSAGE' ), $fileTemplate );
|
||||
}
|
||||
$sBody2 = G::replaceDataField ( file_get_contents ( $fileTemplate ), $arrayData2 );
|
||||
}
|
||||
}
|
||||
|
||||
if ($sTo != null) {
|
||||
@@ -5504,6 +5390,124 @@ class Cases
|
||||
} catch (Exception $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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
if (typeof window.parent != 'undefined') {
|
||||
<?php
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$pathDerivateGmail = 'derivatedGmail';
|
||||
$statusPMGmail = false;
|
||||
$licensedFeatures = &PMLicensedFeatures::getSingleton();
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
@@ -20,8 +21,10 @@ if (isset( $_GET['ux'] )) {
|
||||
default:
|
||||
$url = 'casesListExtJs';
|
||||
}
|
||||
} else if( key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && $statusPMGmail ){
|
||||
$url = 'derivatedGmail';
|
||||
/*----------------------------------********---------------------------------*/
|
||||
} else if( $statusPMGmail ){
|
||||
$url = $pathDerivateGmail;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
} else {
|
||||
$url = 'casesListExtJs';
|
||||
}
|
||||
@@ -32,7 +35,7 @@ echo " window.parent.location.href = '$url';";
|
||||
if (isset( $_GET['ux'] )) {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if(PMLicensedFeatures::getSingleton()->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') && $statusPMGmail){
|
||||
echo '} else { window.parent.location.href = \'derivatedGmail\'; }';
|
||||
echo '} else { window.parent.location.href = \''.$pathDerivateGmail.'\'; }';
|
||||
} else {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
echo '} else { window.parent.location.href = \'casesListExtJs\'; }';
|
||||
|
||||
@@ -271,7 +271,7 @@ function startCase ()
|
||||
if($pmGoogle->getServiceGmailStatus()){
|
||||
require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php';
|
||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
||||
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX']);
|
||||
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX'], null, null);
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
@@ -163,7 +163,35 @@ 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'] . '>' : '');
|
||||
$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 {
|
||||
$oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName );
|
||||
} catch (Exception $e) {
|
||||
@@ -223,15 +251,16 @@ try {
|
||||
// Set users drive - End
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$debuggerAvailable = true;
|
||||
|
||||
if (isset( $_SESSION['user_experience'] )) {
|
||||
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience'];
|
||||
$debuggerAvailable = false;
|
||||
} else if( isset( $_SESSION['gmail'] ) ){
|
||||
$aNextStep['PAGE'] = 'casesListExtJsRedirector?gmail='.$_SESSION['gmail'];
|
||||
} else {
|
||||
$aNextStep['PAGE'] = 'casesListExtJsRedirector';
|
||||
$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) {
|
||||
|
||||
@@ -17,19 +17,6 @@ $appDel = new AppDelegation();
|
||||
$actualThread = $appDel->Load($caseId, $actualIndex);
|
||||
$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");
|
||||
$oLabels = new labelsGmail();
|
||||
$oLabels->addRelabelingToQueue($caseId, $actualIndex, $actualLastIndex, false);
|
||||
|
||||
@@ -80,16 +80,25 @@ class Pmgmail {
|
||||
* 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");
|
||||
//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();
|
||||
$formData = $oApplication->Load($app_uid);
|
||||
|
||||
$frmData = unserialize($formData['APP_DATA']);
|
||||
$dataFormToShowString = "";
|
||||
foreach ($frmData as $field=>$value){
|
||||
if( ($field != 'SYS_LANG') &&
|
||||
|
||||
foreach ($frmData as $field => $value) {
|
||||
if (($field != 'SYS_LANG') &&
|
||||
($field != 'SYS_SKIN') &&
|
||||
($field != 'SYS_SYS') &&
|
||||
($field != 'APPLICATION') &&
|
||||
@@ -99,13 +108,15 @@ class Pmgmail {
|
||||
($field != 'USER_LOGGED') &&
|
||||
($field != 'USR_USERNAME') &&
|
||||
($field != 'DYN_CONTENT_HISTORY') &&
|
||||
($field != 'PIN') ){
|
||||
($field != 'PIN') &&
|
||||
(!is_array($value))
|
||||
) {
|
||||
$dataFormToShowString .= " " . $field . " " . $value;
|
||||
}
|
||||
}
|
||||
$appData = $this->getDraftApp($app_uid, $index);
|
||||
|
||||
foreach ($appData as $application){
|
||||
foreach ($appData as $application) {
|
||||
$appNumber = $application['APP_NUMBER'];
|
||||
$appStatus = $application['APP_STATUS'];
|
||||
$index = $application['DEL_INDEX'];
|
||||
@@ -119,39 +130,69 @@ class Pmgmail {
|
||||
$tasUid = $application['TAS_UID'];
|
||||
$lastIndex = $application['DEL_LAST_INDEX'];
|
||||
|
||||
if($appStatus == "DRAFT"){
|
||||
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($mail == ""){
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
||||
$oUsers = new \Users();
|
||||
|
||||
if($nextUsr == ""){
|
||||
//Unassigned:
|
||||
$mail = "";
|
||||
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php");
|
||||
$oTaskUsers = new \TaskUser();
|
||||
|
||||
$taskUsers = $oTaskUsers->getAllUsersTask($tasUid);
|
||||
foreach ($taskUsers as $user){
|
||||
$usrData = $oUsers->loadDetails($user['USR_UID']);
|
||||
$nextMail = $usrData['USR_EMAIL'];
|
||||
$mail .= ($mail == '') ? $nextMail : ','. $nextMail;
|
||||
}
|
||||
$labelID = "PMUASS";
|
||||
}else {
|
||||
$usrData = $oUsers->loadDetails($nextUsr);
|
||||
$mail = $usrData['USR_EMAIL'];
|
||||
}
|
||||
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)){
|
||||
if (!file_exists($pathTemplate)) {
|
||||
$file = @fopen($pathTemplate, "w");
|
||||
fwrite($file, '<div>');
|
||||
fwrite($file, '<span style="display: none !important;">');
|
||||
@@ -173,7 +214,8 @@ class Pmgmail {
|
||||
|
||||
$change = array('[', ']', '"');
|
||||
$fdata = str_replace($change, ' ', $dataFormToShowString);
|
||||
$aFields = array('proName' => $proName,
|
||||
$aFields = array(
|
||||
'proName' => $proName,
|
||||
'appNumber' => $appNumber,
|
||||
'caseUid' => $app_uid,
|
||||
'taskName' => $tasName,
|
||||
@@ -186,18 +228,15 @@ class Pmgmail {
|
||||
'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();
|
||||
|
||||
$resultMail = $ws->sendMessage(
|
||||
$app_uid,
|
||||
$defaultEmail, //From,
|
||||
$mail,//To,
|
||||
'',
|
||||
$mailToAddresses,//$To,
|
||||
$mailCcAddresses,//$Cc
|
||||
'',
|
||||
$subject,
|
||||
'pmGmail.html',//template
|
||||
@@ -279,5 +318,3 @@ class Pmgmail {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.bootstrap.php');
|
||||
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.g.php');
|
||||
|
||||
$gmailToken = $_GET['gmailToken'];
|
||||
$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_RETURNTRANSFER, true);
|
||||
curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0);
|
||||
|
||||
$gCurl_response = curl_exec( $gCurl );
|
||||
curl_close($gCurl);
|
||||
$gResp = json_decode($gCurl_response);
|
||||
|
||||
if($gResp == false){
|
||||
echo Bootstrap::LoadTranslation( 'ID_NO_LICENSE_FEATURE_ENABLED' );
|
||||
die;
|
||||
curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0);
|
||||
curl_setopt($gCurl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
if (curl_exec ( $gCurl ) === false) {
|
||||
echo 'Curl error: ' . curl_error ( $gCurl );
|
||||
error_log(Bootstrap::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR'));
|
||||
die ();
|
||||
} else {
|
||||
$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);
|
||||
|
||||
$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_RETURNTRANSFER, true);
|
||||
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false);
|
||||
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0);
|
||||
|
||||
$curl_response = curl_exec( $curl );
|
||||
curl_close($curl);
|
||||
$decodedResp = json_decode($curl_response);
|
||||
$decodedResp = G::json_decode($curl_response);
|
||||
|
||||
if(!is_object($decodedResp) || property_exists($decodedResp,'error')) {
|
||||
die($decodedResp->error->message);
|
||||
@@ -67,16 +74,17 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp
|
||||
// init curl object
|
||||
$ch = curl_init();
|
||||
// define options
|
||||
$optArray = array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false
|
||||
$optArray = array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => false
|
||||
);
|
||||
// apply those options
|
||||
curl_setopt_array($ch, $optArray);
|
||||
// execute request and get response
|
||||
$result = curl_exec($ch);
|
||||
$response = (json_decode($result));
|
||||
$response = (G::json_decode($result));
|
||||
curl_close($ch);
|
||||
|
||||
//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"){
|
||||
//sending the email
|
||||
$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_CUSTOMREQUEST, "POST");
|
||||
curl_setopt( $curlApp, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt( $curlApp, CURLOPT_SSL_VERIFYPEER,false);
|
||||
curl_setopt( $curlApp, CURLOPT_CONNECTTIMEOUT, 0);
|
||||
$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_CUSTOMREQUEST, "POST" );
|
||||
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_close( $curlApp );
|
||||
|
||||
Reference in New Issue
Block a user