GI-208 PMdrive

- Add functionality cron
This commit is contained in:
Marco A. Nina Mena
2015-12-19 20:23:57 -04:00
parent 9956974498
commit 7830fcdf0a
24 changed files with 811 additions and 720 deletions

View File

@@ -337,6 +337,7 @@ function processWorkspace()
/*----------------------------------********---------------------------------*/
fillReportByUser();
fillReportByProcess();
synchronizeDrive();
/*----------------------------------********---------------------------------*/
} catch (Exception $oError) {
saveLog("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n");
@@ -955,5 +956,29 @@ function fillReportByProcess ()
saveLog("fillReportByProcess", "error", "Error in fill report by process: " . $e->getMessage());
}
}
function synchronizeDrive ()
{
try
{
global $argvx;
if (strpos($argvx, "synchronize-documents-drive") === false) {
return false;
}
setExecutionMessage("Synchronize documents to drive");
G::LoadClass('AppDocumentDrive');
$drive = new AppDocumentDrive();
$drive->synchronizeDrive(true);
setExecutionResultMessage("DONE");
} catch (Exception $e) {
setExecutionResultMessage("WITH ERRORS", "error");
eprintln(" '-" . $e->getMessage(), "red");
saveLog("synchronizeDocumentsDrive", "error", "Error in synchronize documents to drive: " . $e->getMessage());
}
}
/*----------------------------------********---------------------------------*/

View File

