コード例 #1
0
ファイル: elastixutils.lib.php プロジェクト: hardikk/HNH
function searchModulesByName()
{
    include_once "libs/JSON.php";
    include_once "modules/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
    global $arrConf;
    $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
    $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']);
    $arrSessionPermissions = $pMenu->filterAuthorizedMenus($pACL->getIdUser($_SESSION['elastix_user']));
    $arrIdMenues = array();
    foreach ($arrSessionPermissions as $key => $value) {
        $arrIdMenues[] = $value['id'];
        // id, IdParent, Link, Name, 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 = $pGroupPermission->ObtainResources(25, 0, $name);
    } else {
        $arrResult = $pGroupPermission->ObtainResources(25, 0, $parameter_to_find);
    }
    foreach ($arrResult as $key2 => $value2) {
        // leyendo el resultado del query
        if (in_array($value2["name"], $arrIdMenues)) {
            $arrMenu['caption'] = _tr($value2["description"]);
            $arrMenu['value'] = $value2["name"];
            $result[] = $arrMenu;
        }
    }
    header('Content-Type: application/json');
    return $json->encode($result);
}
コード例 #2
0
ファイル: index.php プロジェクト: hardikk/HNH
function reportGroupPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $wasSaved = false, $value_action = "", $value_start = 0)
{
    global $arrLang;
    $pGroupPermission = new paloSantoGroupPermission();
    $filter_group = getParameter("filter_group");
    $id_administrador = 1;
    $filter_group = isset($filter_group) ? $filter_group : $id_administrador;
    $filter_resource = getParameter("filter_resource");
    $action = getParameter("nav");
    $start = getParameter("start");
    if ($wasSaved) {
        $action = $value_action;
        $start = $value_start;
    }
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $parameter_to_find = array();
    $lang = get_language();
    if ($lang != "en") {
        foreach ($arrLang as $key => $value) {
            $langValue = strtolower(trim($value));
            $filter_value = strtolower(trim($filter_resource));
            if ($filter_value != "") {
                if (preg_match("/^[[:alnum:]| ]*\$/", $filter_value)) {
                    if (strpos($langValue, $filter_value) !== FALSE) {
                        $parameter_to_find[] = $key;
                    }
                }
            }
        }
    }
    $parameter_to_find[] = $filter_resource;
    if (empty($parameter_to_find)) {
        $totalGroupPermission = $pGroupPermission->ObtainNumResouces($filter_resource);
    } else {
        $totalGroupPermission = $pGroupPermission->ObtainNumResouces($parameter_to_find);
    }
    $limit = 25;
    $total = $totalGroupPermission;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $oGrid->calculatePagination($action, $start);
    $offset = $oGrid->getOffsetValue();
    $end = $oGrid->getEnd();
    $arrData = null;
    if (empty($parameter_to_find)) {
        $arrResult = $pGroupPermission->ObtainResources($limit, $offset, $filter_resource);
    } else {
        $arrResult = $pGroupPermission->ObtainResources($limit, $offset, $parameter_to_find);
    }
    $url = array('menu' => $module_name, 'filter_group' => $filter_group, 'filter_resource' => $filter_resource);
    $idGroup = $filter_group;
    $arrPermisos = $pGroupPermission->loadGroupPermissionsACL($idGroup);
    $arrPermisos = OrderGroupPermissions($arrPermisos);
    $isAdministrator = $idGroup == 1 ? true : false;
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $resource) {
            $disabled = "";
            if (($resource["name"] == 'usermgr' || $resource["name"] == 'grouplist' || $resource["name"] == 'userlist' || $resource["name"] == 'group_permission') & $isAdministrator) {
                $disabled = "disabled='disabled'";
            }
            $checked0 = "";
            $checked1 = "";
            $checked2 = "";
            $checked3 = "";
            $checked4 = "";
            if (isset($arrPermisos[$resource["name"]])) {
                $T = $arrPermisos[$resource["name"]];
                $T = $T["actions"];
                foreach ($T as $num => $key) {
                    if ($key == "access") {
                        $checked0 = "checked";
                    }
                    if ($key == "view") {
                        $checked1 = "checked";
                    }
                    if ($key == "create") {
                        $checked2 = "checked";
                    }
                    if ($key == "delete") {
                        $checked3 = "checked";
                    }
                    if ($key == "update") {
                        $checked4 = "checked";
                    }
                }
            }
            $arrTmp[0] = "<input type='checkbox' {$disabled} name='groupPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked0}>";
            $arrTmp[1] = _tr($resource["description"]);
            $arrTmp[2] = "<input type='checkbox' {$disabled} name='viewPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked1}>";
            $arrTmp[3] = "<input type='checkbox' {$disabled} name='createPermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked2}>";
            $arrTmp[4] = "<input type='checkbox' {$disabled} name='deletePermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked3}>";
            $arrTmp[5] = "<input type='checkbox' {$disabled} name='updatePermission[" . $resource["name"] . "][" . $resource["id"] . "]' {$checked4}>";
            $arrData[] = $arrTmp;
        }
    }
    $arrGrid = array("title" => _tr("Group Permission"), "icon" => "images/list.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "url" => $url, "columns" => array(0 => array("name" => "<input class='button' type='submit' name='apply' value='" . _tr('Apply') . "' />", "property1" => ""), 1 => array("name" => _tr("Resource"), "property1" => "")));
    //begin section filter
    $arrFormFilterGroupPermission = createFieldFilter($pGroupPermission);
    $oFilterForm = new paloForm($smarty, $arrFormFilterGroupPermission);
    $smarty->assign("SHOW", _tr("Show"));
    $_POST["filter_group"] = $filter_group;
    $_POST["filter_resource"] = $filter_resource;
    $nameGroup = $arrFormFilterGroupPermission["filter_group"]["INPUT_EXTRA_PARAM"][$filter_group];
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Group") . " = {$nameGroup}", $_POST, array("filter_group" => 1), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Resource") . " = {$filter_resource}", $_POST, array("filter_resource" => ""));
    //ayuda para el pagineo -> estod datos son tomados en la function applyGroupPermission($smarty, $module_name, ......
    //ayuda a que despues de "aplicar" se quede en la misma pagina
    $smarty->assign("resource_apply", htmlspecialchars($filter_resource, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("limit_apply", htmlspecialchars($limit, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("offset_apply", htmlspecialchars($offset, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("action_apply", htmlspecialchars($action, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("start_apply", htmlspecialchars($start, ENT_COMPAT, 'UTF-8'));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
    //end grid parameters
    return $contenidoModulo;
}