diff --git a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature index 49507542c..14a12a1b7 100644 --- a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature @@ -23,7 +23,7 @@ Scenario: Returns an uploaded documents for a given case Scenario: Post metadata and then upload documents for a given case - Given POST upload an input document "/uploadfiles/test1.html" to "cases/170220159534214f642abb8058832933/input-document" + Given POST upload an input document "test1.html" to "cases/170220159534214f642abb8058832933/input-document" """ { diff --git a/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature b/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature index 58d63e538..59db02829 100644 --- a/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature @@ -33,11 +33,11 @@ Scenario Outline: Post metadata and then upload documents for a given case And store "app_doc_uid" in session array as variable "app_doc_uid_" Examples: - | app_doc_uid_number | document_file | case_uid | inp_doc_uid | tas_uid | app_doc_comment | - | 1 | /uploadfiles/test1.html | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | - | 2 | /uploadfiles/random.jpg | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | - | 3 | /uploadfiles/test.pm | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | - | 4 | /uploadfiles/test.txt | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | + | app_doc_uid_number | document_file | case_uid | inp_doc_uid | tas_uid | app_doc_comment | + | 1 | test1.html | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | + | 2 | random.jpg | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | + | 3 | test.pm | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | + | 4 | test.txt | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | Scenario Outline: Returns an uploaded documents for a given case Given I request "cases//input-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" diff --git a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature index bfdd20bdb..400bebb83 100644 --- a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature +++ b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature @@ -59,6 +59,8 @@ Scenario Outline: Create a 13 case scheduler for a project | Create with One time only | 12 | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-One Time only 678%$@ | 4 | | | 20:00 | | | | | | | | Create with Every | 13 | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-Every 987&%@ | 5 | | | | | | | | | 12.30 | | Create with Daily - Test BUG 15316 | 14 | admin | 46941969352af5be2ab3f39001216717 | Bug 15316 | 1 | 2014-01-30 | | 12:00 | | | | | | | + | Test BUG 15330, 15331: Every format in the properties Invalid Start Timer 1.00 | 15 | admin | 46941969352af5be2ab3f39001216717 | BUG 15330 1.0 | 5 | | | | | | | | | 1.00 | + | Test BUG 15330, 15331: Every format in the properties Invalid Start Timer 01.00 | 16 | admin | 46941969352af5be2ab3f39001216717 | BUG 15330 01.00 | 5 | | | | | | | | | 01.00 | Scenario: Create a new case scheduler with same name @@ -82,7 +84,7 @@ Scenario: Create a new case scheduler with same name """ And I request "project/1265557095225ff5c688f46031700471/case-scheduler" Then the response status code should be 400 - And the response status message should have the following text "Duplicate Case Scheduler name" + And the response status message should have the following text "Duplicate" Scenario: Get the case schedulers list when there are exactly 13 case schedulers @@ -91,7 +93,7 @@ Scenario: Get the case schedulers list when there are exactly 13 case schedulers And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 14 record + And the response has 16 record Scenario Outline: Update the case schedulers for a project and then check if the values had changed @@ -184,6 +186,8 @@ Scenario Outline: Delete all case scheduler of a project created previously in t | 12 | | 13 | | 14 | + | 15 | + | 16 | diff --git a/features/backend/projects/files_manager/main_test_files_manager.feature b/features/backend/projects/files_manager/main_test_files_manager.feature index 07b937df7..b841470d6 100644 --- a/features/backend/projects/files_manager/main_test_files_manager.feature +++ b/features/backend/projects/files_manager/main_test_files_manager.feature @@ -50,11 +50,11 @@ Scenario Outline: Create files and subfolders And store "prf_uid" in session array as variable "prf_uid_" Examples: - | test_description | prf_filename | prf_path | prf_content | http_code | type | prf_number | - | into public folder | file_test_1.txt | public/ | only text | 200 | object | 0 | - | into mailtemplates folder | file_test_2.html | templates/ |

Test

html test

| 200 | object | 1 | - | into public subfolder | file_test_3 | public/public_subfolder | test | 200 | object | 2 | - | into mailtemplates subfolder | file_test_4 | templates/templates_subfolder | test | 200 | object | 3 | + | test_description | prf_filename | prf_path | prf_content | http_code | type | prf_number | + | into public folder | file_test_1.txt | public/ | only text | 200 | object | 0 | + | into mailtemplates folder | file_test_2.html | templates/ |

Test

html test

| 200 | object | 1 | + | into public subfolder | file_test_3 | public/public_subfolder | test | 200 | object | 2 | + | into mailtemplates subfolder | file_test_4 | templates/templates_subfolder | test | 200 | object | 3 | Scenario: Create files and subfolders with same name in path public @@ -100,11 +100,11 @@ Scenario Outline: Update files by updating the content And the type is "" Examples: - | test_description | prf_filename | prf_content | http_code | type | prf_number | - | put into public folder | file_test_1.txt | only text - modified | 200 | object | 0 | - | put into mailtemplates folder | file_test_2.html |

