BY-200 CLONE - Asignar permisos a los archivos en Google Drive cuando la tarea a la que se deriva es ScriptTask

- La funcion no contemplaba ese tipo de derivacion.
- Se cambio la funcion para que haga un barrido de la tabla app_delegation para obtener los usuarios de la siguiente tarea.

Identation
This commit is contained in:
Marco A. Nina Mena
2016-02-29 12:45:35 -04:00
parent 6e56feb708
commit ef37ef5ce4
2 changed files with 55 additions and 96 deletions

View File

@@ -22,7 +22,7 @@ class AppDocumentDrive
private $user; private $user;
private $statusDrive; private $statusDrive;
private $usersDrive = ''; private $usersEmail = '';
/** /**
* InputDocumentDrive constructor. * InputDocumentDrive constructor.
@@ -32,7 +32,7 @@ class AppDocumentDrive
$this->drive = new PMDrive(); $this->drive = new PMDrive();
$status = $this->drive->getServiceDriveStatus(); $status = $this->drive->getServiceDriveStatus();
$status = !empty($status) ? ($status == 1 ? true : false): false; $status = !empty($status) ? ($status == 1 ? true : false): false;
$this->usersDrive = ''; $this->usersEmail = '';
$this->setStatusDrive($status); $this->setStatusDrive($status);
} }
@@ -140,101 +140,50 @@ class AppDocumentDrive
} }
} }
public function addUserDrive ($email) public function addUserEmail ($email)
{ {
if (empty($email)) { if (empty($email)) {
return; return;
} }
if ($this->usersDrive == '') { if ($this->usersEmail == '') {
$this->usersDrive = $email; $this->usersEmail = $email;
} else { } else {
$emails = explode('|', $this->usersDrive); $emails = explode('|', $this->usersEmail);
if (array_search($email, $emails) === false) { if (array_search($email, $emails) === false) {
$this->usersDrive .= '|' . $email; $this->usersEmail .= '|' . $email;
} }
} }
} }
/** /**
* @param AppDocument $appDoc * Get email of task users to app_uid
* @param array $arrayTask * @param $appUid id application
* @param $arrayData
* *
* @throws \Exception * @throws \Exception
*/ */
public function getEmailUsersTask($arrayTask, $arrayData) public function getEmailUsersTask($appUid)
{ {
try { try {
G::LoadClass("tasks"); $criteria = new Criteria('workflow');
G::LoadClass("groups"); $criteria->add(AppDelegationPeer::APP_UID, $appUid);
G::LoadClass("spool"); $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
$rsAppDelegation = AppDelegationPeer::doSelectRS($criteria);
$rsAppDelegation->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$task = new Tasks();
$group = new Groups(); $group = new Groups();
$oUser = new Users(); $user = new Users();
$data = [];
foreach ($arrayTask as $aTask) { while ($rsAppDelegation->next()) {
switch ($aTask["TAS_ASSIGN_TYPE"]) { $row = $rsAppDelegation->getRow();
case "SELF_SERVICE": if ($user->userExists($row['USR_UID'])) {
if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $data = [];
$usersTask = array(); $data[] = $user->load($row['USR_UID']);
} else {
$groupsTask = $task->getGroupsOfTask($aTask["TAS_UID"], 1); $data = $group->getUsersOfGroup($row['USR_UID']);
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 ($data as $dataUser) {
$this->addUserEmail($dataUser["USR_EMAIL"]);
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) { } catch (Exception $exception) {
@@ -465,9 +414,9 @@ class AppDocumentDrive
} }
} }
public function addUsersDocumentDrive ($appUid, $arrayTask, $arrayData ) public function addUsersDocumentDrive ($appUid)
{ {
$this->getEmailUsersTask($arrayTask, $arrayData); $this->getEmailUsersTask($appUid);
$criteria = new Criteria( 'workflow' ); $criteria = new Criteria( 'workflow' );
$criteria->add( AppDocumentPeer::APP_UID, $appUid ); $criteria->add( AppDocumentPeer::APP_UID, $appUid );
@@ -478,7 +427,14 @@ class AppDocumentDrive
$appDoc = new AppDocument(); $appDoc = new AppDocument();
while ($rs->next()) { while ($rs->next()) {
$row = $rs->getRow(); $row = $rs->getRow();
$row['SYNC_PERMISSIONS'] = $this->usersDrive; if (empty($row['SYNC_PERMISSIONS'])) {
$row['SYNC_PERMISSIONS'] = $this->usersEmail;
} else {
$emails = explode('|', $row['SYNC_PERMISSIONS']);
foreach ($emails as $email) {
$this->addUserEmail($email);
}
}
$appDoc->update($row); $appDoc->update($row);
} }
} }

View File

@@ -183,18 +183,6 @@ try {
} }
// Send notifications Mobile - End // Send notifications Mobile - End
// Set users drive - start
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
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']);
}
}
// Set users drive - End
// Events - Start // Events - Start
$oEvent = new Event(); $oEvent = new Event();
@@ -220,6 +208,21 @@ try {
} }
} }
//Events - End //Events - End
/*----------------------------------********---------------------------------*/
// Set users drive - start
$licensedFeatures = &PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
G::LoadClass("AppDocumentDrive");
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
//add users email next task
$drive->addUsersDocumentDrive($appFields['APP_UID']);
}
}
// Set users drive - End
/*----------------------------------********---------------------------------*/
$debuggerAvailable = true; $debuggerAvailable = true;
if (isset( $_SESSION['user_experience'] )) { if (isset( $_SESSION['user_experience'] )) {