Fix test on permission for widgets

This commit is contained in:
Laurent Destailleur 2017-06-12 14:09:00 +02:00
parent ec24f223b5
commit bf41056c68
35 changed files with 410 additions and 110 deletions

View File

@ -44,6 +44,21 @@ class box_actions extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param='')
{
global $user;
$this->db = $db;
$this->hidden = ! ($user->rights->agenda->myactions->read);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -173,8 +188,8 @@ class box_actions extends ModeleBoxes
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
global $langs, $conf; global $langs, $conf;
parent::showBox($this->info_box_head, $this->info_box_contents); $out = parent::showBox($this->info_box_head, $this->info_box_contents);
$out='';
if (! empty($conf->global->SHOW_DIALOG_HOMEPAGE)) if (! empty($conf->global->SHOW_DIALOG_HOMEPAGE))
{ {
$actioncejour=false; $actioncejour=false;

View File

@ -51,11 +51,17 @@ class box_activity extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $conf, $user;
$this->db=$db; $this->db=$db;
// FIXME: Pb into some status // FIXME: Pb into some status
$this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments) $this->enabled=($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments)
$this->hidden= ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire)
|| (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|| (! empty($conf->propal->enabled) && $user->rights->propale->lire)
);
} }
/** /**
@ -352,7 +358,7 @@ class box_activity extends ModeleBoxes
} }
// list the summary of the propals // list the summary of the propals
if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
{ {
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic=new Propal($db); $propalstatic=new Propal($db);
@ -456,10 +462,10 @@ class box_activity extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -40,6 +40,21 @@ class box_bookmarks extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->bookmark->lire);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -136,11 +151,11 @@ class box_bookmarks extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -58,6 +58,8 @@ class box_clients extends ModeleBoxes
// disable box for such cases // disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option
$this->hidden = ! ($user->rights->societe->lire);
} }
/** /**
@ -158,11 +160,11 @@ class box_clients extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -44,6 +44,21 @@ class box_commandes extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->commande->lire);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -177,11 +192,11 @@ class box_commandes extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -61,6 +61,8 @@ class box_comptes extends ModeleBoxes
// disable module for such cases // disable module for such cases
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users
$this->hidden = ! ($user->rights->banque->lire);
} }
/** /**
@ -171,11 +173,11 @@ class box_comptes extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -45,6 +45,21 @@ class box_contacts extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->societe->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -164,11 +179,11 @@ class box_contacts extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_contracts extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->contrat->lire);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -160,11 +175,11 @@ class box_contracts extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -185,11 +185,11 @@ class box_external_rss extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -42,6 +42,21 @@ class box_factures extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->facture->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -181,11 +196,11 @@ class box_factures extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_factures_fourn extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->fournisseur->facture->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -190,11 +205,11 @@ class box_factures_fourn extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -42,6 +42,21 @@ class box_factures_fourn_imp extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->fournisseur->facture->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -181,11 +196,11 @@ class box_factures_fourn_imp extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -45,6 +45,21 @@ class box_factures_imp extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->facture->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -184,11 +199,11 @@ class box_factures_imp extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_ficheinter extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->ficheinter->lire);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -145,11 +160,11 @@ class box_ficheinter extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_fournisseurs extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->societe->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -140,11 +155,11 @@ class box_fournisseurs extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -60,6 +60,8 @@ class box_goodcustomers extends ModeleBoxes
// disable box for such cases // disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database
$this->hidden = ! ($user->rights->societe->lire);
} }
/** /**
@ -160,11 +162,11 @@ class box_goodcustomers extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,9 +47,11 @@ class box_graph_invoices_permonth extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user;
$this->db=$db; $this->db=$db;
$this->hidden = ! ($user->rights->facture->lire);
} }
/** /**
@ -266,11 +268,11 @@ class box_graph_invoices_permonth extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,9 +47,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user;
$this->db=$db; $this->db=$db;
$this->hidden = ! ($user->rights->fournisseur->facture->lire);
} }
/** /**
@ -263,11 +265,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,9 +47,11 @@ class box_graph_orders_permonth extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user;
$this->db=$db; $this->db=$db;
$this->hidden = ! ($user->rights->commande->lire);
} }
/** /**
@ -264,11 +266,11 @@ class box_graph_orders_permonth extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,9 +47,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user;
$this->db=$db; $this->db=$db;
$this->hidden = ! ($user->rights->fournisseur->commande->lire);
} }
/** /**
@ -263,11 +265,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -48,9 +48,15 @@ class box_graph_product_distribution extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user, $conf;
$this->db=$db; $this->db=$db;
$this->hidden = ! (
(! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
|| (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
|| (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
);
} }
/** /**
@ -93,7 +99,7 @@ class box_graph_product_distribution extends ModeleBoxes
} }
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0; if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
$nowarray=dol_getdate(dol_now(),true); $nowarray=dol_getdate(dol_now(),true);
@ -188,7 +194,7 @@ class box_graph_product_distribution extends ModeleBoxes
} }
} }
if (! empty($conf->propal->enabled) && ! empty($user->rights->propal->lire)) if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
{ {
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showpropalnb) if ($showpropalnb)
@ -334,7 +340,7 @@ class box_graph_product_distribution extends ModeleBoxes
$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices"); $stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
$stringtoshow.=' &nbsp; '; $stringtoshow.=' &nbsp; ';
} }
if (! empty($conf->propal->enabled) || ! empty($user->rights->propal->lire)) if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
{ {
$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals"); $stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
$stringtoshow.='&nbsp;'; $stringtoshow.='&nbsp;';
@ -393,11 +399,11 @@ class box_graph_product_distribution extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,9 +47,11 @@ class box_graph_propales_permonth extends ModeleBoxes
*/ */
function __construct($db,$param) function __construct($db,$param)
{ {
global $conf; global $user;
$this->db=$db; $this->db=$db;
$this->hidden=! ($user->rights->propale->lire);
} }
/** /**
@ -87,7 +89,7 @@ class box_graph_propales_permonth extends ModeleBoxes
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->propal->lire) if ($user->rights->propale->lire)
{ {
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
@ -265,11 +267,11 @@ class box_graph_propales_permonth extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -60,6 +60,8 @@ class box_members extends ModeleBoxes
// disable module for such cases // disable module for such cases
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users
$this->hidden=! ($user->rights->adherent->lire);
} }
/** /**
@ -170,11 +172,11 @@ class box_members extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -45,6 +45,21 @@ class box_produits extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->produit->lire || $user->rights->service->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -202,11 +217,11 @@ class box_produits extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -47,6 +47,21 @@ class box_produits_alerte_stock extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param='')
{
global $user;
$this->db = $db;
$this->hidden = ! (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -214,11 +229,11 @@ class box_produits_alerte_stock extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -48,12 +48,14 @@ class box_project extends ModeleBoxes
*/ */
function __construct($db,$param='') function __construct($db,$param='')
{ {
global $langs; global $user, $langs;
$langs->load("boxes"); $langs->load("boxes");
$langs->load("projects"); $langs->load("projects");
$this->db = $db; $this->db = $db;
$this->boxlabel="Projects"; $this->boxlabel="Projects";
$this->hidden=! ($user->rights->projet->lire);
} }
/** /**
@ -195,11 +197,11 @@ class box_project extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -44,6 +44,21 @@ class box_propales extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->propale->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -167,11 +182,11 @@ class box_propales extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -60,6 +60,8 @@ class box_prospect extends ModeleBoxes
// disable box for such cases // disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option
$this->hidden=! ($user->rights->societe->lire);
} }
/** /**
@ -168,11 +170,11 @@ class box_prospect extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_services_contracts extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -173,11 +188,11 @@ class box_services_contracts extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -42,6 +42,21 @@ class box_services_expired extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->contrat->lire);
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *
@ -151,11 +166,11 @@ class box_services_expired extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -43,6 +43,21 @@ class box_supplier_orders extends ModeleBoxes
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->fournisseur->commande->lire);
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *
@ -172,11 +187,11 @@ class box_supplier_orders extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -42,6 +42,7 @@ class box_task extends ModeleBoxes
var $info_box_head = array(); var $info_box_head = array();
var $info_box_contents = array(); var $info_box_contents = array();
/** /**
* Constructor * Constructor
* *
@ -50,11 +51,13 @@ class box_task extends ModeleBoxes
*/ */
function __construct($db,$param='') function __construct($db,$param='')
{ {
global $langs; global $user, $langs;
$langs->load("boxes"); $langs->load("boxes");
$langs->load("projects"); $langs->load("projects");
$this->boxlabel="Tasks"; $this->boxlabel="Tasks";
$this->db = $db; $this->db = $db;
$this->hidden = ! ($user->rights->projet->lire);
} }
/** /**
@ -138,10 +141,10 @@ class box_task extends ModeleBoxes
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return string
*/ */
function showBox($head = null, $contents = null, $nooutput=0) function showBox($head = null, $contents = null, $nooutput=0)
{ {
parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

View File

@ -49,10 +49,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
public $max = 5; public $max = 5;
/** /**
* @var int Status * @var int Condition to have widget enabled
*/ */
public $enabled=1; public $enabled=1;
/**
* @var int Condition to have widget visible (in most cases, permissions)
*/
public $hidden=0;
/** /**
* @var int Box definition database ID * @var int Box definition database ID
*/ */
@ -203,6 +208,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
{ {
global $langs, $user, $conf; global $langs, $user, $conf;
if (! empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n'; // Nothing done if hidden (for example when user has no permission)
require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
$MAXLENGTHBOX=60; // Mettre 0 pour pas de limite $MAXLENGTHBOX=60; // Mettre 0 pour pas de limite

View File

@ -989,7 +989,7 @@ class FormOther
* Class 'Form' must be known. * Class 'Form' must be known.
* *
* @param User $user Object User * @param User $user Object User
* @param String $areacode Code of area for pages (0=value for Home page) * @param string $areacode Code of area for pages ('0'=value for Home page)
* @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>) * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>)
*/ */
static function getBoxesArea($user,$areacode) static function getBoxesArea($user,$areacode)
@ -1004,7 +1004,7 @@ class FormOther
// $boxidactivatedforuser will be array of boxes choosed by user // $boxidactivatedforuser will be array of boxes choosed by user
$selectboxlist=''; $selectboxlist='';
$boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup) $boxactivated=InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone)?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup)
$boxidactivatedforuser=array(); $boxidactivatedforuser=array();
foreach($boxactivated as $box) foreach($boxactivated as $box)

View File

@ -45,9 +45,10 @@ class InfoBox
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
* @param User|null $user Object user to filter * @param User|null $user Object user to filter
* @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude
* @param int $includehidden Include also hidden boxes
* @return array Array of boxes * @return array Array of boxes
*/ */
static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array()) static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
{ {
global $conf; global $conf;
@ -155,7 +156,7 @@ class InfoBox
//print '=>'.$boxname.'-enabled='.$enabled.'<br>'; //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
//print 'xx module='.$module.' enabled='.$enabled; //print 'xx module='.$module.' enabled='.$enabled;
if ($enabled) $boxes[]=$box; if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box;
else unset($box); else unset($box);
} }
else else