diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php
index 973738fec11..096786c0ffa 100644
--- a/htdocs/core/boxes/box_actions.php
+++ b/htdocs/core/boxes/box_actions.php
@@ -44,6 +44,21 @@ class box_actions extends ModeleBoxes
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
*
@@ -173,8 +188,8 @@ class box_actions extends ModeleBoxes
function showBox($head = null, $contents = null, $nooutput=0)
{
global $langs, $conf;
- parent::showBox($this->info_box_head, $this->info_box_contents);
- $out='';
+ $out = parent::showBox($this->info_box_head, $this->info_box_contents);
+
if (! empty($conf->global->SHOW_DIALOG_HOMEPAGE))
{
$actioncejour=false;
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 34666507488..a7d54f3554a 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -51,11 +51,17 @@ class box_activity extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $conf, $user;
$this->db=$db;
+
// 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
- 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';
$propalstatic=new Propal($db);
@@ -456,10 +462,10 @@ class box_activity extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php
index e99a0b30387..92a2313d8e4 100644
--- a/htdocs/core/boxes/box_bookmarks.php
+++ b/htdocs/core/boxes/box_bookmarks.php
@@ -40,6 +40,21 @@ class box_bookmarks extends ModeleBoxes
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
*
@@ -136,11 +151,11 @@ class box_bookmarks extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php
index 307dcc7cbfd..e6cd2ede39e 100644
--- a/htdocs/core/boxes/box_clients.php
+++ b/htdocs/core/boxes/box_clients.php
@@ -58,6 +58,8 @@ class box_clients extends ModeleBoxes
// disable box for such cases
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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php
index 7653206333d..c8b2b30fbad 100644
--- a/htdocs/core/boxes/box_commandes.php
+++ b/htdocs/core/boxes/box_commandes.php
@@ -44,6 +44,21 @@ class box_commandes extends ModeleBoxes
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
*
@@ -177,11 +192,11 @@ class box_commandes extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php
index a1c3625e78c..245a15e946c 100644
--- a/htdocs/core/boxes/box_comptes.php
+++ b/htdocs/core/boxes/box_comptes.php
@@ -61,6 +61,8 @@ class box_comptes extends ModeleBoxes
// disable module for such cases
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index 45963af9bb1..068d378ac5e 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -45,6 +45,21 @@ class box_contacts extends ModeleBoxes
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.
*
@@ -164,11 +179,11 @@ class box_contacts extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php
index fe864e1df16..747368d6112 100644
--- a/htdocs/core/boxes/box_contracts.php
+++ b/htdocs/core/boxes/box_contracts.php
@@ -43,6 +43,21 @@ class box_contracts extends ModeleBoxes
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
*
@@ -160,11 +175,11 @@ class box_contracts extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php
index dbe71a6ca41..0e49caf9381 100644
--- a/htdocs/core/boxes/box_external_rss.php
+++ b/htdocs/core/boxes/box_external_rss.php
@@ -185,11 +185,11 @@ class box_external_rss extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php
index 22a90929a0b..aadf5ab13ba 100644
--- a/htdocs/core/boxes/box_factures.php
+++ b/htdocs/core/boxes/box_factures.php
@@ -42,6 +42,21 @@ class box_factures extends ModeleBoxes
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.
*
@@ -181,11 +196,11 @@ class box_factures extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php
index b43d9cfc47b..383a6115b29 100644
--- a/htdocs/core/boxes/box_factures_fourn.php
+++ b/htdocs/core/boxes/box_factures_fourn.php
@@ -43,6 +43,21 @@ class box_factures_fourn extends ModeleBoxes
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.
*
@@ -190,11 +205,11 @@ class box_factures_fourn extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index 0d6bc28f077..4c56fc9cc93 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -42,6 +42,21 @@ class box_factures_fourn_imp extends ModeleBoxes
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.
*
@@ -181,11 +196,11 @@ class box_factures_fourn_imp extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php
index d3336500263..ccb7f5c91eb 100644
--- a/htdocs/core/boxes/box_factures_imp.php
+++ b/htdocs/core/boxes/box_factures_imp.php
@@ -45,6 +45,21 @@ class box_factures_imp extends ModeleBoxes
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.
*
@@ -184,11 +199,11 @@ class box_factures_imp extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php
index d57a2a991df..0a68c8173b4 100644
--- a/htdocs/core/boxes/box_ficheinter.php
+++ b/htdocs/core/boxes/box_ficheinter.php
@@ -43,6 +43,21 @@ class box_ficheinter extends ModeleBoxes
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
*
@@ -145,11 +160,11 @@ class box_ficheinter extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php
index ed3680af455..bac582a4534 100644
--- a/htdocs/core/boxes/box_fournisseurs.php
+++ b/htdocs/core/boxes/box_fournisseurs.php
@@ -43,6 +43,21 @@ class box_fournisseurs extends ModeleBoxes
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.
*
@@ -140,11 +155,11 @@ class box_fournisseurs extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php
index 552ed92b8a3..36d99ce7b9a 100644
--- a/htdocs/core/boxes/box_goodcustomers.php
+++ b/htdocs/core/boxes/box_goodcustomers.php
@@ -59,7 +59,9 @@ class box_goodcustomers extends ModeleBoxes
// disable box for such cases
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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php
index e4639070203..49bdc447fa1 100644
--- a/htdocs/core/boxes/box_graph_invoices_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_permonth.php
@@ -47,9 +47,11 @@ class box_graph_invoices_permonth extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user;
$this->db=$db;
+
+ $this->hidden = ! ($user->rights->facture->lire);
}
/**
@@ -133,7 +135,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
if (! $mesg)
{
$langs->load("bills");
-
+
$px1->SetData($data1);
unset($data1);
$px1->SetPrecisionY(0);
@@ -266,11 +268,11 @@ class box_graph_invoices_permonth extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
index 254195b42f1..8e822db8baf 100644
--- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
@@ -47,9 +47,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user;
$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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php
index 6b023b9c157..ac48ca6313e 100644
--- a/htdocs/core/boxes/box_graph_orders_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_permonth.php
@@ -47,9 +47,11 @@ class box_graph_orders_permonth extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user;
$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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
index 646f28e949c..63868c8dcee 100644
--- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
@@ -47,9 +47,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user;
$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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php
index 2b3c69a9e15..0623c9a0466 100644
--- a/htdocs/core/boxes/box_graph_product_distribution.php
+++ b/htdocs/core/boxes/box_graph_product_distribution.php
@@ -48,9 +48,15 @@ class box_graph_product_distribution extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user, $conf;
$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($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;
$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),...)
if ($showpropalnb)
@@ -250,7 +256,7 @@ class box_graph_product_distribution extends ModeleBoxes
if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
{
$langs->load("orders");
-
+
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showordernb)
{
@@ -334,7 +340,7 @@ class box_graph_product_distribution extends ModeleBoxes
$stringtoshow.=' '.$langs->trans("ForCustomersInvoices");
$stringtoshow.=' ';
}
- if (! empty($conf->propal->enabled) || ! empty($user->rights->propal->lire))
+ if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
{
$stringtoshow.=' '.$langs->trans("ForProposals");
$stringtoshow.=' ';
@@ -393,11 +399,11 @@ class box_graph_product_distribution extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php
index 39fe12ed7a3..00bcc0cd1e3 100644
--- a/htdocs/core/boxes/box_graph_propales_permonth.php
+++ b/htdocs/core/boxes/box_graph_propales_permonth.php
@@ -47,9 +47,11 @@ class box_graph_propales_permonth extends ModeleBoxes
*/
function __construct($db,$param)
{
- global $conf;
+ global $user;
$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->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_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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php
index afcbe8e68a6..b19c35ca8b3 100644
--- a/htdocs/core/boxes/box_members.php
+++ b/htdocs/core/boxes/box_members.php
@@ -60,6 +60,8 @@ class box_members extends ModeleBoxes
// disable module for such cases
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php
index 7ea5b8aec58..f1307e496f5 100644
--- a/htdocs/core/boxes/box_produits.php
+++ b/htdocs/core/boxes/box_produits.php
@@ -45,6 +45,21 @@ class box_produits extends ModeleBoxes
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.
*
@@ -202,11 +217,11 @@ class box_produits extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php
index 50a4abd320a..2fb58372db4 100644
--- a/htdocs/core/boxes/box_produits_alerte_stock.php
+++ b/htdocs/core/boxes/box_produits_alerte_stock.php
@@ -47,6 +47,21 @@ class box_produits_alerte_stock extends ModeleBoxes
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.
*
@@ -214,11 +229,11 @@ class box_produits_alerte_stock extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php
index a47ae3d0cb5..66fd386d226 100644
--- a/htdocs/core/boxes/box_project.php
+++ b/htdocs/core/boxes/box_project.php
@@ -48,12 +48,14 @@ class box_project extends ModeleBoxes
*/
function __construct($db,$param='')
{
- global $langs;
+ global $user, $langs;
$langs->load("boxes");
$langs->load("projects");
$this->db = $db;
$this->boxlabel="Projects";
+
+ $this->hidden=! ($user->rights->projet->lire);
}
/**
@@ -77,16 +79,16 @@ class box_project extends ModeleBoxes
// list the summary of the orders
if ($user->rights->projet->lire) {
-
+
include_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
$projectstatic = new Project($this->db);
-
+
$socid=$user->societe_id;
-
+
// Get list of project id allowed to user (in a string list separated by coma)
$projectsListId='';
if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid);
-
+
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc";
@@ -96,7 +98,7 @@ class box_project extends ModeleBoxes
$sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
-
+
$sql.= " ORDER BY p.datec DESC";
//$sql.= $db->plimit($max, 0);
@@ -156,7 +158,7 @@ class box_project extends ModeleBoxes
}
if ($max < $num)
{
- $this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...');
+ $this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...');
$i++;
}
}
@@ -195,11 +197,11 @@ class box_project extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php
index b0a1e4a3798..a505fa8e275 100644
--- a/htdocs/core/boxes/box_propales.php
+++ b/htdocs/core/boxes/box_propales.php
@@ -44,6 +44,21 @@ class box_propales extends ModeleBoxes
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.
*
@@ -167,11 +182,11 @@ class box_propales extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php
index 40adb98b405..098ea813e44 100644
--- a/htdocs/core/boxes/box_prospect.php
+++ b/htdocs/core/boxes/box_prospect.php
@@ -60,6 +60,8 @@ class box_prospect extends ModeleBoxes
// disable box for such cases
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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php
index 4d7759ff081..fd8346a3f0c 100644
--- a/htdocs/core/boxes/box_services_contracts.php
+++ b/htdocs/core/boxes/box_services_contracts.php
@@ -43,6 +43,21 @@ class box_services_contracts extends ModeleBoxes
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.
*
@@ -173,11 +188,11 @@ class box_services_contracts extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php
index 90f36ef6d30..42ac3750a11 100644
--- a/htdocs/core/boxes/box_services_expired.php
+++ b/htdocs/core/boxes/box_services_expired.php
@@ -42,6 +42,21 @@ class box_services_expired extends ModeleBoxes
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
*
@@ -84,7 +99,7 @@ class box_services_expired extends ModeleBoxes
$i = 0;
$thirdpartytmp = new Societe($this->db);
-
+
while ($i < $num)
{
$late='';
@@ -151,11 +166,11 @@ class box_services_expired extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php
index 1f0e1ece2ef..4f28a8ce62c 100644
--- a/htdocs/core/boxes/box_supplier_orders.php
+++ b/htdocs/core/boxes/box_supplier_orders.php
@@ -43,6 +43,21 @@ class box_supplier_orders extends ModeleBoxes
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.
*
@@ -172,11 +187,11 @@ class box_supplier_orders extends ModeleBoxes
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php
index 29dd9390597..e6224198ca5 100644
--- a/htdocs/core/boxes/box_task.php
+++ b/htdocs/core/boxes/box_task.php
@@ -42,6 +42,7 @@ class box_task extends ModeleBoxes
var $info_box_head = array();
var $info_box_contents = array();
+
/**
* Constructor
*
@@ -50,11 +51,13 @@ class box_task extends ModeleBoxes
*/
function __construct($db,$param='')
{
- global $langs;
+ global $user, $langs;
$langs->load("boxes");
$langs->load("projects");
$this->boxlabel="Tasks";
$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 $contents Array with properties of box lines
* @param int $nooutput No print, only return string
- * @return void
+ * @return string
*/
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);
}
}
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 566da25aad3..b1a27f1d77c 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -49,10 +49,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
public $max = 5;
/**
- * @var int Status
+ * @var int Condition to have widget enabled
*/
public $enabled=1;
+ /**
+ * @var int Condition to have widget visible (in most cases, permissions)
+ */
+ public $hidden=0;
+
/**
* @var int Box definition database ID
*/
@@ -168,29 +173,29 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
}
}
-
+
/**
* Standard method to get content of a box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
*
- * @return string
+ * @return string
*/
function outputBox($head = null, $contents = null)
{
global $langs, $user, $conf;
-
+
// Trick to get result into a var from a function that makes print instead of return
// TODO Replace ob_start with param nooutput=1 into showBox
ob_start();
$result = $this->showBox($head, $contents);
$output = ob_get_contents();
ob_end_clean();
-
+
return $output;
}
-
+
/**
* Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
*
@@ -203,6 +208,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
{
global $langs, $user, $conf;
+ if (! empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission)
+
require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
$MAXLENGTHBOX=60; // Mettre 0 pour pas de limite
@@ -365,13 +372,13 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
$out = "";
$out.= dol_readcachefile($cachedir, $filename);
}
-
+
if ($nooutput) return $out;
else print $out;
-
+
return '';
}
-
+
}
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 7e78f7bbe4d..cdf6dc79155 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -320,7 +320,7 @@ class FormOther
{
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
}
-
+
// Load list of "categories"
$static_categs = new Categorie($this->db);
$tab_categs = $static_categs->get_full_arbo($type);
@@ -621,12 +621,12 @@ class FormOther
$b = hexdec($hexb);
}
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
- if ($bright > 0.6) $textcolor='000';
+ if ($bright > 0.6) $textcolor='000';
}
-
+
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$color = colorArrayToHex(colorStringToArray($color,array()),'');
-
+
if ($color) print '';
else print $textifnotdefined;
}
@@ -989,7 +989,7 @@ class FormOther
* Class 'Form' must be known.
*
* @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'=>)
*/
static function getBoxesArea($user,$areacode)
@@ -1002,16 +1002,16 @@ class FormOther
// $boxactivated will be array of boxes enabled into global setup
// $boxidactivatedforuser will be array of boxes choosed by user
-
+
$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();
foreach($boxactivated as $box)
{
if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user
}
-
+
// Define selectboxlist
$arrayboxtoactivatelabel=array();
if (! empty($user->conf->$confuserzone))
diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php
index cd06eb587b7..41e131bba37 100644
--- a/htdocs/core/class/infobox.class.php
+++ b/htdocs/core/class/infobox.class.php
@@ -45,9 +45,10 @@ class InfoBox
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
* @param User|null $user Object user to filter
* @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
*/
- static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array())
+ static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
{
global $conf;
@@ -72,7 +73,7 @@ class InfoBox
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
$sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
}
-
+
dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
@@ -155,7 +156,7 @@ class InfoBox
//print '=>'.$boxname.'-enabled='.$enabled.'
';
//print 'xx module='.$module.' enabled='.$enabled;
- if ($enabled) $boxes[]=$box;
+ if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box;
else unset($box);
}
else