@@ -0,0 +1,484 @@
<?php
G::LoadClass( "pmDrive" );
/**
* Class InputDocumentDrive
*/
class AppDocumentDrive
{
/**
* @var PMDrive $drive
*/
private $drive;
/**
* @var Application $app
*/
private $app;
/**
* @var Users $user
*/
private $user;
private $statusDrive;
private $usersDrive = '';
/**
* InputDocumentDrive constructor.
*/
public function __construct()
{
$this->drive = new PMDrive();
$status = $this->drive->getStatusService();
$status = !empty($status) ? ($status == 1 ? true : false): false;
$this->usersDrive = '';
$this->setStatusDrive($status);
}
/**
* @return boolean
*/
public function getStatusDrive()
{
return $this->statusDrive;
}
/**
* @param boolen $statusDrive
*/
public function setStatusDrive($statusDrive)
{
$this->statusDrive = $statusDrive;
}
public function loadUser ($usrUid)
{
$this->user = new Users();
$this->user->load($usrUid);
$this->drive->setDriveUser($this->user->getUsrEmail());
}
public function loadApplication ($appUid)
{
$this->app = new Application();
$this->app->Load($appUid);
}
public function existAppFolderDrive ()
{
try {
if ($this->app->getAppDriveFolderUid() == null) {
$process = new Process();
$process->setProUid($this->app->getProUid());
$result = $this->drive->createFolder(
$process->getProTitle() . ' - ' . G::LoadTranslation("ID_CASE") . ' #' . $this->app->getAppNumber(),
$this->drive->getFolderIdPMDrive($this->user->getUsrUid())
);
$this->app->setAppDriveFolderUid($result->id);
$this->app->update($this->app->toArray(BasePeer::TYPE_FIELDNAME));
}
} catch (Exception $e) {
error_log('Error create folder Drive: ' . $e->getMessage());
}
}
public function permission ($appUid, $folderUid, $fileIdDrive)
{
$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, $appUid);
$criteria->addJoin(ApplicationPeer::PRO_UID, TaskPeer::PRO_UID, Criteria::LEFT_JOIN);
$criteria->addJoin(TaskPeer::TAS_UID, TaskUserPeer::TAS_UID, Criteria::LEFT_JOIN);
$rs = ApplicationPeer::doSelectRS($criteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$userPermission = array();
$user = new Users();
while ($rs->next()) {
$row = $rs->getRow();
if ($row['TU_RELATION'] == 1) {
//users
$dataUser = $user->load($row['USR_UID']);
if (array_search($dataUser['USR_EMAIL'], $userPermission) === false) {
$objectPermissions = $this->getAllObjects($row['PRO_UID'], $appUid, $row['TAS_UID'],
$row['USR_UID']);
$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);
$rsGroup = AppDelegationPeer::doSelectRS($criteria);
$rsGroup->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsGroup->next()) {
$aRow = $rsGroup->getRow();
if (array_search($aRow['USR_EMAIL'], $userPermission) === false) {
$objectPermissions = $this->getAllObjects($row['PRO_UID'], $appUid,
$row['TAS_UID'], $aRow['USR_UID']);
$userPermission[] = $aRow['USR_EMAIL'];
}
}
}
}
$userPermission = array_unique($userPermission);
foreach ($userPermission as $key => $val) {
$this->drive->setPermission($folderUid, $val, 'user', 'writer');
$this->drive->setPermission($fileIdDrive, $val);
}
}
public function addUserDrive ($email)
{
if (empty($email)) {
return;
}
if ($this->usersDrive == '') {
$this->usersDrive = $email;
} else {
$emails = explode('|', $this->usersDrive);
if (array_search($email, $emails) === false) {
$this->usersDrive .= '|' . $email;
}
}
}
/**
* @param AppDocument $appDoc
* @param array $arrayTask
* @param $arrayData
*
* @throws \Exception
*/
public function getEmailUsersTask($arrayTask, $arrayData)
{
try {
G::LoadClass("tasks");
G::LoadClass("groups");
G::LoadClass("spool");
$task = new Tasks();
$group = new Groups();
$oUser = new Users();
foreach ($arrayTask as $aTask) {
switch ($aTask["TAS_ASSIGN_TYPE"]) {
case "SELF_SERVICE":
if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
$usersTask = array();
$groupsTask = $task->getGroupsOfTask($aTask["TAS_UID"], 1);
foreach ($groupsTask as $arrayGroup) {
$usersGroup = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);
foreach ($usersGroup as $userGroup) {
$usersTask[] = $userGroup["USR_UID"];
}
}
$groupsTask = $task->getUsersOfTask($aTask["TAS_UID"], 1);
foreach ($groupsTask as $userGroup) {
$usersTask[] = $userGroup["USR_UID"];
}
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(UsersPeer::USR_UID);
$criteria->addSelectColumn(UsersPeer::USR_EMAIL);
$criteria->add(UsersPeer::USR_UID, $usersTask, Criteria::IN);
$rsCriteria = UsersPeer::doSelectRs($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$this->addUserDrive($row['USR_EMAIL']);
}
}
break;
case "MULTIPLE_INSTANCE":
$oDerivation = new Derivation();
$userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($aTask["TAS_UID"]));
if(isset($userFields)){
foreach($userFields as $row){
$this->addUserDrive($row['USR_EMAIL']);
}
}
break;
case "MULTIPLE_INSTANCE_VALUE_BASED":
$taskNext = $task->load($aTask["TAS_UID"]);
if(isset($taskNext["TAS_ASSIGN_VARIABLE"]) && !empty($taskNext["TAS_ASSIGN_VARIABLE"])){
$nextTaskAssignVariable = trim($taskNext["TAS_ASSIGN_VARIABLE"], " @#");
$arrayUsers = $arrayData[$nextTaskAssignVariable];
$oDerivation = new Derivation();
$userFields = $oDerivation->getUsersFullNameFromArray($arrayUsers);
foreach ($userFields as $row) {
$this->addUserDrive($row['USR_EMAIL']);
}
}
break;
default:
if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
$aUser = $oUser->load($aTask["USR_UID"]);
$this->addUserDrive($aUser["USR_EMAIL"]);
}
break;
}
}
} catch (Exception $exception) {
error_log('Error: ' . $exception);
}
}
/**
* @param array $appDocument
* @param string $typeDocument type document INPUT, OUTPUT_DOC, OUTPUT_PDF, ATTACHED
* @param string $mime MIME type of the file to insert.
* @param string $src location of the file to insert.
* @param string $name Title of the file to insert, including the extension.
* return string uid
*/
public function upload ($appDocument, $typeDocument, $mime, $src, $name)
{
try
{
$idFileDrive = null;
$this->existAppFolderDrive();
$appDoc = new AppDocument();
$result = $this->drive->uploadFile(
$mime,
$src,
$name,
$this->app->getAppDriveFolderUid()
);
if ($result->id !== null) {
$idFileDrive = $result->id;
$appDoc->setDriveDownload($typeDocument, $result->id);
$appDoc->update($appDocument);
}
return $idFileDrive;
} catch (Exception $e) {
error_log('Error upload file drive: ' . $e->getMessage());
}
}
/**
* Download file drive
* @param $uidFileDrive
*/
public function download ($uidFileDrive)
{
try
{
$result = $this->drive->downloadFile($uidFileDrive);
} catch (Exception $e) {
error_log('Error Download file drive: ' . $e->getMessage());
}
return $result;
}
/**
* @param array $data
* @param string $typeDoc value INPUT, OUTPUT_DOC, OUTPUT_PDF, ATTACHED
*
* @return string url drive
*/
public function changeUrlDrive ($data, $typeDoc)
{
try
{
$urlDrive = $data['APP_DOC_DRIVE_DOWNLOAD'];
if ($this->getStatusDrive()) {
$driveDownload = @unserialize($data['APP_DOC_DRIVE_DOWNLOAD']);
$urlDrive = $driveDownload !== false
&& is_array($driveDownload)
&& array_key_exists($typeDoc, $driveDownload) ?
$driveDownload[$typeDoc] : $urlDrive;
}
} catch (Exception $e) {
error_log('Error change url drive: ' . $e->getMessage());
}
return $urlDrive;
}
/**
* Synchronize documents drive
*
* @param boolean $log enable print cron
*/
public function synchronizeDrive ($log)
{
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
$criteria->add( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED' );
//Verify other permissions
/*$criteria->add(
$criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL )->
addOr($criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'NO_EXIST_FILE_PM', Criteria::NOT_EQUAL )->
addAnd($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 );
while ($rs->next()) {
$row = $rs->getRow();
$appDoc = new AppDocument();
$fields = $appDoc->load($row['APP_DOC_UID'], $row['DOC_VERSION']);
$appDocUid = $appDoc->getAppDocUid();
$docVersion = $appDoc->getDocVersion();
$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 );
$sw_file_exists_doc = false;
$sw_file_exists_pdf = false;
if ($appDoc->getAppDocType() == 'OUTPUT') {
//$name = substr($name, 1, -1);
$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 )) {
$sw_file_exists = true;
$sw_file_exists_doc = true;
} elseif (file_exists( $realPathDoc1 )) {
$sw_file_exists = true;
$sw_file_exists_doc = true;
$realPathDoc = $realPathDoc1;
} 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';
$realPathPdf2 = PATH_DOCUMENT . $appUid . '/outdocs/' . $name . '.' . 'pdf';
if (file_exists( $realPathPdf )) {
$sw_file_exists = true;
$sw_file_exists_pdf = true;
} elseif (file_exists( $realPathPdf1 )) {
$sw_file_exists = true;
$sw_file_exists_pdf = true;
$realPathPdf = $realPathPdf1;
} 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;
$realPath1 = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '.' . $ext;
$sw_file_exists = false;
if (file_exists( $realPath )) {
$sw_file_exists = true;
} elseif (file_exists( $realPath1 )) {
$sw_file_exists = true;
$realPath = $realPath1;
}
}
if ($sw_file_exists) {
$this->loadApplication($appDoc->getAppUid());
$emails = $appDoc->getSyncPermissions();
$emails = !empty($emails) ? explode('|', $emails) : array();
foreach ($emails as $index => $email) {
if (!empty($email)) {
if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') {
if ($log) {
eprintln('upload file:' . $name , 'green');
}
$this->drive->setDriveUser($email);
$this->loadUser($fields['USR_UID']);
$info = finfo_open(FILEINFO_MIME_TYPE);
if ($appDoc->getAppDocType() == 'OUTPUT') {
if ($sw_file_exists_doc) {
$nameDoc = explode('/', $realPathDoc);
$mime = finfo_file($info, $realPathDoc);
$result = $this->upload($fields, 'OUTPUT_DOC', 'application/msword', $realPathDoc, array_pop($nameDoc));
}
if ($sw_file_exists_pdf) {
$namePdf = explode('/', $realPathPdf);
$mime = finfo_file($info, $realPathPdf);
$result = $this->upload($fields, 'OUTPUT_PDF', $mime, $realPathPdf, array_pop($namePdf));
}
} else {
$mime = finfo_file($info, $realPath);
$result = $this->upload($fields, $appDoc->getAppDocType(), $mime, $realPath, $name);
}
if ($log) {
eprintln('Set Permission:' . $email , 'green');
}
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
} else {
if ($log) {
eprintln('Set Permission:' . $email , 'green');
}
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
}
}
}
$fields['SYNC_WITH_DRIVE'] = 'SYNCHRONIZED';
$fields['SYNC_PERMISSIONS'] = null;
} else {
$fields['SYNC_WITH_DRIVE'] = 'NO_EXIST_FILE_PM';
if ($log) {
eprintln('File no exists:' . $name , 'red');
//eprintln($realPath , 'red');
}
}
$appDoc->update($fields);
}
}
public function addUsersDocumentDrive ($appUid, $arrayTask, $arrayData )
{
$this->getEmailUsersTask($arrayTask, $arrayData);
$criteria = new Criteria( 'workflow' );
$criteria->add( AppDocumentPeer::APP_UID, $appUid );
$criteria->addAscendingOrderByColumn( 'DOC_VERSION' );
$rs = AppDocumentPeer::doSelectRS( $criteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$appDoc = new AppDocument();
while ($rs->next()) {
$row = $rs->getRow();
$row['SYNC_PERMISSIONS'] = $this->usersDrive;
$appDoc->update($row);
}
}
}

View File

@@ -3640,15 +3640,6 @@ class Cases
'APP_DOC_FILENAME' => 'char',
'APP_DOC_INDEX' => 'integer'
);
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
}
/*----------------------------------********---------------------------------*/
while ($aRow = $oDataset->getRow()) {
$aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
@@ -3709,15 +3700,6 @@ class Cases
}
}
$aFields['COMMENT'] = $aFields['APP_DOC_COMMENT'];
/*----------------------------------********---------------------------------*/
//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 (($aRow['DOC_VERSION'] == $lastVersion) || ($sAppDocuUID != "")) {
$aInputDocuments[] = $aFields;
}
@@ -3942,93 +3924,6 @@ class Cases
$strPathName = PATH_DOCUMENT . G::getPathFromUID($applicationUid) . PATH_SEP;
$strFileName = $appDocUid . "_" . $docVersion . "." . $extension;
/*----------------------------------********---------------------------------*/
$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);
}
$result = $pmDrive->uploadFile('application/' . $extension, $fileTmpName, $file,
$appData['APP_DRIVE_FOLDER_UID']);
$appDocument->setDriveDownload('INPUT', $result->webContentLink);
$fileIdDrive = $result->id;
$arrayField['DOC_VERSION'] = $docVersion;
$arrayField['APP_DOC_UID'] = $appDocUid;
$appDocument->update($arrayField);
//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();
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 = $this->getAllObjects($row['PRO_UID'], $applicationUid, $row['TAS_UID'],
$row['USR_UID']);
$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 = $this->getAllObjects($row['PRO_UID'], $applicationUid,
$row['TAS_UID'], $aRow['USR_UID']);
$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($fileIdDrive, $val);
}
}
}
/*----------------------------------********---------------------------------*/
switch ($option) {
case "xmlform":
G::uploadFile($fileTmpName, $strPathName, $strFileName);
@@ -4232,10 +4127,9 @@ class Cases
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
if (!empty($enablePMGmail) && $enablePMGmail == 1) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
$pmGmail = new \ProcessMaker\BusinessModel\Pmgmail();
$pmGmail->modifyMailToPauseCase($aData['APP_UID'], $aData['APP_DEL_INDEX']);
}
@@ -4341,10 +4235,9 @@ class Cases
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
if (!empty($enablePMGmail) && $enablePMGmail == 1) {
G::LoadClass("AppDocumentDrive");
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
$pmGmail = new \ProcessMaker\BusinessModel\Pmgmail();
$pmGmail->modifyMailToUnpauseCase($aData['APP_UID'], $aData['DEL_INDEX']);
}
@@ -4729,15 +4622,6 @@ class Cases
'APP_DOC_FILENAME' => 'char', 'APP_DOC_INDEX' => 'integer'
);
$oUser = new Users();
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
}
/*----------------------------------********---------------------------------*/
while ($aRow = $oDataset->getRow()) {
$oCriteria2 = new Criteria('workflow');
$oCriteria2->add(AppDelegationPeer::APP_UID, $sApplicationUID);
@@ -4798,15 +4682,6 @@ 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;
@@ -4884,15 +4759,6 @@ class Cases
$aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD');
$aFields['DOWNLOAD_LINK'] = "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;
@@ -4960,15 +4826,6 @@ 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;
@@ -5076,15 +4933,6 @@ class Cases
'APP_DOC_INDEX' => 'integer'
);
$oUser = new Users();
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
}
/*----------------------------------********---------------------------------*/
while ($aRow = $oDataset->getRow()) {
$oCriteria2 = new Criteria('workflow');
$oCriteria2->add(AppDelegationPeer::APP_UID, $sApplicationUID);
@@ -5188,21 +5036,6 @@ class Cases
$firstDocLabel = $fileDocLabel;
}
/*----------------------------------********---------------------------------*/
//change donwload link - drive
$driveDownload = @unserialize($aAux['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'];
}
/*----------------------------------********---------------------------------*/
$aFields = array(
'APP_DOC_UID' => $aAux['APP_DOC_UID'],
'DOC_UID' => $aAux['DOC_UID'],

View File

@@ -164,7 +164,7 @@ class PMDrive extends PMGoogleApi
$service = $this->serviceDrive();
$file = new Google_Service_Drive_DriveFile();
$file->setMimeType("*/*");
$file->setMimeType($mime);
$file->setTitle($name);
// Set the parent folder.
@@ -208,17 +208,16 @@ class PMDrive extends PMGoogleApi
$this->setScope('https://www.googleapis.com/auth/drive.metadata.readonly');
$this->setScope('https://www.googleapis.com/auth/drive.readonly');
$service = $this->serviceDrive();
$response = null;
try {
$file = $service->files->get($fileId);
$response = null;
$downloadUrl = $file->getDownloadUrl();
if ($downloadUrl) {
$request = new Google_Http_Request($downloadUrl, 'GET', null, null);
$httpRequest = $service->getClient()->getAuth()->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
$response = $httpRequest->getResponseBody();
$response = $httpRequest->getResponseBody();
} else {
error_log(G::LoadTranslation("ID_MSG_AJAX_FAILURE"));
}

View File

@@ -373,24 +373,10 @@ class pmDynaform
}
}
if ($key === "type" && ($value === "file") && isset($this->fields["APP_DATA"]["APPLICATION"])) {
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass("pmDrive");
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
}
/*----------------------------------********---------------------------------*/
$oCriteria = new Criteria("workflow");
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
$oCriteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
/*----------------------------------********---------------------------------*/
if ($enablePMGmail) {
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD);
}
/*----------------------------------********---------------------------------*/
$oCriteria->addJoin(AppDocumentPeer::APP_DOC_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$oCriteria->add(AppDocumentPeer::APP_UID, $this->fields["APP_DATA"]["APPLICATION"]);
$oCriteria->add(AppDocumentPeer::APP_DOC_FIELDNAME, $json->name);
@@ -402,14 +388,6 @@ class pmDynaform
while ($rs->next()) {
$row = $rs->getRow();
$linkDownload = "../cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
/*----------------------------------********---------------------------------*/
//change donwload link - drive
$driveDownload = @unserialize($row['APP_DOC_DRIVE_DOWNLOAD']);
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('ATTACHED', $driveDownload) && $enablePMGmail
) {
$linkDownload = $driveDownload['ATTACHED'];
}
/*----------------------------------********---------------------------------*/
array_push($links, $linkDownload);
array_push($labelsFromDb, $row["CON_VALUE"]);
}

