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

This commit is contained in:
Laurent Destailleur 2024-02-04 13:54:55 +01:00
parent 8710e0b235
commit 8592db0729
8 changed files with 59 additions and 59 deletions

View file

@ -191,7 +191,7 @@ class AgendaEvents extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) {
if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) {
throw new RestException(401, "Insufficient rights to create your Agenda Event");
}
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
@ -236,7 +236,7 @@ class AgendaEvents extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) {
if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) {
throw new RestException(401, "Insufficient rights to create your Agenda Event");
}
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) {

View file

@ -67,7 +67,7 @@ class BankAccounts extends DolibarrApi
{
$list = array();
if (!DolibarrApiAccess::$user->rights->banque->lire) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
throw new RestException(403);
}
@ -129,7 +129,7 @@ class BankAccounts extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->banque->lire) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
throw new RestException(403);
}
@ -150,7 +150,7 @@ class BankAccounts extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->banque->configurer) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
throw new RestException(403);
}
// Check mandatory fields
@ -201,7 +201,7 @@ class BankAccounts extends DolibarrApi
*/
public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0)
{
if (!DolibarrApiAccess::$user->rights->banque->configurer) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
throw new RestException(403);
}
@ -325,7 +325,7 @@ class BankAccounts extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->banque->configurer) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
throw new RestException(403);
}
@ -363,7 +363,7 @@ class BankAccounts extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->banque->configurer) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
throw new RestException(403);
}
$account = new Account($this->db);
@ -436,7 +436,7 @@ class BankAccounts extends DolibarrApi
{
$list = array();
if (!DolibarrApiAccess::$user->rights->banque->lire) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
throw new RestException(403);
}
@ -595,7 +595,7 @@ class BankAccounts extends DolibarrApi
{
$list = array();
if (!DolibarrApiAccess::$user->rights->banque->lire) {
if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
throw new RestException(403);
}

View file

@ -64,7 +64,7 @@ class Shipments extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->expedition->lire) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
throw new RestException(403);
}
@ -103,7 +103,7 @@ class Shipments extends DolibarrApi
{
global $db, $conf;
if (!DolibarrApiAccess::$user->rights->expedition->lire) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
throw new RestException(403);
}
@ -182,7 +182,7 @@ class Shipments extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -224,7 +224,7 @@ class Shipments extends DolibarrApi
/*
public function getLines($id)
{
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
throw new RestException(403);
}
@ -258,7 +258,7 @@ class Shipments extends DolibarrApi
/*
public function postLine($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
@ -326,7 +326,7 @@ class Shipments extends DolibarrApi
/*
public function putLine($id, $lineid, $request_data = null)
{
if (! DolibarrApiAccess::$user->rights->expedition->creer) {
if (! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
@ -393,7 +393,7 @@ class Shipments extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
@ -426,7 +426,7 @@ class Shipments extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
@ -467,7 +467,7 @@ class Shipments extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->expedition->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'supprimer')) {
throw new RestException(403);
}
$result = $this->shipment->fetch($id);
@ -512,7 +512,7 @@ class Shipments extends DolibarrApi
*/
public function validate($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
$result = $this->shipment->fetch($id);
@ -558,7 +558,7 @@ class Shipments extends DolibarrApi
public function setinvoiced($id)
{
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
if(empty($id)) {
@ -597,10 +597,10 @@ class Shipments extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) {
throw new RestException(403);
}
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}
if(empty($proposalid)) {
@ -634,7 +634,7 @@ class Shipments extends DolibarrApi
*/
public function close($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->expedition->creer) {
if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) {
throw new RestException(403);
}

View file

@ -305,7 +305,7 @@ class Interventions extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->ficheinter->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'supprimer')) {
throw new RestException(403);
}
$result = $this->fichinter->fetch($id);

View file

@ -68,7 +68,7 @@ class Partnerships extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->partnership->read) {
if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) {
throw new RestException(403);
}
@ -107,7 +107,7 @@ class Partnerships extends DolibarrApi
$obj_ret = array();
$tmpobject = new Partnership($this->db);
if (!DolibarrApiAccess::$user->rights->partnership->read) {
if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) {
throw new RestException(403);
}

View file

