Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
B
bat_api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
bat_api
Commits
c267c052
Commit
c267c052
authored
May 20, 2016
by
Nicolò Caruso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve services for Units
parent
3999a832
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
14 deletions
+30
-14
bat_api.module
bat_api.module
+30
-14
No files found.
bat_api.module
View file @
c267c052
...
...
@@ -128,11 +128,11 @@ function bat_api_services_resources() {
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'bat_unit'
,
'type'
=>
'array'
,
'description'
=>
t
(
'The unit data to update'
),
'source'
=>
'data'
,
'optional'
=>
FALSE
,
'name'
=>
'bat_unit'
,
'type'
=>
'array'
,
'description'
=>
t
(
'The unit data to update'
),
'source'
=>
'data'
,
'optional'
=>
FALSE
,
),
),
),
...
...
@@ -157,6 +157,20 @@ function bat_api_services_resources() {
'source'
=>
array
(
'data'
=>
'type'
),
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'type_id'
,
'type'
=>
'integer'
,
'description'
=>
t
(
'Type ID'
),
'source'
=>
array
(
'data'
=>
'type_id'
),
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'uid'
,
'type'
=>
'integer'
,
'description'
=>
t
(
'UID'
),
'source'
=>
array
(
'data'
=>
'uid'
),
'optional'
=>
FALSE
,
),
array
(
'name'
=>
'status'
,
'type'
=>
'integer'
,
...
...
@@ -503,7 +517,7 @@ function bat_api_services_units_index($unit_ids, $offset, $limit) {
$ids
=
array_filter
(
explode
(
','
,
$unit_ids
));
$query
=
db_select
(
'bat_units'
,
'n'
)
->
fields
(
'n'
,
array
(
'unit_id'
,
'type'
,
'name'
,
'language'
,
'status'
,
'uid'
));
->
fields
(
'n'
,
array
(
'unit_id'
,
'type'
,
'
type_id'
,
'
name'
,
'language'
,
'status'
,
'uid'
));
if
(
!
empty
(
$ids
))
{
$query
->
condition
(
'unit_id'
,
$ids
,
'IN'
);
}
...
...
@@ -515,8 +529,9 @@ function bat_api_services_units_index($unit_ids, $offset, $limit) {
foreach
(
$bat_units
as
$unit
)
{
$units
[
$unit
->
unit_id
]
=
array
(
'properties'
=>
array
(
'type'
=>
$unit
->
type
,
'name'
=>
$unit
->
name
,
'type'
=>
$unit
->
type
,
'type_id'
=>
$unit
->
type_id
,
'language'
=>
$unit
->
language
,
'status'
=>
$unit
->
status
,
'uid'
=>
$unit
->
uid
,
...
...
@@ -548,19 +563,22 @@ function bat_api_services_units_index($unit_ids, $offset, $limit) {
*
* @param $name
* @param $type
* @param $type_id
* @param $uid
* @param $status
*/
function
bat_api_services_add_unit
(
$name
,
$type
,
$status
)
{
function
bat_api_services_add_unit
(
$name
,
$type
,
$
type_id
,
$uid
,
$
status
)
{
$return
=
new
stdClass
();
$return
->
sessid
=
session_id
();
if
(
bat_
type_load
(
$type
)
!==
FALSE
&&
$name
!=
''
)
{
if
(
bat_
unit_bundle_load
(
$type
)
!==
FALSE
&&
bat_type_load
(
$type_id
)
!==
FALSE
&&
$name
!=
''
)
{
$unit
=
bat_unit_create
(
array
(
'name'
=>
$name
,
'type'
=>
$type
,
'type_id'
=>
$type_id
,
'status'
=>
$status
,
'uid'
=>
0
,
'uid'
=>
$uid
,
'created'
=>
REQUEST_TIME
,
'changed'
=>
REQUEST_TIME
,
)
...
...
@@ -588,13 +606,11 @@ function bat_api_services_edit_unit($unit_id, $bat_unit_data) {
$return
=
new
stdClass
();
$return
->
sessid
=
session_id
();
$unit
=
bat_unit_load
(
$unit_id
);
if
(
$unit
!==
FALSE
)
{
if
(
$unit
=
bat_unit_load
(
$unit_id
))
{
$unit
->
name
=
(
isset
(
$bat_unit_data
[
'name'
]))
?
$bat_unit_data
[
'name'
]
:
$unit
->
name
;
$unit
->
default_state
=
(
isset
(
$bat_unit_data
[
'default_state'
]))
?
$bat_unit_data
[
'default_state'
]
:
$unit
->
default_state
;
$unit
->
status
=
(
isset
(
$bat_unit_data
[
'status'
]))
?
$bat_unit_data
[
'status'
]
:
$unit
->
status
;
$unit
->
uid
=
(
isset
(
$bat_unit_data
[
'uid'
]))
?
$bat_unit_data
[
'uid'
]
:
$unit
->
uid
;
$unit
->
data
=
(
isset
(
$bat_unit_data
[
'data'
]))
?
$bat_unit_data
[
'data'
]
:
$unit
->
data
;
$unit
->
changed
=
REQUEST_TIME
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment