GI-162 Corregir obser. code Review Pmdrive/Gmail SOLVED
- Add validation error_log, return Change validate array_search == null to === false Change setTimeout 36000 to 60000
This commit is contained in:
@@ -2302,14 +2302,14 @@ class Cases
|
||||
break;
|
||||
}
|
||||
if(array_key_exists('gmail',$_SESSION) || (array_key_exists('gmail',$_GET) && $_GET['gmail'] == 1)){
|
||||
$aNextStep = array(
|
||||
'TYPE' => $oStep->getStepTypeObj(),
|
||||
'UID' => $oStep->getStepUidObj(),
|
||||
'POSITION' => $oStep->getStepPosition(),
|
||||
'PAGE' => 'cases_Step?TYPE=' . $oStep->getStepTypeObj() . '&UID=' .
|
||||
$oStep->getStepUidObj() . '&POSITION=' . $oStep->getStepPosition() .
|
||||
$aNextStep = array(
|
||||
'TYPE' => $oStep->getStepTypeObj(),
|
||||
'UID' => $oStep->getStepUidObj(),
|
||||
'POSITION' => $oStep->getStepPosition(),
|
||||
'PAGE' => 'cases_Step?TYPE=' . $oStep->getStepTypeObj() . '&UID=' .
|
||||
$oStep->getStepUidObj() . '&POSITION=' . $oStep->getStepPosition() .
|
||||
'&ACTION=' . $sAction .
|
||||
'&gmail=1'
|
||||
'&gmail=1'
|
||||
);
|
||||
} else{
|
||||
$aNextStep = array(
|
||||
@@ -2336,11 +2336,11 @@ class Cases
|
||||
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN&gmail=1'
|
||||
);
|
||||
}else {
|
||||
$aNextStep = array(
|
||||
'TYPE' => 'DERIVATION',
|
||||
'UID' => -1,
|
||||
'POSITION' => ($iLastStep + 1),
|
||||
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN'
|
||||
$aNextStep = array(
|
||||
'TYPE' => 'DERIVATION',
|
||||
'UID' => -1,
|
||||
'POSITION' => ($iLastStep + 1),
|
||||
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3980,7 +3980,7 @@ class Cases
|
||||
if ($row['TU_RELATION'] == 1) {
|
||||
//users
|
||||
$dataUser = $user->load($row['USR_UID']);
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) == null) {
|
||||
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'];
|
||||
@@ -3997,7 +3997,7 @@ class Cases
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) == null) {
|
||||
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'];
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
G::LoadClass( "pmGoogleApi" );
|
||||
|
||||
class PMDrive extends PMGoogleApi
|
||||
{
|
||||
private $folderIdPMDrive = '';
|
||||
@@ -102,18 +103,18 @@ class PMDrive extends PMGoogleApi
|
||||
$service = $this->serviceDrive();
|
||||
|
||||
try {
|
||||
$rows = array();
|
||||
$parameters['q'] = "'" . $fileId . "' in parents and trashed = false";
|
||||
$parents = $service->files->listFiles($parameters);
|
||||
|
||||
$rows = array();
|
||||
foreach ($parents->getItems() as $parent) {
|
||||
//echo 'File Id: ' . $parent->getId() . '<br>';
|
||||
$rows = $parent;
|
||||
}
|
||||
return $rows;
|
||||
|
||||
} catch (Exception $e) {
|
||||
return G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage();
|
||||
error_log( G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage());
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,10 +142,11 @@ class PMDrive extends PMGoogleApi
|
||||
|
||||
try {
|
||||
$createdFolder = $service->files->insert($file);
|
||||
return $createdFolder;
|
||||
} catch (Exception $e) {
|
||||
return "An error occurred: " . $e->getMessage();
|
||||
$createdFolder = null;
|
||||
error_log ( "An error occurred: " . $e->getMessage());
|
||||
}
|
||||
return $createdFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +159,6 @@ class PMDrive extends PMGoogleApi
|
||||
*/
|
||||
public function uploadFile($mime, $src, $name, $parentId = null)
|
||||
{
|
||||
//$this->validateFolderPMDrive();
|
||||
$this->setScope('https://www.googleapis.com/auth/drive.file');
|
||||
|
||||
$service = $this->serviceDrive();
|
||||
@@ -185,10 +186,10 @@ class PMDrive extends PMGoogleApi
|
||||
)
|
||||
);
|
||||
|
||||
return $createdFile;
|
||||
} catch (Exception $e) {
|
||||
return "An error occurred: " . $e->getMessage();
|
||||
error_log( "An error occurred: " . $e->getMessage());
|
||||
}
|
||||
return $createdFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +200,6 @@ class PMDrive extends PMGoogleApi
|
||||
*/
|
||||
public function downloadFile($fileId)
|
||||
{
|
||||
//$this->validateFolderPMDrive();
|
||||
$this->setScope('https://www.googleapis.com/auth/drive');
|
||||
$this->setScope('https://www.googleapis.com/auth/drive.appdata');
|
||||
$this->setScope('https://www.googleapis.com/auth/drive.apps.readonly');
|
||||
@@ -211,24 +211,24 @@ class PMDrive extends PMGoogleApi
|
||||
|
||||
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) {
|
||||
return $httpRequest->getResponseBody();
|
||||
$response = $httpRequest->getResponseBody();
|
||||
} else {
|
||||
// An error occurred.
|
||||
return null;
|
||||
error_log( "An error occurred. ");
|
||||
}
|
||||
} else {
|
||||
// The file doesn't have any content stored on Drive.
|
||||
return null;
|
||||
error_log( "The file doesn't have any content stored on Drive.");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
print "An error occurred: " . $e->getMessage();
|
||||
error_log( "An error occurred: " . $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,10 +261,9 @@ class PMDrive extends PMGoogleApi
|
||||
)
|
||||
);
|
||||
|
||||
return $permission;
|
||||
} catch (Exception $e) {
|
||||
error_log('permission error: ' . $e->getMessage());
|
||||
return "An error occurred: " . $e->getMessage();
|
||||
}
|
||||
return $permission;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,12 @@ class PMGoogleApi
|
||||
{
|
||||
$client = null;
|
||||
if ($this->typeAuthentication == 'webApplication') {
|
||||
$credential = file_get_contents(PATH_DATA_SITE . $this->accountJson);
|
||||
if (file_exists(PATH_DATA_SITE . $this->accountJson)) {
|
||||
$credential = file_get_contents(PATH_DATA_SITE . $this->accountJson);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
||||
}
|
||||
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($credential);
|
||||
@@ -206,7 +211,12 @@ class PMGoogleApi
|
||||
die;
|
||||
}
|
||||
} else if ($this->typeAuthentication == 'serviceAccount') {
|
||||
$key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountP12);
|
||||
|
||||
if (file_exists(PATH_DATA_SITE . $this->serviceAccountP12)) {
|
||||
$key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountP12);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_P12_ERROR'));
|
||||
}
|
||||
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$this->serviceAccountEmail,
|
||||
@@ -244,7 +254,12 @@ class PMGoogleApi
|
||||
);
|
||||
|
||||
if ($credentials->typeAuth == 'webApplication') {
|
||||
$credential = file_get_contents($credentials->pathFileJson);
|
||||
|
||||
if (file_exists($credentials->pathFileJson)) {
|
||||
$credential = file_get_contents($credentials->pathFileJson);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
||||
}
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($credential);
|
||||
@@ -267,7 +282,12 @@ class PMGoogleApi
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
$key = file_get_contents($credentials->pathServiceAccountP12);
|
||||
|
||||
if (file_exists($credentials->pathServiceAccountP12)) {
|
||||
$key = file_get_contents($credentials->pathServiceAccountP12);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_P12_ERROR'));
|
||||
}
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$credentials->emailServiceAccount,
|
||||
$scope,
|
||||
|
||||
@@ -412,7 +412,7 @@ try {
|
||||
if ($row['TU_RELATION'] == 1) {
|
||||
//users
|
||||
$dataUser = $user->load($row['USR_UID']);
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) == null) {
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) === false) {
|
||||
$userPermission[] = $dataUser['USR_EMAIL'];
|
||||
}
|
||||
} else {
|
||||
@@ -427,7 +427,7 @@ try {
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($dataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) == null) {
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) === false) {
|
||||
$userPermission[] = $aRow['USR_EMAIL'];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
<?php
|
||||
if (!isset($_SESSION['USER_LOGGED'])) {
|
||||
G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' );
|
||||
die( '<script type="text/javascript">
|
||||
try
|
||||
{
|
||||
var olink = document.location.href;
|
||||
if(olink.search("gmail") == -1){
|
||||
prnt = parent.parent;
|
||||
top.location = top.location;
|
||||
} else {
|
||||
var data = olink.split("?");
|
||||
var odata = data[1].split("&");
|
||||
var appUid = odata[1].split("=");
|
||||
var proUid = odata[0].split("=");
|
||||
|
||||
var dataToSend = {
|
||||
"action": "credentials",
|
||||
"operation": "refreshPmSession",
|
||||
"type": "processCall",
|
||||
"funParams": [
|
||||
appUid[1],
|
||||
proUid[1]
|
||||
],
|
||||
};
|
||||
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
if (x == undefined){
|
||||
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
}
|
||||
}
|
||||
}catch (err)
|
||||
{
|
||||
parent.location = parent.location;
|
||||
}
|
||||
</script>');
|
||||
if (!isset($_SESSION['USER_LOGGED'])) {
|
||||
G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' );
|
||||
die( '<script type="text/javascript">
|
||||
try
|
||||
{
|
||||
var olink = document.location.href;
|
||||
if(olink.search("gmail") == -1){
|
||||
prnt = parent.parent;
|
||||
top.location = top.location;
|
||||
} else {
|
||||
var data = olink.split("?");
|
||||
var odata = data[1].split("&");
|
||||
var appUid = odata[1].split("=");
|
||||
var proUid = odata[0].split("=");
|
||||
|
||||
var dataToSend = {
|
||||
"action": "credentials",
|
||||
"operation": "refreshPmSession",
|
||||
"type": "processCall",
|
||||
"funParams": [
|
||||
appUid[1],
|
||||
proUid[1]
|
||||
],
|
||||
};
|
||||
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
if (x == undefined){
|
||||
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
}
|
||||
}
|
||||
}catch (err)
|
||||
{
|
||||
parent.location = parent.location;
|
||||
}
|
||||
</script>');
|
||||
}
|
||||
|
||||
require_once 'classes/model/AppDelegation.php';
|
||||
@@ -82,9 +82,9 @@ switch ($RBAC->userCanAccess( 'PM_CASES' )) {
|
||||
die();
|
||||
break;
|
||||
}
|
||||
|
||||
if(array_key_exists('gmail',$_GET) && $_GET['gmail'] == 1){
|
||||
$_SESSION['gmail'] = 1;
|
||||
|
||||
if(array_key_exists('gmail',$_GET) && $_GET['gmail'] == 1){
|
||||
$_SESSION['gmail'] = 1;
|
||||
}
|
||||
|
||||
if ((int) $_SESSION['INDEX'] < 1) {
|
||||
@@ -705,10 +705,10 @@ try {
|
||||
if ($row['TU_RELATION'] == 1) {
|
||||
//users
|
||||
$dataUser = $user->load($row['USR_UID']);
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) == null) {
|
||||
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']) != null) {
|
||||
if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
|
||||
$userPermission[] = $dataUser['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
@@ -724,11 +724,11 @@ try {
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) == null) {
|
||||
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']) != null
|
||||
$objectPermissions['OUTPUT_DOCUMENTS']) !== false
|
||||
) {
|
||||
$userPermission[] = $aRow['USR_EMAIL'];
|
||||
}
|
||||
|
||||
@@ -462,10 +462,10 @@ class OutputDocument
|
||||
if ($row['TU_RELATION'] == 1) {
|
||||
//users
|
||||
$dataUser = $user->load($row['USR_UID']);
|
||||
if (array_search($dataUser['USR_EMAIL'], $userPermission) == null) {
|
||||
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']) != null) {
|
||||
if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
|
||||
$userPermission[] = $dataUser['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
@@ -482,10 +482,10 @@ class OutputDocument
|
||||
|
||||
while ( $oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
if (array_search($aRow['USR_EMAIL'], $userPermission) == null) {
|
||||
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']) != null) {
|
||||
if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
|
||||
$userPermission[] = $aRow['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ var testSettings = function ()
|
||||
url : '../pmGmail/testConfigPmGmail',
|
||||
waitMsg : _('ID_TEST_CONNECTION'),
|
||||
waitTitle : " ",
|
||||
timeout : 36000,
|
||||
timeout : 60000,
|
||||
success : function(obj, resp) {
|
||||
Ext.getCmp('testPMGmail').show();
|
||||
Ext.getCmp('listUsers').show();
|
||||
@@ -392,7 +392,7 @@ var saveSettings = function ()
|
||||
url : '../pmGmail/saveConfigPmGmail',
|
||||
waitMsg : _('ID_SAVING_PROCESS'),
|
||||
waitTitle : " ",
|
||||
timeout : 36000,
|
||||
timeout : 60000,
|
||||
success : function(obj, resp) {
|
||||
var response = Ext.decode(resp.response.responseText);
|
||||
parent.PMExt.notify(_('ID_INFO'),_('ID_SAVED_SUCCESSFULLY'));
|
||||
|
||||
Reference in New Issue
Block a user