32require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
48$permissiontoadd = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
49$permissiontoread = ($user->admin || $user->hasRight(
"user",
"user",
"read"));
50$permissiontoedit = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
51$permissiontodisable = ($user->admin || $user->hasRight(
"user",
"user",
"delete"));
55$advancedpermsactive =
false;
57 $advancedpermsactive =
true;
58 $permissiontoread = ($user->admin || ($user->hasRight(
"user",
"group_advance",
"read") && $user->hasRight(
"user",
"group_advance",
"readperms")));
59 $permissiontoedit = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
60 $permissiontodisable = ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete"));
61 $feature2 =
'group_advance';
65$langs->loadLangs(array(
'users',
'other'));
68$action =
GETPOST(
'action',
'aZ09');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupcard';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
79$extrafields->fetch_name_optionals_label(
$object->table_element);
82include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
86$hookmanager->initHooks(array(
'groupcard',
'globalcard'));
89$result =
restrictedArea($user,
'user', $id,
'usergroup&usergroup', $feature2);
102$parameters = array(
'id' => $id,
'userid' => $userid,
'caneditperms' => $permissiontoedit);
103$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
108if (empty($reshook)) {
109 $backurlforlist = DOL_URL_ROOT.
'/user/group/list.php';
111 if (empty($backtopage) || ($cancel && empty($id))) {
112 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
113 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
114 $backtopage = $backurlforlist;
116 $backtopage = DOL_URL_ROOT.
'/user/group/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
122 header(
"Location: ".$backtopage);
127 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontoedit) {
130 header(
"Location: ".DOL_URL_ROOT.
"/user/group/list.php?restore_lastsearch_values=1");
135 if ($action ==
'add' && $permissiontoedit) {
136 if (!
GETPOST(
"nom",
"alphanohtml")) {
145 $ret = $extrafields->setOptionalsFromPost(
null, $object);
153 if (
$conf->entity == 1 && $user->admin && !$user->entity) {
167 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
172 $langs->load(
"errors");
180 if (($action ==
'adduser' || $action ==
'removeuser') && $permissiontoedit) {
186 $edituser->fetch($userid);
187 if ($action ==
'adduser') {
190 if ($action ==
'removeuser') {
191 $result = $edituser->RemoveFromGroup(
$object->id,
$object->entity);
195 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
204 if ($action ==
'update' && $permissiontoedit) {
217 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
224 } elseif (GETPOSTISSET(
"entity")) {
230 if ($ret >= 0 && !count(
$object->errors)) {
240 $upload_dir =
$conf->user->dir_output.
'/usergroups';
241 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
249$title =
$object->name.
' - '.$langs->trans(
"Card");
250if ($action ==
'create') {
251 $title = $langs->trans(
"NewGroup");
254llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-group_card');
263if ($action ==
'create') {
268 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
270 print
'<input type="hidden" name="action" value="add">';
271 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
275 print
'<table class="border centpercent tableforfieldcreate">';
278 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc)) {
279 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
280 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
281 print
"<td>".$mc->select_entities(
$conf->entity);
282 print
"</td></tr>\n";
284 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
288 unset(
$object->fields[
'color']);
291 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
293 print
'<tr><td>'.$langs->trans(
"ColorGroup").
'</td>';
295 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') :
$object->color,
'color', null, 1, array(),
'hideifnotset');
299 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
305 print
'<div class="center">';
306 print
'<input class="button" name="add" value="'.$langs->trans(
"CreateGroup").
'" type="submit">';
308 print
'<input class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" type="submit">';
315 $title = $langs->trans(
"Group");
320 if ($action ==
'delete') {
321 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"DeleteAGroup"), $langs->trans(
"ConfirmDeleteGroup",
$object->name),
"confirm_delete",
'', 0, 1);
328 if ($action !=
'edit') {
331 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
333 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin);
335 print
'<div class="fichecenter">';
336 print
'<div class="fichehalfleft">';
338 print
'<div class="underbanner clearboth"></div>';
340 print
'<table class="border centpercent tableforfield">';
344 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
345 print
'<td class="valeur">'.dol_escape_htmltag(
$object->name);
347 print
img_picto($langs->trans(
"GlobalGroup"),
'superadmin');
349 print
"</td></tr>\n";
353 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
355 print
"<tr>".
'<td class="titlefield">'.$langs->trans(
"Entity").
'</td>';
356 print
'<td class="valeur">'.dol_escape_htmltag($mc->label);
357 print
"</td></tr>\n";
361 unset(
$object->fields[
'color']);
365 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
367 print
'<tr><td>'.$langs->trans(
"ColorGroup").
'</td>';
369 print $formother->showColor(
$object->color,
'');
373 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
379 print
'<div class="clearboth"></div>';
387 print
'<div class="tabsAction">';
389 $parameters = array();
390 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
395 if ($permissiontoedit) {
396 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
399 if ($permissiontodisable) {
400 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"DeleteGroup").
'</a>';
412 if (!empty(
$object->members)) {
413 foreach (
$object->members as $useringroup) {
414 $exclude[] = $useringroup->id;
419 $parameters = array(
'caneditperms' => $permissiontoedit,
'exclude' => $exclude);
420 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters, $object, $action);
421 print $hookmanager->resPrint;
423 if (empty($reshook)) {
424 if ($permissiontoedit) {
425 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">'.
"\n";
426 print
'<input type="hidden" name="token" value="'.newToken().
'">';
427 print
'<input type="hidden" name="action" value="adduser">';
428 print
'<div class="div-table-responsive-no-min">';
429 print
'<table class="noborder centpercent">'.
"\n";
430 print
'<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans(
"NonAffectedUsers").
'</td>'.
"\n";
431 print
'<td class="liste_titre">';
432 print $form->select_dolusers(
'',
'user', 1, $exclude, 0,
'',
'', (
string)
$object->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
434 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
435 print
'<input type="submit" class="button buttongen button-add" value="'.$langs->trans(
"Add").
'">';
436 print
'</td></tr>'.
"\n";
439 print
'</form>'.
"\n";
447 print
'<div class="div-table-responsive">';
448 print
'<table class="noborder centpercent">';
449 print
'<tr class="liste_titre">';
450 print
'<td class="liste_titre">'.$langs->trans(
"Login").
'</td>';
451 print
'<td class="liste_titre">'.$langs->trans(
"Lastname").
'</td>';
452 print
'<td class="liste_titre">'.$langs->trans(
"Firstname").
'</td>';
453 print
'<td class="liste_titre center" width="5">'.$langs->trans(
"Status").
'</td>';
454 print
'<td class="liste_titre right" width="5"> </td>';
459 if (!empty(
$object->members)) {
460 foreach (
$object->members as $useringroup) {
461 print
'<tr class="oddeven">';
462 print
'<td class="tdoverflowmax150">';
463 print $useringroup->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
464 if (
isModEnabled(
'multicompany') && $useringroup->admin && empty($useringroup->entity)) {
465 print
img_picto($langs->trans(
"SuperAdministratorDesc"),
'superadmin',
'class="valignmiddle paddingright paddingleft"');
466 } elseif ($useringroup->admin) {
467 print
img_picto($langs->trans(
"AdministratorDesc"),
'admin',
'class="valignmiddle paddingright paddingleft"');
470 print
'<td>'.$useringroup->lastname.
'</td>';
471 print
'<td>'.$useringroup->firstname.
'</td>';
472 print
'<td class="center">'.$useringroup->getLibStatut(5).
'</td>';
473 print
'<td class="right">';
474 if (!empty($user->admin)) {
475 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=removeuser&token='.newToken().
'&user='.$useringroup->id.
'">';
476 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
481 print
"</td></tr>\n";
484 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
492 print
'<div class="fichecenter"><div class="fichehalfleft">';
500 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
501 $genallowed = $user->hasRight(
"user",
"user",
"write");
502 $delallowed = $user->hasRight(
"user",
"user",
"delete");
504 $somethingshown = $formfile->showdocuments(
'usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'',
$mysoc->default_lang);
507 $tmparray = $form->showLinkToObjectBlock($object, array(), array(), 1);
508 $linktoelem = $tmparray[
'linktoelem'];
509 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
510 print $htmltoenteralink;
512 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
514 print
'</div><div class="fichehalfright">';
521 print
'</div></div>';
528 if ($action ==
'edit' && $permissiontoedit) {
529 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="updategroup" enctype="multipart/form-data">';
530 print
'<input type="hidden" name="token" value="'.newToken().
'">';
531 print
'<input type="hidden" name="action" value="update">';
532 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
533 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
537 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
540 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc)) {
541 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
542 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
543 print
"<td>".$mc->select_entities(
$object->entity);
544 print
"</td></tr>\n";
546 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
550 unset(
$object->fields[
'color']);
553 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
555 print
'<tr><td>'.$langs->trans(
"ColorGroup").
'</td>';
557 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') :
$object->color,
'color', null, 1, array(),
'hideifnotset');
561 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
567 print $form->buttonsSaveCancel();
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage user groups.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.