View File

@@ -66,6 +66,8 @@ class AppDocument extends BaseAppDocument
/*----------------------------------********---------------------------------*/
protected $driveDownload = array();
protected $syncWithDrive = '';
protected $syncPermissions = '';
/*----------------------------------********---------------------------------*/
/*
@@ -220,6 +222,7 @@ class AppDocument extends BaseAppDocument
/*----------------------------------********---------------------------------*/
$aData['APP_DOC_DRIVE_DOWNLOAD'] = serialize($this->driveDownload);
//$aData['SYNC_PERMISSIONS'] = $this->syncPermissions;
/*----------------------------------********---------------------------------*/
$oAppDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oAppDocument->setDocVersion( $docVersion );
@@ -267,6 +270,7 @@ class AppDocument extends BaseAppDocument
$oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
try {
$oAppDocument = AppDocumentPeer::retrieveByPK( $aData['APP_DOC_UID'], $aData['DOC_VERSION'] );
if (! is_null( $oAppDocument )) {
/*----------------------------------********---------------------------------*/
$driveDownload = @unserialize($oAppDocument->getAppDocDriveDownload());
@@ -275,6 +279,10 @@ class AppDocument extends BaseAppDocument
} else {
$aData['APP_DOC_DRIVE_DOWNLOAD'] = serialize($this->driveDownload);
}
//$aData['SYNC_PERMISSIONS'] = $this->syncPermissions;
//$aData['SYNC_WITH_DRIVE'] = $this->syncWithDrive;
//$oAppDocument->setSyncWithDrive($aData['SYNC_WITH_DRIVE']);
//$oAppDocument->sync_with_drive = $aData['SYNC_WITH_DRIVE'];
/*----------------------------------********---------------------------------*/
$oAppDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oAppDocument->validate()) {
@@ -508,6 +516,29 @@ class AppDocument extends BaseAppDocument
}
return $url;
}
/*public function setSyncWithDrive ($key)
{
$data = array('SYNCHRONIZED', 'UNSYNCHRONIZED', 'NO_EXIST_FILE_PM');
if (array_search($key, $data) === false) {
$key = 'UNSYNCHRONIZED';
}
$this->syncWithDrive = $key;
}*/
/*public function getSyncWithDrive ()
{
return $this->syncWithDrive;
}*/
/*public function setSyncPermissions ($email)
{
$this->syncPermissions = empty($this->syncPermissions) ? $email : ','.$email;
}
public function getSyncPermissions ()
{
return !empty($this->syncPermissions) ? explode(',', $this->syncPermissions) : '';
}*/
/*----------------------------------********---------------------------------*/