@ -252,7 +252,7 @@ class Products extends DolibarrApi
if (!$ids_only) {
$product_static = new Product($this->db);
if ($product_static->fetch($obj->rowid)) {
if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) {
if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
$product_static->load_stock();
if (is_array($product_static->stock_warehouse)) {
@ -446,7 +446,7 @@ class Products extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
$result = $this->product->fetch($id);
@ -825,7 +825,7 @@ class Products extends DolibarrApi
*/
public function deletePurchasePrice($id, $priceid)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
$result = $this->productsupplier->fetch($id);
@ -1316,7 +1316,7 @@ class Products extends DolibarrApi
*/
public function deleteAttributes($id)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
@ -1428,7 +1428,7 @@ class Products extends DolibarrApi
*/
public function deleteAttributeValueByRef($id, $ref)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
@ -1629,7 +1629,7 @@ class Products extends DolibarrApi
*/
public function deleteAttributeValueById($id)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
@ -1668,7 +1668,7 @@ class Products extends DolibarrApi
$combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id);
$combinations[$key] = $this->_cleanObjectDatas($combinations[$key]);
if (!empty($includestock) && DolibarrApiAccess::$user->rights->stock->lire) {
if (!empty($includestock) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
$productModel = new Product($this->db);
$productModel->fetch((int) $combination->fk_product_child);
$productModel->load_stock($includestock);
@ -1890,7 +1890,7 @@ class Products extends DolibarrApi
*/
public function deleteVariant($id)
{
if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) {
throw new RestException(403);
}
@ -1919,7 +1919,7 @@ class Products extends DolibarrApi
*/
public function getStock($id, $selected_warehouse_id = null)
{
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->rights->stock->lire) {
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
throw new RestException(403);
}
@ -2069,7 +2069,7 @@ class Products extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) {
if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
$this->product->load_stock($includestockdata);
if (is_array($this->product->stock_warehouse)) {

View file

@ -71,7 +71,7 @@ class Projects extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -107,7 +107,7 @@ class Projects extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $properties = '')
{
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -193,7 +193,7 @@ class Projects extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -234,7 +234,7 @@ class Projects extends DolibarrApi
*/
public function getLines($id, $includetimespent = 0)
{
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -274,7 +274,7 @@ class Projects extends DolibarrApi
{
global $db;
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -317,7 +317,7 @@ class Projects extends DolibarrApi
/*
public function postLine($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->projet->creer) {
if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -384,7 +384,7 @@ class Projects extends DolibarrApi
/*
public function putLine($id, $lineid, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->projet->creer) {
if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -445,7 +445,7 @@ class Projects extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -486,7 +486,7 @@ class Projects extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->projet->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) {
throw new RestException(403);
}
$result = $this->project->fetch($id);
@ -530,7 +530,7 @@ class Projects extends DolibarrApi
*/
public function validate($id, $notrigger = 0)
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
$result = $this->project->fetch($id);

View file

@ -67,7 +67,7 @@ class Tasks extends DolibarrApi
*/
public function get($id, $includetimespent = 0)
{
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -109,7 +109,7 @@ class Tasks extends DolibarrApi
{
global $db, $conf;
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -189,7 +189,7 @@ class Tasks extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
@ -229,7 +229,7 @@ class Tasks extends DolibarrApi
/*
public function getLines($id, $includetimespent=0)
{
if(! DolibarrApiAccess::$user->rights->projet->lire) {
if(! DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -274,7 +274,7 @@ class Tasks extends DolibarrApi
{
global $db;
if (!DolibarrApiAccess::$user->rights->projet->lire) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
throw new RestException(403);
}
@ -315,7 +315,7 @@ class Tasks extends DolibarrApi
/*
public function postLine($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->projet->creer) {
if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -382,7 +382,7 @@ class Tasks extends DolibarrApi
/*
public function putLine($id, $lineid, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->projet->creer) {
if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -442,7 +442,7 @@ class Tasks extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
@ -483,7 +483,7 @@ class Tasks extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->projet->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) {
throw new RestException(403);
}
$result = $this->task->fetch($id);
@ -526,7 +526,7 @@ class Tasks extends DolibarrApi
*/
public function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '')
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
$result = $this->task->fetch($id);
@ -585,7 +585,7 @@ class Tasks extends DolibarrApi
*/
public function putTimeSpent($id, $timespent_id, $date, $duration, $user_id = 0, $note = '')
{
if (!DolibarrApiAccess::$user->rights->projet->creer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) {
throw new RestException(403);
}
$this->timespentRecordChecks($id, $timespent_id);
@ -630,7 +630,7 @@ class Tasks extends DolibarrApi
*/
public function deleteTimeSpent($id, $timespent_id)
{
if (!DolibarrApiAccess::$user->rights->projet->supprimer) {
if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) {
throw new RestException(403);
}
$this->timespentRecordChecks($id, $timespent_id);