function reportOrgPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentiasls) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrGroups = array(); $arrOrgz = array(); $filter_resource = getParameter("filter_resource"); $idOrgFil = getParameter("idOrganization"); $orgTmp = $pORGZ->getOrganization(array()); if ($orgTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pORGZ->errMsg)); } elseif (count($orgTmp) == 0) { $smarty->assign("mb_title", _tr("MESSAGE")); $msg = _tr("You haven't created any organization"); $smarty->assign("mb_message", $msg); } else { //si el usuario a selecionado una organizacion comprobamos que esta exista //caso contrario procedemos a sellecionar la primera disponible $flag = false; foreach ($orgTmp as $value) { $arrOrgz[$value["id"]] = $value["name"]; if ($value["id"] == $idOrgFil) { $flag = true; } } if (!$flag) { $idOrgFil = $orgTmp[0]['id']; } } $filter_resource = htmlentities($filter_resource); //buscamos en el arreglo del lenguaje la traduccion del recurso en caso de que exista $lang = get_language(); //lenguage que esta siendo usado $parameter_to_find = null; if (isset($filter_resource)) { if (trim($filter_resource) != "") { if ($lang != "en") { global $arrLang; $filter_value = strtolower(trim($filter_resource)); $parameter_to_find[] = $filter_value; //parametro de busqueda sin traduccion foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } else { $parameter_to_find[] = $filter_resource; } } } //obtenemos el numero de recursos disponibles del sistema $total = 0; if (count($arrOrgz) > 0) { $total = $pACL->getNumResources($parameter_to_find, 'yes'); } if ($total == false && $pACL->errMsg != "") { $total = 0; $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieved resources data")); } $limit = 25; $oGrid = new paloSantoGrid($smarty); $oGrid->setLimit($limit); $oGrid->setTotal($total); $offset = $oGrid->calculateOffset(); $end = $offset + $limit <= $total ? $offset + $limit : $total; $url["menu"] = $module_name; $url["filter_resource"] = $filter_resource; $url["idOrganization"] = $idOrgFil; $oGrid->setTitle(_tr("Organization Permission")); $oGrid->setURL($url); $oGrid->setWidth("99%"); $oGrid->setStart($total == 0 ? 0 : $offset + 1); $oGrid->setEnd($end); $oGrid->setTotal($total); $arrColumn = array(_tr("Resource"), "<input type='checkbox' name='selectAll' id='selectAll' />" . _tr('Permit Access')); $oGrid->setColumns($arrColumn); $arrData = array(); if (count($arrOrgz) > 0 && $total > 0) { //obtengo una lista con todos los recursos a los que una organizacion puede tener acceso $arrResource = $pACL->getListResources($limit, $offset, $parameter_to_find, 'yes'); //lista de los recursos permitidos a la organizacion seleccionada organizacion $arrResourceOrg = $pACL->getResourcesByOrg($idOrgFil, $parameter_to_find); if ($arrResourceOrg === false || $arrResource === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("An error has ocurred to retrieve resource list.") . " " . _tr($pACL->errMsg)); } else { $temp = array(); foreach ($arrResourceOrg as $value) { $temp[] = $value["id"]; } if (is_array($arrResource) && count($arrResource) > 0) { foreach ($arrResource as $resource) { $disabled = ""; if ($resource["id"] == 'usermgr' || $resource["id"] == 'grouplist' || $resource["id"] == 'userlist' || $resource["id"] == 'group_permission' || $resource["id"] == 'organization') { $disabled = "disabled='disabled'"; } $checked0 = ""; if (in_array($resource["id"], $temp)) { $checked0 = "checked"; } $arrTmp[0] = _tr($resource["description"]); $arrTmp[1] = "<input type='checkbox' {$disabled} name='resource[" . $resource["id"] . "]' id='" . $resource["id"] . "' class='resource' {$checked0}>" . " " . _tr("Permit"); $arrData[] = $arrTmp; } } } } $smarty->assign("SHOW", _tr("Show")); $smarty->assign("resource_apply", $filter_resource); if (count($arrOrgz) > 0) { $oGrid->addSubmitAction("apply", _tr("Save")); $oGrid->addComboAction("idOrganization", _tr("Organization"), $arrOrgz, $idOrgFil, "report"); $arrFormFilter = createFieldFilter(); $oFilterForm = new paloForm($smarty, $arrFormFilter); $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST); $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Resource") . " = {$filter_resource}", $_POST, array("filter_resource" => "")); $oGrid->showFilter(trim($htmlFilter)); } $contenidoModulo = $oGrid->fetchGrid(array(), $arrData); //end grid parameters return $contenidoModulo; }
function searchModulesByName() { global $arrConf; include_once "libs/paloSantoACL.class.php"; include_once "libs/JSON.php"; include_once "apps/group_permission/libs/paloSantoGroupPermission.class.php"; $json = new Services_JSON(); $pGroupPermission = new paloSantoGroupPermission(); $name = getParameter("name_module_search"); $result = array(); $arrIdMenues = array(); $lang = get_language(); global $arrLang; // obteniendo los id de los menus permitidos $pACL = new paloACL($arrConf['elastix_dsn']['elastix']); $pMenu = new paloMenu($arrConf['elastix_dsn']['elastix']); //antes de obtener el listado de los modulos debemos determinar //si la interfaz desde la cual se esta llamando a los metodos es administrativa o //es de usuario final. $tmpPath = explode("/", $arrConf['basePath']); if ($tmpPath[count($tmpPath) - 1] == 'admin') { $administrative = "yes"; } else { $administrative = "no"; } $org_access = null; if (!$pACL->isUserSuperAdmin($_SESSION['elastix_user'])) { $org_access = 'yes'; } $arrSessionPermissions = $pMenu->filterAuthorizedMenus($pACL->getIdUser($_SESSION['elastix_user']), $administrative); if (!is_array($arrSessionPermissions)) { $arrSessionPermissions = array(); } $arrIdMenues = array(); foreach ($arrSessionPermissions as $key => $value) { $arrIdMenues[] = $value['id']; // id, IdParent, Link, Type, order_no, HasChild } $parameter_to_find = array(); // arreglo con los valores del name dada la busqueda // el metodo de busqueda de por nombre sera buscando en el arreglo de lenguajes y obteniendo su $key para luego buscarlo en la base de // datos menu.db if ($lang != "en") { // entonces se adjunta la busqueda con el arreglo de lenguajes en ingles foreach ($arrLang as $key => $value) { $langValue = strtolower(trim($value)); $filter_value = strtolower(trim($name)); if ($filter_value != "") { if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) { if (strpos($langValue, $filter_value) !== FALSE) { $parameter_to_find[] = $key; } } } } } $parameter_to_find[] = $name; // buscando en la base de datos acl.db tabla acl_resource con el campo description if (empty($parameter_to_find)) { $arrResult = $pACL->getListResources(25, 0, $name, $org_access, $administrative); } else { $arrResult = $pACL->getListResources(25, 0, $parameter_to_find, $org_access, $administrative); } foreach ($arrResult as $key2 => $value2) { // leyendo el resultado del query if (in_array($value2["id"], $arrIdMenues)) { $arrMenu['caption'] = _tr($value2["description"]); $arrMenu['value'] = $value2["id"]; $result[] = $arrMenu; } } header('Content-Type: application/json'); return $json->encode($result); }