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();
94$parameters = array(
'arrayfields' => &$arrayfields);
95$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
98$fieldstosearchall = array();
99foreach (
$object->fields as $key => $val) {
100 if (!empty($val[
'searchall'])) {
101 $fieldstosearchall[
't.'.$key] = $val[
'label'];
106 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
111if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
116$caneditperms = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")));
117$permissiontodelete = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user",
"user",
"delete")));
120 $caneditperms = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"write")));
121 $permissiontodelete = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"delete")));
129if (
GETPOST(
'cancel',
'alpha')) {
133if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
137$parameters = array(
'arrayfields' => &$arrayfields);
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
143if (empty($reshook)) {
145 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
149 foreach (
$object->fields as $key => $val) {
151 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
152 $search[$key.
'_dtstart'] =
'';
153 $search[$key.
'_dtend'] =
'';
158 $search_array_options = array();
160 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
161 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
166 $objectclass =
'UserGroup';
167 $objectlabel =
'UserGroup';
168 $uploaddir =
$conf->user->dir_output;
169 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
181$title = $langs->trans(
"UserGroups");
188$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";
192$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
193$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
194$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
196 $sql .=
" WHERE g.entity IS NOT NULL";
198 $sql .=
" WHERE g.entity IN (0,".((int)
$conf->entity).
")";
200if (!empty($search_group)) {
206$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
209$nbtotalofrecords =
'';
212 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
213 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
214 $resql =
$db->query($sqlforcount);
216 $objforcount =
$db->fetch_object($resql);
217 $nbtotalofrecords = $objforcount->nbtotalofrecords;
222 if (($page * $limit) > (
int) $nbtotalofrecords) {
230$sql .=
$db->order($sortfield, $sortorder);
232 $sql .=
$db->plimit($limit + 1, $offset);
234$resql =
$db->query($sql);
240$num =
$db->num_rows($resql);
248llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-user page-group_list');
250$arrayofselected = is_array($toselect) ? $toselect : array();
252$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
254 $param .=
'&mode='.urlencode($mode);
256if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
257 $param .=
'&contextpage='.urlencode($contextpage);
259if ($limit > 0 && $limit !=
$conf->liste_limit) {
260 $param .=
'&limit='.((int) $limit);
262if ($optioncss !=
'') {
263 $param .=
'&optioncss='.urlencode($optioncss);
266foreach ($search as $key => $val) {
267 if (is_array($search[$key])) {
268 foreach ($search[$key] as $skey) {
270 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
273 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
274 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
275 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
276 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
277 } elseif ($search[$key] !=
'') {
278 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
282include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
284$parameters = array(
'param' => &$param);
285$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
286$param .= $hookmanager->resPrint;
289$arrayofmassactions = array(
295if (!empty($permissiontodelete)) {
296 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
298if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
299 $arrayofmassactions = array();
301$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
303print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
304if ($optioncss !=
'') {
305 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
307print
'<input type="hidden" name="token" value="'.newToken().
'">';
308print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
309print
'<input type="hidden" name="action" value="list">';
310print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
311print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
312print
'<input type="hidden" name="page" value="'.$page.
'">';
313print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
314print
'<input type="hidden" name="page_y" value="">';
315print
'<input type="hidden" name="mode" value="'.$mode.
'">';
318$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'));
319$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'));
323 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=',
'', $caneditperms ? 1 : 0);
326print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
329$topicmail =
"SendGroup";
332$trackid =
'grp'.$object->id;
333include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
338 foreach ($fieldstosearchall as $key => $val) {
339 $fieldstosearchall[$key] = $langs->trans($val);
340 $setupstring .= $key.
"=".$val.
";";
342 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
343 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
348$parameters = array();
349$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
350if (empty($reshook)) {
351 $moreforfilter .= $hookmanager->resPrint;
353 $moreforfilter = $hookmanager->resPrint;
356if (!empty($moreforfilter)) {
357 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
358 print $moreforfilter;
362$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
363$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
364$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
365$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
367print
'<div class="div-table-responsive">';
368print
'<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
376print
'<tr class="liste_titre_filter">';
378if (
$conf->main_checkbox_left_column) {
379 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
386 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity",
'', $param,
'', $sortfield, $sortorder,
'center ');
389print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb",
'', $param,
'', $sortfield, $sortorder,
'center ');
391print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions",
'', $param,
'', $sortfield, $sortorder,
'center ');
393print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec",
'', $param,
'', $sortfield, $sortorder,
'center ');
395print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms",
'', $param,
'', $sortfield, $sortorder,
'center ');
398include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
400$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &
$totalarray);
401$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
402print $hookmanager->resPrint;
408if (!
$conf->main_checkbox_left_column) {
409 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
421$imaxinloop = ($limit ? min($num, $limit) : $num);
422while ($i < $imaxinloop) {
423 $obj =
$db->fetch_object($resql);
429 $object->setVarsFromFetchObj($obj);
433 $object->nb_rights = $obj->nbpermissions;
436 if ($mode ==
'kanban') {
438 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
439 print
'<div class="box-flex-container kanban">';
443 if ($massactionbutton || $massaction) {
445 if (in_array(
$object->id, $arrayofselected)) {
449 print
$object->getKanbanView(
'', array(
'selected' => $selected));
450 if ($i == ($imaxinloop - 1)) {
456 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
458 if (
$conf->main_checkbox_left_column) {
459 print
'<td class="nowrap center">';
460 if ($massactionbutton || $massaction) {
462 if (in_array(
$object->id, $arrayofselected)) {
465 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
473 print
'<td class="tdoverflowmax200">';
476 print
img_picto($langs->trans(
"GlobalGroup"),
'superadmin');
485 $mc->getInfo($obj->entity);
486 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
497 print
'<td class="center">';
498 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
503 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->datec),
"dayhour").
'</td>';
507 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->tms),
"dayhour").
'</td>';
512 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
514 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &
$totalarray);
515 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
516 print $hookmanager->resPrint;
518 if (empty(
$conf->main_checkbox_left_column)) {
519 print
'<td class="nowrap center">';
520 if ($massactionbutton || $massaction) {
522 if (in_array(
$object->id, $arrayofselected)) {
525 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
539include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
549 $colspan = $savnbfield;
550 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
555$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
556$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
557print $hookmanager->resPrint;
559print
'</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)
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.