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 = $caneditperms;
120 $caneditperms = (
isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"write")));
128if (
GETPOST(
'cancel',
'alpha')) {
132if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
136$parameters = array(
'arrayfields' => &$arrayfields);
137$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
142if (empty($reshook)) {
144 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
147 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
148 foreach (
$object->fields as $key => $val) {
150 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
151 $search[$key.
'_dtstart'] =
'';
152 $search[$key.
'_dtend'] =
'';
157 $search_array_options = array();
159 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
160 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
165 $objectclass =
'UserGroup';
166 $objectlabel =
'UserGroup';
167 $uploaddir =
$conf->user->dir_output;
168 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
180$title = $langs->trans(
"UserGroups");
187$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";
191$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
192$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
193$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
195 $sql .=
" WHERE g.entity IS NOT NULL";
197 $sql .=
" WHERE g.entity IN (0,".((int)
$conf->entity).
")";
199if (!empty($search_group)) {
205$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
208$nbtotalofrecords =
'';
211 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
212 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
213 $resql =
$db->query($sqlforcount);
215 $objforcount =
$db->fetch_object($resql);
216 $nbtotalofrecords = $objforcount->nbtotalofrecords;
221 if (($page * $limit) > (
int) $nbtotalofrecords) {
229$sql .=
$db->order($sortfield, $sortorder);
231 $sql .=
$db->plimit($limit + 1, $offset);
233$resql =
$db->query($sql);
239$num =
$db->num_rows($resql);
247llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-user page-group_list');
249$arrayofselected = is_array($toselect) ? $toselect : array();
251$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
253 $param .=
'&mode='.urlencode($mode);
255if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
256 $param .=
'&contextpage='.urlencode($contextpage);
258if ($limit > 0 && $limit !=
$conf->liste_limit) {
259 $param .=
'&limit='.((int) $limit);
261if ($optioncss !=
'') {
262 $param .=
'&optioncss='.urlencode($optioncss);
265foreach ($search as $key => $val) {
266 if (is_array($search[$key])) {
267 foreach ($search[$key] as $skey) {
269 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
272 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
273 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
274 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
275 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
276 } elseif ($search[$key] !=
'') {
277 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
281include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
283$parameters = array(
'param' => &$param);
284$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
285$param .= $hookmanager->resPrint;
288$arrayofmassactions = array(
294if (!empty($permissiontodelete)) {
295 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
297if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
298 $arrayofmassactions = array();
300$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
302print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
303if ($optioncss !=
'') {
304 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
306print
'<input type="hidden" name="token" value="'.newToken().
'">';
307print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
308print
'<input type="hidden" name="action" value="list">';
309print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
310print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
311print
'<input type="hidden" name="page" value="'.$page.
'">';
312print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
313print
'<input type="hidden" name="page_y" value="">';
314print
'<input type="hidden" name="mode" value="'.$mode.
'">';
317$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'));
318$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'));
322 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=',
'', $caneditperms ? 1 : 0);
325print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
328$topicmail =
"SendGroup";
331$trackid =
'grp'.$object->id;
332include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
337 foreach ($fieldstosearchall as $key => $val) {
338 $fieldstosearchall[$key] = $langs->trans($val);
339 $setupstring .= $key.
"=".$val.
";";
341 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
342 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
347$parameters = array();
348$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
349if (empty($reshook)) {
350 $moreforfilter .= $hookmanager->resPrint;
352 $moreforfilter = $hookmanager->resPrint;
355if (!empty($moreforfilter)) {
356 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
357 print $moreforfilter;
361$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
362$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
363$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
364$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
366print
'<div class="div-table-responsive">';
367print
'<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
375print
'<tr class="liste_titre_filter">';
377if (
$conf->main_checkbox_left_column) {
378 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
385 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity",
'', $param,
'', $sortfield, $sortorder,
'center ');
388print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb",
'', $param,
'', $sortfield, $sortorder,
'center ');
390print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions",
'', $param,
'', $sortfield, $sortorder,
'center ');
392print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec",
'', $param,
'', $sortfield, $sortorder,
'center ');
394print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms",
'', $param,
'', $sortfield, $sortorder,
'center ');
397include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
399$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &
$totalarray);
400$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
401print $hookmanager->resPrint;
407if (!
$conf->main_checkbox_left_column) {
408 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
420$imaxinloop = ($limit ? min($num, $limit) : $num);
421while ($i < $imaxinloop) {
422 $obj =
$db->fetch_object($resql);
428 $object->setVarsFromFetchObj($obj);
432 $object->nb_rights = $obj->nbpermissions;
435 if ($mode ==
'kanban') {
437 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
438 print
'<div class="box-flex-container kanban">';
442 if ($massactionbutton || $massaction) {
444 if (in_array(
$object->id, $arrayofselected)) {
448 print
$object->getKanbanView(
'', array(
'selected' => $selected));
449 if ($i == ($imaxinloop - 1)) {
455 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
457 if (
$conf->main_checkbox_left_column) {
458 print
'<td class="nowrap center">';
459 if ($massactionbutton || $massaction) {
461 if (in_array(
$object->id, $arrayofselected)) {
464 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
472 print
'<td class="tdoverflowmax200">';
475 print
img_picto($langs->trans(
"GlobalGroup"),
'superadmin');
484 $mc->getInfo($obj->entity);
485 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
496 print
'<td class="center">';
497 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
502 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->datec),
"dayhour").
'</td>';
506 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->tms),
"dayhour").
'</td>';
511 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
513 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &
$totalarray);
514 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
515 print $hookmanager->resPrint;
517 if (empty(
$conf->main_checkbox_left_column)) {
518 print
'<td class="nowrap center">';
519 if ($massactionbutton || $massaction) {
521 if (in_array(
$object->id, $arrayofselected)) {
524 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
538include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
548 $colspan = $savnbfield;
549 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
554$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
555$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
556print $hookmanager->resPrint;
558print
'</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.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.