View File

@@ -293,16 +293,6 @@ class AppFolder extends BaseAppFolder
//require_once ("classes/model/OutputDocument.php");
//require_once ("classes/model/Users.php");
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
}
/*----------------------------------********---------------------------------*/
G::LoadClass( 'case' );
$oCase = new Cases();
G::LoadClass( 'process' );
@@ -328,11 +318,7 @@ class AppFolder extends BaseAppFolder
$oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_STATUS);
$oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_STATUS_DATE);
$oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_FIELDNAME);
/*----------------------------------********---------------------------------*/
if ($enablePMGmail) {
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD);
}
/*----------------------------------********---------------------------------*/
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD);
if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) {
//Search by App Doc UID no matter what Folder it is
@@ -433,39 +419,6 @@ class AppFolder extends BaseAppFolder
//$filesResult [] = $completeInfo;
if ($completeInfo['APP_DOC_STATUS'] != "DELETED") {
/*----------------------------------********---------------------------------*/
if ($enablePMGmail) {
$driveDownload = @unserialize($completeInfo['APP_DOC_DRIVE_DOWNLOAD']);
switch ($completeInfo['APP_DOC_TYPE']) {
case 'INPUT':
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('INPUT',
$driveDownload)
) {
$completeInfo['DOWNLOAD_LINK'] = $driveDownload['INPUT'];
}
break;
case 'ATTACHED':
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('ATTACHED',
$driveDownload)
) {
$completeInfo['DOWNLOAD_LINK'] = $driveDownload['ATTACHED'];
}
break;
case 'OUTPUT':
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_DOC',
$driveDownload)
) {
$completeInfo['DOWNLOAD_LINK1'] = $driveDownload['OUTPUT_DOC'];
}
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_PDF',
$driveDownload)
) {
$completeInfo['DOWNLOAD_LINK'] = $driveDownload['OUTPUT_PDF'];
}
break;
}
}
/*----------------------------------********---------------------------------*/
if (in_array($row["APP_DOC_UID"], $completeInfo["INPUT_DOCUMENTS"]) || in_array($row["APP_DOC_UID"], $completeInfo["OUTPUT_DOCUMENTS"]) || in_array($completeInfo["USR_UID"], array($_SESSION["USER_LOGGED"], "-1")) || $user == "") {
if (count( $docIdFilter ) > 0) {
if (in_array( $row['APP_DOC_UID'], $docIdFilter )) {

View File

@@ -97,6 +97,10 @@ class AppDocumentMapBuilder
$tMap->addColumn('APP_DOC_DRIVE_DOWNLOAD', 'AppDocDriveDownload', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('SYNC_WITH_DRIVE', 'SyncWithDrive', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('SYNC_PERMISSIONS', 'SyncPermissions', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addValidator('APP_DOC_UID', 'maxLength', 'propel.validator.MaxLengthValidator', '32', 'Application Document UID can be no larger than 32 in size');
$tMap->addValidator('APP_DOC_UID', 'required', 'propel.validator.RequiredValidator', '', 'Application Document UID is required.');
@@ -127,6 +131,10 @@ class AppDocumentMapBuilder
$tMap->addValidator('APP_DOC_STATUS', 'required', 'propel.validator.RequiredValidator', '', 'Application Document Status is required.');
$tMap->addValidator('SYNC_WITH_DRIVE', 'validValues', 'propel.validator.ValidValuesValidator', 'SYNCHRONIZED|UNSYNCHRONIZED|NO_EXIST_FILE_PM', 'Please select a valid type.');
$tMap->addValidator('SYNC_WITH_DRIVE', 'required', 'propel.validator.RequiredValidator', '', 'Type is required.');
} // doBuild()
} // AppDocumentMapBuilder

View File

@@ -123,6 +123,18 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
*/
protected $app_doc_drive_download;
/**
* The value for the sync_with_drive field.
* @var string
*/
protected $sync_with_drive = 'UNSYNCHRONIZED';
/**
* The value for the sync_permissions field.
* @var string
*/
protected $sync_permissions;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -355,6 +367,28 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
return $this->app_doc_drive_download;
}
/**
* Get the [sync_with_drive] column value.
*
* @return string
*/
public function getSyncWithDrive()
{
return $this->sync_with_drive;
}
/**
* Get the [sync_permissions] column value.
*
* @return string
*/
public function getSyncPermissions()
{
return $this->sync_permissions;
}
/**
* Set the value of [app_doc_uid] column.
*
@@ -721,6 +755,50 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
} // setAppDocDriveDownload()
/**
* Set the value of [sync_with_drive] column.
*
* @param string $v new value
* @return void
*/
public function setSyncWithDrive($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->sync_with_drive !== $v || $v === 'UNSYNCHRONIZED') {
$this->sync_with_drive = $v;
$this->modifiedColumns[] = AppDocumentPeer::SYNC_WITH_DRIVE;
}
} // setSyncWithDrive()
/**
* Set the value of [sync_permissions] column.
*
* @param string $v new value
* @return void
*/
public function setSyncPermissions($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->sync_permissions !== $v) {
$this->sync_permissions = $v;
$this->modifiedColumns[] = AppDocumentPeer::SYNC_PERMISSIONS;
}
} // setSyncPermissions()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
@@ -770,12 +848,16 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
$this->app_doc_drive_download = $rs->getString($startcol + 15);
$this->sync_with_drive = $rs->getString($startcol + 16);
$this->sync_permissions = $rs->getString($startcol + 17);
$this->resetModified();
$this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 16; // 16 = AppDocumentPeer::NUM_COLUMNS - AppDocumentPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 18; // 18 = AppDocumentPeer::NUM_COLUMNS - AppDocumentPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating AppDocument object", $e);
@@ -1027,6 +1109,12 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
case 15:
return $this->getAppDocDriveDownload();
break;
case 16:
return $this->getSyncWithDrive();
break;
case 17:
return $this->getSyncPermissions();
break;
default:
return null;
break;
@@ -1063,6 +1151,8 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
$keys[13] => $this->getAppDocStatusDate(),
$keys[14] => $this->getAppDocFieldname(),
$keys[15] => $this->getAppDocDriveDownload(),
$keys[16] => $this->getSyncWithDrive(),
$keys[17] => $this->getSyncPermissions(),
);
return $result;
}
@@ -1142,6 +1232,12 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
case 15:
$this->setAppDocDriveDownload($value);
break;
case 16:
$this->setSyncWithDrive($value);
break;
case 17:
$this->setSyncPermissions($value);
break;
} // switch()
}
@@ -1229,6 +1325,14 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
$this->setAppDocDriveDownload($arr[$keys[15]]);
}
if (array_key_exists($keys[16], $arr)) {
$this->setSyncWithDrive($arr[$keys[16]]);
}
if (array_key_exists($keys[17], $arr)) {
$this->setSyncPermissions($arr[$keys[17]]);
}
}
/**
@@ -1304,6 +1408,14 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
$criteria->add(AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD, $this->app_doc_drive_download);
}
if ($this->isColumnModified(AppDocumentPeer::SYNC_WITH_DRIVE)) {
$criteria->add(AppDocumentPeer::SYNC_WITH_DRIVE, $this->sync_with_drive);
}
if ($this->isColumnModified(AppDocumentPeer::SYNC_PERMISSIONS)) {
$criteria->add(AppDocumentPeer::SYNC_PERMISSIONS, $this->sync_permissions);
}
return $criteria;
}
@@ -1398,6 +1510,10 @@ abstract class BaseAppDocument extends BaseObject implements Persistent
$copyObj->setAppDocDriveDownload($this->app_doc_drive_download);
$copyObj->setSyncWithDrive($this->sync_with_drive);
$copyObj->setSyncPermissions($this->sync_permissions);
$copyObj->setNew(true);

View File

@@ -25,7 +25,7 @@ abstract class BaseAppDocumentPeer
const CLASS_DEFAULT = 'classes.model.AppDocument';
/** The total number of columns. */
const NUM_COLUMNS = 16;
const NUM_COLUMNS = 18;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -79,6 +79,12 @@ abstract class BaseAppDocumentPeer
/** the column name for the APP_DOC_DRIVE_DOWNLOAD field */
const APP_DOC_DRIVE_DOWNLOAD = 'APP_DOCUMENT.APP_DOC_DRIVE_DOWNLOAD';
/** the column name for the SYNC_WITH_DRIVE field */
const SYNC_WITH_DRIVE = 'APP_DOCUMENT.SYNC_WITH_DRIVE';
/** the column name for the SYNC_PERMISSIONS field */
const SYNC_PERMISSIONS = 'APP_DOCUMENT.SYNC_PERMISSIONS';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
@@ -90,10 +96,10 @@ abstract class BaseAppDocumentPeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('AppDocUid', 'DocVersion', 'AppUid', 'DelIndex', 'DocUid', 'UsrUid', 'AppDocType', 'AppDocCreateDate', 'AppDocIndex', 'FolderUid', 'AppDocPlugin', 'AppDocTags', 'AppDocStatus', 'AppDocStatusDate', 'AppDocFieldname', 'AppDocDriveDownload', ),
BasePeer::TYPE_COLNAME => array (AppDocumentPeer::APP_DOC_UID, AppDocumentPeer::DOC_VERSION, AppDocumentPeer::APP_UID, AppDocumentPeer::DEL_INDEX, AppDocumentPeer::DOC_UID, AppDocumentPeer::USR_UID, AppDocumentPeer::APP_DOC_TYPE, AppDocumentPeer::APP_DOC_CREATE_DATE, AppDocumentPeer::APP_DOC_INDEX, AppDocumentPeer::FOLDER_UID, AppDocumentPeer::APP_DOC_PLUGIN, AppDocumentPeer::APP_DOC_TAGS, AppDocumentPeer::APP_DOC_STATUS, AppDocumentPeer::APP_DOC_STATUS_DATE, AppDocumentPeer::APP_DOC_FIELDNAME, AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD, ),
BasePeer::TYPE_FIELDNAME => array ('APP_DOC_UID', 'DOC_VERSION', 'APP_UID', 'DEL_INDEX', 'DOC_UID', 'USR_UID', 'APP_DOC_TYPE', 'APP_DOC_CREATE_DATE', 'APP_DOC_INDEX', 'FOLDER_UID', 'APP_DOC_PLUGIN', 'APP_DOC_TAGS', 'APP_DOC_STATUS', 'APP_DOC_STATUS_DATE', 'APP_DOC_FIELDNAME', 'APP_DOC_DRIVE_DOWNLOAD', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
BasePeer::TYPE_PHPNAME => array ('AppDocUid', 'DocVersion', 'AppUid', 'DelIndex', 'DocUid', 'UsrUid', 'AppDocType', 'AppDocCreateDate', 'AppDocIndex', 'FolderUid', 'AppDocPlugin', 'AppDocTags', 'AppDocStatus', 'AppDocStatusDate', 'AppDocFieldname', 'AppDocDriveDownload', 'SyncWithDrive', 'SyncPermissions', ),
BasePeer::TYPE_COLNAME => array (AppDocumentPeer::APP_DOC_UID, AppDocumentPeer::DOC_VERSION, AppDocumentPeer::APP_UID, AppDocumentPeer::DEL_INDEX, AppDocumentPeer::DOC_UID, AppDocumentPeer::USR_UID, AppDocumentPeer::APP_DOC_TYPE, AppDocumentPeer::APP_DOC_CREATE_DATE, AppDocumentPeer::APP_DOC_INDEX, AppDocumentPeer::FOLDER_UID, AppDocumentPeer::APP_DOC_PLUGIN, AppDocumentPeer::APP_DOC_TAGS, AppDocumentPeer::APP_DOC_STATUS, AppDocumentPeer::APP_DOC_STATUS_DATE, AppDocumentPeer::APP_DOC_FIELDNAME, AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD, AppDocumentPeer::SYNC_WITH_DRIVE, AppDocumentPeer::SYNC_PERMISSIONS, ),
BasePeer::TYPE_FIELDNAME => array ('APP_DOC_UID', 'DOC_VERSION', 'APP_UID', 'DEL_INDEX', 'DOC_UID', 'USR_UID', 'APP_DOC_TYPE', 'APP_DOC_CREATE_DATE', 'APP_DOC_INDEX', 'FOLDER_UID', 'APP_DOC_PLUGIN', 'APP_DOC_TAGS', 'APP_DOC_STATUS', 'APP_DOC_STATUS_DATE', 'APP_DOC_FIELDNAME', 'APP_DOC_DRIVE_DOWNLOAD', 'SYNC_WITH_DRIVE', 'SYNC_PERMISSIONS', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
);
/**
@@ -103,10 +109,10 @@ abstract class BaseAppDocumentPeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('AppDocUid' => 0, 'DocVersion' => 1, 'AppUid' => 2, 'DelIndex' => 3, 'DocUid' => 4, 'UsrUid' => 5, 'AppDocType' => 6, 'AppDocCreateDate' => 7, 'AppDocIndex' => 8, 'FolderUid' => 9, 'AppDocPlugin' => 10, 'AppDocTags' => 11, 'AppDocStatus' => 12, 'AppDocStatusDate' => 13, 'AppDocFieldname' => 14, 'AppDocDriveDownload' => 15, ),
BasePeer::TYPE_COLNAME => array (AppDocumentPeer::APP_DOC_UID => 0, AppDocumentPeer::DOC_VERSION => 1, AppDocumentPeer::APP_UID => 2, AppDocumentPeer::DEL_INDEX => 3, AppDocumentPeer::DOC_UID => 4, AppDocumentPeer::USR_UID => 5, AppDocumentPeer::APP_DOC_TYPE => 6, AppDocumentPeer::APP_DOC_CREATE_DATE => 7, AppDocumentPeer::APP_DOC_INDEX => 8, AppDocumentPeer::FOLDER_UID => 9, AppDocumentPeer::APP_DOC_PLUGIN => 10, AppDocumentPeer::APP_DOC_TAGS => 11, AppDocumentPeer::APP_DOC_STATUS => 12, AppDocumentPeer::APP_DOC_STATUS_DATE => 13, AppDocumentPeer::APP_DOC_FIELDNAME => 14, AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD => 15, ),
BasePeer::TYPE_FIELDNAME => array ('APP_DOC_UID' => 0, 'DOC_VERSION' => 1, 'APP_UID' => 2, 'DEL_INDEX' => 3, 'DOC_UID' => 4, 'USR_UID' => 5, 'APP_DOC_TYPE' => 6, 'APP_DOC_CREATE_DATE' => 7, 'APP_DOC_INDEX' => 8, 'FOLDER_UID' => 9, 'APP_DOC_PLUGIN' => 10, 'APP_DOC_TAGS' => 11, 'APP_DOC_STATUS' => 12, 'APP_DOC_STATUS_DATE' => 13, 'APP_DOC_FIELDNAME' => 14, 'APP_DOC_DRIVE_DOWNLOAD' => 15, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
BasePeer::TYPE_PHPNAME => array ('AppDocUid' => 0, 'DocVersion' => 1, 'AppUid' => 2, 'DelIndex' => 3, 'DocUid' => 4, 'UsrUid' => 5, 'AppDocType' => 6, 'AppDocCreateDate' => 7, 'AppDocIndex' => 8, 'FolderUid' => 9, 'AppDocPlugin' => 10, 'AppDocTags' => 11, 'AppDocStatus' => 12, 'AppDocStatusDate' => 13, 'AppDocFieldname' => 14, 'AppDocDriveDownload' => 15, 'SyncWithDrive' => 16, 'SyncPermissions' => 17, ),
BasePeer::TYPE_COLNAME => array (AppDocumentPeer::APP_DOC_UID => 0, AppDocumentPeer::DOC_VERSION => 1, AppDocumentPeer::APP_UID => 2, AppDocumentPeer::DEL_INDEX => 3, AppDocumentPeer::DOC_UID => 4, AppDocumentPeer::USR_UID => 5, AppDocumentPeer::APP_DOC_TYPE => 6, AppDocumentPeer::APP_DOC_CREATE_DATE => 7, AppDocumentPeer::APP_DOC_INDEX => 8, AppDocumentPeer::FOLDER_UID => 9, AppDocumentPeer::APP_DOC_PLUGIN => 10, AppDocumentPeer::APP_DOC_TAGS => 11, AppDocumentPeer::APP_DOC_STATUS => 12, AppDocumentPeer::APP_DOC_STATUS_DATE => 13, AppDocumentPeer::APP_DOC_FIELDNAME => 14, AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD => 15, AppDocumentPeer::SYNC_WITH_DRIVE => 16, AppDocumentPeer::SYNC_PERMISSIONS => 17, ),
BasePeer::TYPE_FIELDNAME => array ('APP_DOC_UID' => 0, 'DOC_VERSION' => 1, 'APP_UID' => 2, 'DEL_INDEX' => 3, 'DOC_UID' => 4, 'USR_UID' => 5, 'APP_DOC_TYPE' => 6, 'APP_DOC_CREATE_DATE' => 7, 'APP_DOC_INDEX' => 8, 'FOLDER_UID' => 9, 'APP_DOC_PLUGIN' => 10, 'APP_DOC_TAGS' => 11, 'APP_DOC_STATUS' => 12, 'APP_DOC_STATUS_DATE' => 13, 'APP_DOC_FIELDNAME' => 14, 'APP_DOC_DRIVE_DOWNLOAD' => 15, 'SYNC_WITH_DRIVE' => 16, 'SYNC_PERMISSIONS' => 17, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
);
/**
@@ -239,6 +245,10 @@ abstract class BaseAppDocumentPeer
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_DRIVE_DOWNLOAD);
$criteria->addSelectColumn(AppDocumentPeer::SYNC_WITH_DRIVE);
$criteria->addSelectColumn(AppDocumentPeer::SYNC_PERMISSIONS);
}
const COUNT = 'COUNT(APP_DOCUMENT.APP_DOC_UID)';
@@ -611,6 +621,9 @@ abstract class BaseAppDocumentPeer
if ($obj->isNew() || $obj->isColumnModified(AppDocumentPeer::APP_DOC_STATUS))
$columns[AppDocumentPeer::APP_DOC_STATUS] = $obj->getAppDocStatus();
if ($obj->isNew() || $obj->isColumnModified(AppDocumentPeer::SYNC_WITH_DRIVE))
$columns[AppDocumentPeer::SYNC_WITH_DRIVE] = $obj->getSyncWithDrive();
}
return BasePeer::doValidate(AppDocumentPeer::DATABASE_NAME, AppDocumentPeer::TABLE_NAME, $columns);

View File

@@ -191,6 +191,18 @@
<parameter name="Extra" value=""/>
</vendor>
</column>
<column name="SYNC_WITH_DRIVE" type="VARCHAR" size="32" required="true" default="UNSYNCHRONIZED"/>
<column name="SYNC_PERMISSIONS" type="LONGVARCHAR" required="false">
<vendor type="mysql">
<parameter name="Field" value="SYNC_PERMISSIONS"/>
<parameter name="Type" value="MEDIUMTEXT"/>
<parameter name="Null" value="YES"/>
<parameter name="Key" value=""/>
<parameter name="Default" value=""/>
<parameter name="Extra" value=""/>
</vendor>
</column>
<validator column="APP_DOC_UID">
<rule name="maxLength" value="32" message="Application Document UID can be no larger than ${value} in size"/>
<rule name="required" message="Application Document UID is required."/>
@@ -222,6 +234,10 @@
<rule name="validValues" value="ACTIVE|DELETED" message="Please select a valid document status (ACTIVE|DELETED)."/>
<rule name="required" message="Application Document Status is required."/>
</validator>
<validator column="SYNC_WITH_DRIVE">
<rule name="validValues" value="SYNCHRONIZED|UNSYNCHRONIZED|NO_EXIST_FILE_PM" message="Please select a valid type."/>
<rule name="required" message="Type is required."/>
</validator>
<index name="indexAppDocument">
<index-column name="FOLDER_UID"/>

View File

@@ -98,6 +98,8 @@ CREATE TABLE `APP_DOCUMENT`
`APP_DOC_STATUS_DATE` DATETIME,
`APP_DOC_FIELDNAME` VARCHAR(150),
`APP_DOC_DRIVE_DOWNLOAD` MEDIUMTEXT,
`SYNC_WITH_DRIVE` VARCHAR(32) default 'UNSYNCHRONIZED' NOT NULL,
`SYNC_PERMISSIONS` MEDIUMTEXT,
PRIMARY KEY (`APP_DOC_UID`,`DOC_VERSION`),
KEY `indexAppDocument`(`FOLDER_UID`, `APP_DOC_UID`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Documents in an Application';

View File

@@ -2,12 +2,12 @@
if (typeof window.parent != 'undefined') {
<?php
/*----------------------------------********---------------------------------*/
$enablePMGmail = false;
$statusPMGmail = false;
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
$statusPMGmail = $drive->getStatusDrive();
}
/*----------------------------------********---------------------------------*/
if (isset( $_GET['ux'] )) {
@@ -20,7 +20,7 @@ if (isset( $_GET['ux'] )) {
default:
$url = 'casesListExtJs';
}
} else if( key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail==1 ){
} else if( key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && $statusPMGmail ){
$url = 'derivatedGmail';
} else {
$url = 'casesListExtJs';
@@ -31,8 +31,8 @@ if (isset( $_GET['ux'] )) {
echo " window.parent.location.href = '$url';";
if (isset( $_GET['ux'] )) {
/*----------------------------------********---------------------------------*/
if(PMLicensedFeatures::getSingleton()->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') && !empty($enablePMGmail) && $enablePMGmail==1){
echo '} else { window.parent.location.href = \'derivatedGmail\'; }';
if(PMLicensedFeatures::getSingleton()->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') && $statusPMGmail){
echo '} else { window.parent.location.href = \'derivatedGmail\'; }';
} else {
/*----------------------------------********---------------------------------*/
echo '} else { window.parent.location.href = \'casesListExtJs\'; }';

View File

@@ -263,18 +263,16 @@ function startCase ()
/*----------------------------------********---------------------------------*/
//sending the email for gmail integration if the option es available
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
$enablePMGmail = false;
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
if(!empty($enablePMGmail) && $enablePMGmail==1){
require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php';
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX']);
}
if($drive->getStatusDrive()){
require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php';
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
$response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX']);
}
}
/*----------------------------------********---------------------------------*/

View File

@@ -183,6 +183,19 @@ try {
}
// Send notifications Mobile - End
// Set users drive - start
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
$drive->addUserDrive($aUser['USR_EMAIL']);
$drive ->addUsersDocumentDrive($appFields['APP_UID'], $_POST['form']['TASKS'], $appFields['APP_DATA']);
$drive->synchronizeDrive(false);
}
}
// Set users drive - End
// Events - Start
$oEvent = new Event();
@@ -214,7 +227,7 @@ try {
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience'];
$debuggerAvailable = false;
} else if( isset( $_SESSION['gmail'] ) ){
$aNextStep['PAGE'] = 'casesListExtJsRedirector?gmail='.$_SESSION['gmail'];
$aNextStep['PAGE'] = 'casesListExtJsRedirector?gmail='.$_SESSION['gmail'];
} else {
$aNextStep['PAGE'] = 'casesListExtJsRedirector';
}

View File

@@ -360,91 +360,6 @@ try {
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
/*----------------------------------********---------------------------------*/
$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($_SESSION['USER_LOGGED']);
$pmDrive->setDriveUser($dataUser['USR_EMAIL']);
$appData = $app->Load($_SESSION['APPLICATION']);
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($_SESSION['USER_LOGGED']));
$appData['APP_DRIVE_FOLDER_UID'] = $result->id;
$app->update($appData);
}
$result = $pmDrive->uploadFile('application/' . $sExtension, $arrayFileTmpName[$i],
$arrayFileName[$i], $appData['APP_DRIVE_FOLDER_UID']);
$oAppDocument->setDriveDownload('ATTACHED', $result->webContentLink);
$fileIdDrive = $result->id;
$aFields['DOC_VERSION'] = $iDocVersion;
$aFields['APP_DOC_UID'] = $sAppDocUid;
$oAppDocument->update($aFields);
//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, $_SESSION['APPLICATION']);
$criteria->addJoin(ApplicationPeer::PRO_UID, TaskPeer::PRO_UID, Criteria::LEFT_JOIN);
$criteria->addJoin(TaskPeer::TAS_UID, TaskUserPeer::TAS_UID, Criteria::LEFT_JOIN);
$dataset = TaskUserPeer::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) {
$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) {
$userPermission[] = $aRow['USR_EMAIL'];
}
}
}
}
$userPermission = array_unique($userPermission);
foreach ($userPermission as $key => $value) {
$pmDrive->setPermission($appData['APP_DRIVE_FOLDER_UID'], $value, 'user', 'writer');
$pmDrive->setPermission($fileIdDrive, $value);
}
}
}
/*----------------------------------********---------------------------------*/
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document

