29require 
'../../main.inc.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
 
   41$langs->loadLangs(array(
"users"));
 
   43$action     = 
GETPOST(
'action', 
'aZ09') ? 
GETPOST(
'action', 
'aZ09') : 
'view'; 
 
   44$massaction = 
GETPOST(
'massaction', 
'alpha'); 
 
   46$confirm    = 
GETPOST(
'confirm', 
'alpha'); 
 
   47$cancel     = 
GETPOST(
'cancel', 
'alpha'); 
 
   48$toselect   = 
GETPOST(
'toselect', 
'array'); 
 
   49$contextpage = 
GETPOST(
'contextpage', 
'aZ') ? 
GETPOST(
'contextpage', 
'aZ') : str_replace(
'_', 
'', basename(dirname(__FILE__)).basename(__FILE__, 
'.php')); 
 
   50$backtopage = 
GETPOST(
'backtopage', 
'alpha'); 
 
   51$optioncss  = 
GETPOST(
'optioncss', 
'aZ'); 
 
   54$search_all = trim(
GETPOST(
'search_all', 
'alphanohtml'));
 
   55$search_group = 
GETPOST(
'search_group');
 
   60$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   61$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   63if (empty($page) || $page < 0 || 
GETPOST(
'button_search', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) {
 
   67$offset = $limit * $page;
 
   75$hookmanager->initHooks(array($contextpage));   
 
   78$extrafields->fetch_name_optionals_label(
$object->table_element);
 
   81$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element, 
'', 
'search_');
 
   91$fieldstosearchall = array();
 
   92foreach (
$object->fields as $key => $val) {
 
   93  if (!empty($val[
'searchall'])) {
 
   94    $fieldstosearchall[
't.'.$key] = $val[
'label'];
 
   99  if (!$user->hasRight(
"user", 
"group_advance", 
"read") && !$user->admin) {
 
  104if (!$user->hasRight(
"user", 
"user", 
"read") && !$user->admin) {
 
  109$caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) && 
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user", 
"user", 
"write")));
 
  110$permissiontodelete = $caneditperms;
 
  113  $caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) && 
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user", 
"group_advance", 
"write")));
 
  121if (
GETPOST(
'cancel', 
'alpha')) {
 
  125if (!
GETPOST(
'confirmmassaction', 
'alpha') && $massaction != 
'presend' && $massaction != 
'confirm_presend') {
 
  129$parameters = array();
 
  130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  135if (empty($reshook)) {
 
  137  include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
 
  140  if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) { 
 
  141    foreach (
$object->fields as $key => $val) {
 
  143      if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
 
  144        $search[$key.
'_dtstart'] = 
'';
 
  145        $search[$key.
'_dtend'] = 
'';
 
  149    $search_array_options = array();
 
  151  if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')
 
  152    || 
GETPOST(
'button_search_x', 
'alpha') || 
GETPOST(
'button_search.x', 
'alpha') || 
GETPOST(
'button_search', 
'alpha')) {
 
  157  $objectclass = 
'UserGroup';
 
  158  $objectlabel = 
'UserGroup';
 
  159  $uploaddir = 
$conf->user->dir_output;
 
  160  include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
 
  168$form = 
new Form($db);
 
  172$title = $langs->trans(
"UserGroups");
 
  179$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";
 
  183$sql .= 
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
 
  184$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
 
  185$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
 
  186if (isModEnabled(
'multicompany') && 
$conf->entity == 1 && (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
 
  187  $sql .= 
" WHERE g.entity IS NOT NULL";
 
  189  $sql .= 
" WHERE g.entity IN (0,".$conf->entity.
")";
 
  191if (!empty($search_group)) {
 
  197$sql .= 
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
 
  200$nbtotalofrecords = 
'';
 
  203  $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields, 
'/').
'/', 
'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
 
  204  $sqlforcount = preg_replace(
'/GROUP BY .*$/', 
'', $sqlforcount);
 
  205  $resql = $db->query($sqlforcount);
 
  207    $objforcount = $db->fetch_object($resql);
 
  208    $nbtotalofrecords = $objforcount->nbtotalofrecords;
 
  213  if (($page * $limit) > $nbtotalofrecords) { 
 
  221$sql .= $db->order($sortfield, $sortorder);
 
  223$resql = $db->query($sql);
 
  229$num = $db->num_rows($resql);
 
  237llxHeader(
'', $title, $help_url, 
'', 0, 0, $morejs, $morecss, 
'', 
'bodyforlist mod-user page-group_list');
 
  239$arrayofselected = is_array($toselect) ? $toselect : array();
 
  241$param = 
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
 
  243  $param .= 
'&mode='.urlencode($mode);
 
  245if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
 
  246  $param .= 
'&contextpage='.urlencode($contextpage);
 
  248if ($limit > 0 && $limit != 
$conf->liste_limit) {
 
  249  $param .= 
'&limit='.((int) $limit);
 
  251foreach ($search as $key => $val) {
 
  252  if (is_array($search[$key])) {
 
  253    foreach ($search[$key] as $skey) {
 
  255        $param .= 
'&search_'.$key.
'[]='.urlencode($skey);
 
  258  } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
 
  259    $param .= 
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
 
  260    $param .= 
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
 
  261    $param .= 
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
 
  262  } elseif ($search[$key] != 
'') {
 
  263    $param .= 
'&search_'.$key.
'='.urlencode($search[$key]);
 
  266if ($optioncss != 
'') {
 
  267  $param .= 
'&optioncss='.urlencode($optioncss);
 
  270include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
 
  272$parameters = array(
'param' => &$param);
 
  273$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action); 
 
  274$param .= $hookmanager->resPrint;
 
  277$arrayofmassactions = array(
 
  283if (!empty($permissiontodelete)) {
 
  284  $arrayofmassactions[
'predelete'] = 
img_picto(
'', 
'delete', 
'class="pictofixedwidth"').$langs->trans(
"Delete");
 
  286if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend', 
'predelete'))) {
 
  287  $arrayofmassactions = array();
 
  289$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
 
  291print 
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
 
  292if ($optioncss != 
'') {
 
  293  print 
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
 
  295print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  296print 
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 
  297print 
'<input type="hidden" name="action" value="list">';
 
  298print 
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
 
  299print 
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
 
  300print 
'<input type="hidden" name="page" value="'.$page.
'">';
 
  301print 
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
 
  302print 
'<input type="hidden" name="page_y" value="">';
 
  303print 
'<input type="hidden" name="mode" value="'.$mode.
'">';
 
  306$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'));
 
  307$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'));
 
  311  $newcardbutton .= 
dolGetButtonTitle($langs->trans(
'NewGroup'), 
'', 
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=', 
'', $caneditperms ? 1 : 0);
 
  314print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 
'object_'.
$object->picto, 0, $newcardbutton, 
'', $limit, 0, 0, 1);
 
  317$topicmail = 
"SendGroup";
 
  320$trackid = 
'grp'.$object->id;
 
  321include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
 
  325  foreach ($fieldstosearchall as $key => $val) {
 
  326    $fieldstosearchall[$key] = $langs->trans($val);
 
  327    $setupstring .= $key.
"=".$val.
";";
 
  329  print 
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
 
  330  print 
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
 
  335$parameters = array();
 
  336$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action); 
 
  337if (empty($reshook)) {
 
  338  $moreforfilter .= $hookmanager->resPrint;
 
  340  $moreforfilter = $hookmanager->resPrint;
 
  343if (!empty($moreforfilter)) {
 
  344  print 
'<div class="liste_titre liste_titre_bydiv centpercent">';
 
  345  print $moreforfilter;
 
  349$varpage=empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
 
  350$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage, 
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));  
 
  351$selectedfields = ($mode != 
'kanban' ? $htmlofselectarray : 
'');
 
  352$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) : 
'');
 
  354print 
'<div class="div-table-responsive">';
 
  355print 
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ? 
" listwithfilterbefore" : 
"").
'">'.
"\n";
 
  361$totalarray = array();
 
  362$totalarray[
'nbfield'] = 0;
 
  366print 
'<tr class="liste_titre">';
 
  368  print 
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"], 
'', 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch ').
"\n";
 
  369  $totalarray[
'nbfield']++;
 
  372$totalarray[
'nbfield']++;
 
  374if (isModEnabled(
'multicompany') && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && 
$conf->entity == 1) {
 
  375  print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"], 
"g.entity", $param, 
"", 
'', $sortfield, $sortorder, 
'center ');
 
  376  $totalarray[
'nbfield']++;
 
  378print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"], 
"nb", $param, 
"", 
'', $sortfield, $sortorder, 
'center ');
 
  379$totalarray[
'nbfield']++;
 
  380print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"], 
"nbpermissions", $param, 
"", 
'', $sortfield, $sortorder, 
'center ');
 
  381$totalarray[
'nbfield']++;
 
  382print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"], 
"g.datec", $param, 
"", 
'', $sortfield, $sortorder, 
'center ');
 
  383$totalarray[
'nbfield']++;
 
  384print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"], 
"g.tms", $param, 
"", 
'', $sortfield, $sortorder, 
'center ');
 
  385$totalarray[
'nbfield']++;
 
  387include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
 
  389$parameters = array(
'arrayfields'=>$arrayfields, 
'param'=>$param, 
'sortfield'=>$sortfield, 
'sortorder'=>$sortorder, 
'totalarray'=>&$totalarray);
 
  390$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action); 
 
  391print $hookmanager->resPrint;
 
  398  print 
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"], 
'', 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch ').
"\n";
 
  399  $totalarray[
'nbfield']++;
 
  407$savnbfield = $totalarray[
'nbfield'];
 
  408$totalarray = array();
 
  409$totalarray[
'nbfield'] = 0;
 
  410$imaxinloop = ($limit ? min($num, $limit) : $num);
 
  411while ($i < $imaxinloop) {
 
  412  $obj = $db->fetch_object($resql);
 
  418  $object->setVarsFromFetchObj($obj);
 
  422  $object->nb_rights = $obj->nbpermissions;
 
  425  if ($mode == 
'kanban') {
 
  427      print 
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
 
  428      print 
'<div class="box-flex-container kanban">';
 
  432    if ($massactionbutton || $massaction) { 
 
  434      if (in_array(
$object->id, $arrayofselected)) {
 
  438    print 
$object->getKanbanView(
'', array(
'selected' => $selected));
 
  439    if ($i == ($imaxinloop - 1)) {
 
  446    print 
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
 
  449      print 
'<td class="nowrap center">';
 
  450      if ($massactionbutton || $massaction) { 
 
  452        if (in_array(
$object->id, $arrayofselected)) {
 
  455        print 
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
  459        $totalarray[
'nbfield']++;
 
  463    print 
'<td class="tdoverflowmax125">';
 
  465    if (isModEnabled(
'multicompany') && !$obj->entity) {
 
  466      print 
img_picto($langs->trans(
"GlobalGroup"), 
'redstar');
 
  470      $totalarray[
'nbfield']++;
 
  473    if (isModEnabled(
'multicompany') && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && 
$conf->entity == 1) {
 
  474      $mc->getInfo($obj->entity);
 
  475      print 
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
 
  477        $totalarray[
'nbfield']++;
 
  480    print 
'<td class="center">'.dol_escape_htmltag($obj->nb).
'</td>';
 
  482      $totalarray[
'nbfield']++;
 
  484    print 
'<td class="center">';
 
  485    print 
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
 
  488      $totalarray[
'nbfield']++;
 
  490    print 
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), 
"dayhour").
'</td>';
 
  492      $totalarray[
'nbfield']++;
 
  494    print 
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms), 
"dayhour").
'</td>';
 
  496      $totalarray[
'nbfield']++;
 
  499    include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
 
  501    $parameters = array(
'arrayfields'=>$arrayfields, 
'object'=>$object, 
'obj'=>$obj, 
'i'=>$i, 
'totalarray'=>&$totalarray);
 
  502    $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action); 
 
  503    print $hookmanager->resPrint;
 
  506      print 
'<td class="nowrap center">';
 
  507      if ($massactionbutton || $massaction) { 
 
  509        if (in_array(
$object->id, $arrayofselected)) {
 
  512        print 
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
  516        $totalarray[
'nbfield']++;
 
  526include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
 
  536  $colspan = $savnbfield;
 
  537  print 
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
 
  542print 
'</table>'.
"\n";
 
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
 
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)
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.
 
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)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
 
dol_now($mode='auto')
Return date for now.
 
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
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.
 
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.
 
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...
 
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
 
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.