code comment api contract
This commit is contained in:
parent
622f31fd1e
commit
dbbcb6f8a1
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -215,7 +216,7 @@ class Contracts extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @url GET {id}/lines
|
* @url GET {id}/lines
|
||||||
*
|
*
|
||||||
* @return int
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getLines($id)
|
function getLines($id)
|
||||||
{
|
{
|
||||||
@ -234,7 +235,7 @@ class Contracts extends DolibarrApi
|
|||||||
$this->contract->getLinesArray();
|
$this->contract->getLinesArray();
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($this->contract->lines as $line) {
|
foreach ($this->contract->lines as $line) {
|
||||||
array_push($result,$this->_cleanObjectDatas($line));
|
array_push($result, $this->_cleanObjectDatas($line));
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -247,7 +248,7 @@ class Contracts extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @url POST {id}/lines
|
* @url POST {id}/lines
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int|bool
|
||||||
*/
|
*/
|
||||||
function postLine($id, $request_data = null)
|
function postLine($id, $request_data = null)
|
||||||
{
|
{
|
||||||
@ -300,7 +301,7 @@ class Contracts extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @url PUT {id}/lines/{lineid}
|
* @url PUT {id}/lines/{lineid}
|
||||||
*
|
*
|
||||||
* @return object
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function putLine($id, $lineid, $request_data = null)
|
function putLine($id, $lineid, $request_data = null)
|
||||||
{
|
{
|
||||||
@ -360,7 +361,7 @@ class Contracts extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @url PUT {id}/lines/{lineid}/activate
|
* @url PUT {id}/lines/{lineid}/activate
|
||||||
*
|
*
|
||||||
* @return object
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null)
|
function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null)
|
||||||
{
|
{
|
||||||
@ -369,7 +370,7 @@ class Contracts extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contrat not found');
|
throw new RestException(404, 'Contrat not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,16 +399,16 @@ class Contracts extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @url PUT {id}/lines/{lineid}/unactivate
|
* @url PUT {id}/lines/{lineid}/unactivate
|
||||||
*
|
*
|
||||||
* @return object
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function unactivateLine($id, $lineid, $datestart, $comment = null)
|
function unactivateLine($id, $lineid, $datestart, $comment = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contrat not found');
|
throw new RestException(404, 'Contrat not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,16 +444,16 @@ class Contracts extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function deleteLine($id, $lineid)
|
function deleteLine($id, $lineid)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contrat not found');
|
throw new RestException(404, 'Contrat not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,16 +479,16 @@ class Contracts extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function put($id, $request_data = null)
|
function put($id, $request_data = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contrat not found');
|
throw new RestException(404, 'Contrat not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
@ -514,19 +515,19 @@ class Contracts extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->supprimer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->supprimer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contract not found');
|
throw new RestException(404, 'Contract not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
if (! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->contract->delete(DolibarrApiAccess::$user)) {
|
if (! $this->contract->delete(DolibarrApiAccess::$user)) {
|
||||||
throw new RestException(500, 'Error when delete contract : '.$this->contract->error);
|
throw new RestException(500, 'Error when delete contract : '.$this->contract->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,15 +557,15 @@ class Contracts extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function validate($id, $notrigger=0)
|
function validate($id, $notrigger=0)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contract not found');
|
throw new RestException(404, 'Contract not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
if (! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,15 +603,15 @@ class Contracts extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function close($id, $notrigger=0)
|
function close($id, $notrigger=0)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
|
if (! DolibarrApiAccess::$user->rights->contrat->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->contract->fetch($id);
|
$result = $this->contract->fetch($id);
|
||||||
if( ! $result ) {
|
if (! $result) {
|
||||||
throw new RestException(404, 'Contract not found');
|
throw new RestException(404, 'Contract not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
if (! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user