30require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
43$langs->loadLangs(array(
"users"));
45$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
46$massaction =
GETPOST(
'massaction',
'alpha');
48$confirm =
GETPOST(
'confirm',
'alpha');
49$cancel =
GETPOST(
'cancel',
'alpha');
50$toselect =
GETPOST(
'toselect',
'array:int');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
52$backtopage =
GETPOST(
'backtopage',
'alpha');
53$optioncss =
GETPOST(
'optioncss',
'aZ');
56$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
57$search_group =
GETPOST(
'search_group');
62$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
63$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
69$offset = $limit * $page;
77$hookmanager->initHooks(array($contextpage));
80$extrafields->fetch_name_optionals_label(
$object->table_element);
83$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
92$arrayfields = array();
95$fieldstosearchall = array();
96foreach (
$object->fields as $key => $val) {
97 if (!empty($val[
'searchall'])) {
98 $fieldstosearchall[
't.'.$key] = $val[
'label'];
103 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
108if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
113$caneditperms = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")));
114$permissiontodelete = $caneditperms;
117 $caneditperms = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"write")));
125if (
GETPOST(
'cancel',
'alpha')) {
129if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
133$parameters = array(
'arrayfields' => &$arrayfields);
134$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
139if (empty($reshook)) {
141 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
144 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
145 foreach (
$object->fields as $key => $val) {
147 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
148 $search[$key.
'_dtstart'] =
'';
149 $search[$key.
'_dtend'] =
'';
154 $search_array_options = array();
156 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
157 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
162 $objectclass =
'UserGroup';
163 $objectlabel =
'UserGroup';
164 $uploaddir =
$conf->user->dir_output;
165 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
177$title = $langs->trans(
"UserGroups");
184$sql =
"SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
188$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
189$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
190$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
192 $sql .=
" WHERE g.entity IS NOT NULL";
194 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
196if (!empty($search_group)) {
202$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
205$nbtotalofrecords =
'';
208 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
209 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
210 $resql =
$db->query($sqlforcount);
212 $objforcount =
$db->fetch_object($resql);
213 $nbtotalofrecords = $objforcount->nbtotalofrecords;
218 if (($page * $limit) > (
int) $nbtotalofrecords) {
226$sql .=
$db->order($sortfield, $sortorder);
228 $sql .=
$db->plimit($limit + 1, $offset);
230$resql =
$db->query($sql);
236$num =
$db->num_rows($resql);
244llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-user page-group_list');
246$arrayofselected = is_array($toselect) ? $toselect : array();
248$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
250 $param .=
'&mode='.urlencode($mode);
252if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
253 $param .=
'&contextpage='.urlencode($contextpage);
255if ($limit > 0 && $limit !=
$conf->liste_limit) {
256 $param .=
'&limit='.((int) $limit);
258if ($optioncss !=
'') {
259 $param .=
'&optioncss='.urlencode($optioncss);
262foreach ($search as $key => $val) {
263 if (is_array($search[$key])) {
264 foreach ($search[$key] as $skey) {
266 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
269 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
270 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
271 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
272 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
273 } elseif ($search[$key] !=
'') {
274 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
278include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
280$parameters = array(
'param' => &$param);
281$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
282$param .= $hookmanager->resPrint;
285$arrayofmassactions = array(
291if (!empty($permissiontodelete)) {
292 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
294if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
295 $arrayofmassactions = array();
297$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
299print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
300if ($optioncss !=
'') {
301 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
303print
'<input type="hidden" name="token" value="'.newToken().
'">';
304print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
305print
'<input type="hidden" name="action" value="list">';
306print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
307print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
308print
'<input type="hidden" name="page" value="'.$page.
'">';
309print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
310print
'<input type="hidden" name="page_y" value="">';
311print
'<input type="hidden" name="mode" value="'.$mode.
'">';
314$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
315$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
318 $newcardbutton .= dolGetButtonTitleSeparator();
319 $newcardbutton .= dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=',
'', $caneditperms ? 1 : 0);
322print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
325$topicmail =
"SendGroup";
328$trackid =
'grp'.$object->id;
329include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
334 foreach ($fieldstosearchall as $key => $val) {
335 $fieldstosearchall[$key] = $langs->trans($val);
336 $setupstring .= $key.
"=".$val.
";";
338 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
339 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
344$parameters = array();
345$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
346if (empty($reshook)) {
347 $moreforfilter .= $hookmanager->resPrint;
349 $moreforfilter = $hookmanager->resPrint;
352if (!empty($moreforfilter)) {
353 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
354 print $moreforfilter;
358$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
359$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
360$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
361$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
363print
'<div class="div-table-responsive">';
364print
'<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
372print
'<tr class="liste_titre_filter">';
374if (
$conf->main_checkbox_left_column) {
375 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
382 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity",
'', $param,
'', $sortfield, $sortorder,
'center ');
385print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb",
'', $param,
'', $sortfield, $sortorder,
'center ');
387print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions",
'', $param,
'', $sortfield, $sortorder,
'center ');
389print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec",
'', $param,
'', $sortfield, $sortorder,
'center ');
391print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms",
'', $param,
'', $sortfield, $sortorder,
'center ');
394include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
396$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &
$totalarray);
397$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
398print $hookmanager->resPrint;
404if (!
$conf->main_checkbox_left_column) {
405 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
417$imaxinloop = ($limit ? min($num, $limit) : $num);
418while ($i < $imaxinloop) {
419 $obj =
$db->fetch_object($resql);
425 $object->setVarsFromFetchObj($obj);
429 $object->nb_rights = $obj->nbpermissions;
432 if ($mode ==
'kanban') {
434 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
435 print
'<div class="box-flex-container kanban">';
439 if ($massactionbutton || $massaction) {
441 if (in_array(
$object->id, $arrayofselected)) {
445 print
$object->getKanbanView(
'', array(
'selected' => $selected));
446 if ($i == ($imaxinloop - 1)) {
452 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
454 if (
$conf->main_checkbox_left_column) {
455 print
'<td class="nowrap center">';
456 if ($massactionbutton || $massaction) {
458 if (in_array(
$object->id, $arrayofselected)) {
461 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
469 print
'<td class="tdoverflowmax200">';
472 print
img_picto($langs->trans(
"GlobalGroup"),
'superadmin');
481 $mc->getInfo($obj->entity);
482 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
493 print
'<td class="center">';
494 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
499 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->datec),
"dayhour").
'</td>';
503 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->tms),
"dayhour").
'</td>';
508 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
510 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &
$totalarray);
511 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
512 print $hookmanager->resPrint;
514 if (empty(
$conf->main_checkbox_left_column)) {
515 print
'<td class="nowrap center">';
516 if ($massactionbutton || $massaction) {
518 if (in_array(
$object->id, $arrayofselected)) {
521 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
535include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
545 $colspan = $savnbfield;
546 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
551$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
552$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
553print $hookmanager->resPrint;
555print
'</table>'.
"\n";
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.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.