Exemplo n.º 1
0
 G::LoadClass('processes');
 $oProcess = new Processes();
 $oProcess->downloadFile($downloadUrl, $localPath, $newfilename);
 //getting the ProUid from the file recently downloaded
 $oData = $oProcess->getProcessData($localPath . $newfilename);
 if (is_null($oData)) {
     throw new Exception('Error');
 }
 $Fields['IMPORT_OPTION'] = 2;
 $Fields['PRO_FILENAME'] = $newfilename;
 $Fields['OBJ_UID'] = $ObjUid;
 $sProUid = $oData->process['PRO_UID'];
 $oData->process['PRO_UID_OLD'] = $sProUid;
 //print $sProUid;die;
 //if the process exists, we need to ask what kind of re-import the user wants,
 if ($oProcess->processExists($sProUid)) {
     $G_MAIN_MENU = 'processmaker';
     $G_ID_MENU_SELECTED = 'PROCESSES';
     $G_PUBLISH = new Publisher();
     $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_ImportExisting', '', $Fields, 'downloadPML_ImportExisting');
     G::RenderPage('publish', 'blank');
     die;
 }
 //creating the process
 $oProcess->createProcessFromData($oData, $localPath . $newfilename);
 //show the info after the imported process
 G::LoadClass('processes');
 $oProcess = new Processes();
 $oProcess->ws_open_public();
 $processData = $oProcess->ws_processGetData($ObjUid);
 $Fields['pro_title'] = $processData->title;
Exemplo n.º 2
0
    /**

     * creates a new case impersonating a user who has the proper privileges to create new cases

     *

     * @param string $processId

     * @param string $userId

     * @param string $variables

     * @param string $taskId, must be in the starting group.

     * @return $result will return an object

     */

    public function newCaseImpersonate ($processId, $userId, $variables, $taskId = '')

    {

        try {

            if (is_array( $variables )) {

                if (count( $variables ) > 0) {

                    $c = count( $variables );

                    $Fields = $variables;

                } else {

                    if ($c == 0) {

                        $result = new wsResponse( 10, G::loadTranslation( 'ID_ARRAY_VARIABLES_EMPTY' ) );



                        return $result;

                    }

                }

            } else {

                $result = new wsResponse( 10, G::loadTranslation( 'ID_VARIABLES_PARAM_NOT_ARRAY' ) );



                return $result;

            }



            $processes = new Processes();



            if (! $processes->processExists( $processId )) {

                $result = new wsResponse( 11, G::loadTranslation( 'ID_INVALID_PROCESS' ) . " " . $processId . "!!" );



                return $result;

            }



            $user = new Users();



            if (! $user->userExists( $userId )) {

                $result = new wsResponse( 11, G::loadTranslation( 'ID_USER_NOT_REGISTERED' ) . " " . $userId . "!!" );



                return $result;

            }



            $oCase = new Cases();



            $numTasks = 0;

            if ($taskId != '') {

                $aTasks = $processes->getStartingTaskForUser( $processId, null );

                foreach ($aTasks as $task) {

                    if ($task['TAS_UID'] == $taskId) {

                        $arrayTask[0]['TAS_UID'] = $taskId;

                        $numTasks = 1;

                    }

                }

            } else {

                $arrayTask = $processes->getStartingTaskForUser( $processId, null );

                $numTasks = count( $arrayTask );

            }



            if ($numTasks == 1) {

                $case = $oCase->startCase( $arrayTask[0]['TAS_UID'], $userId );

                $caseId = $case['APPLICATION'];

                $caseNumber = $case['CASE_NUMBER'];



                $oldFields = $oCase->loadCase( $caseId );



                $oldFields['APP_DATA'] = array_merge( $oldFields['APP_DATA'], $Fields );



                $up_case = $oCase->updateCase( $caseId, $oldFields );



                $result = new wsResponse( 0, G::loadTranslation( 'ID_COMMAND_EXECUTED_SUCCESSFULLY' ) );



                $result->caseId = $caseId;

                $result->caseNumber = $caseNumber;



                return $result;

            } else {

                if ($numTasks == 0) {

                    $result = new wsResponse( 12, G::loadTranslation( 'ID_NO_STARTING_TASK' ) );



                    return $result;

                }



                if ($numTasks > 1) {

                    $result = new wsResponse( 13, G::loadTranslation( 'ID_MULTIPLE_STARTING_TASKS' ) );



                    return $result;

                }

            }

        } catch (Exception $e) {

            $result = new wsResponse( 100, $e->getMessage() );



            return $result;

        }

    }
