29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
33 require_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 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
43 $canreadperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"read"));
44 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
45 $candisableperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete"));
46 $feature2 =
'group_advance';
50 $langs->loadLangs(array(
'users',
'other'));
53 $action =
GETPOST(
'action',
'aZ09');
54 $cancel =
GETPOST(
'cancel',
'aZ09');
55 $confirm =
GETPOST(
'confirm',
'alpha');
56 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupcard';
57 $backtopage =
GETPOST(
'backtopage',
'alpha');
59 $userid =
GETPOST(
'user',
'int');
61 $object =
new Usergroup($db);
64 $extrafields->fetch_name_optionals_label($object->table_element);
67 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
71 $hookmanager->initHooks(array(
'groupcard',
'globalcard'));
74 $result =
restrictedArea($user,
'user', $id,
'usergroup&usergroup', $feature2);
77 if (
isModEnabled(
'multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
86 $parameters = array(
'id' => $id,
'userid' => $userid,
'caneditperms' => $caneditperms);
87 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
92 if (empty($reshook)) {
93 $backurlforlist = DOL_URL_ROOT.
'/user/group/list.php';
95 if (empty($backtopage) || ($cancel && empty($id))) {
96 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
97 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
98 $backtopage = $backurlforlist;
100 $backtopage = DOL_URL_ROOT.
'/user/group/card.php?id='.($id > 0 ? $id :
'__ID__');
106 header(
"Location: ".$backtopage);
111 if ($action ==
'confirm_delete' && $confirm ==
"yes") {
114 $object->delete($user);
115 header(
"Location: ".DOL_URL_ROOT.
"/user/group/list.php?restore_lastsearch_values=1");
118 $langs->load(
"errors");
124 if ($action ==
'add') {
126 if (!
GETPOST(
"nom",
"alphanohtml")) {
130 $object->name =
GETPOST(
"nom",
'alphanohtml');
134 $ret = $extrafields->setOptionalsFromPost(
null, $object);
139 if (
isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
142 if ($conf->entity == 1 && $user->admin && !$user->entity) {
145 $object->entity = $conf->entity;
151 $id = $object->create();
156 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
161 $langs->load(
"errors");
162 setEventMessages($langs->trans(
"ErrorGroupAlreadyExists", $object->name),
null,
'errors');
167 $langs->load(
"errors");
173 if ($action ==
'adduser' || $action ==
'removeuser') {
177 $object->oldcopy = clone $object;
179 $edituser =
new User($db);
180 $edituser->fetch($userid);
181 if ($action ==
'adduser') {
182 $result = $edituser->SetInGroup($object->id, $object->entity);
184 if ($action ==
'removeuser') {
185 $result = $edituser->RemoveFromGroup($object->id, $object->entity);
189 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
196 $langs->load(
"errors");
202 if ($action ==
'update') {
208 $object->oldcopy = clone $object;
210 $object->name =
GETPOST(
"nom",
'alphanohtml');
214 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
219 if (
isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
222 $object->entity =
GETPOST(
"entity",
"int");
225 $ret = $object->update();
227 if ($ret >= 0 && !count($object->errors)) {
235 $langs->load(
"errors");
241 $upload_dir = $conf->user->dir_output.
'/usergroups';
242 $permissiontoadd = $user->hasRight(
"user",
"user",
"write");
243 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
250 $title = $object->name.
' - '.$langs->trans(
"Card");
251 if ($action ==
'create') {
252 $title = $langs->trans(
"NewGroup");
259 $fuserstatic =
new User($db);
263 if ($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">';
279 if (empty($conf->global->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.
'" />';
289 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
292 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
298 print
'<div class="center">';
299 print
'<input class="button" name="add" value="'.$langs->trans(
"CreateGroup").
'" type="submit">';
301 print
'<input class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" type="submit">';
312 $res = $object->fetch_optionals();
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">';
337 print
'<div class="underbanner clearboth"></div>';
339 print
'<table class="border centpercent tableforfield">';
342 if (!empty($conf->mutlicompany->enabled)) {
343 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
344 print
'<td class="valeur">'.dol_escape_htmltag($object->name);
345 if (empty($object->entity)) {
346 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
348 print
"</td></tr>\n";
352 if (
isModEnabled(
'multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
353 $mc->getInfo($object->entity);
354 print
"<tr>".
'<td class="titlefield">'.$langs->trans(
"Entity").
'</td>';
355 print
'<td class="valeur">'.dol_escape_htmltag($mc->label);
356 print
"</td></tr>\n";
359 unset($object->fields[
'nom']);
363 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
366 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
372 print
'<div class="clearboth"></div>';
380 print
'<div class="tabsAction">';
383 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
389 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
392 if ($candisableperms) {
393 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"DeleteGroup").
'</a>';
405 if (!empty($object->members)) {
406 foreach ($object->members as $useringroup) {
407 $exclude[] = $useringroup->id;
412 $parameters = array(
'caneditperms' => $caneditperms,
'exclude' => $exclude);
413 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup',
$parameters, $object, $action);
414 print $hookmanager->resPrint;
416 if (empty($reshook)) {
418 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST">'.
"\n";
419 print
'<input type="hidden" name="token" value="'.newToken().
'">';
420 print
'<input type="hidden" name="action" value="adduser">';
421 print
'<div class="div-table-responsive-no-min">';
422 print
'<table class="noborder centpercent">'.
"\n";
423 print
'<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans(
"NonAffectedUsers").
'</td>'.
"\n";
424 print
'<td class="liste_titre">';
425 print
$form->select_dolusers(
'',
'user', 1, $exclude, 0,
'',
'', $object->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
427 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
428 print
'<input type="submit" class="button buttongen button-add" value="'.$langs->trans(
"Add").
'">';
429 print
'</td></tr>'.
"\n";
432 print
'</form>'.
"\n";
440 print
'<div class="div-table-responsive">';
441 print
'<table class="noborder centpercent">';
442 print
'<tr class="liste_titre">';
443 print
'<td class="liste_titre">'.$langs->trans(
"Login").
'</td>';
444 print
'<td class="liste_titre">'.$langs->trans(
"Lastname").
'</td>';
445 print
'<td class="liste_titre">'.$langs->trans(
"Firstname").
'</td>';
446 print
'<td class="liste_titre center" width="5">'.$langs->trans(
"Status").
'</td>';
447 print
'<td class="liste_titre right" width="5"> </td>';
450 if (!empty($object->members)) {
451 foreach ($object->members as $useringroup) {
452 print
'<tr class="oddeven">';
453 print
'<td class="tdoverflowmax150">';
454 print $useringroup->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
455 if (
isModEnabled(
'multicompany') && $useringroup->admin && empty($useringroup->entity)) {
456 print
img_picto($langs->trans(
"SuperAdministrator"),
'redstar');
457 } elseif ($useringroup->admin) {
458 print
img_picto($langs->trans(
"Administrator"),
'star');
461 print
'<td>'.$useringroup->lastname.
'</td>';
462 print
'<td>'.$useringroup->firstname.
'</td>';
463 print
'<td class="center">'.$useringroup->getLibStatut(5).
'</td>';
464 print
'<td class="right">';
465 if (!empty($user->admin)) {
466 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removeuser&token='.
newToken().
'&user='.$useringroup->id.
'">';
467 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
472 print
"</td></tr>\n";
475 print
'<tr><td colspan="6" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
483 print
'<div class="fichecenter"><div class="fichehalfleft">';
491 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
492 $genallowed = $user->hasRight(
"user",
"user",
"write");
493 $delallowed = $user->hasRight(
"user",
"user",
"delete");
495 $somethingshown = $formfile->showdocuments(
'usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $mysoc->default_lang);
498 $linktoelem =
$form->showLinkToObjectBlock($object,
null,
null);
499 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
501 print
'</div><div class="fichehalfright">';
508 print
'</div></div>';
515 if ($action ==
'edit' && $caneditperms) {
516 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="updategroup" enctype="multipart/form-data">';
517 print
'<input type="hidden" name="token" value="'.newToken().
'">';
518 print
'<input type="hidden" name="action" value="update">';
519 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
520 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
524 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
528 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
529 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
530 print
"<td>".$mc->select_entities($object->entity);
531 print
"</td></tr>\n";
533 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
538 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
541 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
547 print
$form->buttonsSaveCancel();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.