use user hasRight

This commit is contained in:
Frédéric France 2023-06-20 18:16:19 +02:00
parent 6458075a3d
commit 52eff0b56c
11 changed files with 20 additions and 20 deletions

View file

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('admin', 'bills', 'blockedlog', 'other'));
// Access Control
if ((!$user->admin && empty($user->rights->blockedlog->read)) || empty($conf->blockedlog->enabled)) {
if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || empty($conf->blockedlog->enabled)) {
accessforbidden();
}

View file

@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$id = GETPOST('id', 'int');
$block = new BlockedLog($db);
if ((!$user->admin && empty($user->rights->blockedlog->read)) || empty($conf->blockedlog->enabled)) {
if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || empty($conf->blockedlog->enabled)) {
accessforbidden();
}

View file

@ -1407,7 +1407,7 @@ class ActionComm extends CommonObject
if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".((int) $user->id);
}
$sql .= " WHERE 1 = 1";
@ -1421,7 +1421,7 @@ class ActionComm extends CommonObject
if ($user->socid) {
$sql .= " AND a.fk_soc = ".((int) $user->socid);
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id);
$sql .= " OR ar.fk_element = ".((int) $user->id);
$sql .= ")";

View file

@ -91,13 +91,13 @@ if ($socid < 0) {
}
$canedit = 1;
if (empty($user->rights->agenda->myactions->read)) {
if (!$user->hasRight('agenda', 'myactions', 'read')) {
accessforbidden();
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$canedit = 0;
}
if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}

View file

@ -144,13 +144,13 @@ if ($socid < 0) {
}
$canedit = 1;
if (empty($user->rights->agenda->myactions->read)) {
if (!$user->hasRight('agenda', 'myactions', 'read')) {
accessforbidden();
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$canedit = 0;
}
if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}

View file

@ -89,13 +89,13 @@ if ($socid < 0) {
// Permissions
$canedit = 1;
if (empty($user->rights->agenda->myactions->read)) {
if (!$user->hasRight('agenda', 'myactions', 'read')) {
accessforbidden();
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$canedit = 0;
}
if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}

View file

@ -85,13 +85,13 @@ if ($socid < 0) {
}
$canedit = 1;
if (empty($user->rights->agenda->myactions->read)) {
if (!$user->hasRight('agenda', 'myactions', 'read')) {
accessforbidden();
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$canedit = 0;
}
if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}

View file

@ -105,7 +105,7 @@ class box_actions extends ModeleBoxes
if ($user->socid) {
$sql .= " AND s.rowid = ".((int) $user->socid);
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")";
}
$sql .= " ORDER BY a.datep ASC";

View file

@ -107,7 +107,7 @@ class box_actions_future extends ModeleBoxes
if ($user->socid) {
$sql .= " AND s.rowid = ".((int) $user->socid);
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")";
}
$sql .= " AND a.datep > '".$this->db->idate($now)."'";

View file

@ -480,7 +480,7 @@ class modAgenda extends DolibarrModules
if (empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
}
$this->export_sql_order[$r] = ' ORDER BY ac.datep';

View file

@ -402,7 +402,7 @@ class modEventOrganization extends DolibarrModules
if (empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
}
if (empty($user->rights->agenda->allactions->read)) {
if (!$user->hasRight('agenda', 'allactions', 'read')) {
$this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
}
$this->export_sql_order[$r] = ' ORDER BY ac.datep';