--- /tmp/dsg/dolibarr/htdocs/user/group/github_19.0.3_card.php
+++ /tmp/dsg/dolibarr/htdocs/user/group/client_card.php
@@ -3,5 +3,5 @@
- * Copyright (C) 2005-2021	Laurent Destailleur		<eldy@users.sourceforge.net>

- * Copyright (C) 2005-2017	Regis Houssin			<regis.houssin@inodbox.com>

- * Copyright (C) 2011		Herve Prot				<herve.prot@symeos.com>

- * Copyright (C) 2012		Florian Henry			<florian.henry@open-concept.pro>

- * Copyright (C) 2018		Juanjo Menent			<jmenent@2byte.es>

+ * Copyright (C) 2005-2015	Laurent Destailleur	<eldy@users.sourceforge.net>

+ * Copyright (C) 2005-2017	Regis Houssin		<regis.houssin@inodbox.com>

+ * Copyright (C) 2011		Herve Prot			<herve.prot@symeos.com>

+ * Copyright (C) 2012		Florian Henry		<florian.henry@open-concept.pro>

+ * Copyright (C) 2018		Juanjo Menent		<jmenent@2byte.es>

@@ -25 +25 @@
- *       \brief      Tab of a user group

+ *       \brief      Onglet groupes utilisateurs

@@ -28 +27,0 @@
-// Load Dolibarr environment

@@ -35,4 +34,4 @@
-// Define if user can read permissions

-$canreadperms = ($user->admin || $user->hasRight("user", "user", "read"));

-$caneditperms = ($user->admin || $user->hasRight("user", "user", "write"));

-$candisableperms = ($user->admin || $user->hasRight("user", "user", "delete"));

+// Defini si peux lire/modifier utilisateurs et permisssions

+$canreadperms = ($user->admin || $user->rights->user->user->lire);

+$caneditperms = ($user->admin || $user->rights->user->user->creer);

+$candisableperms = ($user->admin || $user->rights->user->user->supprimer);

@@ -42,7 +41,6 @@
-$advancedpermsactive = false;

-if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-	$advancedpermsactive = true;

-	$canreadperms = ($user->admin || ($user->hasRight("user", "group_advance", "read") && $user->hasRight("user", "group_advance", "readperms")));

-	$caneditperms = ($user->admin || $user->hasRight("user", "group_advance", "write"));

-	$candisableperms = ($user->admin || $user->hasRight("user", "group_advance", "delete"));

-	$feature2 = 'group_advance';

+if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))

+{

+    $canreadperms = ($user->admin || $user->rights->user->group_advance->read);

+    $caneditperms = ($user->admin || $user->rights->user->group_advance->write);

+    $candisableperms = ($user->admin || $user->rights->user->group_advance->delete);

+    $feature2 = 'group_advance';

@@ -55 +53 @@
-$action = GETPOST('action', 'aZ09');

+$action = GETPOST('action', 'alpha');

@@ -58 +56 @@
-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search

+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search

@@ -63 +61,10 @@
-$object = new UserGroup($db);

+// Security check

+$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2);

+

+// Users/Groups management only in master entity if transverse mode

+if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)

+{

+    accessforbidden();

+}

+

+$object = new Usergroup($db);

@@ -75,7 +81,0 @@
-// Security check

-$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2);

-

-// Users/Groups management only in master entity if transverse mode

-if (isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {

-	accessforbidden();

-}

@@ -90,3 +90 @@
-if ($reshook < 0) {

-	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-}

+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

@@ -99,9 +97,7 @@
-			if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {

-				$backtopage = $backurlforlist;

-			} else {

-				$backtopage = DOL_URL_ROOT.'/user/group/card.php?id='.($id > 0 ? $id : '__ID__');

-			}

-		}

-	}

-

-	if ($cancel) {

+			if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;

+			else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__');

+		}

+	}

+

+	if ($cancel)

+	{

@@ -113,2 +109,4 @@
-	if ($action == 'confirm_delete' && $confirm == "yes") {

-		if ($caneditperms) {

+	if ($action == 'confirm_delete' && $confirm == "yes")

+	{

+		if ($caneditperms)

+		{

@@ -119 +117,3 @@
-		} else {

+		}

+		else

+		{

@@ -126,3 +126,5 @@
-	if ($action == 'add') {

-		if ($caneditperms) {

-			if (!GETPOST("nom", "alphanohtml")) {

+	if ($action == 'add')

+	{

+		if ($caneditperms)

+		{

+			if (! GETPOST("nom", "nohtml")) {

@@ -132,2 +134,3 @@
-				$object->name	= GETPOST("nom", 'alphanohtml');

-				$object->note	= dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));

+				$object->name	= trim(GETPOST("nom", 'nohtml'));

+				//$object->nom = $object->name; // For backward compatibility

+				$object->note	= dol_htmlcleanlastbr(trim(GETPOST("note", 'none')));

@@ -137,13 +140,4 @@
-				if ($ret < 0) {

-					$error++;

-				}

-

-				if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {

-					$object->entity = 0;

-				} else {

-					if ($conf->entity == 1 && $user->admin && !$user->entity) {		// Same permissions test than the one used to show the combo of entities into the form

-						$object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity;

-					} else {

-						$object->entity = $conf->entity;

-					}

-				}

+				if ($ret < 0) $error++;

+

+				if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;

+				else $object->entity = $_POST["entity"];

@@ -155 +149,2 @@
-				if ($id > 0) {

+				if ($id > 0)

+				{

@@ -160 +155,3 @@
-				} else {

+				}

+				else

+				{

@@ -168 +165,3 @@
-		} else {

+		}

+		else

+		{

@@ -175,3 +174,6 @@
-	if ($action == 'adduser' || $action == 'removeuser') {

-		if ($caneditperms) {

-			if ($userid > 0) {

+	if ($action == 'adduser' || $action == 'removeuser')

+	{

+		if ($caneditperms)

+		{

+			if ($userid > 0)

+			{

@@ -183,8 +185,5 @@
-				if ($action == 'adduser') {

-					$result = $edituser->SetInGroup($object->id, $object->entity);

-				}

-				if ($action == 'removeuser') {

-					$result = $edituser->RemoveFromGroup($object->id, $object->entity);

-				}

-

-				if ($result > 0) {

+				if ($action == 'adduser')    $result = $edituser->SetInGroup($object->id, $object->entity);

+				if ($action == 'removeuser') $result = $edituser->RemoveFromGroup($object->id, $object->entity);

+

+				if ($result > 0)

+				{

@@ -193 +192,3 @@
-				} else {

+				}

+				else

+				{

@@ -197 +198,3 @@
-		} else {

+		}

+		else

+		{

@@ -204,2 +207,4 @@
-	if ($action == 'update') {

-		if ($caneditperms) {

+	if ($action == 'update')

+	{

+		if ($caneditperms)

+		{

@@ -212,3 +217,3 @@
-			$object->name = GETPOST("nom", 'alphanohtml');

-			$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));

-			$object->tms = dol_now();

+			$object->name	= trim(GETPOST("nom", 'nohtml'));

+			//$object->nom = $object->name; // For backward compatibility

+			$object->note	= dol_htmlcleanlastbr(trim(GETPOST("note", 'none')));

@@ -217,10 +222,5 @@
-			$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');

-			if ($ret < 0) {

-				$error++;

-			}

-

-			if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {

-				$object->entity = 0;

-			} elseif (GETPOSTISSET("entity")) {

-				$object->entity = GETPOST("entity", "int");

-			}

+			$ret = $extrafields->setOptionalsFromPost(null, $object);

+			if ($ret < 0) $error++;

+

+			if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;

+			else $object->entity = $_POST["entity"];

@@ -230 +230,2 @@
-			if ($ret >= 0 && !count($object->errors)) {

+			if ($ret >= 0 && !count($object->errors))

+			{

@@ -233 +234,3 @@
-			} else {

+			}

+			else

+			{

@@ -237 +240,3 @@
-		} else {

+		}

+		else

+		{

@@ -244,2 +249,2 @@
-	$upload_dir = $conf->user->dir_output.'/usergroups';

-	$permissiontoadd = $user->hasRight("user", "user", "write");

+	$upload_dir = $conf->usergroup->dir_output;

+	$permissiontoadd = $user->rights->user->user->creer;

@@ -254,7 +259 @@
-$title = $object->name.' - '.$langs->trans("Card");

-if ($action == 'create') {

-	$title = $langs->trans("NewGroup");

-}

-$help_url = "";

-llxHeader('', $title, $help_url);

-

+llxHeader('', $langs->trans("GroupCard"));

@@ -267,8 +266,9 @@
-if ($action == 'create') {

-	print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');

-

-	dol_set_focus('#nom');

-

-	print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';

-	print '<input type="hidden" name="token" value="'.newToken().'">';

-	print '<input type="hidden" name="action" value="add">';

+if ($action == 'create')

+{

+    print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');

+

+    print dol_set_focus('#nom');

+

+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';

+    print '<input type="hidden" name="token" value="'.newToken().'">';

+    print '<input type="hidden" name="action" value="add">';

@@ -277,3 +277,3 @@
-	print dol_get_fiche_head('', '', '', 0, '');

-

-	print '<table class="border centpercent tableforfieldcreate">';

+    dol_fiche_head('', '', '', 0, '');

+

+    print '<table class="border centpercent tableforfieldcreate">';

@@ -282,2 +282,4 @@
-	if (isModEnabled('multicompany') && is_object($mc)) {

-		if (!getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {

+	if (!empty($conf->multicompany->enabled) && is_object($mc))

+	{

+		if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)

+		{

@@ -287 +289,3 @@
-		} else {

+		}

+		else

+		{

@@ -300,18 +304,25 @@
-	print dol_get_fiche_end();

-

-	print '<div class="center">';

-	print '<input class="button" name="add" value="'.$langs->trans("CreateGroup").'" type="submit">';

-	print ' &nbsp; ';

-	print '<input class="button button-cancel" value="'.$langs->trans("Cancel").'" name="cancel" type="submit">';

-	print '</div>';

-

-	print "</form>";

-} else {

-	/* ************************************************************************** */

-	/*                                                                            */

-	/* Visu et edition                                                            */

-	/*                                                                            */

-	/* ************************************************************************** */

-	if ($id) {

-		$head = group_prepare_head($object);

-		$title = $langs->trans("Group");

+    dol_fiche_end();

+

+    print '<div class="center">';

+    print '<input class="button" name="add" value="'.$langs->trans("CreateGroup").'" type="submit">';

+    print ' &nbsp; ';

+    print '<input class="button" value="'.$langs->trans("Cancel").'" name="cancel" type="submit">';

+    print '</div>';

+

+    print "</form>";

+}

+

+

+/* ************************************************************************** */

+/*                                                                            */

+/* Visu et edition                                                            */

+/*                                                                            */

+/* ************************************************************************** */

+else

+{

+    if ($id)

+    {

+		$res = $object->fetch_optionals();

+

+        $head = group_prepare_head($object);

+        $title = $langs->trans("Group");

@@ -322 +333,2 @@
-		if ($action == 'delete') {

+		if ($action == 'delete')

+		{

@@ -330,2 +342,3 @@
-		if ($action != 'edit') {

-			print dol_get_fiche_head($head, 'group', $title, -1, 'group');

+		if ($action != 'edit')

+		{

+			dol_fiche_head($head, 'group', $title, -1, 'group');

@@ -335 +348 @@
-			dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin);

+			dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);

@@ -343,9 +356,11 @@
-			// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)

-			if (!empty($conf->mutlicompany->enabled)) {

-				print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

-				print '<td class="valeur">'.dol_escape_htmltag($object->name);

-				if (empty($object->entity)) {

-					print img_picto($langs->trans("GlobalGroup"), 'redstar');

-				}

-				print "</td></tr>\n";

-			}

+            // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)

+            if (!empty($conf->mutlicompany->enabled))

+            {

+    			print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

+    			print '<td class="valeur">'.dol_escape_htmltag($object->name);

+    			if (empty($object->entity))

+    			{

+    				print img_picto($langs->trans("GlobalGroup"), 'redstar');

+    			}

+    			print "</td></tr>\n";

+            }

@@ -354 +369,2 @@
-			if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {

+			if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)

+			{

@@ -376 +392 @@
-			print dol_get_fiche_end();

+			dol_fiche_end();

@@ -380 +396 @@
-			 * Action bar

+			 * Barre d'actions

@@ -381,0 +398 @@
+

@@ -386,10 +403,10 @@
-			if ($reshook < 0) {

-				setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-			}

-

-			if ($caneditperms) {

-				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';

-			}

-

-			if ($candisableperms) {

-				print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("DeleteGroup").'</a>';

+			if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

+

+			if ($caneditperms)

+			{

+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';

+			}

+

+			if ($candisableperms)

+			{

+				print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'">'.$langs->trans("DeleteGroup").'</a>';

@@ -400,9 +417,11 @@
-			// List users in group

-

-			print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', 'user');

-

-			// On selectionne les users qui ne sont pas deja dans le groupe

-			$exclude = array();

-

-			if (!empty($object->members)) {

-				foreach ($object->members as $useringroup) {

+            // List users in group

+

+            print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', 'user');

+

+            // On selectionne les users qui ne sont pas deja dans le groupe

+            $exclude = array();

+

+			if (!empty($object->members))

+			{

+				foreach ($object->members as $useringroup)

+				{

@@ -418,2 +437,4 @@
-			if (empty($reshook)) {

-				if ($caneditperms) {

+			if (empty($reshook))

+			{

+				if ($caneditperms)

+				{

@@ -423 +443,0 @@
-					print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table

@@ -427 +447 @@
-					print $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500');

+					print $form->select_dolusers('', 'user', 1, $exclude, 0, '', '', $object->entity, 0, 0, '', 0, '', 'maxwidth300');

@@ -430 +450 @@
-					print '<input type="submit" class="button buttongen button-add" value="'.$langs->trans("Add").'">';

+					print '<input type="submit" class="button buttongen" value="'.$langs->trans("Add").'">';

@@ -432,4 +452,2 @@
-					print '</table>';

-					print '</div>';

-					print '</form>'."\n";

-					//print '<br>';

+					print '</table></form>'."\n";

+					print '<br>';

@@ -442 +459,0 @@
-				print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table

@@ -452,4 +469,4 @@
-				$object->fetch($object->id, '', true);	// true to force load of all users, member of the group

-

-				if (!empty($object->members)) {

-					foreach ($object->members as $useringroup) {

+				if (!empty($object->members))

+				{

+					foreach ($object->members as $useringroup)

+					{

@@ -457 +474 @@
-						print '<td class="tdoverflowmax150">';

+						print '<td>';

@@ -459,5 +476,5 @@
-						if (isModEnabled('multicompany') && $useringroup->admin && empty($useringroup->entity)) {

-							print img_picto($langs->trans("SuperAdministratorDesc"), 'redstar');

-						} elseif ($useringroup->admin) {

-							print img_picto($langs->trans("AdministratorDesc"), 'star');

-						}

+						if ($useringroup->admin && !$useringroup->entity) {

+                            print img_picto($langs->trans("SuperAdministrator"), 'redstar');

+                        } elseif ($useringroup->admin) {

+                            print img_picto($langs->trans("Administrator"), 'star');

+                        }

@@ -470 +487 @@
-							print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removeuser&token='.newToken().'&user='.$useringroup->id.'">';

+							print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removeuser&amp;user='.$useringroup->id.'">';

@@ -473 +490,3 @@
-						} else {

+						}

+						else

+						{

@@ -478,2 +497,4 @@
-				} else {

-					print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';

+				}

+				else

+				{

+					print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';

@@ -482 +502,0 @@
-				print '</div>';

@@ -490,16 +510,16 @@
-			 * Generated documents

-			 */

-

-			$filename = dol_sanitizeFileName($object->ref);

-			$filedir = $conf->user->dir_output."/usergroups/".dol_sanitizeFileName($object->ref);

-			$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;

-			$genallowed = $user->hasRight("user", "user", "write");

-			$delallowed = $user->hasRight("user", "user", "delete");

-

-			$somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $mysoc->default_lang);

-

-			// Show links to link elements

-			$linktoelem = $form->showLinkToObjectBlock($object, null, null);

-			$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);

-

-			print '</div><div class="fichehalfright">';

+	         * Documents generes

+	         */

+

+	        $filename = dol_sanitizeFileName($object->ref);

+	        $filedir = $conf->usergroup->dir_output."/".dol_sanitizeFileName($object->ref);

+	        $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;

+	        $genallowed = $user->rights->user->user->creer;

+	        $delallowed = $user->rights->user->user->supprimer;

+

+	        $somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);

+

+	        // Show links to link elements

+	        $linktoelem = $form->showLinkToObjectBlock($object, null, null);

+	        $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);

+

+	        print '</div><div class="fichehalfright"><div class="ficheaddleft">';

@@ -512,11 +532,12 @@
-			print '</div></div>';

-		}

-

-		/*

-		 * Fiche en mode edition

-		 */

-

-		if ($action == 'edit' && $caneditperms) {

-			print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="updategroup" enctype="multipart/form-data">';

-			print '<input type="hidden" name="token" value="'.newToken().'">';

-			print '<input type="hidden" name="action" value="update">';

+	        print '</div></div></div>';

+        }

+

+        /*

+         * Fiche en mode edition

+         */

+

+        if ($action == 'edit' && $caneditperms)

+        {

+            print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="updategroup" enctype="multipart/form-data">';

+            print '<input type="hidden" name="token" value="'.newToken().'">';

+            print '<input type="hidden" name="action" value="update">';

@@ -526 +547 @@
-			print dol_get_fiche_head($head, 'group', $title, 0, 'group');

+            dol_fiche_head($head, 'group', $title, 0, 'group');

@@ -531,2 +552,4 @@
-			if (isModEnabled('multicompany') && is_object($mc)) {

-				if (!getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {

+			if (!empty($conf->multicompany->enabled) && is_object($mc))

+			{

+				if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)

+				{

@@ -536 +559,3 @@
-				} else {

+				}

+				else

+				{

@@ -549,7 +574,9 @@
-			print dol_get_fiche_end();

-

-			print $form->buttonsSaveCancel();

-

-			print '</form>';

-		}

-	}

+            dol_fiche_end();

+

+			print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';

+			print ' &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';

+			print '</div>';

+

+            print '</form>';

+        }

+    }

--- /tmp/dsg/dolibarr/htdocs/user/group/github_19.0.3_ldap.php
+++ /tmp/dsg/dolibarr/htdocs/user/group/client_ldap.php
@@ -26 +25,0 @@
-// Load Dolibarr environment

@@ -36,0 +36,12 @@
+// Users/Groups management only in master entity if transverse mode

+if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)

+{

+	accessforbidden();

+}

+

+$canreadperms = true;

+if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))

+{

+	$canreadperms = ($user->admin || $user->rights->user->group_advance->read);

+}

+

@@ -38 +49 @@
-$action = GETPOST('action', 'aZ09');

+$action = GETPOST('action', 'alpha');

@@ -41,6 +52,4 @@
-if ($user->socid > 0) {

-	$socid = $user->socid;

-}

-

-$object = new UserGroup($db);

-$object->fetch($id, '', true);

+if ($user->socid > 0) $socid = $user->socid;

+

+$object = new Usergroup($db);

+$object->fetch($id);

@@ -48,10 +56,0 @@
-

-// Users/Groups management only in master entity if transverse mode

-if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {

-	accessforbidden();

-}

-

-$canreadperms = true;

-if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-	$canreadperms = (!empty($user->admin) || !empty($user->rights->user->group_advance->read));

-}

@@ -64 +63,2 @@
-if ($action == 'dolibarr2ldap') {

+if ($action == 'dolibarr2ldap')

+{

@@ -68 +68,2 @@
-	if ($result > 0) {

+	if ($result > 0)

+	{

@@ -71,2 +72,2 @@
-		// Get a gid number for objectclass PosixGroup if none was provided

-		if (empty($info[getDolGlobalString('LDAP_GROUP_FIELD_GROUPID')]) && in_array('posixGroup', $info['objectclass'])) {

+		// Get a gid number for objectclass PosixGroup

+		if (in_array('posixGroup', $info['objectclass'])) {

@@ -82 +83,2 @@
-	if ($result >= 0) {

+	if ($result >= 0)

+	{

@@ -84 +86,3 @@
-	} else {

+	}

+	else

+	{

@@ -96,3 +100 @@
-$title = $object->name." - ".$langs->trans('LDAP');

-$help_url = '';

-llxHeader('', $title, $help_url);

+llxHeader();

@@ -102 +104 @@
-print dol_get_fiche_head($head, 'ldap', $langs->trans("Group"), -1, 'group');

+dol_fiche_head($head, 'ldap', $langs->trans("Group"), -1, 'group');

@@ -106 +108 @@
-dol_banner_tab($object, 'id', $linkback, ($user->hasRight('user', 'user', 'lire') || !empty($user->admin)));

+dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);

@@ -111 +113 @@
-print '<table class="border centpercent tableforfield">';

+print '<table class="border centpercent">';

@@ -114,7 +116,9 @@
-if (!empty($conf->mutlicompany->enabled)) {

-	print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

-	print '<td class="valeur">'.$object->name;

-	if (!$object->entity) {

-		print img_picto($langs->trans("GlobalGroup"), 'redstar');

-	}

-	print "</td></tr>\n";

+if (!empty($conf->mutlicompany->enabled))

+{

+    print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

+    print '<td class="valeur">'.$object->name;

+    if (!$object->entity)

+    {

+    	print img_picto($langs->trans("GlobalGroup"), 'redstar');

+    }

+    print "</td></tr>\n";

@@ -131 +135 @@
-print '<tr><td>LDAP '.$langs->trans("LDAPGroupDn").'</td><td class="valeur">'.getDolGlobalString('LDAP_GROUP_DN')."</td></tr>\n";

+print '<tr><td>LDAP '.$langs->trans("LDAPGroupDn").'</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";

@@ -134 +138 @@
-print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.getDolGlobalString('LDAP_KEY_GROUPS')."</td></tr>\n";

+print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_GROUPS."</td></tr>\n";

@@ -137,3 +141,3 @@
-print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.getDolGlobalString('LDAP_SERVER_HOST')."</td></tr>\n";

-print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.getDolGlobalString('LDAP_SERVER_HOST_SLAVE')."</td></tr>\n";

-print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.getDolGlobalString('LDAP_SERVER_PORT')."</td></tr>\n";

+print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";

+print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";

+print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";

@@ -145 +149 @@
-print dol_get_fiche_end();

+dol_fiche_end();

@@ -149,2 +153,3 @@
- * Action bar

- */

+ * Barre d'actions

+ */

+

@@ -153 +158,2 @@
-if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {

+if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')

+{

@@ -159,3 +165 @@
-if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {

-	print "<br>\n";

-}

+if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n";

@@ -178 +182,2 @@
-if ($result > 0) {

+if ($result > 0)

+{

@@ -188,4 +193,8 @@
-	if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {

-		if (!is_array($records)) {

-			print '<tr class="oddeven"><td colspan="2"><span class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</span></td></tr>';

-		} else {

+    if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0))

+	{

+		if (!is_array($records))

+		{

+			print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';

+		}

+		else

+		{

@@ -194,2 +203,4 @@
-	} else {

-		print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.dol_escape_htmltag($dn).' - search='.dol_escape_htmltag($search).')</td></tr>';

+	}

+	else

+	{

+		print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';

@@ -198 +209,4 @@
-} else {

+	$ldap->close();

+}

+else

+{

--- /tmp/dsg/dolibarr/htdocs/user/group/github_19.0.3_list.php
+++ /tmp/dsg/dolibarr/htdocs/user/group/client_list.php
@@ -6 +6 @@
- * Copyright (C) 2019-2021  Frédéric France         <frederic.france@netlogic.fr>

+ * Copyright (C) 2019       Frédéric France         <frederic.france@netlogic.fr>

@@ -28 +27,0 @@
-// Load Dolibarr environment

@@ -31,0 +31,12 @@
+if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))

+{

+	if (!$user->rights->user->group_advance->read && !$user->admin)

+		accessforbidden();

+}

+

+// Users/Groups management only in master entity if transverse mode

+if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)

+{

+	accessforbidden();

+}

+

@@ -33,14 +44,3 @@
-$langs->loadLangs(array("users"));

-

-$action     = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...

-$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)

-$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?

-$confirm    = GETPOST('confirm', 'alpha'); // Result of a confirmation

-$cancel     = GETPOST('cancel', 'alpha'); // We click on a Cancel button

-$toselect   = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list

-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search

-$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page

-$optioncss  = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')

-$mode       = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)

-

-$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));

+$langs->load("users");

+

+$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));

@@ -48 +48,9 @@
-$search = array();

+$optioncss = GETPOST('optioncss', 'alpha');

+

+// Defini si peux lire/modifier utilisateurs et permisssions

+$caneditperms = ($user->admin || $user->rights->user->user->creer);

+// Advanced permissions

+if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))

+{

+	$caneditperms = ($user->admin || $user->rights->user->group_advance->write);

+}

@@ -51,3 +59,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;

-$sortfield = GETPOST('sortfield', 'aZ09comma');

-$sortorder = GETPOST('sortorder', 'aZ09comma');

+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;

+$sortfield = GETPOST('sortfield', 'alpha');

+$sortorder = GETPOST('sortorder', 'alpha');

@@ -55,4 +63 @@
-if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

-	// If $page is not defined, or '' or -1 or if we click on clear filters

-	$page = 0;

-}

+if (empty($page) || $page == -1) { $page = 0; }

@@ -63,18 +68,2 @@
-// Initialize technical objects

-$object = new UserGroup($db);

-$extrafields = new ExtraFields($db);

-//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;

-$hookmanager->initHooks(array($contextpage)); 	// Note that conf->hooks_modules contains array of activated contexes

-

-// Fetch optionals attributes and labels

-$extrafields->fetch_name_optionals_label($object->table_element);

-//$extrafields->fetch_name_optionals_label($object->table_element_line);

-

-$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

-

-if (!$sortfield) {

-	$sortfield = "g.nom";

-}

-if (!$sortorder) {

-	$sortorder = "ASC";

-}

+if (!$sortfield) $sortfield = "g.nom";

+if (!$sortorder) $sortorder = "ASC";

@@ -83,29 +72,4 @@
-$fieldstosearchall = array();

-foreach ($object->fields as $key => $val) {

-	if (!empty($val['searchall'])) {

-		$fieldstosearchall['t.'.$key] = $val['label'];

-	}

-}

-

-if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-	if (!$user->hasRight("user", "group_advance", "read") && !$user->admin) {

-		accessforbidden();

-	}

-}

-

-// Users/Groups management only in master entity if transverse mode

-if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {

-	accessforbidden();

-}

-

-if (!$user->hasRight("user", "user", "read") && !$user->admin) {

-	accessforbidden();

-}

-

-// Defini si peux lire/modifier utilisateurs et permisssions

-$caneditperms = ($user->admin || $user->hasRight("user", "user", "write"));

-$permissiontodelete = ($user->admin || $user->hasRight("user", "user", "write"));

-// Advanced permissions

-if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-	$caneditperms = ($user->admin || $user->hasRight("user", "group_advance", "write"));

-}

+$fieldstosearchall = array(

+    'g.nom'=>"Group",

+    'g.note'=>"Note"

+);

@@ -118,7 +82,2 @@
-if (GETPOST('cancel', 'alpha')) {

-	$action = 'list';

-	$massaction = '';

-}

-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {

-	$massaction = '';

-}

+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }

+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }

@@ -127,32 +86,18 @@
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

-if ($reshook < 0) {

-	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-}

-

-if (empty($reshook)) {

-	// Selection of new fields

-	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';

-

-	// Purge search criteria

-	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers

-		foreach ($object->fields as $key => $val) {

-			$search[$key] = '';

-			if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {

-				$search[$key.'_dtstart'] = '';

-				$search[$key.'_dtend'] = '';

-			}

-		}

-		$toselect = array();

-		$search_array_options = array();

-	}

-	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')

-		|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {

-		$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation

-	}

-

-	// Mass actions

-	$objectclass = 'UserGroup';

-	$objectlabel = 'UserGroup';

-	$uploaddir = $conf->user->dir_output;

-	include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';

-}

+$reshook = $hookmanager->executeHooks('doActions', $parameters); // Note that $action and $object may have been modified by some hooks

+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

+

+if (empty($reshook))

+{

+    // Selection of new fields

+    include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';

+

+    // Purge search criteria

+    if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers

+    {

+        $search_label = "";

+        $search_date_creation = "";

+        $search_date_update = "";

+        $search_array_options = array();

+    }

+}

+

@@ -165,15 +110,3 @@
-$form = new Form($db);

-

-$now = dol_now();

-

-$title = $langs->trans("UserGroups");

-$help_url = '';

-$morejs = array();

-$morecss = array();

-

-// Build and execute select

-// --------------------------------------------------------------------

-$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";

-

-$sqlfields = $sql;

-

+llxHeader();

+

+$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";

@@ -183 +116,2 @@
-if (isModEnabled('multicompany') && $conf->entity == 1 && (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {

+if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity)))

+{

@@ -185 +119,3 @@
-} else {

+}

+else

+{

@@ -188,30 +124,3 @@
-if (!empty($search_group)) {

-	natural_search(array("g.nom", "g.note"), $search_group);

-}

-if ($search_all) {

-	$sql .= natural_search(array("g.nom", "g.note"), $search_all);

-}

-$sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";

-

-// Count total nb of records

-$nbtotalofrecords = '';

-if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {

-	/* The fast and low memory method to get and count full list converts the sql into a sql count */

-	$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);

-	$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);

-	$resql = $db->query($sqlforcount);

-	if ($resql) {

-		$objforcount = $db->fetch_object($resql);

-		$nbtotalofrecords = $objforcount->nbtotalofrecords;

-	} else {

-		dol_print_error($db);

-	}

-

-	if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller than paging size (filtering), goto and load page 0

-		$page = 0;

-		$offset = 0;

-	}

-	$db->free($resql);

-}

-

-// Complete request and execute it with limit

+if (!empty($search_group)) natural_search(array("g.nom", "g.note"), $search_group);

+if ($sall) $sql .= natural_search(array("g.nom", "g.note"), $sall);

+$sql .= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec";

@@ -221,324 +130,99 @@
-if (!$resql) {

-	dol_print_error($db);

-	exit;

-}

-

-$num = $db->num_rows($resql);

-

-$i = 0;

-

-

-// Output page

-// --------------------------------------------------------------------

-

-llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');

-

-$arrayofselected = is_array($toselect) ? $toselect : array();

-

-$param = "&search_group=".urlencode($search_group)."&search_all=".urlencode($search_all);

-if (!empty($mode)) {

-	$param .= '&mode='.urlencode($mode);

-}

-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {

-	$param .= '&contextpage='.urlencode($contextpage);

-}

-if ($limit > 0 && $limit != $conf->liste_limit) {

-	$param .= '&limit='.((int) $limit);

-}

-foreach ($search as $key => $val) {

-	if (is_array($search[$key])) {

-		foreach ($search[$key] as $skey) {

-			if ($skey != '') {

-				$param .= '&search_'.$key.'[]='.urlencode($skey);

-			}

-		}

-	} elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {

-		$param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));

-		$param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));

-		$param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));

-	} elseif ($search[$key] != '') {

-		$param .= '&search_'.$key.'='.urlencode($search[$key]);

-	}

-}

-if ($optioncss != '') {

-	$param .= '&optioncss='.urlencode($optioncss);

-}

-// Add $param from extra fields

-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';

-// Add $param from hooks

-$parameters = array('param' => &$param);

-$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

-$param .= $hookmanager->resPrint;

-

-// List of mass actions available

-$arrayofmassactions = array(

-	//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),

-	//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),

-	//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),

-	//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),

-);

-if (!empty($permissiontodelete)) {

-	$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");

-}

-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {

-	$arrayofmassactions = array();

-}

-$massactionbutton = $form->selectMassAction('', $arrayofmassactions);

-

-print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";

-if ($optioncss != '') {

-	print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';

-}

-print '<input type="hidden" name="token" value="'.newToken().'">';

-print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';

-print '<input type="hidden" name="action" value="list">';

-print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';

-print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';

-print '<input type="hidden" name="page" value="'.$page.'">';

-print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';

-print '<input type="hidden" name="page_y" value="">';

-print '<input type="hidden" name="mode" value="'.$mode.'">';

-

-$newcardbutton = '';

-$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));

-$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));

-

-if ($caneditperms) {

-	$newcardbutton .= dolGetButtonTitleSeparator();

-	$newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=');

-}

-

-print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);

-

-// Add code for pre mass action (confirmation or email presend form)

-$topicmail = "SendGroup";

-$modelmail = "group";

-$objecttmp = new UserGroup($db);

-$trackid = 'grp'.$object->id;

-include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

-

-if ($search_all) {

-	$setupstring = '';

-	foreach ($fieldstosearchall as $key => $val) {

-		$fieldstosearchall[$key] = $langs->trans($val);

-		$setupstring .= $key."=".$val.";";

-	}

-	print '<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";

-	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";

-}

-

-$moreforfilter = '';

-

-$parameters = array();

-$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

-if (empty($reshook)) {

-	$moreforfilter .= $hookmanager->resPrint;

-} else {

-	$moreforfilter = $hookmanager->resPrint;

-}

-

-if (!empty($moreforfilter)) {

-	print '<div class="liste_titre liste_titre_bydiv centpercent">';

-	print $moreforfilter;

-	$parameters = array();

-	$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

-	print $hookmanager->resPrint;

-	print '</div>';

-}

-

-$varpage=empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;

-$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields

-$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');

-

-print '<div class="div-table-responsive">';

-print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";

-

-// Fields title search

-// --------------------------------------------------------------------

-// ...

-

-$totalarray = array();

-$totalarray['nbfield'] = 0;

-

-// Fields title label

-// --------------------------------------------------------------------

-print '<tr class="liste_titre">';

-if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {

-	print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";

-	$totalarray['nbfield']++;

-}

-print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder);

-$totalarray['nbfield']++;

-//multicompany

-if (isModEnabled('multicompany') && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {

-	print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center ');

-	$totalarray['nbfield']++;

-}

-print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center ');

-$totalarray['nbfield']++;

-print_liste_field_titre("NbOfPermissions", $_SERVER["PHP_SELF"], "nbpermissions", $param, "", '', $sortfield, $sortorder, 'center ');

-$totalarray['nbfield']++;

-print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $param, "", '', $sortfield, $sortorder, 'center ');

-$totalarray['nbfield']++;

-print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "g.tms", $param, "", '', $sortfield, $sortorder, 'center ');

-$totalarray['nbfield']++;

-// Extra fields

-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';

-// Hook fields

-$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);

-$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

-print $hookmanager->resPrint;

-/*if (!empty($arrayfields['anotherfield']['checked'])) {

- print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';

- $totalarray['nbfield']++;

- }*/

-// Action column

-if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {

-	print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";

-	$totalarray['nbfield']++;

-}

-print '</tr>'."\n";

-

-

-// Loop on record

-// --------------------------------------------------------------------

-$i = 0;

-$savnbfield = $totalarray['nbfield'];

-$totalarray = array();

-$totalarray['nbfield'] = 0;

-$imaxinloop = ($limit ? min($num, $limit) : $num);

-while ($i < $imaxinloop) {

-	$obj = $db->fetch_object($resql);

-	if (empty($obj)) {

-		break; // Should not happen

-	}

-

-	// Store properties in $object

-	$object->setVarsFromFetchObj($obj);

-

-	$object->name = $obj->name;

-	$object->note = $obj->note;

-	$object->nb_rights = $obj->nbpermissions;

-	$object->nb_users = $obj->nb;

-

-	if ($mode == 'kanban') {

-		if ($i == 0) {

-			print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';

-			print '<div class="box-flex-container kanban">';

-		}

-		// Output Kanban

-		$selected = -1;

-		if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined

-			$selected = 0;

-			if (in_array($object->id, $arrayofselected)) {

-				$selected = 1;

-			}

-		}

-		print $object->getKanbanView('', array('selected' => $selected));

-		if ($i == ($imaxinloop - 1)) {

-			print '</div>';

-			print '</td></tr>';

-		}

-	} else {

-		// Show here line of result

-		$j = 0;

-		print '<tr data-rowid="'.$object->id.'" class="oddeven">';

-		// Action column

-		if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {

-			print '<td class="nowrap center">';

-			if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined

-				$selected = 0;

-				if (in_array($object->id, $arrayofselected)) {

-					$selected = 1;

-				}

-				print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';

-			}

-			print '</td>';

-			if (!$i) {

-				$totalarray['nbfield']++;

-			}

-		}

-

-		print '<td class="tdoverflowmax125">';

-		print $object->getNomUrl(1);

-		if (isModEnabled('multicompany') && !$obj->entity) {

-			print img_picto($langs->trans("GlobalGroup"), 'redstar');

-		}

-		print "</td>";

-		if (!$i) {

-			$totalarray['nbfield']++;

-		}

-		//multicompany

-		if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {

-			$mc->getInfo($obj->entity);

-			print '<td class="center">'.dol_escape_htmltag($mc->label).'</td>';

-			if (!$i) {

-				$totalarray['nbfield']++;

-			}

-		}

-		print '<td class="center">'.dol_escape_htmltag($obj->nb).'</td>';

-		if (!$i) {

-			$totalarray['nbfield']++;

-		}

-		print '<td class="center">';

-		print '<a href="'.DOL_URL_ROOT.'/user/group/perms.php?id='.$obj->rowid.'">'.dol_escape_htmltag($obj->nbpermissions).'</a>';

-		print '</td>';

-		if (!$i) {

-			$totalarray['nbfield']++;

-		}

-		print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), "dayhour").'</td>';

-		if (!$i) {

-			$totalarray['nbfield']++;

-		}

-		print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms), "dayhour").'</td>';

-		if (!$i) {

-			$totalarray['nbfield']++;

-		}

-		// Extra fields

-		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';

-		// Fields from hook

-		$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);

-		$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook

-		print $hookmanager->resPrint;

-		// Action column

-		if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {

-			print '<td class="nowrap center">';

-			if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined

-				$selected = 0;

-				if (in_array($object->id, $arrayofselected)) {

-					$selected = 1;

-				}

-				print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';

-			}

-			print '</td>';

-			if (!$i) {

-				$totalarray['nbfield']++;

-			}

-		}

-

-		print '</tr>'."\n";

-	}

-	$i++;

-}

-

-// Show total line

-include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';

-

-// If no record found

-if ($num == 0) {

-	/*$colspan = 1;

-	foreach ($arrayfields as $key => $val) {

-		if (!empty($val['checked'])) {

-			$colspan++;

-		}

-	}*/

-	$colspan = $savnbfield;

-	print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';

-}

-

-$db->free($resql);

-

-print '</table>'."\n";

-print '</div>'."\n";

-

-print '</form>'."\n";

+if ($resql)

+{

+    $num = $db->num_rows($resql);

+

+    $nbtotalofrecords = $num;

+

+    $i = 0;

+

+    $param = "&amp;search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall);

+    if ($optioncss != '') $param .= '&amp;optioncss='.$optioncss;

+

+    $text = $langs->trans("ListOfGroups");

+

+    $newcardbutton = '';

+    if ($caneditperms)

+    {

+        $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=');

+    }

+

+    print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";

+    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';

+    print '<input type="hidden" name="token" value="'.newToken().'">';

+    print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';

+    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';

+    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';

+    print '<input type="hidden" name="mode" value="'.$mode.'">';

+    print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';

+

+    print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'object_group', 0, $newcardbutton, '', $limit, 0, 0, 1);

+

+    if ($sall)

+    {

+        foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);

+        print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';

+    }

+

+    $moreforfilter = '';

+

+	//$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;

+	//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields

+

+    print '<div class="div-table-responsive">';

+    print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";

+

+    print '<tr class="liste_titre">';

+    print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder);

+    //multicompany

+    if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)

+    {

+    	print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], "g.entity", $param, "", '', $sortfield, $sortorder, 'center ');

+    }

+    print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center ');

+    print_liste_field_titre("NbOfPermissions", $_SERVER["PHP_SELF"], "nbpermissions", $param, "", '', $sortfield, $sortorder, 'center ');

+    print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $param, "", '', $sortfield, $sortorder, 'center ');

+    print_liste_field_titre("", $_SERVER["PHP_SELF"]);

+    print "</tr>\n";

+

+    $grouptemp = new UserGroup($db);

+

+    while ($i < $num)

+    {

+        $obj = $db->fetch_object($resql);

+

+        $grouptemp->id = $obj->rowid;

+        $grouptemp->name = $obj->name;

+        $grouptemp->note = $obj->note;

+

+        print '<tr class="oddeven">';

+        print '<td>';

+        print $grouptemp->getNomUrl(1);

+        if (!$obj->entity)

+        {

+        	print img_picto($langs->trans("GlobalGroup"), 'redstar');

+        }

+        print "</td>";

+        //multicompany

+        if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)

+        {

+            $mc->getInfo($obj->entity);

+            print '<td class="center">'.$mc->label.'</td>';

+        }

+        print '<td class="center">'.$obj->nb.'</td>';

+        print '<td class="center">'.$obj->nbpermissions.'</td>';

+        print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), "dayhour").'</td>';

+        print '<td></td>';

+        print "</tr>\n";

+        $i++;

+    }

+    print "</table>";

+

+    print '</div>';

+    print "</form>\n";

+

+    $db->free($resql);

+}

+else

+{

+    dol_print_error($db);

+}

--- /tmp/dsg/dolibarr/htdocs/user/group/github_19.0.3_perms.php
+++ /tmp/dsg/dolibarr/htdocs/user/group/client_perms.php
@@ -2,6 +2,5 @@
-/* Copyright (C) 2002-2005	Rodolphe Quiedeville	<rodolphe@quiedeville.org>

- * Copyright (C) 2002-2003	Jean-Louis Bergamo		<jlb@j1b.org>

- * Copyright (C) 2004-2020	Laurent Destailleur		<eldy@users.sourceforge.net>

- * Copyright (C) 2004		Eric Seigne				<eric.seigne@ryxeo.com>

- * Copyright (C) 2005-2017	Regis Houssin			<regis.houssin@inodbox.com>

- * Copyright (C) 2020		Tobias Sekan			<tobias.sekan@startmail.com>

+/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>

+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>

+ * Copyright (C) 2004-2020 Laurent Destailleur  <eldy@users.sourceforge.net>

+ * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>

+ * Copyright (C) 2005-2017 Regis Houssin        <regis.houssin@inodbox.com>

@@ -24,2 +23,2 @@
- *		\file		htdocs/user/group/perms.php

- * 		\brief		Page to set permissions of a user group record

+ *       \file       htdocs/user/group/perms.php

+ *       \brief      Onglet user et permissions de la fiche utilisateur

@@ -28,5 +26,0 @@
-if (!defined('CSRFCHECK_WITH_TOKEN')) {

-	define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET

-}

-

-// Load Dolibarr environment

@@ -43 +37 @@
-$action = GETPOST('action', 'aZ09');

+$action = GETPOST('action', 'alpha');

@@ -47,5 +41 @@
-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'groupperms'; // To manage different context of search

-

-if (!isset($id) || empty($id)) {

-	accessforbidden();

-}

+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupperms'; // To manage different context of search

@@ -54 +44 @@
-$canreadperms = ($user->admin || $user->hasRight("user", "user", "read"));

+$canreadperms = ($user->admin || $user->rights->user->user->lire);

@@ -56 +46 @@
-$caneditperms = ($user->admin || $user->hasRight("user", "user", "write"));

+$caneditperms = ($user->admin || $user->rights->user->user->creer);

@@ -59,4 +49,5 @@
-if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-	$advancedpermsactive = true;

-	$canreadperms = ($user->admin || ($user->hasRight("user", "group_advance", "read") && $user->hasRight("user", "group_advance", "readperms")));

-	$caneditperms = ($user->admin || $user->hasRight("user", "group_advance", "write"));

+if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))

+{

+    $advancedpermsactive = true;

+    $canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms));

+    $caneditperms = ($user->admin || $user->rights->user->group_advance->write);

@@ -65,7 +56,3 @@
-// Security check

-//$result = restrictedArea($user, 'user', $id, 'usergroup', '');

-if (!$canreadperms) {

-	accessforbidden();

-}

-

-$object = new UserGroup($db);

+if (!$canreadperms) accessforbidden();

+

+$object = new Usergroup($db);

@@ -73 +59,0 @@
-$object->getrights();

@@ -87,3 +73 @@
-if ($reshook < 0) {

-	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-}

+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

@@ -93,2 +77,2 @@
-		$editgroup = new UserGroup($db);

-		$result = $editgroup->fetch($object->id);

+		$editgroup = new Usergroup($db);

+		$result = $editgroup->fetch($id);

@@ -103,3 +86,0 @@
-

-		$user->clearrights();

-		$user->getrights();

@@ -109 +90 @@
-		$editgroup = new UserGroup($db);

+		$editgroup = new Usergroup($db);

@@ -119,3 +99,0 @@
-

-		$user->clearrights();

-		$user->getrights();

@@ -126 +104 @@
-/*

+/**

@@ -132,72 +110,4 @@
-$title = $object->name." - ".$langs->trans('Permissions');

-$help_url = '';

-llxHeader('', $title, $help_url);

-

-if ($object->id > 0) {

-	$head = group_prepare_head($object);

-	$title = $langs->trans("Group");

-	print dol_get_fiche_head($head, 'rights', $title, -1, 'group');

-

-	// Charge les modules soumis a permissions

-	$modules = array();

-	$modulesdir = dolGetModulesDirs();

-

-	$db->begin();

-

-	foreach ($modulesdir as $dir) {

-		$handle = @opendir(dol_osencode($dir));

-		if (is_resource($handle)) {

-			while (($file = readdir($handle)) !== false) {

-				if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {

-					$modName = substr($file, 0, dol_strlen($file) - 10);

-

-					if ($modName) {

-						include_once $dir.$file;

-						$objMod = new $modName($db);

-						// Load all lang files of module

-						if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {

-							foreach ($objMod->langfiles as $domain) {

-								$langs->load($domain);

-							}

-						}

-						// Load all permissions

-						if ($objMod->rights_class) {

-							$ret = $objMod->insert_permissions(0, $entity);

-							$modules[$objMod->rights_class] = $objMod;

-						}

-					}

-				}

-			}

-		}

-	}

-

-	$db->commit();

-

-	// Read permissions of group

-	$permsgroupbyentity = array();

-

-	$sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";

-	$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";

-	$sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";

-	$sql .= " WHERE gr.fk_id = r.id";

-	$sql .= " AND gr.entity = ".((int) $entity);

-	$sql .= " AND gr.fk_usergroup = ".((int) $object->id);

-

-	dol_syslog("get user perms", LOG_DEBUG);

-	$result = $db->query($sql);

-	if ($result) {

-		$num = $db->num_rows($result);

-		$i = 0;

-		while ($i < $num) {

-			$obj = $db->fetch_object($result);

-			if (!isset($permsgroupbyentity[$obj->entity])) {

-				$permsgroupbyentity[$obj->entity] = array();

-			}

-			array_push($permsgroupbyentity[$obj->entity], $obj->id);

-			$i++;

-		}

-		$db->free($result);

-	} else {

-		dol_print_error($db);

-	}

-

+llxHeader('', $langs->trans("Permissions"));

+

+if ($object->id > 0)

+{

@@ -205,337 +115,251 @@
-	 * Part to add/remove permissions

-	 */

-

-	$linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';

-

-	dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin);

-

-	print '<div class="fichecenter">';

-	print '<div class="fichehalfleft">';

-	print '<div class="underbanner clearboth"></div>';

-

-

-	print '<table class="border centpercent tableforfield">';

-

-	// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)

-	if (!empty($conf->mutlicompany->enabled)) {

-		print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

-		print '<td class="valeur">'.dol_escape_htmltag($object->name);

-		if (empty($object->entity)) {

-			print img_picto($langs->trans("GlobalGroup"), 'redstar');

-		}

-		print "</td></tr>\n";

-	}

-

-	// Multicompany

-	if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {

-		$mc->getInfo($object->entity);

-		print "<tr>".'<td class="titlefield">'.$langs->trans("Entity").'</td>';

-		print '<td class="valeur">'.dol_escape_htmltag($mc->label);

-		print "</td></tr>\n";

-	}

-

-	unset($object->fields['nom']); // Name already displayed in banner

-

-	// Common attributes

-	$keyforbreak = '';

-	include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';

-

-	// Other attributes

-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

-

-	print '</table>';

-	print '</div>';

-	print '</div>';

-

-	print '<div class="clearboth"></div>';

-

-	print '<br>';

-

-	if ($user->admin) {

-		print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));

-	}

-

-	$parameters = array();

-	$reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

-	if ($reshook < 0) {

-		setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-	}

-

-	print "\n";

-	print '<div class="div-table-responsive-no-min">';

-	print '<table class="noborder centpercent">';

-	print '<tr class="liste_titre">';

-	print '<td>'.$langs->trans("Module").'</td>';

-	if ($caneditperms) {

-		print '<td class="center nowrap">';

-		print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("All")."</a>";

-		print '/';

-		print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("None")."</a>";

-		print '</td>';

-	} else {

-		print '<td></td>';

-	}

-	print '<td class="center" width="24"></td>';

-	//print '<td>'.$langs->trans("Permissions").'</td>';

-	print '<td class="center"></td>';

-

-	print '<td class="right nowrap">';

-	print '<a class="showallperms" title="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("ExpandAll").'</span></a>';

-	print ' | ';

-	print '<a class="hideallperms" title="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" href="#">'.img_picto('', 'folder', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("UndoExpandAll").'</span></a>';

-	print '</td>';

-	print '</tr>'."\n";

-

-	$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";

-	$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";

-	$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"

-	$sql .= " AND r.entity = ".((int) $entity);

-	if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-		$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable

-	}

-	$sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";

-

-	$result = $db->query($sql);

-	if ($result) {

-		$num = $db->num_rows($result);

-		$i = 0;

-		$j = 0;

-		$oldmod = '';

-

-		$cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));

-		$cookietohidegrouparray = explode(',', $cookietohidegroup);

-

-		while ($i < $num) {

-			$obj = $db->fetch_object($result);

-

-			// If line is for a module that does not exist anymore (absent of includes/module), we ignore it

-			if (empty($modules[$obj->module])) {

-				$i++;

-				continue;

-			}

-

-			$objMod = $modules[$obj->module];

-

-			if (GETPOSTISSET('forbreakperms_'.$obj->module)) {

-				$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');

-			} elseif (in_array($j, $cookietohidegrouparray)) {	// If j is among list of hidden group

-				$ishidden = 1;

-			} else {

-				$ishidden = 0;

-			}

-			$isexpanded = ! $ishidden;

-

-			// Break found, it's a new module to catch

-			if (isset($obj->module) && ($oldmod != $obj->module)) {

-				$oldmod = $obj->module;

-

-				$j++;

-				if (GETPOSTISSET('forbreakperms_'.$obj->module)) {

-					$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');

-				} elseif (in_array($j, $cookietohidegrouparray)) {	// If j is among list of hidden group

-					$ishidden = 1;

-				} else {

-					$ishidden = 0;

-				}

-				$isexpanded = ! $ishidden;

-				// Break detected, we get objMod

-				$objMod = $modules[$obj->module];

-				$picto = ($objMod->picto ? $objMod->picto : 'generic');

-

-				// Show break line

-				print '<tr class="oddeven trforbreakperms" data-hide-perms="'.$obj->module.'" data-j="'.$j.'">';

-				// Picto and label of module

-				print '<td class="maxwidthonsmartphone tdoverflowonsmartphone tdforbreakperms" data-hide-perms="'.$obj->module.'">';

-				print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();

-				print '<a name="'.$objMod->getName().'"></a>';

-				print '</td>';

-				// Permission and tick (2 columns)

-				if ($caneditperms) {

-					print '<td class="center wraponsmartphone">';

-					print '<span class="permtohide_'.$obj->module.'" '.(!$isexpanded ? ' style="display:none"' : '').'>';

-					print '<a class="reposition alink addexpandedmodulesinparamlist" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All")."</a>";

-					print ' / ';

-					print '<a class="reposition alink addexpandedmodulesinparamlist" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")."</a>";

-					print '</span>';

-					print '</td>';

-					print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'">';

-					print '</td>';

-				} else {

-					print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';

-					print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';

-				}

-				// Description of permission (2 columns)

-				print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';

-				print '<td class="maxwidthonsmartphone right tdforbreakperms" data-hide-perms="'.$obj->module.'">';

-				print '<div class="switchfolderperms folderperms_'.$obj->module.'"'.($isexpanded ? ' style="display:none;"' : '').'>';

-				print img_picto('', 'folder', 'class="marginright"');

-				print '</div>';

-				print '<div class="switchfolderperms folderopenperms_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none;"' : '').'>';

-				print img_picto('', 'folder-open', 'class="marginright"');

-				print '</div>';

-				print '</td>'; //Add picto + / - when open en closed

-				print '</tr>'."\n";

-			}

-

-			print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";

-			print '<tr class="oddeven trtohide_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none"' : '').'>';

-

-

-			// Picto and label of module

-			print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';

-			print '<input type="hidden" name="forbreakperms_'.$obj->module.'" id="idforbreakperms_'.$obj->module.'" css="cssforfieldishiden" data-j="'.$j.'" value="'.($isexpanded ? '0' : "1").'">';

-			//print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();

-			print '</td>';

-

-			// Permission and tick (2 columns)

-			if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {

-				if (in_array($obj->id, $permsgroupbyentity[$entity])) {

-					// Own permission by group

-					if ($caneditperms) {

-						print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes">';

-						//print img_edit_remove($langs->trans("Remove"));

-						print img_picto($langs->trans("Remove"), 'switch_on');

-						print '</a></td>';

-					}

-					print '<td class="center nowrap">';

-					print img_picto($langs->trans("Active"), 'tick');

-					print '</td>';

-				} else {

-					// Do not own permission

-					if ($caneditperms) {

-						print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes">';

-						//print img_edit_add($langs->trans("Add"));

-						print img_picto($langs->trans("Add"), 'switch_off');

-						print '</a></td>';

-					}

-					print '<td>&nbsp;</td>';

-				}

-			} else {

-				// Do not own permission

-				if ($caneditperms) {

-					print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&token='.newToken().'">';

-					//print img_edit_add($langs->trans("Add"));

-					print img_picto($langs->trans("Add"), 'switch_off');

-					print '</a></td>';

-				} else {

-					print '<td>&nbsp;</td>';

-				}

-				print '<td>&nbsp;</td>';

-			}

-

-			// Description of permission (2 columns)

-			$permlabel = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($langs->trans("PermissionAdvanced".$obj->id) != "PermissionAdvanced".$obj->id) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != "Permission".$obj->id) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));

-			print '<td>';

-			print $permlabel;

-			if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {

-				if (preg_match('/_advance$/', $obj->perms)) {

-					print ' <span class="opacitymedium">('.$langs->trans("AdvancedModeOnly").')</span>';

-				}

-			}

-			print '</td>';

-

-			// Permission id

-			if ($user->admin) {

-				print '<td class="right">';

-				$htmltext = $langs->trans("ID").': '.$obj->id;

-				$htmltext .= '<br>'.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '');

-				print $form->textwithpicto('', $htmltext);

-				//print '<span class="opacitymedium">'.$obj->id.'</span>';

-				print '</td>';

-			} else {

-				print '<td>&nbsp;</td>';

-			}

-

-			print '</tr>'."\n";

-

-			$i++;

-		}

-	}

-	print '</table>';

-	print '</div>';

-

-	print '<script>';

-	print '$(".tdforbreakperms:not(.alink)").on("click", function(){

-		console.log("Click on tdforbreakperms");

-		moduletohide = $(this).data("hide-perms");

-		j = $(this).data("j");

-		if ($("#idforbreakperms_"+moduletohide).val() == 1) {

-			console.log("idforbreakperms_"+moduletohide+" has value hidden=1");

-			$(".trtohide_"+moduletohide).show();

-			$(".permtoshow_"+moduletohide).hide();

-			$(".permtohide_"+moduletohide).show();

-			$(".folderperms_"+moduletohide).hide();

-			$(".folderopenperms_"+moduletohide).show();

-			$("#idforbreakperms_"+moduletohide).val("0");

-		} else {

-			console.log("idforbreakperms_"+moduletohide+" has value hidden=0");

-			$(".trtohide_"+moduletohide).hide();

-			$(".folderopenperms_"+moduletohide).hide();

-			$(".folderperms_"+moduletohide).show();

-			$(".permtoshow_"+moduletohide).show();

-			$(".permtohide_"+moduletohide).hide();

-			$("#idforbreakperms_"+moduletohide).val("1");

-		}

-

-		// Now rebuild the value for cookie

-		var hideuserperm="";

-		$(".trforbreakperms").each(function(index) {

-			//console.log( index + ": " + $( this ).data("j") + " " + $( this ).data("hide-perms") + " " + $("input[data-j="+(index+1)+"]").val());

-			if ($("input[data-j="+(index+1)+"]").val() == 1) {

-				hideuserperm=hideuserperm+","+(index+1);

-			}

-		});

-		// set cookie by js

-		date = new Date(); date.setTime(date.getTime()+(30*86400000));

-		if (hideuserperm) {

-			console.log("set cookie DOLUSER_PERMS_HIDE_GRP="+hideuserperm);

-			document.cookie = "DOLUSER_PERMS_HIDE_GRP=" + hideuserperm + "; expires=" + date.toGMTString() + "; path=/ ";

-		} else {

-			console.log("delete cookie DOLUSER_PERMS_HIDE_GRP");

-			document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";

-		}

-	});';

-

-	// Button expand / collapse all

-	print '$(".showallperms").on("click", function(){

-		console.log("Click on showallperms");

-

-		console.log("delete cookie DOLUSER_PERMS_HIDE_GRP from showallperms click");

-		document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";

-		$(".tdforbreakperms").each( function(){

-			moduletohide = $(this).data("hide-perms");

-			//console.log(moduletohide);

-			if ($("#idforbreakperms_"+moduletohide).val() != 0) {

-				$(this).trigger("click");	// emulate the click, so the cooki will be resaved

-			}

-		})

-	});

-

-	$(".hideallperms").on("click", function(){

-		console.log("Click on hideallperms");

-

-		$(".tdforbreakperms").each( function(){

-			moduletohide = $(this).data("hide-perms");

-			//console.log(moduletohide);

-			if ($("#idforbreakperms_"+moduletohide).val() != 1) {

-				$(this).trigger("click");	// emulate the click, so the cooki will be resaved

-			}

-		})

-	});';

-	print "\n";

-	print '</script>';

-

-	print '<style>';

-	print '.switchfolderperms{

-		cursor: pointer;

-	}';

-	print '</style>';

-	print '</div>';

-

-	$parameters = array();

-	$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

-	if ($reshook < 0) {

-		setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

-	}

-

-	print dol_get_fiche_end();

+     * Affichage onglets

+     */

+	$object->getrights(); // Reload permission

+

+    $head = group_prepare_head($object);

+    $title = $langs->trans("Group");

+    dol_fiche_head($head, 'rights', $title, -1, 'group');

+

+    // Charge les modules soumis a permissions

+    $modules = array();

+    $modulesdir = dolGetModulesDirs();

+

+    $db->begin();

+

+    foreach ($modulesdir as $dir)

+    {

+        $handle = @opendir(dol_osencode($dir));

+        if (is_resource($handle))

+        {

+            while (($file = readdir($handle)) !== false)

+            {

+                if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')

+                {

+                    $modName = substr($file, 0, dol_strlen($file) - 10);

+

+                    if ($modName)

+                    {

+                        include_once $dir.$file;

+                        $objMod = new $modName($db);

+                        // Load all lang files of module

+                        if (isset($objMod->langfiles) && is_array($objMod->langfiles))

+                        {

+                            foreach ($objMod->langfiles as $domain)

+                            {

+                                $langs->load($domain);

+                            }

+                        }

+                        // Load all permissions

+                        if ($objMod->rights_class)

+                        {

+                            $ret = $objMod->insert_permissions(0, $entity);

+                            $modules[$objMod->rights_class] = $objMod;

+                        }

+                    }

+                }

+            }

+        }

+    }

