Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
9ced1dc0
Commit
9ced1dc0
authored
8 years ago
by
nka11
Browse files
Options
Downloads
Patches
Plain Diff
fixing some style and renaming Account to User API
parent
e5a447c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/commande/class/api_commande.class.php
+8
-8
8 additions, 8 deletions
htdocs/commande/class/api_commande.class.php
htdocs/user/class/api_user.class.php
+31
-35
31 additions, 35 deletions
htdocs/user/class/api_user.class.php
with
39 additions
and
43 deletions
htdocs/commande/class/api_commande.class.php
+
8
−
8
View file @
9ced1dc0
...
...
@@ -98,16 +98,16 @@ class CommandeApi extends DolibarrApi
* Get a list of orders
*
* @param int $mode Use this param to filter list
* @param string $societe Societe filter field
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $societe Societe filter field
*
* @url GET /order/list
* @return array Array of order objects
*/
function
getList
(
$mode
=
0
,
$societe
=
""
,
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
)
{
function
getList
(
$mode
=
0
,
$sortfield
=
"s.rowid"
,
$sortorder
=
'ASC'
,
$limit
=
0
,
$page
=
0
,
$societe
=
0
)
{
global
$db
,
$conf
;
$obj_ret
=
array
();
...
...
@@ -191,8 +191,8 @@ class CommandeApi extends DolibarrApi
* @url GET /thirdparty/{socid}/order/list
* @return array Array of order objects
*/
function
getListForSoc
(
$socid
=
""
)
{
return
getList
(
0
,
$socid
);
function
getListForSoc
(
$socid
=
0
)
{
return
getList
(
0
,
"s.rowid"
,
"ASC"
,
0
,
0
,
$socid
);
}
...
...
@@ -219,7 +219,7 @@ class CommandeApi extends DolibarrApi
if
(
isset
(
$request_data
[
"lines"
]))
{
$lines
=
array
();
foreach
(
$request_data
[
"lines"
]
as
$line
)
{
array_push
(
$lines
,
(
object
)
$line
);
array_push
(
$lines
,
(
object
)
$line
);
}
$this
->
commande
->
lines
=
$lines
;
}
...
...
@@ -284,7 +284,7 @@ class CommandeApi extends DolibarrApi
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'commande'
,
$this
->
commande
->
id
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
$request_data
=
(
object
)
$request_data
;
$request_data
=
(
object
)
$request_data
;
$updateRes
=
$this
->
commande
->
addline
(
$request_data
->
desc
,
$request_data
->
subprice
,
...
...
@@ -344,7 +344,7 @@ class CommandeApi extends DolibarrApi
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'commande'
,
$this
->
commande
->
id
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
$request_data
=
(
object
)
$request_data
;
$request_data
=
(
object
)
$request_data
;
$updateRes
=
$this
->
commande
->
updateline
(
$lineid
,
$request_data
->
desc
,
...
...
@@ -400,7 +400,7 @@ class CommandeApi extends DolibarrApi
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'commande'
,
$this
->
commande
->
id
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
$request_data
=
(
object
)
$request_data
;
$request_data
=
(
object
)
$request_data
;
$updateRes
=
$this
->
commande
->
deleteline
(
$lineid
);
if
(
$updateRes
==
1
)
{
return
$this
->
get
(
$id
);
...
...
This diff is collapsed.
Click to expand it.
htdocs/user/class/api_
account
.class.php
→
htdocs/user/class/api_
user
.class.php
+
31
−
35
View file @
9ced1dc0
...
...
@@ -27,7 +27,7 @@ use Luracast\Restler\RestException;
* @class DolibarrApiAccess {@requires user,external}
*
*/
class
Account
Api
extends
DolibarrApi
class
User
Api
extends
DolibarrApi
{
/**
*
...
...
@@ -38,68 +38,66 @@ class AccountApi extends DolibarrApi
);
/**
* @var User $
account
{@type User}
* @var User $
user
{@type User}
*/
public
$account
;
public
$
user
account
;
/**
* Constructor
*
* @url
account
/
* @url
user
/
*
*/
function
__construct
()
{
global
$db
,
$conf
;
$this
->
db
=
$db
;
$this
->
account
=
new
User
(
$this
->
db
);
$this
->
user
account
=
new
User
(
$this
->
db
);
}
/**
* Get properties of an
account
object
* Get properties of an
user
object
*
* Return an array with
account
informations
* Return an array with
user
informations
*
* @param int $id ID of
account
* @param int $id ID of
user
* @return array|mixed data without useless information
*
* @url GET
account/{
user}
* @url GET user
/{id
}
* @throws RestException
*/
function
get
(
$id
)
{
//if (!DolibarrApiAccess::$user->rights->user->lire)
//{
//if (!DolibarrApiAccess::$user->rights->user->user->lire) {
//throw new RestException(401);
//}
$result
=
$this
->
account
->
fetch
(
$id
);
$result
=
$this
->
user
account
->
fetch
(
$id
);
if
(
!
$result
)
{
throw
new
RestException
(
404
,
'User not found'
);
}
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
account
->
id
,
'user'
))
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
user
account
->
id
,
'user'
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
return
$this
->
_cleanObjectDatas
(
$this
->
account
);
return
$this
->
_cleanObjectDatas
(
$this
->
user
account
);
}
/**
* Create account object from contact
* Create
user
account object from contact
*
* @param int $contactid Id of contact
* @param array $request_data Request datas
* @return int ID of
account
* @return int ID of
user
*
* @url POST /contact/{contactid}/create
Account
* @url POST /contact/{contactid}/create
User
*/
function
createFromContact
(
$contactid
,
$request_data
=
NULL
)
{
//if (!DolibarrApiAccess::$user->rights->user->creer)
//{
//if (!DolibarrApiAccess::$user->rights->user->user->creer) {
//throw new RestException(401);
//}
//
if
(
!
isset
(
$request_data
[
"login"
]))
throw
new
RestException
(
400
,
"login field missing"
);
if
(
!
isset
(
$request_data
[
"password"
]))
...
...
@@ -119,12 +117,12 @@ class AccountApi extends DolibarrApi
// Check mandatory fields
$login
=
$request_data
[
"login"
];
$password
=
$request_data
[
"password"
];
$result
=
$this
->
account
->
create_from_contact
(
$contact
,
$login
,
$password
);
$result
=
$this
->
user
account
->
create_from_contact
(
$contact
,
$login
,
$password
);
if
(
$result
<=
0
)
{
throw
new
RestException
(
500
,
"User not created"
);
}
// password parameter not used in create_from_contact
$this
->
account
->
setPassword
(
$this
->
account
,
$password
);
$this
->
user
account
->
setPassword
(
$this
->
user
account
,
$password
);
return
$result
;
}
...
...
@@ -135,31 +133,30 @@ class AccountApi extends DolibarrApi
* @param array $request_data Datas
* @return int
*
* @url PUT
account
/{id}
* @url PUT
user
/{id}
*/
function
put
(
$id
,
$request_data
=
NULL
)
{
//if (!DolibarrApiAccess::$user->rights->user->creer)
//{//
//if (!DolibarrApiAccess::$user->rights->user->user->creer) {
//throw new RestException(401);
//}
$result
=
$this
->
account
->
fetch
(
$id
);
$result
=
$this
->
user
account
->
fetch
(
$id
);
if
(
!
$result
)
{
throw
new
RestException
(
404
,
'Account not found'
);
}
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
account
->
id
,
'user'
))
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
user
account
->
id
,
'user'
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
foreach
(
$request_data
as
$field
=>
$value
)
{
$this
->
account
->
$field
=
$value
;
$this
->
user
account
->
$field
=
$value
;
}
if
(
$this
->
account
->
update
(
$id
,
DolibarrApiAccess
::
$user
,
1
,
''
,
''
,
'update'
))
if
(
$this
->
user
account
->
update
(
$id
,
DolibarrApiAccess
::
$user
,
1
,
''
,
''
,
'update'
))
return
$this
->
get
(
$id
);
return
false
;
...
...
@@ -171,25 +168,24 @@ class AccountApi extends DolibarrApi
* @param int $id Account ID
* @return array
*
* @url DELETE
account
/{id}
* @url DELETE
user
/{id}
*/
function
delete
(
$id
)
{
//if (!DolibarrApiAccess::$user->rights->user->supprimer)
//{
//if (!DolibarrApiAccess::$user->rights->user->user->supprimer) {
//throw new RestException(401);
//}
$result
=
$this
->
account
->
fetch
(
$id
);
$result
=
$this
->
user
account
->
fetch
(
$id
);
if
(
!
$result
)
{
throw
new
RestException
(
404
,
'User not found'
);
}
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
account
->
id
,
'user'
))
if
(
!
DolibarrApi
::
_checkAccessToResource
(
'user'
,
$this
->
user
account
->
id
,
'user'
))
{
throw
new
RestException
(
401
,
'Access not allowed for login '
.
DolibarrApiAccess
::
$user
->
login
);
}
return
$this
->
account
->
delete
(
$id
);
return
$this
->
user
account
->
delete
(
$id
);
}
/**
...
...
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