mergeconflich resolved
This commit is contained in:
@@ -1042,6 +1042,15 @@ class Cases
|
||||
//$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
$enablePMGmail = false;
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
G::LoadClass( "pmDrive" );
|
||||
$pmDrive = new \PMDrive();
|
||||
$enablePMGmail = $pmDrive->getStatusService();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
|
||||
if (!is_array($aObjectPermissions)) {
|
||||
$aObjectPermissions = array(
|
||||
@@ -1147,7 +1156,7 @@ class Cases
|
||||
$aFields['ID_DELETE'] = \G::LoadTranslation('ID_DELETE');
|
||||
}
|
||||
$aFields['DOWNLOAD_LABEL'] = \G::LoadTranslation('ID_DOWNLOAD');
|
||||
$aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION'];
|
||||
$aFields['DOWNLOAD_LINK'] = "cases/cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION'];
|
||||
$aFields['DOC_VERSION'] = $aRow['DOC_VERSION'];
|
||||
if (is_array($listing)) {
|
||||
foreach ($listing as $folderitem) {
|
||||
@@ -1158,6 +1167,15 @@ class Cases
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($aRow['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('INPUT',
|
||||
$driveDownload) && $enablePMGmail
|
||||
) {
|
||||
$aFields['DOWNLOAD_LINK'] = $driveDownload['INPUT'];
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if ($lastVersion == $aRow['DOC_VERSION']) {
|
||||
//Show only last version
|
||||
$aInputDocuments[] = $aFields;
|
||||
@@ -1228,7 +1246,16 @@ class Cases
|
||||
$aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE');
|
||||
}
|
||||
$aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD');
|
||||
$aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'];
|
||||
$aFields['DOWNLOAD_LINK'] = "cases/cases_ShowDocument?a=" . $aRow['APP_DOC_UID'];
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($aRow['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('ATTACHED',
|
||||
$driveDownload) && $enablePMGmail
|
||||
) {
|
||||
$aFields['DOWNLOAD_LINK'] = $driveDownload['ATTACHED'];
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if ($lastVersion == $aRow['DOC_VERSION']) {
|
||||
//Show only last version
|
||||
$aInputDocuments[] = $aFields;
|
||||
@@ -1292,6 +1319,15 @@ class Cases
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($aRow['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('INPUT',
|
||||
$driveDownload) && $enablePMGmail
|
||||
) {
|
||||
$aFields['DOWNLOAD_LINK'] = $driveDownload['INPUT'];
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if ($lastVersion == $aRow['DOC_VERSION']) {
|
||||
//Show only last version
|
||||
$aInputDocuments[] = $aFields;
|
||||
@@ -1335,6 +1371,15 @@ class Cases
|
||||
//$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
$enablePMGmail = false;
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
G::LoadClass( "pmDrive" );
|
||||
$pmDrive = new \PMDrive();
|
||||
$enablePMGmail = $pmDrive->getStatusService();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
|
||||
if (!is_array($aObjectPermissions)) {
|
||||
$aObjectPermissions = array('DYNAFORMS' => array(-1),'INPUT_DOCUMENTS' => array(-1),'OUTPUT_DOCUMENTS' => array(-1));
|
||||
@@ -1417,7 +1462,7 @@ class Cases
|
||||
case "PDF":
|
||||
$fileDoc = 'javascript:alert("NO DOC")';
|
||||
$fileDocLabel = " ";
|
||||
$filePdf = 'cases_ShowOutputDocument?a=' .
|
||||
$filePdf = 'cases/cases_ShowOutputDocument?a=' .
|
||||
$aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
|
||||
$filePdfLabel = ".pdf";
|
||||
if (is_array($listing)) {
|
||||
@@ -1431,7 +1476,7 @@ class Cases
|
||||
}
|
||||
break;
|
||||
case "DOC":
|
||||
$fileDoc = 'cases_ShowOutputDocument?a=' .
|
||||
$fileDoc = 'cases/cases_ShowOutputDocument?a=' .
|
||||
$aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
|
||||
$fileDocLabel = ".doc";
|
||||
$filePdf = 'javascript:alert("NO PDF")';
|
||||
@@ -1447,7 +1492,7 @@ class Cases
|
||||
}
|
||||
break;
|
||||
case "BOTH":
|
||||
$fileDoc = 'cases_ShowOutputDocument?a=' .
|
||||
$fileDoc = 'cases/cases_ShowOutputDocument?a=' .
|
||||
$aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
|
||||
$fileDocLabel = ".doc";
|
||||
if (is_array($listing)) {
|
||||
@@ -1459,7 +1504,7 @@ class Cases
|
||||
}
|
||||
}
|
||||
}
|
||||
$filePdf = 'cases_ShowOutputDocument?a=' .
|
||||
$filePdf = 'cases/cases_ShowOutputDocument?a=' .
|
||||
$aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
|
||||
$filePdfLabel = ".pdf";
|
||||
|
||||
@@ -1480,6 +1525,20 @@ class Cases
|
||||
} catch (\Exception $oException) {
|
||||
$sUser = '(USER DELETED)';
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($aRow['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_DOC',
|
||||
$driveDownload) && $enablePMGmail
|
||||
) {
|
||||
$fileDoc = $driveDownload['OUTPUT_DOC'];
|
||||
}
|
||||
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_PDF',
|
||||
$driveDownload) && $enablePMGmail
|
||||
) {
|
||||
$filePdf = $driveDownload['OUTPUT_PDF'];
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//if both documents were generated, we choose the pdf one, only if doc was
|
||||
//generate then choose the doc file.
|
||||
$firstDocLink = $filePdf;
|
||||
@@ -2384,7 +2443,7 @@ class Cases
|
||||
$aConditions[] = array('PCS.PRO_CATEGORY', 'PCSCAT.CATEGORY_UID');
|
||||
$c->addJoinMC( $aConditions, \Criteria::LEFT_JOIN );
|
||||
}
|
||||
|
||||
$c->setDistinct();
|
||||
$rs = \TaskPeer::doSelectRS($c);
|
||||
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
@@ -260,10 +260,11 @@ class InputDocument
|
||||
$flagSupervisor = 0;
|
||||
|
||||
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
|
||||
$arraySupervisor = $supervisor->getProcessSupervisors($application->getProUid());
|
||||
$processSupervisor = $supervisor->getProcessSupervisors($application->getProUid(), "ASSIGNED");
|
||||
$arraySupervisor = $processSupervisor["data"];
|
||||
|
||||
foreach ($arraySupervisor as $value) {
|
||||
if($value["usr_uid"] == $userUid) {
|
||||
if(!empty($value["usr_uid"]) && $value["usr_uid"] == $userUid) {
|
||||
$flagSupervisor = 1;
|
||||
break;
|
||||
}
|
||||
@@ -283,6 +284,16 @@ class InputDocument
|
||||
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
$enablePMGmail = false;
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
\G::LoadClass( "pmDrive" );
|
||||
$pmDrive = new \PMDrive();
|
||||
$enablePMGmail = $pmDrive->getStatusService();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
@@ -293,6 +304,19 @@ class InputDocument
|
||||
$row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
|
||||
$row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
|
||||
$row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($arrayAppDocument['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && $enablePMGmail
|
||||
) {
|
||||
if (array_key_exists('INPUT', $driveDownload)) {
|
||||
$row['APP_DOC_LINK'] = $driveDownload['INPUT'];
|
||||
} else if (array_key_exists('ATTACHED', $driveDownload)) {
|
||||
$row['APP_DOC_LINK'] = $driveDownload['ATTACHED'];
|
||||
}
|
||||
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
|
||||
}
|
||||
@@ -347,6 +371,15 @@ class InputDocument
|
||||
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
$enablePMGmail = false;
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
\G::LoadClass( "pmDrive" );
|
||||
$pmDrive = new \PMDrive();
|
||||
$enablePMGmail = $pmDrive->getStatusService();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
@@ -354,9 +387,23 @@ class InputDocument
|
||||
|
||||
$arrayAppDocument = $appDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);
|
||||
|
||||
|
||||
$row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
|
||||
$row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
|
||||
$row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//change donwload link - drive
|
||||
$driveDownload = @unserialize($arrayAppDocument['APP_DOC_DRIVE_DOWNLOAD']);
|
||||
if ($driveDownload !== false && is_array($driveDownload) && $enablePMGmail
|
||||
) {
|
||||
if (array_key_exists('INPUT', $driveDownload)) {
|
||||
$row['APP_DOC_LINK'] = $driveDownload['INPUT'];
|
||||
} else if (array_key_exists('ATTACHED', $driveDownload)) {
|
||||
$row['APP_DOC_LINK'] = $driveDownload['ATTACHED'];
|
||||
}
|
||||
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
|
||||
}
|
||||
@@ -404,7 +451,7 @@ class InputDocument
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
$docrow['app_doc_link'] = $row['DOWNLOAD_LINK'];
|
||||
|
||||
if ($docrow["app_doc_uid"] == $inputDocumentUid) {
|
||||
$flagInputDocument = true;
|
||||
|
||||
@@ -197,7 +197,7 @@ class OutputDocument
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
$docrow['app_doc_link'] = $row['DOWNLOAD_LINK'];
|
||||
$result[] = $docrow;
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ class OutputDocument
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
$docrow['app_doc_link'] = $row['DOWNLOAD_LINK'];
|
||||
if ($docrow['app_doc_uid'] == $applicationDocumentUid) {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $row['DOC_VERSION'] );
|
||||
if (is_null( $oAppDocument )) {
|
||||
@@ -380,6 +380,129 @@ class OutputDocument
|
||||
$aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
|
||||
}
|
||||
$this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid);
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
\G::LoadClass( "pmDrive" );
|
||||
$pmDrive = new \PMDrive();
|
||||
if ($pmDrive->getStatusService()) {
|
||||
$app = new \Application();
|
||||
$user = new \Users();
|
||||
$dataUser = $user->load($userUid);
|
||||
$pmDrive->setDriveUser($dataUser['USR_EMAIL']);
|
||||
|
||||
$appData = $app->Load($applicationUid);
|
||||
if ($appData['APP_DRIVE_FOLDER_UID'] == null) {
|
||||
$process = new \Process();
|
||||
$process->setProUid($appData['PRO_UID']);
|
||||
|
||||
$result = $pmDrive->createFolder($process->getProTitle() . ' - ' . G::LoadTranslation("ID_CASE") . ' #' . $appData['APP_NUMBER'],
|
||||
$pmDrive->getFolderIdPMDrive($userUid));
|
||||
$appData['APP_DRIVE_FOLDER_UID'] = $result->id;
|
||||
$app->update($appData);
|
||||
}
|
||||
|
||||
$fileIdDriveDoc = '';
|
||||
$fileIdDrivePdf = '';
|
||||
$sFilenameOriginal = preg_replace('[^A-Za-z0-9_]', '_',
|
||||
\G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
|
||||
switch ($aOD['OUT_DOC_GENERATE']) {
|
||||
case "BOTH":
|
||||
$result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf',
|
||||
$sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']);
|
||||
$oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink);
|
||||
$fileIdDrivePdf = $result->id;
|
||||
$result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc',
|
||||
$sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']);
|
||||
$oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink);
|
||||
$fileIdDriveDoc = $result->id;
|
||||
break;
|
||||
case "PDF":
|
||||
$result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf',
|
||||
$sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']);
|
||||
$oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink);
|
||||
$fileIdDrivePdf = $result->id;
|
||||
break;
|
||||
case "DOC":
|
||||
$result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc',
|
||||
$sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']);
|
||||
$oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink);
|
||||
$fileIdDriveDoc = $result->id;
|
||||
break;
|
||||
}
|
||||
$aFields['DOC_VERSION'] = $oAppDocument->getDocVersion();// $docVersion;
|
||||
$aFields['APP_DOC_UID'] = $oAppDocument->getAppDocUid();//$appDocUid;
|
||||
$appDocUid = $aFields['APP_DOC_UID'];
|
||||
|
||||
$oAppDocument->update($aFields);
|
||||
//$option = 'pmDrive';
|
||||
|
||||
|
||||
//add permissions
|
||||
$criteria = new \Criteria('workflow');
|
||||
$criteria->addSelectColumn(\ApplicationPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(\TaskUserPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(\TaskUserPeer::USR_UID);
|
||||
$criteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
|
||||
|
||||
$criteria->add(\ApplicationPeer::APP_UID, $applicationUid);
|
||||
$criteria->addJoin(\ApplicationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::LEFT_JOIN);
|
||||
$criteria->addJoin(\TaskPeer::TAS_UID, \TaskUserPeer::TAS_UID, \Criteria::LEFT_JOIN);
|
||||
|
||||
|
||||
$dataset = \ApplicationPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$userPermission = array();
|
||||
$case = new \Cases();
|
||||
|
||||
while ($dataset->next()) {
|
||||
$row = $dataset->getRow();
|
||||
if ($row['TU_RELATION'] == 1) {
|
||||
//users
|
||||
$dataUser = $user->load($row['USR_UID']);
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) === false) {
|
||||
$objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid,
|
||||
$row['TAS_UID'], $row['USR_UID']);
|
||||
if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
|
||||
$userPermission[] = $dataUser['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Groups
|
||||
$criteria = new \Criteria('workflow');
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_EMAIL);
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_UID);
|
||||
$criteria->add(\GroupUserPeer::GRP_UID, $row['USR_UID']);
|
||||
$criteria->addJoin(\GroupUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||
|
||||
$oDataset = \AppDelegationPeer::doSelectRS($criteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ( $oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) === false) {
|
||||
$objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid,
|
||||
$row['TAS_UID'], $aRow['USR_UID']);
|
||||
if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
|
||||
$userPermission[] = $aRow['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$userPermission = array_unique($userPermission);
|
||||
|
||||
foreach ($userPermission as $key => $val) {
|
||||
$pmDrive->setPermission($appData['APP_DRIVE_FOLDER_UID'], $val, 'user', 'writer');
|
||||
$pmDrive->setPermission($fileIdDrivePdf, $val);
|
||||
$pmDrive->setPermission($fileIdDriveDoc, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||
//G::LoadClass('plugin');
|
||||
$oPluginRegistry = & \PMPluginRegistry::getSingleton();
|
||||
|
||||
267
workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php
Normal file
267
workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
/**
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Pmgmail {
|
||||
|
||||
/**
|
||||
* Get User by usrGmail
|
||||
*
|
||||
* @param string $usr_gmail Unique id of User
|
||||
*
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function getUserByEmail($usr_gmail)
|
||||
{
|
||||
//getting the user data
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
||||
$oUsers = new \Users();
|
||||
$response['user'] = $oUsers->loadByUserEmailInArray($usr_gmail);
|
||||
|
||||
//getting the skin
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.system.php");
|
||||
$sysConf = new \System();
|
||||
$responseSysConfig = $sysConf->getSystemConfiguration( PATH_CONFIG . 'env.ini' );
|
||||
$response['enviroment'] = $responseSysConfig['default_skin'];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Application data by appUid
|
||||
*
|
||||
* @param string $app_uid Unique id of the app
|
||||
* @param string $index
|
||||
*
|
||||
* return row app_cache_view
|
||||
*
|
||||
*/
|
||||
public function getDraftApp($app_uid, $index=1)
|
||||
{
|
||||
$c = new \Criteria( 'workflow' );
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
|
||||
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
|
||||
|
||||
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
|
||||
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
|
||||
|
||||
$rs = \AppCacheViewPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$rows = Array ();
|
||||
while ($rs->next()) {
|
||||
$rows[] = $rs->getRow();
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send email using appUid and mail
|
||||
*
|
||||
* @param string $app_uid Unique id of the app
|
||||
* @param string $mail
|
||||
*
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function sendEmail($app_uid, $mail, $index)
|
||||
{
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php");
|
||||
$oApplication = new \Application();
|
||||
$formData = $oApplication->Load($app_uid);
|
||||
|
||||
$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') ){
|
||||
$dataFormToShowString .= " " . $field . " " . $value;
|
||||
}
|
||||
}
|
||||
$appData = $this->getDraftApp($app_uid, $index);
|
||||
|
||||
foreach ($appData as $application){
|
||||
$appNumber = $application['APP_NUMBER'];
|
||||
$appStatus = $application['APP_STATUS'];
|
||||
$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($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'];
|
||||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.wsBase.php");
|
||||
$ws = new \wsBase();
|
||||
$resultMail = $ws->sendMessage(
|
||||
$app_uid,
|
||||
'inbox.pm@processmaker.com', //From,
|
||||
$mail,//To,
|
||||
'',
|
||||
'',
|
||||
$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
|
||||
*
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function hasGmailFeature()
|
||||
{
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.licensedFeatures.php");
|
||||
|
||||
$licensedFeatures = new \PMLicensedFeatures();
|
||||
if (!$licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default 'email from account' that is used to send emails in the server email in PM
|
||||
*
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function emailAccount()
|
||||
{
|
||||
$emailServer = new \EmailServer();
|
||||
$response = $emailServer->loadDefaultAccount();
|
||||
|
||||
return $response['MESS_ACCOUNT'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Business Model to delete all the labels of an acount
|
||||
*
|
||||
* @param string $mail
|
||||
*
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function deleteLabels($mail)
|
||||
{
|
||||
require_once(PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php");
|
||||
$oLabels = new \labelsGmail();
|
||||
|
||||
$response = $oLabels->deletePMGmailLabels($mail);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user