View File

@@ -107,7 +107,27 @@ if (! $sw_file_exists) {
$res['message'] = $oAppDocument->Fields['APP_DOC_FILENAME'];
print G::json_encode( $res );
} else {
G::streamFile( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] ); //download
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$downloadStatus = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
$fieldDrive = $oAppDocument->getAppDocDriveDownload();
$drive->loadUser($_SESSION['USER_LOGGED']);
$uidDrive = $drive->changeUrlDrive($oAppDocument->Fields, $oAppDocument->getAppDocType());
$result = $drive->download($uidDrive);
//verify download
//file_put_contents($oAppDocument->Fields['APP_DOC_FILENAME'], $result);
$downloadStatus = true;
}
}
if (!$downloadStatus) {
G::streamFile( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] ); //download
}
}
}

View File

@@ -109,7 +109,27 @@ if (! $sw_file_exists) {
$res['message'] = $info['basename'] . $ver . '.' . $ext;
print G::json_encode( $res );
} else {
G::streamFile( $realPath, $download, $info['basename'] . $ver . '.' . $ext );
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$downloadStatus = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
$fieldDrive = $oAppDocument->getAppDocDriveDownload();
$drive->loadUser($_SESSION['USER_LOGGED']);
$type = $ext == 'doc' ? 'OUTPUT_DOC' : 'OUTPUT_PDF';
$uidDrive = $drive->changeUrlDrive($oAppDocument->Fields, $type);
$result = $drive->download($uidDrive);
//verify download file
$downloadStatus = true;
}
}
if (!$downloadStatus) {
G::streamFile( $realPath, $download, $info['basename'] . $ver . '.' . $ext ); //download
}
//die($realPath);
//G::streamFile( $realPath, $download, $info['basename'] . $ver . '.' . $ext );
}
}
//G::streamFile ( $realPath, true);

