Merged in marcoAntonioNina/processmaker/GI-217 (pull request #3433)

GI-217
This commit is contained in:
Dante Loayza
2015-12-21 16:12:51 -04:00
3 changed files with 23 additions and 25 deletions

View File

@@ -332,13 +332,11 @@ class AppDocumentDrive
$criteria = new Criteria( 'workflow' ); $criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID); $criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION); $criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
$criteria->add( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED' ); $criteria->add(
//Verify other permissions
/*$criteria->add(
$criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL )-> $criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'UNSYNCHRONIZED', Criteria::EQUAL )->
addOr($criteria->getNewCriterion( AppDocumentPeer::SYNC_WITH_DRIVE, 'NO_EXIST_FILE_PM', Criteria::NOT_EQUAL )-> addOr($criteria->getNewCriterion( AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL ))
addAnd($criteria->getNewCriterion( AppDocumentPeer::SYNC_PERMISSIONS, null, Criteria::NOT_EQUAL ))) );
);*/
$criteria->addAscendingOrderByColumn( 'APP_DOC_CREATE_DATE' ); $criteria->addAscendingOrderByColumn( 'APP_DOC_CREATE_DATE' );
$criteria->addAscendingOrderByColumn( 'APP_UID' ); $criteria->addAscendingOrderByColumn( 'APP_UID' );
$rs = AppDocumentPeer::doSelectRS( $criteria ); $rs = AppDocumentPeer::doSelectRS( $criteria );
@@ -410,48 +408,46 @@ class AppDocumentDrive
if ($sw_file_exists) { if ($sw_file_exists) {
$this->loadApplication($appDoc->getAppUid()); $this->loadApplication($appDoc->getAppUid());
$this->loadUser($fields['USR_UID']);
$emails = $appDoc->getSyncPermissions(); $emails = $appDoc->getSyncPermissions();
$emails = !empty($emails) ? explode('|', $emails) : array(); $emails = !empty($emails) ? explode('|', $emails) : array();
$result = null; $result = null;
foreach ($emails as $index => $email) { foreach ($emails as $index => $email) {
if (!empty($email)) { if (!empty($email)) {
if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') { if ($index == 0 && $fields['SYNC_WITH_DRIVE'] == 'UNSYNCHRONIZED') {
if ($log) { if ($log) {
eprintln('upload file:' . $name , 'green'); eprintln('upload file:' . $name , 'green');
} }
$this->drive->setDriveUser($email); $this->drive->setDriveUser($email);
$this->loadUser($fields['USR_UID']);
$info = finfo_open(FILEINFO_MIME_TYPE); $info = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($info, $realPath);
$type = $appDoc->getAppDocType();
if ($appDoc->getAppDocType() == 'OUTPUT') { if ($appDoc->getAppDocType() == 'OUTPUT') {
if ($sw_file_exists_doc) { if ($sw_file_exists_doc) {
$nameDoc = explode('/', $realPathDoc); $realPath = $realPathDoc;
$result = $this->upload($fields, 'OUTPUT_DOC', 'application/msword', $realPathDoc, array_pop($nameDoc)); $name = array_pop(explode('/', $realPathDoc));
$mime = 'application/msword';
$type = 'OUTPUT_DOC';
} }
if ($sw_file_exists_pdf) { if ($sw_file_exists_pdf) {
$namePdf = explode('/', $realPathPdf); $realPath = $realPathPdf;
$name = array_pop(explode('/', $realPathPdf));
$mime = finfo_file($info, $realPathPdf); $mime = finfo_file($info, $realPathPdf);
$result = $this->upload($fields, 'OUTPUT_PDF', $mime, $realPathPdf, array_pop($namePdf)); $type = 'OUTPUT_PDF';
} }
} else {
$mime = finfo_file($info, $realPath);
$result = $this->upload($fields, $appDoc->getAppDocType(), $mime, $realPath, $name);
} }
$result = $this->upload($fields, $type, $mime, $realPath, $name);
if ($log) {
eprintln('Set Permission:' . $email , 'green');
}
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
} else { } else {
if ($log) { $this->drive->setDriveUser($this->user->getUsrEmail());
eprintln('Set Permission:' . $email , 'green');
}
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
} }
if ($log) {
eprintln('Set Permission:' . $email , 'green');
}
$this->drive->setPermission($this->app->getAppDriveFolderUid(), $email, 'user', 'writer');
} }
} }

View File

@@ -246,6 +246,7 @@ class PMDrive extends PMGoogleApi
$this->setScope(static::DRIVE_FILE); $this->setScope(static::DRIVE_FILE);
$service = $this->serviceDrive(); $service = $this->serviceDrive();
$permission = null;
$newPermission = new Google_Service_Drive_Permission(); $newPermission = new Google_Service_Drive_Permission();
$newPermission->setValue($value); $newPermission->setValue($value);

View File

@@ -352,6 +352,7 @@ Ext.onReady(function(){
Ext.getCmp('status_pmgmail').checked = enablePMGmail; Ext.getCmp('status_pmgmail').checked = enablePMGmail;
Ext.getCmp('status_pmgmail').setValue(enablePMGmail); Ext.getCmp('status_pmgmail').setValue(enablePMGmail);
Ext.getCmp('typeAuthentication').setValue('serviceAccount');
if (enablePMGmail){ if (enablePMGmail){
changeType(); changeType();
} }