* 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/AppDocumentPeer.php"; $oAppDocument = new AppDocument(); if (!isset($_GET['v'])) { //Load last version of the document $docVersion = $oAppDocument->getLastAppDocVersion($_GET['a']); } else { $docVersion = $_GET['v']; } $oAppDocument->Fields = $oAppDocument->load($_GET['a'], $docVersion); $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = $info['extension']; if (isset($_GET['b'])) { if ($_GET['b'] == '0') { $bDownload = false; } else { $bDownload = true; } } else {
unlink($pathOutput . $sFilename . '.doc'); } break; } } $outputNextStep = 'cases_Step?TYPE=OUTPUT_DOCUMENT&UID=' . $_GET['UID'] . '&POSITION=' . $_SESSION['STEP_POSITION'] . '&ACTION=VIEW&DOC=' . $sDocUID; G::header('location: ' . $outputNextStep); die; break; case 'VIEW': if ($noShowTitle == 0) { $G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $array); } require_once 'classes/model/AppDocument.php'; $oAppDocument = new AppDocument(); $lastVersion = $oAppDocument->getLastAppDocVersion($_GET['DOC'], $_SESSION['APPLICATION']); $aFields = $oAppDocument->load($_GET['DOC'], $lastVersion); $listing = false; $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) { $folderData = new folderData(null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED']); $folderData->PMType = "OUTPUT"; $folderData->returnList = true; $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData); } require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aGields = $oOutputDocument->load($aFields['DOC_UID']); if (isset($aGields['OUT_DOC_VERSIONING']) && $aGields['OUT_DOC_VERSIONING'] != 0) { $oAppDocument = new AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($_GET['UID'], $_SESSION['APPLICATION']);
public function getAllUploadedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID) { G::LoadClass("configuration"); $conf = new Configurations(); $confEnvSetting = $conf->getFormats(); //verifica si existe la tabla OBJECT_PERMISSION $this->verifyTable(); $listing = false; $oPluginRegistry = & PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) { $folderData = new folderData(null, null, $sApplicationUID, null, $sUserUID); $folderData->PMType = "INPUT"; $folderData->returnList = true; //$oPluginRegistry = & PMPluginRegistry::getSingleton(); $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData); } $aObjectPermissions = $this->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID); if (!is_array($aObjectPermissions)) { $aObjectPermissions = array( 'DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1) ); } if (!isset($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } else { if (!is_array($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } } if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } } if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } } $aDelete = $this->getAllObjectsFrom($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID, 'DELETE'); $oAppDocument = new AppDocument(); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, array('INPUT'), Criteria::IN); $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), Criteria::IN); //$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], Criteria::IN); $oCriteria->add( $oCriteria->getNewCriterion( AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], Criteria::IN)-> addOr($oCriteria->getNewCriterion(AppDocumentPeer::USR_UID, array($sUserUID, '-1'), Criteria::IN)) ); $aConditions = array(); $aConditions[] = array(AppDocumentPeer::APP_UID, AppDelegationPeer::APP_UID); $aConditions[] = array(AppDocumentPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(AppDelegationPeer::PRO_UID, $sProcessUID); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aInputDocuments = array(); $aInputDocuments[] = array( 'APP_DOC_UID' => 'char', 'DOC_UID' => 'char', 'APP_DOC_COMMENT' => 'char', 'APP_DOC_FILENAME' => 'char', 'APP_DOC_INDEX' => 'integer' ); $oUser = new Users(); while ($aRow = $oDataset->getRow()) { $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria2->add(AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oTask = new Task(); if ($oTask->taskExists($aRow2['TAS_UID'])) { $aTask = $oTask->load($aRow2['TAS_UID']); } else { $aTask = array('TAS_TITLE' => '(TASK DELETED)'); } $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']); $lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID); try { $aAux1 = $oUser->load($aAux['USR_UID']); $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]); } catch (Exception $oException) { //$sUser = '******'; $sUser = '******'; } $aFields = array( 'APP_DOC_UID' => $aAux['APP_DOC_UID'], 'DOC_UID' => $aAux['DOC_UID'], 'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'], 'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'], 'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'], 'TYPE' => $aAux['APP_DOC_TYPE'], 'ORIGIN' => $aTask['TAS_TITLE'], 'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'], 'CREATED_BY' => $sUser ); if ($aFields['APP_DOC_FILENAME'] != '') { $aFields['TITLE'] = $aFields['APP_DOC_FILENAME']; } else { $aFields['TITLE'] = $aFields['APP_DOC_COMMENT']; } $aFields['POSITION'] = $_SESSION['STEP_POSITION']; $aFields['CONFIRM'] = G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT'); if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) { $aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE'); } $aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD'); $aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION']; $aFields['DOC_VERSION'] = $aRow['DOC_VERSION']; if (is_array($listing)) { foreach ($listing as $folderitem) { if ($folderitem->filename == $aRow['APP_DOC_UID']) { $aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE'); $aFields['DOWNLOAD_LINK'] = $folderitem->downloadScript; continue; } } } if ($lastVersion == $aRow['DOC_VERSION']) { //Show only last version $aInputDocuments[] = $aFields; } $oDataset->next(); } $oAppDocument = new AppDocument(); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, array('ATTACHED'), Criteria::IN); $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), Criteria::IN); $oCriteria->add( $oCriteria->getNewCriterion( AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], Criteria::IN )-> addOr($oCriteria->getNewCriterion(AppDocumentPeer::USR_UID, array($sUserUID, '-1'), Criteria::IN))); $aConditions = array(); $aConditions[] = array(AppDocumentPeer::APP_UID, AppDelegationPeer::APP_UID); $aConditions[] = array(AppDocumentPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(AppDelegationPeer::PRO_UID, $sProcessUID); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria2->add(AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oTask = new Task(); if ($oTask->taskExists($aRow2['TAS_UID'])) { $aTask = $oTask->load($aRow2['TAS_UID']); } else { $aTask = array('TAS_TITLE' => '(TASK DELETED)'); } $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']); $lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID); try { $aAux1 = $oUser->load($aAux['USR_UID']); $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]); } catch (Exception $oException) { $sUser = '******'; } $aFields = array( 'APP_DOC_UID' => $aAux['APP_DOC_UID'], 'DOC_UID' => $aAux['DOC_UID'], 'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'], 'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'], 'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'], 'TYPE' => $aAux['APP_DOC_TYPE'], 'ORIGIN' => $aTask['TAS_TITLE'], 'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'], 'CREATED_BY' => $sUser ); if ($aFields['APP_DOC_FILENAME'] != '') { $aFields['TITLE'] = $aFields['APP_DOC_FILENAME']; } else { $aFields['TITLE'] = $aFields['APP_DOC_COMMENT']; } $aFields['POSITION'] = $_SESSION['STEP_POSITION']; $aFields['CONFIRM'] = G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT'); if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) { $aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE'); } $aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD'); $aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID']; if ($lastVersion == $aRow['DOC_VERSION']) { //Show only last version $aInputDocuments[] = $aFields; } $oDataset->next(); } // Get input documents added/modified by a supervisor - Begin $oAppDocument = new AppDocument(); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, array('INPUT'), Criteria::IN); $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), Criteria::IN); $oCriteria->add(AppDocumentPeer::DEL_INDEX, 100000); $oCriteria->addJoin(AppDocumentPeer::APP_UID, ApplicationPeer::APP_UID, Criteria::LEFT_JOIN); $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $oUser = new Users(); while ($aRow = $oDataset->getRow()) { $aTask = array('TAS_TITLE' => '[ ' . G::LoadTranslation('ID_SUPERVISOR') . ' ]'); $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']); $lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID); try { $aAux1 = $oUser->load($aAux['USR_UID']); $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]); } catch (Exception $oException) { $sUser = '******'; } $aFields = array( 'APP_DOC_UID' => $aAux['APP_DOC_UID'], 'DOC_UID' => $aAux['DOC_UID'], 'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'], 'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'], 'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'], 'TYPE' => $aAux['APP_DOC_TYPE'], 'ORIGIN' => $aTask['TAS_TITLE'], 'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'], 'CREATED_BY' => $sUser ); if ($aFields['APP_DOC_FILENAME'] != '') { $aFields['TITLE'] = $aFields['APP_DOC_FILENAME']; } else { $aFields['TITLE'] = $aFields['APP_DOC_COMMENT']; } $aFields['POSITION'] = $_SESSION['STEP_POSITION']; $aFields['CONFIRM'] = G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT'); if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) { $aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE'); } $aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD'); $aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION']; $aFields['DOC_VERSION'] = $aRow['DOC_VERSION']; if (is_array($listing)) { foreach ($listing as $folderitem) { if ($folderitem->filename == $aRow['APP_DOC_UID']) { $aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE'); $aFields['DOWNLOAD_LINK'] = $folderitem->downloadScript; continue; } } } if ($lastVersion == $aRow['DOC_VERSION']) { //Show only last version $aInputDocuments[] = $aFields; } $oDataset->next(); } // Get input documents added/modified by a supervisor - End global $_DBArray; $_DBArray['inputDocuments'] = $aInputDocuments; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('inputDocuments'); $oCriteria->addDescendingOrderByColumn('CREATE_DATE'); return $oCriteria; }
/** * Delete OutputDocument * * @param string $applicationDocumentUid * */ public function removeOutputDocument($applicationDocumentUid) { try { $oAppDocumentVersion = new \AppDocument(); $lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid); $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid))); } $aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED'); $oAppDocument->update( $aFields ); } catch (\Exception $e) { throw $e; } }
public function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId) { //require_once ("classes/model/AppDocument.php"); //require_once ("classes/model/InputDocument.php"); //require_once ("classes/model/OutputDocument.php"); //require_once ("classes/model/Users.php"); //**** start get Doc Info $oApp = new Application(); $oAppDocument = new AppDocument(); G::LoadClass( 'case' ); $oCase = new Cases(); G::LoadClass( 'process' ); $oProcess = new Process(); if (($oApp->exists( $appUid )) || ($appUid == "00000000000000000000000000000000")) { if ($appUid == "00000000000000000000000000000000") { //External Files $row1 = $oAppDocument->load( $appDocUid, $docVersion ); $row2 = array ('PRO_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); $row3 = array ('APP_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); } else { $row1 = $oAppDocument->load( $appDocUid, $docVersion ); $row2 = $oCase->loadCase( $appUid ); $row3 = $oProcess->Load( $row2['PRO_UID'] ); } $lastVersion = $oAppDocument->getLastAppDocVersion( $appDocUid, $appUid ); switch ($row1['APP_DOC_TYPE']) { case "OUTPUT": $oOutputDocument = new OutputDocument(); $row4 = array(); $swOutDocExists = 0; if ($oOutputDocument->OutputExists($docUid)) { $row4 = $oOutputDocument->load($docUid); $swOutDocExists = 1; } if ($swOutDocExists == 0) { $swpdf = 0; $swdoc = 0; $info = pathinfo($oAppDocument->getAppDocFilename()); $version = (!empty($docVersion))? "_" . $docVersion : "_1"; $outDocPath = PATH_DOCUMENT . G::getPathFromUID($row1["APP_UID"]) . PATH_SEP . "outdocs" . PATH_SEP; if (file_exists($outDocPath . $appDocUid . $version . ".pdf") || file_exists($outDocPath . $info["basename"] . $version . ".pdf") || file_exists($outDocPath . $info["basename"] . ".pdf") ) { $swpdf = 1; } if (file_exists($outDocPath . $appDocUid . $version . ".doc") || file_exists($outDocPath . $info["basename"] . $version . ".doc") || file_exists($outDocPath . $info["basename"] . ".doc") ) { $swdoc = 1; } if ($swpdf == 1 && $swdoc == 1) { $row4["OUT_DOC_GENERATE"] = "BOTH"; } else { if ($swpdf == 1) { $row4["OUT_DOC_GENERATE"] = "PDF"; } else { if ($swdoc == 1) { $row4["OUT_DOC_GENERATE"] = "DOC"; } else { $row4["OUT_DOC_GENERATE"] = "NOFILE"; } } } } $versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs. switch ($row4['OUT_DOC_GENERATE']) { case "PDF": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); $downloadLink1 = ""; $downloadLabel = ".pdf"; $downloadLabel1 = ""; break; case "DOC": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); $downloadLink1 = ""; $downloadLabel = ".doc"; $downloadLabel1 = ""; break; case "BOTH": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); $downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); $downloadLabel = ".pdf"; $downloadLabel1 = ".doc"; break; case "NOFILE": $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation("ID_DOWNLOAD"); $downloadLabel1 = ""; break; } if ($swOutDocExists == 0) { $row4 = array(); } break; case "INPUT": $oInputDocument = new InputDocument(); if ($docUid != - 1) { if ($oInputDocument->InputExists( $docUid )) { $row4 = $oInputDocument->load( $docUid ); $versioningEnabled = $row4['INP_DOC_VERSIONING']; } else { $row4 = array (); $versioningEnabled = false; } $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; } else { $row4 = array (); $versioningEnabled = false; $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; } if (! empty( $row1["APP_DOC_PLUGIN"] )) { $pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginName = $row1["APP_DOC_PLUGIN"]; $fieldValue = ""; if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) { $pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" ); if ($pluginDetail) { if ($pluginDetail->enabled) { require_once (PATH_PLUGINS . $pluginName . ".php"); $pluginNameClass = $pluginName . "Plugin"; $objPluginClass = new $pluginNameClass( $pluginName ); if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) { if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) { require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php"); $pluginNameClass = $pluginName . "Class"; $objClass = new $pluginNameClass(); if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) { eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" ); $downloadLink = $url; $fieldValue = $row1["APP_DOC_PLUGIN"]; } } } } } } $row1["APP_DOC_PLUGIN"] = $fieldValue; } break; default: $row4 = array (); $versioningEnabled = false; $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; break; } $oUser = new Users(); if (($usrId != "-1") && ($oUser->userExists( $usrId ))) { $row5 = $oUser->load( $usrId ); } else { $row5['USR_USERNAME'] = "******"; } //Labels/Links $row6 = array (); $row6['DELETE_LABEL'] = G::LoadTranslation( 'ID_DELETE' ); $row6['DOWNLOAD_LABEL'] = $downloadLabel; $row6['DOWNLOAD_LINK'] = $downloadLink; $row6['DOWNLOAD_LABEL1'] = $downloadLabel1; $row6['DOWNLOAD_LINK1'] = $downloadLink1; //if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){ if (($docVersion > 1)) { $row6['VERSIONHISTORY_LABEL'] = G::LoadTranslation( 'ID_VERSION_HISTORY' ); } if ($versioningEnabled) { $row6['NEWVERSION_LABEL'] = G::LoadTranslation( 'ID_NEW_VERSION' ); } $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion; if ($appUid == "00000000000000000000000000000000") { //External Files $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' ); } //**** End get docinfo $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 ); $sUserUID = $_SESSION['USER_LOGGED']; $aObjectPermissions = array (); if (isset( $infoMerged['PRO_UID'] )) { $aObjectPermissions = $oCase->getAllObjects( $infoMerged['PRO_UID'], $infoMerged['APP_UID'], '', $sUserUID ); } if (! is_array( $aObjectPermissions )) { $aObjectPermissions = array ('DYNAFORMS' => array (- 1), 'INPUT_DOCUMENTS' => array (- 1), 'OUTPUT_DOCUMENTS' => array (- 1) ); } if (! isset( $aObjectPermissions['DYNAFORMS'] )) { $aObjectPermissions['DYNAFORMS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['DYNAFORMS'] )) { $aObjectPermissions['DYNAFORMS'] = array (- 1); } } if (! isset( $aObjectPermissions['INPUT_DOCUMENTS'] )) { $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['INPUT_DOCUMENTS'] )) { $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); } } if (! isset( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); } } return array_merge( $infoMerged, $aObjectPermissions ); } }
/** * Download files and resize dimensions in file type image * if not type image return content file * * return array Return an array with Task Case */ public function downloadFile($app_uid, $request_data) { try { $oAppDocument = new \AppDocument(); $arrayFiles = array(); foreach ($request_data as $key => $fileData) { if (! isset( $fileData['version'] )) { //Load last version of the document $docVersion = $oAppDocument->getLastAppDocVersion( $fileData['fileId'] ); } else { $docVersion = $fileData['version']; } $oAppDocument->Fields = $oAppDocument->load( $fileData['fileId'], $docVersion ); $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo( $oAppDocument->getAppDocFilename() ); $ext = (isset($info['extension'])?$info['extension']:'');//BUG fix: must handle files without any extension //$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']); $file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid); $realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext; $realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext; $width = isset($fileData['width']) ? $fileData['width']:null; $height = isset($fileData['height']) ? $fileData['height']:null; if (file_exists( $realPath )) { switch($ext){ case 'jpg': case 'jpeg': case 'gif': case 'png': $arrayFiles[$key]['fileId'] = $fileData['fileId']; $arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext, $width, $height)); break; default: $fileTmp = fopen($realPath, "r"); $content = fread($fileTmp, filesize($realPath)); $arrayFiles[$key]['fileId'] = $fileData['fileId']; $arrayFiles[$key]['fileContent'] = base64_encode($content); fclose($fileTmp); break; } } elseif (file_exists( $realPath1 )) { switch($ext){ case 'jpg': case 'jpeg': case 'gif': case 'png': $arrayFiles[$key]['fileId'] = $fileData['fileId']; $arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width, $height); break; default: $fileTmp = fopen($realPath, "r"); $content = fread($fileTmp, filesize($realPath)); $arrayFiles[$key]['fileId'] = $fileData['fileId']; $arrayFiles[$key]['fileContent'] = base64_encode($content); fclose($fileTmp); break; } } } } catch (\Exception $e) { throw $e; } return $arrayFiles; }
<?php $actionAjax = isset($_REQUEST['actionAjax']) ? $_REQUEST['actionAjax'] : null; if ($actionAjax == "streaming") { $app_uid = isset($_REQUEST['a']) ? $_REQUEST['a'] : null; $inp_doc_uid = isset($_REQUEST['d']) ? $_REQUEST['d'] : null; $oAppDocument = new \AppDocument(); if (!isset($fileData['version'])) { $docVersion = $oAppDocument->getLastAppDocVersion($inp_doc_uid); } else { $docVersion = $fileData['version']; } $oAppDocument->Fields = $oAppDocument->load($inp_doc_uid, $docVersion); $sAppDocUid = $oAppDocument->getAppDocUid(); $iDocVersion = $oAppDocument->getDocVersion(); $info = pathinfo($oAppDocument->getAppDocFilename()); $ext = isset($info['extension']) ? $info['extension'] : ''; $file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid); $realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext; $realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext; if (file_exists($realPath)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($finfo, $realPath); finfo_close($finfo); if ($ext == "mp3") { $mimeType = "audio/mpeg"; } rangeDownload($realPath, $mimeType); } elseif (file_exists($realPath1)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($finfo, $realPath1);