Test

html test

modified | 200 | object | 1 | - | put into public subfolder | file_test_3 | put test | 200 | object | 2 | - | put into mailtemplates subfolder | file_test_4 | put test | 200 | object | 3 | + | test_description | prf_filename | prf_content | http_code | type | prf_number | + | put into public folder | file_test_1.txt | only text - modified | 200 | object | 0 | + | put into mailtemplates folder | file_test_2.html |

Test

html test

modified | 200 | object | 1 | + | put into public subfolder | file_test_3 | put test | 200 | object | 2 | + | put into mailtemplates subfolder | file_test_4 | put test | 200 | object | 3 | Scenario Outline: Get a single Files Manager and check some properties @@ -119,11 +119,11 @@ Scenario Outline: Get a single Files Manager and check some properties And that "prf_content" is set to "" Examples: - | test_description | prf_filename | prf_content | http_code | type | prf_number | row | prf_path | - | put into public folder | file_test_1.txt | only text - modified | 200 | object | 0 | 1 | public/ | - | put into mailtemplates folder | file_test_2.html |

Test

html test

modified | 200 | object | 1 | 1 | templates/ | - | put into public subfolder | file_test_3 | put test | 200 | object | 2 | 0 | public/public_subfolder | - | put into mailtemplates subfolder | file_test_4 | put test | 200 | object | 3 | 0 | templates/templates_subfolder | + | test_description | prf_filename | prf_content | http_code | type | prf_number | row | prf_path | + | put into public folder | file_test_1.txt | only text - modified | 200 | object | 0 | 1 | public/ | + | put into mailtemplates folder | file_test_2.html |

Test

html test

