31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47$permissiontoadd = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
48$permissiontoread = ($user->admin || $user->hasRight(
"user",
"user",
"read"));
49$permissiontoedit = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
50$permissiontodisable = ($user->admin || $user->hasRight(
"user",
"user",
"delete"));
54$advancedpermsactive =
false;
56 $advancedpermsactive =
true;
57 $permissiontoread = ($user->admin || ($user->hasRight(
"user",
"group_advance",
"read") && $user->hasRight(
"user",
"group_advance",
"readperms")));
58 $permissiontoedit = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
59 $permissiontodisable = ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete"));
60 $feature2 =
'group_advance';
64$langs->loadLangs(array(
'users',
'other'));
67$action =
GETPOST(
'action',
'aZ09');
68$cancel =
GETPOST(
'cancel',
'aZ09');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupcard';
71$backtopage =
GETPOST(
'backtopage',
'alpha');
78$extrafields->fetch_name_optionals_label(
$object->table_element);
81include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
85$hookmanager->initHooks(array(
'groupcard',
'globalcard'));
88$result =
restrictedArea($user,
'user', $id,
'usergroup&usergroup', $feature2);
91if (isModEnabled(
'multicompany') &&
$conf->entity > 1 &&
$conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
100$parameters = array(
'id' => $id,
'userid' => $userid,
'caneditperms' => $permissiontoedit);
101$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
106if (empty($reshook)) {
107 $backurlforlist = DOL_URL_ROOT.
'/user/group/list.php';
109 if (empty($backtopage) || ($cancel && empty($id))) {
110 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
111 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
112 $backtopage = $backurlforlist;
114 $backtopage = DOL_URL_ROOT.
'/user/group/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
120 header(
"Location: ".$backtopage);
125 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontoedit) {
128 header(
"Location: ".DOL_URL_ROOT.
"/user/group/list.php?restore_lastsearch_values=1");
133 if ($action ==
'add' && $permissiontoedit) {
134 if (!
GETPOST(
"nom",
"alphanohtml")) {
142 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
147 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
150 if (
$conf->entity == 1 && $user->admin && !$user->entity) {
164 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
169 $langs->load(
"errors");
177 if (($action ==
'adduser' || $action ==
'removeuser') && $permissiontoedit) {
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);
201 if ($action ==
'update' && $permissiontoedit) {
213 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
218 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
220 } elseif (GETPOSTISSET(
"entity")) {
226 if ($ret >= 0 && !count(
$object->errors)) {
236 $upload_dir =
$conf->user->dir_output.
'/usergroups';
237 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
245$title =
$object->name.
' - '.$langs->trans(
"Card");
246if ($action ==
'create') {
247 $title = $langs->trans(
"NewGroup");
250llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-group_card');
253$form =
new Form($db);
254$fuserstatic =
new User($db);
255$form =
new Form($db);
258if ($action ==
'create') {
263 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
264 print
'<input type="hidden" name="token" value="'.newToken().
'">';
265 print
'<input type="hidden" name="action" value="add">';
266 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
270 print
'<table class="border centpercent tableforfieldcreate">';
273 if (isModEnabled(
'multicompany') && is_object($mc)) {
274 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
275 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
276 print
"<td>".$mc->select_entities(
$conf->entity);
277 print
"</td></tr>\n";
279 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
284 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
287 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
293 print
'<div class="center">';
294 print
'<input class="button" name="add" value="'.$langs->trans(
"CreateGroup").
'" type="submit">';
296 print
'<input class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" type="submit">';
308 $title = $langs->trans(
"Group");
313 if ($action ==
'delete') {
314 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"DeleteAGroup"), $langs->trans(
"ConfirmDeleteGroup",
$object->name),
"confirm_delete",
'', 0, 1);
321 if ($action !=
'edit') {
324 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
326 dol_banner_tab(
$object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin);
328 print
'<div class="fichecenter">';
329 print
'<div class="fichehalfleft">';
330 print
'<div class="underbanner clearboth"></div>';
332 print
'<table class="border centpercent tableforfield">';
335 if (isModEnabled(
'multicompany')) {
336 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
337 print
'<td class="valeur">'.dol_escape_htmltag(
$object->name);
339 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
341 print
"</td></tr>\n";
345 if (isModEnabled(
'multicompany') && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
347 print
"<tr>".
'<td class="titlefield">'.$langs->trans(
"Entity").
'</td>';
348 print
'<td class="valeur">'.dol_escape_htmltag($mc->label);
349 print
"</td></tr>\n";
356 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
359 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
365 print
'<div class="clearboth"></div>';
373 print
'<div class="tabsAction">';
375 $parameters = array();
376 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
381 if ($permissiontoedit) {
382 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
385 if ($permissiontodisable) {
386 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"DeleteGroup").
'</a>';
398 if (!empty(
$object->members)) {
399 foreach (
$object->members as $useringroup) {
400 $exclude[] = $useringroup->id;
405 $parameters = array(
'caneditperms' => $permissiontoedit,
'exclude' => $exclude);
406 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters,
$object, $action);
407 print $hookmanager->resPrint;
409 if (empty($reshook)) {
410 if ($permissiontoedit) {
411 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">'.
"\n";
412 print
'<input type="hidden" name="token" value="'.newToken().
'">';
413 print
'<input type="hidden" name="action" value="adduser">';
414 print
'<div class="div-table-responsive-no-min">';
415 print
'<table class="noborder centpercent">'.
"\n";
416 print
'<tr class="liste_titre"><td class="titlefield liste_titre">'.$langs->trans(
"NonAffectedUsers").
'</td>'.
"\n";
417 print
'<td class="liste_titre">';
418 print $form->select_dolusers(
'',
'user', 1, $exclude, 0,
'',
'',
$object->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
420 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
421 print
'<input type="submit" class="button buttongen button-add" value="'.$langs->trans(
"Add").
'">';
422 print
'</td></tr>'.
"\n";
425 print
'</form>'.
"\n";
433 print
'<div class="div-table-responsive">';
434 print
'<table class="noborder centpercent">';
435 print
'<tr class="liste_titre">';
436 print
'<td class="liste_titre">'.$langs->trans(
"Login").
'</td>';
437 print
'<td class="liste_titre">'.$langs->trans(
"Lastname").
'</td>';
438 print
'<td class="liste_titre">'.$langs->trans(
"Firstname").
'</td>';
439 print
'<td class="liste_titre center" width="5">'.$langs->trans(
"Status").
'</td>';
440 print
'<td class="liste_titre right" width="5"> </td>';
445 if (!empty(
$object->members)) {
446 foreach (
$object->members as $useringroup) {
447 print
'<tr class="oddeven">';
448 print
'<td class="tdoverflowmax150">';
449 print $useringroup->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
450 if (isModEnabled(
'multicompany') && $useringroup->admin && empty($useringroup->entity)) {
451 print
img_picto($langs->trans(
"SuperAdministratorDesc"),
'redstar');
452 } elseif ($useringroup->admin) {
453 print
img_picto($langs->trans(
"AdministratorDesc"),
'star');
456 print
'<td>'.$useringroup->lastname.
'</td>';
457 print
'<td>'.$useringroup->firstname.
'</td>';
458 print
'<td class="center">'.$useringroup->getLibStatut(5).
'</td>';
459 print
'<td class="right">';
460 if (!empty($user->admin)) {
461 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=removeuser&token='.
newToken().
'&user='.$useringroup->id.
'">';
462 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
467 print
"</td></tr>\n";
470 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
478 print
'<div class="fichecenter"><div class="fichehalfleft">';
486 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
487 $genallowed = $user->hasRight(
"user",
"user",
"write");
488 $delallowed = $user->hasRight(
"user",
"user",
"delete");
490 $somethingshown = $formfile->showdocuments(
'usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $mysoc->default_lang);
493 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(), 1);
494 $linktoelem = $tmparray[
'linktoelem'];
495 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
496 print $htmltoenteralink;
498 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
500 print
'</div><div class="fichehalfright">';
507 print
'</div></div>';
514 if ($action ==
'edit' && $permissiontoedit) {
515 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post" name="updategroup" enctype="multipart/form-data">';
516 print
'<input type="hidden" name="token" value="'.newToken().
'">';
517 print
'<input type="hidden" name="action" value="update">';
518 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
519 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
523 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
526 if (isModEnabled(
'multicompany') && is_object($mc)) {
527 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
528 print
"<tr>".
'<td class="tdtop">'.$langs->trans(
"Entity").
'</td>';
529 print
"<td>".$mc->select_entities(
$object->entity);
530 print
"</td></tr>\n";
532 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
537 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
540 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
546 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($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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.