function reportUser($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { global $arrPermission; $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $idOrgFil = getParameter("idOrganization"); $username = getParameter("username"); $total = 0; if ($credentials['userlevel'] == "superadmin") { if (!empty($idOrgFil)) { $total = $pACL->getNumUsers($idOrgFil, $username); } else { $idOrgFil = 0; //opcion default se muestran todos los usuarios $total = $pACL->getNumUsers(null, $username); } } else { $idOrgFil = $credentials['id_organization']; $total = $pACL->getNumUsers($idOrgFil, $username); } if ($total === false) { $total = 0; $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Couldn't be retrieved user data")); } //url $url['menu'] = $module_name; $url['idOrganization'] = $idOrgFil; $url['username'] = $module_name; $limit = 20; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $oGrid->setTitle(_tr('User List')); $oGrid->setIcon("../web/_common/images/user.png"); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $arrColumns = array(); if ($credentials["userlevel"] == "superadmin") { $arrColumns[] = _tr("Organization"); //delete } $arrColumns[] = _tr("Username"); $arrColumns[] = _tr("Name"); $arrColumns[] = _tr("Group"); $arrColumns[] = _tr("Extension") . " / " . _tr("Fax Extension"); $arrColumns[] = _tr("Used Space") . " / " . _tr("Email Quota"); if (in_array('reconstruct_mailbox', $arrPermission)) { $arrColumns[] = ""; } //reconstruct mailbox $oGrid->setColumns($arrColumns); $arrData = array(); if ($credentials['userlevel'] == "superadmin") { if ($idOrgFil != 0) { $arrUsers = $pACL->getUsersPaging($limit, $offset, $idOrgFil, $username); } else { $arrUsers = $pACL->getUsersPaging($limit, $offset, null, $username); } } else { $arrUsers = $pACL->getUsersPaging($limit, $offset, $idOrgFil, $username); } if ($arrUsers === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); } //si es un usuario solo se ve a si mismo //si es un administrador ve a todo los usuarios de foreach ($arrUsers as $user) { $arrTmp = array(); if ($credentials["userlevel"] == "superadmin") { $arrOgz = $pORGZ->getOrganizationById($user[4]); $arrTmp[] = htmlentities($arrOgz["name"], ENT_COMPAT, 'UTF-8'); //organization } $arrTmp[] = " <a href='?menu=userlist&action=view&id={$user['0']}'>" . $user[1] . "</a>"; //username $arrTmp[] = htmlentities($user[2], ENT_COMPAT, 'UTF-8'); //name $gpTmp = $pACL->getGroupNameByid($user[7]); $arrTmp[] = $gpTmp == "superadmin" ? _tr("NONE") : $gpTmp; if (!isset($user[5]) || $user[5] == "") { $ext = _tr("Not assigned"); } else { $ext = $user[5]; } if (!isset($user[6]) || $user[6] == "") { $faxExt = _tr("Not assigned"); } else { $faxExt = $user[6]; } $arrTmp[] = $ext . " / " . $faxExt; if ($user[4] != 1) { //user that belong organization 1 do not have email account $arrTmp[] = obtener_quota_usuario($user[1], $module_name); //email quota if (in_array('reconstruct_mailbox', $arrPermission)) { $arrTmp[] = " <a href='#' onclick=mailbox_reconstruct('{$user[1]}')>" . _tr('Reconstruct Mailbox') . "</a>"; //reconstruct mailbox } } else { $arrTmp[] = ''; $arrTmp[] = ''; } $arrData[] = $arrTmp; $end++; } $smarty->assign("USERLEVEL", $credentials['userlevel']); $smarty->assign("SEARCH", "<input name='search_org' type='submit' class='button' value='" . _tr('Search') . "'>"); if ($pORGZ->getNumOrganization(array()) > 0) { $arrOrgz = array(0 => _tr("all")); if (in_array('create_user', $arrPermission)) { $oGrid->addNew("create_user", _tr("Create New User")); } if ($credentials['userlevel'] == "superadmin") { foreach ($pORGZ->getOrganization(array()) as $value) { $arrOrgz[$value["id"]] = $value["name"]; } $_POST["idOrganization"] = $idOrgFil; $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$idOrgFil], $_POST, array("idOrganization" => 0), true); //organization } $arrFormElements = createFieldFilter($arrOrgz); $oFilterForm = new paloForm($smarty, $arrFormElements); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Username") . " = " . $username, $_POST, array("username" => "")); //username $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->showFilter(trim($htmlFilter)); } else { $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("In order to use this module must exist at least 1 organization in the Elastix Server")); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); $mensaje = showMessageReload($module_name, $pDB, $credentials); $contenidoModulo = $mensaje . $contenidoModulo; return $contenidoModulo; }