modified | 200 | object | 1 | 1 | templates/ | + | put into public subfolder | file_test_3 | put test | 200 | object | 2 | 0 | public/public_subfolder | + | put into mailtemplates subfolder | file_test_4 | put test | 200 | object | 3 | 0 | templates/templates_subfolder | Scenario Outline: Upload files to same folders @@ -131,11 +131,11 @@ Scenario Outline: Upload files to same folders And store "prf_uid" in session array as variable "prf_uid_" Examples: - | file | prf_path | prf_number | - | /uploadfiles/test1.html | templates | 4 | - | /uploadfiles/test2.html | templates | 5 | - | /uploadfiles/test.txt | public | 6 | - | /uploadfiles/TestQA.html| templates | 7 | + | file | prf_path | prf_number | + | test1.html | templates | 4 | + | test2.html | templates | 5 | + | test.txt | public | 6 | + | TestQA.html| templates | 7 | Scenario Outline: Verify if TestQA was overwrited @@ -223,5 +223,5 @@ Scenario Outline: Upload files to same folders "Project - Process Complete BPMN" And the response status message should have the following text "incorrect extension" Examples: - | file | prf_path | prf_number | - | /uploadfiles/SnagIt823.exe | templates | 1 | \ No newline at end of file + | file | prf_path | prf_number | + | SnagIt823.exe | templates | 1 | \ No newline at end of file diff --git a/features/backend/projects/project_export_import/main_tests_project_export_import.feature b/features/backend/projects/project_export_import/main_tests_project_export_import.feature index c65c24ac6..8a3a0f655 100644 --- a/features/backend/projects/project_export_import/main_tests_project_export_import.feature +++ b/features/backend/projects/project_export_import/main_tests_project_export_import.feature @@ -137,7 +137,7 @@ Scenario: Get for Export Project Then the response status code should be 200 And the response charset is "UTF-8" And the content type is "application/xml" - And save exported process to "/uploadfiles/" as "Process_Complete_BPMN" + And save exported process to "/" as "Process_Complete_BPMN" Scenario: Delete a Project created previously in this script @@ -160,12 +160,12 @@ Scenario Outline: Import a process Examples: - | project_file | import_option | prj_uid_number | - | /uploadfiles/Process_NewCreate_BPMN.pmx | create | 1 | - | /uploadfiles/Process_Complete_BPMN.pmx | create | 2 | - | /uploadfiles/Process_Complete_BPMN.pmx | overwrite | 3 | - | /uploadfiles/Process_Complete_BPMN.pmx | disable | 4 | - | /uploadfiles/Process_Complete_BPMN.pmx | keep | 5 | + | project_file | import_option | prj_uid_number | + | Process_NewCreate_BPMN.pmx | create | 1 | + | Process_Complete_BPMN.pmx | create | 2 | + | Process_Complete_BPMN.pmx | overwrite | 3 | + | Process_Complete_BPMN.pmx | disable | 4 | + | Process_Complete_BPMN.pmx | keep | 5 | #Verificar cantidad de dynaform, output, inputs, triggers, asignacion de usuarios, etc. @@ -413,8 +413,8 @@ Scenario Outline: Import a process And the type is "object" Examples: - | project_file | import_option | - | /uploadfiles/Process_Complete_BPMN.pmx | create | + | project_file | import_option | + | Process_Complete_BPMN.pmx | create | #For example, to export a empty process @@ -424,7 +424,7 @@ Scenario: Get for Export Project "Export process empty" Then the response status code should be 200 And the response charset is "UTF-8" And the content type is "application/xml" - And save exported process to "/uploadfiles/" as "Export process empty" + And save exported process to "/" as "Export process empty" Scenario: Delete a Project created previously in this script "Export process empty" Given that I want to delete a resource with the key "prj_uid" stored in session array @@ -435,7 +435,7 @@ Scenario: Delete a Project created previously in this script "Export process emp And the type is "object" Scenario: Import a process "Export process empty" - Given POST upload a project file "/uploadfiles/Export_process_empty.pmx" to "project/import?option=create" + Given POST upload a project file "Export_process_empty.pmx" to "project/import?option=create" Then the response status code should be 201 And the response charset is "UTF-8" And the content type is "application/json" diff --git a/features/backend/projects/project_export_import/negative_tests_project_export_import.feature b/features/backend/projects/project_export_import/negative_tests_project_export_import.feature index 86eb3d8fe..e6cf144ea 100644 --- a/features/backend/projects/project_export_import/negative_tests_project_export_import.feature +++ b/features/backend/projects/project_export_import/negative_tests_project_export_import.feature @@ -11,8 +11,8 @@ Scenario Outline: Import a process negative tests Examples: - | Description | project_file | import_option | error_code | error_message | - | Import process when the process alredy exists | /uploadfiles/Process_Complete_BPMN.pmx | create | 400 | already exists | + | Description | project_file | import_option | error_code | error_message | + | Import process when the process alredy exists | Process_Complete_BPMN.pmx | create | 400 | already exists | Scenario Outline: Import a process with wrong "option" @@ -22,6 +22,6 @@ Scenario Outline: Import a process with wrong "option" Examples: - | Description | project_file | option | option_group | error_message | - | Invalid option | /uploadfiles/Process_NewCreate_BPMN.pmx | sample | merge | option | - | Invalid option_group | /uploadfiles/Process_Complete_BPMN.pmx | create | sample | option_group | \ No newline at end of file + | Description | project_file | option | option_group | error_message | + | Invalid option | Process_NewCreate_BPMN.pmx | sample | merge | option | + | Invalid option_group | Process_Complete_BPMN.pmx | create | sample | option_group | \ No newline at end of file diff --git a/features/backend/projects/step/main_tests_step.feature b/features/backend/projects/step/main_tests_step.feature index 194775281..22a4ce787 100644 --- a/features/backend/projects/step/main_tests_step.feature +++ b/features/backend/projects/step/main_tests_step.feature @@ -73,11 +73,12 @@ Feature: Project Properties - Step Resources Main Tests And I request "project/16062437052cd6141881e06088349078/input-document" And the content type is "application/json" Then the response status code should be 400 + And the response status message should have the following text "assigned" Examples: | step_number | - | 3 | + | 2 | Scenario Outline: Try delete a Output document when it is assigned to a step @@ -90,7 +91,7 @@ Feature: Project Properties - Step Resources Main Tests Examples: | step_number | - | 4 | + | 3 | diff --git a/features/backend/projects/variables/basic_sequence_variables.feature b/features/backend/projects/variables/basic_sequence_variables.feature index 5a413cf46..1a931066c 100644 --- a/features/backend/projects/variables/basic_sequence_variables.feature +++ b/features/backend/projects/variables/basic_sequence_variables.feature @@ -20,7 +20,7 @@ Feature: Process variables Resources """ { "var_name": "My Variable", - "var_field_type": "text_field", + "var_field_type": "string", "var_field_size": 12, "var_label": "Nombre:", "var_dbconnection": "", @@ -44,8 +44,8 @@ Feature: Process variables Resources And PUT this data: """ { - "var_name": "My Variable Modify", - "var_field_type": "text_field", + + "var_field_type": "string", "var_field_size": 1, "var_label": "Nombre modificado:", "var_dbconnection": "", diff --git a/features/backend/projects/variables/main_tests_variables.feature b/features/backend/projects/variables/main_tests_variables.feature index f6791b1e8..25d184af5 100644 --- a/features/backend/projects/variables/main_tests_variables.feature +++ b/features/backend/projects/variables/main_tests_variables.feature @@ -72,9 +72,9 @@ Scenario Outline: Update a process variable Examples: | test_description | var_uid_number | var_field_type | var_field_size | var_label | var_dbconnection | var_sql | var_null | var_default | var_accepted_values | - | Update a text | 1 | text | 12 | Texto 1 - Updated | | | 0 | | | + | Update a text | 1 | string | 12 | Texto 1 - Updated | | | 0 | | | | Update a date | 2 | date | 10 | Fecha - Updated | | | 0 | | | - | Update a dropdown | 3 | dropdown | 12 | Dropdown 1 - Updated | | SELECT IC_UID, IC_NAME FROM ISO_COUNTRY | 0 | | | + | Update a dropdown | 3 | string | 12 | Dropdown 1 - Updated | | SELECT IC_UID, IC_NAME FROM ISO_COUNTRY | 0 | | | diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 98dd105c2..69eb22afd 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -78,6 +78,10 @@ class RestContext extends BehatContext throw new \Exception('Parameters not loaded!'); } else { $parameters = $this->_parameters; + + if(($name=="uploadFilesFolder")&&(!isset($parameters[$name]) ) ){ + $parameters[$name] = "/opt/uploadfiles/"; + } return (isset($parameters[$name])) ? $parameters[$name] : null; } } @@ -1362,7 +1366,7 @@ class RestContext extends BehatContext */ public function postIWantToUploadTheFileToPathPublicUrl($prfFile, $prfPath, $url) { - $prfFile = sys_get_temp_dir() . $prfFile; + $prfFile = $this->getParameter('uploadFilesFolder') . $prfFile; $baseUrl = $this->getParameter('base_url'); $url = $baseUrl.$url; $accesstoken = $this->getParameter('access_token'); @@ -1422,7 +1426,7 @@ class RestContext extends BehatContext */ public function postIWantToUploadTheImageToUser($imageFile, $usrUid, $url) { - $imageFile = sys_get_temp_dir() . $imageFile; + $imageFile = $this->getParameter('uploadFilesFolder') . $imageFile; $baseUrl = $this->getParameter('base_url'); $url = $baseUrl.$url.$usrUid."/image-upload"; @@ -1464,7 +1468,7 @@ class RestContext extends BehatContext } $usrUid = $varValue; - $imageFile = sys_get_temp_dir() . $imageFile; + $imageFile = $imageFile; $this->postIWantToUploadTheImageToUser($imageFile, $usrUid, $url); } @@ -1521,7 +1525,7 @@ class RestContext extends BehatContext */ public function postUploadAnInputDocumentTo($file, $url, PyStringNode $string) { - $file = sys_get_temp_dir() . $file; + $file = $this->getParameter('uploadFilesFolder') . $file; $postFields = json_decode($string); $postFields->form ='@'.$file; @@ -1537,7 +1541,7 @@ class RestContext extends BehatContext */ public function postUploadAProjectFile($file, $url) { - $file = sys_get_temp_dir() . $file; + $file = $this->getParameter('uploadFilesFolder') . $file; $postFields = new StdClass(); $postFields->project_file ='@'.$file; @@ -1642,7 +1646,7 @@ class RestContext extends BehatContext } - $destinationFolder = sys_get_temp_dir() . $destinationFolder; + $destinationFolder = $this->getParameter('uploadFilesFolder') . $destinationFolder; $exportedProcessFileName = $destinationFolder.str_replace(" ","_",$exportedProcessFileName).".pmx"; $this->printDebug("Exporting process to: $exportedProcessFileName"); @@ -1661,8 +1665,8 @@ class RestContext extends BehatContext { $postFields = json_decode($string); - if ((isset($postFields->dyn_content))&&(file_exists(sys_get_temp_dir() . $postFields->dyn_content))) { - $postFields->dyn_content = sys_get_temp_dir() . $postFields->dyn_content; + if ((isset($postFields->dyn_content))&&(file_exists($this->getParameter('uploadFilesFolder') . $postFields->dyn_content))) { + $postFields->dyn_content = $this->getParameter('uploadFilesFolder') . $postFields->dyn_content; $this->printDebug("Extracting dyanform content from: ".$postFields->dyn_content."\n"); $postFields->dyn_content = file_get_contents($postFields->dyn_content); @@ -1683,8 +1687,8 @@ class RestContext extends BehatContext { $postFields = json_decode($string); - if ((isset($postFields->dyn_content))&&(file_exists(sys_get_temp_dir() . $postFields->dyn_content))) { - $postFields->dyn_content = sys_get_temp_dir() . $postFields->dyn_content; + if ((isset($postFields->dyn_content))&&(file_exists($this->getParameter('uploadFilesFolder') . $postFields->dyn_content))) { + $postFields->dyn_content = $this->getParameter('uploadFilesFolder') . $postFields->dyn_content; $this->printDebug("Extracting dyanform content from: ".$postFields->dyn_content."\n"); $postFields->dyn_content = file_get_contents($postFields->dyn_content); diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 3b4ff177c..82093ccb5 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -6,23 +6,52 @@ use ProcessMaker\Services; use ProcessMaker\Services\Api; use Luracast\Restler\RestException; +/** + * Web application bootstrap + * + * @author Erik Amaru Ortiz + */ class WebApplication { - protected $rootDir = ""; - protected $workflowDir = ""; - protected $workspaceDir = ""; - protected $workspaceCacheDir = ""; - protected $requestUri = ""; - protected $responseMultipart = array(); - const RUNNING_DEFAULT = "default.running"; const RUNNING_INDEX = "index.running"; const RUNNING_WORKFLOW = "workflow.running"; const RUNNING_API = "api.running"; - const SERVICE_API = "service.api"; const REDIRECT_DEFAULT = "redirect.default"; + /** + * @var string application root directory + */ + protected $rootDir = ""; + /** + * @var string workflow directory + */ + protected $workflowDir = ""; + /** + * @var string workspace directory located into shared directory + */ + protected $workspaceDir = ""; + /** + * @var string workspace cache directory + */ + protected $workspaceCacheDir = ""; + /** + * @var string request location uri + */ + protected $requestUri = ""; + /** + * @var array holds multiple request response + */ + protected $responseMultipart = array(); + /** + * @var \Maveriks\Extension\Restler main REST dispatcher object + */ + protected $rest; + + /** + * class constructor + */ public function __construct() { defined("DS") || define("DS", DIRECTORY_SEPARATOR); @@ -61,6 +90,10 @@ class WebApplication return $this->requestUri; } + /** + * Routes the request to dispatch + * @return string + */ public function route() { if ($this->requestUri === "/") { @@ -78,6 +111,10 @@ class WebApplication } } + /** + * Run application + * @param string $type the request type to run and dispatch, by now only self::SERVICE_API is accepted + */ public function run($type = "") { switch ($type) { @@ -85,9 +122,10 @@ class WebApplication $request = $this->parseApiRequestUri(); $this->loadEnvironment($request["workspace"]); - Util\Logger::log("API::Dispatching ".$_SERVER["REQUEST_METHOD"]." ".$request["uri"]); + Util\Logger::log("REST API Dispatching url: ".$_SERVER["REQUEST_METHOD"]." ".$request["uri"]); + if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtoupper($_SERVER["HTTP_X_REQUESTED_WITH"]) == 'MULTIPART') { - $this->multipart($request["uri"], $request["version"]); + $this->dispatchMultipleApiRequest($request["uri"], $request["version"]); } else { $this->dispatchApiRequest($request["uri"], $request["version"]); } @@ -97,19 +135,17 @@ class WebApplication } /** - * This method performs the functionality of multipart + * Dispatch multiple api request * - * @param string $version. Version Api - * - * @access public + * @param string $uri the request uri + * @param string $version version of api * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia - * - * @return void */ - public function multipart($uri, $version = "1.0") + public function dispatchMultipleApiRequest($uri, $version = "1.0") { + $stringInput = file_get_contents('php://input'); + if (empty($stringInput)) { $rest = new \Maveriks\Extension\Restler(); $rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart without body.")); @@ -124,26 +160,31 @@ class WebApplication } $baseUrl = (empty($input->base_url)) ? $uri : $input->base_url; + foreach($input->calls as $value) { - $_SERVER["REQUEST_METHOD"] = (empty($value->method)) ? 'GET' : $value->method; + $_SERVER["REQUEST_METHOD"] = empty($value->method) ? 'GET' : $value->method; $uriTemp = trim($baseUrl) . trim($value->url); + if (strpos($uriTemp, '?') !== false) { $dataGet = explode('?', $uriTemp); parse_str($dataGet[1], $_GET); } - $inputExecute = (empty($value->data)) ? '' : json_encode($value->data); + + $inputExecute = empty($value->data) ? '' : json_encode($value->data); $this->responseMultipart[] = $this->dispatchApiRequest($uriTemp, $version, true, $inputExecute); } + echo json_encode($this->responseMultipart); } /** * This method dispatch rest/api service - * * @author Erik Amaru Ortiz */ public function dispatchApiRequest($uri, $version = "1.0", $multipart = false, $inputExecute = '') { + $this->initRest($uri, "1.0", $multipart); + // to handle a request with "OPTIONS" method if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS'); @@ -161,6 +202,21 @@ class WebApplication */ header('Access-Control-Allow-Origin: *'); + $_SERVER['REQUEST_URI'] = $uri; + + $this->rest->inputExecute = $inputExecute; + $this->rest->handle(); + + if ($this->rest->flagMultipart === true) { + return $this->rest->responseMultipart; + } + } + + /** + * create a new instance of local $rest Restler object + */ + protected function initRest($uri, $version, $multipart = false) + { require_once $this->rootDir . "/framework/src/Maveriks/Extension/Restler/UploadFormat.php"; // $servicesDir contains directory where Services Classes are allocated @@ -209,14 +265,13 @@ class WebApplication // create a new Restler instance //$rest = new \Luracast\Restler\Restler(); - $rest = new \Maveriks\Extension\Restler($productionMode); + $this->rest = new \Maveriks\Extension\Restler($productionMode); // setting flag for multipart to Restler - $rest->setFlagMultipart($multipart); - $rest->inputExecute = $inputExecute; + $this->rest->setFlagMultipart($multipart); // setting api version to Restler - $rest->setAPIVersion($version); + $this->rest->setAPIVersion($version); // adding $authenticationClass to Restler - $rest->addAuthenticationClass($authenticationClass, ''); + $this->rest->addAuthenticationClass($authenticationClass, ''); // Setting database connection source list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, ''); @@ -226,7 +281,7 @@ class WebApplication // Setting default OAuth Client id, for local PM Web Designer Services\OAuth2\Server::setPmClientId($pmOauthClientId); - $rest->setOverridingFormats('JsonFormat', 'UploadFormat'); + $this->rest->setOverridingFormats('JsonFormat', 'UploadFormat'); $isPluginRequest = strpos($uri, '/plugin-') !== false ? true : false; @@ -240,7 +295,6 @@ class WebApplication } // Override $_SERVER['REQUEST_URI'] to Restler handles the modified url - $_SERVER['REQUEST_URI'] = $uri; if (! $isPluginRequest) { // if it is not a request for a plugin endpoint // scan all api directory to find api classes @@ -248,13 +302,15 @@ class WebApplication foreach ($classesList as $classFile) { if (pathinfo($classFile, PATHINFO_EXTENSION) === 'php') { - require_once $classFile; - $namespace = '\\ProcessMaker\\Services\\' . str_replace( - DIRECTORY_SEPARATOR, - '\\', - str_replace('.php', '', str_replace($servicesDir, '', $classFile)) - ); - $rest->addAPIClass($namespace); + $relClassPath = str_replace('.php', '', str_replace($servicesDir, '', $classFile)); + $namespace = '\\ProcessMaker\\Services\\' . str_replace(DS, '\\', $relClassPath); + $namespace = strpos($namespace, "//") === false? $namespace: str_replace("//", '', $namespace); + + //if (! class_exists($namespace)) { + require_once $classFile; + //} + + $this->rest->addAPIClass($namespace); } } @@ -264,7 +320,7 @@ class WebApplication if (is_array($aliasData)) { foreach ($aliasData as $label => $namespace) { $namespace = '\\' . ltrim($namespace, '\\'); - $rest->addAPIClass($namespace, $alias); + $this->rest->addAPIClass($namespace, $alias); } } } @@ -282,12 +338,6 @@ class WebApplication // } // } } - - $rest->handle(); - - if ($rest->flagMultipart === true) { - return $rest->responseMultipart; - } } public function parseApiRequestUri() diff --git a/workflow/engine/bin/reindex_solr.php b/workflow/engine/bin/reindex_solr.php index e19c5a111..907019db4 100644 --- a/workflow/engine/bin/reindex_solr.php +++ b/workflow/engine/bin/reindex_solr.php @@ -118,12 +118,29 @@ if (! defined ('PATH_HOME')) { Bootstrap::registerSystemClasses(); spl_autoload_register(array('Bootstrap', 'autoloadClass')); - Bootstrap::registerClass('BaseAppDelegation', PATH_HOME . "engine/classes/model/om/BaseAppDelegation.php"); + Bootstrap::registerClass('BaseProcess', PATH_HOME . "engine/classes/model/om/BaseProcess.php"); + Bootstrap::registerClass('ProcessPeer', PATH_HOME . "engine/classes/model/ProcessPeer.php"); + Bootstrap::registerClass('BaseAppSolrQueue', PATH_HOME . "engine/classes/model/om/BaseAppSolrQueue.php"); + Bootstrap::registerClass('BaseDynaform', PATH_HOME . "engine/classes/model/om/BaseDynaform.php"); + Bootstrap::registerClass('DynaformPeer', PATH_HOME . "engine/classes/model/DynaformPeer.php"); + Bootstrap::registerClass('BaseTaskUser', PATH_HOME . "engine/classes/model/om/BaseTaskUser.php"); + Bootstrap::registerClass('BaseTask', PATH_HOME . "engine/classes/model/om/BaseTask.php"); + Bootstrap::registerClass('BaseGroupUserPeer', PATH_HOME . "engine/classes/model/om/BaseGroupUserPeer.php"); + Bootstrap::registerClass('BaseGroupUser', PATH_HOME . "engine/classes/model/om/BaseGroupUser.php"); + Bootstrap::registerClass('BaseUsers', PATH_HOME . "engine/classes/model/om/BaseUsers.php"); + Bootstrap::registerClass('BaseContent', PATH_HOME . "engine/classes/model/om/BaseContent.php"); + Bootstrap::registerClass('BaseContentPeer', PATH_HOME . "engine/classes/model/om/BaseContentPeer.php"); + Bootstrap::registerClass('ContentPeer', PATH_HOME . "engine/classes/model/ContentPeer.php"); + Bootstrap::registerClass('BaseAppThread', PATH_HOME . "engine/classes/model/om/BaseAppThread.php"); + Bootstrap::registerClass('AppThreadPeer', PATH_HOME . "engine/classes/model/AppThreadPeer.php"); + Bootstrap::registerClass('BaseApplication', PATH_HOME . "engine/classes/model/om/BaseApplication.php"); + Bootstrap::registerClass('ApplicationPeer', PATH_HOME . "engine/classes/model/ApplicationPeer.php"); + Bootstrap::registerClass('BaseAppDelegation', PATH_HOME . "engine/classes/model/om/BaseAppDelegation.php"); Bootstrap::registerClass('BaseAppDelegationPeer',PATH_HOME . "engine/classes/model/om/BaseAppDelegationPeer.php"); - Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); - Bootstrap::registerClass('BaseEventPeer', PATH_HOME . "engine/classes/model/om/BaseEventPeer.php"); - Bootstrap::registerClass('BaseAppEvent', PATH_HOME . "engine/classes/model/om/BaseAppEvent.php"); - Bootstrap::registerClass('AppEventPeer', PATH_HOME . "engine/classes/model/AppEventPeer.php"); + Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); + Bootstrap::registerClass('BaseEventPeer', PATH_HOME . "engine/classes/model/om/BaseEventPeer.php"); + Bootstrap::registerClass('BaseAppEvent', PATH_HOME . "engine/classes/model/om/BaseAppEvent.php"); + Bootstrap::registerClass('AppEventPeer', PATH_HOME . "engine/classes/model/AppEventPeer.php"); Bootstrap::registerClass('BaseCaseScheduler', PATH_HOME . "engine/classes/model/om/BaseCaseScheduler.php"); Bootstrap::registerClass('BaseCaseSchedulerPeer',PATH_HOME . "engine/classes/model/om/BaseCaseSchedulerPeer.php"); Bootstrap::registerClass('CaseSchedulerPeer', PATH_HOME . "engine/classes/model/CaseSchedulerPeer.php"); diff --git a/workflow/engine/controllers/designer.php b/workflow/engine/controllers/designer.php index 554249ea1..a4a3eac89 100644 --- a/workflow/engine/controllers/designer.php +++ b/workflow/engine/controllers/designer.php @@ -28,6 +28,7 @@ class Designer extends Controller $proReadOnly = isset($httpData->prj_readonly) ? $httpData->prj_readonly : 'false'; $client = $this->getClientCredentials(); $authCode = $this->getAuthorizationCode($client); + $debug = false; //System::isDebugMode(); $loader = Maveriks\Util\ClassLoader::getInstance(); $loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); @@ -57,9 +58,9 @@ class Designer extends Controller $this->setVar('app_uid', $appUid); $this->setVar('prj_readonly', $proReadOnly); $this->setVar('credentials', base64_encode(json_encode($clientToken))); - $this->setVar('isDebugMode', System::isDebugMode()); + $this->setVar('isDebugMode', $debug); - if (System::isDebugMode()) { + if ($debug) { if (! file_exists(PATH_HTML . "lib-dev/pmUI/build.cache")) { throw new RuntimeException("Development JS Files were are not generated!.\nPlease execute: \$>rake pmBuildDebug in pmUI project"); } diff --git a/workflow/engine/methods/services/sessionPersists.php b/workflow/engine/methods/services/sessionPersists.php index 218472a78..7c17418c8 100755 --- a/workflow/engine/methods/services/sessionPersists.php +++ b/workflow/engine/methods/services/sessionPersists.php @@ -2,39 +2,42 @@ $response = new stdclass(); $response->status = isset($_SESSION['USER_LOGGED']); if (isset($_REQUEST['dynaformEditorParams'])) { - $arrayParameterAux = unserialize(rawurldecode($_REQUEST["dynaformEditorParams"])); - $arrayParameterAux["DYNAFORM_NAME"] = base64_decode($arrayParameterAux["DYNAFORM_NAME"]); - $_SESSION["Current_Dynafom"]["Parameters"] = $arrayParameterAux; + $arrayParameterAux = @unserialize(rawurldecode($_REQUEST["dynaformEditorParams"])); - if (isset($_REQUEST['DYN_UID'])) { - if (class_exists('Dynaform')) { - require_once 'classes/model/Dynaform.php'; + if (! empty($arrayParameterAux) && isset($arrayParameterAux["DYNAFORM_NAME"])) { + $arrayParameterAux["DYNAFORM_NAME"] = base64_decode($arrayParameterAux["DYNAFORM_NAME"]); + $_SESSION["Current_Dynafom"]["Parameters"] = $arrayParameterAux; + + if (isset($_REQUEST['DYN_UID'])) { + if (class_exists('Dynaform')) { + require_once 'classes/model/Dynaform.php'; + } + $dynaform = new Dynaform(); + $dynaform->load($_REQUEST['DYN_UID']); + + G::LoadClass('dynaformEditor'); + $editor = new dynaformEditor(array()); + $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 = 'processmap'; + $editor->_setUseTemporalCopy(true); + + $A = isset($_SESSION['Current_Dynafom']['Parameters']['URL']) ? $_SESSION['Current_Dynafom']['Parameters']['URL'] : ''; + $form = new Form($dynaform->getProUid() . '/' . $dynaform->getDynUid(), PATH_DYNAFORM, SYS_LANG, true); + $properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), + 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, + 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, + 'NEXTSTEPSAVE' => $form->nextstepsave); + $tmp = $editor->_getTmpData(); + $tmp['Properties'] = $properties; + $editor->_setTmpData($tmp); } - $dynaform = new Dynaform(); - $dynaform->load($_REQUEST['DYN_UID']); - - G::LoadClass('dynaformEditor'); - $editor = new dynaformEditor(array()); - $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 = 'processmap'; - $editor->_setUseTemporalCopy(true); - - $A = isset($_SESSION['Current_Dynafom']['Parameters']['URL']) ? $_SESSION['Current_Dynafom']['Parameters']['URL'] : ''; - $form = new Form($dynaform->getProUid() . '/' . $dynaform->getDynUid(), PATH_DYNAFORM, SYS_LANG, true); - $properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), - 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, - 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, - 'NEXTSTEPSAVE' => $form->nextstepsave); - $tmp = $editor->_getTmpData(); - $tmp['Properties'] = $properties; - $editor->_setTmpData($tmp); } } if (isset($_REQUEST['dynaformRestoreValues'])) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php index e7aeb61c0..3bee930e5 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php @@ -469,13 +469,12 @@ class CaseScheduler $sDateTmp = date('Y-m-d'); $caseSchedulerData['SCH_START_DATE'] = $sDateTmp; } - $caseSchedulerData['SCH_END_DATE'] = date('Y-m-d', strtotime( $sDateTmp )) . ' ' . date('H:i:s', strtotime( $sTimeTmp )); $caseSchedulerData['SCH_START_TIME'] = time(); $caseSchedulerData['SCH_START_DATE'] = $caseSchedulerData['SCH_START_TIME']; if ($caseSchedulerData['SCH_REPEAT_EVERY'] == "") { throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_repeat_every'))); } - $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; + $patternHour="/^([0-9]|0[0-9]|1[0-9]|2[0-3]).[0-5][0-9]$/"; if (!preg_match($patternHour, $caseSchedulerData['SCH_REPEAT_EVERY'])) { throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_REPEAT")); } @@ -764,13 +763,12 @@ class CaseScheduler $sDateTmp = date('Y-m-d'); $caseSchedulerData['SCH_START_DATE'] = $sDateTmp; } - $caseSchedulerData['SCH_END_DATE'] = date('Y-m-d', strtotime($sDateTmp)) . ' ' . date('H:i:s', strtotime($sTimeTmp)); $caseSchedulerData['SCH_START_TIME'] = time(); $caseSchedulerData['SCH_START_DATE'] = $caseSchedulerData['SCH_START_TIME']; if ($caseSchedulerData['SCH_REPEAT_EVERY'] == "") { throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_repeat_every'))); } - $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; + $patternHour="/^([0-9]|0[0-9]|1[0-9]|2[0-3]).[0-5][0-9]$/"; if (!preg_match($patternHour, $caseSchedulerData['SCH_REPEAT_EVERY'])) { throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_REPEAT")); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index 33195319a..45db27736 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -349,13 +349,12 @@ class Variable Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type'); Validator::isNotEmpty($aData['VAR_FIELD_TYPE'], '$var_field_type'); if ($aData["VAR_FIELD_TYPE"] != 'string' && $aData["VAR_FIELD_TYPE"] != 'integer' && $aData["VAR_FIELD_TYPE"] != 'boolean' && $aData["VAR_FIELD_TYPE"] != 'float' && - $aData["VAR_FIELD_TYPE"] != 'datetime' && $aData["VAR_FIELD_TYPE"] != 'date_of_birth') { + $aData["VAR_FIELD_TYPE"] != 'datetime' && $aData["VAR_FIELD_TYPE"] != 'date_of_birth' && $aData["VAR_FIELD_TYPE"] != 'date') { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('$var_field_type'))); } } if (isset($aData["VAR_FIELD_SIZE"])) { Validator::isInteger($aData["VAR_FIELD_SIZE"], '$var_field_size'); - Validator::isNotEmpty($aData['VAR_FIELD_SIZE'], '$var_field_size'); } if (isset($aData["VAR_LABEL"])) { Validator::isString($aData['VAR_LABEL'], '$var_label');