Fix: avoid warning on permission if there is only admin users

This commit is contained in:
Laurent Destailleur 2017-06-24 22:13:00 +02:00
parent bd4f91d7eb
commit 778e581aca

View File

@ -206,11 +206,22 @@ if ($action == 'set' && $user->admin)
{ {
//var_dump($resarray);exit; //var_dump($resarray);exit;
if ($resarray['nbperms'] > 0) if ($resarray['nbperms'] > 0)
{
$tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
$resqltmp=$db->query($tmpsql);
if ($resqltmp)
{
$obj=$db->fetch_object($resqltmp);
//var_dump($obj->nb);exit;
if ($obj && $obj->nb > 1)
{ {
$msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
setEventMessages($msg, null, 'warnings'); setEventMessages($msg, null, 'warnings');
} }
} }
else dol_print_error($db);
}
}
header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
exit; exit;
} }