diff --git a/workflow/engine/bin/tasks/cliCaseArchive.php b/workflow/engine/bin/tasks/cliCaseArchive.php new file mode 100644 index 000000000..576a42dba --- /dev/null +++ b/workflow/engine/bin/tasks/cliCaseArchive.php @@ -0,0 +1,165 @@ +initPropel(); + + G::isPMUnderUpdating(1); + + try { + pmCaseArchive($command[0], $command[1]); + } catch (Exception $e) { + CLI::logging($e->getMessage() . "\n"); + } + + G::isPMUnderUpdating(0); + + CLI::logging("Archive ended at : " . Date("Y-m-d H:i:s") . "\n"); +} + +function runUnarchive($command, $args) +{ + CLI::logging("ProcessMaker Case Restore\n"); + + if (!$command[0]) { + throw new Exception("Must be specified the workspace name"); + } + + if (!$command[1]) { + throw new Exception("Must be specified the name file tar"); + } + + CLI::logging("Workspace: " . $command[0] . "\n"); + CLI::logging("Restoring cases until: " . $command[1] . "\n"); + CLI::logging("Restore action Date: " . Date("Y-m-d H:i:s") . "\n\n"); + + $config = System::getSystemConfiguration(); + require_once("propel/Propel.php"); + require_once("creole/Creole.php"); + + if (!defined("PATH_SEP")) { + define("PATH_SEP", (substr(PHP_OS, 0, 3) == "WIN") ? "\\" : "/"); + } + + if (!extension_loaded("mysql")) { + dl("mysql.so"); + } + + ini_set("display_errors", $config["debug"]); + ini_set("error_reporting", $config['error_reporting']); + ini_set("short_open_tag", "On"); + ini_set("default_charset", "UTF-8"); + ini_set("memory_limit", $config["memory_limit"]); + ini_set("soap.wsdl_cache_enabled", $config["wsdl_cache"]); + ini_set("date.timezone", $config["time_zone"]); + + set_include_path(PATH_PLUGINS . "pmCaseArchive" . PATH_SEPARATOR . get_include_path()); + + include_once(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php"); + if (!defined('PATH_RBAC_HOME')) { + include_once(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php'); + } + include_once(PATH_CORE . "plugins" . PATH_SEP . "pmCaseArchive" . PATH_SEP . "classes" . PATH_SEP . "class.pmFunctions.php"); + + define("SYS_SYS", $command[0]); + + $oWorkspaces = new workspaceTools($command[0]); + $oWorkspaces->initPropel(); + + G::isPMUnderUpdating(1); + + try { + pmCaseUnarchive($command[0], $command[1]); + } catch (Exception $e) { + CLI::logging($e->getMessage() . "\n"); + } + + G::isPMUnderUpdating(0); + CLI::logging("Unarchive ended at : " . Date("Y-m-d H:i:s") . "\n"); + //CLI::logging("End -- Unarchive file tar ...\n"); +} diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 59fbfee92..15fdcc066 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -306,7 +306,7 @@ try { if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) { $oInputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); - $oInputDocument->uploadFileCase($_FILES, $oCase, $_SESSION["USER_LOGGED"], $_SESSION["APPLICATION"], $_SESSION["INDEX"]); + $oInputDocument->uploadFileCase($_FILES, $oCase, $aData, $_SESSION["USER_LOGGED"], $_SESSION["APPLICATION"], $_SESSION["INDEX"]); } //Delete MultipleFile diff --git a/workflow/engine/methods/services/ActionsByEmailDataFormPost.php b/workflow/engine/methods/services/ActionsByEmailDataFormPost.php index a070add9a..ccf346019 100644 --- a/workflow/engine/methods/services/ActionsByEmailDataFormPost.php +++ b/workflow/engine/methods/services/ActionsByEmailDataFormPost.php @@ -123,7 +123,7 @@ if (PMLicensedFeatures if (isset ( $_FILES ['form'] )) { if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) { $oInputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument(); - $oInputDocument->uploadFileCase($_FILES, $case, $current_user_uid, $_REQUEST['APP_UID'], $_REQUEST["DEL_INDEX"]); + $oInputDocument->uploadFileCase($_FILES, $case, $casesFields, $current_user_uid, $_REQUEST['APP_UID'], $_REQUEST["DEL_INDEX"]); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index ef3c96e2b..93c9d0e80 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -648,11 +648,12 @@ class InputDocument /** * @param $files $_FILES request files * @param $caseInstance \Cases object class.cases + * @param $aData array data case * @param $userUid string user id * @param $appUid string application id * @param $delIndex int the index case */ - public function uploadFileCase($files, $caseInstance, $userUid, $appUid, $delIndex) + public function uploadFileCase($files, $caseInstance, $aData, $userUid, $appUid, $delIndex) { $arrayField = array(); $arrayFileName = array();