Skip to content

Commit

Permalink
Use the non deprecated function loadRights instead of getrights
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 2, 2024
1 parent 56d4a30 commit f002fb4
Show file tree
Hide file tree
Showing 48 changed files with 67 additions and 68 deletions.
2 changes: 1 addition & 1 deletion htdocs/api/class/api_access.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function __isAllowed()
}

// User seems valid
$fuser->getrights();
$fuser->loadRights();

// Set the property $user to the $user of API
static::$user = $fuser;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/class/api_login.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function index($login, $password, $entity = '', $reset = 0)

// Renew the hash
if (empty($tmpuser->api_key) || $reset) {
$tmpuser->getrights();
$tmpuser->loadRights();
if (!$tmpuser->hasRight('user', 'self', 'creer')) {
if (empty($tmpuser->api_key)) {
throw new RestException(403, 'No API token set for this user and user need write permission on itself to reset its API token');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/ws.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function check_authentication($authentication, &$error, &$errorcode, &$errorlabe

// Validation of login
if (!$error) {
$fuser->getrights(); // Load permission of user
$fuser->loadRights(); // Load permission of user

// Authentication mode
if (empty($dolibarr_main_authentication)) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/DolibarrModules.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ public function insert_permissions($reinitadminperms = 0, $force_entity = null,
if (!empty($reinitadminperms) && !empty($user->admin)) { // Reload permission for current user if defined
// We reload permissions
$user->clearrights();
$user->getrights();
$user->loadRights();
}
}
$this->db->free($resql);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/dav/fileserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$user = new User($db);
if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] != '') {
$user->fetch(0, $_SERVER['PHP_AUTH_USER']);
$user->getrights();
$user->loadRights();
}

// Load translation files required by the page
Expand Down
2 changes: 1 addition & 1 deletion htdocs/ecm/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$result = restrictedArea($user, 'ecm', '');

// Load permissions
$user->getrights('ecm');
$user->loadRights('ecm');

// Get parameters
$socid = GETPOSTINT('socid');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/expensereport/class/expensereport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,7 @@ public function computeTotalKm($fk_cat, $qty, $tva)

$currentUser = new User($db);
$currentUser->fetch($this->fk_user);
$currentUser->getrights('expensereport');
$currentUser->loadRights('expensereport');
//Clean
$qty = (float) price2num($qty);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/expensereport/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
if ($id > 0) {
// Charge utilisateur edite
$fuser->fetch($id, '', '', 1);
$fuser->getrights();
$fuser->loadRights();
$user_id = $fuser->id;

$search_user = $user_id;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/commande/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@

$userstatic = new User($db);
$userstatic->id = $obj->rowid;
$userstatic->getrights('fournisseur');
$userstatic->loadRights('fournisseur');

if ($userstatic->hasRight('fournisseur', 'commande', 'approuver')) {
print '<tr class="oddeven">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/holiday/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
if ($id > 0) {
// Charge utilisateur edite
$fuser->fetch($id, '', '', 1);
$fuser->getrights();
$fuser->loadRights();
$user_id = $fuser->id;

$search_employee = $user_id;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/imports/emptyexample.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages =

// Check exportkey
if (empty($datatoimport)) {
$user->getrights();
$user->loadRights();

llxHeader();
print '<div class="error">Bad value for datatoimport.</div>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ function analyseVarsForSqlAndScriptsInjection(&$var, $type, $stopcode = 1)
}

// Load permissions
$user->getrights();
$user->loadRights();
}

dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').(defined('NOTOKENRENEWAL') ? ' NOTOKENRENEWAL='.constant('NOTOKENRENEWAL') : ''), LOG_NOTICE);
Expand Down
4 changes: 1 addition & 3 deletions htdocs/modulebuilder/template/css/mymodule.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
// Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS
/*if (empty($user->id) && !empty($_SESSION['dol_login'])) {
$user->fetch('',$_SESSION['dol_login']);
$user->getrights();
$user->loadRights();
}*/


Expand All @@ -107,5 +107,3 @@
.myclasscss {
/* ... */
}


2 changes: 1 addition & 1 deletion htdocs/modulebuilder/template/scripts/mymodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
dol_print_error(null, $user->error);
exit;
}
$user->getrights();
$user->loadRights();

$hookmanager->initHooks(array('cli'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
$user->loadRights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/public/agenda/agendaexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function llxFooterVierge()

// Check config
if (!getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
$user->getrights();
$user->loadRights();

top_httphead();

Expand All @@ -189,7 +189,7 @@ function llxFooterVierge()
} elseif (empty($reshook)) {
// Check exportkey
if (!GETPOST("exportkey") || getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY') != GETPOST("exportkey")) {
$user->getrights();
$user->loadRights();

top_httphead();

Expand Down
4 changes: 2 additions & 2 deletions htdocs/public/cron/cron_run_jobs_by_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
exit;
}
}
$user->getrights();
$user->loadRights();

$id = GETPOST('id', 'alpha'); // We accept non numeric id. We will filter later.

Expand Down Expand Up @@ -180,7 +180,7 @@
exit(-1);
}
}
$user->getrights();
$user->loadRights();
}
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/public/stripe/ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
// We set the user to use for all ipn actions in Dolibarr
$user = new User($db);
$user->fetch(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'));
$user->getrights();
$user->loadRights();
} else {
httponly_accessforbidden('Error: Setup of module Stripe not complete for mode '.dol_escape_htmltag($service).'. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.', 400, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/theme/eldy/style.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
// and permission, so we can later calculate number of top menu ($nbtopmenuentries) according to user profile.
if (empty($user->id) && !empty($_SESSION['dol_login'])) {
$user->fetch('', $_SESSION['dol_login'], '', 1);
$user->getrights();
$user->loadRights();

// Reload menu now we have the good user (and we need the good menu to have ->showmenu('topnb') correct.
$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/theme/md/style.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
// and permission, so we can later calculate number of top menu ($nbtopmenuentries) according to user profile.
if (empty($user->id) && !empty($_SESSION['dol_login'])) {
$user->fetch('', $_SESSION['dol_login'], '', 1);
$user->getrights();
$user->loadRights();
//$user->loadPersonalConf();

// Reload menu now we have the good user (and we need the good menu to have ->showmenu('topnb') correct.
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/agenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
$object = new User($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
$object->loadRights();
}

// Security check
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/agenda_extsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

$object = new User($db);
$object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();

// Security check
$socid = 0;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/bank.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
$object = new User($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
$object->loadRights();
}

$account = new UserBankAccount($db);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@

// Check if user has rights
if (!getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
$object->getrights();
$object->loadRights();
if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings');
}
Expand Down
5 changes: 3 additions & 2 deletions htdocs/user/class/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ public function loadRights($moduletag = '', $forcereload = 0)
$sql .= " ".$this->db->prefix()."usergroup_user as gu,";
$sql .= " ".$this->db->prefix()."rights_def as r";
$sql .= " WHERE r.id = gr.fk_id";
// @FIXME Very strange business rules. Must be alays the same than into user->getrights() user/perms.php and user/group/perms.php
// @FIXME Very strange business rules. Must be always the same than into user->loadRights() user/perms.php and user/group/perms.php
if (getDolGlobalString('MULTICOMPANY_BACKWARD_COMPATIBILITY')) {
if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
$sql .= " AND gu.entity IN (0,".$conf->entity.")";
Expand Down Expand Up @@ -1443,11 +1443,12 @@ public function loadRights($moduletag = '', $forcereload = 0)

/**
* Load permissions granted to a user->id into object user->rights
* TODO Remove this method. It has a name conflict with getRights() in CommonObject.
* TODO Remove this method. It has a name conflict with getRights() in CommonObject and was replaced in v20 with loadRights()
*
* @param string $moduletag Limit permission for a particular module ('' by default means load all permissions)
* @param int $forcereload Force reload of permissions even if they were already loaded (ignore cache)
* @return void
* @deprecated
*
* @see clearrights(), delrights(), addrights(), hasRight()
* @phpstan-ignore-next-line
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/clicktodial.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if ($id > 0) {
$object = new User($db);
$object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();
$object->fetch_clicktodial();

$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
$object = new User($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
$object->loadRights();
//$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ;
// For users, the upload_dir is always $conf->user->entity for the moment
$upload_dir = $conf->user->dir_output."/".$object->id;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/group/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
$object->getrights();
$object->loadRights();

// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('groupcard', 'globalcard'));
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/group/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

$object = new UserGroup($db);
$object->fetch($id, '', true);
$object->getrights();
$object->loadRights();

// Users/Groups management only in master entity if transverse mode
if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
Expand Down
6 changes: 3 additions & 3 deletions htdocs/user/group/perms.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

$object = new UserGroup($db);
$object->fetch($id);
$object->getrights();
$object->loadRights();

$entity = $conf->entity;

Expand Down Expand Up @@ -106,7 +106,7 @@
}

$user->clearrights();
$user->getrights();
$user->loadRights();
}

if ($action == 'delrights' && $caneditperms) {
Expand All @@ -122,7 +122,7 @@
}

$user->clearrights();
$user->getrights();
$user->loadRights();
}
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

$object = new User($db);
$object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();

// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('usercard', 'userldap', 'globalcard'));
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
if ($result <= 0) {
accessforbidden('User not found');
}
$object->getrights();
$object->loadRights();
}

// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

$object = new User($db);
$object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();

// If user is not user read and no permission to read other users, we stop
if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
Expand Down
4 changes: 2 additions & 2 deletions htdocs/user/notify/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
$object = new User($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
$object->loadRights();
}

$permissiontoadd = (($object->id == $user->id) || ($user->hasRight('user', 'user', 'lire')));
Expand Down Expand Up @@ -141,7 +141,7 @@

$object = new User($db);
$result = $object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();

$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification");
if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/param_ihm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
// Charge utilisateur edite
$object = new User($db);
$object->fetch($id, '', '', 1);
$object->getrights();
$object->loadRights();

// Liste des zone de recherche permanentes supportees
/* deprecated
Expand Down
Loading

0 comments on commit f002fb4

Please sign in to comment.