View File

@@ -628,130 +628,6 @@ try {
$oCase->updateCase( $_SESSION['APPLICATION'], $Fields );
//Save data - End
/*----------------------------------********---------------------------------*/
$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($_SESSION['USER_LOGGED']);
$pmDrive->setDriveUser($dataUser['USR_EMAIL']);
$applicationUid = $_SESSION['APPLICATION'];
$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($_SESSION['USER_LOGGED']));
$appData['APP_DRIVE_FOLDER_UID'] = $result->id;
$app->update($appData);
}
$fileIdDriveDoc = '';
$fileIdDrivePdf = '';
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
$oPluginRegistry = & PMPluginRegistry::getSingleton();
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
@@ -867,29 +743,6 @@ try {
}
}
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
if ($pmDrive->getStatusService()) {
//change donwload link - drive
$driveDownload = @unserialize($aFields['APP_DOC_DRIVE_DOWNLOAD']);
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_DOC',
$driveDownload)
) {
$aFields['FILE1'] = $driveDownload['OUTPUT_DOC'];
}
if ($driveDownload !== false && is_array($driveDownload) && array_key_exists('OUTPUT_PDF',
$driveDownload)
) {
$aFields['FILE2'] = $driveDownload['OUTPUT_PDF'];
}
}
}
/*----------------------------------********---------------------------------*/
if (($aGields['OUT_DOC_GENERATE'] == 'BOTH') || ($aGields['OUT_DOC_GENERATE'] == '')) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ViewOutputDocument1', '', G::array_merges( $aOD, $aFields ), '' );
}

