Merge pull request #9057 from inoveaconseil/checkRightOnLink

ADD Check right on link
This commit is contained in:
Laurent Destailleur 2018-07-16 09:31:21 +02:00 committed by GitHub
commit 387abf2da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 6 deletions

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -1220,6 +1221,9 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id))
$option = 'nolink';
$label = $this->label; $label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility if (empty($label)) $label=$this->libelle; // For backward compatibility
@ -1286,6 +1290,10 @@ class ActionComm extends CommonObject
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($option == 'nolink') {
$linkstart = '';
$linkend = '';
}
//print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto; //print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto;
if ($withpicto == 2) if ($withpicto == 2)

View File

@ -3422,6 +3422,9 @@ class Commande extends CommonOrder
if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
if (!$user->rights->commande->lire)
$option = 'nolink';
if ($option !== 'nolink') if ($option !== 'nolink')
{ {
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
@ -3465,6 +3468,11 @@ class Commande extends CommonOrder
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($option == 'nolink') {
$linkstart = '';
$linkend = '';
}
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref; if ($withpicto != 2) $result.= $this->ref;

View File

@ -1301,13 +1301,17 @@ class Account extends CommonObject
*/ */
function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0) function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0)
{ {
global $conf, $langs; global $conf, $langs, $user;
$result=''; $result='';
$label = '<u>' . $langs->trans("ShowAccount") . '</u>'; $label = '<u>' . $langs->trans("ShowAccount") . '</u>';
$label .= '<br><b>' . $langs->trans('BankAccount') . ':</b> ' . $this->label; $label .= '<br><b>' . $langs->trans('BankAccount') . ':</b> ' . $this->label;
$label .= '<br><b>' . $langs->trans('AccountNumber') . ':</b> ' . $this->number; $label .= '<br><b>' . $langs->trans('AccountNumber') . ':</b> ' . $this->number;
$label .= '<br><b>' . $langs->trans("AccountCurrency") . ':</b> ' . $this->currency_code; $label .= '<br><b>' . $langs->trans("AccountCurrency") . ':</b> ' . $this->currency_code;
if (!$user->rights->accounting->read || !empty($user->socid))
$option = 'nolink';
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -1338,6 +1342,11 @@ class Account extends CommonObject
$linkstart = '<a href="'.$url.$linkclose; $linkstart = '<a href="'.$url.$linkclose;
$linkend = '</a>'; $linkend = '</a>';
if ($option == 'nolink') {
$linkstart = '';
$linkend = '';
}
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); if ($withpicto != 2) $result.= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');

View File

@ -1159,7 +1159,8 @@ class Facture extends CommonInvoice
if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id;
else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id;
if ($short) return $url; if (!$user->rights->facture->lire)
$option = 'nolink';
if ($option !== 'nolink') if ($option !== 'nolink')
{ {
@ -1214,6 +1215,11 @@ class Facture extends CommonInvoice
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($option == 'nolink') {
$linkstart = '';
$linkend = '';
}
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref); if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref);

View File

@ -2158,10 +2158,12 @@ class User extends CommonObject
*/ */
function getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='', $save_lastsearch_value=-1) function getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='', $save_lastsearch_value=-1)
{ {
global $langs, $conf, $db, $hookmanager; global $langs, $conf, $db, $hookmanager, $user;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if(!$user->rights->user->user->lire && $user->id !=$this->id) $option='nolink';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
$result=''; $label=''; $result=''; $label='';
@ -2293,19 +2295,28 @@ class User extends CommonObject
*/ */
function getLoginUrl($withpicto=0,$option='') function getLoginUrl($withpicto=0,$option='')
{ {
global $langs; global $langs, $user;
$result=''; $result='';
$linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
$linkend='</a>'; $linkend='</a>';
//Check user's rights to see an other user
if((!$user->rights->user->user->lire && $this->id !=$user->id)) $option='nolink';
if ($option == 'xxx') if ($option == 'xxx')
{ {
$linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
$linkend='</a>'; $linkend='</a>';
} }
if ($option == 'nolink')
{
$linkstart = '';
$linkend='';
}
$result.=$linkstart; $result.=$linkstart;
if ($withpicto) $result.=img_object($langs->trans("ShowUser"), 'user', 'class="paddingright"'); if ($withpicto) $result.=img_object($langs->trans("ShowUser"), 'user', 'class="paddingright"');
$result.=$this->login; $result.=$this->login;