Move rights->x->y into hasRight('x', 'y')

This commit is contained in:
Laurent Destailleur 2024-02-04 13:20:38 +01:00
parent 840d73a471
commit 9c7294aa81
7 changed files with 97 additions and 97 deletions

View file

@ -320,7 +320,7 @@ class Categories extends DolibarrApi
throw new RestException(403);
}
if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->rights->produit->lire && !DolibarrApiAccess::$user->rights->service->lire) {
if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) {
throw new RestException(403);
} elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) {
throw new RestException(403);
@ -372,7 +372,7 @@ class Categories extends DolibarrApi
}
if ($type === Categorie::TYPE_PRODUCT) {
if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
throw new RestException(403);
}
$object = new Product($this->db);
@ -387,7 +387,7 @@ class Categories extends DolibarrApi
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(403);
}
$object = new Contact($this->db);
@ -452,7 +452,7 @@ class Categories extends DolibarrApi
}
if ($type === Categorie::TYPE_PRODUCT) {
if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
throw new RestException(403);
}
$object = new Product($this->db);
@ -467,7 +467,7 @@ class Categories extends DolibarrApi
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(403);
}
$object = new Contact($this->db);
@ -532,7 +532,7 @@ class Categories extends DolibarrApi
}
if ($type === Categorie::TYPE_PRODUCT) {
if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
throw new RestException(403);
}
$object = new Product($this->db);
@ -547,7 +547,7 @@ class Categories extends DolibarrApi
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(403);
}
$object = new Contact($this->db);
@ -610,7 +610,7 @@ class Categories extends DolibarrApi
}
if ($type === Categorie::TYPE_PRODUCT) {
if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
throw new RestException(403);
}
$object = new Product($this->db);
@ -625,7 +625,7 @@ class Categories extends DolibarrApi
}
$object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(403);
}
$object = new Contact($this->db);

View file