View File

@@ -34,11 +34,9 @@ require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.la
$oLabels = new labelsGmail();
$oResponse = $oLabels->setLabels($caseId, $actualIndex, $actualLastIndex, false);
$enablePMGmail = false;
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
if(key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail==1 ){
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if(array_key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && $drive->getStatusDrive() ){
$_SESSION['gmail'] = 0;
unset($_SESSION['gmail']); //cleaning session
$mUrl = '/sys'. $_SESSION['WORKSPACE'] .'/en/neoclassic/cases/cases_Open?APP_UID='.$caseId.'&DEL_INDEX='.$actualIndex.'&action=sent';

View File

@@ -61,18 +61,17 @@ $oHeadPublisher = & headPublisher::getSingleton();
$urlToRedirectAfterPause = 'casesListExtJs';
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
if (key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail == 1) {
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
if (array_key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && $drive->getStatusDrive()) {
$_SESSION['gmail'] = 0;
$urlToRedirectAfterPause = '/sys'. $_SESSION['WORKSPACE'] .'/en/neoclassic/cases/cases_Open?APP_UID='.$_SESSION['APPLICATION'].'&DEL_INDEX='.$_SESSION['INDEX'].'&action=sent';
}
}
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
$oHeadPublisher->assign( 'urlToRedirectAfterPause', $urlToRedirectAfterPause );

View File

@@ -1044,11 +1044,11 @@ class Cases
}
/*----------------------------------********---------------------------------*/
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
$statusPMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new \PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
$statusPMGmail = $drive->getStatusDrive();
}
/*----------------------------------********---------------------------------*/
$aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
@@ -1169,11 +1169,8 @@ 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 ($statusPMGmail) {
$aFields['DOWNLOAD_LINK'] = $drive->changeUrlDrive($aRow, 'INPUT');
}
/*----------------------------------********---------------------------------*/
if ($lastVersion == $aRow['DOC_VERSION']) {
@@ -1249,11 +1246,8 @@ class Cases
$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 ($statusPMGmail) {
$aFields['DOWNLOAD_LINK'] = $drive->changeUrlDrive($aRow, 'INPUT');
}
/*----------------------------------********---------------------------------*/
if ($lastVersion == $aRow['DOC_VERSION']) {
@@ -1321,11 +1315,8 @@ 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 ($statusPMGmail) {
$aFields['DOWNLOAD_LINK'] = $drive->changeUrlDrive($aRow, 'INPUT');
}
/*----------------------------------********---------------------------------*/
if ($lastVersion == $aRow['DOC_VERSION']) {
@@ -1373,11 +1364,11 @@ class Cases
}
/*----------------------------------********---------------------------------*/
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
$enablePMGmail = false;
$statusPMGmail = false;
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
G::LoadClass( "pmDrive" );
$pmDrive = new \PMDrive();
$enablePMGmail = $pmDrive->getStatusService();
G::LoadClass( "AppDocumentDrive" );
$drive = new AppDocumentDrive();
$statusPMGmail = $drive->getStatusDrive();
}
/*----------------------------------********---------------------------------*/
$aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
@@ -1527,16 +1518,9 @@ class Cases
}
/*----------------------------------********---------------------------------*/
//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 ($statusPMGmail) {
$fileDoc = $drive->changeUrlDrive($aRow, 'OUTPUT_DOC');
$filePdf = $drive->changeUrlDrive($aRow, 'OUTPUT_PDF');
}
/*----------------------------------********---------------------------------*/
//if both documents were generated, we choose the pdf one, only if doc was

View File

@@ -284,16 +284,6 @@ 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();
@@ -304,19 +294,6 @@ 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);
}
@@ -371,15 +348,6 @@ 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();
@@ -391,19 +359,6 @@ 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);
}

View File

@@ -381,128 +381,6 @@ class OutputDocument
}
$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();