Spaces:
Sleeping
Sleeping
File size: 25,222 Bytes
07c3cdd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | <?php
/**
* AppDocument.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//require_once 'classes/model/om/BaseAppDocument.php';
//require_once 'classes/model/Content.php';
//require_once 'classes/model/InputDocument.php';
/**
* Skeleton subclass for representing a row from the 'APP_DOCUMENT' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class AppDocument extends BaseAppDocument
{
/*----------------------------------********---------------------------------*/
/*
* Load the application document registry
* @param string $sAppDocUid
* @param integer $iVersion (Document version)
* @return variant
*/
public function load ($sAppDocUid, $iVersion = null)
{
try {
if ($iVersion == null) {
$iVersion = $this->getLastAppDocVersion( $sAppDocUid );
}
$oAppDocument = AppDocumentPeer::retrieveByPK( $sAppDocUid, $iVersion );
if (! is_null( $oAppDocument )) {
$aFields = $oAppDocument->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
/*----------------------------------********---------------------------------*/
return $aFields;
} else {
throw (new Exception( 'Error loading Document ' . $sAppDocUid . '/' . $iVersion . '. This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
public function getLastIndex ($sAppUid)
{
try {
$oCriteria = new Criteria();
$oCriteria->add( AppDocumentPeer::APP_UID, $sAppUid );
//$oCriteria->addAscendingOrderByColumn ( AppDocumentPeer::APP_DOC_INDEX );
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX );
$lastAppDoc = AppDocumentPeer::doSelectOne( $oCriteria );
if (! is_null( $lastAppDoc )) {
return $lastAppDoc->getAppDocIndex();
} else {
return 0;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Get last Document Version based on Doc UID
*
* @param s $sAppDocUid
* @return integer
*
*/
public function getLastDocVersion ($sDocUid, $appUID)
{
try {
$oCriteria = new Criteria();
$oCriteria->add( AppDocumentPeer::DOC_UID, $sDocUid );
$oCriteria->add( AppDocumentPeer::APP_UID, $appUID );
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION );
$lastAppDocVersion = AppDocumentPeer::doSelectOne( $oCriteria );
if (! is_null( $lastAppDocVersion )) {
return $lastAppDocVersion->getDocVersion();
} else {
return 0;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Get last Document Version based on APPDoc UID
*
* @param s $sAppDocUid
* @return integer
*
*/
public function getLastAppDocVersion ($sAppDocUid, $appUID = 0)
{
try {
$oCriteria = new Criteria();
$oCriteria->add( AppDocumentPeer::APP_DOC_UID, $sAppDocUid );
if ($appUID != 0) {
$oCriteria->add( AppDocumentPeer::APP_UID, $appUID );
}
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION );
$lastAppDocVersion = AppDocumentPeer::doSelectOne( $oCriteria );
if (! is_null( $lastAppDocVersion )) {
return $lastAppDocVersion->getDocVersion();
} else {
return 0;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the application document registry
*
* @param array $aData
* @return string
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
try {
$oAppDocument = new AppDocument();
if (! isset( $aData['APP_DOC_UID'] )) {
$sUID = G::generateUniqueID();
$docVersion = 1;
} else {
$sUID = $aData['APP_DOC_UID'];
$docVersion = $this->getLastAppDocVersion( $aData['APP_DOC_UID'], $oAppDocument->getAppUid() );
$oAppDocument->load( $aData['APP_DOC_UID'], $docVersion );
switch ($oAppDocument->getAppDocType()) {
case "OUTPUT": //Output versioning
$o = new OutputDocument();
$oOutputDocument = $o->load( $oAppDocument->getDocUid() );
if (! $oOutputDocument['OUT_DOC_VERSIONING']) {
throw (new Exception( 'The Output document has not versioning enabled!' ));
}
break;
case "INPUT": // Input versioning
$o = new InputDocument();
$oInputDocument = $o->load( $oAppDocument->getDocUid() );
if (! $oInputDocument['INP_DOC_VERSIONING']) {
throw (new Exception( 'This Input document does not have the versioning enabled, for this reason this operation cannot be completed' ));
}
break;
default: //Not a valid type
throw (new Exception( 'The document is not of a valid Type' ));
break;
}
$docVersion ++;
}
/*----------------------------------********---------------------------------*/
$oAppDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oAppDocument->setDocVersion( $docVersion );
$oAppDocument->setAppDocUid( $sUID );
$oAppDocument->setAppDocIndex( $this->getLastIndex( $oAppDocument->getAppUid() ) + 1 );
if ($oAppDocument->validate()) {
$oConnection->begin();
if (isset( $aData['APP_DOC_TITLE'] )) {
$oAppDocument->setAppDocTitleContent( $aData['APP_DOC_TITLE'] );
}
if (isset( $aData['APP_DOC_COMMENT'] )) {
$oAppDocument->setAppDocCommentContent( $aData['APP_DOC_COMMENT'] );
}
if (isset( $aData['APP_DOC_FILENAME'] )) {
$oAppDocument->setAppDocFilenameContent( $aData['APP_DOC_FILENAME'] );
}
$iResult = $oAppDocument->save();
$oConnection->commit();
$this->fromArray( $oAppDocument->toArray( BasePeer::TYPE_FIELDNAME ), BasePeer::TYPE_FIELDNAME );
return $sUID;
} else {
$sMessage = '';
$aValidationFailures = $oAppDocument->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Update the application document registry
*
* @param array $aData
* @return string
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
try {
$oAppDocument = AppDocumentPeer::retrieveByPK( $aData['APP_DOC_UID'], $aData['DOC_VERSION'] );
if (! is_null( $oAppDocument )) {
/*----------------------------------********---------------------------------*/
$oAppDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oAppDocument->validate()) {
$oConnection->begin();
if (isset( $aData['APP_DOC_TITLE'] )) {
$oAppDocument->setAppDocTitleContent( $aData['APP_DOC_TITLE'] );
}
if (isset( $aData['APP_DOC_COMMENT'] )) {
$oAppDocument->setAppDocCommentContent( $aData['APP_DOC_COMMENT'] );
}
if (isset( $aData['APP_DOC_FILENAME'] )) {
$oAppDocument->setAppDocFilenameContent( $aData['APP_DOC_FILENAME'] );
}
$iResult = $oAppDocument->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oAppDocument->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Remove the application document registry by changing status only
* Modified by Hugo Loza hugo@colosa.com
*
* @param array $aData
* @return string
*
*/
public function remove ($sAppDocUid, $iVersion = 1)
{
$oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
try {
$oAppDocument = AppDocumentPeer::retrieveByPK( $sAppDocUid, $iVersion );
if (! is_null( $oAppDocument )) {
$arrayDocumentsToDelete = array ();
if ($oAppDocument->getAppDocType() == "INPUT") {
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( AppDocumentPeer::APP_DOC_UID, $sAppDocUid );
$oDataset = AppDocumentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$arrayDocumentsToDelete[] = array ('sAppDocUid' => $aRow['APP_DOC_UID'],'iVersion' => $aRow['DOC_VERSION']
);
$oDataset->next();
}
} else {
$arrayDocumentsToDelete[] = array ('sAppDocUid' => $sAppDocUid,'iVersion' => $iVersion
);
}
foreach ($arrayDocumentsToDelete as $key => $docToDelete) {
$aFields = array ('APP_DOC_UID' => $docToDelete['sAppDocUid'],'DOC_VERSION' => $docToDelete['iVersion'],'APP_DOC_STATUS' => 'DELETED'
);
$oAppDocument->update( $aFields );
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Get the [app_doc_title] column value.
*
* @return string
*/
public function getAppDocTitleContent ()
{
if ($this->app_doc_title == '') {
try {
$this->app_doc_title = Content::load( 'APP_DOC_TITLE', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
if ($this->app_doc_title == "") {
$this->app_doc_title = Content::load( 'APP_DOC_TITLE', '', $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') ); //For backward compatibility
}
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->app_doc_title;
}
/**
* Set the [app_doc_title] column value.
*
* @param string $sValue new value
* @return void
*/
public function setAppDocTitleContent ($sValue)
{
if ($sValue !== null && ! is_string( $sValue )) {
$sValue = (string) $sValue;
}
if (in_array(AppDocumentPeer::APP_DOC_TITLE, $this->modifiedColumns) || $sValue === '') {
try {
$this->app_doc_title = $sValue;
$iResult = Content::addContent( 'APP_DOC_TITLE', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_title );
} catch (Exception $oError) {
$this->app_doc_title = '';
throw ($oError);
}
}
}
/**
* Get the [app_doc_comment] column value.
*
* @return string
*/
public function getAppDocCommentContent ()
{
if ($this->app_doc_comment == '') {
try {
$this->app_doc_comment = Content::load( 'APP_DOC_COMMENT', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
if ($this->app_doc_comment == "") {
$this->app_doc_comment = Content::load( 'APP_DOC_COMMENT', '', $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') ); //For backward compatibility
}
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->app_doc_comment;
}
/**
* Set the [app_doc_comment] column value.
*
* @param string $sValue new value
* @return void
*/
public function setAppDocCommentContent ($sValue)
{
if ($sValue !== null && ! is_string( $sValue )) {
$sValue = (string) $sValue;
}
if (in_array(AppDocumentPeer::APP_DOC_COMMENT, $this->modifiedColumns) || $sValue === '') {
try {
$this->app_doc_comment = $sValue;
$iResult = Content::addContent( 'APP_DOC_COMMENT', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_comment );
} catch (Exception $oError) {
$this->app_doc_comment = '';
throw ($oError);
}
}
}
/**
* Get the [app_doc_filename] column value.
*
* @return string
*/
public function getAppDocFilenameContent ()
{
if ($this->app_doc_filename == '') {
try {
$this->app_doc_filename = Content::load( 'APP_DOC_FILENAME', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
if ($this->app_doc_filename == "") {
$this->app_doc_filename = Content::load( 'APP_DOC_FILENAME', '', $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') ); //For backward compatibility
}
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->app_doc_filename;
}
/**
* Set the [app_doc_filename] column value.
*
* @param string $sValue new value
* @return void
*/
public function setAppDocFilenameContent ($sValue)
{
if ($sValue !== null && ! is_string( $sValue )) {
$sValue = (string) $sValue;
}
if (in_array(AppDocumentPeer::APP_DOC_FILENAME, $this->modifiedColumns) || $sValue === '') {
try {
$this->app_doc_filename = $sValue;
$iResult = Content::addContent( 'APP_DOC_FILENAME', $this->getDocVersion(), $this->getAppDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->app_doc_filename );
} catch (Exception $oError) {
$this->app_doc_filename = '';
throw ($oError);
}
}
}
public function isEmptyInContent ($content, $field, $lang)
{
if (isset( $content[$field][$lang] )) {
if (trim( $content[$field][$lang] ) != '') {
return false;
}
}
;
return true;
}
/*----------------------------------********---------------------------------*/
public function getObject ($APP_UID, $DEL_INDEX, $STEP_UID_OBJ, $APP_DOC_TYPE)
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( AppDocumentPeer::APP_UID, $APP_UID );
$oCriteria->add( AppDocumentPeer::DEL_INDEX, $DEL_INDEX );
$oCriteria->add( AppDocumentPeer::DOC_UID, $STEP_UID_OBJ );
$oCriteria->add( AppDocumentPeer::APP_DOC_TYPE, $APP_DOC_TYPE );
$oDataset = AppDocumentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
return $oDataset->getRow();
}
/**
* Get all docuemnts for a folder
*
* @param array $sFolderUid
* @return array
*/
public function getDocumentsinFolders ($sFolderUid)
{
$documents = array ();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( AppDocumentPeer::FOLDER_UID, $sFolderUid );
$oDataset = AppDocumentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$documents[] = array ('sAppDocUid' => $aRow['APP_DOC_UID'],'iVersion' => $aRow['DOC_VERSION']
);
$oDataset->next();
}
return $documents;
}
/**
* This function check if exist a document
* @param string $appDocUid, Uid of the document
* @param integer $version,
* @return object
*/
public function exists ($appDocUid, $version = 1)
{
$oAppDocument = AppDocumentPeer::retrieveByPK($appDocUid, $version);
return (is_object($oAppDocument) && get_class($oAppDocument) == 'AppDocument');
}
/**
* The user that uploaded a document can download the same input file.
* A participated user or a supervisor must have the process permission "view" to be able to download the input document.
* If the user is a supervisor and had the input document assign, he can download the file too.
* @param $user
* @param $appDocUid
* @param $version
* @return bool
*/
public function canDownloadInput($user, $appDocUid, $version)
{
//Check if the the requester is the owner in the file
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(AppDocumentPeer::APP_UID);
$oCriteria->addJoin(AppDocumentPeer::DOC_UID, InputDocumentPeer::INP_DOC_UID, Criteria::LEFT_JOIN);
$oCriteria->add(AppDocumentPeer::USR_UID, $user);
$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $appDocUid);
$oCriteria->add(AppDocumentPeer::DOC_VERSION, $version);
$oCriteria->setLimit(1);
$dataset = AppDocumentPeer::doSelectRS($oCriteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
if ($dataset->getRow()) {
return true;
} else {
//Review if is a INPUT or ATTACHED
$oCriteria = new Criteria("workflow");
$oCriteria->addSelectColumn(AppDocumentPeer::APP_UID);
$oCriteria->addSelectColumn(AppDocumentPeer::DOC_UID);
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE);
$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $appDocUid);
$oCriteria->add(AppDocumentPeer::DOC_VERSION, $version);
$oCriteria->setLimit(1);
$dataset = AppDocumentPeer::doSelectRS($oCriteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$row = $dataset->getRow();
if ($row['DOC_UID'] == '-1') {
//If is an attached we only verify if is a supervisor in the process
$appUid = $row['APP_UID'];
$oApplication = new Application();
$aColumns = $oApplication->Load($appUid);
$cases = new \ProcessMaker\BusinessModel\Cases();
$userAuthorization = $cases->userAuthorization(
$user,
$aColumns['PRO_UID'],
$appUid,
array(),
array('ATTACHMENTS' => 'VIEW')
);
//Has permissions?
if (in_array($appDocUid, $userAuthorization['objectPermissions']['ATTACHMENTS'])) {
return true;
}
//Is supervisor?
if ($userAuthorization['supervisor']) {
return true;
}
} else {
//If is an file related an input document, we will check if the user is a supervisor or has permissions
$appUid = $row['APP_UID'];
$oInputDoc = new InputDocument();
$aColumns = $oInputDoc->Load($row['DOC_UID']);
$cases = new \ProcessMaker\BusinessModel\Cases();
$userAuthorization = $cases->userAuthorization(
$user,
$aColumns['PRO_UID'],
$appUid,
array(),
array('INPUT_DOCUMENTS' => 'VIEW', 'ATTACHMENTS' => 'VIEW')
);
//Has permissions?
if (in_array($appDocUid, $userAuthorization['objectPermissions']['INPUT_DOCUMENTS'])) {
return true;
}
//Has permissions?
if (in_array($appDocUid, $userAuthorization['objectPermissions']['ATTACHMENTS'])) {
return true;
}
//Is supervisor?
if ($userAuthorization['supervisor']) {
//Review if the supervisor has assigned the object input document
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
$criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL);
$criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $row['DOC_UID'], \Criteria::EQUAL);
$rsCriteria = StepSupervisorPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
return true;
}
}
}
}
return false;
}
/**
* Check if the user $userCanDownload can download the Output Document
*
* The user that generate the output document can download the same output document file
* A participated user or a supervisor must have the process permission "view" to be able to download the output document
* @param string $userGenerateDocument
* @param string $userCanDownload
* @param string $proUid
* @param string $appUid
* @param string $sAppDocUid
* @return boolean
*/
public function canDownloadOutput($userGenerateDocument, $userCanDownload, $proUid, $appUid, $sAppDocUid)
{
//Check if the user Logged was generate the document
if ($userGenerateDocument !== $userCanDownload) {
$objCase = new \ProcessMaker\BusinessModel\Cases();
$aUserCanAccess = $objCase->userAuthorization(
$userCanDownload,
$proUid,
$appUid,
array(),
array('OUTPUT_DOCUMENTS'=>'VIEW')
);
//If the user does not have the process permission can not download
if (in_array($sAppDocUid, $aUserCanAccess['objectPermissions']['OUTPUT_DOCUMENTS'])) {
return true;
}
} else {
return true;
}
return false;
}
}
|