Exemplo n.º 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;
}
Exemplo n.º 2
0
function reportOtherDestinations($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $other_destination_name = getParameter("other_destination_name");
    $pOtherDestinations = new paloSantoOtherDestinations($pDB, $domain);
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['other_destination_name'] = $other_destination_name;
    $total = $pOtherDestinations->getNumOtherDestinations($domain, $other_destination_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pOtherDestinations->errMsg;
        $total = 0;
    }
    $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('Other Destinations List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Other Destination Name");
    $arrColum[] = _tr("Dial Destination");
    $oGrid->setColumns($arrColum);
    $arrOtherDestinations = array();
    $arrData = array();
    if ($total != 0) {
        $arrOtherDestinations = $pOtherDestinations->getOtherDestinations($domain, $other_destination_name, $limit, $offset);
    }
    if ($arrOtherDestinations === false) {
        $error = _tr("Error to obtain Other Destinations") . $pOtherDestinations->errMsg;
        $arrOtherDestinations = array();
    }
    foreach ($arrOtherDestinations as $row) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$row["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id=" . $row['id'] . "&organization={$row['organization_domain']}'>" . htmlentities($row["description"], ENT_QUOTES, "UTF-8") . "</a>";
        $arrTmp[] = $row["destdial"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Other Destination"), array_slice($arrOrgz, 1), $selected = null, "create_other_destination", $onchange_select = null);
            } else {
                $oGrid->addNew("create_other_destination", _tr("ADD Other Destination"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["other_destination_name"] = $other_destination_name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Other Destination Name") . " = " . $other_destination_name, $_POST, array("other_destination_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Exemplo n.º 3
0
function reportMoH($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $name = getParameter("name");
    if ($credentials['userlevel'] == "superadmin") {
        $domain = getParameter("organization");
        $domain = empty($domain) ? 'all' : $domain;
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $arrOrgz = array();
        $domain = $credentials['domain'];
    }
    $url["menu"] = $module_name;
    $url["organization"] = $domain;
    $url["name"] = $name;
    $pMoH = new paloSantoMoH($pDB, $domain);
    $total = $pMoH->getNumMoH($domain, $name);
    if ($total === false) {
        $error = $pMoH->errMsg;
        $total = 0;
    }
    $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('MoH Class List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Name");
    $arrColum[] = _tr("Type");
    $arrColum[] = _tr("Sort");
    $arrColum[] = _tr("Directory");
    $arrColum[] = _tr("Aplication");
    $oGrid->setColumns($arrColum);
    $arrMoH = array();
    $arrData = array();
    if ($total != 0) {
        $arrMoH = $pMoH->getMoHs($domain, $name, $limit, $offset);
    }
    if ($arrMoH === false) {
        $error = _tr("Error to obtain MoH Class") . $pMoH->errMsg;
        $arrMoH = array();
    }
    $arrData = array();
    foreach ($arrMoH as $moh) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            if (empty($moh["organization_domain"])) {
                $arrTmp[] = "";
                $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>";
            } else {
                $arrTmp[] = $arrOrgz[$moh["organization_domain"]];
                $arrTmp[] = $moh["description"];
            }
        } else {
            $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id_moh=" . $moh["name"] . "'>" . $moh["description"] . "</a>";
        }
        $arrTmp[] = $moh["mode"];
        $arrTmp[] = $moh["sort"];
        $arrTmp[] = $moh["directory"];
        $arrTmp[] = $moh["application"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if (in_array("create", $arrPermission)) {
        $oGrid->addNew("create_moh", _tr("Create New Class MoH"));
    }
    if ($credentials['userlevel'] == "superadmin") {
        $_POST["organization"] = $domain;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
    }
    $_POST["name"] = $name;
    // name
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => ""));
    $arrFormElements = createFieldFilter($arrOrgz);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    return $contenidoModulo;
}
Exemplo n.º 4
0
function reportANI($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $smarty->assign("SHOW_DIV_ERROR", "0");
    //FIXED: can show div error message with javascript
    $smarty->assign("mb_message", "hide");
    //FIXED: can show div error message with javascript
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $ani_prefix = getParameter("ani_prefix");
    $pANI = new paloSantoANI($pDB, $domain);
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['ani_prefix'] = $ani_prefix;
    $total = $pANI->getNumANI($domain, $ani_prefix);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pANI->errMsg;
        $total = 0;
    }
    $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('ANI List'));
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Trunk Name");
    $arrColum[] = _tr("Prefix ANI");
    $oGrid->setColumns($arrColum);
    $arrANI = array();
    $arrData = array();
    if ($total != 0) {
        $arrANI = $pANI->getANI($domain, $ani_prefix, $limit, $offset);
    }
    if ($arrANI === false) {
        $error = _tr("Error to obtain ANI") . $pANI->errMsg;
        $arrANI = array();
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
        $smarty->assign("SHOW_DIV_ERROR", "1");
    }
    foreach ($arrANI as $row) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$row["organization_domain"]];
        }
        $arrTmp[] = $row["name"];
        $arrTmp[] = "<input type='text' style='width:60px; text-align:center;' id='text#{$row['organization_domain']}#{$row['trunkid']}' value='{$row['ani_prefix']}' />&nbsp;&nbsp;\n                     <input type='button' id='button#{$row['organization_domain']}#{$row['trunkid']}' value='" . _tr("Save") . "' />";
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) == 0) {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", _tr("It's necesary you create at least one organization so you can use this module"));
        $smarty->assign("SHOW_DIV_ERROR", "1");
    }
    if ($credentials['userlevel'] == 'superadmin') {
        $_POST["organization"] = $domain;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
    }
    $_POST["ani_prefix"] = $ani_prefix;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("ANI Prefix") . " = " . $ani_prefix, $_POST, array("ani_prefix" => ""));
    $arrFormElements = createFieldFilter($arrOrgz);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    return $oGrid->fetchGrid(array(), $arrData);
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
function reportQueue($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $queue_name = getParameter("queue_name");
    $pQueue = new paloQueuePBX($pDB, $domain);
    $queue_number = getParameter("queue_number");
    if (isset($queue_number) && $queue_number != '') {
        $expression = $pQueue->getRegexPatternFromAsteriskPattern($queue_number);
        if ($expression === false) {
            $queue_number = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['queue_number'] = $queue_number;
    //queue_number
    $url['queue_name'] = $queue_name;
    //queue_name
    $total = $pQueue->getTotalQueues($domain, $queue_number, $queue_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pQueue->errMsg;
        $total = 0;
    }
    $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('Queues List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    if ($credentials['userlevel'] == 'superadmin') {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Queue Number");
    $arrColumns[] = _tr("Queue Name");
    $arrColumns[] = _tr("Password");
    $arrColumns[] = _tr("Record Call");
    $arrColumns[] = _tr("Strategy");
    $arrColumns[] = _tr("Timeout Queue");
    $arrColumns[] = _tr("Timeout Agent");
    $oGrid->setColumns($arrColumns);
    $arrData = array();
    $arrQueues = array();
    if ($total != 0) {
        $arrQueues = $pQueue->getQueues($domain, $queue_number, $queue_name, $limit, $offset);
    }
    if ($arrQueues === false) {
        $error = _tr("Error getting queue data. ") . $pQueue->errMsg;
    } else {
        foreach ($arrQueues as $queue) {
            $arrTmp = array();
            if ($credentials['userlevel'] == 'superadmin') {
                $arrTmp[] = $arrOrgz[$queue['organization_domain']];
            }
            $queunumber = $queue["queue_number"];
            $arrTmp[] = "&nbsp;<a href='?menu=queues&action=view&qname=" . $queue['name'] . "&organization={$queue['organization_domain']}'>" . $queunumber . "</a>";
            $arrTmp[] = htmlentities($queue["description"], ENT_QUOTES, "UTF-8");
            $arrTmp[] = $queue["password_detail"];
            $arrTmp[] = isset($queue["monitor_format"]) ? "yes" : "no";
            $arrTmp[] = $queue["strategy"];
            $arrTmp[] = $queue["timeout_detail"] == "0" ? "unlimited" : $queue["timeout_detail"];
            $arrTmp[] = $queue["timeout"];
            /*$result=getInfoQueue();
              $arrTmp[6]=$result["logged"];
              $arrTmp[6]=$result["free"];*/
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New Queue"), array_slice($arrOrgz, 1), $selected = null, "create_queue", $onchange_select = null);
            } else {
                $oGrid->addNew("create_queue", _tr("Create New Queue"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["queue_number"] = $queue_number;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Number") . " = " . $queue_number, $_POST, array("queue_number" => ""));
        $_POST["queue_name"] = $queue_name;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Queue Name") . " = " . $queue_name, $_POST, array("queue_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Exemplo n.º 7
0
function reportExten($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pExten = new paloSantoExtensions($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $error = '';
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $extension = getParameter("extension");
    if (isset($extension) && $extension != '') {
        $pPBX = new paloAsteriskDB($pDB);
        $expression = $pPBX->getRegexPatternFromAsteriskPattern($extension);
        if ($expression === false) {
            $extension = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['extension'] = $extension;
    $total = $pExten->getNumExtensions($domain, $extension);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pExten->errMsg;
        $total = 0;
    }
    $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('Extensions List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Extension");
    $arrColum[] = _tr("Caller ID");
    $arrColum[] = _tr("Technology");
    $arrColum[] = _tr("Device");
    $arrColum[] = _tr("Context");
    $arrColum[] = _tr("User");
    $arrColum[] = _tr("Voicemail");
    $arrColum[] = _tr("Recording In") . " / " . _tr("Recording Out");
    $oGrid->setColumns($arrColum);
    $arrExtens = array();
    $arrData = array();
    if ($total != 0) {
        $arrExtens = $pExten->getExtensions($domain, $extension, $limit, $offset);
    }
    if ($arrExtens === false) {
        $error = _tr("Error to obtain extensions") . $pExten->errMsg;
        $arrExtens = array();
    } else {
        foreach ($arrExtens as $exten) {
            $arrTmp = array();
            if ($credentials['userlevel'] == "superadmin") {
                $arrTmp[] = $arrOrgz[$exten["organization_domain"]];
            }
            $arrTmp[] = "&nbsp;<a href='?menu=extensions&action=view&id_exten=" . $exten['id'] . "&organization={$exten['organization_domain']}'>" . $exten["exten"] . "</a>";
            $arrTmp[] = $exten['clid_name'] . " <{$exten['clid_number']}>";
            $arrTmp[] = strtoupper($exten['tech']);
            $arrTmp[] = $exten['device'];
            $arrTmp[] = $exten['context'];
            $query = "Select username from acl_user where extension=? and id_group in (select g.id from acl_group g join organization o on g.id_organization=o.id where o.domain=?)";
            $result = $pDB->getFirstRowQuery($query, false, array($exten["exten"], $exten["organization_domain"]));
            if ($result != false) {
                $arrTmp[] = $result[0];
            } else {
                $arrTmp[] = _tr("Nobody");
            }
            if (isset($exten["voicemail"])) {
                if ($exten["voicemail"] != "novm") {
                    $arrTmp[] = "yes";
                } else {
                    $arrTmp[] = "no";
                }
            } else {
                $arrTmp[] = "no";
            }
            $arrTmp[] = _tr($exten["record_in"]) . " / " . _tr($exten["record_out"]);
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New Extension"), array_slice($arrOrgz, 1), $selected = null, "create_exten", $onchange_select = null);
            } else {
                $oGrid->addNew("create_exten", _tr("Create New Extension"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["extension"] = $extension;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Extension") . " = " . $extension, $_POST, array("extension" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Exemplo n.º 8
0
function showCallers($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $success = false;
    $id_conf = getParameter("id_conf");
    $domain = getParameter('organization');
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $pConf = new paloConference($pDB, $domain);
    $conference = $pConf->getConferenceById($id_conf);
    if ($conference == false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $pConf->errMsg);
        return reportConference($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        $date = time();
        if ($date >= strtotime($conference["startTime"]) && $date <= strtotime($conference["endtime"]) || $conference["startTime"] == "1900-01-01 12:00:00") {
            $room = $conference["confno"];
            $total = $conference["members"];
        } else {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Conference out of Time"));
            return reportConference($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    }
    $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('Conference') . ": {$conference['name']} ({$conference['ext_conf']})");
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url = "?menu={$module_name}&action=current_conf&id_conf={$id_conf}");
    //permission
    $invite_part = in_array("admin_conference_participant", $arrPermission);
    $arrColum = array();
    $arrColum[] = _tr("Orden Join");
    $arrColum[] = _tr("CallerId");
    $arrColum[] = _tr("Time in Conference");
    $arrColum[] = _tr("Mode");
    if ($invite_part) {
        $arrColum[] = "<input type='button' name='mute_caller' value=" . _tr("Mute") . " class='button' onclick='javascript:muteCaller()'/>";
        $msgKill = _tr("Are you sure you wish to Kick all caller (s)?");
        $arrColum[] = "<input type='button' name='kick_caller' value=" . _tr("Kick") . " class='button' onclick=\"javascript:kickCaller('{$msgKill}');\"/>";
    }
    $oGrid->setColumns($arrColum);
    $arrData = array();
    $arrMemb = array();
    if ($total != 0) {
        $arrMemb = $pConf->ObtainCallers($room);
    }
    $session = getSession();
    if ($arrMemb === false) {
        $error = _tr("Error getting conference data.") . $pConf->errMsg;
    } else {
        $membPagg = array_slice($arrMemb, $offset, $limit);
        foreach ($membPagg as $memb) {
            $arrTmp = array();
            $arrTmp[0] = $memb['userId'];
            $arrTmp[1] = trim($memb['callerId']);
            $arrTmp[2] = $memb['duration'];
            $arrTmp[3] = empty($memb['mode']) ? "user" : "admin";
            if ($invite_part) {
                $status = strstr($memb['status'], "Muted");
                //falso si no encuentra la palabra en el arreglo
                $checked = empty($status) ? "" : "checked";
                $arrTmp[4] = "<input type='checkbox' name=mute_{$memb['userId']} class='conf_mute' {$checked}>";
                $arrTmp[5] = "<input type='checkbox' name=kick_{$memb['userId']} class='conf_kick'>";
            }
            $arrData[] = $arrTmp;
            //se usa para comprobar si ha habido cambios en el estado de las conferencias
            $session['conference']["current_conf"][$memb['userId']] = $memb['callerId'];
        }
    }
    //se escribe en session el estado actual de las conferencias
    if (!isset($session['conference']["current_conf"])) {
        $session['conference']["current_conf"] = array();
    }
    putSession($session);
    //filters
    $extens = $pConf->getAllDevice($domain);
    $arrExten = array("" => "--unselected--");
    if ($extens != false) {
        $astMang = AsteriskManagerConnect($errorM);
        $result = $pConf->getCodeByDomain($domain);
        foreach ($extens as $value) {
            $cidname = "";
            if ($astMang != false && $result != false) {
                $cidname = $astMang->database_get("EXTUSER/" . $result["code"] . "/" . $value["exten"], "cidname");
            }
            $arrExten[$value["dial"]] = isset($cidname) ? $cidname . " <{$value["exten"]}>" : $value["exten"] . " ({$value["dial"]})";
        }
    }
    if ($invite_part) {
        $oGrid->addComboAction("invite_caller", _tr("Invite Caller"), $arrExten, "Invite Caller to Conference", "invite_caller", "javascript:inviteCaller()");
        $oGrid->addButtonAction("kick_all", $alt = "Kick All Callers", "../web/_common/images/delete5.png", "javascript:kickAll('{$msgKill}')");
        $oGrid->addButtonAction("mute_all", $alt = "Mute All Callers", null, "javascript:muteAll()");
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $contenidoModulo .= "<input type='hidden' name='id_conf' id='id_conf' value='{$id_conf}'>";
    $contenidoModulo .= "<input type='hidden' name='organization' id='organization' value='{$domain}'>";
    $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>";
    $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>";
    $contenidoModulo .= "<input type='hidden' name='conf_action' id='conf_action' value='showCallers'>";
    return $contenidoModulo;
}
Exemplo n.º 9
0
function reportIVR($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $name = getParameter("name");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials['domain'];
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    if ($credentials['userlevel'] == "superadmin") {
        if (isset($domain) && $domain != "all") {
            $pIVR = new paloIvrPBX($pDB, $domain);
        } else {
            $pIVR = new paloIvrPBX($pDB, "");
        }
        $total = $pIVR->getTotalIvr($domain, $name);
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $arrOrgz = array();
        $pIVR = new paloIvrPBX($pDB, $domain);
        $total = $pIVR->getTotalIvr($domain, $name);
    }
    if ($total === false) {
        $error = $pIVR->errMsg;
        $total = 0;
    }
    $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('Ivrs List'));
    $oGrid->setUrl($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    if ($credentials['userlevel'] == "superadmin") {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Ivr Name");
    $arrColumns[] = _tr("Timeout");
    $arrColumns[] = _tr("Enable Call Extensions");
    $arrColumns[] = _tr("# Loops");
    $oGrid->setColumns($arrColumns);
    $arrData = array();
    $arrIVR = array();
    if ($total != 0) {
        $arrIVR = $pIVR->getIvrs($domain, $name, $limit, $offset);
    }
    if ($arrIVR === false) {
        $error = _tr("Error getting ivr data.") . $pIVR->errMsg;
    } else {
        foreach ($arrIVR as $ivr) {
            $arrTmp = array();
            if ($credentials['userlevel'] == "superadmin") {
                $arrTmp[] = $arrOrgz[$ivr['organization_domain']];
            }
            $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=view&id_ivr=" . $ivr['id'] . "&organization={$ivr["organization_domain"]}'>" . htmlentities($ivr["name"], ENT_QUOTES, "UTF-8") . "</a>";
            $arrTmp[] = $ivr["timeout"];
            $arrTmp[] = $ivr["directdial"];
            $arrTmp[] = $ivr["loops"];
            $arrData[] = $arrTmp;
        }
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("Create New IVR"), array_slice($arrOrgz, 1), $selected = null, "create_ivr", $onchange_select = null);
            } else {
                $oGrid->addNew("create_ivr", _tr("Create New IVR"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => _tr("all")), true);
        }
        $_POST["name"] = $name;
        //ivr name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
function reportDIDorganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials)
{
    $pORGZ = new paloSantoOrganization($pDB);
    $pDID = new paloDidPBX($pDB);
    $domain = getParameter('domain');
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    if (!preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $domain)) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("Invalid domain format"));
        return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $total = $pDID->getTotalDID($domain);
    if ($total === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data"));
        return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    }
    $limit = 20;
    $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['domain'] = $domain;
    $oGrid->setTitle(_tr('DID Organization List'));
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    if ($credentials['userlevel'] == "superadmin") {
        $arrColumns[] = '';
        $arrColumns[] = _tr("Organization Domain");
    }
    $arrColumns[] = _tr("DID");
    $arrColumns[] = _tr("Type");
    $arrColumns[] = _tr("Country");
    $arrColumns[] = _tr("City");
    $arrColumns[] = _tr("Country Code / Area Code");
    $oGrid->setColumns($arrColumns);
    $arrData = array();
    $arrDID = $pDID->getDIDs($domain, null, null, null, $limit, $offset);
    if ($arrDID === false) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", _tr("An error has ocurred to retrieve DID data"));
        return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
    } else {
        //si es un usuario solo se ve su didsion
        //si es un administrador ve todas las didsiones
        foreach ($arrDID as $did) {
            $arrTmp = array();
            if ($credentials["userlevel"] == "superadmin") {
                $arrTmp[] = "<input type='checkbox' name='dids[]' value='{$did['id']}' />";
                $arrTmp[] = $did["organization_domain"];
            }
            $arrTmp[] = $did['did'];
            $arrTmp[] = $did["type"];
            $arrTmp[] = $did["country"];
            $arrTmp[] = $did["city"];
            $arrTmp[] = $did["country_code"] . " / " . $did["area_code"];
            $arrData[] = $arrTmp;
        }
    }
    if ($credentials['userlevel'] == "superadmin") {
        $oGrid->addNew("assignDIDs", _tr("Add DID"));
        $oGrid->deleteList(_tr('Are you sure you wish REMOVE this DID from organization'), 'removeDID', "Remove DID");
    }
    $content = $oGrid->fetchGrid(array(), $arrData);
    return $content;
}
Exemplo n.º 12
0
function reportTrunks($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pTrunk = new paloSantoTrunk($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $error = "";
    $domain = getParameter("organization");
    $technology = getParameter("technology");
    $status = getParameter("status");
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['technology'] = $technology;
    $url['status'] = $status;
    $total = $pTrunk->getNumTrunks($domain, $technology, $status);
    if ($total === false) {
        $error = $pTrunk->errMsg;
        $total = 0;
    }
    $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('Trunks List'));
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum[] = _tr("Name");
    $arrColum[] = _tr("Technology");
    $arrColum[] = _tr("Channel / Peer|[User]");
    $arrColum[] = _tr("Max. Channels");
    $arrColum[] = _tr("Current # of calls by period");
    $arrColum[] = _tr("Status");
    $oGrid->setColumns($arrColum);
    $edit = in_array('edit', $arrPermission);
    $arrData = array();
    if ($total != 0) {
        $arrTrunks = $pTrunk->getTrunks($domain, $technology, $status, $limit, $offset);
        if ($arrTrunks === false) {
            $error = _tr("Error to obtain trunks") . $pTrunk->errMsg;
            $arrTrunks = array();
        }
        foreach ($arrTrunks as $trunk) {
            $arrTmp[0] = "&nbsp;<a href='?menu=trunks&action=view&id_trunk=" . $trunk['trunkid'] . "&tech_trunk=" . $trunk["tech"] . "'>" . $trunk['name'] . "</a>";
            $arrTmp[1] = strtoupper($trunk['tech']);
            $arrTmp[2] = $trunk['channelid'];
            $arrTmp[3] = $trunk['maxchans'];
            $state = "";
            if ($trunk['sec_call_time'] == "yes") {
                $arrTmp[4] = createDivToolTip($trunk['trunkid'], $pTrunk, $state);
            } else {
                $arrTmp[4] = _tr("Feature don't Set");
            }
            if ($trunk['disabled'] == "on" || $state == "YES") {
                $disabled = "on";
            } else {
                $disabled = "off";
            }
            if ($edit) {
                $arrTmp[5] = createSelect($trunk['trunkid'], $disabled);
            } else {
                $arrTmp[5] = $disabled == 'on' ? _tr('Disabled') : _tr('Enabled');
            }
            $arrData[] = $arrTmp;
        }
    }
    if (in_array('create', $arrPermission)) {
        $arrTech = array("sip" => _tr("SIP"), "dahdi" => _tr("DAHDI"), "iax2" => _tr("IAX2"), "custom" => _tr("CUSTOM"));
        $oGrid->addComboAction($name_select = "tech_trunk", _tr("Create New Trunk"), $arrTech, $selected = null, $task = "create_trunk", $onchange_select = null);
    }
    $arrOrgz = array("" => _tr("all"));
    foreach ($pORGZ->getOrganization(array()) as $value) {
        $arrOrgz[$value["domain"]] = $value["name"];
    }
    $_POST["organization"] = $domain;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization Allow") . " = " . $arrOrgz[$domain], $_POST, array("organization" => ""), true);
    //organization allow
    $techFilter = array('' => _tr('All'), "sip" => _tr("SIP"), "dahdi" => _tr("DAHDI"), "iax2" => _tr("IAX2"), "custom" => _tr("CUSTOM"));
    $_POST["technology"] = $technology;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Type") . " = " . $techFilter[$technology], $_POST, array("technology" => ""), true);
    //technology
    $arrStatus = array('' => '', 'off' => _tr('Enabled'), 'on' => _tr('Disabled'));
    $_POST["status"] = $status;
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Status") . " = " . $arrStatus[$status], $_POST, array("status" => ""), true);
    //status
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='search'>");
    $arrFormElements = createFieldFilter($arrOrgz, $techFilter, $arrStatus);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $contenidoModulo .= "<input type='hidden' name='grid_limit' id='grid_limit' value='{$limit}'>";
    $contenidoModulo .= "<input type='hidden' name='grid_offset' id='grid_offset' value='{$offset}'>";
    return $contenidoModulo;
}
Exemplo n.º 13
0
function reportRecording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $name = getParameter("name");
    if ($credentials['userlevel'] == 'superadmin') {
        $domain = getParameter('organization');
        $domain = empty($domain) ? 'all' : $domain;
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    } else {
        $arrOrgz = array();
        $domain = $credentials['domain'];
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    $pRecording = new paloSantoRecordings($pDB);
    $total = $pRecording->getNumRecording($domain, $name);
    if ($total === false) {
        $error = $pRecording->errMsg;
        $total = 0;
    }
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    //permission
    $create = in_array("create", $arrPermission);
    $edit = in_array("edit", $arrPermission);
    $delete = in_array("delete", $arrPermission);
    if ($delete) {
        $check = "&nbsp;<input type='checkbox' name='checkall' class='checkall' id='checkall' onclick='jqCheckAll(this.id);' />";
    } else {
        $check = "";
    }
    $oGrid->setTitle(_tr('Recordings List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColumns[] = $check;
    if ($credentials['userlevel'] == 'superadmin') {
        $arrColumns[] = _tr("Organization");
    }
    $arrColumns[] = _tr("Name");
    //$arrColumns[]=_tr("Source");
    $arrColumns[] = _tr("");
    $oGrid->setColumns($arrColumns);
    $arrRecordings = array();
    $arrData = array();
    if ($total != 0) {
        $arrRecordings = $pRecording->getRecordings($domain, $name, $limit, $offset);
    }
    if ($arrRecordings === false) {
        $error = _tr("Error to obtain Recordings") . $pRecording->errMsg;
        $arrRecordings = array();
    }
    $i = 0;
    foreach ($arrRecordings as $recording) {
        $arrTmp = array();
        $ext = explode(".", $recording["name"]);
        if ($delete) {
            $arrTmp[] = "&nbsp;<input type ='checkbox' class='delete' name='record_delete[]' value='" . $recording['uniqueid'] . "' />";
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $arrTmp[] = $recording["organization_domain"] == '' ? '' : $arrOrgz[$recording["organization_domain"]];
        }
        //$arrTmp[] = $recording["source"];
        $idfile = $recording['uniqueid'];
        if ($ext[1] == "gsm") {
            $div_display = '';
        } else {
            $div_display = "<div class='single' id='{$i}' style='display:inline;'><span data-src='index.php?menu={$module_name}&action=download&id={$idfile}&rawmode=yes'><img style='cursor:pointer;' width='13px' src='web/apps/recordings/images/sound.png'/>&nbsp;&nbsp;</span></div>";
        }
        $download = "<a href='index.php?menu={$module_name}&action=download&id={$idfile}&rawmode=yes'>" . $recording['name'] . "</a>";
        $arrTmp[] = $div_display . $download;
        $arrTmp[] = "<audio></audio>";
        $i++;
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($create) {
        $oGrid->addNew("add_recording", _tr("Add Recording"));
    }
    if ($delete) {
        $oGrid->deleteList(_tr("Are you sure you want to delete?"), "remove", _tr("Delete Selected"), false);
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    if ($credentials['userlevel'] == 'superadmin') {
        $_POST["organization"] = $domain;
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
    }
    $_POST["name"] = $name;
    // name
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name") . " = " . $name, $_POST, array("name" => ""));
    $arrFormElements = createFieldFilter($arrOrgz);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    return $contenidoModulo;
}
Exemplo n.º 14
0
function reportTG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $name = getParameter('name');
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['name'] = $name;
    //name
    $pTG = new paloSantoTG($pDB, $domain);
    $total = $pTG->getNumTG($domain, $name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => "all");
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pTG->errMsg;
        $total = 0;
    }
    $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('Time Groups List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Name");
    $oGrid->setColumns($arrColum);
    $arrTG = array();
    $arrData = array();
    if ($total != 0) {
        $arrTG = $pTG->getTGs($domain, $name, $limit, $offset);
    }
    if ($arrTG === false) {
        $error = _tr("Error to obtain Time Groups") . $pTG->errMsg;
        $arrTG = array();
    }
    $arrData = array();
    foreach ($arrTG as $tg) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$tg["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu={$module_name}&action=edit&id_tg=" . $tg['id'] . "&organization={$tg['organization_domain']}'>" . $tg['name'] . "</a>";
        $arrData[] = $arrTmp;
    }
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Time Group"), array_slice($arrOrgz, 1), $selected = null, "create_tg", $onchange_select = null);
            } else {
                $oGrid->addNew("create_tg", _tr("ADD Time Group"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["name"] = $name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Time Condition Group") . " = " . $name, $_POST, array("name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}
Exemplo n.º 15
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;
}
Exemplo n.º 16
0
function reportEmailList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $pORGZ = new paloSantoOrganization($pDB);
    $pEmailList = new paloSantoEmailList($pDB);
    $org_domain = getParameter("domain");
    $name_list = getParameter("name_list");
    $total = 0;
    if ($credentials['userlevel'] == "superadmin") {
        if (!empty($org_domain)) {
            $total = $pEmailList->getNumEmailList($name_list, $org_domain);
        } else {
            $org_domain = 0;
            //opcion default se muestran todas las listas
            $total = $pEmailList->getNumEmailList($name_list);
        }
    } else {
        $org_domain = $credentials['domain'];
        $total = $pEmailList->getNumEmailList($name_list, $org_domain);
    }
    if ($total === false) {
        $total = 0;
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("Couldn't be retrieved Email List data"));
    }
    //url
    $url['menu'] = $module_name;
    $url['domain'] = $org_domain;
    $url['name_list'] = $name_list;
    $limit = 20;
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTitle(_tr("Email List"));
    $oGrid->setIcon("web/apps/{$module_name}/images/email.png");
    $oGrid->setURL($url);
    $oGrid->setWidth("99%");
    $del_permission = in_array('delete_list', $arrPermission);
    $edit_permission = in_array('edit_list', $arrPermission);
    $create_permission = in_array('create_list', $arrPermission);
    if ($del_permission) {
        $arrColumns[] = "";
    }
    //checkbox to delete
    $arrColumns[] = _tr('List Name');
    $arrColumns[] = _tr('Number of Members');
    $arrColumns[] = _tr('Actions');
    $oGrid->setColumns($arrColumns);
    $arrData = null;
    if ($total > 0) {
        $arrResult = $pEmailList->getEmailListPagging($name_list, $org_domain, $limit, $offset);
        if ($arrResult === false) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("Couldn't be retrieved Email List data"));
        } else {
            foreach ($arrResult as $list) {
                $arrTmp = array();
                if ($del_permission) {
                    $arrTmp[] = "<input type='checkbox' name='del_list' id='{$list['id']}'>";
                }
                $arrTmp[] = "<a href='?menu={$module_name}&action=view_list&id={$list['id']}'>" . htmlentities($list['listname'], ENT_QUOTES, "UTF-8") . "@" . $list['organization_domain'] . "</a>";
                $arrTmp[] = $pEmailList->getTotalMembers($list['id']);
                $arrTmp[] = "<a href='?menu={$module_name}&action=view_memberlist&id=" . $list['id'] . "'>" . _tr("View members") . "</a>";
                $arrData[] = $arrTmp;
            }
        }
    }
    //Verifico si en el archivo /etc/postfix/main.cf las variables alias_map y virtual_alias_map están apuntando a los archivos correctos, de no ser así se lo corrige
    $checkPostfixFile = $pEmailList->checkPostfixFile();
    if (!$checkPostfixFile) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("An error has ocurred to try config postfix file"));
    }
    //begin section filter
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input name='search_org' type='submit' class='button' value='" . _tr('Search') . "'>");
    //se comprueba que el mailman haya sido configurado por primera vez
    $MailmanListCreated = $pEmailList->isMailmanListCreated();
    if (is_null($MailmanListCreated)) {
        $smarty->assign("mb_title", _tr("ERROR"));
        $smarty->assign("mb_message", $pEmailList->getError());
    } elseif (!$MailmanListCreated) {
        //sino ha sido configurado se muestra un mensaje
        if ($credentials['userlevel'] != 'superadmin') {
            //solo el superadmin puede hacer esta accion
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("A new List can not be added because some configurations are missed. Please contact with Elastix Admisnistrator"));
        } else {
            $smarty->assign("mb_title", _tr("Message"));
            $smarty->assign("mb_message", _tr("In order to use this module configure the Mailman Admin Settings. Click here >> ") . "<a href='?menu={$module_name}&action=mailman_settings'>" . _tr('Mailman Settings') . "</a>");
        }
    } else {
        if ($pORGZ->getNumOrganization(array()) > 0) {
            if ($create_permission) {
                $oGrid->addNew("new_emaillist", _tr("New Email list"));
            }
            /*if($del_permission)
              $oGrid->deleteList(_tr("Are you sure you wish to delete the Email List(s)."),"delete",_tr("Delete"));*/
            $arrOrgz = array(0 => "all");
            if ($credentials['userlevel'] == "superadmin") {
                foreach ($pORGZ->getOrganization(array()) as $value) {
                    $arrOrgz[$value["domain"]] = $value["domain"];
                }
                $_POST["domain"] = $org_domain;
                $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$org_domain], $_POST, array("domain" => 0), true);
                //organization
            }
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Name List") . " = " . $name_list, $_POST, array("name_list" => ""));
            //name_list
            $arrFormElements = createFieldFilter($arrOrgz);
            $oFilterForm = new paloForm($smarty, $arrFormElements);
            $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("In order to use this module must exist at least 1 organization in the Elastix Server"));
        }
    }
    $content = $oGrid->fetchGrid(array(), $arrData);
    return $content;
}
Exemplo n.º 17
0
function reportRG($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $pORGZ = new paloSantoOrganization($pDB);
    $domain = getParameter("organization");
    $domain = empty($domain) ? 'all' : $domain;
    if ($credentials['userlevel'] != "superadmin") {
        $domain = $credentials['domain'];
    }
    $rg_name = getParameter("rg_name");
    $pRG = new paloSantoRG($pDB, $domain);
    $rg_number = getParameter("rg_number");
    if (isset($rg_number) && $rg_number != '') {
        $expression = $pRG->getRegexPatternFromAsteriskPattern($rg_number);
        if ($expression === false) {
            $rg_number = '';
        }
    }
    $url['menu'] = $module_name;
    $url['organization'] = $domain;
    $url['rg_number'] = $rg_number;
    //ring group number
    $url['rg_name'] = $rg_name;
    //ring group number
    $total = $pRG->getNumRG($domain, $rg_number, $rg_name);
    $arrOrgz = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrOrgz = array("all" => _tr("all"));
        foreach ($pORGZ->getOrganization(array()) as $value) {
            $arrOrgz[$value["domain"]] = $value["name"];
        }
    }
    if ($total === false) {
        $error = $pRG->errMsg;
        $total = 0;
    }
    $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('RG List'));
    //$oGrid->setIcon('url de la imagen');
    $oGrid->setWidth("99%");
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $oGrid->setURL($url);
    $arrColum = array();
    if ($credentials['userlevel'] == "superadmin") {
        $arrColum[] = _tr("Organization");
    }
    $arrColum[] = _tr("Number");
    $arrColum[] = _tr("Name");
    $arrColum[] = _tr("Strategy");
    $arrColum[] = _tr("Ring Time");
    $arrColum[] = _tr("Ignore CF");
    $arrColum[] = _tr("Skip Busy Extensions");
    $arrColum[] = _tr("Default Destination");
    $oGrid->setColumns($arrColum);
    $arrRG = array();
    $arrData = array();
    if ($total != 0) {
        $arrRG = $pRG->getRGs($domain, $rg_number, $rg_name, $limit, $offset);
    }
    if ($arrRG === false) {
        $error = _tr("Error to obtain Ring Groups") . $pRG->errMsg;
        $arrRG = array();
    }
    foreach ($arrRG as $rg) {
        $arrTmp = array();
        if ($credentials['userlevel'] == "superadmin") {
            $arrTmp[] = $arrOrgz[$rg["organization_domain"]];
        }
        $arrTmp[] = "&nbsp;<a href='?menu=ring_group&action=view&id_rg=" . $rg['id'] . "&organization={$rg['organization_domain']}'>" . $rg['rg_number'] . "</a>";
        $arrTmp[] = htmlentities($rg["rg_name"], ENT_QUOTES, "UTF-8");
        $arrTmp[] = $rg["rg_strategy"];
        $arrTmp[] = $rg["rg_time"];
        $arrTmp[] = $rg["rg_cf_ignore"];
        $arrTmp[] = $rg["rg_skipbusy"];
        $arrTmp[] = $rg["destination"];
        $arrData[] = $arrTmp;
    }
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("SEARCH", "<input type='submit' class='button' value='" . _tr('Search') . "' name='report'>");
    if ($pORGZ->getNumOrganization(array()) >= 1) {
        if (in_array('create', $arrPermission)) {
            if ($credentials['userlevel'] == 'superadmin') {
                $oGrid->addComboAction("organization_add", _tr("ADD Ring Group"), array_slice($arrOrgz, 1), $selected = null, "create_rg", $onchange_select = null);
            } else {
                $oGrid->addNew("create_rg", _tr("ADD Ring Group"));
            }
        }
        if ($credentials['userlevel'] == 'superadmin') {
            $_POST["organization"] = $domain;
            $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Organization") . " = " . $arrOrgz[$domain], $_POST, array("organization" => "all"), true);
        }
        $_POST["rg_number"] = $rg_number;
        // patter to filter estension number
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Number") . " = " . $rg_number, $_POST, array("rg_number" => ""));
        $_POST["rg_name"] = $rg_name;
        // name
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Ring Group Name") . " = " . $rg_name, $_POST, array("rg_name" => ""));
        $arrFormElements = createFieldFilter($arrOrgz);
        $oFilterForm = new paloForm($smarty, $arrFormElements);
        $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("It's necesary you create at least one organization so you can use this module"));
    }
    if ($error != "") {
        $smarty->assign("mb_title", _tr("MESSAGE"));
        $smarty->assign("mb_message", $error);
    }
    $contenidoModulo = $oGrid->fetchGrid(array(), $arrData);
    $mensaje = showMessageReload($module_name, $pDB, $credentials);
    $contenidoModulo = $mensaje . $contenidoModulo;
    return $contenidoModulo;
}