示例#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;
}
示例#2
0
function applyOrgPermission($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentiasls)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $arrGroups = array();
    $arrOrgz = array();
    $idOrgFil = getParameter("idOrganization");
    $filter_resource = getParameter("resource_apply");
    $error = false;
    $orgTmp = $pORGZ->getOrganizationById($idOrgFil);
    //valido exista una organizacion con dicho id
    if ($orgTmp === false) {
        $error = true;
        $msg_error = _tr($pORGZ->errMsg);
    } elseif (count($orgTmp) == 0) {
        $error = true;
        $msg_error = _tr("Organization doesn't exist");
    }
    if ($idOrgFil == 1) {
        $error = true;
        $msg_error = _tr("Invalid Organization");
    }
    //obtenemos las traducciones del parametro filtrado
    $filter_resource = htmlentities($filter_resource);
    $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;
            }
        }
    }
    if (isset($filter_resource)) {
        $parameter_to_find[] = $filter_resource;
    } else {
        $parameter_to_find = null;
    }
    $pACL->_DB->beginTransaction();
    if (!$error) {
        $oGrid = new paloSantoGrid($smarty);
        $total = $pACL->getNumResources($parameter_to_find);
        $limit = 25;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $tmpResource = $pACL->getListResources($limit, $offset, $parameter_to_find, 'yes');
        //todos los recursos
        $tmpResourceOrg = $pACL->getResourcesByOrg($idOrgFil, $parameter_to_find);
        //los recuros a los que tiene permiso actualmente la organizacion
        if ($tmpResourceOrg === false || $tmpResource === false) {
            $error = true;
            $msg_error = $msg_error . "" . _tr($pACL->errMsg);
        } else {
            $arrPermissionAct = array();
            //los recursos seleccionados a los que se le va a dar acceso
            $selectedResource = isset($_POST['resource']) ? array_keys($_POST['resource']) : array();
            //validamos que los recursos seleccionados realmente existan
            foreach ($tmpResourceOrg as $value) {
                $arrPermissionAct[] = $value["id"];
            }
            $selectedResource[] = 'usermgr';
            $selectedResource[] = 'grouplist';
            $selectedResource[] = 'userlist';
            $selectedResource[] = 'group_permission';
            $selectedResource[] = 'organization';
            //hacemos una lista de los permisos que debemos eliminar y de los que debemos añadir
            $saveAcc = array_diff($selectedResource, $arrPermissionAct);
            //permisos que debemos añadir
            $delAcc = array_diff($arrPermissionAct, $selectedResource);
            //permisos que debemos eliminar
            $arrSave = array();
            $arrDelete = array();
            $arrSelected = array();
            //nos aseguramos que los recursos existan y cogemos los que se visualizan en el modulo al dar click en save
            foreach ($tmpResource as $resource) {
                if (in_array($resource["id"], $saveAcc)) {
                    $arrSave[] = $resource["id"];
                }
                if (in_array($resource["id"], $delAcc)) {
                    $arrDelete[] = $resource["id"];
                }
                if (in_array($resource["id"], $selectedResource)) {
                    $arrSelected[] = $resource["id"];
                }
            }
            if (!$pACL->saveOrgPermission($idOrgFil, $arrSave) || !$pACL->deleteOrgPermissions($idOrgFil, $arrDelete)) {
                $error = true;
                $msg_error = _tr($pACL->errMsg);
            }
        }
    }
    //verificamos si todo salio bien
    if ($error) {
        $pACL->_DB->rollBAck();
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Error saving changes.") . " " . $msg_error);
    } else {
        $pACL->_DB->commit();
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("Changes were applied successfully"));
    }
    unset($_SESSION['elastix_user_permission']);
    return reportOrgPermission($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls);
}
示例#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;
}
示例#4
0
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[] = "&nbsp;<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[] = "&nbsp;<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;
}
示例#5
0
function viewFormOrganization($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $pOrganization = new paloSantoOrganization($pDB);
    $pACL = new paloACL($pDB);
    $dataOrgz = false;
    $arrFill = $_POST;
    $action = getParameter("action");
    $id = getParameter("id");
    $check_e = isset($_POST["max_num_exten_chk"]) ? "checked" : "";
    $check_q = isset($_POST["max_num_queues_chk"]) ? "checked" : "";
    $check_u = isset($_POST["max_num_user_chk"]) ? "checked" : "";
    $smarty->assign("edit_entity", 0);
    if ($action == "view" || getParameter("edit") || getParameter("save_edit")) {
        if ($id == "1") {
            //no se puede editar ni observar la organizacion principal
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Invalid ID Organization"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        if ($credentials['userlevel'] != "superadmin" && $id != $credentials['id_organization']) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Invalid Organization"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        $dataOrgz = $pOrganization->getOrganizationById($id);
        if (is_array($dataOrgz) & count($dataOrgz) > 0) {
            $num_exten = $pOrganization->getOrganizationProp($id, "max_num_exten");
            $num_queues = $pOrganization->getOrganizationProp($id, "max_num_queues");
            $num_users = $pOrganization->getOrganizationProp($id, "max_num_user");
            if ($credentials['userlevel'] != "superadmin") {
                $check_e = empty($num_exten) ? _tr("unlimited") : $num_exten;
                $check_q = empty($num_queues) ? _tr("unlimited") : $num_queues;
                $check_u = empty($num_users) ? _tr("unlimited") : $num_users;
            }
            if (!getParameter("save_edit")) {
                $arrFill['name'] = $dataOrgz['name'];
                $arrFill['country'] = $dataOrgz['country'];
                $arrFill['city'] = $dataOrgz['city'];
                $arrFill['address'] = $dataOrgz['address'];
                $arrFill['email_contact'] = $dataOrgz['email_contact'];
                $arrFill['country_code'] = $pOrganization->getOrganizationProp($id, "country_code");
                $arrFill['area_code'] = $pOrganization->getOrganizationProp($id, "area_code");
                $arrFill['quota'] = $pOrganization->getOrganizationProp($id, "email_quota");
                $arrFill['domain'] = $dataOrgz['domain'];
                if ($credentials['userlevel'] == "superadmin") {
                    if (empty($num_exten)) {
                        $check_e = "checked";
                    } else {
                        $check_e = "";
                        $arrFill["max_num_exten"] = $num_exten;
                    }
                    if (empty($num_queues)) {
                        $check_q = "checked";
                    } else {
                        $check_q = "";
                        $arrFill["max_num_queues"] = $num_queues;
                    }
                    if (empty($num_users)) {
                        $check_u = "checked";
                    } else {
                        $check_u = "";
                        $arrFill["max_num_user"] = $num_users;
                    }
                }
            }
            $smarty->assign("domain_name", $dataOrgz['domain']);
        } else {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("An error has ocurred to try retrieve organization data"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    } else {
        //solo el superadmin tiene permitido crear organizaciones
        if ($credentials['userlevel'] != "superadmin") {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("You are not authorized to perform this action"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        if (getParameter("new_organization")) {
            $arrFill['quota'] = 30;
            $check_e = "checked";
            $check_u = "checked";
            $check_q = "checked";
        }
    }
    $smarty->assign("ID", $id);
    //persistence id with input hidden in tpl
    $smarty->assign("ORG_RESTRINCTION", _tr("Organization Limits"));
    $smarty->assign("UNLIMITED", _tr("unlimited"));
    $smarty->assign("CHECK_U", $check_u);
    $smarty->assign("CHECK_E", $check_e);
    $smarty->assign("CHECK_Q", $check_q);
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("APLICAR_CAMBIOS", _tr("Apply Changes"));
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("DELETE", _tr("Delete"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?"));
    // $smarty->assign("icon", "web/apps/organizaciones/images/organization.png");
    //variable usadas en el tpl
    //estas acciones solosp pueden ser realizadas por el susperadmin
    global $arrPermission;
    if ($credentials['userlevel'] == "superadmin") {
        if (in_array('create_org', $arrPermission)) {
            $smarty->assign('CREATE_ORG', TRUE);
        }
        if (in_array('delete_org', $arrPermission)) {
            $smarty->assign('DELETE_ORG', TRUE);
        }
    }
    if (in_array('edit_org', $arrPermission)) {
        $smarty->assign('EDIT_ORG', TRUE);
    }
    $arrFormOrgz = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormOrgz);
    if ($action == "view") {
        $oForm->setViewMode();
        $smarty->assign("edit_entity", 1);
    } else {
        if (getParameter("edit") || getParameter("save_edit")) {
            $oForm->setEditMode();
            $smarty->assign("edit_entity", 1);
        }
    }
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Organization"), $arrFill);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
示例#6
0
function listarFaxes(&$smarty, $module_name, $local_templates_dir, $pDB, $credentials)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $smarty->assign(array('SEARCH' => _tr('Search')));
    $smarty->assign('USERLEVEL', $credentials['userlevel']);
    $arrOrgz = array(0 => "all");
    $organization = getParameter('organization');
    if ($credentials['userlevel'] == 'superadmin') {
        if (empty($organization)) {
            $organization = 0;
        }
        if ($pORGZ->getNumOrganization(array()) > 0) {
            foreach ($pORGZ->getOrganization(array()) as $value) {
                $arrOrgz[$value["id"]] = $value["name"];
            }
        }
    } else {
        $tmpOrg = $pORGZ->getOrganizationById($credentials['id_organization']);
        $arrOrgz[$tmpOrg["id"]] = $tmpOrg['name'];
        $organization = $credentials['id_organization'];
    }
    $oFax = new paloFaxVisor($pDB);
    // Generación del filtro
    $oFilterForm = new paloForm($smarty, getFormElements($arrOrgz));
    // Parámetros base y validación de parámetros
    $url = array('menu' => $module_name);
    $paramFiltroBase = $paramFiltro = array('name_company' => '', 'fax_company' => '', 'date_fax' => NULL, 'filter' => 'All');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    $arrType = array("All" => _tr('All'), "In" => _tr('in'), "Out" => _tr('out'));
    if ($credentials['userlevel'] == 'superadmin') {
        $_POST["organization"] = $organization;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$organization], $_POST, array("organization" => 0), true);
        //organization
    }
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Name") . " = " . $paramFiltro['name_company'], $paramFiltro, array("name_company" => ""));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Company Fax") . " = " . $paramFiltro['fax_company'], $paramFiltro, array("fax_company" => ""));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Fax Date") . " = " . $paramFiltro['date_fax'], $paramFiltro, array("date_fax" => NULL));
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type Fax") . " = " . $arrType[$paramFiltro['filter']], $paramFiltro, array("filter" => "All"), true);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    if (!$oFilterForm->validateForm($paramFiltro)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $paramFiltro = $paramFiltroBase;
    }
    $url = array_merge($url, $paramFiltro);
    $oGrid->setTitle(_tr("Fax Viewer"));
    $oGrid->setIcon("web/apps/{$module_name}/images/kfaxview.png");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->setURL($url);
    $arrData = NULL;
    if ($organization == 0) {
        $total = $oFax->obtener_cantidad_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']);
    } else {
        $total = $oFax->obtener_cantidad_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $paramFiltro['filter']);
    }
    if ($total === false) {
        $total = 0;
        $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
    }
    $delete = in_array('delete_fax', $arrPermission);
    $edit = in_array('edit_fax', $arrPermission);
    $limit = 20;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    if ($delete) {
        $columns[] = "<input type='checkbox' class='checkall'/>";
    }
    if ($credentials['userlevel'] == 'superadmin') {
        $columns[] = _tr('Organization');
    }
    $columns[] = _tr('Type');
    $columns[] = _tr('File');
    $columns[] = _tr('Fax Cid Name');
    $columns[] = _tr('Fax Cid Number');
    $columns[] = _tr('Fax Destiny');
    $columns[] = _tr('Fax Date');
    $columns[] = _tr('Status');
    if ($edit) {
        $columns[] = _tr('Options');
    }
    $oGrid->setColumns($columns);
    if ($total > 0) {
        if ($organization == 0) {
            $arrResult = $oFax->obtener_faxes(null, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']);
        } else {
            $arrResult = $oFax->obtener_faxes($organization, $paramFiltro['name_company'], $paramFiltro['fax_company'], $paramFiltro['date_fax'], $offset, $limit, $paramFiltro['filter']);
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
        } else {
            foreach ($arrResult as $fax) {
                foreach (array('pdf_file', 'company_name', 'company_fax', 'destiny_name', 'destiny_fax') as $k) {
                    $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, 'UTF-8');
                }
                $doc = explode(".", $fax['pdf_file']);
                $iddoc = $doc[0];
                $arrTmp = array();
                if ($delete) {
                    $arrTmp[] = '<input type="checkbox" name="faxes[]" value="' . $fax['id'] . '" />';
                }
                if ($credentials['userlevel'] == 'superadmin') {
                    $arrTmp[] = 'ttt';
                }
                //$arrOrg[$fax['id_organization']];
                $arrTmp[] = _tr($fax['type']);
                $arrTmp[] = strtolower($fax['type']) == 'in' || strpos($fax['pdf_file'], '.pdf') !== FALSE ? "<a href='?menu={$module_name}&action=download&id=" . $fax['id'] . "&rawmode=yes'>" . $fax['pdf_file'] . "</a>" : $fax['pdf_file'];
                $arrTmp[] = $fax['company_name'];
                $arrTmp[] = $fax['company_fax'];
                $arrTmp[] = $fax['destiny_name'] . " - " . $fax['destiny_fax'];
                $arrTmp[] = $fax['date'];
                $arrTmp[] = _tr($fax['status']) . (empty($fax['errormsg']) ? '' : ': ' . $fax['errormsg']);
                if ($edit) {
                    $arrTmp[] = "<a href='?menu={$module_name}&action=edit&id=" . $fax['id'] . "'>" . _tr('Edit') . "</a>";
                }
                $arrData[] = $arrTmp;
            }
        }
    }
    $oGrid->setData($arrData);
    if ($delete) {
        $oGrid->deleteList(_tr('Are you sure you wish to delete fax (es)?'), "faxes_delete", _tr("Delete"));
    }
    $oGrid->showFilter($htmlFilter);
    return $oGrid->fetchGrid();
}