2
0
forked from Wavyzz/dolibarr

Move 401 to 403

This commit is contained in:
Laurent Destailleur
2024-02-01 19:16:58 +01:00
parent cbe1b75332
commit c9823f2b8d
29 changed files with 382 additions and 391 deletions

View File

@@ -119,7 +119,7 @@ class Orders extends DolibarrApi
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id, $ref, $ref_ext);
@@ -166,7 +166,7 @@ class Orders extends DolibarrApi
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $sqlfilterlines = '', $properties = '')
{
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(401);
throw new RestException(403);
}
$obj_ret = array();
@@ -306,7 +306,7 @@ class Orders extends DolibarrApi
public function getLines($id)
{
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -338,7 +338,7 @@ class Orders extends DolibarrApi
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -405,7 +405,7 @@ class Orders extends DolibarrApi
public function putLine($id, $lineid, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -473,7 +473,7 @@ class Orders extends DolibarrApi
public function deleteLine($id, $lineid)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -509,7 +509,7 @@ class Orders extends DolibarrApi
public function getContacts($id, $type = '')
{
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -542,7 +542,7 @@ class Orders extends DolibarrApi
public function postContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -590,7 +590,7 @@ class Orders extends DolibarrApi
public function deleteContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -632,7 +632,7 @@ class Orders extends DolibarrApi
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@@ -679,7 +679,7 @@ class Orders extends DolibarrApi
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->commande->supprimer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
if (!$result) {
@@ -727,7 +727,7 @@ class Orders extends DolibarrApi
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
if (!$result) {
@@ -778,7 +778,7 @@ class Orders extends DolibarrApi
public function reopen($id)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
@@ -814,7 +814,7 @@ class Orders extends DolibarrApi
public function setinvoiced($id)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
@@ -855,7 +855,7 @@ class Orders extends DolibarrApi
public function close($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
if (!$result) {
@@ -900,7 +900,7 @@ class Orders extends DolibarrApi
public function settodraft($id, $idwarehouse = -1)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
$result = $this->commande->fetch($id);
if (!$result) {
@@ -952,10 +952,10 @@ class Orders extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) {
throw new RestException(401);
throw new RestException(403);
}
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
throw new RestException(403);
}
if (empty($proposalid)) {
throw new RestException(400, 'Proposal ID is mandatory');
@@ -993,7 +993,7 @@ class Orders extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (!DolibarrApiAccess::$user->rights->expedition->lire) {
throw new RestException(401);
throw new RestException(403);
}
$obj_ret = array();
$sql = "SELECT e.rowid";
@@ -1049,7 +1049,7 @@ class Orders extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
throw new RestException(401);
throw new RestException(403);
}
if ($warehouse_id <= 0) {
throw new RestException(404, 'Warehouse not found');