Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
362202e6
"core/core_tables.php" did not exist on "7f6af2ddb1b7aa907f6720912127b8610a771182"
Commit
362202e6
authored
5 years ago
by
Guillaume Heurtier
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #12280 TIME 0:30 fix emails json error if no emails + some refactor
parent
49dfff1b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/resource/controllers/ResourceDataExportController.php
+25
-29
25 additions, 29 deletions
...app/resource/controllers/ResourceDataExportController.php
with
25 additions
and
29 deletions
src/app/resource/controllers/ResourceDataExportController.php
+
25
−
29
View file @
362202e6
...
@@ -145,7 +145,7 @@ class ResourceDataExportController
...
@@ -145,7 +145,7 @@ class ResourceDataExportController
'orderBy'
=>
[
'creation_date desc'
]
'orderBy'
=>
[
'creation_date desc'
]
]);
]);
if
(
count
(
$attachments
)
<
count
(
$attachmentsIds
))
{
// TODO do not count
if
(
count
(
$attachments
)
<
count
(
$attachmentsIds
))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Attachment(s) not found'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Attachment(s) not found'
]);
}
}
...
@@ -223,27 +223,26 @@ class ResourceDataExportController
...
@@ -223,27 +223,26 @@ class ResourceDataExportController
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt id is not an integer'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt id is not an integer'
]);
}
}
}
}
$acknowledgementReceiptsIds
=
$resource
[
'acknowledgementReceipts'
];
}
else
{
$acknowledgementReceiptsIds
=
AcknowledgementReceiptModel
::
get
([
'select'
=>
[
'id'
],
'where'
=>
[
'res_id = ?'
],
'data'
=>
[
$resource
[
'resId'
]]
]);
$acknowledgementReceiptsIds
=
array_column
(
$acknowledgementReceiptsIds
,
'id'
);
}
if
(
!
empty
(
$acknowledgementReceiptsIds
))
{
$acknowledgementReceipts
=
AcknowledgementReceiptModel
::
getByIds
([
$acknowledgementReceipts
=
AcknowledgementReceiptModel
::
getByIds
([
'select'
=>
[
'id'
,
'res_id'
,
'format'
,
'contact_id'
,
'user_id'
,
'creation_date'
,
'send_date'
,
'docserver_id'
,
'path'
,
'select'
=>
[
'id'
,
'res_id'
,
'format'
,
'contact_id'
,
'user_id'
,
'creation_date'
,
'send_date'
,
'docserver_id'
,
'path'
,
'filename'
,
'fingerprint'
],
'filename'
,
'fingerprint'
],
'ids'
=>
$acknowledgementReceipts
Ids
'ids'
=>
$
resource
[
'
acknowledgementReceipts
'
]
]);
]);
if
(
count
(
$acknowledgementReceipts
)
<
count
(
$acknowledgementReceipts
Ids
))
{
if
(
count
(
$acknowledgementReceipts
)
<
count
(
$
resource
[
'
acknowledgementReceipts
'
]
))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt(s) not found'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt(s) not found'
]);
}
}
}
else
{
$acknowledgementReceipts
=
AcknowledgementReceiptModel
::
get
([
'select'
=>
[
'id'
,
'res_id'
,
'format'
,
'contact_id'
,
'user_id'
,
'creation_date'
,
'send_date'
,
'docserver_id'
,
'path'
,
'filename'
,
'fingerprint'
],
'where'
=>
[
'res_id = ?'
],
'data'
=>
[
$resource
[
'resId'
]]
]);
}
if
(
!
empty
(
$acknowledgementReceipts
))
{
foreach
(
$acknowledgementReceipts
as
$acknowledgementReceipt
)
{
foreach
(
$acknowledgementReceipts
as
$acknowledgementReceipt
)
{
if
(
$acknowledgementReceipt
[
'res_id'
]
!=
$resource
[
'resId'
])
{
if
(
$acknowledgementReceipt
[
'res_id'
]
!=
$resource
[
'resId'
])
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt not linked to resource'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Acknowledgement Receipt not linked to resource'
]);
...
@@ -273,29 +272,26 @@ class ResourceDataExportController
...
@@ -273,29 +272,26 @@ class ResourceDataExportController
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email id is not an integer'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email id is not an integer'
]);
}
}
}
}
$emailsIds
=
$resource
[
'emails'
];
$emails
=
EmailModel
::
get
([
}
else
{
$emailsIds
=
EmailModel
::
get
([
'select'
=>
[
'id'
],
'where'
=>
[
"cast(document->'id' as INT) = ? "
],
// TODO might not work if no emails in table (or if no 'id' in document ?) -> if document is not null ?
'data'
=>
[
$resource
[
'resId'
]]
]);
$emailsIds
=
array_column
(
$emailsIds
,
'id'
);
}
if
(
!
empty
(
$emailsIds
))
{
$emailsModel
=
EmailModel
::
get
([
'select'
=>
[
'id'
,
'user_id'
,
'sender'
,
'recipients'
,
'cc'
,
'cci'
,
'object'
,
'body'
,
'document'
,
'send_date'
],
'select'
=>
[
'id'
,
'user_id'
,
'sender'
,
'recipients'
,
'cc'
,
'cci'
,
'object'
,
'body'
,
'document'
,
'send_date'
],
'where'
=>
[
'id in (?)'
],
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$emails
Ids
],
'data'
=>
[
$
resource
[
'
emails
'
]
],
'orderBy'
=>
[
'creation_date desc'
]
'orderBy'
=>
[
'creation_date desc'
]
]);
]);
if
(
count
(
$emails
)
<
count
(
$resource
[
'emails'
]))
{
if
(
count
(
$emailsModel
)
<
count
(
$emailsIds
))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email(s) not found'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email(s) not found'
]);
}
}
}
else
{
$emails
=
EmailModel
::
get
([
'select'
=>
[
'id'
,
'user_id'
,
'sender'
,
'recipients'
,
'cc'
,
'cci'
,
'object'
,
'body'
,
'document'
,
'send_date'
],
'where'
=>
[
"cast(document->>'id' as INT) = ? "
],
'data'
=>
[
$resource
[
'resId'
]],
'orderBy'
=>
[
'creation_date desc'
]
]);
}
foreach
(
$emailsModel
as
$email
)
{
if
(
!
empty
(
$emails
))
{
foreach
(
$emails
as
$email
)
{
$emailDocument
=
json_decode
(
$email
[
'document'
],
true
);
$emailDocument
=
json_decode
(
$email
[
'document'
],
true
);
if
(
!
empty
(
$emailDocument
[
'id'
])
&&
$emailDocument
[
'id'
]
!=
$resource
[
'resId'
])
{
if
(
!
empty
(
$emailDocument
[
'id'
])
&&
$emailDocument
[
'id'
]
!=
$resource
[
'resId'
])
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email not linked to resource'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Email not linked to resource'
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment