30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
37$canreadperms = ($user->admin || $user->hasRight(
"user",
"user",
"read"));
38$caneditperms = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
39$candisableperms = ($user->admin || $user->hasRight(
"user",
"user",
"delete"));
43$advancedpermsactive =
false;
45 $advancedpermsactive =
true;
46 $canreadperms = ($user->admin || ($user->hasRight(
"user",
"group_advance",
"read") && $user->hasRight(
"user",
"group_advance",
"readperms")));
47 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
48 $candisableperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete"));
49 $feature2 =
'group_advance';
53$langs->loadLangs(array(
'users',
'other'));
56$action =
GETPOST(
'action',
'aZ09');
57$cancel =
GETPOST(
'cancel',
'aZ09');
58$confirm =
GETPOST(
'confirm',
'alpha');
59$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupcard';
60$backtopage =
GETPOST(
'backtopage',
'alpha');
67$extrafields->fetch_name_optionals_label(
$object->table_element);
70include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
74$hookmanager->initHooks(array(
'groupcard',
'globalcard'));
77$result =
restrictedArea($user,
'user', $id,
'usergroup&usergroup', $feature2);
80if (isModEnabled(
'multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
89$parameters = array(
'id' => $id,
'userid' => $userid,
'caneditperms' => $caneditperms);
90$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
96 $backurlforlist = DOL_URL_ROOT.
'/user/group/list.php';
98 if (empty($backtopage) || ($cancel && empty($id))) {
99 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
100 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
101 $backtopage = $backurlforlist;
103 $backtopage = DOL_URL_ROOT.
'/user/group/card.php?id='.($id > 0 ? $id :
'__ID__');
109 header(
"Location: ".$backtopage);
114 if ($action ==
'confirm_delete' && $confirm ==
"yes") {
118 header(
"Location: ".DOL_URL_ROOT.
"/user/group/list.php?restore_lastsearch_values=1");
121 $langs->load(
"errors");
127 if ($action ==
'add') {
129 if (!
GETPOST(
"nom",
"alphanohtml")) {
137 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
142 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
145 if ($conf->entity == 1 && $user->admin && !$user->entity) {
146 $object->entity = GETPOSTISSET(
"entity") ?
GETPOST(
"entity") : $conf->entity;
148 $object->entity = $conf->entity;
159 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
164 $langs->load(
"errors");
170 $langs->load(
"errors");
176 if ($action ==
'adduser' || $action ==
'removeuser') {
182 $edituser =
new User($db);
183 $edituser->fetch($userid);
184 if ($action ==
'adduser') {
187 if ($action ==
'removeuser') {
188 $result = $edituser->RemoveFromGroup(
$object->id,
$object->entity);
192 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
199 $langs->load(
"errors");
205 if ($action ==
'update') {
218 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
223 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
225 } elseif (GETPOSTISSET(
"entity")) {
231 if ($ret >= 0 && !count(
$object->errors)) {
239 $langs->load(
"errors");
245 $upload_dir = $conf->user->dir_output.
'/usergroups';
246 $permissiontoadd = $user->hasRight(
"user",
"user",
"write");
247 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
255$title =
$object->name.
' - '.$langs->trans(
"Card");
256if ($action ==
'create') {
257 $title = $langs->trans(
"NewGroup");
260llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-group_card');
263$form =
new Form($db);
264$fuserstatic =
new User($db);
265$form =
new Form($db);
268if ($action ==
'create') {
273 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
275 print
'<input type="hidden" name="action" value="add">';
276 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
280 print
'<table class="border centpercent tableforfieldcreate">';
283 if (isModEnabled(
'multicompany') && is_object($mc)) {
284 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
285 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
286 print
"<td>".$mc->select_entities($conf->entity);
287 print
"</td></tr>\n";
289 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
294 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
297 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
303 print
'<div class="center">';
304 print
'<input class="button" name="add" value="'.$langs->trans(
"CreateGroup").
'" type="submit">';
306 print
'<input class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" type="submit">';
318 $title = $langs->trans(
"Group");
323 if ($action ==
'delete') {
324 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"DeleteAGroup"), $langs->trans(
"ConfirmDeleteGroup",
$object->name),
"confirm_delete",
'', 0, 1);
331 if ($action !=
'edit') {
334 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
336 dol_banner_tab(
$object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin);
338 print
'<div class="fichecenter">';
339 print
'<div class="fichehalfleft">';
340 print
'<div class="underbanner clearboth"></div>';
342 print
'<table class="border centpercent tableforfield">';
345 if (!empty($conf->mutlicompany->enabled)) {
346 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
347 print
'<td class="valeur">'.dol_escape_htmltag(
$object->name);
349 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
351 print
"</td></tr>\n";
355 if (isModEnabled(
'multicompany') && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
357 print
"<tr>".
'<td class="titlefield">'.$langs->trans(
"Entity").
'</td>';
358 print
'<td class="valeur">'.dol_escape_htmltag($mc->label);
359 print
"</td></tr>\n";
366 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
369 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
375 print
'<div class="clearboth"></div>';
383 print
'<div class="tabsAction">';
385 $parameters = array();
386 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
392 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
395 if ($candisableperms) {
396 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"DeleteGroup").
'</a>';
408 if (!empty(
$object->members)) {
409 foreach (
$object->members as $useringroup) {
410 $exclude[] = $useringroup->id;
415 $parameters = array(
'caneditperms' => $caneditperms,
'exclude' => $exclude);
416 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters,
$object, $action);
417 print $hookmanager->resPrint;
419 if (empty($reshook)) {
421 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">'.
"\n";
422 print
'<input type="hidden" name="token" value="'.newToken().
'">';
423 print
'<input type="hidden" name="action" value="adduser">';
424 print
'<div class="div-table-responsive-no-min">';
425 print
'<table class="noborder centpercent">'.
"\n";
426 print
'<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans(
"NonAffectedUsers").
'</td>'.
"\n";
427 print
'<td class="liste_titre">';
428 print $form->select_dolusers(
'',
'user', 1, $exclude, 0,
'',
'',
$object->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
430 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
431 print
'<input type="submit" class="button buttongen button-add" value="'.$langs->trans(
"Add").
'">';
432 print
'</td></tr>'.
"\n";
435 print
'</form>'.
"\n";
443 print
'<div class="div-table-responsive">';
444 print
'<table class="noborder centpercent">';
445 print
'<tr class="liste_titre">';
446 print
'<td class="liste_titre">'.$langs->trans(
"Login").
'</td>';
447 print
'<td class="liste_titre">'.$langs->trans(
"Lastname").
'</td>';
448 print
'<td class="liste_titre">'.$langs->trans(
"Firstname").
'</td>';
449 print
'<td class="liste_titre center" width="5">'.$langs->trans(
"Status").
'</td>';
450 print
'<td class="liste_titre right" width="5"> </td>';
455 if (!empty(
$object->members)) {
456 foreach (
$object->members as $useringroup) {
457 print
'<tr class="oddeven">';
458 print
'<td class="tdoverflowmax150">';
459 print $useringroup->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
460 if (isModEnabled(
'multicompany') && $useringroup->admin && empty($useringroup->entity)) {
461 print
img_picto($langs->trans(
"SuperAdministratorDesc"),
'redstar');
462 } elseif ($useringroup->admin) {
463 print
img_picto($langs->trans(
"AdministratorDesc"),
'star');
466 print
'<td>'.$useringroup->lastname.
'</td>';
467 print
'<td>'.$useringroup->firstname.
'</td>';
468 print
'<td class="center">'.$useringroup->getLibStatut(5).
'</td>';
469 print
'<td class="right">';
470 if (!empty($user->admin)) {
471 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=removeuser&token='.
newToken().
'&user='.$useringroup->id.
'">';
472 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
477 print
"</td></tr>\n";
480 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
488 print
'<div class="fichecenter"><div class="fichehalfleft">';
496 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
497 $genallowed = $user->hasRight(
"user",
"user",
"write");
498 $delallowed = $user->hasRight(
"user",
"user",
"delete");
500 $somethingshown = $formfile->showdocuments(
'usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $mysoc->default_lang);
503 $linktoelem = $form->showLinkToObjectBlock(
$object,
null,
null);
504 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
506 print
'</div><div class="fichehalfright">';
513 print
'</div></div>';
520 if ($action ==
'edit' && $caneditperms) {
521 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="updategroup" enctype="multipart/form-data">';
522 print
'<input type="hidden" name="token" value="'.newToken().
'">';
523 print
'<input type="hidden" name="action" value="update">';
524 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
525 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
529 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
532 if (isModEnabled(
'multicompany') && is_object($mc)) {
533 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
534 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
535 print
"<td>".$mc->select_entities(
$object->entity);
536 print
"</td></tr>\n";
538 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
543 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
546 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
552 print $form->buttonsSaveCancel();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage user groups.
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
group_prepare_head($object)
Prepare array with list of tabs.