Beispiel #1
0
function reportGroup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $userLevel1, $userAccount, $idOrganization)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $idOrgFil = getParameter("idOrganization");
    if ($userLevel1 == "superadmin") {
        if (!empty($idOrgFil)) {
            $cntGroups = $pACL->getNumGroups($idOrgFil);
        } else {
            $idOrgFil = 0;
            //opcion default se muestran todos los grupos
            $cntGroupsMO = $pACL->getNumGroups(1);
            //obtenemos en numero de grupos que pertenecen a
            //la organizacion 1 y lo restamos del total de grupos
            $cntGroups = $pACL->getNumGroups() - $cntGroupsMO;
        }
    } else {
        $idOrgFil = $idOrganization;
        $cntGroups = $pACL->getNumGroups($idOrganization);
    }
    if ($cntGroups === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr($pACL->errMsg));
        $total = 0;
    } else {
        $total = $cntGroups;
    }
    //url
    $url['menu'] = $module_name;
    $url['idOrganization'] = $idOrgFil;
    $total = $total == NULL ? 0 : $total;
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $oGrid->getEnd();
    $oGrid->setURL($url);
    $oGrid->setTitle(_tr('Group List'));
    $oGrid->setIcon("web/apps/{$module_name}/images/system_groups.png");
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    if ($userLevel1 == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Group Name");
    $arrColumns[] = _tr("Group Description");
    $oGrid->setColumns($arrColumns);
    if ($idOrgFil != 0) {
        $Groups = $pACL->getGroupsPaging($limit, $offset, $idOrgFil);
    } else {
        $Groups = $pACL->getGroupsPaging($limit, $offset);
    }
    $arrData = array();
    foreach ($Groups as $group) {
        if ($group[3] != 1) {
            $arrTmp = array();
            if ($userLevel1 == "superadmin") {
                $orgz = $pORGZ->getOrganizationById($group[3]);
                $arrTmp[] = htmlentities($orgz["name"], ENT_COMPAT, 'UTF-8');
                //organization
            }
            $arrTmp[] = "&nbsp;<a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>";
            //id,group name
            $arrTmp[] = _tr($group[2]);
            //description
            $arrData[] = $arrTmp;
        }
    }
    if ($pORGZ->getNumOrganization(array()) > 0) {
        global $arrPermission;
        if (in_array('create_group', $arrPermission)) {
            $oGrid->addNew("create_group", _tr("Create New Group"));
        }
        if ($userLevel1 == "superadmin") {
            $arrOrgz = array(0 => _tr("all"));
            foreach ($pORGZ->getOrganization(array()) as $value) {
                if ($value["id"] != 1) {
                    $arrOrgz[$value["id"]] = $value["name"];
                }
            }
            $arrFormElements = createFieldFilter($arrOrgz);
            $oFilterForm = new paloForm($smarty, $arrFormElements);
            $_POST["idOrganization"] = $idOrgFil;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$idOrgFil], $_POST, array("idOrganization" => 0), true);
            $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
            $oGrid->showFilter(trim($htmlFilter));
        }
    } else {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("You need have created at least one organization before you can create a new group"));
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    return $contenidoModulo;
}
Beispiel #2
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoACL.class.php";
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    //global variables
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    /////conexion a php
    $pDB = new paloDB($arrConf['elastix_dsn']['acl']);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    if (!empty($pDB->errMsg)) {
        echo "ERROR DE DB: {$pDB->errMsg} <br>";
    }
    $arrData = array();
    $pACL = new paloACL($pDB);
    if (!empty($pACL->errMsg)) {
        echo "ERROR DE ACL: {$pACL->errMsg} <br>";
    }
    $arrFormElements = array("description" => array("LABEL" => _tr("Description"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => _tr("Group"), "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    //description  id  name
    $contenidoModulo = "";
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("APPLY_CHANGES", _tr("Apply changes"));
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("DELETE", _tr("Delete"));
    $smarty->assign("icon", "modules/{$module_name}/images/system_groups.png");
    $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?"));
    if (isset($_POST['submit_create_group'])) {
        // Implementar
        include_once "libs/paloSantoForm.class.php";
        $arrFillGroup['group'] = '';
        $arrFillGroup['description'] = '';
        $oForm = new paloForm($smarty, $arrFormElements);
        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $arrFillGroup);
    } else {
        if (isset($_POST['edit'])) {
            // Tengo que recuperar la data del usuario
            $pACL = new paloACL($pDB);
            $arrGroup = $pACL->getGroups($_POST['id_group']);
            if (!is_array($arrGroup)) {
                $contenidoModulo = '';
                Header("Location: ?menu={$module_name}");
            } else {
                if ($arrGroup[0][1] == 'administrator') {
                    $arrGroup[0][1] = _tr('administrator');
                } else {
                    if ($arrGroup[0][1] == 'operator') {
                        $arrGroup[0][1] = _tr('operator');
                    } else {
                        if ($arrGroup[0][1] == 'extension') {
                            $arrGroup[0][1] = _tr('extension');
                        }
                    }
                }
                if ($arrGroup[0][2] == 'total access') {
                    $arrGroup[0][2] = _tr('total access');
                } else {
                    if ($arrGroup[0][2] == 'operator') {
                        $arrGroup[0][2] = _tr('operator');
                    } else {
                        if ($arrGroup[0][2] == 'extension user') {
                            $arrGroup[0][2] = _tr('extension user');
                        }
                    }
                }
                $arrFillGroup['group'] = $arrGroup[0][1];
                $arrFillGroup['description'] = $arrGroup[0][2];
                // Implementar
                include_once "libs/paloSantoForm.class.php";
                $oForm = new paloForm($smarty, $arrFormElements);
                $oForm->setEditMode();
                $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8'));
                $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr('Edit Group') . " \"" . $arrFillGroup['group'] . "\"", $arrFillGroup);
            }
        } else {
            if (isset($_POST['submit_save_group'])) {
                include_once "libs/paloSantoForm.class.php";
                $oForm = new paloForm($smarty, $arrFormElements);
                if ($oForm->validateForm($_POST)) {
                    // Exito, puedo procesar los datos ahora.
                    $pACL = new paloACL($pDB);
                    // Creo el Grupo
                    $pACL->createGroup($_POST['group'], $_POST['description']);
                    if (!empty($pACL->errMsg)) {
                        // Ocurrio algun error aqui
                        $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}");
                        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST);
                    } else {
                        header("Location: ?menu=grouplist");
                    }
                } else {
                    // Error
                    $smarty->assign("mb_title", _tr("Validation Error"));
                    $arrErrores = $oForm->arrErroresValidacion;
                    $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>";
                    foreach ($arrErrores as $k => $v) {
                        $strErrorMsg .= "{$k}, ";
                    }
                    $strErrorMsg .= "";
                    $smarty->assign("mb_message", $strErrorMsg);
                    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("New Group"), $_POST);
                }
            } else {
                if (isset($_POST['submit_apply_changes'])) {
                    $arrGroup = $pACL->getGroups($_POST['id_group']);
                    if (!is_array($arrGroup)) {
                        $contenidoModulo = '';
                        Header("Location: ?menu={$module_name}");
                    } else {
                        $group = $arrGroup[0][1];
                        $description = $arrGroup[0][2];
                        include_once "libs/paloSantoForm.class.php";
                        $oForm = new paloForm($smarty, $arrFormElements);
                        $oForm->setEditMode();
                        if ($oForm->validateForm($_POST)) {
                            // Exito, puedo procesar los datos ahora.
                            $pACL = new paloACL($pDB);
                            if (!$pACL->updateGroup($_POST['id_group'], $_POST['group'], $_POST['description'])) {
                                // Ocurrio algun error aqui
                                $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}");
                                $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $_POST);
                            } else {
                                header("Location: ?menu=grouplist");
                            }
                        } else {
                            // Manejo de Error
                            $smarty->assign("mb_title", _tr("Validation Error"));
                            $arrErrores = $oForm->arrErroresValidacion;
                            $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br>";
                            foreach ($arrErrores as $k => $v) {
                                $strErrorMsg .= "{$k}, ";
                            }
                            $strErrorMsg .= "";
                            $smarty->assign("mb_message", $strErrorMsg);
                            $arrFillGroup['group'] = $_POST['group'];
                            $arrFillGroup['description'] = $_POST['description'];
                            $smarty->assign("id_group", htmlspecialchars($_POST['id_group'], ENT_COMPAT, 'UTF-8'));
                            $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("Edit Group"), $arrFillGroup);
                        }
                    }
                } else {
                    if (isset($_GET['action']) && $_GET['action'] == "view") {
                        include_once "libs/paloSantoForm.class.php";
                        $oForm = new paloForm($smarty, $arrFormElements);
                        //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error
                        $oForm->setViewMode();
                        // Esto es para activar el modo "preview"
                        $arrGroup = $pACL->getGroups($_GET['id']);
                        if (!is_array($arrGroup)) {
                            $contenidoModulo = '';
                            Header("Location: ?menu={$module_name}");
                        } else {
                            // Conversion de formato
                            if ($arrGroup[0][1] == 'administrator') {
                                $arrGroup[0][1] = _tr('administrator');
                            } else {
                                if ($arrGroup[0][1] == 'operator') {
                                    $arrGroup[0][1] = _tr('operator');
                                } else {
                                    if ($arrGroup[0][1] == 'extension') {
                                        $arrGroup[0][1] = _tr('extension');
                                    }
                                }
                            }
                            if ($arrGroup[0][2] == 'total access') {
                                $arrGroup[0][2] = _tr('total access');
                            } else {
                                if ($arrGroup[0][2] == 'operator') {
                                    $arrGroup[0][2] = _tr('operator');
                                } else {
                                    if ($arrGroup[0][2] == 'extension user') {
                                        $arrGroup[0][2] = _tr('extension user');
                                    }
                                }
                            }
                            $arrTmp['group'] = $arrGroup[0][1];
                            $arrTmp['description'] = $arrGroup[0][2];
                            $smarty->assign("id_group", htmlspecialchars($_GET['id'], ENT_COMPAT, 'UTF-8'));
                            $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/grouplist.tpl", _tr("View Group"), $arrTmp);
                            // hay que pasar el arreglo
                        }
                    } else {
                        if (isset($_POST['delete'])) {
                            //- TODO: Validar el id de group
                            if (isset($_POST['id_group']) && $_POST['id_group'] == '1') {
                                // No se puede eliminar al grupo admin
                                $smarty->assign("mb_message", _tr("The administrator group cannot be deleted because is the default Elastix Group. You can delete any other group."));
                            } else {
                                if ($pACL->HaveUsersTheGroup($_POST['id_group']) == TRUE) {
                                    $smarty->assign("mb_message", _tr("The Group have users assigned. You can delete any group that does not have any users assigned in it."));
                                } else {
                                    $pACL->deleteGroup($_POST['id_group']);
                                }
                            }
                        }
                        $nav = getParameter("nav");
                        $start = getParameter("start");
                        $total = $pACL->getNumGroups();
                        $total = $total == NULL ? 0 : $total;
                        $limit = 20;
                        $oGrid = new paloSantoGrid($smarty);
                        $oGrid->setLimit($limit);
                        $oGrid->setTotal($total);
                        $oGrid->pagingShow(true);
                        $oGrid->setURL("?menu=grouplist");
                        $offset = $oGrid->calculateOffset();
                        $end = $oGrid->getEnd();
                        $arrGroups = $pACL->getGroupsPaging($limit, $offset);
                        $end = count($arrGroups);
                        $arrData = array();
                        foreach ($arrGroups as $group) {
                            $arrTmp = array();
                            if ($group[1] == 'administrator') {
                                $group[1] = _tr('administrator');
                            } else {
                                if ($group[1] == 'operator') {
                                    $group[1] = _tr('operator');
                                } else {
                                    if ($group[1] == 'extension') {
                                        $group[1] = _tr('extension');
                                    }
                                }
                            }
                            if ($group[2] == 'total access') {
                                $group[2] = _tr('total access');
                            } else {
                                if ($group[2] == 'operator') {
                                    $group[2] = _tr('operator');
                                } else {
                                    if ($group[2] == 'extension user') {
                                        $group[2] = _tr('extension user');
                                    }
                                }
                            }
                            $arrTmp[0] = "&nbsp;<a href='?menu=grouplist&action=view&id=" . $group[0] . "'>" . $group[1] . "</a>";
                            //id_group   name
                            $arrTmp[1] = $group[2];
                            //description
                            $arrData[] = $arrTmp;
                        }
                        $arrGrid = array("title" => _tr("Group List"), "icon" => "/modules/{$module_name}/images/system_groups.png", "columns" => array(0 => array("name" => _tr("Group"), "property1" => ""), 1 => array("name" => _tr("Description"), "property1" => "")));
                        $oGrid->addNew("submit_create_group", _tr("Create New Group"));
                        $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData);
                    }
                }
            }
        }
    }
    return $contenidoModulo;
}
Beispiel #3
0
function reportGroupPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $arrGroups = array();
    $arrOrgz = array();
    $idOrgFil = getParameter("idOrganization");
    if ($credentials['userlevel'] == "superadmin") {
        $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'];
            }
        }
    } else {
        $idOrgFil = $credentials['id_organization'];
        $orgTmp = $pORGZ->getOrganizationById($idOrgFil);
        if ($orgTmp == false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("An error has ocurred to retrieved organization data"));
        } else {
            $arrOrgz = $orgTmp;
        }
    }
    if (count($arrOrgz) > 0) {
        //que se un arreglo y que tenga al menos una organizacion
        $groupTmp = $pACL->getGroupsPaging(null, null, $idOrgFil);
        if ($groupTmp === false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr($pACL->errMsg));
        } else {
            foreach ($groupTmp as $value) {
                $arrGroups[$value[0]] = $value[1];
            }
        }
    }
    $filter_group = getParameter("filter_group");
    if (count($arrGroups) > 0) {
        if (empty($filter_group)) {
            //seleccionamos el primer grupo de la lista de grupos
            $filter_group = $groupTmp[0][0];
        }
        //valido que el grupo pertenzca a la organizacion
        if ($pACL->getGroups($filter_group, $idOrgFil) == false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Invalid Group"));
            $filter_group = $groupTmp[0][0];
        }
    }
    $filter_resource = getParameter("filter_resource");
    $lang = get_language();
    if ($lang != "en") {
        if (isset($filter_resource)) {
            if (trim($filter_resource) != "") {
                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;
                        }
                    }
                }
            }
        }
    }
    if (isset($filter_resource)) {
        $parameter_to_find[] = $filter_resource;
    } else {
        $parameter_to_find = null;
    }
    $totalGroupPermission = 0;
    if (count($arrGroups) > 0) {
        $arrResourceOrg = $pACL->getResourcesByOrg($idOrgFil, $parameter_to_find);
        if ($arrResourceOrg === false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Resources"));
        } else {
            $totalGroupPermission = count($arrResourceOrg);
        }
    }
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $limit = 25;
    $total = $totalGroupPermission;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $url['menu'] = $module_name;
    $url['idOrganization'] = $idOrgFil;
    $url['filter_group'] = $filter_group;
    $url['filter_resource'] = $filter_resource;
    $arrData = $arrResourceActions = $arrPermisos = array();
    $error = false;
    if (count($arrGroups) > 0 && $totalGroupPermission > 0) {
        $arrResource = array_slice($arrResourceOrg, $offset, $limit);
        $idGroup = $filter_group;
        foreach ($arrResource as $resource) {
            $listResource[] = $resource['id'];
            //lista de id de los recursos que queremos consulta
            $listResDes[$resource['id']] = $resource['description'];
        }
        //las acciones que tiene cada drecurso
        $arrResourceActions = $pACL->getResourcesActions($listResource);
        if ($arrResourceActions === false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Resources Actions"));
            $error = true;
        }
        //los premisos que tiene el grupo
        $arrPermisos = $pACL->loadGroupPermissions($idGroup, $listResource);
        if ($arrPermisos === false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("An error has ocurred to retrieved Group Permissions"));
            $error = true;
        }
    }
    $max_actions = 0;
    $isAdministrator = $pACL->getGroupNameByid($idGroup) == _tr("administrator") ? true : false;
    if ($totalGroupPermission > 0 && !$error) {
        foreach ($arrResourceActions as $resource => $actions) {
            $arrTmp = array();
            $arrTmp[] = _tr($listResDes[$resource]);
            $disabled = "";
            if ($isAdministrator && ($resource == 'grouplist' || $resource == 'userlist' || $resource == 'group_permission')) {
                $disabled = "disabled='disabled'";
            }
            //dentro del modulo organizacion ahi acciones que unicamente las puede realizar el superadmin
            //por lo tando no deben aparecer listadas
            if ($resource == "organization") {
                $actions = array_diff($actions, array('change_org_status', 'create_org', 'delete_org', 'edit_DID'));
            } elseif ($resource == "dashboard") {
                $actions = array('access');
            } elseif ($resource == 'cdrreport') {
                $actions = array('access', 'export');
            }
            if (count($actions) > $max_actions) {
                $max_actions = count($actions);
            }
            $desactivar = false;
            if (isset($arrPermisos[$resource])) {
                //grupo no tiene nigun permiso
                if (!in_array('access', $arrPermisos[$resource])) {
                    $desactivar = true;
                }
            } else {
                $desactivar = true;
                $arrPermisos[$resource] = array();
            }
            foreach ($actions as $action) {
                $class = 'other_act';
                if ($action == 'access') {
                    $class = 'access_act';
                } elseif ($desactivar) {
                    $disabled = "disabled='disabled'";
                }
                $checked0 = '';
                //chequeamos si la accion se encuentra en la lista de acciones permitidas en el recurso
                if (in_array($action, $arrPermisos[$resource])) {
                    $checked0 = "checked";
                }
                $arrTmp[] = "<input type='checkbox' class='{$class}' {$disabled} name='groupPermission[" . $resource . "][{$action}]' {$checked0}> {$action}";
            }
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setTitle(_tr("Group Permission"));
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $arrColumn[] = _tr("Resource");
    for ($i = 1; $i <= $max_actions; $i++) {
        $act = _tr("Action");
        $arrColumn[] = "{$act}" . " {$i}";
    }
    $oGrid->setColumns($arrColumn);
    //begin section filter
    $arrFormFilter = createFieldFilter($arrGroups);
    $oFilterForm = new paloForm($smarty, $arrFormFilter);
    $smarty->assign("SHOW", _tr("Show"));
    $smarty->assign("limit_apply", htmlspecialchars($limit, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("offset_apply", htmlspecialchars($offset, ENT_COMPAT, 'UTF-8'));
    $smarty->assign("resource_apply", htmlentities($filter_resource));
    $_POST["filter_group"] = htmlspecialchars($filter_group, ENT_COMPAT, 'UTF-8');
    $_POST["filter_resource"] = htmlspecialchars($filter_resource, ENT_COMPAT, 'UTF-8');
    $_POST["idOrganization"] = $idOrgFil;
    if (count($arrOrgz) > 0) {
        global $arrPermission;
        if (in_array('edit_permission', $arrPermission)) {
            $oGrid->addSubmitAction("apply", _tr("Save"));
        }
        if ($credentials['userlevel'] == "superadmin") {
            $oGrid->addComboAction("idOrganization", _tr("Organization"), $arrOrgz, $idOrgFil, "report");
        }
        $nameGroup = isset($arrGroups[$filter_group]) ? $arrGroups[$filter_group] : "";
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Group") . " = {$nameGroup}", $_POST, array("filter_group" => $groupTmp[0][0]), true);
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Resource") . " = {$filter_resource}", $_POST, array("filter_resource" => ""));
        $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("You haven't created any organization"));
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    //end grid parameters
    return $contenidoModulo;
}
Beispiel #4
0
function getGroups(&$pDB, $arrCredentiasls)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $jsonObject = new PaloSantoJSON();
    $idOrgSel = getParameter("idOrganization");
    $arrGrupos = array();
    if ($idOrgSel == 0) {
        $arrGrupos = array();
    } else {
        if ($arrCredentiasls['userlevel'] != 'superadmin') {
            if ($idOrgSel != $arrCredentiasls['id_organization']) {
                $jsonObject->set_error("Invalid Action");
                $arrGrupos = array();
            }
        } else {
            $arrGrupos[0] = array("country_code", $pORGZ->getOrganizationProp($idOrgSel, "country_code"));
            $arrGrupos[1] = array("area_code", $pORGZ->getOrganizationProp($idOrgSel, "area_code"));
            $arrGrupos[2] = array("email_quota", $pORGZ->getOrganizationProp($idOrgSel, "email_quota"));
            $temp = $pACL->getGroupsPaging(null, null, $idOrgSel);
            if ($temp === false) {
                $jsonObject->set_error(_tr($pACL->errMsg));
            } else {
                $i = 3;
                foreach ($temp as $value) {
                    $arrGrupos[$i] = array($value[0], $value[1]);
                    $i++;
                }
            }
        }
    }
    $jsonObject->set_message($arrGrupos);
    return $jsonObject->createJSON();
}