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
00aa9f97
Verified
Commit
00aa9f97
authored
5 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #12071 TIME 0:35 Get field by res id
parent
1014928b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rest/index.php
+6
-3
6 additions, 3 deletions
rest/index.php
src/app/contact/controllers/ContactController.php
+4
-8
4 additions, 8 deletions
src/app/contact/controllers/ContactController.php
src/app/resource/controllers/ResController.php
+22
-0
22 additions, 0 deletions
src/app/resource/controllers/ResController.php
with
32 additions
and
11 deletions
rest/index.php
+
6
−
3
View file @
00aa9f97
...
...
@@ -311,6 +311,9 @@ $app->get('/roles', \Entity\controllers\ListTemplateController::class . ':getRol
$app
->
get
(
'/availableCircuits'
,
\Entity\controllers\ListTemplateController
::
class
.
':getAvailableCircuits'
);
$app
->
put
(
'/circuits/{type}'
,
\Entity\controllers\ListInstanceController
::
class
.
':updateCircuits'
);
//MessageExchanges
$app
->
get
(
'/messageExchanges/{id}'
,
\MessageExchange\controllers\MessageExchangeController
::
class
.
':getById'
);
//Notes
$app
->
post
(
'/notes'
,
\Note\controllers\NoteController
::
class
.
':create'
);
$app
->
get
(
'/notes/{id}'
,
\Note\controllers\NoteController
::
class
.
':getById'
);
...
...
@@ -365,17 +368,17 @@ $app->get('/resources/{resId}/visaCircuit', \Entity\controllers\ListInstanceCont
$app
->
get
(
'/resources/{resId}/opinionCircuit'
,
\Entity\controllers\ListInstanceController
::
class
.
':getOpinionCircuitByResId'
);
$app
->
get
(
'/resources/{resId}/parallelOpinion'
,
\Entity\controllers\ListInstanceController
::
class
.
':getParallelOpinionByResId'
);
$app
->
get
(
'/resources/{resId}/defaultCircuit'
,
\Entity\controllers\ListTemplateController
::
class
.
':getDefaultCircuitByResId'
);
$app
->
delete
(
'/resources/{resId}/circuits/{type}'
,
\Entity\controllers\ListInstanceController
::
class
.
':deleteCircuit'
);
$app
->
get
(
'/resources/{resId}/linkedResources'
,
\Resource\controllers\LinkController
::
class
.
':getLinkedResources'
);
$app
->
post
(
'/resources/{resId}/linkedResources'
,
\Resource\controllers\LinkController
::
class
.
':linkResources'
);
$app
->
delete
(
'/resources/{resId}/linkedResources/{id}'
,
\Resource\controllers\LinkController
::
class
.
':unlinkResources'
);
$app
->
put
(
'/resources/{resId}/sign'
,
\SignatureBook\controllers\SignatureBookController
::
class
.
':signResource'
);
$app
->
put
(
'/resources/{resId}/unsign'
,
\SignatureBook\controllers\SignatureBookController
::
class
.
':unsignResource'
);
$app
->
get
(
'/resources/{resId}/acknowledgementReceipts'
,
\AcknowledgementReceipt\controllers\AcknowledgementReceiptController
::
class
.
':getByResId'
);
$app
->
get
(
'/resources/{resId}/shippings'
,
\Shipping\controllers\ShippingController
::
class
.
':getByResId'
);
$app
->
get
(
'/resources/{resId}/messageExchanges'
,
\MessageExchange\controllers\MessageExchangeController
::
class
.
':getByResId'
);
$app
->
get
(
'/resources/{resId}/emailsInitialization'
,
\Email\controllers\EmailController
::
class
.
':getInitializationByResId'
);
$app
->
get
(
'/messageExchanges/{id}'
,
\MessageExchange\controllers\MessageExchangeController
::
class
.
':getById'
);
$app
->
get
(
'/resources/{resId}/fields/{fieldId}'
,
\Resource\controllers\ResController
::
class
.
':getField'
);
$app
->
delete
(
'/resources/{resId}/linkedResources/{id}'
,
\Resource\controllers\LinkController
::
class
.
':unlinkResources'
);
$app
->
delete
(
'/resources/{resId}/circuits/{type}'
,
\Entity\controllers\ListInstanceController
::
class
.
':deleteCircuit'
);
$app
->
put
(
'/res/resource/status'
,
\Resource\controllers\ResController
::
class
.
':updateStatus'
);
$app
->
post
(
'/res/list'
,
\Resource\controllers\ResController
::
class
.
':getList'
);
...
...
This diff is collapsed.
Click to expand it.
src/app/contact/controllers/ContactController.php
+
4
−
8
View file @
00aa9f97
...
...
@@ -438,9 +438,7 @@ class ContactController
if
(
!
empty
(
$queryParams
[
'redirect'
]))
{
if
(
!
Validator
::
intVal
()
->
validate
(
$queryParams
[
'redirect'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Query param redirect is not an integer'
]);
}
if
(
$queryParams
[
'redirect'
]
==
$args
[
'id'
])
{
}
elseif
(
$queryParams
[
'redirect'
]
==
$args
[
'id'
])
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Cannot redirect to contact you are deleting'
]);
}
...
...
@@ -449,8 +447,6 @@ class ContactController
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Contact does not exist'
]);
}
// Replace contact with redirect
// get all res_id linked to contact args['id']
$resourcesContacts
=
ResourceContactModel
::
get
([
'select'
=>
[
'res_id'
,
'mode'
],
'where'
=>
[
'item_id = ?'
,
"type = 'contact'"
],
...
...
@@ -459,8 +455,8 @@ class ContactController
ResourceContactModel
::
update
([
'set'
=>
[
'item_id'
=>
$queryParams
[
'redirect'
]],
'where'
=>
[
'item_id = ?'
,
"
type = '
contact'"
],
'data'
=>
[
$args
[
'id'
]]
'where'
=>
[
'item_id = ?'
,
'
type =
?
'
],
'data'
=>
[
$args
[
'id'
]
,
'contact'
]
]);
// Delete duplicates if needed
...
...
@@ -502,7 +498,7 @@ class ContactController
ResourceContactModel
::
delete
([
'where'
=>
[
'item_id = ?'
,
"type = 'contact'"
],
'data'
=>
[
$args
[
'id'
]]
'data'
=>
[
$args
[
'id'
]]
]);
ContactModel
::
delete
([
...
...
This diff is collapsed.
Click to expand it.
src/app/resource/controllers/ResController.php
+
22
−
0
View file @
00aa9f97
...
...
@@ -814,6 +814,28 @@ class ResController extends ResourceControlController
return
$response
->
withStatus
(
204
);
}
public
function
getField
(
Request
$request
,
Response
$response
,
array
$args
)
{
if
(
!
ResController
::
hasRightByResId
([
'resId'
=>
[
$args
[
'resId'
]],
'userId'
=>
$GLOBALS
[
'id'
]]))
{
return
$response
->
withStatus
(
403
)
->
withJson
([
'errors'
=>
'Document out of perimeter'
]);
}
$authorizedFields
=
[
'destination'
,
'status'
];
if
(
!
in_array
(
$args
[
'fieldId'
],
$authorizedFields
))
{
return
$response
->
withStatus
(
403
)
->
withJson
([
'errors'
=>
'Field out of perimeter'
]);
}
$resource
=
ResModel
::
getById
([
'select'
=>
[
$args
[
'fieldId'
]],
'resId'
=>
$args
[
'resId'
]
]);
if
(
empty
(
$resource
))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Document does not exist'
]);
}
return
$response
->
withJson
([
'field'
=>
$resource
[
$args
[
'fieldId'
]]]);
}
public
static
function
getEncodedDocument
(
array
$aArgs
)
{
ValidatorModel
::
notEmpty
(
$aArgs
,
[
'resId'
]);
...
...
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