From 079ccad1ccabf9638180e8f59f34b4de79baf8cb Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Fri, 14 Sep 2018 18:24:14 +0200 Subject: [PATCH] FEAT #8346 add convert attachment support --- src/app/convert/models/AdrModel.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/app/convert/models/AdrModel.php b/src/app/convert/models/AdrModel.php index 5467931a044..274647ee723 100644 --- a/src/app/convert/models/AdrModel.php +++ b/src/app/convert/models/AdrModel.php @@ -58,6 +58,34 @@ class AdrModel return $adr[0]; } + public static function getTypedAttachAdrByResId(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['resId', 'type']); + ValidatorModel::intVal($aArgs, ['resId']); + ValidatorModel::stringType($aArgs, ['type']); + ValidatorModel::arrayType($aArgs, ['select']); + ValidatorModel::boolType($aArgs, ['isVersion']); + + if ($aArgs['isVersion']) { + $table = "adr_attachments_version"; + } else { + $table = "adr_attachments"; + } + + $adr = DatabaseModel::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => [$table], + 'where' => ['res_id = ?', 'type = ?'], + 'data' => [$aArgs['resId'], $aArgs['type']] + ]); + + if (empty($adr[0])) { + return []; + } + + return $adr[0]; + } + public static function createDocumentAdr(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['resId', 'docserverId', 'path', 'filename', 'type']); -- GitLab