2
0
forked from Wavyzz/dolibarr

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

@@ -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<!-- 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';
$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 = "<!-- Box ".get_class($this)." from cache -->";
$out.= dol_readcachefile($cachedir, $filename);
}
if ($nooutput) return $out;
else print $out;
return '';
}
}