29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36$canreadperms = ($user->admin || $user->hasRight(
"user",
"user",
"read"));
37$caneditperms = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
38$candisableperms = ($user->admin || $user->hasRight(
"user",
"user",
"delete"));
42$advancedpermsactive =
false;
43if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
44 $advancedpermsactive =
true;
45 $canreadperms = ($user->admin || ($user->hasRight(
"user",
"group_advance",
"read") && $user->hasRight(
"user",
"group_advance",
"readperms")));
46 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
47 $candisableperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete"));
48 $feature2 =
'group_advance';
52$langs->loadLangs(array(
'users',
'other'));
55$action =
GETPOST(
'action',
'aZ09');
56$cancel =
GETPOST(
'cancel',
'aZ09');
57$confirm =
GETPOST(
'confirm',
'alpha');
58$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupcard';
59$backtopage =
GETPOST(
'backtopage',
'alpha');
61$userid =
GETPOST(
'user',
'int');
66$extrafields->fetch_name_optionals_label($object->table_element);
69include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
73$hookmanager->initHooks(array(
'groupcard',
'globalcard'));
76$result =
restrictedArea($user,
'user', $id,
'usergroup&usergroup', $feature2);
79if (isModEnabled(
'multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
88$parameters = array(
'id' => $id,
'userid' => $userid,
'caneditperms' => $caneditperms);
89$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
95 $backurlforlist = DOL_URL_ROOT.
'/user/group/list.php';
97 if (empty($backtopage) || ($cancel && empty($id))) {
98 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
99 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
100 $backtopage = $backurlforlist;
102 $backtopage = DOL_URL_ROOT.
'/user/group/card.php?id='.($id > 0 ? $id :
'__ID__');
108 header(
"Location: ".$backtopage);
113 if ($action ==
'confirm_delete' && $confirm ==
"yes") {
116 $object->delete($user);
117 header(
"Location: ".DOL_URL_ROOT.
"/user/group/list.php?restore_lastsearch_values=1");
120 $langs->load(
"errors");
126 if ($action ==
'add') {
128 if (!
GETPOST(
"nom",
"alphanohtml")) {
132 $object->name =
GETPOST(
"nom",
'alphanohtml');
136 $ret = $extrafields->setOptionalsFromPost(
null, $object);
141 if (isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
144 if ($conf->entity == 1 && $user->admin && !$user->entity) {
145 $object->entity = GETPOSTISSET(
"entity") ?
GETPOST(
"entity") : $conf->entity;
147 $object->entity = $conf->entity;
153 $id = $object->create();
158 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
163 $langs->load(
"errors");
164 setEventMessages($langs->trans(
"ErrorGroupAlreadyExists", $object->name),
null,
'errors');
169 $langs->load(
"errors");
175 if ($action ==
'adduser' || $action ==
'removeuser') {
179 $object->oldcopy = clone $object;
181 $edituser =
new User($db);
182 $edituser->fetch($userid);
183 if ($action ==
'adduser') {
184 $result = $edituser->SetInGroup($object->id, $object->entity);
186 if ($action ==
'removeuser') {
187 $result = $edituser->RemoveFromGroup($object->id, $object->entity);
191 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
198 $langs->load(
"errors");
204 if ($action ==
'update') {
210 $object->oldcopy = clone $object;
212 $object->name =
GETPOST(
"nom",
'alphanohtml');
217 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
222 if (isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
224 } elseif (GETPOSTISSET(
"entity")) {
225 $object->entity =
GETPOST(
"entity",
"int");
228 $ret = $object->update();
230 if ($ret >= 0 && !count($object->errors)) {
238 $langs->load(
"errors");
244 $upload_dir = $conf->user->dir_output.
'/usergroups';
245 $permissiontoadd = $user->hasRight(
"user",
"user",
"write");
246 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
254$title = $object->name.
' - '.$langs->trans(
"Card");
255if ($action ==
'create') {
256 $title = $langs->trans(
"NewGroup");
262$form =
new Form($db);
263$fuserstatic =
new User($db);
264$form =
new Form($db);
267if ($action ==
'create') {
272 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
273 print
'<input type="hidden" name="token" value="'.newToken().
'">';
274 print
'<input type="hidden" name="action" value="add">';
275 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
279 print
'<table class="border centpercent tableforfieldcreate">';
282 if (isModEnabled(
'multicompany') && is_object($mc)) {
283 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
284 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
285 print
"<td>".$mc->select_entities($conf->entity);
286 print
"</td></tr>\n";
288 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
293 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
296 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
302 print
'<div class="center">';
303 print
'<input class="button" name="add" value="'.$langs->trans(
"CreateGroup").
'" type="submit">';
305 print
'<input class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" type="submit">';
317 $title = $langs->trans(
"Group");
322 if ($action ==
'delete') {
323 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".$object->id, $langs->trans(
"DeleteAGroup"), $langs->trans(
"ConfirmDeleteGroup", $object->name),
"confirm_delete",
'', 0, 1);
330 if ($action !=
'edit') {
333 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
335 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin);
337 print
'<div class="fichecenter">';
338 print
'<div class="fichehalfleft">';
339 print
'<div class="underbanner clearboth"></div>';
341 print
'<table class="border centpercent tableforfield">';
344 if (!empty($conf->mutlicompany->enabled)) {
345 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
346 print
'<td class="valeur">'.dol_escape_htmltag($object->name);
347 if (empty($object->entity)) {
348 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
350 print
"</td></tr>\n";
354 if (isModEnabled(
'multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
355 $mc->getInfo($object->entity);
356 print
"<tr>".
'<td class="titlefield">'.$langs->trans(
"Entity").
'</td>';
357 print
'<td class="valeur">'.dol_escape_htmltag($mc->label);
358 print
"</td></tr>\n";
361 unset($object->fields[
'nom']);
365 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
368 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
374 print
'<div class="clearboth"></div>';
382 print
'<div class="tabsAction">';
384 $parameters = array();
385 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
391 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
394 if ($candisableperms) {
395 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"DeleteGroup").
'</a>';
407 if (!empty($object->members)) {
408 foreach ($object->members as $useringroup) {
409 $exclude[] = $useringroup->id;
414 $parameters = array(
'caneditperms' => $caneditperms,
'exclude' => $exclude);
415 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters, $object, $action);
416 print $hookmanager->resPrint;
418 if (empty($reshook)) {
420 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST">'.
"\n";
421 print
'<input type="hidden" name="token" value="'.newToken().
'">';
422 print
'<input type="hidden" name="action" value="adduser">';
423 print
'<div class="div-table-responsive-no-min">';
424 print
'<table class="noborder centpercent">'.
"\n";
425 print
'<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans(
"NonAffectedUsers").
'</td>'.
"\n";
426 print
'<td class="liste_titre">';
427 print $form->select_dolusers(
'',
'user', 1, $exclude, 0,
'',
'', $object->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
429 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
430 print
'<input type="submit" class="button buttongen button-add" value="'.$langs->trans(
"Add").
'">';
431 print
'</td></tr>'.
"\n";
434 print
'</form>'.
"\n";
442 print
'<div class="div-table-responsive">';
443 print
'<table class="noborder centpercent">';
444 print
'<tr class="liste_titre">';
445 print
'<td class="liste_titre">'.$langs->trans(
"Login").
'</td>';
446 print
'<td class="liste_titre">'.$langs->trans(
"Lastname").
'</td>';
447 print
'<td class="liste_titre">'.$langs->trans(
"Firstname").
'</td>';
448 print
'<td class="liste_titre center" width="5">'.$langs->trans(
"Status").
'</td>';
449 print
'<td class="liste_titre right" width="5"> </td>';
452 $object->fetch($object->id,
'',
true);
454 if (!empty($object->members)) {
455 foreach ($object->members as $useringroup) {
456 print
'<tr class="oddeven">';
457 print
'<td class="tdoverflowmax150">';
458 print $useringroup->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
459 if (isModEnabled(
'multicompany') && $useringroup->admin && empty($useringroup->entity)) {
460 print
img_picto($langs->trans(
"SuperAdministrator"),
'redstar');
461 } elseif ($useringroup->admin) {
462 print
img_picto($langs->trans(
"Administrator"),
'star');
465 print
'<td>'.$useringroup->lastname.
'</td>';
466 print
'<td>'.$useringroup->firstname.
'</td>';
467 print
'<td class="center">'.$useringroup->getLibStatut(5).
'</td>';
468 print
'<td class="right">';
469 if (!empty($user->admin)) {
470 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removeuser&token='.newToken().
'&user='.$useringroup->id.
'">';
471 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
476 print
"</td></tr>\n";
479 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
487 print
'<div class="fichecenter"><div class="fichehalfleft">';
495 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
496 $genallowed = $user->hasRight(
"user",
"user",
"write");
497 $delallowed = $user->hasRight(
"user",
"user",
"delete");
499 $somethingshown = $formfile->showdocuments(
'usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $mysoc->default_lang);
502 $linktoelem = $form->showLinkToObjectBlock($object,
null,
null);
503 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
505 print
'</div><div class="fichehalfright">';
512 print
'</div></div>';
519 if ($action ==
'edit' && $caneditperms) {
520 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="updategroup" enctype="multipart/form-data">';
521 print
'<input type="hidden" name="token" value="'.newToken().
'">';
522 print
'<input type="hidden" name="action" value="update">';
523 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
524 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
528 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
531 if (isModEnabled(
'multicompany') && is_object($mc)) {
532 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
533 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
534 print
"<td>".$mc->select_entities($object->entity);
535 print
"</td></tr>\n";
537 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
542 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
545 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
551 print $form->buttonsSaveCancel();
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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.
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.