+

+    $db->commit();

+

+    // Read permissions of group

+    $permsgroupbyentity = array();

+

+    $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";

+    $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";

+    $sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";

+    $sql .= " WHERE gr.fk_id = r.id";

+    $sql .= " AND gr.entity = ".$entity;

+    $sql .= " AND gr.fk_usergroup = ".$object->id;

+

+    dol_syslog("get user perms", LOG_DEBUG);

+    $result = $db->query($sql);

+    if ($result)

+    {

+    	$num = $db->num_rows($result);

+    	$i = 0;

+    	while ($i < $num)

+    	{

+    		$obj = $db->fetch_object($result);

+    		if (!isset($permsgroupbyentity[$obj->entity]))

+    			$permsgroupbyentity[$obj->entity] = array();

+    			array_push($permsgroupbyentity[$obj->entity], $obj->id);

+    			$i++;

+    	}

+    	$db->free($result);

+    }

+    else

+    {

+    	dol_print_error($db);

+    }

+

+    $linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';

+

+    dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);

+

+    print '<div class="fichecenter">';

+    print '<div class="underbanner clearboth"></div>';

+

+    /*

+     * Ecran ajout/suppression permission

+     */

+

+    print '<table class="border centpercent tableforfield">';

+

+    // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)

+    if (!empty($conf->mutlicompany->enabled))

+    {

+        print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';

+        print '<td colspan="2">'.$object->name.'';

+        if (!$object->entity)

+        {

+            print img_picto($langs->trans("GlobalGroup"), 'redstar');

+        }

+        print "</td></tr>\n";

+    }

+

+    // Note

+    print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td>';

+    print '<td class="valeur sensiblehtmlcontent">';

+    print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note));

+    print '</td>';

+    print "</tr>\n";

+

+    print '</table><br>';

+

+    if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));

+

+    $parameters = array();

+    $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

+    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

+

+    print "\n";

+    print '<div class="div-table-responsive-no-min">';

+    print '<table class="noborder centpercent">';

+    print '<tr class="liste_titre">';

+    print '<td>'.$langs->trans("Module").'</td>';

+    if ($caneditperms)

+    {

+    	print '<td class="center nowrap">';

+    	print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";

+    	print '/';

+    	print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";

+    	print '</td>';

+    }

+    print '<td class="center" width="24">&nbsp;</td>';

+    print '<td>'.$langs->trans("Permissions").'</td>';

+    print '</tr>'."\n";

+

+    $sql = "SELECT r.id, r.libelle as label, r.module";

+    $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";

+    $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"

+    $sql .= " AND r.entity = ".$entity;

+    if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable

+    $sql .= " ORDER BY r.module, r.id";

+

+    $result = $db->query($sql);

+    if ($result)

+    {

+    	$num = $db->num_rows($result);

+    	$i = 0;

+        $oldmod = '';

+

+        while ($i < $num)

+        {

+            $obj = $db->fetch_object($result);

+

+            // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it

+            if (empty($modules[$obj->module]))

+            {

+                $i++;

+                continue;

+            }

+

+            if ($oldmod <> $obj->module)

+            {

+                $oldmod = $obj->module;

+

+                // Break detected, we get objMod

+                $objMod = $modules[$obj->module];

+                $picto = ($objMod->picto ? $objMod->picto : 'generic');

+

+                // Show break line

+                print '<tr class="oddeven trforbreak">';

+                print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';

+                print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();

+                print '<a name="'.$objMod->getName().'"></a>';

+                print '</td>';

+                if ($caneditperms)

+                {

+                	print '<td class="center nowrap">';

+                	print '<a class="reposition" title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>";

+                    print '/';

+                    print '<a class="reposition" title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("None")."</a>";

+                    print '</td>';

+                } else {

+                	print '<td>&nbsp;</td>';

+                }

+                print '<td colspan="2">&nbsp;</td>';

+                print '</tr>';

+            }

+

+            print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";

+            print '<tr class="oddeven">';

+

+            // Picto and label of module

+            print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';

+            //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();

+            print '</td>';

+

+            if (is_array($permsgroupbyentity[$entity]))

+            {

+            	if (in_array($obj->id, $permsgroupbyentity[$entity]))

+            	{

+            		// Own permission by group

+            		if ($caneditperms)

+            		{

+            			print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';

+            		}

+            		print '<td class="center nowrap">';

+            		print img_picto($langs->trans("Active"), 'tick');

+            		print '</td>';

+            	}

+            	else

+            	{

+            		// Do not own permission

+            		if ($caneditperms)

+            		{

+            			print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';

+            		}

+            		print '<td>&nbsp</td>';

+            	}

+            }

+            else

+            {

+            	// Do not own permission

+            	if ($caneditperms)

+            	{

+            		print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';

+            	}

+            	print '<td>&nbsp</td>';

+            }

+

+            $permlabel = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));

+            print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';

+

+            print '</tr>'."\n";

+

+            $i++;

+        }

+    }

+    print '</table>';

+    print '</div>';

+

+    print '</div>';

+

+    $parameters = array();

+    $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

+    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

+

+    dol_fiche_end();