diff --git a/workflow/engine/classes/model/AppFolder.php b/workflow/engine/classes/model/AppFolder.php index b5e70efa6..11299b741 100755 --- a/workflow/engine/classes/model/AppFolder.php +++ b/workflow/engine/classes/model/AppFolder.php @@ -1,543 +1,557 @@ -|number - */ - function createFolder($folderName, $folderParent = "/", $action="createifnotexists") { - $validActions=array("createifnotexists","create","update"); - if(!in_array($action,$validActions)) $action="createifnotexists"; - //Clean Folder and Parent names (delete spaces...) - $folderName=trim($folderName); - $folderParent=trim($folderParent); - //Try to Load the folder (Foldername+FolderParent) - $oCriteria = new Criteria ( 'workflow' ); - $oCriteria->add ( AppFolderPeer::FOLDER_NAME, $folderName ); - $oCriteria->add ( AppFolderPeer::FOLDER_PARENT_UID, $folderParent ); - $oDataset = AppFolderPeer::doSelectRS ( $oCriteria ); - $oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next (); - if ($aRow = $oDataset->getRow ()) {//Folder exist, then return the ID - $response['success']=false; - $response['message']=$response['error']="Can't create folder A folder with same name already exist. $folderName"; - $response['folderUID']=$aRow ['FOLDER_UID']; - //return ($aRow ['FOLDER_UID']); - return ($response); - } else {//Folder doesn't exist. Create and return the ID - $folderUID = G::GenerateUniqueID (); - $tr = new AppFolder ( ); - $tr->setFolderUid ( $folderUID ); - $tr->setFolderParentUid ( $folderParent ); - $tr->setFolderName ( $folderName ); - $tr->setFolderCreateDate ( 'now' ); - $tr->setFolderUpdateDate ( 'now' ); - if ($tr->validate ()) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save (); - $response['success']=true; - $response['message']="Folder successfully created. $folderName"; - $response['folderUID']=$folderUID; - return ($response); - //return $folderUID; - } else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures (); - foreach ( $validationFailuresArray as $objValidationFailure ) { - $msg .= $objValidationFailure->getMessage () . ""; - } - $response['success']=false; - - $response['message']=$response['error']="Can't create folder \n A \n ".$msg; - return ($response); - } - } - } - /** - * @param string $folderPath - * @param strin(32) $sessionID - * @return string Last Folder ID generated - */ - function createFromPath($folderPath, $sessionID = "") { - if ($sessionID == "") - $sessionID = $_SESSION ['APPLICATION']; - //Get current Application Fields - $oApplication = new Application ( ); - - $appFields = $oApplication->Load ( $sessionID ); - - $folderPathParsed = G::replaceDataField ( $folderPath, $appFields ); - $folderPathParsed = G::replaceDataField ( $folderPath, unserialize ( $appFields ['APP_DATA'] ) ); - - $folderPathParsedArray = explode ( "/", $folderPathParsed ); - - $folderRoot = "/"; //Always starting from Root - foreach ( $folderPathParsedArray as $folderName ) { - if (trim ( $folderName ) != "") { - $response = $this->createFolder ( $folderName, $folderRoot ); - $folderRoot=$response['folderUID']; - } - } - return $folderRoot != "/" ? $folderRoot : ""; - } - - /** - * @param string $fileTags - * @param string(32) $sessionID Application ID - * @return string - */ - function parseTags($fileTags, $sessionID = "") { - - if ($sessionID == "") - $sessionID = $_SESSION ['APPLICATION']; - //Get current Application Fields - $oApplication = new Application ( ); - - $appFields = $oApplication->Load ( $sessionID ); - - $fileTagsParsed = G::replaceDataField ( $fileTags, $appFields ); - $fileTagsParsed = G::replaceDataField ( $fileTags, unserialize ( $appFields ['APP_DATA'] ) ); - - return $fileTagsParsed; - } - /** - * @param string(32) $folderID - * @return multitype: - */ - function getFolderList($folderID, $limit=0, $start=0) { - $Criteria = new Criteria ( 'workflow' ); - $Criteria->clearSelectColumns ()->clearOrderByColumns (); - - $Criteria->addSelectColumn ( AppFolderPeer::FOLDER_UID ); - $Criteria->addSelectColumn ( AppFolderPeer::FOLDER_PARENT_UID ); - $Criteria->addSelectColumn ( AppFolderPeer::FOLDER_NAME ); - $Criteria->addSelectColumn ( AppFolderPeer::FOLDER_CREATE_DATE ); - $Criteria->addSelectColumn ( AppFolderPeer::FOLDER_UPDATE_DATE ); - - $Criteria->add ( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL ); - - $Criteria->addAscendingOrderByColumn ( AppFolderPeer::FOLDER_NAME ); - - $response['totalFoldersCount'] = AppFolderPeer::doCount($Criteria); - $response['folders'] = array(); - -if($limit != 0){ - - $Criteria->setLimit($limit); - $Criteria->setOffset($start); -} - $rs = appFolderPeer::doSelectRS ( $Criteria ); - $rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $rs->next (); - $folderResult = array (); - while ( is_array ( $row = $rs->getRow () ) ) { - $response['folders'] [] = $row; - $rs->next (); - } - return ($response); - } - /** - * @param string(32) $folderUid - * @return array - */ - function load($folderUid) { - $tr = AppFolderPeer::retrieveByPK ( $folderUid ); - if ((is_object ( $tr ) && get_class ( $tr ) == 'AppFolder')) { - $fields ['FOLDER_UID'] = $tr->getFolderUid (); - $fields ['FOLDER_PARENT_UID'] = $tr->getFolderParentUid (); - $fields ['FOLDER_NAME'] = $tr->getFolderName (); - $fields ['FOLDER_CREATE_DATE'] = $tr->getFolderCreateDate (); - $fields ['FOLDER_UPDATE_DATE'] = $tr->getFolderUpdateDate (); - } elseif ($folderUid == "/") { - $fields ['FOLDER_UID'] = "/"; - $fields ['FOLDER_PARENT_UID'] = ""; - $fields ['FOLDER_NAME'] = "/"; - $fields ['FOLDER_CREATE_DATE'] = ""; - $fields ['FOLDER_UPDATE_DATE'] = ""; - } else { -// $fields = array (); - $fields ['FOLDER_UID'] = "/"; - $fields ['FOLDER_PARENT_UID'] = ""; - $fields ['FOLDER_NAME'] = "root"; - $fields ['FOLDER_CREATE_DATE'] = ""; - $fields ['FOLDER_UPDATE_DATE'] = ""; - } - return $fields; - } - function getFolderStructure($folderId) { - - $folderObj = $this->load ( $folderId ); - $folderArray [$folderObj ['FOLDER_UID']] = array ("NAME" => $folderObj ['FOLDER_NAME'], "PARENT" => $folderObj ['FOLDER_PARENT_UID'] ); - $folderArray ['PATH_ARRAY'] [] = $folderObj ['FOLDER_NAME']; - - while ( $folderObj ['FOLDER_PARENT_UID'] != "" ) { - $folderObj = $this->load ( $folderObj ['FOLDER_PARENT_UID'] ); - $folderArray [$folderObj ['FOLDER_UID']] = array ("NAME" => $folderObj ['FOLDER_NAME'], "PARENT" => $folderObj ['FOLDER_PARENT_UID'] ); - $folderArray ['PATH_ARRAY'] [] = $folderObj ['FOLDER_NAME']; - } - - $folderArray ['PATH'] = str_replace ( "//", "/", implode ( "/", array_reverse ( $folderArray ['PATH_ARRAY'] ) ) ); - return $folderArray; - } - - function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL, $limit=0, $start=0, $user='', $onlyActive=false) { - require_once ("classes/model/AppDocument.php"); - require_once ("classes/model/InputDocument.php"); - require_once ("classes/model/OutputDocument.php"); - require_once ("classes/model/Users.php"); - - G::LoadClass ( 'case' ); - $oCase = new Cases ( ); - G::LoadClass ( 'process' ); - $oProcess = new Process ( ); - - $oAppDocument = new AppDocument ( ); - $oCriteria = new Criteria ( ); - - if ((is_array ( $docIdFilter )) && (count ( $docIdFilter ) > 0)) { //Search by App Doc UID no matter what Folder it is - $oCriteria->add ( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); - } elseif ($folderID != NULL) { - if($folderID=="/"){ - $oCriteria->add ( AppDocumentPeer::FOLDER_UID, array('root','',NULL), CRITERIA::IN ); - }else{ - $oCriteria->add ( AppDocumentPeer::FOLDER_UID, $folderID ); - } - } elseif ($searchType == "TAG") { - $oCriteria->add ( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE ); - } - - if ($user != '') { - require_once ("classes/model/AppDelegation.php"); - $criteria = new Criteria (); - $criteria->addSelectColumn (AppDelegationPeer::APP_UID); - $criteria->setDistinct(); - - $conditions = array (); - $conditions [] = array (AppDelegationPeer::APP_UID, AppDocumentPeer::APP_UID); - $conditions [] = array (AppDelegationPeer::DEL_INDEX, AppDocumentPeer::DEL_INDEX); - - $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN); - - $criteria->add(AppDelegationPeer::USR_UID, $user); - - $rs2 = AppDocumentPeer::doSelectRS($criteria); - - $rs2->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $data = array(); - while ($rs2->next()) { - $row = $rs2->getRow(); - $data[] = $row['APP_UID']; - } - $oCriteria->add ( AppDocumentPeer::APP_UID, $data, CRITERIA::IN ); - } - if ($onlyActive){ - $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE'); - } - - $oCase->verifyTable (); - - - $oCriteria->addAscendingOrderByColumn ( AppDocumentPeer::APP_DOC_INDEX ); - $oCriteria->addDescendingOrderByColumn ( AppDocumentPeer::DOC_VERSION ); - - - $response['totalDocumentsCount'] = AppDocumentPeer::doCount($oCriteria); - $response['documents'] = array(); - - - - $oCriteria->setLimit($limit); - $oCriteria->setOffset($start); - - - $rs = AppDocumentPeer::doSelectRS ( $oCriteria ); - $rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $rs->next (); - $filesResult = array (); - while ( is_array ( $row = $rs->getRow () ) ) { - //**** start get Doc Info - $oApp = new Application ( ); - if (($oApp->exists ( $row ['APP_UID'] )) || ($row ['APP_UID'] == "00000000000000000000000000000000")) { - - //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); - $completeInfo = $this->getCompleteDocumentInfo ( $row ['APP_UID'], $row ['APP_DOC_UID'], $row ['DOC_VERSION'], $row ['DOC_UID'], $row ['USR_UID'] ); - - $oAppDocument = new AppDocument ( ); - $lastVersion = $oAppDocument->getLastAppDocVersion ( $row ['APP_DOC_UID'], $row ['APP_UID'] ); - //$filesResult [] = $completeInfo; - if ($completeInfo ['APP_DOC_STATUS'] != "DELETED") { - if ((in_array ( $row ['APP_DOC_UID'], $completeInfo ['INPUT_DOCUMENTS'] )) || (in_array ( $row ['APP_DOC_UID'], $completeInfo ['OUTPUT_DOCUMENTS'] )) || (in_array ( $completeInfo ['USR_UID'], array ($_SESSION ['USER_LOGGED'], '-1' ) ))) { - if (count ( $docIdFilter ) > 0) { - if (in_array ( $row ['APP_DOC_UID'], $docIdFilter )) { - $response['documents'][] = $completeInfo; - } - } elseif ($lastVersion == $row ['DOC_VERSION']) { //Only Last Document version - if ($searchType == "ALL") {// If search in name of docs is active then filter - if ((stripos ( $completeInfo ['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos ( $completeInfo ['APP_DOC_TAGS'], $keyword ) !== false)) { - $response['documents'][] = $completeInfo; - } - } else {//No search filter active - $response['documents'][] = $completeInfo; - } - } - - } - } - } - $rs->next (); - } - return ($response); - } - 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 = $oOutputDocument->load ( $docUid ); - $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; - } - - 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 ); - //krumo($infoMerged); - //**************************************************************************************************** - $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 ); - } - } - function getFolderChilds($folderID, $folderArray) { - $folderList = $this->getFolderList ( $folderID ); - $foldersList = array (); - foreach ( $folderList as $key => $folderObj ) { - $foldersList [$folderObj ['FOLDER_UID']] = $folderObj ['FOLDER_NAME']; - $foldersList = array_merge ( $foldersList, $this->getFolderChilds ( $folderObj ['FOLDER_UID'], $folderArray ) ); - } - return (array_merge ( $folderArray, $foldersList )); - } - - function getFolderTags($rootFolder) { - $folderArray [$rootFolder] = $rootFolder; - $foldersToProcess = $this->getFolderChilds ( $rootFolder, $folderArray ); - $tagsInfo = array (); - - foreach ( $foldersToProcess as $folderkey => $foldername ) { - $filesList = $this->getFolderContent ( $folderkey ); - - foreach ( $filesList as $key => $fileInfo ) { - $fileTags = explode ( ",", $fileInfo ['APP_DOC_TAGS'] ); - foreach ( $fileTags as $key1 => $tag ) { - if (! (isset ( $tagsInfo [$tag] ))) - $tagsInfo [$tag] = 0; - $tagsInfo [$tag] ++; - } - } - } - return $tagsInfo; - - } - function remove ($FolderUid, $rootfolder ) { - $oCriteria = new Criteria('workflow'); - $oCriteria->add ( AppFolderPeer::FOLDER_UID, $FolderUid ); - AppFolderPeer::doDelete($oCriteria); - } -} // AppFolder +|number + */ + function createFolder ($folderName, $folderParent = "/", $action = "createifnotexists") + { + $validActions = array ("createifnotexists","create","update" + ); + if (! in_array( $action, $validActions )) { + $action = "createifnotexists"; + } + + //Clean Folder and Parent names (delete spaces...) + $folderName = trim( $folderName ); + $folderParent = trim( $folderParent ); + //Try to Load the folder (Foldername+FolderParent) + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppFolderPeer::FOLDER_NAME, $folderName ); + $oCriteria->add( AppFolderPeer::FOLDER_PARENT_UID, $folderParent ); + $oDataset = AppFolderPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + if ($aRow = $oDataset->getRow()) { + //Folder exist, then return the ID + $response['success'] = false; + $response['message'] = $response['error'] = "Can't create folder A folder with same name already exist. $folderName"; + $response['folderUID'] = $aRow['FOLDER_UID']; + //return ($aRow ['FOLDER_UID']); + return ($response); + } else { + //Folder doesn't exist. Create and return the ID + $folderUID = G::GenerateUniqueID(); + $tr = new AppFolder(); + $tr->setFolderUid( $folderUID ); + $tr->setFolderParentUid( $folderParent ); + $tr->setFolderName( $folderName ); + $tr->setFolderCreateDate( 'now' ); + $tr->setFolderUpdateDate( 'now' ); + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + $response['success'] = true; + $response['message'] = "Folder successfully created. $folderName"; + $response['folderUID'] = $folderUID; + return ($response); + //return $folderUID; + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . ""; + } + $response['success'] = false; + $response['message'] = $response['error'] = "Can't create folder \n A \n " . $msg; + return ($response); + } + } + } + + /** + * + * @param string $folderPath + * @param strin(32) $sessionID + * @return string Last Folder ID generated + */ + function createFromPath ($folderPath, $sessionID = "") + { + if ($sessionID == "") { + $sessionID = $_SESSION['APPLICATION']; + //Get current Application Fields + } + + $oApplication = new Application(); + $appFields = $oApplication->Load( $sessionID ); + $folderPathParsed = G::replaceDataField( $folderPath, $appFields ); + $folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) ); + $folderPathParsedArray = explode( "/", $folderPathParsed ); + $folderRoot = "/"; //Always starting from Root + foreach ($folderPathParsedArray as $folderName) { + if (trim( $folderName ) != "") { + $response = $this->createFolder( $folderName, $folderRoot ); + $folderRoot = $response['folderUID']; + } + } + return $folderRoot != "/" ? $folderRoot : ""; + } + + /** + * + * @param string $fileTags + * @param string(32) $sessionID Application ID + * @return string + */ + function parseTags ($fileTags, $sessionID = "") + { + + if ($sessionID == "") { + $sessionID = $_SESSION['APPLICATION']; + //Get current Application Fields + } + + $oApplication = new Application(); + $appFields = $oApplication->Load( $sessionID ); + $fileTagsParsed = G::replaceDataField( $fileTags, $appFields ); + $fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) ); + return $fileTagsParsed; + } + + /** + * + * @param string(32) $folderID + * @return multitype: + */ + function getFolderList ($folderID, $limit = 0, $start = 0) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns()->clearOrderByColumns(); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UID ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_PARENT_UID ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_NAME ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_CREATE_DATE ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UPDATE_DATE ); + $Criteria->add( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL ); + $Criteria->addAscendingOrderByColumn( AppFolderPeer::FOLDER_NAME ); + + $response['totalFoldersCount'] = AppFolderPeer::doCount( $Criteria ); + $response['folders'] = array (); + + if ($limit != 0) { + $Criteria->setLimit( $limit ); + $Criteria->setOffset( $start ); + } + + $rs = appFolderPeer::doSelectRS( $Criteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + $folderResult = array (); + while (is_array( $row = $rs->getRow() )) { + $response['folders'][] = $row; + $rs->next(); + } + return ($response); + } + + /** + * + * @param string(32) $folderUid + * @return array + */ + function load ($folderUid) + { + $tr = AppFolderPeer::retrieveByPK( $folderUid ); + if ((is_object( $tr ) && get_class( $tr ) == 'AppFolder')) { + $fields['FOLDER_UID'] = $tr->getFolderUid(); + $fields['FOLDER_PARENT_UID'] = $tr->getFolderParentUid(); + $fields['FOLDER_NAME'] = $tr->getFolderName(); + $fields['FOLDER_CREATE_DATE'] = $tr->getFolderCreateDate(); + $fields['FOLDER_UPDATE_DATE'] = $tr->getFolderUpdateDate(); + } elseif ($folderUid == "/") { + $fields['FOLDER_UID'] = "/"; + $fields['FOLDER_PARENT_UID'] = ""; + $fields['FOLDER_NAME'] = "/"; + $fields['FOLDER_CREATE_DATE'] = ""; + $fields['FOLDER_UPDATE_DATE'] = ""; + } else { + // $fields = array (); + $fields['FOLDER_UID'] = "/"; + $fields['FOLDER_PARENT_UID'] = ""; + $fields['FOLDER_NAME'] = "root"; + $fields['FOLDER_CREATE_DATE'] = ""; + $fields['FOLDER_UPDATE_DATE'] = ""; + } + return $fields; + } + + function getFolderStructure ($folderId) + { + $folderObj = $this->load( $folderId ); + $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID'] + ); + $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; + + while ($folderObj['FOLDER_PARENT_UID'] != "") { + $folderObj = $this->load( $folderObj['FOLDER_PARENT_UID'] ); + $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID']); + $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; + } + + $folderArray['PATH'] = str_replace( "//", "/", implode( "/", array_reverse( $folderArray['PATH_ARRAY'] ) ) ); + return $folderArray; + } + + function getFolderContent ($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false) + { + require_once ("classes/model/AppDocument.php"); + require_once ("classes/model/InputDocument.php"); + require_once ("classes/model/OutputDocument.php"); + require_once ("classes/model/Users.php"); + + G::LoadClass( 'case' ); + $oCase = new Cases(); + G::LoadClass( 'process' ); + $oProcess = new Process(); + + $oAppDocument = new AppDocument(); + $oCriteria = new Criteria(); + + if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) { + //Search by App Doc UID no matter what Folder it is + $oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); + } elseif ($folderID != null) { + if ($folderID == "/") { + $oCriteria->add( AppDocumentPeer::FOLDER_UID, array ('root','',null), CRITERIA::IN ); + } else { + $oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID ); + } + } elseif ($searchType == "TAG") { + $oCriteria->add( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE ); + } + + if ($user != '') { + require_once ("classes/model/AppDelegation.php"); + $criteria = new Criteria(); + $criteria->addSelectColumn( AppDelegationPeer::APP_UID ); + $criteria->setDistinct(); + + $conditions = array (); + $conditions[] = array (AppDelegationPeer::APP_UID,AppDocumentPeer::APP_UID); + $conditions[] = array (AppDelegationPeer::DEL_INDEX,AppDocumentPeer::DEL_INDEX); + + $criteria->addJoinMC( $conditions, Criteria::LEFT_JOIN ); + + $criteria->add( AppDelegationPeer::USR_UID, $user ); + + $rs2 = AppDocumentPeer::doSelectRS( $criteria ); + + $rs2->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $data = array (); + while ($rs2->next()) { + $row = $rs2->getRow(); + $data[] = $row['APP_UID']; + } + $oCriteria->add( AppDocumentPeer::APP_UID, $data, CRITERIA::IN ); + } + if ($onlyActive) { + $oCriteria->add( AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE' ); + } + + $oCase->verifyTable(); + + $oCriteria->addAscendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX ); + $oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION ); + + $response['totalDocumentsCount'] = AppDocumentPeer::doCount( $oCriteria ); + $response['documents'] = array (); + + $oCriteria->setLimit( $limit ); + $oCriteria->setOffset( $start ); + + $rs = AppDocumentPeer::doSelectRS( $oCriteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + $filesResult = array (); + while (is_array( $row = $rs->getRow() )) { + //**** start get Doc Info + $oApp = new Application(); + if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) { + //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); + $completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] ); + $oAppDocument = new AppDocument(); + $lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] ); + //$filesResult [] = $completeInfo; + if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { + if ((in_array( $row['APP_DOC_UID'], $completeInfo['INPUT_DOCUMENTS'] )) || (in_array( $row['APP_DOC_UID'], $completeInfo['OUTPUT_DOCUMENTS'] )) || (in_array( $completeInfo['USR_UID'], array ($_SESSION['USER_LOGGED'],'-1') ))) { + if (count( $docIdFilter ) > 0) { + if (in_array( $row['APP_DOC_UID'], $docIdFilter )) { + $response['documents'][] = $completeInfo; + } + } elseif ($lastVersion == $row['DOC_VERSION']) { + //Only Last Document version + if ($searchType == "ALL") { // If search in name of docs is active then filter + if ((stripos( $completeInfo['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos( $completeInfo['APP_DOC_TAGS'], $keyword ) !== false)) { + $response['documents'][] = $completeInfo; + } + } else { + //No search filter active + $response['documents'][] = $completeInfo; + } + } + } + } + } + $rs->next(); + } + return ($response); + } + + 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 = $oOutputDocument->load( $docUid ); + $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; + } + + 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 ); + //krumo($infoMerged); + //**************************************************************************************************** + $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 ); + } + } + + function getFolderChilds ($folderID, $folderArray) + { + $folderList = $this->getFolderList( $folderID ); + $foldersList = array (); + foreach ($folderList as $key => $folderObj) { + $foldersList[$folderObj['FOLDER_UID']] = $folderObj['FOLDER_NAME']; + $foldersList = array_merge( $foldersList, $this->getFolderChilds( $folderObj['FOLDER_UID'], $folderArray ) ); + } + return (array_merge( $folderArray, $foldersList )); + } + + function getFolderTags ($rootFolder) + { + $folderArray[$rootFolder] = $rootFolder; + $foldersToProcess = $this->getFolderChilds( $rootFolder, $folderArray ); + $tagsInfo = array (); + + foreach ($foldersToProcess as $folderkey => $foldername) { + $filesList = $this->getFolderContent( $folderkey ); + + foreach ($filesList as $key => $fileInfo) { + $fileTags = explode( ",", $fileInfo['APP_DOC_TAGS'] ); + foreach ($fileTags as $key1 => $tag) { + if (! (isset( $tagsInfo[$tag] ))) + $tagsInfo[$tag] = 0; + $tagsInfo[$tag] ++; + } + } + } + return $tagsInfo; + + } + + function remove ($FolderUid, $rootfolder) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppFolderPeer::FOLDER_UID, $FolderUid ); + AppFolderPeer::doDelete( $oCriteria ); + } +} +// AppFolder + diff --git a/workflow/engine/classes/model/Step.php b/workflow/engine/classes/model/Step.php index ad32da5af..34d080fb8 100755 --- a/workflow/engine/classes/model/Step.php +++ b/workflow/engine/classes/model/Step.php @@ -1,218 +1,209 @@ -. - * - * 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/BaseStep.php'; - - -/** - * Skeleton subclass for representing a row from the 'STEP' 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 Step extends BaseStep { - function create($aData) - { - $con = Propel::getConnection(StepPeer::DATABASE_NAME); - try - { - if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' ) - unset ( $aData['STEP_UID'] ); - if ( isset ( $aData['STEP_UID'] ) ) - $sStepUID = $aData['STEP_UID']; - else - $sStepUID = G::generateUniqueID(); - - $con->begin(); - $this->setStepUid($sStepUID); - $this->setProUid($aData['PRO_UID']); - $this->setTasUid($aData['TAS_UID']); - - if (isset ( $aData['STEP_TYPE_OBJ'] )) - $this->setStepTypeObj( $aData['STEP_TYPE_OBJ'] ); - else - $this->setStepTypeObj("DYNAFORM"); - - if (isset ( $aData['STEP_UID_OBJ'] )) - $this->setStepUidObj( $aData['STEP_UID_OBJ'] ); - else - $this->setStepUidObj(""); - - if (isset ( $aData['STEP_CONDITION'] )) - $this->setStepCondition( $aData['STEP_CONDITION'] ); - else - $this->setStepCondition(""); - - if (isset ( $aData['STEP_POSITION'] )) - $this->setStepPosition( $aData['STEP_POSITION'] ); - else - $this->setStepPosition(""); - - if (isset ( $aData['STEP_MODE'] )) - $this->setStepMode( $aData['STEP_MODE'] ); - else - $this->setStepMode(""); - - if($this->validate()) - { - $result=$this->save(); - $con->commit(); - return $sStepUID; - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - - public function load($StepUid) - { - try { - $oRow = StepPeer::retrieveByPK( $StepUid ); - if (!is_null($oRow)) - { - $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); - $this->setNew(false); - return $aFields; - } - else { - throw( new Exception( "The row '$StepUid' in table StepUid doesn't exist!" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - public function loadByProcessTaskPosition($sProUid, $sTasUid, $sPosition ) - { - try { - $c = new Criteria('workflow'); - $c->add ( StepPeer::PRO_UID, $sProUid ); - $c->add ( StepPeer::TAS_UID, $sTasUid ); - $c->add ( StepPeer::STEP_POSITION, $sPosition ); - if (StepPeer::doCount($c) > 0) { - $rs = StepPeer::doSelect( $c ); - return $rs[0]; - } - else { - return null; - } - - } - catch (Exception $oError) { - throw($oError); - } - } - - /* +. + * + * 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/BaseStep.php'; + +/** + * Skeleton subclass for representing a row from the 'STEP' 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 Step extends BaseStep +{ + + public function create ($aData) + { + $con = Propel::getConnection( StepPeer::DATABASE_NAME ); + try { + if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') { + unset( $aData['STEP_UID'] ); + } + if (isset( $aData['STEP_UID'] )) { + $sStepUID = $aData['STEP_UID']; + } else { + $sStepUID = G::generateUniqueID(); + } + + $con->begin(); + $this->setStepUid( $sStepUID ); + $this->setProUid( $aData['PRO_UID'] ); + $this->setTasUid( $aData['TAS_UID'] ); + + if (isset( $aData['STEP_TYPE_OBJ'] )) { + $this->setStepTypeObj( $aData['STEP_TYPE_OBJ'] ); + } else { + $this->setStepTypeObj( "DYNAFORM" ); + } + + if (isset( $aData['STEP_UID_OBJ'] )) { + $this->setStepUidObj( $aData['STEP_UID_OBJ'] ); + } else { + $this->setStepUidObj( "" ); + } + + if (isset( $aData['STEP_CONDITION'] )) { + $this->setStepCondition( $aData['STEP_CONDITION'] ); + } else { + $this->setStepCondition( "" ); + } + + if (isset( $aData['STEP_POSITION'] )) { + $this->setStepPosition( $aData['STEP_POSITION'] ); + } else { + $this->setStepPosition( "" ); + } + + if (isset( $aData['STEP_MODE'] )) { + $this->setStepMode( $aData['STEP_MODE'] ); + } else { + $this->setStepMode( "" ); + } + + if ($this->validate()) { + $result = $this->save(); + $con->commit(); + return $sStepUID; + } else { + $con->rollback(); + throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); + } + + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function load ($StepUid) + { + try { + $oRow = StepPeer::retrieveByPK( $StepUid ); + if (! is_null( $oRow )) { + $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + $this->setNew( false ); + return $aFields; + } else { + throw (new Exception( "The row '$StepUid' in table StepUid doesn't exist!" )); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + public function loadByProcessTaskPosition ($sProUid, $sTasUid, $sPosition) + { + try { + $c = new Criteria( 'workflow' ); + $c->add( StepPeer::PRO_UID, $sProUid ); + $c->add( StepPeer::TAS_UID, $sTasUid ); + $c->add( StepPeer::STEP_POSITION, $sPosition ); + if (StepPeer::doCount( $c ) > 0) { + $rs = StepPeer::doSelect( $c ); + return $rs[0]; + } else { + return null; + } + + } catch (Exception $oError) { + throw ($oError); + } + } + + /* * Load the step information using the Task UID, the type and the object UID * @param string $sTaskUID * @param string $sType * @param string $sUID * @return variant - */ - public function loadByType($sTasUid, $sType, $sUid ) - { - try { - $c = new Criteria('workflow'); - $c->add ( StepPeer::TAS_UID, $sTasUid ); - $c->add ( StepPeer::STEP_TYPE_OBJ, $sType ); - $c->add ( StepPeer::STEP_UID_OBJ, $sUid ); - $rs = StepPeer::doSelect( $c ); - if (!is_null($rs) && !is_null($rs[0])) - { - return $rs[0]; - } - else { - throw( new Exception( "You tried to call to loadByType method without send the Task UID or Type or Object UID !" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - /* + */ + public function loadByType ($sTasUid, $sType, $sUid) + { + try { + $c = new Criteria( 'workflow' ); + $c->add( StepPeer::TAS_UID, $sTasUid ); + $c->add( StepPeer::STEP_TYPE_OBJ, $sType ); + $c->add( StepPeer::STEP_UID_OBJ, $sUid ); + $rs = StepPeer::doSelect( $c ); + if (! is_null( $rs ) && ! is_null( $rs[0] )) { + return $rs[0]; + } else { + throw (new Exception( "You tried to call to loadByType method without send the Task UID or Type or Object UID !" )); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + /* * update the step information using an array with all values * @param array $fields * @return variant - */ - function update($fields) - { - $con = Propel::getConnection(StepPeer::DATABASE_NAME); - try - { - $con->begin(); - $this->load($fields['STEP_UID']); - $this->fromArray($fields,BasePeer::TYPE_FIELDNAME); - if($this->validate()) - { - $result=$this->save(); - $con->commit(); - return $result; - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - function remove($sStepUID) - { - require_once('classes/model/StepTrigger.php'); - $oStepTriggers = new StepTrigger(); - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepTriggerPeer::STEP_UID , $sStepUID); - $oDataset = StepTriggerPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while($oDataset->next()){ - $aRow = $oDataset->getRow(); - $oStepTriggers->remove($aRow['STEP_UID'], $aRow['TAS_UID'], $aRow['TRI_UID'], $aRow['ST_TYPE']); - } - /*$con = Propel::getConnection(StepPeer::DATABASE_NAME); + */ + public function update ($fields) + { + $con = Propel::getConnection( StepPeer::DATABASE_NAME ); + try { + $con->begin(); + $this->load( $fields['STEP_UID'] ); + $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); + if ($this->validate()) { + $result = $this->save(); + $con->commit(); + return $result; + } else { + $con->rollback(); + throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function remove ($sStepUID) + { + require_once ('classes/model/StepTrigger.php'); + $oStepTriggers = new StepTrigger(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepTriggerPeer::STEP_UID, $sStepUID ); + $oDataset = StepTriggerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + while ($oDataset->next()) { + $aRow = $oDataset->getRow(); + $oStepTriggers->remove( $aRow['STEP_UID'], $aRow['TAS_UID'], $aRow['TRI_UID'], $aRow['ST_TYPE'] ); + } + /*$con = Propel::getConnection(StepPeer::DATABASE_NAME); try { $con->begin(); @@ -226,376 +217,357 @@ class Step extends BaseStep { { $con->rollback(); throw($e); - }*/ - $oConnection = Propel::getConnection(StepPeer::DATABASE_NAME); - try { - $oStep = StepPeer::retrieveByPK($sStepUID); - if (!is_null($oStep)) - { - $oConnection->begin(); - $iResult = $oStep->delete(); - $oConnection->commit(); - return $iResult; - } - else { - throw(new Exception('This row doesn\'t exist!')); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - function getNextPosition($sTaskUID) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION'); - $oCriteria->add(StepPeer::TAS_UID, $sTaskUID); - $oDataset = StepPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - return (int)$aRow['POSITION']; - } - catch (Exception $oException) { - throw $Exception; - } - } - - function reOrder($sStepUID, $iPosition) { - try { - /*$oCriteria1 = new Criteria('workflow'); + }*/ + $oConnection = Propel::getConnection( StepPeer::DATABASE_NAME ); + try { + $oStep = StepPeer::retrieveByPK( $sStepUID ); + if (! is_null( $oStep )) { + $oConnection->begin(); + $iResult = $oStep->delete(); + $oConnection->commit(); + return $iResult; + } else { + throw (new Exception( 'This row doesn\'t exist!' )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + public function getNextPosition ($sTaskUID) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' ); + $oCriteria->add( StepPeer::TAS_UID, $sTaskUID ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + return (int) $aRow['POSITION']; + } catch (Exception $oException) { + throw $Exception; + } + } + + public function reOrder ($sStepUID, $iPosition) + { + try { + /*$oCriteria1 = new Criteria('workflow'); $oCriteria1->add(StepPeer::STEP_POSITION, StepPeer::STEP_POSITION); $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(StepPeer::TAS_UID, $sTaskUID); $oCriteria2->add(StepPeer::STEP_POSITION, $iPosition, '>'); - BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));*/ - $oStep = StepPeer::retrieveByPK($sStepUID); - $sTaskUID = $oStep->getTasUid(); - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepPeer::TAS_UID, $sTaskUID); - $oCriteria->add(StepPeer::STEP_POSITION, $iPosition, '>'); - $oDataset = StepPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oStep = StepPeer::retrieveByPK($aRow['STEP_UID']); - $oStep->setStepPosition(($aRow['STEP_POSITION']) - 1); - $oStep->save(); - $oDataset->next(); - } - } - catch (Exception $oException) { - throw $oException; - } - } - - function up($sStepUID = '', $sTaskUID = '', $iPosition = 0) { - try { - if ($iPosition > 1) { - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->add(StepPeer::STEP_POSITION, $iPosition); - $oCriteria2 = new Criteria('workflow'); - $oCriteria2->add(StepPeer::TAS_UID, $sTaskUID); - $oCriteria2->add(StepPeer::STEP_POSITION, ($iPosition - 1)); - BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow')); - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->add(StepPeer::STEP_POSITION, ($iPosition - 1)); - $oCriteria2 = new Criteria('workflow'); - $oCriteria2->add(StepPeer::STEP_UID, $sStepUID); - BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow')); - } - } - catch (Exception $oException) { - throw $oException; - } - } - - function down($sStepUID = '', $sTaskUID = '', $iPosition = 0) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn('COUNT(*) AS MAX_POSITION'); - $oCriteria->add(StepPeer::TAS_UID, $sTaskUID); - $oDataset = StepPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - if ($iPosition < (int)$aRow['MAX_POSITION']) { - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->add(StepPeer::STEP_POSITION, $iPosition); - $oCriteria2 = new Criteria('workflow'); - $oCriteria2->add(StepPeer::TAS_UID, $sTaskUID); - $oCriteria2->add(StepPeer::STEP_POSITION, ($iPosition + 1)); - BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow')); - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->add(StepPeer::STEP_POSITION, ($iPosition + 1)); - $oCriteria2 = new Criteria('workflow'); - $oCriteria2->add(StepPeer::STEP_UID, $sStepUID); - BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow')); - } - } - catch (Exception $oException) { - throw $oException; - } - } - - function removeStep($sType = '', $sObjUID = '') { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepPeer::STEP_TYPE_OBJ, $sType); - $oCriteria->add(StepPeer::STEP_UID_OBJ, $sObjUID); - $oDataset = StepPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $this->reOrder($aRow['STEP_UID'], $aRow['STEP_POSITION']); - $this->remove($aRow['STEP_UID']); - $oDataset->next(); - } - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * verify if Step row specified in [sUid] exists. - * - * @param string $sUid the uid of the - */ - - function StepExists ( $sUid ) { - $con = Propel::getConnection(StepPeer::DATABASE_NAME); - try { - $oObj = StepPeer::retrieveByPk( $sUid ); - if (is_object($oObj) && get_class ($oObj) == 'Step' ) { - return true; - } - else { - return false; - } - } - catch (Exception $oError) { - throw($oError); - } - } - - /** - * verify if a dynaform is assigned some steps - * - * @param string $sproUid the uid of the process - * @param string $sObjUID the uid of the dynaform - */ - function loadInfoAssigDynaform($sproUid,$sObjUID){ - - require_once ( "classes/model/DynaformPeer.php" ); - G::LoadSystem('dynaformhandler'); - - $oC = new Criteria('workflow'); - $oC->add(DynaformPeer::DYN_UID, $sObjUID); - $oC->add(DynaformPeer::PRO_UID, $sproUid); - $oDataset = DynaformPeer::doSelectRS($oC); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - - - if($aRow['DYN_TYPE']!='xmlform') { - - $oC1 = new Criteria('workflow'); - $oC1->add(DynaformPeer::PRO_UID, $sproUid); - $oC1->add(DynaformPeer::DYN_TYPE, "xmlform"); - $oDataset = DynaformPeer::doSelectRS($oC1); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while($oDataset->next()){ - $aRow1 = $oDataset->getRow(); - //print_r($aRow1); - $dynHandler = new dynaFormHandler(PATH_DYNAFORM.$_POST['PRO_UID']."/".$aRow1['DYN_UID'].".xml"); - $dynFields = $dynHandler->getFields(); - $sxmlgrid = ''; - $sType = ''; - $check=0; - foreach($dynFields as $field){ - $sType = $this->getAttribute($field, 'type'); - if($sType == 'grid'){ - $sxmlgrid = $this->getAttribute($field, 'xmlgrid'); - $aGridInfo= explode("/",$sxmlgrid); - if($aGridInfo[0] == $sproUid && $aGridInfo[1] == $sObjUID){ - $check=1; - } - } - } - } - return ($check==1)?$aGridInfo:''; - }else{ - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepPeer::PRO_UID, $sproUid); - $oCriteria->add(StepPeer::STEP_UID_OBJ, $sObjUID); - $oCriteria->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM'); - $oDataset = StepPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - return($aRow); - } - die; - } - - function getAttribute($node, $attName){ - - foreach ( $node->attributes as $attribute ) - { - if ( $attribute->name == $attName ) - { - return $attribute->value; - } - - } - } - - /** - * verify if a dbconnection is assigned in some dynaforms or triggers - * - * @param string $sproUid the uid of the process - * @param string $sdbsUid the uid of the db connection - */ - function loadInfoAssigConnecctionDB($sproUid,$sdbsUid){ - - require_once ( "classes/model/DynaformPeer.php" ); - G::LoadSystem('dynaformhandler'); - $swDynaform = true; - $swTriggers = true; - //we are looking for triggers if there is at least one db connection - $oC = new Criteria('workflow'); - $oC->add(TriggersPeer::PRO_UID, $sproUid); - $oDataset = TriggersPeer::doSelectRS($oC); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - //print $sproUid; - while($aRowT = $oDataset->getRow()){ - $uidConnection =preg_quote($sdbsUid) ; - if( strrpos($uidConnection,$aRowT['TRI_WEBBOT']) ) { - $swTriggers = false; - } - $oDataset->next(); - } - //we are looking for dynaforms if there is at least one db connection - $oC = new Criteria('workflow'); - $oC->add(DynaformPeer::PRO_UID, $sproUid); - $oDataset = DynaformPeer::doSelectRS($oC); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while($aRow = $oDataset->getRow()){ - if($aRow['DYN_TYPE']=='xmlform') { - $dynHandler = new dynaFormHandler(PATH_DYNAFORM.$aRow['DYN_FILENAME'].".xml"); - $dynFields = $dynHandler->getFields(); - $sxmlgrid = ''; - $sType = ''; - $check=0; - foreach($dynFields as $field){ - $ssqlConnection = $this->getAttribute($field, 'sqlconnection'); - if($ssqlConnection==$sdbsUid) - $swDynaform=false; - }//end foreach - - }//end if - $oDataset->next(); - }//end while - //is there a connecction? - if ($swDynaform && $swTriggers){ - //there is no db connection, you can delete this connection - return true; - } else { - //there is a db connection, you can not delete this connection - return false; - } - die; - } - - /** - * Get related steps for a determinated case - * - * @author Erik A. O. - */ - function getAllCaseSteps($PRO_UID, $TAS_UID, $APP_UID) - { - - $c = new Criteria(); - $c->addSelectColumn('*'); - $c->add(StepPeer::PRO_UID, $PRO_UID); - $c->add(StepPeer::TAS_UID, $TAS_UID); - $c->addAscendingOrderByColumn (StepPeer::STEP_POSITION); - - return StepPeer::doSelect($c); - } - - /** - * Get the uids of the grids into a xml form - * - * @param string $sproUid the uid of the process - * @param string $sdbsUid the uid of the db connection - * @author krlos - */ - function lookingforUidGrids($sproUid,$sObjUID) { - - require_once ( "classes/model/DynaformPeer.php" ); - G::LoadSystem('dynaformhandler'); - $uidsGrids=array(); - $oC = new Criteria('workflow'); - $oC->add(DynaformPeer::DYN_UID, $sObjUID); - $oC->add(DynaformPeer::PRO_UID, $sproUid); - $oDataset = DynaformPeer::doSelectRS($oC); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - - if($aRow['DYN_TYPE']=='xmlform') { - - $oC1 = new Criteria('workflow'); - $oC1->add(DynaformPeer::PRO_UID, $sproUid); - $oC1->add(DynaformPeer::DYN_TYPE, "xmlform"); - $oDataset = DynaformPeer::doSelectRS($oC1); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while($oDataset->next()){ - $aRow1 = $oDataset->getRow(); - - $dynHandler = new dynaFormHandler(PATH_DYNAFORM.$sproUid."/".$sObjUID.".xml"); - $dynFields = $dynHandler->getFields(); - $sxmlgrid = ''; - $sType = ''; - $check=0; - foreach($dynFields as $field){ - $sType = $this->getAttribute($field, 'type'); - - if($sType == 'grid'){ - $sxmlgrid = $this->getAttribute($field, 'xmlgrid'); - //print_r($sxmlgrid);print""; - $aGridInfo= explode("/",$sxmlgrid); - $uidsGrids[]=$aGridInfo[1]; - } - } - } - return ($uidsGrids); - - } - } - - -} // Step - - - - - - - - - - - - - - - - + BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));*/ + $oStep = StepPeer::retrieveByPK( $sStepUID ); + $sTaskUID = $oStep->getTasUid(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepPeer::TAS_UID, $sTaskUID ); + $oCriteria->add( StepPeer::STEP_POSITION, $iPosition, '>' ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oStep = StepPeer::retrieveByPK( $aRow['STEP_UID'] ); + $oStep->setStepPosition( ($aRow['STEP_POSITION']) - 1 ); + $oStep->save(); + $oDataset->next(); + } + } catch (Exception $oException) { + throw $oException; + } + } + + public function up ($sStepUID = '', $sTaskUID = '', $iPosition = 0) + { + try { + if ($iPosition > 1) { + $oCriteria1 = new Criteria( 'workflow' ); + $oCriteria1->add( StepPeer::STEP_POSITION, $iPosition ); + $oCriteria2 = new Criteria( 'workflow' ); + $oCriteria2->add( StepPeer::TAS_UID, $sTaskUID ); + $oCriteria2->add( StepPeer::STEP_POSITION, ($iPosition - 1) ); + BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); + $oCriteria1 = new Criteria( 'workflow' ); + $oCriteria1->add( StepPeer::STEP_POSITION, ($iPosition - 1) ); + $oCriteria2 = new Criteria( 'workflow' ); + $oCriteria2->add( StepPeer::STEP_UID, $sStepUID ); + BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); + } + } catch (Exception $oException) { + throw $oException; + } + } + + public function down ($sStepUID = '', $sTaskUID = '', $iPosition = 0) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( 'COUNT(*) AS MAX_POSITION' ); + $oCriteria->add( StepPeer::TAS_UID, $sTaskUID ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + if ($iPosition < (int) $aRow['MAX_POSITION']) { + $oCriteria1 = new Criteria( 'workflow' ); + $oCriteria1->add( StepPeer::STEP_POSITION, $iPosition ); + $oCriteria2 = new Criteria( 'workflow' ); + $oCriteria2->add( StepPeer::TAS_UID, $sTaskUID ); + $oCriteria2->add( StepPeer::STEP_POSITION, ($iPosition + 1) ); + BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); + $oCriteria1 = new Criteria( 'workflow' ); + $oCriteria1->add( StepPeer::STEP_POSITION, ($iPosition + 1) ); + $oCriteria2 = new Criteria( 'workflow' ); + $oCriteria2->add( StepPeer::STEP_UID, $sStepUID ); + BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); + } + } catch (Exception $oException) { + throw $oException; + } + } + + public function removeStep ($sType = '', $sObjUID = '') + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepPeer::STEP_TYPE_OBJ, $sType ); + $oCriteria->add( StepPeer::STEP_UID_OBJ, $sObjUID ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $this->reOrder( $aRow['STEP_UID'], $aRow['STEP_POSITION'] ); + $this->remove( $aRow['STEP_UID'] ); + $oDataset->next(); + } + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * verify if Step row specified in [sUid] exists. + * + * @param string $sUid the uid of the + */ + + public function StepExists ($sUid) + { + $con = Propel::getConnection( StepPeer::DATABASE_NAME ); + try { + $oObj = StepPeer::retrieveByPk( $sUid ); + if (is_object( $oObj ) && get_class( $oObj ) == 'Step') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * verify if a dynaform is assigned some steps + * + * @param string $sproUid the uid of the process + * @param string $sObjUID the uid of the dynaform + */ + public function loadInfoAssigDynaform ($sproUid, $sObjUID) + { + + require_once ("classes/model/DynaformPeer.php"); + G::LoadSystem( 'dynaformhandler' ); + + $oC = new Criteria( 'workflow' ); + $oC->add( DynaformPeer::DYN_UID, $sObjUID ); + $oC->add( DynaformPeer::PRO_UID, $sproUid ); + $oDataset = DynaformPeer::doSelectRS( $oC ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + if ($aRow['DYN_TYPE'] != 'xmlform') { + + $oC1 = new Criteria( 'workflow' ); + $oC1->add( DynaformPeer::PRO_UID, $sproUid ); + $oC1->add( DynaformPeer::DYN_TYPE, "xmlform" ); + $oDataset = DynaformPeer::doSelectRS( $oC1 ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + while ($oDataset->next()) { + $aRow1 = $oDataset->getRow(); + //print_r($aRow1); + $dynHandler = new dynaFormHandler( PATH_DYNAFORM . $_POST['PRO_UID'] . "/" . $aRow1['DYN_UID'] . ".xml" ); + $dynFields = $dynHandler->getFields(); + $sxmlgrid = ''; + $sType = ''; + $check = 0; + foreach ($dynFields as $field) { + $sType = $this->getAttribute( $field, 'type' ); + if ($sType == 'grid') { + $sxmlgrid = $this->getAttribute( $field, 'xmlgrid' ); + $aGridInfo = explode( "/", $sxmlgrid ); + if ($aGridInfo[0] == $sproUid && $aGridInfo[1] == $sObjUID) { + $check = 1; + } + } + } + } + return ($check == 1) ? $aGridInfo : ''; + } else { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepPeer::PRO_UID, $sproUid ); + $oCriteria->add( StepPeer::STEP_UID_OBJ, $sObjUID ); + $oCriteria->add( StepPeer::STEP_TYPE_OBJ, 'DYNAFORM' ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + return ($aRow); + } + die(); + } + + public function getAttribute ($node, $attName) + { + + foreach ($node->attributes as $attribute) { + if ($attribute->name == $attName) { + return $attribute->value; + } + + } + } + + /** + * verify if a dbconnection is assigned in some dynaforms or triggers + * + * @param string $sproUid the uid of the process + * @param string $sdbsUid the uid of the db connection + */ + public function loadInfoAssigConnecctionDB ($sproUid, $sdbsUid) + { + require_once ("classes/model/DynaformPeer.php"); + G::LoadSystem( 'dynaformhandler' ); + $swDynaform = true; + $swTriggers = true; + //we are looking for triggers if there is at least one db connection + $oC = new Criteria( 'workflow' ); + $oC->add( TriggersPeer::PRO_UID, $sproUid ); + $oDataset = TriggersPeer::doSelectRS( $oC ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + //print $sproUid; + while ($aRowT = $oDataset->getRow()) { + $uidConnection = preg_quote( $sdbsUid ); + if (strrpos( $uidConnection, $aRowT['TRI_WEBBOT'] )) { + $swTriggers = false; + } + $oDataset->next(); + } + //we are looking for dynaforms if there is at least one db connection + $oC = new Criteria( 'workflow' ); + $oC->add( DynaformPeer::PRO_UID, $sproUid ); + $oDataset = DynaformPeer::doSelectRS( $oC ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($aRow['DYN_TYPE'] == 'xmlform') { + $dynHandler = new dynaFormHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml" ); + $dynFields = $dynHandler->getFields(); + $sxmlgrid = ''; + $sType = ''; + $check = 0; + foreach ($dynFields as $field) { + $ssqlConnection = $this->getAttribute( $field, 'sqlconnection' ); + if ($ssqlConnection == $sdbsUid) + $swDynaform = false; + } //end foreach + + + } //end if + $oDataset->next(); + } //end while + //is there a connecction? + if ($swDynaform && $swTriggers) { + //there is no db connection, you can delete this connection + return true; + } else { + //there is a db connection, you can not delete this connection + return false; + } + die(); + } + + /** + * Get related steps for a determinated case + * + * @author Erik A. O. + */ + public function getAllCaseSteps ($PRO_UID, $TAS_UID, $APP_UID) + { + + $c = new Criteria(); + $c->addSelectColumn( '*' ); + $c->add( StepPeer::PRO_UID, $PRO_UID ); + $c->add( StepPeer::TAS_UID, $TAS_UID ); + $c->addAscendingOrderByColumn( StepPeer::STEP_POSITION ); + + return StepPeer::doSelect( $c ); + } + + /** + * Get the uids of the grids into a xml form + * + * @param string $sproUid the uid of the process + * @param string $sdbsUid the uid of the db connection + * @author krlos + */ + public function lookingforUidGrids ($sproUid, $sObjUID) + { + + require_once ("classes/model/DynaformPeer.php"); + G::LoadSystem( 'dynaformhandler' ); + $uidsGrids = array (); + $oC = new Criteria( 'workflow' ); + $oC->add( DynaformPeer::DYN_UID, $sObjUID ); + $oC->add( DynaformPeer::PRO_UID, $sproUid ); + $oDataset = DynaformPeer::doSelectRS( $oC ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + if ($aRow['DYN_TYPE'] == 'xmlform') { + $oC1 = new Criteria( 'workflow' ); + $oC1->add( DynaformPeer::PRO_UID, $sproUid ); + $oC1->add( DynaformPeer::DYN_TYPE, "xmlform" ); + $oDataset = DynaformPeer::doSelectRS( $oC1 ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + while ($oDataset->next()) { + $aRow1 = $oDataset->getRow(); + + $dynHandler = new dynaFormHandler( PATH_DYNAFORM . $sproUid . "/" . $sObjUID . ".xml" ); + $dynFields = $dynHandler->getFields(); + $sxmlgrid = ''; + $sType = ''; + $check = 0; + foreach ($dynFields as $field) { + $sType = $this->getAttribute( $field, 'type' ); + + if ($sType == 'grid') { + $sxmlgrid = $this->getAttribute( $field, 'xmlgrid' ); + //print_r($sxmlgrid);print""; + $aGridInfo = explode( "/", $sxmlgrid ); + $uidsGrids[] = $aGridInfo[1]; + } + } + } + return ($uidsGrids); + + } + } + +} +// Step + diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index 3cdc11b81..af441642c 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -25,1275 +25,1215 @@ class adminProxy extends HttpProxyController { - public function saveSystemConf($httpData) - { - G::loadClass('system'); - $envFile = PATH_CONFIG . 'env.ini'; - $updateRedirector = false; - $restart = false; - - if (!file_exists($envFile) ) { // if ini file doesn't exists - if (!is_writable(PATH_CONFIG)) { - throw new Exception('The enviroment config directory is not writable. Please give write permission to directory: /workflow/engine/config'); - } - $content = ";\r\n"; - $content .= "; ProcessMaker System Bootstrap Configuration\r\n"; - $content .= ";\r\n"; - file_put_contents($envFile, $content); - //@chmod($envFile, 0777); - } - else { - if (!is_writable($envFile)) { - throw new Exception('The enviroment ini file file is not writable. Please give write permission to file: /workflow/engine/config/env.ini'); - } - } - - $sysConf = System::getSystemConfiguration($envFile); - - $updatedConf = array(); - - if ($sysConf['default_lang'] != $httpData->default_lang) { - $updatedConf['default_lang'] = $sysConf['default_lang'] = $httpData->default_lang; - $updateRedirector = true; - } - - if ($sysConf['default_skin'] != $httpData->default_skin) { - $updatedConf['default_skin'] = $sysConf['default_skin'] = $httpData->default_skin; - $updateRedirector = true; - } - - if ($sysConf['time_zone'] != $httpData->time_zone) { - $updatedConf['time_zone'] = $httpData->time_zone; - } - - $httpData->memory_limit .= 'M'; - if ($sysConf['memory_limit'] != $httpData->memory_limit) { - $updatedConf['memory_limit'] = $httpData->memory_limit; - } - - if ($sysConf['proxy_host'] != $httpData->proxy_host) { - $updatedConf['proxy_host'] = $httpData->proxy_host; - } - - if ($sysConf['proxy_port'] != $httpData->proxy_port) { - $updatedConf['proxy_port'] = $httpData->proxy_port; - } - - if ($sysConf['proxy_user'] != $httpData->proxy_user) { - $updatedConf['proxy_user'] = $httpData->proxy_user; - } - - if ($sysConf['proxy_pass'] != $httpData->proxy_pass) { - $updatedConf['proxy_pass'] = G::encrypt($httpData->proxy_pass, 'proxy_pass'); - } - - if ($updateRedirector) { - if (!file_exists(PATH_HTML . 'index.html')) { - throw new Exception('The index.html file is not writable on workflow/public_html directory.'); - } - else { - if (!is_writable(PATH_HTML . 'index.html')) { - throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html'); - } - } - - System::updateIndexFile(array( - 'lang' => $sysConf['default_lang'], - 'skin' => $sysConf['default_skin'] - )); - - $restart = true; - } - - G::update_php_ini($envFile, $updatedConf); - if (substr($sysConf['default_skin'], 0, 2) == 'ux') { - $urlPart = '/main/login'; - } - else { - $urlPart = '/login/login'; - } - - $this->success = true; - $this->restart = $restart; - $this->url = '/sys' . SYS_SYS . '/' . $sysConf['default_lang'] . '/' . $sysConf['default_skin'] . $urlPart; - $this->message = 'Saved Successfully'; - } - - function uxUserUpdate($httpData) - { - require_once 'classes/model/Users.php'; - $data = G::json_decode($httpData->users); - $list = array(); - - if (!is_array($data)) { - $list[0] = (array) $data ; - } - else { - $list = $data; - } - - $rows = array(); - - foreach ($list as $value) { - $value = (array) $value; - $user = UsersPeer::retrieveByPK($value['USR_UID']); - $user->setUsrUx($value['USR_UX']); - $user->save(); - - $row = $user->toArray(BasePeer::TYPE_FIELDNAME); - - $uxList = self::getUxTypesList(); - $row['USR_UX'] = $uxList[$user->getUsrUx()]; - $rows[] = $row; - } - - if (count($rows) == 1) { - $retRow = $rows[0]; - } - else { - $retRow = $rows; - } - - return array('success' => true, 'message'=>'done', 'users'=>$retRow); - } - - function calendarValidate($httpData) { - $httpData=array_unique((array)$httpData); - $message = ''; - $oldName = isset($_POST['oldName'])? $_POST['oldName']:''; - - switch ($_POST['action']){ - case 'calendarName': - require_once ('classes/model/CalendarDefinition.php'); - $oCalendar = new CalendarDefinition(); - $aCalendars = $oCalendar->getCalendarList(false,true); - $aCalendarDefinitions = end($aCalendars); - - foreach($aCalendarDefinitions as $aDefinitions) { - if (trim($_POST['name'])==''){ - $validated = false; - $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); - break; - } - if ($aDefinitions['CALENDAR_NAME'] != $_POST['name']){ - $validated = true; - } - else { - if ($aDefinitions['CALENDAR_NAME'] != $oldName) { - $validated = false; - $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); - break; - } - } - } - break; - case 'calendarDates': - $validated = false; - $message = G::loadTranslation('ID_CALENDAR_INVALID_WORK_DATES'); - break; - } - return $message; - } - - function uxGroupUpdate($httpData) - { - G::LoadClass('groups'); - $groups = new Groups(); - $users = $groups->getUsersOfGroup($httpData->GRP_UID); - $success = true; - $usersAdmin = ''; - foreach ($users as $user) { - if ($user['USR_ROLE'] == 'PROCESSMAKER_ADMIN' && ($httpData->GRP_UX == 'SIMPLIFIED' || $httpData->GRP_UX == 'SINGLE')) { - $success = false; - $usersAdmin .= $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'] . ', '; - } - } - if ($success) { - $group = GroupwfPeer::retrieveByPK($httpData->GRP_UID); - $group->setGrpUx($httpData->GRP_UX); - $group->save(); - } - return array('success' => $success, 'users' => $usersAdmin); - } - - function getUxTypesList($type = 'assoc') - { - $list = array(); - - if ($type == 'assoc') { - $list = array( - 'NORMAL' => 'Normal', - 'SIMPLIFIED' => 'Simplified', - 'SWITCHABLE' => 'Switchable', - 'SINGLE' => 'Single Application' - ); - } - else { - $list = array( - array('NORMAL', 'Normal'), - array('SIMPLIFIED', 'Simplified'), - array('SWITCHABLE', 'Switchable'), - array('SINGLE', 'Single Application') - ); - } - - return $list; - } - - function calendarSave() - { - //{ $_POST['BUSINESS_DAY'] - $businessDayArray = G::json_decode($_POST['BUSINESS_DAY']); - $businessDayFixArray = array(); - for($i=0;$iCALENDAR_BUSINESS_DAY; - $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_START'] = $businessDayArray[$i]->CALENDAR_BUSINESS_START; - $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_END'] = $businessDayArray[$i]->CALENDAR_BUSINESS_END; - } - $_POST['BUSINESS_DAY'] = $businessDayFixArray; - //} - - //{ $_POST['CALENDAR_WORK_DAYS'] - $calendarWorkDaysArray = G::json_decode($_POST['CALENDAR_WORK_DAYS']); - $calendarWorkDaysFixArray = array(); - for($i=0;$iCALENDAR_HOLIDAY_NAME; - $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_START'] = $holidayArray[$i]->CALENDAR_HOLIDAY_START; - $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_END'] = $holidayArray[$i]->CALENDAR_HOLIDAY_END; - } - $_POST['HOLIDAY'] = $holidayFixArray; - //} - - //[ CALENDAR_STATUS BUSINESS_DAY_STATUS HOLIDAY_STATUS - if($_POST['BUSINESS_DAY_STATUS']=="INACTIVE") { - unset($_POST['BUSINESS_DAY_STATUS']); - } - if($_POST['HOLIDAY_STATUS']=="INACTIVE") { - unset($_POST['HOLIDAY_STATUS']); - } - //] - - $form = $_POST; - G::LoadClass('calendar'); - $calendarObj=new calendar(); - $calendarObj->saveCalendarInfo($form); - - echo "{success: true}"; - } - - /** - * getting the kind of the authentication source - * @param object $params - * @return array $data - */ - function testingOption($params){ - - $data['success'] = true; - $data['optionAuthS'] = $params->optionAuthS; - return $data; - - }// end testingOption function - - /** - * saving the authentication source data - * @param object $params - * @return array $data - */ - function saveAuthSources($params){ - - global $RBAC; - if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - } - $aCommonFields = array('AUTH_SOURCE_UID', - 'AUTH_SOURCE_NAME', - 'AUTH_SOURCE_PROVIDER', - 'AUTH_SOURCE_SERVER_NAME', - 'AUTH_SOURCE_PORT', - 'AUTH_SOURCE_ENABLED_TLS', - 'AUTH_ANONYMOUS', - 'AUTH_SOURCE_SEARCH_USER', - 'AUTH_SOURCE_PASSWORD', - 'AUTH_SOURCE_VERSION', - 'AUTH_SOURCE_BASE_DN', - 'AUTH_SOURCE_OBJECT_CLASSES', - 'AUTH_SOURCE_ATTRIBUTES'); - - $aFields = $aData = array(); - - unset($params->PHPSESSID); - foreach ($params as $sField => $sValue) { - if (in_array($sField, $aCommonFields)) { - $aFields[$sField] = (($sField=='AUTH_SOURCE_ENABLED_TLS' || $sField=='AUTH_ANONYMOUS'))? ($sValue=='yes')?1:0 :$sValue; - } - else { - $aData[$sField] = ($sValue=='Active Directory')?'ad':$sValue; - } - } - $aFields['AUTH_SOURCE_DATA'] = $aData; - if ($aFields['AUTH_SOURCE_UID'] == '') { - $RBAC->createAuthSource($aFields); - } - else { - $RBAC->updateAuthSource($aFields); - } - $data=array(); - $data['success'] = true; - return $data; - }//end saveAuthSoruces function - - /** - * for Test email configuration - * @autor Alvaro - */ - public function testConnection($params) { - - G::LoadClass('net'); - G::LoadThirdParty('phpmailer', 'class.smtp'); - - if ($_POST['typeTest'] == 'MAIL') + public function saveSystemConf($httpData) { - define("SUCCESSFUL", 'SUCCESSFUL'); - define("FAILED", 'FAILED'); - $mail_to = $_POST['mail_to']; - $send_test_mail = $_POST['send_test_mail']; - $_POST['FROM_NAME'] = $mail_to; - $_POST['FROM_EMAIL'] = $mail_to; - $_POST['MESS_ENGINE'] = 'MAIL'; - $_POST['MESS_SERVER'] = 'localhost'; - $_POST['MESS_PORT'] = 25; - $_POST['MESS_ACCOUNT'] = $mail_to; - $_POST['MESS_PASSWORD'] = ''; - $_POST['TO'] = $mail_to; - $_POST['SMTPAuth'] = true; + G::loadClass('system'); + $envFile = PATH_CONFIG . 'env.ini'; + $updateRedirector = false; + $restart = false; - try { - $resp = $this->sendTestMail(); - } catch (Exception $error) { - $resp = new stdclass(); - $resp->status = false; - $resp->msg = $error->getMessage(); - } - - $response = array('success' => $resp->status); - - if ($resp->status == false) - $response['msg'] = G::LoadTranslation('ID_SENDMAIL_NOT_INSTALLED'); - - echo G::json_encode($response); - die; - } - - $step = $_POST['step']; - $server = $_POST['server']; - $user = $_POST['user']; - $passwd = $_POST['passwd']; - $passwdHide = $_POST['passwdHide']; - - if (trim($passwdHide) != '') { - $passwd = $passwdHide; - $passwdHide = ''; - } - - $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); - $auxPass = explode('hash:', $passwdDec); - if (count($auxPass) > 1) { - if (count($auxPass) == 2) { - $passwd = $auxPass[1]; + if (!file_exists($envFile) ) { + if (!is_writable(PATH_CONFIG)) { + throw new Exception('The enviroment config directory is not writable. Please give write permission to directory: /workflow/engine/config'); + } + $content = ";\r\n"; + $content .= "; ProcessMaker System Bootstrap Configuration\r\n"; + $content .= ";\r\n"; + file_put_contents($envFile, $content); + //@chmod($envFile, 0777); } else { - array_shift($auxPass); - $passwd = implode('', $auxPass); - } - } - $_POST['passwd'] = $passwd; - - $port = $_POST['port']; - $auth_required = $_POST['req_auth']; - $UseSecureCon = $_POST['UseSecureCon']; - $SendaTestMail = $_POST['SendaTestMail']; - $Mailto = $_POST['eMailto']; - $SMTPSecure = $_POST['UseSecureCon']; - - $Server = new NET($server); - $smtp = new SMTP; - - $timeout = 10; - $hostinfo = array(); - $srv=$_POST['server']; - - switch ($step) { - case 1: - $this->success = $Server->getErrno() == 0; - $this->msg = $this->result ? 'success' : $Server->error; - break; - - case 2: - $Server->scannPort($port); - - $this->success = $Server->getErrno() == 0; //'Successfull'.$smtp->status; - $this->msg = $this->result ? '' : $Server->error; - break; - - case 3: //try to connect to host - if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { - $server = $hostinfo[1]; - $port = $hostinfo[2]; - } - else { - $host = $srv; + if (!is_writable($envFile)) { + throw new Exception('The enviroment ini file file is not writable. Please give write permission to file: /workflow/engine/config/env.ini'); + } } - $tls = (strtoupper($SMTPSecure) == 'tls'); - $ssl = (strtoupper($SMTPSecure) == 'ssl'); + $sysConf = System::getSystemConfiguration($envFile); - $this->success = $smtp->Connect(($ssl ? 'ssl://':'').$server, $port, $timeout); - $this->msg = $this->result ? '' : $Server->error; + $updatedConf = array(); - break; - - case 4: //try login to host - if($auth_required == 'true') { - try { - if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { - $server = $hostinfo[1]; - $port = $hostinfo[2]; - } - else { - $server = $srv; - } - if (strtoupper($UseSecureCon)=='TLS') { - $tls = 'tls'; - } - - if (strtoupper($UseSecureCon)=='SSL') { - $tls = 'ssl'; - } - - $tls = (strtoupper($UseSecureCon) == 'tls'); - $ssl = (strtoupper($UseSecureCon) == 'ssl'); - $server = $_POST['server']; - - if(strtoupper($UseSecureCon) == 'SSL') { - $resp = $smtp->Connect(('ssl://').$server, $port, $timeout); - } - else { - $resp = $smtp->Connect($server, $port, $timeout); - } - - if ($resp) { - $hello = $_SERVER['SERVER_NAME']; - $smtp->Hello($hello); - - if (strtoupper($UseSecureCon) == 'TLS') { - $smtp->Hello($hello); - } - - if( $smtp->Authenticate($user, $passwd) ) { - $this->success = true; - } - else { - $this->success = false; - $this->msg = $smtp->error['error']; - } - } - else { - $this->success = false; - $this->msg = $smtp->error['error']; - } - } - catch (Exception $e) { - $this->success = false; - $this->msg = $e->getMessage(); - } + if ($sysConf['default_lang'] != $httpData->default_lang) { + $updatedConf['default_lang'] = $sysConf['default_lang'] = $httpData->default_lang; + $updateRedirector = true; } - else { - $this->success = true; - $this->msg = 'No authentication required!'; + + if ($sysConf['default_skin'] != $httpData->default_skin) { + $updatedConf['default_skin'] = $sysConf['default_skin'] = $httpData->default_skin; + $updateRedirector = true; } - break; - case 5: //send a test mail - if($SendaTestMail == 'true') { - try { - $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]'; - $_POST['FROM_EMAIL'] = $user; - $_POST['MESS_ENGINE'] = 'PHPMAILER'; - $_POST['MESS_SERVER'] = $server; - $_POST['MESS_PORT'] = $port; - $_POST['MESS_ACCOUNT'] = $user; - $_POST['MESS_PASSWORD'] = $passwd; - $_POST['TO'] = $Mailto; - - if($auth_required == 'true') { - $_POST['SMTPAuth'] = true; - } - else { - $_POST['SMTPAuth'] = false; - } - - if (strtolower($_POST["UseSecureCon"]) != "no") { - $_POST["SMTPSecure"] = $_POST["UseSecureCon"]; - } - - if ($_POST['UseSecureCon'] == 'ssl') { - $_POST['MESS_SERVER'] = 'ssl://'.$_POST['MESS_SERVER']; - } - - $resp = $this->sendTestMail(); - if ($resp->status == '1') { - $this->success=true; - } - else { - $this->success=false; - $this->msg=$smtp->error['error']; - } - } - catch (Exception $e) { - $this->success = false; - $this->msg = $e->getMessage(); - } + if ($sysConf['time_zone'] != $httpData->time_zone) { + $updatedConf['time_zone'] = $httpData->time_zone; } - else { - $this->success=true; - $this->msg='jump this step'; + + $httpData->memory_limit .= 'M'; + if ($sysConf['memory_limit'] != $httpData->memory_limit) { + $updatedConf['memory_limit'] = $httpData->memory_limit; } - break; - } - } - /** - * for send email configuration - * @autor Alvaro - */ - public function sendTestMail() { + if ($sysConf['proxy_host'] != $httpData->proxy_host) { + $updatedConf['proxy_host'] = $httpData->proxy_host; + } - global $G_PUBLISH; - G::LoadClass("system"); - G::LoadClass('spool'); + if ($sysConf['proxy_port'] != $httpData->proxy_port) { + $updatedConf['proxy_port'] = $httpData->proxy_port; + } - $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>'; - $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT'); - $msg = G::LoadTranslation('ID_MESS_TEST_BODY'); + if ($sysConf['proxy_user'] != $httpData->proxy_user) { + $updatedConf['proxy_user'] = $httpData->proxy_user; + } - switch ($_POST['MESS_ENGINE']) { - case 'MAIL': - $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1'); - break; + if ($sysConf['proxy_pass'] != $httpData->proxy_pass) { + $updatedConf['proxy_pass'] = G::encrypt($httpData->proxy_pass, 'proxy_pass'); + } - case 'PHPMAILER': - $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2'); - break; + if ($updateRedirector) { + if (!file_exists(PATH_HTML . 'index.html')) { + throw new Exception('The index.html file is not writable on workflow/public_html directory.'); + } else { + if (!is_writable(PATH_HTML . 'index.html')) { + throw new Exception(G::LoadTranslation('ID_INDEX_NOT_WRITEABLE') . ' /workflow/public_html/index.html'); + } + } - case 'OPENMAIL': - $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3'); - break; + System::updateIndexFile(array( + 'lang' => $sysConf['default_lang'], + 'skin' => $sysConf['default_skin'] + )); + + $restart = true; + } + + G::update_php_ini($envFile, $updatedConf); + if (substr($sysConf['default_skin'], 0, 2) == 'ux') { + $urlPart = '/main/login'; + } else { + $urlPart = '/login/login'; + } + + $this->success = true; + $this->restart = $restart; + $this->url = '/sys' . SYS_SYS . '/' . $sysConf['default_lang'] . '/' . $sysConf['default_skin'] . $urlPart; + $this->message = 'Saved Successfully'; } - $sBodyPre = new TemplatePower(PATH_TPL . 'admin' . PATH_SEP . 'email.tpl'); - $sBodyPre->prepare(); - $sBodyPre->assign('server', $_SERVER['SERVER_NAME']); - $sBodyPre->assign('date', date('H:i:s')); - $sBodyPre->assign('ver', System::getVersion()); - $sBodyPre->assign('engine', $engine); - $sBodyPre->assign('msg', $msg); - $sBody = $sBodyPre->getOutputContent(); + public function uxUserUpdate($httpData) + { + require_once 'classes/model/Users.php'; + $data = G::json_decode($httpData->users); + $list = array(); - $oSpool = new spoolRun(); - $oSpool->setConfig( - array( - 'MESS_ENGINE' => $_POST['MESS_ENGINE'], - 'MESS_SERVER' => $_POST['MESS_SERVER'], - 'MESS_PORT' => $_POST['MESS_PORT'], - 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], - 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], - 'SMTPAuth' => $_POST['SMTPAuth'], - 'SMTPSecure' => isset($_POST['SMTPSecure'])?$_POST['SMTPSecure']:'none' - ) - ); + if (!is_array($data)) { + $list[0] = (array) $data ; + } else { + $list = $data; + } - $oSpool->create( - array( - 'msg_uid' => '', - 'app_uid' => '', - 'del_index' => 0, - 'app_msg_type' => 'TEST', - 'app_msg_subject' => $sSubject, - 'app_msg_from' => $sFrom, - 'app_msg_to' => $_POST['TO'], - 'app_msg_body' => $sBody, - 'app_msg_cc' => '', - 'app_msg_bcc' => '', - 'app_msg_attach' => '', - 'app_msg_template' => '', - 'app_msg_status' => 'pending', - 'app_msg_attach'=>'' // Added By Ankit - ) - ); + $rows = array(); - $oSpool->sendMail(); - $G_PUBLISH = new Publisher(); + foreach ($list as $value) { + $value = (array) $value; + $user = UsersPeer::retrieveByPK($value['USR_UID']); + $user->setUsrUx($value['USR_UX']); + $user->save(); - if ($oSpool->status == 'sent') { - $o->status = true; - $o->success = true; - $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS'); + $row = $user->toArray(BasePeer::TYPE_FIELDNAME); + + $uxList = self::getUxTypesList(); + $row['USR_UX'] = $uxList[$user->getUsrUx()]; + $rows[] = $row; + } + + if (count($rows) == 1) { + $retRow = $rows[0]; + } else { + $retRow = $rows; + } + + return array('success' => true, 'message'=>'done', 'users'=>$retRow); } - else { - $o->status = false; - $o->success = false; - $o->msg = $oSpool->error; + + public function calendarValidate($httpData) + { + $httpData=array_unique((array)$httpData); + $message = ''; + $oldName = isset($_POST['oldName'])? $_POST['oldName']:''; + + switch ($_POST['action']){ + case 'calendarName': + require_once ('classes/model/CalendarDefinition.php'); + $oCalendar = new CalendarDefinition(); + $aCalendars = $oCalendar->getCalendarList(false,true); + $aCalendarDefinitions = end($aCalendars); + + foreach ($aCalendarDefinitions as $aDefinitions) { + if (trim($_POST['name'])=='') { + $validated = false; + $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); + break; + } + if ($aDefinitions['CALENDAR_NAME'] != $_POST['name']) { + $validated = true; + } else { + if ($aDefinitions['CALENDAR_NAME'] != $oldName) { + $validated = false; + $message = G::loadTranslation('ID_CALENDAR_INVALID_NAME'); + break; + } + } + } + break; + case 'calendarDates': + $validated = false; + $message = G::loadTranslation('ID_CALENDAR_INVALID_WORK_DATES'); + break; + } + return $message; } - return $o; - } - /** - * getting Save email configuration - * @autor Alvaro - */ - public function saveConfiguration() { + public function uxGroupUpdate($httpData) + { + G::LoadClass('groups'); + $groups = new Groups(); + $users = $groups->getUsersOfGroup($httpData->GRP_UID); + $success = true; + $usersAdmin = ''; + foreach ($users as $user) { + if ($user['USR_ROLE'] == 'PROCESSMAKER_ADMIN' && ($httpData->GRP_UX == 'SIMPLIFIED' || $httpData->GRP_UX == 'SINGLE')) { + $success = false; + $usersAdmin .= $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'] . ', '; + } + } + if ($success) { + $group = GroupwfPeer::retrieveByPK($httpData->GRP_UID); + $group->setGrpUx($httpData->GRP_UX); + $group->save(); + } + return array('success' => $success, 'users' => $usersAdmin); + } - require_once 'classes/model/Configuration.php'; + public function getUxTypesList($type = 'assoc') + { + $list = array(); - try { - $oConfiguration = new Configuration(); - $aFields['MESS_PASSWORD'] = $_POST['passwd']; + if ($type == 'assoc') { + $list = array( + 'NORMAL' => 'Normal', + 'SIMPLIFIED' => 'Simplified', + 'SWITCHABLE' => 'Switchable', + 'SINGLE' => 'Single Application' + ); + } else { + $list = array( + array('NORMAL', 'Normal'), + array('SIMPLIFIED', 'Simplified'), + array('SWITCHABLE', 'Switchable'), + array('SINGLE', 'Single Application') + ); + } + return $list; + } - if ($_POST['passwdHide'] != '') { - $aFields['MESS_PASSWORD'] = $_POST['passwdHide']; - } + public function calendarSave() + { + //{ $_POST['BUSINESS_DAY'] + $businessDayArray = G::json_decode($_POST['BUSINESS_DAY']); + $businessDayFixArray = array(); + for ($i=0; $iCALENDAR_BUSINESS_DAY; + $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_START'] = $businessDayArray[$i]->CALENDAR_BUSINESS_START; + $businessDayFixArray[$i+1]['CALENDAR_BUSINESS_END'] = $businessDayArray[$i]->CALENDAR_BUSINESS_END; + } + $_POST['BUSINESS_DAY'] = $businessDayFixArray; + //} - $aFields['MESS_PASSWORD_HIDDEN'] = ''; - $passwd = $aFields['MESS_PASSWORD']; - $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); - $auxPass = explode('hash:', $passwdDec); - if (count($auxPass) > 1) { - if (count($auxPass) == 2) { - $passwd = $auxPass[1]; - } else { - array_shift($auxPass); - $passwd = implode('', $auxPass); - } - } - $aFields['MESS_PASSWORD'] = $passwd; + //{ $_POST['CALENDAR_WORK_DAYS'] + $calendarWorkDaysArray = G::json_decode($_POST['CALENDAR_WORK_DAYS']); + $calendarWorkDaysFixArray = array(); + for ($i=0; $iCALENDAR_HOLIDAY_NAME; + $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_START'] = $holidayArray[$i]->CALENDAR_HOLIDAY_START; + $holidayFixArray[$i+1]['CALENDAR_HOLIDAY_END'] = $holidayArray[$i]->CALENDAR_HOLIDAY_END; + } + $_POST['HOLIDAY'] = $holidayFixArray; + //} - $aFields['MESS_ENABLED'] = isset($_POST['EnableEmailNotifications']) ? $_POST['EnableEmailNotifications'] : ''; - $aFields['MESS_ENABLED'] = ($aFields['MESS_ENABLED'] == 'true') ? '1' : $aFields['MESS_ENABLED']; - $aFields['MESS_ENGINE'] = $_POST['EmailEngine']; - $aFields['MESS_SERVER'] = trim($_POST['server']); - $aFields['MESS_RAUTH'] = isset($_POST['req_auth']) ? $_POST['req_auth'] : ''; - $aFields['MESS_RAUTH'] = ($aFields['MESS_RAUTH'] == 'true') ? '1' : $aFields['MESS_RAUTH']; - $aFields['MESS_PORT'] = $_POST['port']; - $aFields['MESS_ACCOUNT'] = $_POST['from']; - $aFields['MESS_BACKGROUND'] = '';//isset($_POST['background']) ? $_POST['background'] : ''; - $aFields['MESS_EXECUTE_EVERY'] = '';//$_POST['form']['MESS_EXECUTE_EVERY']; - $aFields['MESS_SEND_MAX'] = '';//$_POST['form']['MESS_SEND_MAX']; - $aFields['SMTPSecure'] = $_POST['UseSecureCon']; - $aFields['SMTPSecure'] = ($aFields['SMTPSecure'] == 'No') ? 'none' : $aFields['SMTPSecure']; - $aFields['MAIL_TO'] = $_POST['eMailto']; - $aFields['MESS_TRY_SEND_INMEDIATLY'] = $_POST['SendaTestMail'];//isset($_POST['form']['MESS_TRY_SEND_INMEDIATLY']) ? $_POST['form']['MESS_TRY_SEND_INMEDIATLY'] : ''; - $aFields['MESS_TRY_SEND_INMEDIATLY'] = ($aFields['MESS_TRY_SEND_INMEDIATLY'] == 'true') ? '1' : $aFields['MESS_TRY_SEND_INMEDIATLY']; - $CfgUid='Emails'; - $ObjUid=''; - $ProUid=''; - $UsrUid=''; - $AppUid=''; + //[ CALENDAR_STATUS BUSINESS_DAY_STATUS HOLIDAY_STATUS + if ($_POST['BUSINESS_DAY_STATUS']=="INACTIVE") { + unset($_POST['BUSINESS_DAY_STATUS']); + } + if ($_POST['HOLIDAY_STATUS']=="INACTIVE") { + unset($_POST['HOLIDAY_STATUS']); + } + //] - if($oConfiguration->exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)) { - $oConfiguration->update( - array( - 'CFG_UID' => 'Emails', - 'OBJ_UID' => '', - 'CFG_VALUE' => serialize($aFields), - 'PRO_UID' => '', - 'USR_UID' => '', - 'APP_UID' => '' - ) + $form = $_POST; + G::LoadClass('calendar'); + $calendarObj=new calendar(); + $calendarObj->saveCalendarInfo($form); + echo "{success: true}"; + } + + /** + * getting the kind of the authentication source + * @param object $params + * @return array $data + */ + public function testingOption($params) + { + $data['success'] = true; + $data['optionAuthS'] = $params->optionAuthS; + return $data; + + } + + /** + * saving the authentication source data + * @param object $params + * @return array $data + */ + public function saveAuthSources($params) + { + global $RBAC; + if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) { + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); + G::header('location: ../login/login'); + die; + } + $aCommonFields = array('AUTH_SOURCE_UID', + 'AUTH_SOURCE_NAME', + 'AUTH_SOURCE_PROVIDER', + 'AUTH_SOURCE_SERVER_NAME', + 'AUTH_SOURCE_PORT', + 'AUTH_SOURCE_ENABLED_TLS', + 'AUTH_ANONYMOUS', + 'AUTH_SOURCE_SEARCH_USER', + 'AUTH_SOURCE_PASSWORD', + 'AUTH_SOURCE_VERSION', + 'AUTH_SOURCE_BASE_DN', + 'AUTH_SOURCE_OBJECT_CLASSES', + 'AUTH_SOURCE_ATTRIBUTES'); + + $aFields = $aData = array(); + + unset($params->PHPSESSID); + foreach ($params as $sField => $sValue) { + if (in_array($sField, $aCommonFields)) { + $aFields[$sField] = (($sField=='AUTH_SOURCE_ENABLED_TLS' || $sField=='AUTH_ANONYMOUS'))? ($sValue=='yes')?1:0 :$sValue; + } else { + $aData[$sField] = ($sValue=='Active Directory')?'ad':$sValue; + } + } + $aFields['AUTH_SOURCE_DATA'] = $aData; + if ($aFields['AUTH_SOURCE_UID'] == '') { + $RBAC->createAuthSource($aFields); + } else { + $RBAC->updateAuthSource($aFields); + } + $data=array(); + $data['success'] = true; + return $data; + } + + /** + * for Test email configuration + * @autor Alvaro + */ + public function testConnection($params) + { + G::LoadClass('net'); + G::LoadThirdParty('phpmailer', 'class.smtp'); + + if ($_POST['typeTest'] == 'MAIL') { + define("SUCCESSFUL", 'SUCCESSFUL'); + define("FAILED", 'FAILED'); + $mail_to = $_POST['mail_to']; + $send_test_mail = $_POST['send_test_mail']; + $_POST['FROM_NAME'] = $mail_to; + $_POST['FROM_EMAIL'] = $mail_to; + $_POST['MESS_ENGINE'] = 'MAIL'; + $_POST['MESS_SERVER'] = 'localhost'; + $_POST['MESS_PORT'] = 25; + $_POST['MESS_ACCOUNT'] = $mail_to; + $_POST['MESS_PASSWORD'] = ''; + $_POST['TO'] = $mail_to; + $_POST['SMTPAuth'] = true; + + try { + $resp = $this->sendTestMail(); + } catch (Exception $error) { + $resp = new stdclass(); + $resp->status = false; + $resp->msg = $error->getMessage(); + } + + $response = array('success' => $resp->status); + + if ($resp->status == false) { + $response['msg'] = G::LoadTranslation('ID_SENDMAIL_NOT_INSTALLED'); + } + echo G::json_encode($response); + die; + } + + $step = $_POST['step']; + $server = $_POST['server']; + $user = $_POST['user']; + $passwd = $_POST['passwd']; + $passwdHide = $_POST['passwdHide']; + + if (trim($passwdHide) != '') { + $passwd = $passwdHide; + $passwdHide = ''; + } + + $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); + $auxPass = explode('hash:', $passwdDec); + if (count($auxPass) > 1) { + if (count($auxPass) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift($auxPass); + $passwd = implode('', $auxPass); + } + } + $_POST['passwd'] = $passwd; + + $port = $_POST['port']; + $auth_required = $_POST['req_auth']; + $UseSecureCon = $_POST['UseSecureCon']; + $SendaTestMail = $_POST['SendaTestMail']; + $Mailto = $_POST['eMailto']; + $SMTPSecure = $_POST['UseSecureCon']; + + $Server = new NET($server); + $smtp = new SMTP; + + $timeout = 10; + $hostinfo = array(); + $srv=$_POST['server']; + + switch ($step) { + case 1: + $this->success = $Server->getErrno() == 0; + $this->msg = $this->result ? 'success' : $Server->error; + break; + case 2: + $Server->scannPort($port); + + $this->success = $Server->getErrno() == 0; //'Successfull'.$smtp->status; + $this->msg = $this->result ? '' : $Server->error; + break; + case 3: //try to connect to host + if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { + $server = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $srv; + } + + $tls = (strtoupper($SMTPSecure) == 'tls'); + $ssl = (strtoupper($SMTPSecure) == 'ssl'); + + $this->success = $smtp->Connect(($ssl ? 'ssl://':'').$server, $port, $timeout); + $this->msg = $this->result ? '' : $Server->error; + break; + case 4: //try login to host + if ($auth_required == 'true') { + try { + if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { + $server = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $server = $srv; + } + if (strtoupper($UseSecureCon)=='TLS') { + $tls = 'tls'; + } + + if (strtoupper($UseSecureCon)=='SSL') { + $tls = 'ssl'; + } + + $tls = (strtoupper($UseSecureCon) == 'tls'); + $ssl = (strtoupper($UseSecureCon) == 'ssl'); + $server = $_POST['server']; + + if (strtoupper($UseSecureCon) == 'SSL') { + $resp = $smtp->Connect(('ssl://').$server, $port, $timeout); + } else { + $resp = $smtp->Connect($server, $port, $timeout); + } + if ($resp) { + $hello = $_SERVER['SERVER_NAME']; + $smtp->Hello($hello); + if (strtoupper($UseSecureCon) == 'TLS') { + $smtp->Hello($hello); + } + if ( $smtp->Authenticate($user, $passwd) ) { + $this->success = true; + } else { + $this->success = false; + $this->msg = $smtp->error['error']; + } + } else { + $this->success = false; + $this->msg = $smtp->error['error']; + } + } catch (Exception $e) { + $this->success = false; + $this->msg = $e->getMessage(); + } + } else { + $this->success = true; + $this->msg = 'No authentication required!'; + } + break; + case 5: + if ($SendaTestMail == 'true') { + try { + $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]'; + $_POST['FROM_EMAIL'] = $user; + $_POST['MESS_ENGINE'] = 'PHPMAILER'; + $_POST['MESS_SERVER'] = $server; + $_POST['MESS_PORT'] = $port; + $_POST['MESS_ACCOUNT'] = $user; + $_POST['MESS_PASSWORD'] = $passwd; + $_POST['TO'] = $Mailto; + + if ($auth_required == 'true') { + $_POST['SMTPAuth'] = true; + } else { + $_POST['SMTPAuth'] = false; + } + if (strtolower($_POST["UseSecureCon"]) != "no") { + $_POST["SMTPSecure"] = $_POST["UseSecureCon"]; + } + if ($_POST['UseSecureCon'] == 'ssl') { + $_POST['MESS_SERVER'] = 'ssl://'.$_POST['MESS_SERVER']; + } + $resp = $this->sendTestMail(); + if ($resp->status == '1') { + $this->success=true; + } else { + $this->success=false; + $this->msg=$smtp->error['error']; + } + } catch (Exception $e) { + $this->success = false; + $this->msg = $e->getMessage(); + } + } else { + $this->success=true; + $this->msg='jump this step'; + } + break; + } + } + + /** + * for send email configuration + * @autor Alvaro + */ + public function sendTestMail() + { + global $G_PUBLISH; + G::LoadClass("system"); + G::LoadClass('spool'); + + $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>'; + $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT'); + $msg = G::LoadTranslation('ID_MESS_TEST_BODY'); + + switch ($_POST['MESS_ENGINE']) { + case 'MAIL': + $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1'); + break; + case 'PHPMAILER': + $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2'); + break; + case 'OPENMAIL': + $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3'); + break; + } + + $sBodyPre = new TemplatePower(PATH_TPL . 'admin' . PATH_SEP . 'email.tpl'); + $sBodyPre->prepare(); + $sBodyPre->assign('server', $_SERVER['SERVER_NAME']); + $sBodyPre->assign('date', date('H:i:s')); + $sBodyPre->assign('ver', System::getVersion()); + $sBodyPre->assign('engine', $engine); + $sBodyPre->assign('msg', $msg); + $sBody = $sBodyPre->getOutputContent(); + + $oSpool = new spoolRun(); + $oSpool->setConfig( + array( + 'MESS_ENGINE' => $_POST['MESS_ENGINE'], + 'MESS_SERVER' => $_POST['MESS_SERVER'], + 'MESS_PORT' => $_POST['MESS_PORT'], + 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], + 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], + 'SMTPAuth' => $_POST['SMTPAuth'], + 'SMTPSecure' => isset($_POST['SMTPSecure'])?$_POST['SMTPSecure']:'none' + ) ); - $this->success='true'; - $this->msg='Saved'; - } - else { - $oConfiguration->create( - array( - 'CFG_UID' => 'Emails', - 'OBJ_UID' => '', - 'CFG_VALUE' => serialize($aFields), - 'PRO_UID' => '', - 'USR_UID' => '', - 'APP_UID' => '' - ) + + $oSpool->create( + array( + 'msg_uid' => '', + 'app_uid' => '', + 'del_index' => 0, + 'app_msg_type' => 'TEST', + 'app_msg_subject' => $sSubject, + 'app_msg_from' => $sFrom, + 'app_msg_to' => $_POST['TO'], + 'app_msg_body' => $sBody, + 'app_msg_cc' => '', + 'app_msg_bcc' => '', + 'app_msg_attach' => '', + 'app_msg_template' => '', + 'app_msg_status' => 'pending', + 'app_msg_attach'=>'' // Added By Ankit + ) ); - $this->success='true'; - $this->msg='Saved'; - } - } - catch (Exception $e) { - $this->success= false; - $this->msg = $e->getMessage(); - } - } - /** - * loadFields for email configuration - * @autor Alvaro - */ - public function loadFields() { + $oSpool->sendMail(); + $G_PUBLISH = new Publisher(); - G::loadClass('configuration'); - - $oConfiguration = new Configurations(); - $oConfiguration->loadConfig($x, 'Emails','','','',''); - $fields = $oConfiguration->aConfig; - if (count($fields) > 0) { - $this->success = (count($fields) > 0); - $passwd = $fields['MESS_PASSWORD']; - $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); - $auxPass = explode('hash:', $passwdDec); - if (count($auxPass) > 1) { - if (count($auxPass) == 2) { - $passwd = $auxPass[1]; - } else { - array_shift($auxPass); - $passwd = implode('', $auxPass); - } - } - $fields['MESS_PASSWORD'] = $passwd; - } - $this->data = $fields; - } - - /** - * get List Image - * @param type $httpData - */ - public function getListImage($httpData) - { - G::LoadClass('replacementLogo'); - $uplogo = PATH_TPL . 'setup' . PATH_SEP . 'uplogo.html'; - $width = "100%"; - $upload = new replacementLogo(); - $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); - $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); - $check = ''; - $ainfoSite = explode("/",$_SERVER["REQUEST_URI"]); - $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; - G::mk_dir ( $dir ); - $i = 0; - $images = array(); - /** if we have at least one image it's load */ - if (file_exists($dir)) { - if ($handle = opendir($dir)) { - while (false !== ($file = readdir($handle))) { - if (($file != ".") && ($file != "..")) { - $extention = explode(".", $file); - $aImageProp = getimagesize($dir . '/' . $file, $info); - $sfileExtention = strtoupper($extention[count($extention)-1]); - - if( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { - - $check = (!strcmp($file, $sPhotoSelect)) ? '/images/toadd.png' : '/images/delete.png'; - $onclick = (strcmp($file, $sPhotoSelect)) ? "onclick ='deleteLogo(\" $file \");return false;'" : ''; - - if ($i == 0) { - $i++; - } - $i++; - $images[] = array( - 'name' => $file, - 'size' => '0', - 'lastmod' => '32', - 'url' => "../adminProxy/showLogoFile?id=".base64_encode($file), - 'thumb_url' => "../adminProxy/showLogoFile?id=".base64_encode($file) - ); - } - } + if ($oSpool->status == 'sent') { + $o->status = true; + $o->success = true; + $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS'); + } else { + $o->status = false; + $o->success = false; + $o->msg = $oSpool->error; } - closedir($handle); - } - } - $o = array('images' => $images); - echo G::json_encode($o); - exit(); - } - /** - * Change Name logo - * @param type $snameLogo - * @return type $snameLogo - */ - function changeNamelogo($snameLogo) - { - $snameLogo = preg_replace("/[áàâãª]/", "a", $snameLogo); - $snameLogo = preg_replace("/[ÁÀÂÃ]/", "A", $snameLogo); - $snameLogo = preg_replace("/[ÍÌÎ]/", "I", $snameLogo); - $snameLogo = preg_replace("/[íìî]/", "i", $snameLogo); - $snameLogo = preg_replace("/[éèê]/", "e", $snameLogo); - $snameLogo = preg_replace("/[ÉÈÊ]/", "E", $snameLogo); - $snameLogo = preg_replace("/[óòôõº]/", "o", $snameLogo); - $snameLogo = preg_replace("/[ÓÒÔÕ]/", "O", $snameLogo); - $snameLogo = preg_replace("/[úùû]/", "u", $snameLogo); - $snameLogo = preg_replace("/[ÚÙÛ]/", "U", $snameLogo); - $snameLogo = str_replace( "ç", "c", $snameLogo); - $snameLogo = str_replace( "Ç", "C", $snameLogo); - $snameLogo = str_replace( "[ñ]", "n", $snameLogo); - $snameLogo = str_replace( "[Ñ]", "N", $snameLogo); - return ($snameLogo); - } - /** - * Create Thumb - * @param type $img_file - * @param type $ori_path - * @param type $thumb_path - * @param type $img_type - */ - function createThumb($img_file, $ori_path, $thumb_path, $img_type) - { - $path = $ori_path; - $img = $path.$img_file; - switch ($img_type) { - case "image/jpeg": - $img_src = @imagecreatefromjpeg($img); - break; - case "image/pjpeg": - $img_src = @imagecreatefromjpeg($img); - break; - case "image/png": - $img_src = @imagecreatefrompng($img); - break; - case "image/x-png": - $img_src = @imagecreatefrompng($img); - break; - case "image/gif": - $img_src = @imagecreatefromgif($img); - break; - } - $img_width = imagesx($img_src); - $img_height = imagesy($img_src); - $square_size = 100; - // check width, height, or square - if ($img_width == $img_height) { - // square - $tmp_width = $square_size; - $tmp_height = $square_size; - } else if ($img_height < $img_width) { - // wide - $tmp_height = $square_size; - $tmp_width = intval(($img_width / $img_height) * $square_size); - if ($tmp_width % 2 != 0) { - $tmp_width++; - } - } else if ($img_height > $img_width) { - $tmp_width = $square_size; - $tmp_height = intval(($img_height / $img_width) * $square_size); - if (($tmp_height % 2) != 0) { - $tmp_height++; - } - } - $img_new = imagecreatetruecolor($tmp_width, $tmp_height); - imagecopyresampled($img_new, $img_src, 0, 0, 0, 0, - $tmp_width, $tmp_height, $img_width, $img_height); - - // create temporary thumbnail and locate on the server - $thumb = $thumb_path."thumb_".$img_file; - switch ($img_type) { - case "image/jpeg": - imagejpeg($img_new, $thumb); - break; - case "image/pjpeg": - imagejpeg($img_new, $thumb); - break; - case "image/png": - imagepng($img_new, $thumb); - break; - case "image/x-png": - imagepng($img_new, $thumb); - break; - case "image/gif": - imagegif($img_new, $thumb); - break; + return $o; } - // get tmp_image - switch ($img_type) { - case "image/jpeg": - $img_thumb_square = imagecreatefromjpeg($thumb); - break; - case "image/pjpeg": - $img_thumb_square = imagecreatefromjpeg($thumb); - break; - case "image/png": - $img_thumb_square = imagecreatefrompng($thumb); - break; - case "image/x-png": - $img_thumb_square = imagecreatefrompng($thumb); - break; - case "image/gif": - $img_thumb_square = imagecreatefromgif($thumb); - break; + /** + * getting Save email configuration + * @autor Alvaro + */ + public function saveConfiguration() + { + require_once 'classes/model/Configuration.php'; + try { + $oConfiguration = new Configuration(); + $aFields['MESS_PASSWORD'] = $_POST['passwd']; + + if ($_POST['passwdHide'] != '') { + $aFields['MESS_PASSWORD'] = $_POST['passwdHide']; + } + + $aFields['MESS_PASSWORD_HIDDEN'] = ''; + $passwd = $aFields['MESS_PASSWORD']; + $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); + $auxPass = explode('hash:', $passwdDec); + if (count($auxPass) > 1) { + if (count($auxPass) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift($auxPass); + $passwd = implode('', $auxPass); + } + } + $aFields['MESS_PASSWORD'] = $passwd; + + if ($aFields['MESS_PASSWORD'] != '') { + $aFields['MESS_PASSWORD'] = 'hash:'.$aFields['MESS_PASSWORD']; + $aFields['MESS_PASSWORD'] = G::encrypt($aFields['MESS_PASSWORD'],'EMAILENCRYPT'); + } + + $aFields['MESS_ENABLED'] = isset($_POST['EnableEmailNotifications']) ? $_POST['EnableEmailNotifications'] : ''; + $aFields['MESS_ENABLED'] = ($aFields['MESS_ENABLED'] == 'true') ? '1' : $aFields['MESS_ENABLED']; + $aFields['MESS_ENGINE'] = $_POST['EmailEngine']; + $aFields['MESS_SERVER'] = trim($_POST['server']); + $aFields['MESS_RAUTH'] = isset($_POST['req_auth']) ? $_POST['req_auth'] : ''; + $aFields['MESS_RAUTH'] = ($aFields['MESS_RAUTH'] == 'true') ? '1' : $aFields['MESS_RAUTH']; + $aFields['MESS_PORT'] = $_POST['port']; + $aFields['MESS_ACCOUNT'] = $_POST['from']; + $aFields['MESS_BACKGROUND'] = '';//isset($_POST['background']) ? $_POST['background'] : ''; + $aFields['MESS_EXECUTE_EVERY'] = '';//$_POST['form']['MESS_EXECUTE_EVERY']; + $aFields['MESS_SEND_MAX'] = '';//$_POST['form']['MESS_SEND_MAX']; + $aFields['SMTPSecure'] = $_POST['UseSecureCon']; + $aFields['SMTPSecure'] = ($aFields['SMTPSecure'] == 'No') ? 'none' : $aFields['SMTPSecure']; + $aFields['MAIL_TO'] = $_POST['eMailto']; + $aFields['MESS_TRY_SEND_INMEDIATLY'] = $_POST['SendaTestMail'];//isset($_POST['form']['MESS_TRY_SEND_INMEDIATLY']) ? $_POST['form']['MESS_TRY_SEND_INMEDIATLY'] : ''; + $aFields['MESS_TRY_SEND_INMEDIATLY'] = ($aFields['MESS_TRY_SEND_INMEDIATLY'] == 'true') ? '1' : $aFields['MESS_TRY_SEND_INMEDIATLY']; + $CfgUid='Emails'; + $ObjUid=''; + $ProUid=''; + $UsrUid=''; + $AppUid=''; + + if ($oConfiguration->exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)) { + $oConfiguration->update( + array ( + 'CFG_UID' => 'Emails', + 'OBJ_UID' => '', + 'CFG_VALUE' => serialize($aFields), + 'PRO_UID' => '', + 'USR_UID' => '', + 'APP_UID' => '' + ) + ); + $this->success='true'; + $this->msg='Saved'; + } else { + $oConfiguration->create( + array( + 'CFG_UID' => 'Emails', + 'OBJ_UID' => '', + 'CFG_VALUE' => serialize($aFields), + 'PRO_UID' => '', + 'USR_UID' => '', + 'APP_UID' => '' + ) + ); + $this->success='true'; + $this->msg='Saved'; + } + } catch (Exception $e) { + $this->success= false; + $this->msg = $e->getMessage(); + } } - $thumb_width = imagesx($img_thumb_square); - $thumb_height = imagesy($img_thumb_square); + /** + * loadFields for email configuration + * @autor Alvaro + */ + public function loadFields() + { + G::loadClass('configuration'); - if ($thumb_height < $thumb_width) { - // wide - $x_src = ($thumb_width - $square_size) / 2; - $y_src = 0; - $img_final = imagecreatetruecolor($square_size, $square_size); - imagecopy($img_final, $img_thumb_square, 0, 0, - $x_src, $y_src, $square_size, $square_size); - } - else if ($thumb_height > $thumb_width) { - // landscape - $x_src = 0; - $y_src = ($thumb_height - $square_size) / 2; - $img_final = imagecreatetruecolor($square_size, $square_size); - imagecopy($img_final, $img_thumb_square, 0, 0, - $x_src, $y_src, $square_size, $square_size); - } - else { - $img_final = imagecreatetruecolor($square_size, $square_size); - imagecopy($img_final, $img_thumb_square, 0, 0, - 0, 0, $square_size, $square_size); + $oConfiguration = new Configurations(); + $oConfiguration->loadConfig($x, 'Emails','','','',''); + $fields = $oConfiguration->aConfig; + if (count($fields) > 0) { + $this->success = (count($fields) > 0); + $passwd = $fields['MESS_PASSWORD']; + $passwdDec = G::decrypt($passwd,'EMAILENCRYPT'); + $auxPass = explode('hash:', $passwdDec); + if (count($auxPass) > 1) { + if (count($auxPass) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift($auxPass); + $passwd = implode('', $auxPass); + } + } + $fields['MESS_PASSWORD'] = $passwd; + } + $this->data = $fields; } - switch ($img_type) { - case "image/jpeg": - @imagejpeg($img_final, $thumb); - break; - case "image/pjpeg": - @imagejpeg($img_final, $thumb); - break; - case "image/png": - @imagepng($img_final, $thumb); - break; - case "image/x-png": - @imagepng($img_final, $thumb); - break; - case "image/gif": - @imagegif($img_final, $thumb); - break; + /** + * get List Image + * @param type $httpData + */ + public function getListImage($httpData) + { + G::LoadClass('replacementLogo'); + $uplogo = PATH_TPL . 'setup' . PATH_SEP . 'uplogo.html'; + $width = "100%"; + $upload = new replacementLogo(); + $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); + $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); + $check = ''; + $ainfoSite = explode("/",$_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; + G::mk_dir ( $dir ); + $i = 0; + $images = array(); + + /** if we have at least one image it's load */ + if (file_exists($dir)) { + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if (($file != ".") && ($file != "..")) { + $extention = explode(".", $file); + $aImageProp = getimagesize($dir . '/' . $file, $info); + $sfileExtention = strtoupper($extention[count($extention)-1]); + if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { + $check = (!strcmp($file, $sPhotoSelect)) ? '/images/toadd.png' : '/images/delete.png'; + $onclick = (strcmp($file, $sPhotoSelect)) ? "onclick ='deleteLogo(\" $file \");return false;'" : ''; + if ($i == 0) { + $i++; + } + $i++; + $images[] = array( + 'name' => $file, + 'size' => '0', + 'lastmod' => '32', + 'url' => "../adminProxy/showLogoFile?id=".base64_encode($file), + 'thumb_url' => "../adminProxy/showLogoFile?id=".base64_encode($file) + ); + } + } + } + closedir($handle); + } + } + $o = array('images' => $images); + echo G::json_encode($o); + exit(); } - } - /** - * Upload Image - * @global type $_FILES - */ - function uploadImage() - { - //!dataSystem - $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); - $dir = PATH_DATA."sites".PATH_SEP.str_replace("sys","",$ainfoSite[1]).PATH_SEP."files/logos"; - global $_FILES; + /** + * Change Name logo + * @param type $snameLogo + * @return type $snameLogo + */ + public function changeNamelogo($snameLogo) + { + $snameLogo = preg_replace("/[áàâãª]/", "a", $snameLogo); + $snameLogo = preg_replace("/[ÁÀÂÃ]/", "A", $snameLogo); + $snameLogo = preg_replace("/[ÍÌÎ]/", "I", $snameLogo); + $snameLogo = preg_replace("/[íìî]/", "i", $snameLogo); + $snameLogo = preg_replace("/[éèê]/", "e", $snameLogo); + $snameLogo = preg_replace("/[ÉÈÊ]/", "E", $snameLogo); + $snameLogo = preg_replace("/[óòôõº]/", "o", $snameLogo); + $snameLogo = preg_replace("/[ÓÒÔÕ]/", "O", $snameLogo); + $snameLogo = preg_replace("/[úùû]/", "u", $snameLogo); + $snameLogo = preg_replace("/[ÚÙÛ]/", "U", $snameLogo); + $snameLogo = str_replace( "ç", "c", $snameLogo); + $snameLogo = str_replace( "Ç", "C", $snameLogo); + $snameLogo = str_replace( "[ñ]", "n", $snameLogo); + $snameLogo = str_replace( "[Ñ]", "N", $snameLogo); + return ($snameLogo); + } - //| 0-> non fail - //| 1-> fail in de type of the image - //| 2-> fail in de size of the image - //| 3-> fail in de myme of the image - $failed = 0; - //!dataSystem + /** + * Create Thumb + * @param type $img_file + * @param type $ori_path + * @param type $thumb_path + * @param type $img_type + */ + public function createThumb($img_file, $ori_path, $thumb_path, $img_type) + { + $path = $ori_path; + $img = $path.$img_file; + switch ($img_type) { + case "image/jpeg": + $img_src = @imagecreatefromjpeg($img); + break; + case "image/pjpeg": + $img_src = @imagecreatefromjpeg($img); + break; + case "image/png": + $img_src = @imagecreatefrompng($img); + break; + case "image/x-png": + $img_src = @imagecreatefrompng($img); + break; + case "image/gif": + $img_src = @imagecreatefromgif($img); + break; + } + $img_width = imagesx($img_src); + $img_height = imagesy($img_src); + $square_size = 100; + // check width, height, or square + if ($img_width == $img_height) { + // square + $tmp_width = $square_size; + $tmp_height = $square_size; + } elseif ($img_height < $img_width) { + // wide + $tmp_height = $square_size; + $tmp_width = intval(($img_width / $img_height) * $square_size); + if ($tmp_width % 2 != 0) { + $tmp_width++; + } + } elseif ($img_height > $img_width) { + $tmp_width = $square_size; + $tmp_height = intval(($img_height / $img_width) * $square_size); + if (($tmp_height % 2) != 0) { + $tmp_height++; + } + } + $img_new = imagecreatetruecolor($tmp_width, $tmp_height); + imagecopyresampled($img_new, $img_src, 0, 0, 0, 0, + $tmp_width, $tmp_height, $img_width, $img_height); - $ori_dir = $dir . '/img/ori/'; - $thumb_dir = $dir . '/img/thumbs/'; + // create temporary thumbnail and locate on the server + $thumb = $thumb_path."thumb_".$img_file; + switch ($img_type) { + case "image/jpeg": + imagejpeg($img_new, $thumb); + break; + case "image/pjpeg": + imagejpeg($img_new, $thumb); + break; + case "image/png": + imagepng($img_new, $thumb); + break; + case "image/x-png": + imagepng($img_new, $thumb); + break; + case "image/gif": + imagegif($img_new, $thumb); + break; + } - $allowedType = array( - 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png' - ); - $allowedTypeArray['index' . base64_encode('image/jpg')] = IMAGETYPE_JPEG; - $allowedTypeArray['index' . base64_encode('image/jpeg')] = IMAGETYPE_JPEG; - $allowedTypeArray['index' . base64_encode('image/pjpeg')] = IMAGETYPE_JPEG; - $allowedTypeArray['index' . base64_encode('image/gif')] = IMAGETYPE_GIF; - $allowedTypeArray['index' . base64_encode('image/png')] = IMAGETYPE_PNG; - $allowedTypeArray['index' . base64_encode('image/x-png')] = IMAGETYPE_PNG; + // get tmp_image + switch ($img_type) { + case "image/jpeg": + $img_thumb_square = imagecreatefromjpeg($thumb); + break; + case "image/pjpeg": + $img_thumb_square = imagecreatefromjpeg($thumb); + break; + case "image/png": + $img_thumb_square = imagecreatefrompng($thumb); + break; + case "image/x-png": + $img_thumb_square = imagecreatefrompng($thumb); + break; + case "image/gif": + $img_thumb_square = imagecreatefromgif($thumb); + break; + } + $thumb_width = imagesx($img_thumb_square); + $thumb_height = imagesy($img_thumb_square); + if ($thumb_height < $thumb_width) { + // wide + $x_src = ($thumb_width - $square_size) / 2; + $y_src = 0; + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + $x_src, $y_src, $square_size, $square_size); + } elseif ($thumb_height > $thumb_width) { + // landscape + $x_src = 0; + $y_src = ($thumb_height - $square_size) / 2; + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + $x_src, $y_src, $square_size, $square_size); + } else { + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + 0, 0, $square_size, $square_size); + } - $uploaded = 0; - $failed = 0; + switch ($img_type) { + case "image/jpeg": + @imagejpeg($img_final, $thumb); + break; + case "image/pjpeg": + @imagejpeg($img_final, $thumb); + break; + case "image/png": + @imagepng($img_final, $thumb); + break; + case "image/x-png": + @imagepng($img_final, $thumb); + break; + case "image/gif": + @imagegif($img_final, $thumb); + break; + } + } - if (in_array($_FILES['img']['type'], $allowedType)) { - // max upload file is 500 KB - if ($_FILES['img']['size'] <= 500000) { + /** + * Upload Image + * @global type $_FILES + */ + public function uploadImage() + { + //!dataSystem + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA."sites".PATH_SEP.str_replace("sys","",$ainfoSite[1]).PATH_SEP."files/logos"; + global $_FILES; - $formf = $_FILES['img']; - $namefile = $formf['name']; - $typefile = $formf['type']; - $errorfile = $formf['error']; - $tmpFile = $formf['tmp_name']; - $aMessage1 = array(); - $fileName = trim(str_replace(' ', '_', $namefile)); - $fileName = self::changeNamelogo($fileName); + //| 0-> non fail + //| 1-> fail in de type of the image + //| 2-> fail in de size of the image + //| 3-> fail in de myme of the image + $failed = 0; + //!dataSystem - G::uploadFile($tmpFile, $dir, 'tmp' . $fileName); + $ori_dir = $dir . '/img/ori/'; + $thumb_dir = $dir . '/img/thumbs/'; + + $allowedType = array( + 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png' + ); + $allowedTypeArray['index' . base64_encode('image/jpg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/jpeg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/pjpeg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/gif')] = IMAGETYPE_GIF; + $allowedTypeArray['index' . base64_encode('image/png')] = IMAGETYPE_PNG; + $allowedTypeArray['index' . base64_encode('image/x-png')] = IMAGETYPE_PNG; + + $uploaded = 0; + $failed = 0; + + if (in_array($_FILES['img']['type'], $allowedType)) { + // max upload file is 500 KB + if ($_FILES['img']['size'] <= 500000) { + $formf = $_FILES['img']; + $namefile = $formf['name']; + $typefile = $formf['type']; + $errorfile = $formf['error']; + $tmpFile = $formf['tmp_name']; + $aMessage1 = array(); + $fileName = trim(str_replace(' ', '_', $namefile)); + $fileName = self::changeNamelogo($fileName); + G::uploadFile($tmpFile, $dir, 'tmp' . $fileName); + try { + if (extension_loaded('exif')) { + $typeMime = exif_imagetype($dir . '/'. 'tmp'.$fileName); + } else { + $arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName); + $typeMime = $arrayInfo[2]; + } + if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) { + $error = false; + try { + list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); + G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); + } catch (Exception $e) { + $error = $e->getMessage(); + } + $uploaded++; + } else { + $failed = "3"; + } + unlink ($dir . '/tmp' . $fileName); + } catch (Exception $e) { + $failed = "3"; + } + } else { + $failed = "2"; + } + } elseif ($_FILES['img']['type'] != '') { + $failed = "1"; + } + + echo '{success: true, failed: ' . $failed . ', uploaded: ' . $uploaded . ', type: "' . $_FILES['img']['type'] . '"}'; + exit(); + } + + /** + * Get Name Current Logo + * @return type + */ + public function getNameCurrentLogo() + { + G::LoadClass('replacementLogo'); + $upload = new replacementLogo(); + $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); + $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); + return $sPhotoSelect; + } + + /** + * compare Name Current Logo + * @param type $selectLogo + * @return type int value + */ + public function isCurrentLogo() + { + $arrayImg = explode(";", $_POST['selectLogo']); + foreach ($arrayImg as $imgname) { + if ($imgname != "") { + if ( strcmp($imgname, self::getNameCurrentLogo()) == 0 ) { + echo '{success: true}'; + exit(); + } + } + } + echo '{success: false}'; + exit(); + } + + /** + * + * Delete Image from the list + * @param + * @return string '{success: true | false}' + */ + public function deleteImage() + { + //!dataSystem + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; + global $_FILES; + //!dataSystem + + $dir = $dir; + $dir_thumbs = $dir; + + $arrayImg = explode(";", $_POST['images']); + foreach ($arrayImg as $imgname) { + if ($imgname != "") { + if ( strcmp($imgname, self::getNameCurrentLogo()) != 0 ) { + if (file_exists($dir . '/' . $imgname)) { + unlink ($dir . '/' . $imgname); + } + if (file_exists($dir . '/tmp' . $imgname)) { + unlink ($dir . '/tmp' . $imgname); + } + } else { + echo '{success: false}'; + exit(); + } + } + } + echo '{success: true}'; + exit(); + } + + /** + * Replacement Logo + * @global type $_REQUEST + * @global type $RBAC + */ + public function replacementLogo() + { + global $_REQUEST; + $sfunction = $_REQUEST['nameFunction']; + $_GET['NAMELOGO'] = $_REQUEST['NAMELOGO']; try { - if (extension_loaded('exif')) { - $typeMime = exif_imagetype($dir . '/'. 'tmp'.$fileName); - } - else { - $arrayInfo = getimagesize($dir . '/' . 'tmp' . $fileName); - $typeMime = $arrayInfo[2]; - } - - if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) { - $error = false; - try { - list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); - G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); + global $RBAC; + switch ($RBAC->userCanAccess('PM_LOGIN')) { + case -2: + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); + G::header('location: ../login/login'); + die; + break; + case -1: + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); + G::header('location: ../login/login'); + die; + break; } - catch (Exception $e) { - $error = $e->getMessage(); + + switch ($sfunction) { + case 'replacementLogo': + $snameLogo = urldecode($_GET['NAMELOGO']); + $snameLogo = trim($snameLogo); + $snameLogo = self::changeNamelogo($snameLogo); + G::loadClass('configuration'); + $oConf = new Configurations; + $aConf = Array( + 'WORKSPACE_LOGO_NAME' => SYS_SYS, + 'DEFAULT_LOGO_NAME' => $snameLogo + ); + + $oConf->aConfig = $aConf; + $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); + + G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); + break; + case 'restoreLogo': + $snameLogo = $_GET['NAMELOGO']; + G::loadClass('configuration'); + $oConf = new Configurations; + $aConf = Array( + 'WORKSPACE_LOGO_NAME' => '', + 'DEFAULT_LOGO_NAME' => '' + ); + + $oConf->aConfig = $aConf; + $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); + + G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); + break; } - $uploaded++; - } - else { - $failed = "3"; - } - unlink ($dir . '/tmp' . $fileName); + } catch (Exception $oException) { + die($oException->getMessage()); } - catch (Exception $e) { - $failed = "3"; + exit(); + } + + /** + * Show Logo + * @param type $imagen + */ + public function showLogo($imagen) + { + $info = @getimagesize($imagen); + $fp = fopen($imagen, "rb"); + if ($info && $fp) { + header("Content-type: {$info['mime']}"); + fpassthru($fp); + exit; + } else { + throw new Exception("Image format not valid"); } - } - else { - $failed = "2"; - } - } - else if ($_FILES['img']['type'] != '') { - $failed = "1"; } - echo '{success: true, failed: ' . $failed . ', uploaded: ' . $uploaded . ', type: "' . $_FILES['img']['type'] . '"}'; - exit(); - } - - /** - * Get Name Current Logo - * @return type - */ - function getNameCurrentLogo() - { - G::LoadClass('replacementLogo'); - $upload = new replacementLogo(); - $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); - $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); - return $sPhotoSelect; - } - - /** - * compare Name Current Logo - * @param type $selectLogo - * @return type int value - */ - function isCurrentLogo() - { - $arrayImg = explode(";", $_POST['selectLogo']); - foreach ($arrayImg as $imgname) { - if ($imgname != "") { - if( strcmp($imgname, self::getNameCurrentLogo()) == 0 ) { - echo '{success: true}'; - exit(); - } - } - } - echo '{success: false}'; - exit(); - } - - /** - * - * Delete Image from the list - * @param - * @return string '{success: true | false}' - */ - function deleteImage() - { - //!dataSystem - $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); - $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; - global $_FILES; - //!dataSystem - - $dir = $dir; - $dir_thumbs = $dir; - - $arrayImg = explode(";", $_POST['images']); - foreach ($arrayImg as $imgname) { - if ($imgname != "") { - if( strcmp($imgname, self::getNameCurrentLogo()) != 0 ) { - if(file_exists($dir . '/' . $imgname)) { - unlink ($dir . '/' . $imgname); - } - if(file_exists($dir . '/tmp' . $imgname)) { - unlink ($dir . '/tmp' . $imgname); - } - } - else { - echo '{success: false}'; - exit(); - } - } - } - echo '{success: true}'; - exit(); - } - - /** - * Replacement Logo - * @global type $_REQUEST - * @global type $RBAC - */ - function replacementLogo() - { - global $_REQUEST; - $sfunction = $_REQUEST['nameFunction']; - $_GET['NAMELOGO'] = $_REQUEST['NAMELOGO']; - - try {//ini_set('display_errors','1'); - global $RBAC; - switch ($RBAC->userCanAccess('PM_LOGIN')) { - case -2: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - case -1: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - } - - switch ($sfunction) { - case 'replacementLogo': - $snameLogo = urldecode($_GET['NAMELOGO']); - $snameLogo = trim($snameLogo); - $snameLogo = self::changeNamelogo($snameLogo); - G::loadClass('configuration'); - $oConf = new Configurations; - $aConf = Array( - 'WORKSPACE_LOGO_NAME' => SYS_SYS, - 'DEFAULT_LOGO_NAME' => $snameLogo - ); - - $oConf->aConfig = $aConf; - $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); - - G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); - break; - case 'restoreLogo': - $snameLogo = $_GET['NAMELOGO']; - G::loadClass('configuration'); - $oConf = new Configurations; - $aConf = Array( - 'WORKSPACE_LOGO_NAME' => '', - 'DEFAULT_LOGO_NAME' => '' - ); - - $oConf->aConfig = $aConf; - $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); - - G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); - break; - } - } - catch (Exception $oException) { - die($oException->getMessage()); - } - exit(); - } - - /** - * Show Logo - * @param type $imagen - */ - function showLogo($imagen) - { - $info = @getimagesize($imagen); - $fp = fopen($imagen, "rb"); - if ($info && $fp) { - header("Content-type: {$info['mime']}"); - fpassthru($fp); - exit; - } - else { - throw new Exception("Image format not valid"); - } - } - - /** - * Copy More Logos - * @param type $dir - * @param type $newDir - */ - function cpyMoreLogos($dir,$newDir) - { - if (file_exists($dir)) { - if (($handle = opendir($dir))) { - while (false !== ($file = readdir($handle))) { - if (($file != ".") && ($file != "..")) { - $extention = explode(".", $file); - $aImageProp = getimagesize($dir . '/' . $file, $info); - $sfileExtention = strtoupper($extention[count($extention)-1]); - if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { - - $dir1 = $dir . PATH_SEP . $file; - $dir2 = $newDir . PATH_SEP . $file; - copy($dir1, $dir2); + /** + * Copy More Logos + * @param type $dir + * @param type $newDir + */ + public function cpyMoreLogos($dir, $newDir) + { + if (file_exists($dir)) { + if (($handle = opendir($dir))) { + while (false !== ($file = readdir($handle))) { + if (($file != ".") && ($file != "..")) { + $extention = explode(".", $file); + $aImageProp = getimagesize($dir . '/' . $file, $info); + $sfileExtention = strtoupper($extention[count($extention)-1]); + if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { + $dir1 = $dir . PATH_SEP . $file; + $dir2 = $newDir . PATH_SEP . $file; + copy($dir1, $dir2); + } + } + } + closedir($handle); } - } } - closedir($handle); - } } - } - /** - * Show Logo File - */ - function showLogoFile() - { - $_GET['id'] = $_REQUEST['id']; + /** + * Show Logo File + */ + public function showLogoFile() + { + $_GET['id'] = $_REQUEST['id']; - $base64Id = base64_decode($_GET['id']); - $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); - $dir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; - $imagen = $dir . PATH_SEP . $base64Id; + $base64Id = base64_decode($_GET['id']); + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; + $imagen = $dir . PATH_SEP . $base64Id; - if (is_file($imagen)) { - self::showLogo($imagen); - } - else { - $newDir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; - $dir = PATH_HOME . "public_html/files/logos"; + if (is_file($imagen)) { + self::showLogo($imagen); + } else { + $newDir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; + $dir = PATH_HOME . "public_html/files/logos"; - if (!is_dir($newDir)) { - G::mk_dir($newDir); + if (!is_dir($newDir)) { + G::mk_dir($newDir); + } + $newDir .= PATH_SEP.$base64Id; + $dir .= PATH_SEP.$base64Id; + copy($dir,$newDir); + self::showLogo($newDir); + die; } - //this function does copy all logos from public_html/files/logos to /shared/site/yourSite/files/logos - //cpyMoreLogos($dir,$newDir); - $newDir .= PATH_SEP.$base64Id; - $dir .= PATH_SEP.$base64Id; - copy($dir,$newDir); - self::showLogo($newDir); die; - } - die; - exit(); - } - + exit(); + } } + diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 397d5a5af..35c120bab 100755 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -1,242 +1,221 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/** - * - * @author Erik Amaru Ortiz - * @date Jan 3th, 2010 - */ - -require_once 'classes/model/Application.php'; -require_once 'classes/model/Users.php'; -require_once 'classes/model/AppThread.php'; -require_once 'classes/model/AppDelay.php'; -require_once 'classes/model/Process.php'; -require_once 'classes/model/Task.php'; -G::LoadClass( 'case' ); - -$action = $_REQUEST['action']; -unset( $_REQUEST['action'] ); -$ajax = new Ajax(); -$ajax->$action( $_REQUEST ); - -class Ajax -{ - - function getCaseMenu ($params) - { - - G::LoadClass( "configuration" ); - G::LoadClass( "case" ); - global $G_TMP_MENU; - global $sStatus; - $sStatus = $params['app_status']; - $oCase = new Cases(); - $conf = new Configurations(); - $oMenu = new Menu(); - $oMenu->load( 'caseOptions' ); - - $menuOptions = Array (); - foreach ($oMenu->Options as $i => $action) { - $option = Array ('id' => $oMenu->Id[$i],'label' => $oMenu->Labels[$i],'action' => $action - ); - - switch ($option['id']) { - case 'STEPS': - $option['options'] = Array (); - break; - case 'ACTIONS': - $option['options'] = $this->getActionOptions(); - break; - case 'INFO': - $option['options'] = $this->getInformationOptions(); - break; - } - $menuOptions[] = $option; - } - - echo G::json_encode( $menuOptions ); - } - - function steps () - { - G::LoadClass( 'applications' ); - $applications = new Applications(); - - $proUid = isset( $_SESSION['PROCESS'] ) ? $_SESSION['PROCESS'] : ''; - $tasUid = isset( $_SESSION['TASK'] ) ? $_SESSION['TASK'] : ''; - $appUid = isset( $_SESSION['APPLICATION'] ) ? $_SESSION['APPLICATION'] : ''; - $index = isset( $_SESSION['INDEX'] ) ? $_SESSION['INDEX'] : ''; - $steps = $applications->getSteps( $appUid, $index, $tasUid, $proUid ); - $list = array (); - - foreach ($steps as $step) { - $item['id'] = $item['idtodraw'] = $step['id']; - $item['draggable'] = false; - $item['leaf'] = true; - $item['hrefTarget'] = 'casesSubFrame'; - $item['text'] = $step['title']; - $item['url'] = '../' . $step['url']; - - switch ($step['type']) { - case 'DYNAFORM': - $item['iconCls'] = 'ss_sprite ss_application_form'; - break; - case 'OUTPUT_DOCUMENT': - $item['iconCls'] = 'ss_sprite ss_application_put'; - break; - case 'INPUT_DOCUMENT': - $item['iconCls'] = 'ss_sprite ss_application_get'; - break; - case 'EXTERNAL': - $item['iconCls'] = 'ss_sprite ss_application_view_detail'; - break; - default: - $item['iconCls'] = 'ICON_ASSIGN_TASK'; - } - - $list[] = $item; - } - - echo G::json_encode( $list ); - } - - function getInformationOptions () - { - $options = Array (); - $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_MAP' ),'fn' => 'processMap' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_INFORMATION' ),'fn' => 'processInformation' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_TASK_INFORMATION' ),'fn' => 'taskInformation' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_CASE_HISTORY' ),'fn' => 'caseHistory' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_HISTORY_MESSAGE_CASE' ),'fn' => 'messageHistory' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_DYNAFORMS' ),'fn' => 'dynaformHistory' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_UPLOADED_DOCUMENTS' ),'fn' => 'uploadedDocuments' - ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_GENERATED_DOCUMENTS' ),'fn' => 'generatedDocuments' - ); - - return $options; - } - - function getActionOptions () - { - $APP_UID = $_SESSION['APPLICATION']; - - $c = new Criteria( 'workflow' ); - $c->clearSelectColumns(); - $c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT ); - $c->add( AppThreadPeer::APP_UID, $APP_UID ); - $c->add( AppThreadPeer::APP_THREAD_STATUS, 'OPEN' ); - $cant = AppThreadPeer::doCount( $c ); - - $oCase = new Cases(); - $aFields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); - - GLOBAL $RBAC; - - $options = Array (); - - switch ($aFields['APP_STATUS']) { - case 'DRAFT': - if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate' - ); - } else { - $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase' - ); - } - - $options[] = Array ('text' => G::LoadTranslation( 'ID_DELETE' ),'fn' => 'deleteCase' - ); - - if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign' - ); - } - break; - - case 'TO_DO': - if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate' - ); - if ($cant == 1) { - if ($RBAC->userCanAccess( 'PM_CANCELCASE' ) == 1) - $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase' - ); - else - $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase','hide' => 'hiden' - ); - } - } else { - $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase' - ); - } - if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign' - ); - } - break; - - case 'CANCELLED': - $options[] = Array ('text' => G::LoadTranslation( 'ID_REACTIVATE' ),'fn' => 'reactivateCase' - ); - break; - } - - if ($_SESSION['TASK'] != '-1') { - $oTask = new Task(); - $aTask = $oTask->load( $_SESSION['TASK'] ); - if ($aTask['TAS_TYPE'] == 'ADHOC') { - $options[] = Array ('text' => G::LoadTranslation( 'ID_ADHOC_ASSIGNMENT' ),'fn' => 'adhocAssignmentUsers' - ); - } - } - return $options; - } - - function processMap () - { - global $G_PUBLISH; - global $G_CONTENT; - global $G_FORM; - global $G_TABLE; - global $RBAC; - - G::LoadClass( 'processMap' ); - - $oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); - $oTemplatePower->prepare(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); - $oHeadPublisher = & headPublisher::getSingleton(); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/** + * + * @author Erik Amaru Ortiz + * @date Jan 3th, 2010 + */ + +require_once 'classes/model/Application.php'; +require_once 'classes/model/Users.php'; +require_once 'classes/model/AppThread.php'; +require_once 'classes/model/AppDelay.php'; +require_once 'classes/model/Process.php'; +require_once 'classes/model/Task.php'; +G::LoadClass( 'case' ); + +$action = $_REQUEST['action']; +unset( $_REQUEST['action'] ); +$ajax = new Ajax(); +$ajax->$action( $_REQUEST ); + +class Ajax +{ + + public function getCaseMenu ($params) + { + + G::LoadClass( "configuration" ); + G::LoadClass( "case" ); + global $G_TMP_MENU; + global $sStatus; + $sStatus = $params['app_status']; + $oCase = new Cases(); + $conf = new Configurations(); + $oMenu = new Menu(); + $oMenu->load( 'caseOptions' ); + + $menuOptions = Array (); + foreach ($oMenu->Options as $i => $action) { + $option = Array ('id' => $oMenu->Id[$i],'label' => $oMenu->Labels[$i],'action' => $action); + + switch ($option['id']) { + case 'STEPS': + $option['options'] = Array (); + break; + case 'ACTIONS': + $option['options'] = $this->getActionOptions(); + break; + case 'INFO': + $option['options'] = $this->getInformationOptions(); + break; + } + $menuOptions[] = $option; + } + + echo G::json_encode( $menuOptions ); + } + + public function steps () + { + G::LoadClass( 'applications' ); + $applications = new Applications(); + + $proUid = isset( $_SESSION['PROCESS'] ) ? $_SESSION['PROCESS'] : ''; + $tasUid = isset( $_SESSION['TASK'] ) ? $_SESSION['TASK'] : ''; + $appUid = isset( $_SESSION['APPLICATION'] ) ? $_SESSION['APPLICATION'] : ''; + $index = isset( $_SESSION['INDEX'] ) ? $_SESSION['INDEX'] : ''; + $steps = $applications->getSteps( $appUid, $index, $tasUid, $proUid ); + $list = array (); + + foreach ($steps as $step) { + $item['id'] = $item['idtodraw'] = $step['id']; + $item['draggable'] = false; + $item['leaf'] = true; + $item['hrefTarget'] = 'casesSubFrame'; + $item['text'] = $step['title']; + $item['url'] = '../' . $step['url']; + + switch ($step['type']) { + case 'DYNAFORM': + $item['iconCls'] = 'ss_sprite ss_application_form'; + break; + case 'OUTPUT_DOCUMENT': + $item['iconCls'] = 'ss_sprite ss_application_put'; + break; + case 'INPUT_DOCUMENT': + $item['iconCls'] = 'ss_sprite ss_application_get'; + break; + case 'EXTERNAL': + $item['iconCls'] = 'ss_sprite ss_application_view_detail'; + break; + default: + $item['iconCls'] = 'ICON_ASSIGN_TASK'; + } + + $list[] = $item; + } + + echo G::json_encode( $list ); + } + + public function getInformationOptions () + { + $options = Array (); + $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_MAP' ),'fn' => 'processMap' ); + $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_INFORMATION' ),'fn' => 'processInformation'); + $options[] = Array ('text' => G::LoadTranslation( 'ID_TASK_INFORMATION' ),'fn' => 'taskInformation'); + $options[] = Array ('text' => G::LoadTranslation( 'ID_CASE_HISTORY' ),'fn' => 'caseHistory'); + $options[] = Array ('text' => G::LoadTranslation( 'ID_HISTORY_MESSAGE_CASE' ),'fn' => 'messageHistory'); + $options[] = Array ('text' => G::LoadTranslation( 'ID_DYNAFORMS' ),'fn' => 'dynaformHistory' ); + $options[] = Array ('text' => G::LoadTranslation( 'ID_UPLOADED_DOCUMENTS' ),'fn' => 'uploadedDocuments'); + $options[] = Array ('text' => G::LoadTranslation( 'ID_GENERATED_DOCUMENTS' ),'fn' => 'generatedDocuments'); + + return $options; + } + + public function getActionOptions () + { + $APP_UID = $_SESSION['APPLICATION']; + + $c = new Criteria( 'workflow' ); + $c->clearSelectColumns(); + $c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT ); + $c->add( AppThreadPeer::APP_UID, $APP_UID ); + $c->add( AppThreadPeer::APP_THREAD_STATUS, 'OPEN' ); + $cant = AppThreadPeer::doCount( $c ); + + $oCase = new Cases(); + $aFields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + + GLOBAL $RBAC; + + $options = Array (); + + switch ($aFields['APP_STATUS']) { + case 'DRAFT': + if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { + $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); + } else { + $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); + } + + $options[] = Array ('text' => G::LoadTranslation( 'ID_DELETE' ),'fn' => 'deleteCase'); + + if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { + $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); + } + break; + case 'TO_DO': + if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { + $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); + if ($cant == 1) { + if ($RBAC->userCanAccess( 'PM_CANCELCASE' ) == 1) { + $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase'); + } else { + $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase','hide' => 'hiden'); + } + } + } else { + $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); + } + if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { + $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); + } + break; + case 'CANCELLED': + $options[] = Array ('text' => G::LoadTranslation( 'ID_REACTIVATE' ),'fn' => 'reactivateCase'); + break; + } + + if ($_SESSION['TASK'] != '-1') { + $oTask = new Task(); + $aTask = $oTask->load( $_SESSION['TASK'] ); + if ($aTask['TAS_TYPE'] == 'ADHOC') { + $options[] = Array ('text' => G::LoadTranslation( 'ID_ADHOC_ASSIGNMENT' ),'fn' => 'adhocAssignmentUsers'); + } + } + return $options; + } + + public function processMap () + { + global $G_PUBLISH; + global $G_CONTENT; + global $G_FORM; + global $G_TABLE; + global $RBAC; + + G::LoadClass( 'processMap' ); + + $oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); + $oTemplatePower->prepare(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); + $oHeadPublisher = & headPublisher::getSingleton(); + //$oHeadPublisher->addScriptfile('/jscore/processmap/core/processmap.js'); $oHeadPublisher->addScriptCode( ' var maximunX = ' . processMap::getMaximunTaskX( $_SESSION['PROCESS'] ) . '; @@ -317,362 +296,368 @@ class Ajax oLeyendsPanel.addContent(rpc.xmlhttp.responseText); }.extend(this); oRPC.make(); - }' ); - - G::RenderPage( 'publish', 'blank' ); - } - - function getProcessInformation () - { - $process = new Process(); - $processData = $process->load( $_SESSION['PROCESS'] ); - require_once 'classes/model/Users.php'; - $user = new Users(); - try { - $userData = $user->load( $processData['PRO_CREATE_USER'] ); - $processData['PRO_AUTHOR'] = $userData['USR_FIRSTNAME'] . ' ' . $userData['USR_LASTNAME']; - } catch (Exception $oError) { - $processData['PRO_AUTHOR'] = '(USER DELETED)'; - } - - $processData['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $processData['PRO_CREATE_DATE'] ) ); - - print (G::json_encode( $processData )) ; - } - - function getTaskInformation () - { - $task = new Task(); - if ($_SESSION['TASK'] == '-1') - $_SESSION['TASK'] = $_SESSION['CURRENT_TASK']; - $taskData = $task->getDelegatedTaskData( $_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); - - print (G::json_encode( $taskData )) ; - } - - function caseHistory () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); + }' ); + + G::RenderPage( 'publish', 'blank' ); + } + + public function getProcessInformation () + { + $process = new Process(); + $processData = $process->load( $_SESSION['PROCESS'] ); + require_once 'classes/model/Users.php'; + $user = new Users(); + try { + $userData = $user->load( $processData['PRO_CREATE_USER'] ); + $processData['PRO_AUTHOR'] = $userData['USR_FIRSTNAME'] . ' ' . $userData['USR_LASTNAME']; + } catch (Exception $oError) { + $processData['PRO_AUTHOR'] = '(USER DELETED)'; + } + + $processData['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $processData['PRO_CREATE_DATE'] ) ); + + print (G::json_encode( $processData )) ; + } + + public function getTaskInformation () + { + $task = new Task(); + if ($_SESSION['TASK'] == '-1') { + $_SESSION['TASK'] = $_SESSION['CURRENT_TASK']; + } + $taskData = $task->getDelegatedTaskData( $_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + + print (G::json_encode( $taskData )) ; + } + + public function caseHistory () + { + global $G_PUBLISH; + G::loadClass( 'configuration' ); + + $oHeadPublisher = & headPublisher::getSingleton(); + $conf = new Configurations(); $oHeadPublisher->addExtJsScript( 'cases/caseHistory', true ); //adding a javascript file .js $oHeadPublisher->addContent( 'cases/caseHistory' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function messageHistory () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); + $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); + G::RenderPage( 'publish', 'extJs' ); + } + + public function messageHistory () + { + global $G_PUBLISH; + G::loadClass( 'configuration' ); + + $oHeadPublisher = & headPublisher::getSingleton(); + $conf = new Configurations(); $oHeadPublisher->addExtJsScript( 'cases/caseMessageHistory', true ); //adding a javascript file .js $oHeadPublisher->addContent( 'cases/caseMessageHistory' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function dynaformHistory () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); + $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); + G::RenderPage( 'publish', 'extJs' ); + } + + public function dynaformHistory () + { + global $G_PUBLISH; + G::loadClass( 'configuration' ); + + $oHeadPublisher = & headPublisher::getSingleton(); + $conf = new Configurations(); $oHeadPublisher->addExtJsScript( 'cases/caseHistoryDynaformPage', true ); //adding a javascript file .js $oHeadPublisher->addContent( 'cases/caseHistoryDynaformPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function uploadedDocuments () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function uploadedDocumentsSummary () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function generatedDocuments () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function generatedDocumentsSummary () - { - global $G_PUBLISH; - G::loadClass( 'configuration' ); - - $oHeadPublisher = & headPublisher::getSingleton(); - $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); - } - - function cancelCase () - { - $oCase = new Cases(); - $multiple = false; - - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { - $APP_UID = $_POST['APP_UID']; - $DEL_INDEX = $_POST['DEL_INDEX']; - - $appUids = explode( ',', $APP_UID ); - $delIndexes = explode( ',', $DEL_INDEX ); - if (count( $appUids ) > 1 && count( $delIndexes ) > 1) - $multiple = true; - } else if (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { - $APP_UID = $_POST['sApplicationUID']; - $DEL_INDEX = $_POST['iIndex']; - } else { - $APP_UID = $_SESSION['APPLICATION']; - $DEL_INDEX = $_SESSION['INDEX']; - } - - // Save the note pause reason - if ($_POST['NOTE_REASON'] != '') { - require_once ("classes/model/AppNotes.php"); - $appNotes = new AppNotes(); - $noteContent = addslashes( $_POST['NOTE_REASON'] ); - $appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE'] ); - } - // End save - - - if ($multiple) { - foreach ($appUids as $i => $appUid) - $oCase->cancelCase( $appUid, $delIndexes[$i], $_SESSION['USER_LOGGED'] ); - } else - $oCase->cancelCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'] ); - } - - function getUsersToReassign () - { - $case = new Cases(); - $result->data = $case->getUsersToReassign( $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - - print G::json_encode( $result ); - - } - - function reassignCase () - { - $cases = new Cases(); - $user = new Users(); - $app = new Application(); - - $TO_USR_UID = $_POST['USR_UID']; - try { - $cases->reassignCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID ); - $caseData = $app->load( $_SESSION['APPLICATION'] ); - $userData = $user->load( $TO_USR_UID ); - //print_r($caseData); - $data['APP_NUMBER'] = $caseData['APP_NUMBER']; - $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf - $result->status = 0; - $result->msg = G::LoadTranslation( 'ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data ); - } catch (Exception $e) { - $result->status = 1; - $result->msg = $e->getMessage(); - } - - print G::json_encode( $result ); - } - - function pauseCase () - { - try { - $unpauseDate = $_REQUEST['unpauseDate']; - $oCase = new Cases(); - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { - $APP_UID = $_POST['APP_UID']; - $DEL_INDEX = $_POST['DEL_INDEX']; - } else if (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { - $APP_UID = $_POST['sApplicationUID']; - $DEL_INDEX = $_POST['iIndex']; - } else { - $APP_UID = $_SESSION['APPLICATION']; - $DEL_INDEX = $_SESSION['INDEX']; - } - - // Save the note pause reason - if ($_REQUEST['NOTE_REASON'] != '') { - require_once ("classes/model/AppNotes.php"); - $appNotes = new AppNotes(); - $noteContent = addslashes( $_REQUEST['NOTE_REASON'] ); - $appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE'] ); - } - // End save - - - $oCase->pauseCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate ); - $app = new Application(); - $caseData = $app->load( $APP_UID ); - $data['APP_NUMBER'] = $caseData['APP_NUMBER']; - $data['UNPAUSE_DATE'] = $unpauseDate; - - $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data ); - } catch (Exception $e) { - $result->success = false; - $result->msg = $e->getMessage(); - } - echo G::json_encode( $result ); - } - - function unpauseCase () - { - try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; - $delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; - $oCase = new Cases(); - $oCase->unpauseCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); - - $app = new Application(); - $caseData = $app->load( $applicationUID ); - $data['APP_NUMBER'] = $caseData['APP_NUMBER']; - - $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_UNPAUSED_SUCCESSFULLY', SYS_LANG, $data ); - } catch (Exception $e) { - $result->success = false; - $result->msg = $e->getMessage(); - } - - print G::json_encode( $result ); - } - - function deleteCase () - { - try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; - $app = new Application(); - $caseData = $app->load( $applicationUID ); - $data['APP_NUMBER'] = $caseData['APP_NUMBER']; - - $oCase = new Cases(); - $oCase->removeCase( $applicationUID ); - - $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_DELETED_SUCCESSFULLY', SYS_LANG, $data ); - } catch (Exception $e) { - $result->success = false; - $result->msg = $e->getMessage(); - } - print G::json_encode( $result ); - } - - function reactivateCase () - { - try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; - $delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; - $app = new Application(); - $caseData = $app->load( $applicationUID ); - $data['APP_NUMBER'] = $caseData['APP_NUMBER']; - - $oCase = new Cases(); - $oCase->reactivateCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); - - $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, $data ); - } catch (Exception $e) { - $result->success = false; - $result->msg = $e->getMessage(); - } - - print G::json_encode( $result ); - } - - function changeLogTab () - { - try { - global $G_PUBLISH; - require_once 'classes/model/AppHistory.php'; - - //!dataInput - $idHistory = $_REQUEST["idHistory"]; - //!dataInput - - - //!dataSytem - $idHistoryArray = explode( "_", $idHistory ); - $_REQUEST["PRO_UID"] = $idHistoryArray[0]; - $_REQUEST["APP_UID"] = $idHistoryArray[1]; - $_REQUEST["TAS_UID"] = $idHistoryArray[2]; - $_REQUEST["DYN_UID"] = ""; - - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_DynaformHistory' ); - ?> - - - + success = true; + $result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success" ); + } catch (Exception $e) { + $result->success = false; + $result->msg = $e->getMessage(); + } + } + + public function dynaformViewFromHistory () + { + ?> + + + -success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success" ); - } catch (Exception $e) { - $result->success = false; - $result->msg = $e->getMessage(); - } - } - - function dynaformViewFromHistory () - { - ?> - + - //!Code that simulated reload library javascript maborak - var leimnud = {}; - leimnud.exec = ""; - leimnud.fix = {}; - leimnud.fix.memoryLeak = ""; - leimnud.browser = {}; - leimnud.browser.isIphone = ""; - leimnud.iphone = {}; - leimnud.iphone.make = function () {}; - function ajax_function(ajax_server, funcion, parameters, method) - { - } - //! - + $_POST["HISTORY_ID"] = $_REQUEST["HISTORY_ID"]; + $_POST["DYN_UID"] = $_REQUEST["DYN_UID"]; -AddContent( "dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view" ); + $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP_LABEL"] = ""; + $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP_LABEL"] = ""; + $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_STEP"] = "#"; + $Fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["NEXT_ACTION"] = "return false;"; + $G_PUBLISH->AddContent( "dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view" ); ?> - + + + + + + + + - - - - - - - -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -$actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null; - -if ($actionAjax == 'historyGridList_JXP') { - - G::LoadClass( 'case' ); - G::LoadClass( "BasePeer" ); - - global $G_PUBLISH; - $c = Cases::getTransferHistoryCriteria( $_SESSION['APPLICATION'] ); - - $result = new stdClass(); - $aProcesses = Array (); - - $rs = GulliverBasePeer::doSelectRs( $c ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - for ($j = 0; $j < $rs->getRecordCount(); $j ++) { - $result = $rs->getRow(); - $result["ID_HISTORY"] = $result["PRO_UID"] . '_' . $result["APP_UID"] . '_' . $result["TAS_UID"]; - $aProcesses[] = $result; - $rs->next(); - } - - $newDir = '/tmp/test/directory'; - $r = G::verifyPath( $newDir ); - $r->data = $aProcesses; - $r->totalCount = 2; - - echo G::json_encode( $r ); -} - -if ($actionAjax == 'historyGridListChangeLogPanelBody_JXP') { - //!dataInput - $idHistory = $_REQUEST["idHistory"]; - //!dataInput - - - //!dataSytem - $idHistoryArray = explode( "*", $idHistory ); - $_REQUEST["PRO_UID"] = $idHistoryArray[0]; - $_REQUEST["APP_UID"] = $idHistoryArray[1]; - $_REQUEST["TAS_UID"] = $idHistoryArray[2]; - $_REQUEST["DYN_UID"] = ""; - - ?> - - - - - - -AddContent( 'view', 'cases/cases_DynaformHistory' ); - G::RenderPage( 'publish', 'raw' ); - ?> - - - - - - - - - - - - - - - - - - - - - - - - OK - - - - - - - - - - - - - -getNewCriterion( ContentPeer::CON_ID, $idDin ); - $c1 = $c->getNewCriterion( ContentPeer::CON_CATEGORY, 'DYN_TITLE' ); - $c0->addAnd( $c1 ); - $c->add( $c0 ); - $contentObjeto = ContentPeer::doSelectOne( $c ); - - if (is_object( $contentObjeto )) { - $dynTitle = $contentObjeto->getConValue(); - } - - $md5Hash = md5( $idDin . $dynDate ); - - //assign task - $result = new stdClass(); - $result->dynTitle = $dynTitle; - $result->md5Hash = $md5Hash; - - echo G::json_encode( $result ); - -} - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +$actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null; + +if ($actionAjax == 'historyGridList_JXP') { + + G::LoadClass( 'case' ); + G::LoadClass( "BasePeer" ); + + global $G_PUBLISH; + $c = Cases::getTransferHistoryCriteria( $_SESSION['APPLICATION'] ); + + $result = new stdClass(); + $aProcesses = Array (); + + $rs = GulliverBasePeer::doSelectRs( $c ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + for ($j = 0; $j < $rs->getRecordCount(); $j ++) { + $result = $rs->getRow(); + $result["ID_HISTORY"] = $result["PRO_UID"] . '_' . $result["APP_UID"] . '_' . $result["TAS_UID"]; + $aProcesses[] = $result; + $rs->next(); + } + + $newDir = '/tmp/test/directory'; + $r = G::verifyPath( $newDir ); + $r->data = $aProcesses; + $r->totalCount = 2; + + echo G::json_encode( $r ); +} + +if ($actionAjax == 'historyGridListChangeLogPanelBody_JXP') { + //!dataInput + $idHistory = $_REQUEST["idHistory"]; + //!dataInput + + + //!dataSytem + $idHistoryArray = explode( "*", $idHistory ); + $_REQUEST["PRO_UID"] = $idHistoryArray[0]; + $_REQUEST["APP_UID"] = $idHistoryArray[1]; + $_REQUEST["TAS_UID"] = $idHistoryArray[2]; + $_REQUEST["DYN_UID"] = ""; + + ?> + + + + + + AddContent( 'view', 'cases/cases_DynaformHistory' ); + G::RenderPage( 'publish', 'raw' ); + ?> + + + + + + + + + + + + + + + + + OK + + + + + + + + + + + + + + getNewCriterion( ContentPeer::CON_ID, $idDin ); + $c1 = $c->getNewCriterion( ContentPeer::CON_CATEGORY, 'DYN_TITLE' ); + $c0->addAnd( $c1 ); + $c->add( $c0 ); + $contentObjeto = ContentPeer::doSelectOne( $c ); + + if (is_object( $contentObjeto )) { + $dynTitle = $contentObjeto->getConValue(); + } + + $md5Hash = md5( $idDin . $dynDate ); + + //assign task + $result = new stdClass(); + $result->dynTitle = $dynTitle; + $result->md5Hash = $md5Hash; + + echo G::json_encode( $result ); + +} + diff --git a/workflow/engine/methods/cases/caseMessageHistory_Ajax.php b/workflow/engine/methods/cases/caseMessageHistory_Ajax.php index 18502b24a..e1d0aa199 100644 --- a/workflow/engine/methods/cases/caseMessageHistory_Ajax.php +++ b/workflow/engine/methods/cases/caseMessageHistory_Ajax.php @@ -1,175 +1,175 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -$actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null; - -if ($actionAjax == 'messageHistoryGridList_JXP') { - - G::LoadClass( 'case' ); - G::LoadClass( "BasePeer" ); - - global $G_PUBLISH; - $oCase = new Cases(); - - $appMessageArray = $oCase->getHistoryMessagesTrackerExt( $_SESSION['APPLICATION'] ); - - $result = new stdClass(); - $aProcesses = Array (); - - $totalCount = 0; - foreach ($appMessageArray as $index => $value) { - $appMessageArray[$index]['ID_MESSAGE'] = $appMessageArray[$index]['APP_UID'] . '_' . $appMessageArray[$index]['APP_MSG_UID']; - $aProcesses[] = $appMessageArray[$index]; - $totalCount ++; - } - - $newDir = '/tmp/test/directory'; - $r = G::verifyPath( $newDir ); - $r->data = $aProcesses; - $r->totalCount = $totalCount; - - echo G::json_encode( $r ); -} -if ($actionAjax == 'showHistoryMessage') { - - ?> - - - -AddContent( 'xmlform', 'xmlform', 'cases/cases_MessagesView', '', $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ) ); - - ?> - -getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ); - //print_r($data); - - - $oConfiguration = new Configuration(); - $sDelimiter = DBAdapter::getStringDelimiter(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); - $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); - $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); - $oCriteria->add( ConfigurationPeer::USR_UID, '' ); - $oCriteria->add( ConfigurationPeer::APP_UID, '' ); - if (ConfigurationPeer::doCount( $oCriteria ) == 0) { - $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '' - ) ); - $aConfiguration = array (); - } else { - $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); - if ($aConfiguration['CFG_VALUE'] != '') { - $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); - } else { - $aConfiguration = array (); - } - } - $passwd = $aConfiguration['MESS_PASSWORD']; - $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); - $auxPass = explode( 'hash:', $passwdDec ); - if (count( $auxPass ) > 1) { - if (count( $auxPass ) == 2) { - $passwd = $auxPass[1]; - } else { - array_shift( $auxPass ); - $passwd = implode( '', $auxPass ); - } - } - $aConfiguration['MESS_PASSWORD'] = $passwd; - - $oSpool = new spoolRun(); - $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $passwd,'SMTPAuth' => $aConfiguration['MESS_RAUTH'] - ) ); - - $oSpool->create( array ('msg_uid' => $data['MSG_UID'],'app_uid' => $data['APP_UID'],'del_index' => $data['DEL_INDEX'],'app_msg_type' => $data['APP_MSG_TYPE'],'app_msg_subject' => $data['APP_MSG_SUBJECT'],'app_msg_from' => $data['APP_MSG_FROM'],'app_msg_to' => $data['APP_MSG_TO'],'app_msg_body' => $data['APP_MSG_BODY'],'app_msg_cc' => $data['APP_MSG_CC'],'app_msg_bcc' => $data['APP_MSG_BCC'],'app_msg_attach' => $data['APP_MSG_ATTACH'],'app_msg_template' => $data['APP_MSG_TEMPLATE'],'app_msg_status' => 'pending' - ) ); - $oSpool->sendMail(); - - } catch (Exception $e) { - - $errorMessage = $e->getMessage(); - } - - echo $errorMessage; - -} - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +$actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null; + +if ($actionAjax == 'messageHistoryGridList_JXP') { + + G::LoadClass( 'case' ); + G::LoadClass( "BasePeer" ); + + global $G_PUBLISH; + $oCase = new Cases(); + + $appMessageArray = $oCase->getHistoryMessagesTrackerExt( $_SESSION['APPLICATION'] ); + + $result = new stdClass(); + $aProcesses = Array (); + + $totalCount = 0; + foreach ($appMessageArray as $index => $value) { + $appMessageArray[$index]['ID_MESSAGE'] = $appMessageArray[$index]['APP_UID'] . '_' . $appMessageArray[$index]['APP_MSG_UID']; + $aProcesses[] = $appMessageArray[$index]; + $totalCount ++; + } + + $newDir = '/tmp/test/directory'; + $r = G::verifyPath( $newDir ); + $r->data = $aProcesses; + $r->totalCount = $totalCount; + + echo G::json_encode( $r ); +} +if ($actionAjax == 'showHistoryMessage') { + + ?> + + + + AddContent( 'xmlform', 'xmlform', 'cases/cases_MessagesView', '', $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ) ); + + ?> + + getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ); + //print_r($data); + + + $oConfiguration = new Configuration(); + $sDelimiter = DBAdapter::getStringDelimiter(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); + $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); + $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); + $oCriteria->add( ConfigurationPeer::USR_UID, '' ); + $oCriteria->add( ConfigurationPeer::APP_UID, '' ); + if (ConfigurationPeer::doCount( $oCriteria ) == 0) { + $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '' + ) ); + $aConfiguration = array (); + } else { + $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); + if ($aConfiguration['CFG_VALUE'] != '') { + $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); + } else { + $aConfiguration = array (); + } + } + $passwd = $aConfiguration['MESS_PASSWORD']; + $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); + $auxPass = explode( 'hash:', $passwdDec ); + if (count( $auxPass ) > 1) { + if (count( $auxPass ) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift( $auxPass ); + $passwd = implode( '', $auxPass ); + } + } + $aConfiguration['MESS_PASSWORD'] = $passwd; + + $oSpool = new spoolRun(); + $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $passwd,'SMTPAuth' => $aConfiguration['MESS_RAUTH'] + ) ); + + $oSpool->create( array ('msg_uid' => $data['MSG_UID'],'app_uid' => $data['APP_UID'],'del_index' => $data['DEL_INDEX'],'app_msg_type' => $data['APP_MSG_TYPE'],'app_msg_subject' => $data['APP_MSG_SUBJECT'],'app_msg_from' => $data['APP_MSG_FROM'],'app_msg_to' => $data['APP_MSG_TO'],'app_msg_body' => $data['APP_MSG_BODY'],'app_msg_cc' => $data['APP_MSG_CC'],'app_msg_bcc' => $data['APP_MSG_BCC'],'app_msg_attach' => $data['APP_MSG_ATTACH'],'app_msg_template' => $data['APP_MSG_TEMPLATE'],'app_msg_status' => 'pending' + ) ); + $oSpool->sendMail(); + + } catch (Exception $e) { + + $errorMessage = $e->getMessage(); + } + + echo $errorMessage; + +} + diff --git a/workflow/engine/methods/cases/caseNotesAjax.php b/workflow/engine/methods/cases/caseNotesAjax.php index 37cc4cdef..bc87c49a1 100755 --- a/workflow/engine/methods/cases/caseNotesAjax.php +++ b/workflow/engine/methods/cases/caseNotesAjax.php @@ -1,76 +1,76 @@ - '','dir' => 'DESC','sort' => '','start' => 0,'limit' => 25,'filter' => '','search' => '','action' => '','xaction' => '','data' => '','status' => '','query' => '','fields' => "" - ); - $result = array (); - foreach ($validParams as $paramName => $paramDefault) { - $result[$paramName] = isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : $paramDefault; - } - return $result; -} - -function sendJsonResultGeneric ($response, $callback) -{ - header( "Content-Type: application/json" ); - $finalResponse = G::json_encode( $response ); - if ($callback != '') { - print $callback . "($finalResponse);"; - } else { - print $finalResponse; - } -} - -function getNotesList () -{ - extract( getExtJSParams() ); - require_once ("classes/model/AppNotes.php"); - if ((isset( $_REQUEST['appUid'] )) && (trim( $_REQUEST['appUid'] ) != "")) { - $appUid = $_REQUEST['appUid']; - } else { - $appUid = $_SESSION['APPLICATION']; - } - $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; - $appNotes = new AppNotes(); - $response = $appNotes->getNotesList( $appUid, '', $start, $limit ); - sendJsonResultGeneric( $response['array'], $callback ); -} - -function postNote () -{ - extract( getExtJSParams() ); - if ((isset( $_REQUEST['appUid'] )) && (trim( $_REQUEST['appUid'] ) != "")) { - $appUid = $_REQUEST['appUid']; - } else { - $appUid = $_SESSION['APPLICATION']; - } - $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; - require_once ("classes/model/AppNotes.php"); - - $noteContent = addslashes( $_POST['noteText'] ); - - $appNotes = new AppNotes(); - $response = $appNotes->postNewNote( $appUid, $usrUid, $noteContent ); - - sendJsonResultGeneric( $response, $callback ); -} - + '','dir' => 'DESC','sort' => '','start' => 0,'limit' => 25,'filter' => '','search' => '','action' => '','xaction' => '','data' => '','status' => '','query' => '','fields' => ""); + $result = array (); + foreach ($validParams as $paramName => $paramDefault) { + $result[$paramName] = isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : $paramDefault; + } + return $result; +} + +function sendJsonResultGeneric ($response, $callback) +{ + header( "Content-Type: application/json" ); + $finalResponse = G::json_encode( $response ); + if ($callback != '') { + print $callback . "($finalResponse);"; + } else { + print $finalResponse; + } +} + +function getNotesList () +{ + extract( getExtJSParams() ); + require_once ("classes/model/AppNotes.php"); + if ((isset( $_REQUEST['appUid'] )) && (trim( $_REQUEST['appUid'] ) != "")) { + $appUid = $_REQUEST['appUid']; + } else { + $appUid = $_SESSION['APPLICATION']; + } + $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; + $appNotes = new AppNotes(); + $response = $appNotes->getNotesList( $appUid, '', $start, $limit ); + + sendJsonResultGeneric( $response['array'], $callback ); +} + +function postNote () +{ + extract( getExtJSParams() ); + if ((isset( $_REQUEST['appUid'] )) && (trim( $_REQUEST['appUid'] ) != "")) { + $appUid = $_REQUEST['appUid']; + } else { + $appUid = $_SESSION['APPLICATION']; + } + $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; + require_once ("classes/model/AppNotes.php"); + + $noteContent = addslashes( $_POST['noteText'] ); + + $appNotes = new AppNotes(); + $response = $appNotes->postNewNote( $appUid, $usrUid, $noteContent ); + + sendJsonResultGeneric( $response, $callback ); +} + diff --git a/workflow/engine/methods/cases/cases_advancedSearch.php b/workflow/engine/methods/cases/cases_advancedSearch.php index 5f2c64da2..8cfe7ef90 100755 --- a/workflow/engine/methods/cases/cases_advancedSearch.php +++ b/workflow/engine/methods/cases/cases_advancedSearch.php @@ -1,81 +1,82 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * by The Answer - */ - -$G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'cases'; -$G_ID_MENU_SELECTED = 'CASES'; -$G_ID_SUB_MENU_SELECTED = 'CASES_ADVANCEDSEARCH'; -$G_PUBLISH = new Publisher(); - -global $RBAC; -$permisse = $RBAC->userCanAccess( 'PM_ALLCASES' ); -$userlogged = $_SESSION['USER_LOGGED']; - -require_once ("classes/model/ProcessUser.php"); -$oCriteria = new Criteria( 'workflow' ); -$oCriteria->addSelectColumn( ProcessUserPeer::PU_UID ); -$oCriteria->addSelectColumn( ProcessUserPeer::PRO_UID ); -$oCriteria->add( ProcessUserPeer::USR_UID, $userlogged ); -$oCriteria->add( ProcessUserPeer::PU_TYPE, "SUPERVISOR" ); - -$oDataset = ProcessUserPeer::doSelectRS( $oCriteria ); -$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); -$oDataset->next(); - -$aSupervisor = array (); -while ($aRow = $oDataset->getRow()) { - $aSupervisor[] = $aRow['PRO_UID']; - $oDataset->next(); -} - -G::LoadClass( 'case' ); -$oCases = new Cases(); - -if (isset( $_POST['form'] )) { - $fields['CASE_NUMBER'] = $_POST['form']['CASE_NUMBER']; - $fields['PROCESS'] = $_POST['form']['PROCESS']; - $fields['TASKS'] = $_POST['form']['TASKS']; - $fields['CURRENT_USER'] = $_POST['form']['CURRENT_USER']; - $fields['SENT_BY'] = $_POST['form']['SENT_BY']; - $fields['LAST_MODIFICATION_F'] = $_POST['form']['LAST_MODIFICATION_F']; - $fields['LAST_MODIFICATION_T'] = $_POST['form']['LAST_MODIFICATION_T']; - $fields['APP_STATUS'] = $_POST['form']['APP_STATUS']; - - $Criteria = $oCases->getAdvancedSearch( $fields['CASE_NUMBER'], $fields['PROCESS'], $fields['TASKS'], $fields['CURRENT_USER'], $fields['SENT_BY'], $fields['LAST_MODIFICATION_F'], $fields['LAST_MODIFICATION_T'], $fields['APP_STATUS'], $permisse, $userlogged, $aSupervisor ); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_advancedSearchFilter', '', $fields ); -} else { - //list($Criteria,$xmlform) = $oCases->getConditionCasesList('gral'); - $Criteria = $oCases->getAdvancedSearch( '', '', '', '', '', '', '', '', $permisse, $userlogged, $aSupervisor ); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_advancedSearchFilter' ); -} -$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_advancedSearch', $Criteria ); - -G::RenderPage( 'publish', 'blank' ); -?> - - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * by The Answer + */ + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'cases'; +$G_ID_MENU_SELECTED = 'CASES'; +$G_ID_SUB_MENU_SELECTED = 'CASES_ADVANCEDSEARCH'; +$G_PUBLISH = new Publisher(); + +global $RBAC; +$permisse = $RBAC->userCanAccess( 'PM_ALLCASES' ); +$userlogged = $_SESSION['USER_LOGGED']; + +require_once ("classes/model/ProcessUser.php"); +$oCriteria = new Criteria( 'workflow' ); +$oCriteria->addSelectColumn( ProcessUserPeer::PU_UID ); +$oCriteria->addSelectColumn( ProcessUserPeer::PRO_UID ); +$oCriteria->add( ProcessUserPeer::USR_UID, $userlogged ); +$oCriteria->add( ProcessUserPeer::PU_TYPE, "SUPERVISOR" ); + +$oDataset = ProcessUserPeer::doSelectRS( $oCriteria ); +$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); +$oDataset->next(); + +$aSupervisor = array (); +while ($aRow = $oDataset->getRow()) { + $aSupervisor[] = $aRow['PRO_UID']; + $oDataset->next(); +} + +G::LoadClass( 'case' ); +$oCases = new Cases(); + +if (isset( $_POST['form'] )) { + $fields['CASE_NUMBER'] = $_POST['form']['CASE_NUMBER']; + $fields['PROCESS'] = $_POST['form']['PROCESS']; + $fields['TASKS'] = $_POST['form']['TASKS']; + $fields['CURRENT_USER'] = $_POST['form']['CURRENT_USER']; + $fields['SENT_BY'] = $_POST['form']['SENT_BY']; + $fields['LAST_MODIFICATION_F'] = $_POST['form']['LAST_MODIFICATION_F']; + $fields['LAST_MODIFICATION_T'] = $_POST['form']['LAST_MODIFICATION_T']; + $fields['APP_STATUS'] = $_POST['form']['APP_STATUS']; + + $Criteria = $oCases->getAdvancedSearch( $fields['CASE_NUMBER'], $fields['PROCESS'], $fields['TASKS'], $fields['CURRENT_USER'], $fields['SENT_BY'], $fields['LAST_MODIFICATION_F'], $fields['LAST_MODIFICATION_T'], $fields['APP_STATUS'], $permisse, $userlogged, $aSupervisor ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_advancedSearchFilter', '', $fields ); +} else { + //list($Criteria,$xmlform) = $oCases->getConditionCasesList('gral'); + $Criteria = $oCases->getAdvancedSearch( '', '', '', '', '', '', '', '', $permisse, $userlogged, $aSupervisor ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_advancedSearchFilter' ); +} +$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_advancedSearch', $Criteria ); + +G::RenderPage( 'publish', 'blank' ); +?> + +. + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -/* +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} + /* * Created on 21/12/2007 * */ - G::LoadClass('dynaformEditor'); - G::LoadClass('toolBar'); - G::LoadClass('dynaFormField'); +G::LoadClass( 'dynaformEditor' ); +G::LoadClass( 'toolBar' ); +G::LoadClass( 'dynaFormField' ); - //G::LoadClass('configuration'); - $G_MAIN_MENU = 'processmaker'; - $G_SUB_MENU = 'processes'; - $G_ID_MENU_SELECTED = 'PROCESSES'; - $G_ID_SUB_MENU_SELECTED = 'FIELDS'; +//G::LoadClass('configuration'); +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'processes'; +$G_ID_MENU_SELECTED = 'PROCESSES'; +$G_ID_SUB_MENU_SELECTED = 'FIELDS'; - $PRO_UID=isset($_GET['PRO_UID'])?$_GET['PRO_UID']:'0'; - $DYN_UID=(isset($_GET['DYN_UID'])) ? urldecode($_GET['DYN_UID']):'0'; - $_SESSION['PROCESS'] = $_GET['PRO_UID']; +$PRO_UID = isset( $_GET['PRO_UID'] ) ? $_GET['PRO_UID'] : '0'; +$DYN_UID = (isset( $_GET['DYN_UID'] )) ? urldecode( $_GET['DYN_UID'] ) : '0'; +$_SESSION['PROCESS'] = $_GET['PRO_UID']; - - if ($PRO_UID==='0') return; - $process = new Process; - if ($process->exists($PRO_UID)) - { +if ($PRO_UID === '0') { + return; +} +$process = new Process(); +if ($process->exists( $PRO_UID )) { $process->load( $PRO_UID ); - } - else - { +} else { //TODO - print("$PRO_UID doesn't exist, continue? yes"); - } + print ("$PRO_UID doesn't exist, continue? yes") ; +} +$dynaform = new dynaform(); - $dynaform = new dynaform; - - if ($dynaform->exists($DYN_UID)) - { +if ($dynaform->exists( $DYN_UID )) { $dynaform->load( $DYN_UID ); $_SESSION['CURRENT_DYN_UID'] = $DYN_UID; - } - else - { - /* New Dynaform - * - */ - $dynaform->create(array('PRO_UID'=>$PRO_UID)); - } +} else { + /* New Dynaform + * + */ + $dynaform->create( array ('PRO_UID' => $PRO_UID) ); +} - //creating SESSION for redirecting to new bpmn editor after closing Dynaform - if(isset($_GET['bpmn']) && $_GET['bpmn'] == '1') - {$_SESSION['dynaform_editor'] = 'bpmn';} - else if(!isset($_GET['bpmn'])) - {$_SESSION['dynaform_editor'] = 'processmap';} +//creating SESSION for redirecting to new bpmn editor after closing Dynaform +if (isset( $_GET['bpmn'] ) && $_GET['bpmn'] == '1') { + $_SESSION['dynaform_editor'] = 'bpmn'; +} elseif (! isset( $_GET['bpmn'] )) { + $_SESSION['dynaform_editor'] = 'processmap'; +} +$editor = new dynaformEditor( $_POST ); +$editor->file = $dynaform->getDynFilename(); +$editor->home = PATH_DYNAFORM; +$editor->title = $dynaform->getDynTitle(); +$editor->dyn_uid = $dynaform->getDynUid(); +$editor->pro_uid = $dynaform->getProUid(); +$editor->dyn_type = $dynaform->getDynType(); +$editor->dyn_title = $dynaform->getDynTitle(); +$editor->dyn_description = $dynaform->getDynDescription(); +$editor->dyn_editor = $_SESSION['dynaform_editor']; +$editor->_setUseTemporalCopy( true ); +$editor->_render(); - $editor=new dynaformEditor($_POST); - $editor->file=$dynaform->getDynFilename(); - $editor->home=PATH_DYNAFORM; - $editor->title=$dynaform->getDynTitle(); - $editor->dyn_uid=$dynaform->getDynUid(); - $editor->pro_uid=$dynaform->getProUid(); - $editor->dyn_type=$dynaform->getDynType(); - $editor->dyn_title=$dynaform->getDynTitle(); - $editor->dyn_description=$dynaform->getDynDescription(); - $editor->dyn_editor=$_SESSION['dynaform_editor']; - $editor->_setUseTemporalCopy(true); - $editor->_render(); - -?> \ No newline at end of file diff --git a/workflow/engine/methods/dynaforms/dynaforms_FlatEditor.php b/workflow/engine/methods/dynaforms/dynaforms_FlatEditor.php index 742b5f6c7..af692fa04 100755 --- a/workflow/engine/methods/dynaforms/dynaforms_FlatEditor.php +++ b/workflow/engine/methods/dynaforms/dynaforms_FlatEditor.php @@ -211,3 +211,4 @@ G::RenderPage( "publish", "raw" ); return myPanel; } + diff --git a/workflow/engine/methods/events/eventList.php b/workflow/engine/methods/events/eventList.php index 3fec22b22..dc98cce45 100644 --- a/workflow/engine/methods/events/eventList.php +++ b/workflow/engine/methods/events/eventList.php @@ -1,5 +1,4 @@ '; + if (file_exists( FILE_PATHS_INSTALLED )) { if (@copy( FILE_PATHS_INSTALLED, FILE_PATHS_INSTALLED . '.backup' )) { echo 'Backup file was created ' . FILE_PATHS_INSTALLED . '.backup';