diff --git a/database/factories/DocumentsFactory.php b/database/factories/DocumentsFactory.php
deleted file mode 100644
index acfafb0ce..000000000
--- a/database/factories/DocumentsFactory.php
+++ /dev/null
@@ -1,54 +0,0 @@
-define(\ProcessMaker\Model\Documents::class, function (Faker $faker) {
- $types = ['INPUT', 'OUTPUT', 'ATTACHED'];
- $type = $faker->randomElement($types);
- return [
- 'APP_DOC_UID' => G::generateUniqueID(),
- 'APP_DOC_FILENAME' => 'image.png',
- 'APP_DOC_TITLE' => '',
- 'APP_DOC_COMMENT' => '',
- 'DOC_VERSION' => 1,
- 'APP_UID' => G::generateUniqueID(),
- 'DEL_INDEX' => 1,
- 'DOC_UID' => G::generateUniqueID(),
- 'USR_UID' => G::generateUniqueID(),
- 'APP_DOC_TYPE' => $type,
- 'APP_DOC_CREATE_DATE' => $faker->date(),
- 'APP_DOC_INDEX' => 1,
- 'FOLDER_UID' => G::generateUniqueID(),
- 'APP_DOC_PLUGIN' => '',
- 'APP_DOC_TAGS' => '',
- 'APP_DOC_STATUS' => 'ACTIVE',
- 'APP_DOC_STATUS_DATE' => $faker->date(),
- 'APP_DOC_FIELDNAME' => '',
- 'APP_DOC_DRIVE_DOWNLOAD' => '',
- ];
-});
-
-// Create a dynaform with the foreign keys
-$factory->state(\ProcessMaker\Model\Documents::class, 'case_notes', function (Faker $faker) {
- return [
- 'APP_DOC_UID' => G::generateUniqueID(),
- 'APP_DOC_FILENAME' => 'image.png',
- 'APP_DOC_TITLE' => '',
- 'APP_DOC_COMMENT' => '',
- 'DOC_VERSION' => 1,
- 'APP_UID' => G::generateUniqueID(),
- 'DEL_INDEX' => 1,
- 'DOC_UID' => G::generateUniqueID(),
- 'USR_UID' => G::generateUniqueID(),
- 'APP_DOC_TYPE' => 'CASE_NOTE',
- 'APP_DOC_CREATE_DATE' => $faker->date(),
- 'APP_DOC_INDEX' => 1,
- 'FOLDER_UID' => G::generateUniqueID(),
- 'APP_DOC_PLUGIN' => '',
- 'APP_DOC_TAGS' => '',
- 'APP_DOC_STATUS' => 'ACTIVE',
- 'APP_DOC_STATUS_DATE' => $faker->date(),
- 'APP_DOC_FIELDNAME' => '',
- 'APP_DOC_DRIVE_DOWNLOAD' => '',
- ];
-});
diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php
index 8e9e9af86..ee129521e 100644
--- a/gulliver/system/class.g.php
+++ b/gulliver/system/class.g.php
@@ -2708,8 +2708,6 @@ class G
$nameToSave = $filter->validateInput($nameToSave, "path");
@chmod($path . "/" . $nameToSave, $permission);
umask($oldumask);
-
- return true;
} catch (Exception $oException) {
throw $oException;
}
diff --git a/tests/resources/images/activate.png b/tests/resources/images/activate.png
deleted file mode 100644
index 1be605c56..000000000
Binary files a/tests/resources/images/activate.png and /dev/null differ
diff --git a/tests/resources/images/activity.gif b/tests/resources/images/activity.gif
deleted file mode 100644
index 94d46c129..000000000
Binary files a/tests/resources/images/activity.gif and /dev/null differ
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
index 0b988bf49..99778d4f2 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
@@ -5,8 +5,6 @@ namespace ProcessMaker\BusinessModel;
use Exception;
use G;
use ProcessMaker\Model\Application;
-use ProcessMaker\Model\Delegation;
-use ProcessMaker\Model\Documents;
use RBAC;
use Tests\TestCase;
@@ -79,61 +77,4 @@ class CasesTest extends TestCase
$case = new Cases();
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
}
-
- /**
- * Review the upload file related to the case notes, an return an exception when the array is empty
- *
- * @covers \ProcessMaker\BusinessModel\Cases::uploadFilesInCaseNotes()
- *
- * @test
- *
- * @expectedException Exception
- */
- public function it_return_exception_in_upload_files_related_case_note()
- {
- $application = factory(Application::class)->create();
- factory(Delegation::class)->states('foreign_keys')->create([
- 'APP_NUMBER' => $application->APP_NUMBER,
- 'APP_UID' => $application->APP_UID
- ]);
- // Upload the file
- $case = new Cases();
- // Return an exception because the files does not exist
- $case->uploadFilesInCaseNotes('00000000000000000000000000000001', $application->APP_UID, $filesReferences = []);
- }
-
- /**
- * Review the upload file related to the case notes
- *
- * @covers \ProcessMaker\BusinessModel\Cases::uploadFilesInCaseNotes()
- *
- * @test
- */
- public function it_should_upload_files_related_case_note()
- {
- $application = factory(Application::class)->create();
- factory(Delegation::class)->states('foreign_keys')->create([
- 'APP_NUMBER' => $application->APP_NUMBER,
- 'APP_UID' => $application->APP_UID
- ]);
- // File reference to upload
- $filesReferences = [
- 'activityRename.gif' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activity.gif',
- ];
- // Path of the case
- $pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . $application->APP_UID . PATH_SEP;
- // Upload the file
- $case = new Cases();
- $result = $case->uploadFilesInCaseNotes('00000000000000000000000000000001', $application->APP_UID, $filesReferences);
- $result = head($result);
- $this->assertNotEmpty($result);
- $this->assertArrayHasKey('APP_UID', $result);
- $this->assertEquals($application->APP_UID, $result['APP_UID']);
- $this->assertArrayHasKey('APP_DOC_TYPE', $result);
- $this->assertEquals(Documents::DOC_TYPE_CASE_NOTE, $result['APP_DOC_TYPE']);
- $this->assertArrayHasKey('APP_DOC_FILENAME', $result);
- $this->assertEquals('activityRename.gif', $result['APP_DOC_FILENAME']);
-
- G::rm_dir($pathCase);
- }
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php
deleted file mode 100644
index bc882b79d..000000000
--- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-states('case_notes')->create();
- $doc = new Documents();
- $res = $doc->getAppFiles($appDoc->APP_UID, Documents::DOC_TYPE_CASE_NOTE);
- $this->assertNotEmpty($res);
- }
-}
\ No newline at end of file
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/SaveAppDocumentTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/SaveAppDocumentTest.php
deleted file mode 100644
index 4f1079a08..000000000
--- a/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/SaveAppDocumentTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
- PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activate.png',
- 'tmp_name' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activate.png',
- ];
- $appUid = G::generateUniqueID();
- $appDocUid = G::generateUniqueID();
- $pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . G::getPathFromUID($appUid) . PATH_SEP;
- saveAppDocument($files, $appUid, $appDocUid, 1, false);
- $this->assertFileExists($pathCase . $appDocUid . '_1.png');
- G::rm_dir($pathCase);
- }
-
- /**
- * It test if the file reference was uploaded
- *
- * @test
- */
- public function it_should_copy_file_different_name()
- {
- $files = [
- 'name' => 'activityRename.gif',
- 'tmp_name' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activity.gif',
- ];
- $appUid = G::generateUniqueID();
- $appDocUid = G::generateUniqueID();
- $pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . G::getPathFromUID($appUid) . PATH_SEP;
- saveAppDocument($files, $appUid, $appDocUid, 1, false);
- $this->assertFileExists($pathCase . $appDocUid . '_1.gif');
- G::rm_dir($pathCase);
- }
-}
\ No newline at end of file
diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php
index 268c9293a..898b2af56 100644
--- a/workflow/engine/classes/WsBase.php
+++ b/workflow/engine/classes/WsBase.php
@@ -3420,17 +3420,16 @@ class WsBase
/**
* Add case note
*
- * @param string $caseUid, ID of the case.
- * @param string $processUid, ID of the process.
- * @param string $taskUid, ID of the task.
- * @param string $userUid, The unique ID of the user who will add note case.
- * @param string $note, Note of the case.
- * @param int $sendMail, Optional parameter. If set to 1, will send an email to all participants in the case.
- * @param array $files, Optional parameter. This is an array of files.
+ * @param string caseUid : ID of the case.
+ * @param string processUid : ID of the process.
+ * @param string taskUid : ID of the task.
+ * @param string userUid : The unique ID of the user who will add note case.
+ * @param string note : Note of the case.
+ * @param int sendMail : Optional parameter. If set to 1, will send an email to all participants in the case.
*
- * @return object
+ * @return $result will return an object
*/
- public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1, $files = [])
+ public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
{
try {
if (empty($caseUid)) {
@@ -3476,7 +3475,7 @@ class WsBase
//Add note case
$appNote = new AppNotes();
- $response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail, $files);
+ $response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail);
//Response
$result = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php
index 5193afb66..e99854804 100644
--- a/workflow/engine/classes/class.pmFunctions.php
+++ b/workflow/engine/classes/class.pmFunctions.php
@@ -2887,15 +2887,13 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid)
* @param string(32) | $userUid | ID user | The unique ID of the user who will add note case.
* @param string | $note | Note of the case | Note of the case.
* @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
- * @param array | $files | Array of files | An array of files (full paths) to be attached to the case notes.
- *
* @return int | $result | Result of the add a case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred.
*
*/
-function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1, $files = [])
+function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
{
$ws = new WsBase();
- $result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail, $files);
+ $result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail);
if ($result->status_code == 0) {
return 1;
diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php
index 3081d519c..6e99dc408 100644
--- a/workflow/engine/classes/model/AppNotes.php
+++ b/workflow/engine/classes/model/AppNotes.php
@@ -260,25 +260,10 @@ class AppNotes extends BaseAppNotes
}
}
- /**
- * Add a note in the case and send an email
- *
- * @param string $applicationUid
- * @param string $userUid
- * @param string $note
- * @param bool $sendMail
- * @param array $files
- *
- * @return array
- */
- public function addCaseNote($applicationUid, $userUid, $note, $sendMail, $files)
+ public function addCaseNote($applicationUid, $userUid, $note, $sendMail)
{
$response = $this->postNewNote($applicationUid, $userUid, $note, false);
- // Check the files to upload
- $case = new Cases();
- $res = $case->uploadFilesInCaseNotes($userUid, $applicationUid, $files, null);
-
if ($sendMail == 1) {
$case = new Cases();
diff --git a/workflow/engine/classes/model/map/AppDocumentMapBuilder.php b/workflow/engine/classes/model/map/AppDocumentMapBuilder.php
index f8171cacb..c0a6495d2 100644
--- a/workflow/engine/classes/model/map/AppDocumentMapBuilder.php
+++ b/workflow/engine/classes/model/map/AppDocumentMapBuilder.php
@@ -127,7 +127,7 @@ class AppDocumentMapBuilder
$tMap->addValidator('USR_UID', 'required', 'propel.validator.RequiredValidator', '', 'User UID is required.');
- $tMap->addValidator('APP_DOC_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'INPUT|OUTPUT|ATTACHED|CASE_NOTE', 'Please select a valid document type.');
+ $tMap->addValidator('APP_DOC_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'INPUT|OUTPUT|ATTACHED', 'Please select a valid document type.');
$tMap->addValidator('APP_DOC_TYPE', 'required', 'propel.validator.RequiredValidator', '', 'Application Document Type is required.');
diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml
index 4d945b5dd..24e4d7490 100644
--- a/workflow/engine/config/schema.xml
+++ b/workflow/engine/config/schema.xml
@@ -284,7 +284,7 @@
-
+
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
index d99b4c597..c8e078d8a 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
@@ -42,7 +42,6 @@ use ProcessMaker\Core\System;
use ProcessMaker\Exception\UploadException;
use ProcessMaker\Model\Application as ModelApplication;
use ProcessMaker\Model\Delegation;
-use ProcessMaker\Model\Documents;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Services\OAuth2\Server;
use ProcessMaker\Util\DateTime as UtilDateTime;
@@ -3844,85 +3843,6 @@ class Cases
return $response;
}
- /**
- * Upload file related to the case notes
- *
- * @param string $userUid
- * @param string $appUid
- * @param array $filesReferences
- * @param string $appDocUid
- *
- * @return array
- * @throws Exception
- */
- public function uploadFilesInCaseNotes($userUid, $appUid, $filesReferences = [], $appDocUid = null)
- {
- if (!empty($_FILES["form"]["name"])) {
- $upload = true;
- // Array from post upload
- foreach ($_FILES["form"]["name"] as $fileIndex => $fileName) {
- if (!is_array($fileName)) {
- $files[] = [
- 'name' => $_FILES["form"]["name"][$fileIndex],
- 'tmp_name' => $_FILES["form"]["tmp_name"][$fileIndex],
- 'error' => $_FILES["form"]["error"][$fileIndex]
- ];
- }
- }
- } elseif (!empty($filesReferences)) {
- $upload = false;
- // Array with path references
- foreach ($filesReferences as $fileIndex => $fileName) {
- $nameFile = !is_numeric($fileIndex) ? basename($fileIndex) : basename($fileName);
- $files[] = [
- 'name' => $nameFile,
- 'tmp_name' => $fileName,
- 'error' => UPLOAD_ERR_OK
- ];
- }
- }
-
- // Get the delIndex related to the case
- $cases = new ClassesCases();
- $delIndex = $cases->getCurrentDelegation($appUid);
-
- // We will to register the files in the database
- $response = [];
- if (!empty($files)) {
- $i = 0;
- foreach ($files as $fileIndex => $fileName) {
- // There is no error, the file uploaded with success
- if ($fileName["error"] === UPLOAD_ERR_OK) {
- $appDocUid = G::generateUniqueID();
- $attributes = [
- "APP_DOC_UID" => $appDocUid,
- "DOC_VERSION" => 1,
- "APP_UID" => $appUid,
- "DEL_INDEX" => $delIndex,
- "USR_UID" => $userUid,
- "DOC_UID" => -1,
- "APP_DOC_TYPE" => 'CASE_NOTE',
- "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"),
- "APP_DOC_FILENAME" => $fileName["name"]
- ];
- Documents::create($attributes);
-
- // Upload or move the file
- $isUploaded = saveAppDocument($fileName, $appUid, $appDocUid, 1, $upload);
-
- // List of files uploaded or copy
- $response[$i++] = $attributes;
- } else {
- throw new UploadException($fileName['error']);
- }
- }
- } else {
- throw new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR'));
- }
-
- return $response;
- }
-
/**
* Run the validations related to an Input Document
*
diff --git a/workflow/engine/src/ProcessMaker/Model/Documents.php b/workflow/engine/src/ProcessMaker/Model/Documents.php
deleted file mode 100644
index 5e915cc69..000000000
--- a/workflow/engine/src/ProcessMaker/Model/Documents.php
+++ /dev/null
@@ -1,95 +0,0 @@
- '',
- 'APP_DOC_COMMENT' => '',
- 'DOC_UID' => '-1',
- 'FOLDER_UID' => '',
- 'APP_DOC_PLUGIN' => '',
- 'APP_DOC_TAGS' => '',
- 'APP_DOC_FIELDNAME' => '',
- 'APP_DOC_DRIVE_DOWNLOAD' => 'a:0:{}',
- 'SYNC_WITH_DRIVE' => 'UNSYNCHRONIZED',
- 'SYNC_PERMISSIONS' => '',
- 'APP_DOC_STATUS_DATE' => '',
- ];
-
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'APP_DOC_UID',
- 'DOC_VERSION',
- 'APP_DOC_FILENAME',
- 'APP_UID',
- 'DEL_INDEX',
- 'DOC_UID',
- 'USR_UID',
- 'APP_DOC_TYPE',
- 'APP_DOC_CREATE_DATE',
- 'APP_DOC_INDEX',
- 'FOLDER_UID',
- 'APP_DOC_STATUS',
- ];
-
- /**
- * Scope a query to filter an specific case
- *
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @param string $proUid
- * @return \Illuminate\Database\Eloquent\Builder
- */
- public function scopeAppUid($query, string $appUid)
- {
- return $query->where('APP_UID', $appUid);
- }
-
- /**
- * Return the documents related to the case
- *
- * @param int $proId
- * @param string $type
- *
- * @return array
- */
- public static function getAppFiles(string $appUid, $type = 'CASE_NOTES')
- {
- $query = Documents::query()->select();
- $query->appUid($appUid);
- $query->where('APP_DOC_TYPE', $type);
- $results = $query->get();
- $documentList = [];
- $results->each(function ($item, $key) use (&$documentList) {
- $documentList[] = $item->toArray();
- });
-
- return $documentList;
- }
-}
diff --git a/workflow/engine/src/ProcessMaker/Util/helpers.php b/workflow/engine/src/ProcessMaker/Util/helpers.php
index a844b2eaa..22272a78e 100644
--- a/workflow/engine/src/ProcessMaker/Util/helpers.php
+++ b/workflow/engine/src/ProcessMaker/Util/helpers.php
@@ -601,39 +601,3 @@ function getMysqlVersion()
return $mysqlVersion;
}
-
-/**
- * Move the uploaded file to the documents folder
- *
- * @param array $file
- * @param string $appUid
- * @param string $appDocUid
- * @param int $version
- *
- * @return string
- */
-function saveAppDocument($file, $appUid, $appDocUid, $version = 1, $upload = true)
-{
- try {
- $info = pathinfo($file["name"]);
- $extension = ((isset($info["extension"])) ? $info["extension"] : "");
- //$pathCase = G::getPathFromUID($appUid);
- $fileName = $appDocUid . "_" . $version . "." . $extension;
-
- $pathCase = PATH_DATA_SITE . 'files' . PATH_SEP . G::getPathFromUID($appUid) . PATH_SEP;
-
- $response = false;
- if ($upload) {
- $response = G::uploadFile(
- $file["tmp_name"],
- $pathCase,
- $fileName
- );
- } else {
- G::verifyPath($pathCase, true);
- $response = copy($file["tmp_name"], $pathCase . $fileName);
- }
- } catch (Exception $e) {
- throw $e;
- }
-}