forked from Wavyzz/dolibarr
FIX Warning to grant permission must be visible only if one module add
some permissions
This commit is contained in:
@@ -75,15 +75,28 @@ if ($search_version) $param.='&search_version='.urlencode($search_version);
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (GETPOST('buttonreset'))
|
||||||
|
{
|
||||||
|
$search_keyword='';
|
||||||
|
$search_status='';
|
||||||
|
$search_nature='';
|
||||||
|
$search_version='';
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'set' && $user->admin)
|
if ($action == 'set' && $user->admin)
|
||||||
{
|
{
|
||||||
$result=activateModule($value);
|
$resarray = activateModule($value);
|
||||||
if ($result) setEventMessages($result, null, 'errors');
|
if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors');
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
//var_dump($resarray);exit;
|
||||||
|
if ($resarray['nbperms'] > 0)
|
||||||
{
|
{
|
||||||
$msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
|
$msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
|
||||||
setEventMessages($msg, null, 'warnings');
|
setEventMessages($msg, null, 'warnings');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
|
header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -96,14 +109,6 @@ if ($action == 'reset' && $user->admin)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('buttonreset'))
|
|
||||||
{
|
|
||||||
$search_keyword='';
|
|
||||||
$search_status='';
|
|
||||||
$search_nature='';
|
|
||||||
$search_version='';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -708,7 +708,7 @@ function purgeSessions($mysessionid)
|
|||||||
*
|
*
|
||||||
* @param string $value Name of module to activate
|
* @param string $value Name of module to activate
|
||||||
* @param int $withdeps Activate/Disable also all dependencies
|
* @param int $withdeps Activate/Disable also all dependencies
|
||||||
* @return string Error message or '';
|
* @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added);
|
||||||
*/
|
*/
|
||||||
function activateModule($value,$withdeps=1)
|
function activateModule($value,$withdeps=1)
|
||||||
{
|
{
|
||||||
@@ -717,7 +717,7 @@ function activateModule($value,$withdeps=1)
|
|||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($value)) return 'ErrorBadParameter';
|
if (empty($value)) return 'ErrorBadParameter';
|
||||||
|
|
||||||
$ret='';
|
$ret=array('nbmodules'=>0, 'errors'=>array(), 'nbperms'=>0);
|
||||||
$modName = $value;
|
$modName = $value;
|
||||||
$modFile = $modName . ".class.php";
|
$modFile = $modName . ".class.php";
|
||||||
|
|
||||||
@@ -761,14 +761,17 @@ function activateModule($value,$withdeps=1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result=$objMod->init();
|
$result=$objMod->init();
|
||||||
if ($result <= 0) $ret=$objMod->error;
|
if ($result <= 0)
|
||||||
|
{
|
||||||
if (! $ret && $withdeps)
|
$ret['errors'][]=$objMod->error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($withdeps)
|
||||||
{
|
{
|
||||||
if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
|
if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
|
||||||
{
|
{
|
||||||
// Activation des modules dont le module depend
|
// Activation des modules dont le module depend
|
||||||
$TError=array();
|
|
||||||
$num = count($objMod->depends);
|
$num = count($objMod->depends);
|
||||||
for ($i = 0; $i < $num; $i++)
|
for ($i = 0; $i < $num; $i++)
|
||||||
{
|
{
|
||||||
@@ -777,15 +780,22 @@ function activateModule($value,$withdeps=1)
|
|||||||
{
|
{
|
||||||
if (file_exists($dir.$objMod->depends[$i].".class.php"))
|
if (file_exists($dir.$objMod->depends[$i].".class.php"))
|
||||||
{
|
{
|
||||||
activateModule($objMod->depends[$i]);
|
$resarray = activateModule($objMod->depends[$i]);
|
||||||
$activate = true;
|
if (empty($resarray['errors'])) $activate = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$activate) $TError[] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
|
if ($activate)
|
||||||
|
{
|
||||||
|
$ret['nbmodules']+=$resarray['nbmodules'];
|
||||||
|
$ret['nbperms']+=$resarray['nbperms'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setEventMessages('', $TError, 'errors');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))
|
if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))
|
||||||
@@ -804,6 +814,13 @@ function activateModule($value,$withdeps=1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! count($ret['errors']))
|
||||||
|
{
|
||||||
|
$ret['nbmodules']++;
|
||||||
|
$ret['nbperms']+=count($objMod->rights);
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
|
|||||||
$res=dol_include_once("/core/modules/".$file);
|
$res=dol_include_once("/core/modules/".$file);
|
||||||
|
|
||||||
$res=activateModule($modtoactivatenew,1);
|
$res=activateModule($modtoactivatenew,1);
|
||||||
if (! $result) print 'ERROR in activating module file='.$file;
|
if (! empty($res['errors'])) print 'ERROR in activating module file='.$file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1625,5 +1625,5 @@ activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is miss
|
|||||||
CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter <strong>$dolibarr_main_restrict_os_commands</strong> into <strong>conf.php</strong> file.
|
CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter <strong>$dolibarr_main_restrict_os_commands</strong> into <strong>conf.php</strong> file.
|
||||||
LandingPage=Landing page
|
LandingPage=Landing page
|
||||||
SamePriceAlsoForSharedCompanies=If you use the multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments
|
SamePriceAlsoForSharedCompanies=If you use the multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments
|
||||||
ModuleEnabledAdminMustCheckRights=Module has been activated. All permissions were given to admin users only.
|
ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users manually if necessary.
|
||||||
UserHasNoPermissions=This user has no permission defined
|
UserHasNoPermissions=This user has no permission defined
|
||||||
|
|||||||
Reference in New Issue
Block a user