@ -264,7 +264,7 @@ class Orders extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -337,7 +337,7 @@ class Orders extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -404,7 +404,7 @@ class Orders extends DolibarrApi
*/
public function putLine($id, $lineid, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -472,7 +472,7 @@ class Orders extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -541,7 +541,7 @@ class Orders extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -589,7 +589,7 @@ class Orders extends DolibarrApi
*/
public function deleteContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -631,7 +631,7 @@ class Orders extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
@ -726,7 +726,7 @@ class Orders extends DolibarrApi
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@ -777,7 +777,7 @@ class Orders extends DolibarrApi
*/
public function reopen($id)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -813,7 +813,7 @@ class Orders extends DolibarrApi
*/
public function setinvoiced($id)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -854,7 +854,7 @@ class Orders extends DolibarrApi
*/
public function close($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@ -899,7 +899,7 @@ class Orders extends DolibarrApi
*/
public function settodraft($id, $idwarehouse = -1)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
$result = $this->commande->fetch($id);
@ -954,7 +954,7 @@ class Orders extends DolibarrApi
if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) {
throw new RestException(403);
}
if (!DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) {
throw new RestException(403);
}
if (empty($proposalid)) {

View file

@ -282,7 +282,7 @@ class Invoices extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -335,7 +335,7 @@ class Invoices extends DolibarrApi
if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) {
throw new RestException(403);
}
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($orderid)) {
@ -376,7 +376,7 @@ class Invoices extends DolibarrApi
if (!DolibarrApiAccess::$user->hasRight('contrat', 'lire')) {
throw new RestException(403);
}
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($contractid)) {
@ -443,7 +443,7 @@ class Invoices extends DolibarrApi
*/
public function putLine($id, $lineid, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -514,7 +514,7 @@ class Invoices extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -562,7 +562,7 @@ class Invoices extends DolibarrApi
*/
public function deleteContact($id, $contactid, $type)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -607,7 +607,7 @@ class Invoices extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($lineid)) {
@ -640,7 +640,7 @@ class Invoices extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -745,7 +745,7 @@ class Invoices extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -833,7 +833,7 @@ class Invoices extends DolibarrApi
*/
public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
$result = $this->invoice->fetch($id);
@ -881,7 +881,7 @@ class Invoices extends DolibarrApi
*/
public function settodraft($id, $idwarehouse = -1)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
$result = $this->invoice->fetch($id);
@ -932,7 +932,7 @@ class Invoices extends DolibarrApi
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
$result = $this->invoice->fetch($id);
@ -981,7 +981,7 @@ class Invoices extends DolibarrApi
*/
public function settopaid($id, $close_code = '', $close_note = '')
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
$result = $this->invoice->fetch($id);
@ -1030,7 +1030,7 @@ class Invoices extends DolibarrApi
*/
public function settounpaid($id)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
$result = $this->invoice->fetch($id);
@ -1118,7 +1118,7 @@ class Invoices extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
@ -1287,7 +1287,7 @@ class Invoices extends DolibarrApi
*/
public function useDiscount($id, $discountid)
{
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -1334,7 +1334,7 @@ class Invoices extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -1426,7 +1426,7 @@ class Invoices extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -1546,7 +1546,7 @@ class Invoices extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
foreach ($arrayofamounts as $id => $amount) {
@ -1680,7 +1680,7 @@ class Invoices extends DolibarrApi
{
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
if (!DolibarrApiAccess::$user->rights->facture->creer) {
if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {

View file

@ -78,7 +78,7 @@ class Interventions extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->lire) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) {
throw new RestException(403);
}
@ -112,7 +112,7 @@ class Interventions extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '')
{
if (!DolibarrApiAccess::$user->rights->ficheinter->lire) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) {
throw new RestException(403);
}
@ -190,7 +190,7 @@ class Interventions extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -225,7 +225,7 @@ class Interventions extends DolibarrApi
/* TODO
public function getLines($id)
{
if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
if(! DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) {
throw new RestException(403);
}
@ -258,7 +258,7 @@ class Interventions extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -346,7 +346,7 @@ class Interventions extends DolibarrApi
*/
public function validate($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
$result = $this->fichinter->fetch($id);
@ -382,7 +382,7 @@ class Interventions extends DolibarrApi
*/
public function closeFichinter($id)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
$result = $this->fichinter->fetch($id);

View file

@ -180,7 +180,7 @@ class Products extends DolibarrApi
{
global $db, $conf;
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -306,7 +306,7 @@ class Products extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
// Check mandatory fields
@ -343,7 +343,7 @@ class Products extends DolibarrApi
{
global $conf;
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -491,7 +491,7 @@ class Products extends DolibarrApi
*/
public function getSubproducts($id)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -529,7 +529,7 @@ class Products extends DolibarrApi
*/
public function addSubproducts($id, $subproduct_id, $qty, $incdec = 1)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -559,7 +559,7 @@ class Products extends DolibarrApi
*/
public function delSubproducts($id, $subproduct_id)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -618,7 +618,7 @@ class Products extends DolibarrApi
{
global $conf;
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -660,7 +660,7 @@ class Products extends DolibarrApi
{
global $conf;
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -709,7 +709,7 @@ class Products extends DolibarrApi
{
global $conf;
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -767,7 +767,7 @@ class Products extends DolibarrApi
*/
public function addPurchasePrice($id, $qty, $buyprice, $price_base_type, $fourn_id, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = null)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -864,7 +864,7 @@ class Products extends DolibarrApi
{
global $db, $conf;
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -977,7 +977,7 @@ class Products extends DolibarrApi
$id = (empty($id) ? 0 : $id);
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1025,7 +1025,7 @@ class Products extends DolibarrApi
*/
public function getAttributes($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1087,7 +1087,7 @@ class Products extends DolibarrApi
*/
public function getAttributeById($id)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1130,7 +1130,7 @@ class Products extends DolibarrApi
*/
public function getAttributesByRef($ref)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1180,7 +1180,7 @@ class Products extends DolibarrApi
*/
public function getAttributesByRefExt($ref_ext)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1232,7 +1232,7 @@ class Products extends DolibarrApi
*/
public function addAttributes($ref, $label, $ref_ext = '')
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1264,7 +1264,7 @@ class Products extends DolibarrApi
*/
public function putAttributes($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1344,7 +1344,7 @@ class Products extends DolibarrApi
*/
public function getAttributeValueById($id)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1385,7 +1385,7 @@ class Products extends DolibarrApi
*/
public function getAttributeValueByRef($id, $ref)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1471,7 +1471,7 @@ class Products extends DolibarrApi
*/
public function getAttributeValues($id)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1502,7 +1502,7 @@ class Products extends DolibarrApi
*/
public function getAttributeValuesByRef($ref)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1544,7 +1544,7 @@ class Products extends DolibarrApi
*/
public function addAttributeValue($id, $ref, $value)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1577,7 +1577,7 @@ class Products extends DolibarrApi
*/
public function putAttributeValue($id, $request_data)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1656,7 +1656,7 @@ class Products extends DolibarrApi
*/
public function getVariants($id, $includestock = 0)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1692,7 +1692,7 @@ class Products extends DolibarrApi
*/
public function getVariantsByProdRef($ref)
{
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
@ -1735,7 +1735,7 @@ class Products extends DolibarrApi
*/
public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features, $reference = '', $ref_ext = '')
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1796,7 +1796,7 @@ class Products extends DolibarrApi
*/
public function addVariantByProductRef($ref, $weight_impact, $price_impact, $price_impact_is_percent, $features)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1850,7 +1850,7 @@ class Products extends DolibarrApi
*/
public function putVariant($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->produit->creer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) {
throw new RestException(403);
}
@ -1919,7 +1919,7 @@ class Products extends DolibarrApi
*/
public function getStock($id, $selected_warehouse_id = null)
{
if (!DolibarrApiAccess::$user->rights->produit->lire || !DolibarrApiAccess::$user->rights->stock->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->rights->stock->lire) {
throw new RestException(403);
}
@ -2056,7 +2056,7 @@ class Products extends DolibarrApi
$id = (empty($id) ? 0 : $id);
if (!DolibarrApiAccess::$user->rights->produit->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}

View file

@ -179,7 +179,7 @@ class Receptions extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -255,7 +255,7 @@ class Receptions extends DolibarrApi
/*
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
@ -323,7 +323,7 @@ class Receptions extends DolibarrApi
/*
public function putLine($id, $lineid, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
@ -388,7 +388,7 @@ class Receptions extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
@ -425,7 +425,7 @@ class Receptions extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
@ -510,7 +510,7 @@ class Receptions extends DolibarrApi
*/
public function validate($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
$result = $this->reception->fetch($id);
@ -556,7 +556,7 @@ class Receptions extends DolibarrApi
public function setinvoiced($id)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
if (empty($id)) {
@ -598,7 +598,7 @@ class Receptions extends DolibarrApi
if (!DolibarrApiAccess::$user->rights->reception->lire) {
throw new RestException(403);
}
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}
if (empty($proposalid)) {
@ -632,7 +632,7 @@ class Receptions extends DolibarrApi
*/
public function close($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->reception->creer) {
if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) {
throw new RestException(403);
}

View file

@ -71,7 +71,7 @@ class Contacts extends DolibarrApi
*/
public function get($id, $includecount = 0, $includeroles = 0)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) {
throw new RestException(401, 'No permission to read contacts');
}
@ -119,7 +119,7 @@ class Contacts extends DolibarrApi
*/
public function getByEmail($email, $includecount = 0, $includeroles = 0)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) {
throw new RestException(401, 'No permission to read contacts');
}
@ -177,7 +177,7 @@ class Contacts extends DolibarrApi
$obj_ret = array();
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) {
throw new RestException(401, 'No permission to read contacts');
}
@ -276,7 +276,7 @@ class Contacts extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(401, 'No permission to create/update contacts');
}
// Check mandatory fields
@ -315,7 +315,7 @@ class Contacts extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(401, 'No permission to create/update contacts');
}
@ -403,7 +403,7 @@ class Contacts extends DolibarrApi
throw new RestException(400, "password field missing");
}
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) {
throw new RestException(403, 'No permission to read contacts');
}
if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'creer')) {
@ -479,7 +479,7 @@ class Contacts extends DolibarrApi
*/
public function addCategory($id, $category_id)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(401, 'Insufficient rights');
}
@ -519,7 +519,7 @@ class Contacts extends DolibarrApi
*/
public function deleteCategory($id, $category_id)
{
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
throw new RestException(401, 'Insufficient rights');
}