First commit on ProcessMaker CORE Engine and Jeaqueline's changes

This commit is contained in:
girish
2010-12-07 11:49:51 +00:00
parent 720db63b61
commit 2e97a8e9ec
31 changed files with 2118 additions and 889 deletions

View File

@@ -53,6 +53,7 @@
G::LoadClass('case');
G::LoadClass('derivation');
/* GET , POST & $_SESSION Vars */
if(isset($_GET['POSITION'])) {
$_SESSION['STEP_POSITION'] = (int)$_GET['POSITION'];
@@ -87,7 +88,7 @@
$G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower);
$oCase = new Cases();
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$sStatus = $Fields['APP_STATUS'];
@@ -95,15 +96,12 @@
$APP_NUMBER = $Fields['APP_NUMBER'];
$APP_TITLE = $Fields['TITLE'];
//optimize for speed, we are reading process info once
//$oProcess = new Process();
//$oProcessFields = $oProcess->Load($_SESSION['PROCESS']);
$oProcess = ProcessPeer::retrieveByPk( $_SESSION['PROCESS'] );
$oProcessFields = $oProcess->toArray(BasePeer::TYPE_FIELDNAME);
$oProcess = new Process();
$oProcessFieds = $oProcess->Load($_SESSION['PROCESS']);
#trigger debug routines...
if( isset($oProcessFields['PRO_DEBUG']) && $oProcessFields['PRO_DEBUG'] ) { #here we must verify if is a debugg session
if( isset($oProcessFieds['PRO_DEBUG']) && $oProcessFieds['PRO_DEBUG'] ) { #here we must verify if is a debugg session
$_SESSION['TRIGGER_DEBUG']['ISSET'] = 1;
$_SESSION['PMDEBUGGER']= true;
}
@@ -115,7 +113,7 @@
//cleaning debug variables
if( !isset($_GET['breakpoint']) ) {
if( isset($_SESSION['TRIGGER_DEBUG']['info']) ) unset($_SESSION['TRIGGER_DEBUG']['info']);
if (!isset($_SESSION['_NO_EXECUTE_TRIGGERS_'])) {
$_SESSION['TRIGGER_DEBUG']['ERRORS'] = Array();
}
@@ -154,7 +152,7 @@
* Here we throw the debug view
*/
if ( isset($_GET['breakpoint']) ) {
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameLoader');
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameBreaker');
G::RenderPage('publish', 'blank');
@@ -204,7 +202,7 @@
/** Added By erik 16-05-08
* Description: this was added for the additional database connections */
G::LoadClass ('dbConnections');
$oDbConnections = new dbConnections(NULL);
$oDbConnections = new dbConnections($_SESSION['PROCESS']);
$oDbConnections->loadAdditionalConnections();
$_SESSION['CURRENT_DYN_UID'] = $_GET['UID'];
@@ -213,7 +211,7 @@
case 'INPUT_DOCUMENT':
$oInputDocument = new InputDocument();
$Fields = $oInputDocument->load($_GET['UID']);
$Fields = $oInputDocument->load($_GET['UID']);
if (!$aPreviousStep) {
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
$Fields['PREVIOUS_STEP_LABEL'] = '';
@@ -221,7 +219,7 @@
else {
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
$Fields['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
}
@@ -248,14 +246,14 @@
$Fields['MESSAGE2'] = G::LoadTranslation('ID_PLEASE_SELECT_FILE');
//START: If there is a Break Step registered from Plugin Similar as a Trigger debug
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED']) );
}
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED']) );
}
//END: If there is a Break Step registered from Plugin
$G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['UID']), array_merge(array('DOC_UID'=>$_GET['UID']),$Fields));//$aFields
//call plugin
//call plugin
//if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST ) ) {
// $folderData = new folderData (null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED'] );
// $oPluginRegistry =& PMPluginRegistry::getSingleton();
@@ -264,15 +262,15 @@
//}
//else
// $G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['UID']), array_merge(array('DOC_UID'=>$_GET['UID']),$Fields));//$aFields
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher =& headPublisher::getSingleton();
$titleDocument="<h3>".$Fields['INP_DOC_TITLE']."<br><small>".G::LoadTranslation('ID_INPUT_DOCUMENT')."</small></h3>";
if($Fields['INP_DOC_DESCRIPTION']) $titleDocument.= " ".str_replace("\n","",str_replace("'","\'",nl2br(htmlentities(utf8_decode($Fields['INP_DOC_DESCRIPTION'])))))."";
$oHeadPublisher->addScriptCode("documentName='{$titleDocument}';");
break;
case 'VIEW':
case 'VIEW':
require_once 'classes/model/AppDocument.php';
require_once 'classes/model/Users.php';
$oAppDocument = new AppDocument();
@@ -304,7 +302,6 @@
require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new OutputDocument();
$aOD = $oOutputDocument->load( $_GET['UID'] );
if (!$aPreviousStep) {
$aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
}
@@ -319,43 +316,19 @@
case 'GENERATE':
//START: If there is a Break Step registered from Plugin Similar as a Trigger debug
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED'],'DOC_UID'=>$_GET['UID'],'PRO_UID'=>$_SESSION['PROCESS']) );
}
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED']) );
}
//END: If there is a Break Step registered from Plugin
$sFilename = ereg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
if ( $sFilename == '' ) $sFilename='_';
$pathOutput = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP ;
G::mk_dir ( $pathOutput );
switch ( $aOD['OUT_DOC_TYPE'] ) {
case 'HTML' :
$aProperties = array(); //maui
if(!isset($aOD['OUT_DOC_MEDIA']))
$aOD['OUT_DOC_MEDIA'] = 'Letter';
if(!isset($aOD['OUT_DOC_LEFT_MARGIN']))
$aOD['OUT_DOC_LEFT_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_RIGHT_MARGIN']))
$aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_TOP_MARGIN']))
$aOD['OUT_DOC_TOP_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_BOTTOM_MARGIN']))
$aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
if(isset($aOD['OUT_DOC_VERSIONING']) && $aOD['OUT_DOC_VERSIONING']!=0){
$oAppDocument= new AppDocument();
$lastDocVersion=$oAppDocument->getLastDocVersion($_GET['UID'],$_SESSION['APPLICATION']);
$lastDocVersion = $lastDocVersion +1;
$lastDocVersion = '_'.$lastDocVersion;
}else {
$lastDocVersion='';
}
$aProperties['media']=$aOD['OUT_DOC_MEDIA'];
$aProperties['margins']=array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'],);
case 'HTML' :
$oOutputDocument->generate( $_GET['UID'], $Fields['APP_DATA'], $pathOutput,
$sFilename.$lastDocVersion, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'],$aProperties );
$sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] );
break;
case 'JRXML' :
//creating the xml with the application data;
@@ -365,22 +338,22 @@
}
$xmlData .= "</dynaform>\n";
$iSize = file_put_contents ( $javaOutput . 'addressBook.xml' , $xmlData );
G::LoadClass ('javaBridgePM');
$JBPM = new JavaBridgePM();
$JBPM->checkJavaExtension();
$util = new Java("com.processmaker.util.pmutils");
$util->setInputPath( $javaInput );
$util->setOutputPath( $javaOutput );
//$content = file_get_contents ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.jrxml' );
//$iSize = file_put_contents ( $javaInput . $aOD['OUT_DOC_UID'] . '.jrxml', $content );
copy ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.jrxml', $javaInput . $aOD['OUT_DOC_UID'] . '.jrxml' );
$outputFile = $javaOutput . $sFilename . '.pdf' ;
print $util->jrxml2pdf( $aOD['OUT_DOC_UID'] . '.jrxml' , basename($outputFile) );
//$content = file_get_contents ( $outputFile );
//$iSize = file_put_contents ( $pathOutput . $sFilename . '.pdf' , $content );
copy ( $outputFile, $pathOutput . $sFilename . '.pdf' );
@@ -394,46 +367,46 @@
}
$xmlData .= "</dynaform>\n";
//$iSize = file_put_contents ( $javaOutput . 'addressBook.xml' , $xmlData );
G::LoadClass ('javaBridgePM');
$JBPM = new JavaBridgePM();
$JBPM->checkJavaExtension();
$util = new Java("com.processmaker.util.pmutils");
$util->setInputPath( $javaInput );
$util->setOutputPath( $javaOutput );
copy ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.pdf', $javaInput . $aOD['OUT_DOC_UID'] . '.pdf' );
$outputFile = $javaOutput . $sFilename . '.pdf' ;
print $util->writeVarsToAcroFields( $aOD['OUT_DOC_UID'] . '.pdf' , $xmlData );
copy ( $javaOutput. $aOD['OUT_DOC_UID'] . '.pdf', $pathOutput . $sFilename . '.pdf' );
break;
default :
throw ( new Exception ('invalid output document' ));
}
require_once 'classes/model/AppFolder.php';
require_once 'classes/model/AppDocument.php';
//Get the Custom Folder ID (create if necessary)
//Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder();
$folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH']);
//Tags
$fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS']);
//Get last Document Version and apply versioning if is enabled
$oAppDocument= new AppDocument();
$oAppDocument= new AppDocument();
$lastDocVersion=$oAppDocument->getLastDocVersion($_GET['UID'],$_SESSION['APPLICATION']);
//if(($aOD['OUT_DOC_VERSIONING'])||($lastDocVersion==0)){
// $lastDocVersion++;
//}
$oCriteria = new Criteria('workflow');
$oCriteria->add(AppDocumentPeer::APP_UID, $_SESSION['APPLICATION']);
//$oCriteria->add(AppDocumentPeer::DEL_INDEX, $_SESSION['INDEX']);
@@ -442,9 +415,9 @@
$oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
$oDataset = AppDocumentPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output
if ($aRow = $oDataset->getRow()) {
$oDataset->next();
if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output
if ($aRow = $oDataset->getRow()) {
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
@@ -456,12 +429,12 @@
'APP_DOC_FILENAME' => $sFilename,
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new AppDocument();
$oAppDocument->create($aFields);
$oAppDocument = new AppDocument();
$oAppDocument->create($aFields);
$sDocUID = $aRow['APP_DOC_UID'];
}
}else{//No versioning so Update a current Output or Create new if no exist
if ($aRow = $oDataset->getRow()) { //Update
if ($aRow = $oDataset->getRow()) { //Update
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
@@ -476,7 +449,7 @@
$oAppDocument = new AppDocument();
$oAppDocument->update($aFields);
$sDocUID = $aRow['APP_DOC_UID'];
}else{ //create
}else{ //create
if($lastDocVersion==0) $lastDocVersion++;
$aFields = array('APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
@@ -490,7 +463,7 @@
'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new AppDocument();
$aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields);
}
}
@@ -506,17 +479,17 @@
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace;
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace;
$oAppDocument1 = new AppDocument();
$oAppDocument1->update($aFields);
$sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP;
$oData['APP_UID'] = $_SESSION['APPLICATION'];
$oData['ATTACHMENT_FOLDER'] = true;
$oData['ATTACHMENT_FOLDER'] = true;
switch($aOD['OUT_DOC_GENERATE']){
case "BOTH":
$documentData = new uploadDocumentData (
@@ -534,7 +507,7 @@
if($uploadReturn){//Only delete if the file was saved correctly
unlink ( $pathOutput . $sFilename. '.pdf' );
}
$documentData = new uploadDocumentData (
@@ -597,55 +570,50 @@
G::header('location: '.$outputNextStep);
die;
break;
case 'VIEW':
case 'VIEW':
require_once 'classes/model/AppDocument.php';
$oAppDocument = new AppDocument();
$lastVersion=$oAppDocument->getLastAppDocVersion($_GET['DOC'],$_SESSION['APPLICATION']);
$aFields = $oAppDocument->load($_GET['DOC'],$lastVersion);
$listing=false;
$oPluginRegistry = & PMPluginRegistry::getSingleton();
if($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
$folderData = new folderData(null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED']);
$folderData->PMType = "OUTPUT";
$folderData->returnList = true;
$listing=$oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
$folderData->returnList = true;
$listing=$oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
}
require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new OutputDocument();
$aGields = $oOutputDocument->load($aFields['DOC_UID']);
if(isset($aGields['OUT_DOC_VERSIONING']) && $aGields['OUT_DOC_VERSIONING']!=0){
$oAppDocument= new AppDocument();
$lastDocVersion=$oAppDocument->getLastDocVersion($_GET['UID'],$_SESSION['APPLICATION']);
}else {
$lastDocVersion='';
}
$aFields['VIEW1'] = G::LoadTranslation('ID_OPEN');
$aFields['VIEW2'] = G::LoadTranslation('ID_OPEN');
$aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$lastDocVersion . '&ext=doc&random=' . rand();
$aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$aFields['DOC_VERSION'] . '&ext=doc&random=' . rand();
$aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$aFields['DOC_VERSION'] . '&ext=pdf&random=' . rand();
$aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$lastDocVersion . '&ext=pdf&random=' . rand();
if ( is_array ($listing) ){//If exist in Plugin Document List
foreach($listing as $folderitem) {
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='DOC')){
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='DOC')){
$aFields['VIEW1'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE');
$aFields['FILE1'] = $folderitem->downloadScript;
continue;
}
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='PDF')){
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='PDF')){
$aFields['VIEW2'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE');
$aFields['FILE2'] = $folderitem->downloadScript;
continue;
}
}
}
}
if(($aGields['OUT_DOC_GENERATE']=='BOTH')||($aGields['OUT_DOC_GENERATE']==''))
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument1', '', G::array_merges($aOD, $aFields), '');
@@ -655,17 +623,16 @@
if($aGields['OUT_DOC_GENERATE']=='PDF')
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument3', '', G::array_merges($aOD, $aFields), '');
break;
}
break;
case 'ASSIGN_TASK':
$oDerivation = new Derivation();
//$oProcess = new Process(); //optimized for speed, we already load process row
$oProcess = new Process();
$aData = $oCase->loadCase($_SESSION['APPLICATION']);
//$aFields['PROCESS'] = $oProcess->load($_SESSION['PROCESS']);
$aFields['PROCESS'] = $oProcessFields;
$aFields['PROCESS'] = $oProcess->load($_SESSION['PROCESS']);
$aFields['PREVIOUS_PAGE'] = $aPreviousStep['PAGE'];
$aFields['PREVIOUS_PAGE_LABEL'] = G::LoadTranslation('ID_PREVIOUS_STEP');
$aFields['ASSIGN_TASK'] = G::LoadTranslation('ID_ASSIGN_TASK');
@@ -677,18 +644,23 @@
$aFields['CONTINUE'] = G::LoadTranslation('ID_CONTINUE');
$aFields['CONTINUE_WITH_OPTION'] = G::LoadTranslation('ID_CONTINUE_WITH_OPTION');
$aFields['FINISH_WITH_OPTION'] = G::LoadTranslation('ID_FINISH_WITH_OPTION');
$aFields['TAS_TIMING_TITLE'] = 'Timing Control';
$aFields['TAS_DURATION'] = 'Task Duration';
$aFields['TAS_TIMEUNIT'] = 'Task Unit';
$aFields['TAS_TYPE_DAY'] = 'Count Days By';
$aFields['TAS_CALENDAR'] = 'Calendar';
$aFields['TASK'] = $oDerivation->prepareInformation(
array( 'USER_UID' => $_SESSION['USER_LOGGED'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'])
);
if ( empty($aFields['TASK']) ) {
throw ( new Exception ( G::LoadTranslation ( 'ID_NO_DERIVATION_RULE') ) );
throw ( new Exception ( G::LoadTranslation( 'ID_NO_DERIVATION_RULE') ) );
}
//take the first derivation rule as the task derivation rule type.
$aFields['PROCESS']['ROU_TYPE'] = $aFields['TASK'][1]['ROU_TYPE'];
$aFields['PROCESS']['ROU_FINISH_FLAG'] = false;
foreach ( $aFields['TASK'] as $sKey => &$aValues)
{
$sPriority = '';//set priority value
@@ -715,7 +687,7 @@
$hiddenName = "form[TASKS][" . $sKey . "][USR_UID]";
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME'];
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_HIDDEN_FIELD'] = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $aValues['NEXT_TASK']['USER_ASSIGNED']['USR_UID'] . '">';
//var_dump($aFields);
//there is a error with reportsTo, when the USR_UID is empty means there are no manager for this user, so we are disabling buttons
//but this validation is not for SELF_SERVICE
if ( $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] != 'SELF_SERVICE' )
@@ -739,6 +711,96 @@
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $sAux;
break;
case 'CANCEL_MI':
case 'STATIC_MI':
//count the Users in the group
$cntInstanceUsers = count($aValues['NEXT_TASK']['USER_ASSIGNED']);
//set TAS_MI_INSTANCE_VARIABLE value
$sMIinstanceVar = '';
if ($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'] != '') {
if (isset($aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'])]))
{
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'])];
if($sMIinstanceVar > $cntInstanceUsers)
throw (new Exception("Total Multiple Instance Task cannot be greater than number of users in the group."));
else if($sMIinstanceVar == 0)
throw (new Exception("Total Multiple Instance Task cannot be zero."));
}
else if(is_int((int)$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE']))
{
$sMIinstanceVar = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'];
if($sMIinstanceVar > $cntInstanceUsers)
throw (new Exception("Total Multiple Instance Task cannot be greater than number of users in the group."));
}
else
throw (new Exception("Total Multiple Instance Task variable doesn't have valid value."));
}
else
throw (new Exception("Total Multiple Instance Task variable doesn't have valid value."));
////set TAS_MI_INSTANCE_VARIABLE value
//set TAS_MI_COMPLETE_VARIABLE value
$sMIcompleteVar = '';
if ($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'] != '') {
if (isset($aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'])]))
{
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'])];
//
if($sMIcompleteVar > $sMIinstanceVar)
throw (new Exception("Total Multiple Instance Task to complete cannot be greater than Total number of Instances."));
}
else if(is_int((int)$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE']))
{
$sMIcompleteVar = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'];
if($sMIcompleteVar > $sMIinstanceVar)
throw (new Exception("Total Multiple Instance Task to complete cannot be greater than Total number of Instances."));
}
else
throw ( new Exception("Total Multiple Instance Task to complete variable doesn't have valid value.") ) ;
}
else
throw ( new Exception("Total Multiple Instance Task to complete variable doesn't have valid value.") ) ;
//set TAS_MI_COMPLETE_VARIABLE value
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_NEXT'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
//If the Users in the group is equal to the MI Instance variable then Show all the users without Dropdown
if($sMIinstanceVar == $cntInstanceUsers)
{
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aUser)
{
$hiddenName = "form[TASKS][" . $sKey . "][NEXT_TASK][USER_ASSIGNED][".$key."][USR_UID]";
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_UID'] = $aUser['USR_FULLNAME'];
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_HIDDEN_FIELD'] = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $aUser['USR_UID'] . '">';
}
}
//If the Users in the group is not equal to the MI Instance variable then Show Only count users in dropdown
else
{
$Aux = array();
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser)
{
$Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME'];
}
asort($Aux);
$aAux = '<option value="" enabled>'.G::LoadTranslation('ID_SELECT').'</option>';
foreach ($Aux as $akey => $value)
{
$aAux .= '<option value="' . $akey . '">' . $value . '</option>';
}
for($key=0; $key < $sMIinstanceVar; $key++)
{
$hiddenName = "form[TASKS][" . $sKey . "][NEXT_TASK][USER_ASSIGNED][".$key."][USR_UID]";
$sAux = "<select name=$hiddenName id=$hiddenName";
$sAux .= $aAux;
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_HIDDEN_FIELD'] = "<input type='hidden' name='hidden' id='hidden' value=''>";
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_UID'] = $sAux;
}
}
break;
case '': //when this task is the Finish process
$userFields = $oDerivation->getUsersFullNameFromArray ( $aFields['TASK'][$sKey]['USER_UID'] );
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $userFields['USR_FULLNAME'];
@@ -747,18 +809,75 @@
break;
}
$hiddenName = 'form[TASKS][' . $sKey . ']';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_ASSIGN_TYPE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_ASSIGN_TYPE]" id="' . $hiddenName . '[TAS_ASSIGN_TYPE]" value="' . $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] . '">';
if (isset ($aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'])){
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="' . $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'] . '">';
} else {
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="">';
}
$aFields['TASK'][$sKey]['NEXT_TASK']['DEL_PRIORITY'] = '<input type="hidden" name="' . $hiddenName . '[DEL_PRIORITY]" id="' . $hiddenName . '[DEL_PRIORITY]" value="' . $sPriority . '">';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PARENT'] = '<input type="hidden" name="' . $hiddenName . '[TAS_PARENT]" id="' . $hiddenName . '[TAS_PARENT]" value="' . $aValues['NEXT_TASK']['TAS_PARENT'] . '">';
}
/* Allow user defined Timing Control
* Values in the dropdown will be populated from the Table TASK.
*/
if($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] != '') //Check for End of Process
{
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TRANSFER_FLY'] = strtolower($aValues['NEXT_TASK']['TAS_TRANSFER_FLY']);
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] = "<input type=hidden name='".$hiddenName."[NEXT_TASK][TAS_TRANSFER_HIDDEN_FLY]' id='".$hiddenName."[NEXT_TASK][TAS_TRANSFER_HIDDEN_FLY]' value=".$aValues['NEXT_TASK']['TAS_TRANSFER_FLY'].">";
if($aValues['NEXT_TASK']['TAS_TRANSFER_FLY'] == 'true')
{
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DURATION'] = '<input type="text" size="5" name="' . $hiddenName . '[NEXT_TASK][TAS_DURATION]" id="' . $hiddenName . '[NEXT_TASK][TAS_DURATION]" value="' . $aValues['NEXT_TASK']['TAS_DURATION'] . '">';
$hoursSelected = $daysSelected = '';
if($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TIMEUNIT'] == 'HOURS')
$hoursSelected = "selected = 'selected'";
else
$daysSelected = "selected = 'selected'";
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_TIMEUNIT] id= '.$hiddenName.'[NEXT_TASK][TAS_TIMEUNIT] ';
$sAux .= "<option ".$hoursSelected." value='HOURS'>Hours</option> ";
$sAux .= "<option ".$daysSelected." value='DAYS'>Days</option> ";
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TIMEUNIT'] = $sAux;
$workSelected = $calendarSelected = '';
if($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TYPE_DAY'] == '1')
$workSelected = "selected = 'selected'";
else
$calendarSelected = "selected = 'selected'";
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_TYPE_DAY] id= '.$hiddenName.'[NEXT_TASK][TAS_TYPE_DAY] ';
$sAux .= "<option ".$workSelected." value='1'>Work Days</option> ";
$sAux .= "<option ".$calendarSelected." value='2'>Calendar Days</option> ";
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TYPE_DAY'] = $sAux;
//Check for
G::LoadClass ( 'calendar' );
$calendar = new Calendar ( );
$calendarObj = $calendar->getCalendarList ( true, true );
$availableCalendar = $calendarObj ['array'];
$aCalendar['CALENDAR_UID'] = '00000000000000000000000000000001';
$aCalendar['CALENDAR_NAME'] = 'DEFAULT';
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_CALENDAR] id= '.$hiddenName.'[NEXT_TASK][TAS_CALENDAR] ';
$sAux .= "<option value='none'>-None-</option> ";
foreach($availableCalendar as $aCalendar)
{
if(is_array($aCalendar))
{
$sAux .= "<option value='".$aCalendar['CALENDAR_UID']."'>".$aCalendar['CALENDAR_NAME']."</option> ";
}
}
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_CALENDAR'] = $sAux;
}
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_ASSIGN_TYPE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_ASSIGN_TYPE]" id="' . $hiddenName . '[TAS_ASSIGN_TYPE]" value="' . $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] . '">';
if (isset ($aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'])){
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="' . $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'] . '">';
} else {
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="">';
}
$aFields['TASK'][$sKey]['NEXT_TASK']['DEL_PRIORITY'] = '<input type="hidden" name="' . $hiddenName . '[DEL_PRIORITY]" id="' . $hiddenName . '[DEL_PRIORITY]" value="' . $sPriority . '">';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PARENT'] = '<input type="hidden" name="' . $hiddenName . '[TAS_PARENT]" id="' . $hiddenName . '[TAS_PARENT]" value="' . $aValues['NEXT_TASK']['TAS_PARENT'] . '">';
}
}
$aFields['PROCESSING_MESSAGE'] = G::loadTranslation('ID_PROCESSING');
$G_PUBLISH->AddContent('smarty', 'cases/cases_ScreenDerivation', '', '', $aFields);
/*
if (isset( $aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){
@@ -776,7 +895,7 @@
}else{
$G_PUBLISH->AddContent('smarty', 'cases/cases_ScreenDerivation', '', '', $aFields);
}
*/
*/
break;
case 'EXTERNAL':
$oPluginRegistry = &PMPluginRegistry::getSingleton();
@@ -803,7 +922,7 @@
/** Added By erik date: 16-05-08
* Description: this was added for the additional database connections */
G::LoadClass ('dbConnections');
$oDbConnections = new dbConnections(NULL);
$oDbConnections = new dbConnections($_SESSION['PROCESS']);
$oDbConnections->loadAdditionalConnections();
$stepFilename = "$sNamespace/$sStepName";
$G_PUBLISH->AddContent('content', $stepFilename );
@@ -812,7 +931,7 @@
}
//Add content content step - End
}
catch ( Exception $e ) {
catch ( Exception $e ) {
G::SendTemporalMessage($e->getMessage(), 'error', 'string', 3, 100);
$aMessage = array();
$aMessage['MESSAGE'] = G::LoadTranslation('ID_PROCESS_DEF_PROBLEM').'<br/>'.G::LoadTranslation('ID_CONTACT_ADMIN');
@@ -862,10 +981,10 @@
');
if( defined('SYS_SKIN') )
$skin = SYS_SKIN;
else
$skin = "green";
$skin = SYS_SKIN;
else
$skin = "green";
G::RenderPage('publish', $skin . '-submenu');
if( $_SESSION['TRIGGER_DEBUG']['ISSET'] ){

View File

@@ -1,10 +1,10 @@
<?php
/**
* patterns_Ajax.php
*
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
@@ -14,20 +14,26 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*
*/
G::LoadInclude('ajax');
$aData = urldecode_values($_POST['form']);
$oJSON = new Services_JSON();
if(isset($_POST['mode']) && $_POST['mode'] != '')
$aData = $_POST;
else
$aData = urldecode_values($_POST['form']);
G::LoadClass('tasks');
$oTasks = new Tasks();
$rou_id = 0;
switch ($aData['action']) {
case 'savePattern':
G::LoadClass('tasks');
$oTasks = new Tasks();
//if ($aData['ROU_TYPE'] != $aData['ROU_TYPE_OLD'])
//{
$oTasks->deleteAllRoutesOfTask($aData['PROCESS'], $aData['TASK']);
@@ -36,7 +42,7 @@ switch ($aData['action']) {
$oRoute = new Route();
switch ($aData['ROU_TYPE']) {
case 'SEQUENTIAL':
case 'SEC-JOIN':
case 'SEC-JOIN':
/*if ($aData['ROU_UID'] != '')
{
$aFields['ROU_UID'] = $aData['ROU_UID'];
@@ -46,7 +52,7 @@ switch ($aData['action']) {
$aFields['ROU_NEXT_TASK'] = $aData['ROU_NEXT_TASK'];
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
//$aFields['ROU_TO_LAST_USER'] = $aData['ROU_TO_LAST_USER'];
$oRoute->create($aFields);
$rou_id = $oRoute->create($aFields);
break;
case 'SELECT':
foreach ($aData['GRID_SELECT_TYPE'] as $iKey => $aRow)
@@ -62,7 +68,7 @@ switch ($aData['action']) {
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
//$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER'];
$oRoute->create($aFields);
$rou_id = $oRoute->create($aFields);
unset($aFields);
}
break;
@@ -80,7 +86,7 @@ switch ($aData['action']) {
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
//$aFields['ROU_TO_LAST_USER'] = $aRow['ROU_TO_LAST_USER'];
$oRoute->create($aFields);
$rou_id = $oRoute->create($aFields);
unset($aFields);
}
break;
@@ -96,7 +102,7 @@ switch ($aData['action']) {
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$oRoute->create($aFields);
$rou_id = $oRoute->create($aFields);
unset($aFields);
}
break;
@@ -107,17 +113,41 @@ switch ($aData['action']) {
{
$aFields['ROU_UID'] = $aRow['ROU_UID'];
}*/
$aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
$oRoute->create($aFields);
$aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$rou_id = $oRoute->create($aFields);
unset($aFields);
}
break;
case 'DISCRIMINATOR': //Girish ->Added to save changes, while editing the route
foreach ($aData['GRID_DISCRIMINATOR_TYPE'] as $iKey => $aRow)
{
$aFields['PRO_UID'] = $aData['PROCESS'];
$aFields['TAS_UID'] = $aData['TASK'];
$aFields['ROU_NEXT_TASK'] = $aRow['ROU_NEXT_TASK'];
$aFields['ROU_CASE'] = $iKey;
$aFields['ROU_TYPE'] = $aData['ROU_TYPE'];
$aFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
$aFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$routeData = $oTasks->getRouteByType($aData['PROCESS'], $aRow['ROU_NEXT_TASK'], $aData['ROU_TYPE']);
foreach($routeData as $route)
{
$sFields['ROU_UID'] = $route['ROU_UID'];
$sFields['ROU_CONDITION'] = $aRow['ROU_CONDITION'];
$sFields['ROU_OPTIONAL'] = $aRow['ROU_OPTIONAL'];
$rou_id = $oRoute->update($sFields);
}
$rou_id =$oRoute->create($aFields);
unset($aFields);
}
break;
}
break;
echo $rou_id;
}
?>

View File

@@ -142,7 +142,12 @@ try {
case 'addSubProcess':
$sOutput = $oProcessMap->addSubProcess($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'taskColor':
$oTask->taskColor($oData->pro_uid, $oData->tas_uid);
break;
case 'addTaskHidden':
$sOutput = $oProcessMap->addTaskHidden($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'editTaskProperties':
$oProcessMap->editTaskProperties($oData->uid, (isset($oData->iForm) ? $oData->iForm : 1), $oData->index);
break;
@@ -228,6 +233,9 @@ try {
case 5:
$oData->type = 'SEC-JOIN';
break;
case 8:
$oData->type = 'DISCRIMINATOR';
break;
}
$oProcessMap->newPattern($oData->pro_uid, $oData->tas_uid, $oData->next_task, $oData->type);
}
@@ -253,14 +261,17 @@ try {
case 5:
$sType = 'SEC-JOIN';
break;
case 8:
$sType = 'DISCRIMINATOR';
break;
}
if (($oData->type != 0) && ($oData->type != 5)) {
if (($oData->type != 0) && ($oData->type != 5) && ($oData->type != 8)) {
if ($oProcessMap->getNumberOfRoutes($oData->pro_uid, $oData->tas_uid, $oData->next_task, $sType) > 0) {
die;
}
unset($aRow);
}
if (($oData->delete) || ($oData->type == 0) || ($oData->type == 5)) {
if (($oData->delete) || ($oData->type == 0) || ($oData->type == 5) || ($oData->type == 8)) {
G::LoadClass('tasks');
$oTasks = new Tasks();
$oTasks->deleteAllRoutesOfTask($oData->pro_uid, $oData->tas_uid);

View File

@@ -0,0 +1,37 @@
<?php
/**
* processes_DownloadFile.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//add more security, and catch any error or exception
$sFileName = $_GET['p'] . '.xpdl';
$file=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName.'tpm';
$filex=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
if(file_exists($file))
{
rename($file, $filex);
}
$realPath = PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
G::streamFile ( $realPath, true );

View File

@@ -0,0 +1,131 @@
<?
/**
* processes_ImportFileExisting.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
try {
//load the variables
G::LoadClass('xpdl');
$oProcess = new Xpdl();
if ( !isset ($_POST['form']['IMPORT_OPTION'] ) ) {
throw ( new Exception ('Please select an option before to continue')) ;
}
if ( !isset ($_POST['form']['GROUP_IMPORT_OPTION']) ) {
$action = "none" ;
} else {
$action = $_POST['form']['GROUP_IMPORT_OPTION'];
}
$option = $_POST['form']['IMPORT_OPTION'];
$filename = $_POST['form']['PRO_FILENAME'];
$ObjUid = $_POST['form']['OBJ_UID'];
$path = PATH_DOCUMENT . 'input' . PATH_SEP ;
$oData = $oProcess->getProcessDataXpdl ( $path . $filename );
$Fields['PRO_FILENAME'] = $filename;
$sProUid = $oData->process['PRO_UID'];
$oData->process['PRO_UID_OLD']=$sProUid;
$tasks = $oData->tasks;
// code added by gustavo cruz gustavo-at-colosa-dot-com
// evaluate actions or import options
switch($action){
case "none":
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
case "rename":
$oData->groupwfs = $oProcess->renameExistingGroups($oData->groupwfs);
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
case "merge":
$oBaseGroup = $oData->groupwfs;
$oNewGroup = $oProcess->mergeExistingGroups($oData->groupwfs);
$oData->groupwfs = $oNewGroup;
$oData->taskusers = $oProcess->mergeExistingUsers($oBaseGroup, $oNewGroup, $oData->taskusers);
break;
default:
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
}
// if there are duplicated groups render the group importing options
if($groupsDuplicated>0){
$Fields['PRO_FILENAME'] = $filename;
$Fields['PRO_PATH'] = $path;
$Fields['IMPORT_OPTION'] = $option;
$Fields['OBJ_UID'] = $ObjUid;
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_ValidatingGroups', '', $Fields, 'processes_ImportExisting' );
G::RenderPage('publish');
die;
}
//end added code
//Update the current Process, overwriting all tasks and steps
if ( $option == 1 ) {
$oProcess->updateProcessFromData ($oData, $path . $filename );
if (file_exists(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid)) {
$oDirectory = dir(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid);
while($sObjectName = $oDirectory->read()) {
if (($sObjectName != '.') && ($sObjectName != '..')) {
unlink(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid . PATH_SEP . $sObjectName);
}
}
$oDirectory->close();
}
$sNewProUid = $sProUid;
}
//Disable current Process and create a new version of the Process
if ( $option == 2 ) {
$oProcess->disablePreviousProcesses( $sProUid );
$sNewProUid = $oProcess->getUnusedProcessGUID() ;
$oProcess->setProcessGuid ( $oData, $sNewProUid );
$oProcess->setProcessParent( $oData, $sProUid );
$oData->process['PRO_TITLE'] = "New - " . $oData->process['PRO_TITLE'] . ' - ' . date ( 'M d, H:i' );
$oProcess->renewAll ( $oData );
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
}
//Create a completely new Process without change the current Process
if ( $option == 3 ) {
//krumo ($oData); die;
$sNewProUid = $oProcess->getUnusedProcessGUID() ;
$oProcess->setProcessGuid ( $oData, $sNewProUid );
$oData->process['PRO_TITLE'] = "Copy of - " . $oData->process['PRO_TITLE'] . ' - ' . date ( 'M d, H:i' );
$oProcess->renewAll ( $oData );
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
}
G::header('Location: processes_Map?PRO_UID=' . $sNewProUid);
}
catch ( Exception $e ){
$G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage('publish');
}

View File

@@ -0,0 +1,105 @@
<?
/**
* processes_ImportFile.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
try {
//load the variables
G::LoadClass('xpdl');
$oProcess = new Xpdl();
if (isset($_POST['form']['PRO_FILENAME'])){
$path = $_POST['form']['PRO_PATH'];
$filename = $_POST['form']['PRO_FILENAME'];
$action = $_POST['form']['GROUP_IMPORT_OPTION'];
} else {
//save the file, if it's not saved
if ($_FILES['form']['error']['PROCESS_FILENAME'] == 0) {
$filename = $_FILES['form']['name']['PROCESS_FILENAME'];
$path = PATH_DOCUMENT . 'input' . PATH_SEP ;
$tempName = $_FILES['form']['tmp_name']['PROCESS_FILENAME'];
$action = "none";
G::uploadFile($tempName, $path, $filename );
}
}
$oData = $oProcess->getProcessDataXpdl ( $path . $filename );
$Fields['PRO_FILENAME'] = $filename;
$Fields['IMPORT_OPTION'] = 2;
$sProUid = $oData->process['PRO_UID'];
$oData->process['PRO_UID_OLD']=$sProUid;
if ( $oProcess->processExists ( $sProUid ) ) {
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_ImportExistingXpdl', '', $Fields, 'processes_ImportExistingXpdl' );
G::RenderPage('publish');
die;
}
// code added by gustavo cruz gustavo-at-colosa-dot-com
// evaluate actions or import options
switch($action){
case "none":
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
case "rename":
$oData->groupwfs = $oProcess->renameExistingGroups($oData->groupwfs);
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
case "merge":
$oBaseGroup = $oData->groupwfs;
$oNewGroup = $oProcess->mergeExistingGroups($oData->groupwfs);
$oData->groupwfs = $oNewGroup;
$oData->taskusers = $oProcess->mergeExistingUsers($oBaseGroup, $oNewGroup, $oData->taskusers);
break;
default:
$groupsDuplicated = $oProcess->checkExistingGroups($oData->groupwfs);
break;
}
// if there are duplicated groups render the group importing options
if($groupsDuplicated>0){
$Fields['PRO_FILENAME'] = $filename;
$Fields['PRO_PATH'] = $path;
$Fields['IMPORT_OPTION'] = 2;
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_ValidatingGroups', '', $Fields, 'processes_ImportFile' );
G::RenderPage('publish');
die;
}
// end added code
$tasks = $oData->tasks;
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
G::header('Location: processes_Map?PRO_UID=' . $sProUid);
}
catch ( Exception $e ){
$G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage('publish');
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* processes_Import.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$access = $RBAC->userCanAccess('PM_FACTORY');
if( $access != 1 ){
switch ($access)
{
case -1:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
break;
case -2:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
G::header('location: ../login/login');
die;
break;
default:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
break;
}
}
try {
/* Includes */
G::LoadClass('processes');
/* Render page */
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_ImportXpdl', '', NULL, 'processes_ImportFileXpdl' );
G::RenderPage( "publish" );
}
catch ( Exception $e ){
$G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage('publish');
}

View File

@@ -26,322 +26,339 @@
global $RBAC;
switch ($RBAC->userCanAccess('PM_FACTORY'))
{
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;
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;
}
$request = (isset($_POST['action']))?$_POST['action']:$_POST['request'];
switch ($request) {
case 'testEmailConfiguration':
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$aFields['FROM_EMAIL'] = $_POST['usermail'];
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_TestForm','', $aFields);
G::RenderPage('publish', 'raw');
break;
case 'sendTestMail':
$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;
}
$colosa_msg = "This Business Process is powered by <b>ProcessMaker</b>.";
$sBody = "
<table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>
<tbody><tr><td><img id='logo' src='http://".$_SERVER['SERVER_NAME']."/images/processmaker.logo.jpg' /></td></tr>
<tr><td style='font-size: 14px;'>$msg $engine [".date('H:i:s')."]</td></tr>
<tr><td style='vertical-align:middel;'>
<br /><hr><b>This Business Process is powered by ProcessMaker.<b><br />
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
</tr></tbody></table>";
case 'testEmailConfiguration':
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$aFields['FROM_EMAIL'] = $_POST['usermail'];
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_TestForm','', $aFields);
G::RenderPage('publish', 'raw');
break;
case 'sendTestMail':
$sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>';
$sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
$msg = G::LoadTranslation('ID_MESS_TEST_BODY');
G::LoadClass('spool');
$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']
));
$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'
));
$oSpool->sendMail();
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
if ($oSpool->status == 'sent') {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_Sended', '', array('MESSAGE_VALUE' => G::LoadTranslation('ID_MESS_TEST_MESSAGE_SENDED')));
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;
}
$colosa_msg = "This Business Process is powered by <b>ProcessMaker</b>.";
$sBody = "
<table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>
<tbody><tr><td><img id='logo' src='http://".$_SERVER['SERVER_NAME']."/images/processmaker.logo.jpg' /></td></tr>
<tr><td style='font-size: 14px;'>$msg $engine [".date('H:i:s')."]</td></tr>
<tr><td style='vertical-align:middel;'>
<br /><hr><b>This Business Process is powered by ProcessMaker.<b><br />
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
</tr></tbody></table>";
G::LoadClass('spool');
$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']
));
$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'
));
$oSpool->sendMail();
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
if ($oSpool->status == 'sent') {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_Sended', '', array('MESSAGE_VALUE' => G::LoadTranslation('ID_MESS_TEST_MESSAGE_SENDED')));
}
else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_Sended', '', array('MESSAGE_VALUE' => G::LoadTranslation('ID_MESS_TEST_MESSAGE_ERROR_PHP_MAIL') . $oSpool->error));
}
G::RenderPage('publish', 'raw');
break;
/**********************************************************************************/
case 'mailTest_Show':
$srv = $_POST['srv'];
$port = $_POST['port'];
$account = $_POST['account'];
$passwd = $_POST['passwd'];
$auth_required = $_POST['auth_required'];
$send_test_mail = $_POST['send_test_mail'];
$mail_to = $_POST['mail_to'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'setup/mailConnectiontest');
G::RenderPage('publish', 'raw');
break;
case 'mailTestMail_Show':
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;
$resp = sendTestMail();
if($resp->status){
print(SUCCESSFUL.','.$resp->msg);
} else {
print(FAILED.','.$resp->msg);
}
else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/emails_Sended', '', array('MESSAGE_VALUE' => G::LoadTranslation('ID_MESS_TEST_MESSAGE_ERROR_PHP_MAIL') . $oSpool->error));
}
G::RenderPage('publish', 'raw');
break;
/**********************************************************************************/
case 'mailTest_Show':
$srv = $_POST['srv'];
$port = $_POST['port'];
$account = $_POST['account'];
$passwd = $_POST['passwd'];
$auth_required = $_POST['auth_required'];
$send_test_mail = $_POST['send_test_mail'];
$mail_to = $_POST['mail_to'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'setup/mailConnectiontest');
G::RenderPage('publish', 'raw');
break;
case 'mailTestMail_Show':
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;
$resp = sendTestMail();
if($resp->status){
print(SUCCESSFUL.','.$resp->msg);
}
else {
print(FAILED.','.$resp->msg);
}
break;
case 'testConnection':
G::LoadClass('net');
require_once('classes/class.smtp.rfc-821.php');
define("SUCCESSFUL", 'SUCCESSFUL');
define("FAILED", 'FAILED');
//$host = 'smtp.bizmail.yahoo.com';
$tld = ereg("([^//]*$)", $_POST['srv'], $regs);
case 'testConnection':
G::LoadClass('net');
require_once('classes/class.smtp.rfc-821.php');
define("SUCCESSFUL", 'SUCCESSFUL');
define("FAILED", 'FAILED');
//$host = 'smtp.bizmail.yahoo.com';
$tld = ereg("([^//]*$)", $_POST['srv'], $regs);
$srv1 = $regs[1];
$srv = $_POST['srv'];
$port = ($_POST['port'] == 'default')? 25: $_POST['port'];
$user = $_POST['account'];
$passwd = $_POST['passwd'];
$step = $_POST['step'];
$auth_required = $_POST['auth_required'];
$send_test_mail = $_POST['send_test_mail'];
$mail_to = $_POST['mail_to'];
$Server = new NET($srv1);
$oSMTP = new ESMTP;
switch ($step) {
case 1:
if ($Server->getErrno() == 0) {
print(SUCCESSFUL.',');
} else {
print(FAILED.','.$Server->error);
}
break;
case 2:
if($port == 0){
$port = $oSMTP->SMTP_PORT;
}
$Server->scannPort($port);
if ($Server->getErrno() == 0) {
print(SUCCESSFUL.',');
} else {
print(FAILED.','.$Server->error);
}
break;
#try to connect to host
case 3:
if($port == 0){
$resp = $oSMTP->Connect($srv);
} else {
$resp = $oSMTP->Connect($srv, $port);
}
if( !$resp) {
print(FAILED.','.$oSMTP->error['error']);
} else {
print(SUCCESSFUL.','.$oSMTP->status);
}
break;
#try login to host
case 4:
if($auth_required == 'yes'){
if($port == 0){
$resp = $oSMTP->Connect($srv);
} else {
$resp = $oSMTP->Connect($srv, $port);
}
if($resp) {
$oSMTP->do_debug = false;
$oSMTP->Hello($srv);
if( !$oSMTP->Authenticate($user, $passwd) ) {
print(FAILED.','.$oSMTP->error['error']);
} else {
print(SUCCESSFUL.','.$oSMTP->status);
}
} else {
print(FAILED.','.$oSMTP->error['error']);
}
} else {
print(SUCCESSFUL.', No authentication required!');
}
break;
case 5:
if($send_test_mail == 'yes'){
//print(SUCCESSFUL.',ok');
$_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]';
$_POST['FROM_EMAIL'] = $user;
$_POST['MESS_ENGINE'] = 'PHPMAILER';
$_POST['MESS_SERVER'] = $srv;
$_POST['MESS_PORT'] = $port;
$_POST['MESS_ACCOUNT'] = $user;
$_POST['MESS_PASSWORD'] = $passwd;
$_POST['TO'] = $mail_to;
if($auth_required == 'yes'){
$_POST['SMTPAuth'] = true;
} else {
$_POST['SMTPAuth'] = false;
}
$resp = sendTestMail();
if($resp->status){
print(SUCCESSFUL.','.$resp->msg);
} else {
print(FAILED.','.$resp->msg);
}
} else {
print('jump this step');
}
break;
default:
print('test finished!');
}
break;
$srv = $_POST['srv'];
$port = ($_POST['port'] == 'default')? 25: $_POST['port'];
$user = $_POST['account'];
$passwd = $_POST['passwd'];
$step = $_POST['step'];
$auth_required = $_POST['auth_required'];
$send_test_mail = $_POST['send_test_mail'];
$mail_to = $_POST['mail_to'];
$Server = new NET($srv1);
$oSMTP = new ESMTP;
switch ($step) {
case 1:
if ($Server->getErrno() == 0) {
print(SUCCESSFUL.',');
} else {
print(FAILED.','.$Server->error);
}
break;
case 2:
if($port == 0){
$port = $oSMTP->SMTP_PORT;
}
$Server->scannPort($port);
if ($Server->getErrno() == 0) {
print(SUCCESSFUL.',');
} else {
print(FAILED.','.$Server->error);
}
break;
#try to connect to host
case 3:
if($port == 0){
$resp = $oSMTP->Connect($srv);
} else {
$resp = $oSMTP->Connect($srv, $port);
}
if( !$resp) {
print(FAILED.','.$oSMTP->error['error']);
} else {
print(SUCCESSFUL.','.$oSMTP->status);
}
break;
#try login to host
case 4:
if($auth_required == 'yes'){
if($port == 0){
$resp = $oSMTP->Connect($srv);
} else {
$resp = $oSMTP->Connect($srv, $port);
}
if($resp) {
$oSMTP->do_debug = false;
$oSMTP->Hello($srv);
if( !$oSMTP->Authenticate($user, $passwd) ) {
print(FAILED.','.$oSMTP->error['error']);
} else {
print(SUCCESSFUL.','.$oSMTP->status);
}
} else {
print(FAILED.','.$oSMTP->error['error']);
}
} else {
print(SUCCESSFUL.', No authentication required!');
}
break;
case 5:
if($send_test_mail == 'yes'){
//print(SUCCESSFUL.',ok');
$_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]';
$_POST['FROM_EMAIL'] = $user;
$_POST['MESS_ENGINE'] = 'PHPMAILER';
$_POST['MESS_SERVER'] = $srv;
$_POST['MESS_PORT'] = $port;
$_POST['MESS_ACCOUNT'] = $user;
$_POST['MESS_PASSWORD'] = $passwd;
$_POST['TO'] = $mail_to;
if($auth_required == 'yes'){
$_POST['SMTPAuth'] = true;
} else {
$_POST['SMTPAuth'] = false;
}
$resp = sendTestMail();
if($resp->status){
print(SUCCESSFUL.','.$resp->msg);
} else {
print(FAILED.','.$resp->msg);
}
} else {
print('jump this step');
}
break;
default:
print('test finished!');
}
break;
}
function sendTestMail() {
$sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>';
$sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
$msg = G::LoadTranslation('ID_MESS_TEST_BODY');
$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;
}
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;
}
$colosa_msg = "This Business Process is powered by <b>ProcessMaker</b>.";
$sBody = "
<table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>
<tbody><tr><td><img id='logo' src='http://".$_SERVER['SERVER_NAME']."/images/processmaker.logo.jpg' /></td></tr>
<tr><td style='font-size: 14px;'>$msg [".date('H:i:s')."] - $engine</td></tr>
<tr><td style='vertical-align:middel;'>
<br /><hr><b>This Business Process is powered by ProcessMaker.<b><br />
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
</tr></tbody></table>";
$colosa_msg = "This Business Process is powered by <b>ProcessMaker</b>.";
$sBody = "
<table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>
<tbody><tr><td><img id='logo' src='http://".$_SERVER['SERVER_NAME']."/images/processmaker.logo.jpg' /></td></tr>
<tr><td style='font-size: 14px;'>$msg [".date('H:i:s')."] - $engine</td></tr>
<tr><td style='vertical-align:middel;'>
<br /><hr><b>This Business Process is powered by ProcessMaker.<b><br />
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
</tr></tbody></table>";
G::LoadClass('spool');
$oSpool = new spoolRun();
G::LoadClass('spool');
$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']
));
$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']
));
$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'
));
$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'
));
$oSpool->sendMail();
$oSpool->sendMail();
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
if ($oSpool->status == 'sent') {
$o->status = true;
$o->msg = G::LoadTranslation('ID_MESS_TEST_MESSAGE_SENDED');
}
else {
$o->status = false;
$o->msg = $oSpool->error;
}
return $o;
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
if ($oSpool->status == 'sent') {
$o->status = true;
$o->msg = G::LoadTranslation('ID_MESS_TEST_MESSAGE_SENDED');
}
else {
$o->status = false;
$o->msg = $oSpool->error;
}
return $o;
}
function e_utf8_encode($input) {
$utftext = null;
$utftext = null;
for ($n = 0; $n < strlen($input); $n++) {
for ($n = 0; $n < strlen($input); $n++) {
$c = ord($input[$n]);
$c = ord($input[$n]);
if ($c < 128) {
$utftext .= chr($c);
} else if (($c > 128) && ($c < 2048)) {
$utftext .= chr(($c >> 6) | 192);
$utftext .= chr(($c & 63) | 128);
} else {
$utftext .= chr(($c >> 12) | 224);
$utftext .= chr((($c & 6) & 63) | 128);
$utftext .= chr(($c & 63) | 128);
}
}
if ($c < 128) {
$utftext .= chr($c);
} else if (($c > 128) && ($c < 2048)) {
$utftext .= chr(($c >> 6) | 192);
$utftext .= chr(($c & 63) | 128);
} else {
$utftext .= chr(($c >> 12) | 224);
$utftext .= chr((($c & 6) & 63) | 128);
$utftext .= chr(($c & 63) | 128);
}
}
return $utftext;
return $utftext;
}