Exemplo n.º 3
0
            $aData = Array('pro_uid' => $_REQUEST['pro_uid'], 'fcontent' => $fcontent, 'filename' => $_REQUEST['filename']);
            $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_FileEdit', '', $aData);
            G::RenderPage('publish', 'raw');
            // $G_PUBLISH->AddContent( 'view', 'processes/processesFileEditEmail' );
            // G::RenderPage( 'publish', 'blank' );
            break;
        case 'saveFile':
            $_REQUEST['pro_uid'] = $filter->xssFilterHard($_REQUEST['pro_uid']);
            $_REQUEST['filename'] = $filter->xssFilterHard($_REQUEST['filename']);
            global $G_PUBLISH;
            $G_PUBLISH = new Publisher();
            global $RBAC;
            if ( $RBAC->userCanAccess('PM_FACTORY') == 1) {
                G::LoadClass('processes');
                $app = new Processes();
                if (!$app->processExists($_REQUEST['pro_uid'])) {
                    echo G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED');
                    die;
                }

                $sDir = "";
                if (isset($_REQUEST['MAIN_DIRECTORY'])) {
                    $_REQUEST['MAIN_DIRECTORY'] = $filter->xssFilterHard($_REQUEST['MAIN_DIRECTORY']);
                    $sDir = $_REQUEST['MAIN_DIRECTORY'];
                }
                switch ($sDir) {
                    case 'mailTemplates':
                        $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
                        G::auditLog('ProcessFileManager','Save template ('.$_REQUEST['filename'].') in process "'.$resultProcess['PRO_TITLE'].'"');
                        break;
                    case 'public':
<?php

global $RBAC;
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
    G::LoadClass('processes');
    $app = new Processes();
    if (!$app->processExists($_POST['form']['PRO_UID'])) {
        echo G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED');
        die;
    }
    switch ($_POST['form']['MAIN_DIRECTORY']) {
        case 'mailTemplates':
            $sDirectory = PATH_DATA_MAILTEMPLATES . $_POST['form']['PRO_UID'] . PATH_SEP . ($_POST['form']['CURRENT_DIRECTORY'] != '' ? $_POST['form']['CURRENT_DIRECTORY'] . PATH_SEP : '');
            break;
        case 'public':
            $sDirectory = PATH_DATA_PUBLIC . $_POST['form']['PRO_UID'] . PATH_SEP . ($_POST['form']['CURRENT_DIRECTORY'] != '' ? $_POST['form']['CURRENT_DIRECTORY'] . PATH_SEP : '');
            break;
        default:
            die;
            break;
    }
    for ($i = 1; $i <= 5; $i++) {
        if ($_FILES['form']['tmp_name']['FILENAME' . (string) $i] != '') {
            G::uploadFile($_FILES['form']['tmp_name']['FILENAME' . (string) $i], $sDirectory, $_FILES['form']['name']['FILENAME' . (string) $i]);
        }
    }
}
die('<script type="text/javascript">parent.goToDirectoryforie(\'' . $_POST['form']['PRO_UID'] . '\', \'' . $_POST['form']['MAIN_DIRECTORY'] . '\', \'' . $_POST['form']['CURRENT_DIRECTORY'] . '\');</script>');
Exemplo n.º 5
0
 /**
  * import process fromLibrary: downloads and imports a process from the ProcessMaker library
  *
  * @param string sessionId : The session ID (which was obtained at login).
  * @param string processId :
  * @param string version :
  * @param string importOption :
  * @param string usernameLibrary : The username to obtain access to the ProcessMaker library.
  * @param string passwordLibrary : The password to obtain access to the ProcessMaker library.
  * @return $eturns will return an object
  */
 public function importProcessFromLibrary($processId, $version = '', $importOption = '', $usernameLibrary = '', $passwordLibrary = '')
 {
     try {
         G::LoadClass('processes');
         //$versionReq = $_GET['v'];
         //. (isset($_GET['s']) ? '&s=' . $_GET['s'] : '')
         $ipaddress = $_SERVER['REMOTE_ADDR'];
         $oProcesses = new Processes();
         $oProcesses->ws_open_public();
         $oProcess = $oProcesses->ws_processGetData($processId);
         if ($oProcess->status_code != 0) {
             throw new Exception($oProcess->message);
         }
         $privacy = $oProcess->privacy;
         $strSession = '';
         if ($privacy != 'FREE') {
             global $sessionId;
             $antSession = $sessionId;
             $oProcesses->ws_open($usernameLibrary, $passwordLibrary);
             $strSession = "&s=" . $sessionId;
             $sessionId = $antSession;
         }
         //downloading the file
         $localPath = PATH_DOCUMENT . 'input' . PATH_SEP;
         G::mk_dir($localPath);
         $newfilename = G::GenerateUniqueId() . '.pm';
         $downloadUrl = PML_DOWNLOAD_URL . '?id=' . $processId . $strSession;
         $oProcess = new Processes();
         $oProcess->downloadFile($downloadUrl, $localPath, $newfilename);
         //getting the ProUid from the file recently downloaded
         $oData = $oProcess->getProcessData($localPath . $newfilename);
         if (is_null($oData)) {
             $data['DOWNLOAD_URL'] = $downloadUrl;
             $data['LOCAL_PATH'] = $localPath;
             $data['NEW_FILENAME'] = $newfilename;
             throw new Exception(G::loadTranslation('ID_ERROR_URL_PROCESS_INVALID', SYS_LANG, $data));
         }
         $sProUid = $oData->process['PRO_UID'];
         $oData->process['PRO_UID_OLD'] = $sProUid;
         //if the process exists, we need to check the $importOption to and re-import if the user wants,
         if ($oProcess->processExists($sProUid)) {
             //Update the current Process, overwriting all tasks and steps
             if ($importOption == 1) {
                 $oProcess->updateProcessFromData($oData, $localPath . $newfilename);
                 //delete the xmlform cache
                 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 != '..') {
                             $strAux = PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP;
                             $strAux = $strAux . $sProUid . PATH_SEP . $sObjectName;
                             unlink($strAux);
                         }
                     }
                     $oDirectory->close();
                 }
                 $sNewProUid = $sProUid;
             }
             //Disable current Process and create a new version of the Process
             if ($importOption == 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->createProcessFromData($oData, $localPath . $newfilename);
             }
             //Create a completely new Process without change the current Process
             if ($importOption == 3) {
                 //krumo ($oData); die;
                 $sNewProUid = $oProcess->getUnusedProcessGUID();
                 $oProcess->setProcessGuid($oData, $sNewProUid);
                 $strAux = "Copy of  - " . $oData->process['PRO_TITLE'] . ' - ' . date('M d, H:i');
                 $oData->process['PRO_TITLE'] = $strAux;
                 $oProcess->renewAll($oData);
                 $oProcess->createProcessFromData($oData, $localPath . $newfilename);
             }
             if ($importOption != 1 && $importOption != 2 && $importOption != 3) {
                 throw new Exception(G::loadTranslation('ID_PROCESS_ALREADY_IN_SYSTEM'));
             }
         }
         //finally, creating the process if the process doesn't exist
         if (!$oProcess->processExists($processId)) {
             $oProcess->createProcessFromData($oData, $localPath . $newfilename);
         }
         //show the info after the imported process
         $oProcess = new Processes();
         $oProcess->ws_open_public();
         $processData = $oProcess->ws_processGetData($processId);
         $result->status_code = 0;
         $result->message = G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY');
         $result->timestamp = date('Y-m-d H:i:s');
         $result->processId = $processId;
         $result->processTitle = $processData->title;
         $result->category = isset($processData->category) ? $processData->category : '';
         $result->version = $processData->version;
         return $result;
     } catch (Exception $e) {
         $result = new wsResponse(100, $e->getMessage());
         return $result;
     }
 }
Exemplo n.º 6
0
<?php

sleep(1);
global $RBAC;
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
    if (isset($_SESSION['processes_upload'])) {
        $form = $_SESSION['processes_upload'];
        G::LoadClass('processes');
        $app = new Processes();
        if (!$app->processExists($form['PRO_UID'])) {
            $result = 0;
            $msg = G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED');
            echo "{'result': {$result}, 'msg':'{$msg}'}";
            die;
        }
        switch ($form['MAIN_DIRECTORY']) {
            case 'mailTemplates':
                $sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
                break;
            case 'public':
                $sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
                break;
            default:
                die;
                break;
        }
    }
    if ($_FILES['form']['error'] == "0") {
        G::uploadFile($_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name']);
        $msg = "Uploaded (" . round(filesize($sDirectory . $_FILES['form']['name']) / 1024 * 10) / 10 . " kb)";
        $result = 1;