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 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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
function report_AccessAudit($smarty, $module_name, $local_templates_dir)
{
    global $arrPermission;
    $pAccessLogs = new paloSantoAccessaudit();
    $listaFechas = $pAccessLogs->astLog->listarFechas();
    $arrFormElements = createFieldFilter($listaFechas);
    $field_pattern = getParameter("filter");
    $busqueda = getParameter('busqueda');
    $sUltimaBusqueda = getParameter('ultima_busqueda');
    $iUltimoOffset = getParameter('ultimo_offset');
    if (is_null($busqueda) || trim($busqueda) == '') {
        $busqueda = '';
    }
    if ($busqueda != '') {
        $_POST['busqueda'] = $busqueda;
    }
    /* Última búsqueda, si existe */
    if (is_null($sUltimaBusqueda) || $sUltimaBusqueda == '' || is_null($iUltimoOffset) || !ereg('^[[:digit:]]+$', $iUltimoOffset)) {
        $sUltimaBusqueda = NULL;
        $iUltimoOffset = NULL;
    }
    if (!ereg($arrFormElements['filter']['VALIDATION_EXTRA_PARAM'], $field_pattern)) {
        $field_pattern = $listaFechas[count($listaFechas) - 1];
    }
    $_POST['filter'] = $field_pattern;
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle(_tr("Audit"));
    $oGrid->setIcon("web/apps/{$module_name}/images/security_audit.png");
    $oGrid->pagingShow(true);
    // show paging section.
    if (in_array("export", $arrPermission)) {
        $oGrid->enableExport();
    }
    // enable export.
    $oGrid->setNameFile_Export(_tr("Access audit"));
    if (in_array("export", $arrPermission)) {
        $isExport = $oGrid->isExportAction();
    } else {
        $isExport = false;
    }
    $total_datos = $pAccessLogs->ObtainNumAccessLogs($field_pattern);
    $totalBytes = $total_datos[0];
    $iNumLineasPorPagina = 30;
    $iEstimadoBytesPagina = $iNumLineasPorPagina * 128;
    $iOffsetVerdadero = getParameter('offset');
    if (is_null($iOffsetVerdadero) || !ereg('^[[:digit:]]+$', $iOffsetVerdadero)) {
        $iOffsetVerdadero = 0;
    }
    if ($iOffsetVerdadero >= $totalBytes) {
        $iOffsetVerdadero = 0;
    }
    if (isset($_GET['filter']) && isset($_POST['filter']) && $_GET['filter'] != $_POST['filter']) {
        $iOffsetVerdadero = 0;
    }
    /* Para ubicarse en la página, se obtiene la región 5 páginas estimadas hacia delante y
         5 páginas estimadas hacia atrás desde el offset indicado.
       */
    $inicioRango = $iOffsetVerdadero - 5 * $iEstimadoBytesPagina;
    if ($inicioRango < 0) {
        $inicioRango = 0;
    }
    if ($isExport) {
        $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, NULL, $isExport);
    } else {
        $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
    }
    /* Localizar la línea del offset verdadero, así como los offsets de las páginas previa y siguiente */
    for ($iPos = 0; $iPos < count($arrResult); $iPos++) {
        if ($arrResult[$iPos]['offset'] >= $iOffsetVerdadero) {
            break;
        }
    }
    $iPosPrevio = $iPos - $iNumLineasPorPagina;
    $iPosSiguiente = $iPos + $iNumLineasPorPagina;
    if ($iPosPrevio < 0) {
        $iPosPrevio = 0;
    }
    if ($iPosSiguiente > count($arrResult) - 1) {
        $iPosSiguiente = count($arrResult) - 1;
    }
    $iOffsetPrevio = $arrResult[$iPosPrevio]['offset'];
    $iOffsetSiguiente = $arrResult[$iPosSiguiente]['offset'];
    $limit = 30;
    $total = (int) ($totalBytes / 128);
    $offset = $iOffsetVerdadero;
    $nav = getParameter('nav');
    if ($nav) {
        switch ($nav) {
            case 'start':
                $offset = 0;
                break;
            case 'end':
                /* Caso especial: se debe tomar la última sección del log */
                $inicioRango = $totalBytes - 5 * $iEstimadoBytesPagina;
                if ($inicioRango < 0) {
                    $inicioRango = 0;
                }
                if ($isExport) {
                    $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
                } else {
                    $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
                }
                if (count($arrResult) <= $iNumLineasPorPagina) {
                    $offset = $arrResult[0]['offset'];
                } else {
                    $offset = $arrResult[count($arrResult) - $iNumLineasPorPagina]['offset'];
                }
                break;
            case 'next':
                $offset = $iOffsetSiguiente;
                break;
            case 'previous':
                $offset = $iOffsetPrevio;
                break;
            case 'bypage':
                $numPage = $limit == 0 ? 0 : ceil($total / $limit);
                $page = getParameter("page");
                if (preg_match("/[0-9]+/", $page) == 0) {
                    // no es un número
                    $page = 1;
                }
                if ($page > $numPage) {
                    // se está solicitando una pagina mayor a las que existen
                    $page = $numPage;
                }
                $start = ($page - 1) * $limit + 1 - $limit;
                //$accion = "next";
                if ($start + $limit <= 1) {
                    break;
                }
                /*$inicioRango = $page * $iEstimadoBytesPagina;
                
                        $arrResult =$pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioRango, $field_pattern, NULL, $isExport);
                        $offset = $arrResult[0]['offset'];
                
                        $oGrid->setOffsetValue($offset);
                
                        $oGrid->setEnd(((int)($offset / 128) + $iNumLineasPorPagina) <= $oGrid->getTotal() ? (int)($offset / 128) + $iNumLineasPorPagina : $oGrid->getTotal());
                
                        $oGrid->setStart(($oGrid->getTotal()==0) ? 0 : (1 + (int)($offset / 128)));*/
                $inicioBusqueda = $page * $iEstimadoBytesPagina - $iEstimadoBytesPagina;
                $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $inicioBusqueda, $field_pattern, NULL, $isExport);
                $offset = $arrResult[0]['offset'];
                $oGrid->setOffsetValue($offset);
                break;
        }
    }
    // Buscar la cadena de texto indicada, y modificar offset si se encuentra
    $smarty->assign("SEARCHNEXT", _tr('Search'));
    if (isset($_POST['searchnext']) && $busqueda != '') {
        $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset);
        $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda);
        if (!is_null($posBusqueda)) {
            $offset = $posBusqueda[1];
            $smarty->assign('SEARCHNEXT', _tr('Search next'));
            $_POST['ultima_busqueda'] = $busqueda;
            $_POST['ultimo_offset'] = $offset;
            // Si el offset anterior indicado es idéntico al offset recién encontrado
            // y la cadena de búsqueda es también idéntica, se asume que se ha
            // pedido una búsqueda de la siguiente ocurrencia.
            if (!is_null($sUltimaBusqueda) && !is_null($iUltimoOffset) && $offset == $iUltimoOffset && $sUltimaBusqueda == $busqueda) {
                $pAccessLogs->astLog->posicionarMensaje($field_pattern, $offset);
                $pAccessLogs->astLog->siguienteMensaje();
                // Sólo para ignorar primera ocurrencia
                $posBusqueda = $pAccessLogs->astLog->buscarTextoMensaje($busqueda);
                if (!is_null($posBusqueda)) {
                    $offset = $posBusqueda[1];
                    $_POST['ultimo_offset'] = $offset;
                }
            }
        } else {
        }
    }
    $url = array('menu' => $module_name, 'filter' => $field_pattern, 'offset' => $offset, 'busqueda' => $busqueda, 'ultima_busqueda' => isset($_POST['ultima_busqueda']) ? $_POST['ultima_busqueda'] : '', 'ultimo_offset' => isset($_POST['ultimo_offset']) ? $_POST['ultimo_offset'] : '');
    $oGrid->setURL($url);
    //Fin Paginacion
    if ($isExport) {
        $arrResult = $pAccessLogs->ObtainAccessLogs($totalBytes, 0, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
    } else {
        $arrResult = $pAccessLogs->ObtainAccessLogs(10 * $iEstimadoBytesPagina, $offset, $field_pattern, $busqueda != '' ? $busqueda : NULL, $isExport);
    }
    if (!$isExport) {
        $arrResult = array_slice($arrResult, 0, $iNumLineasPorPagina);
    }
    $arrData = null;
    if (is_array($arrResult) && $totalBytes > 0) {
        foreach ($arrResult as $key => $value) {
            $arrTmp[0] = $value['fecha'];
            $arrTmp[1] = $value['tipo'];
            $arrTmp[2] = $value['origen'];
            $arrTmp[3] = $value['linea'];
            $arrData[] = $arrTmp;
        }
    }
    $arrColumns = array(_tr("Date"), _tr("Type"), _tr("User"), _tr("Message"));
    $oGrid->setColumns($arrColumns);
    $oGrid->setData($arrData);
    $oGrid->setStart($totalBytes == 0 ? 0 : 1 + (int) ($offset / 128));
    $t = (int) ($totalBytes / 128);
    $e = (int) ($offset / 128) + $iNumLineasPorPagina;
    $e = $t <= $e ? $t : $e;
    $oGrid->setEnd($e + 1);
    $oGrid->setTotal($t + 1);
    $oGrid->setLimit(30);
    $_POST['offset'] = $offset;
    $smarty->assign("SHOW", _tr("Show"));
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Date") . " = " . $_POST['filter'], $_POST, array('filter' => $listaFechas[count($listaFechas) - 1]), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr('Search string') . " = " . $busqueda, $_POST, array('busqueda' => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    $oGrid->showFilter(trim($htmlFilter));
    return $oGrid->fetchGrid();
}
Exemplo n.º 9
0
function reportContact($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    global $arrCredentials;
    $coreContact = new coreContact($pDB);
    $jsonObject = new PaloSantoJSON();
    //obtener los parametros del filtro
    $filters['ftype_contacto'] = getParameter('ftype_contacto');
    $filters['filter'] = getParameter('filter');
    $filters['filter_value'] = getParameter('filter_value');
    $validatedfilters = $coreContact->validatedFilters($filters);
    $total = $coreContact->getTotalContactsByFilter($validatedfilters);
    if ($total === false) {
        $total = 0;
        $smarty->assign("MSG_ERROR_FIELD", _tr("Error en database"));
        $jsonObject->set_error($coreContact->sqlContact->getErrorMsg());
        return $jsonObject->createJSON();
    }
    $limit = 7;
    $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);
    $currentPage = $oGrid->calculateCurrentPage();
    $numPage = $oGrid->calculateNumPage();
    $url['menu'] = $module_name;
    $url['ftype_contacto'] = $filters['ftype_contacto'];
    $url['filter'] = $filters['filter'];
    $url['filter_value'] = $filters['filter_value'];
    $oGrid->setTitle(_tr('Contacts List'));
    $oGrid->setURL($url);
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("ContactsExport"));
    $arrColumn = array();
    if ($oGrid->isExportAction()) {
        // arreglo de columnas para mostrar en los archivos de exportacion
        $arrColumn[] = 'Name';
        //if($validatedfilters['table']=="internal"){
        if ($validatedfilters['table'] == "internal") {
            $arrColumn[] = 'Ext';
        } else {
            $arrColumn[] = 'Phone';
        }
        $arrColumn[] = 'Email';
        $arrColumn[] = 'Type Contact';
    } else {
        //arreglo de columnas para mostrar en la grilla
        $arrColumn[] = "<span class='glyphicon glyphicon-check'></span>";
        $arrColumn[] = _tr('Picture');
        $arrColumn[] = _tr('Name');
        //if($validatedfilters['table']=="internal"){
        $arrColumn[] = _tr('Ext / Phone');
        $arrColumn[] = _tr('Email');
        $arrColumn[] = _tr('Call');
        $arrColumn[] = _tr('Transfer');
        $arrColumn[] = _tr('Type Contact');
    }
    $oGrid->setColumns($arrColumn);
    $validatedfilters = $coreContact->validatedFilters($filters);
    //enviamos como parametros limit, offset y los filtros validados
    $contacts = $coreContact->getContacts($limit, $offset, $validatedfilters);
    $arrDatosGrid = array();
    if ($contacts === false) {
        $smarty->assign("MSG_ERROR_FIELD", $coreContact->getErrorMsg());
        $jsonObject->set_error($coreContact->getErrorMsg());
        return $jsonObject->createJSON();
    } else {
        if ($oGrid->isExportAction()) {
            // data para exportar en los archivos
            foreach ($contacts as $value) {
                $tmp = array();
                $tmp[] = $value['name'];
                if (empty($value['work_phone'])) {
                    $tmp[] = "N/A";
                } else {
                    $tmp[] = $value['work_phone'];
                }
                if (!empty($value['username'])) {
                    $tmp[] = $value['username'];
                } else {
                    $tmp[] = "N/A";
                }
                if ($validatedfilters['table'] != "internal") {
                    if ($value['status'] == "isPrivate") {
                        $tmp[] = _tr('Private');
                    } else {
                        $tmp[] = _tr('Public');
                    }
                } else {
                    $tmp[] = _tr('Public');
                }
                $arrDatosGrid[] = $tmp;
            }
        } else {
            //data para mostrar en las grillas
            foreach ($contacts as $value) {
                $tmp = array();
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >";
                } else {
                    if ($arrCredentials['idUser'] == $value['iduser']) {
                        $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}'>";
                    } else {
                        $tmp[] = "<input type='checkbox' name='checkContacts' id='{$value['id']}' disabled >";
                    }
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu=_elastixutils&action=getImage&ID={$value['id']}&rawmode=yes'/>";
                } else {
                    $tmp[] = "<img id='img-users' width='16' height='16' alt='image' src='index.php?menu={$module_name}&action=getImageExtContact&image={$value['picture']}&rawmode=yes'/>";
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8");
                } else {
                    if ($arrCredentials['idUser'] == $value['iduser']) {
                        $tmp[] = "<a href='#' onclick='editContact({$value['id']})'>" . htmlentities($value['name'], ENT_QUOTES, "UTF-8") . "</a>";
                    } else {
                        $tmp[] = htmlentities($value['name'], ENT_QUOTES, "UTF-8");
                    }
                }
                if ($validatedfilters['table'] == "internal") {
                    $tmp[] = htmlentities($value['extension'], ENT_QUOTES, "UTF-8");
                } else {
                    if (empty($value['work_phone'])) {
                        $tmp[] = "N/A";
                    } else {
                        $tmp[] = htmlentities($value['work_phone'], ENT_QUOTES, "UTF-8");
                    }
                }
                if (!empty($value['username'])) {
                    $tmp[] = htmlentities($value['username'], ENT_QUOTES, "UTF-8");
                } else {
                    $tmp[] = "N/A";
                }
                //$tmp[]="<span class='glyphicon glyphicon-earphone'></span>";
                $tmp[] = "<a href='#' onclick='callContact({$value['id']})'><span class='glyphicon glyphicon-earphone'></span></a>";
                if ($validatedfilters['table'] == "internal") {
                    //$tmp[]=_tr('Transfer');
                    $tmp[] = "<a href='#' onclick='transferCall({$value['id']})'>" . _tr('Transfer') . "</a>";
                } else {
                    $tmp[] = "N/A";
                }
                if ($validatedfilters['table'] != "internal") {
                    if ($value['status'] == "isPrivate") {
                        $tmp[] = _tr('Private');
                    } else {
                        $tmp[] = _tr('Public');
                    }
                } else {
                    $tmp[] = _tr('Public');
                }
                $arrDatosGrid[] = $tmp;
            }
        }
    }
    $action = getParameter('action');
    if ($action == 'search') {
        $arrData['url'] = $oGrid->getURL();
        $arrData['url'] = str_replace('&amp;', '&', $arrData['url']);
        $arrData['numPage'] = $numPage;
        $arrData['currentPage'] = $currentPage;
        $arrData['content'] = $arrDatosGrid;
        $jsonObject->set_message($arrData);
        return $jsonObject->createJSON();
    }
    $oGrid->addButtonAction("new_contact", "<span class='glyphicon glyphicon-user'></span> New Contact", "", "newContact()");
    $oGrid->addButtonAction("remove_contact", "<span class='glyphicon glyphicon-remove'></span> Delete Contacts", "", "deleteContacts('" . _tr("Are you sure you wish to delete the contact.") . "')");
    $oGrid->addButtonAction("elx_upload_file", "<span class='glyphicon glyphicon-upload'></span> Upload from CSV", "", "");
    $oGrid->addButtonAction("elx_export_data", "<span class='glyphicon glyphicon-download'></span>", "", "");
    $oGrid->addButtonAction("elx_show_filter", "<span class='glyphicon glyphicon-filter'></span> Show filter", "", "");
    $arrayData = array();
    $arrFormFilter = createFilterForm();
    $oFilterForm = new paloForm($smarty, $arrFormFilter);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", _tr('extension'), $arrayData);
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = actionsReport($arrDatosGrid, $oGrid);
    return $contenidoModulo;
}
Exemplo n.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
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.º 18
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.º 19
0
function reportMail($smarty, $module_name, $local_templates_dir, &$arrConf, &$pImap)
{
    $jsonObject = new PaloSantoJSON();
    $arrFilter = array();
    //obtenemos el mailbox que deseamos leer
    $mailbox = getParameter('folder');
    $action = getParameter('action');
    //creamos la connección al mailbox
    $pImap->setMailbox($mailbox);
    $smarty->assign("CURRENT_MAILBOX", $pImap->getMailbox());
    $result = $pImap->login($_SESSION['elastix_user'], $_SESSION['elastix_pass2']);
    if ($result === false) {
        if ($action == 'show_messages_folder') {
            $jsonObject->set_error($pImap->errMsg);
            return $jsonObject->createJSON();
        } else {
            $smarty->assign("ERROR_FIELD", $pImap->errMsg);
            return '';
        }
    }
    $listMailbox = $pImap->getMailboxList();
    if ($result === false) {
        $jsonObject->set_error($pImap->errMsg);
        $smarty->assign("ERROR_FIELD", $pImap->errMsg);
        return '';
    } else {
        $smarty->assign('MAILBOX_FOLDER_LIST', $listMailbox);
        $smarty->assign('NEW_FOLDER', _tr('New Folder'));
    }
    $view_filter_opt['all'] = _tr("All");
    $view_filter_opt['seen'] = _tr("Seen");
    $view_filter_opt['unseen'] = _tr("Unseen");
    $view_filter_opt['flagged'] = _tr("Important");
    $view_filter_opt['unflagged'] = _tr("No Important");
    $smarty->assign("ELX_MAIL_FILTER_OPT", $view_filter_opt);
    $filter_view = 'all';
    $tmp_filter_view = getParameter('email_filter1');
    if (array_key_exists($tmp_filter_view, $view_filter_opt)) {
        $filter_view = $tmp_filter_view;
    }
    $arrFilter = array("filter_view" => $filter_view);
    //obtenemos el numero de correos que ahi en el buzon
    //filtrando por los parámetros dados
    $listUID = array();
    $total = $pImap->getNumMails($arrFilter, $listUID);
    if ($total === false) {
        $total = 0;
        $jsonObject->set_error($pImap->errMsg);
        $smarty->assign("ERROR_FIELD", $pImap->errMsg);
    }
    $limit = 50;
    //sacamos calculamos el offset
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $currentPage = $oGrid->calculateCurrentPage();
    $numPage = $oGrid->calculateNumPage();
    $url['menu'] = $module_name;
    $url['email_filter1'] = $filter_view;
    $oGrid->setTitle(_tr('Contacts List'));
    $oGrid->setURL($url);
    $oGrid->setStart($total == 0 ? 0 : $offset + 1);
    $oGrid->setEnd($end);
    $oGrid->setTotal($total);
    $smarty->assign("TOTAL_MAILS", $total);
    $smarty->assign("CURRENT_PAGMAIL", $currentPage);
    $smarty->assign("NUM_PAGMAIL", $numPage);
    $smarty->assign("PAGINA", _tr("Page"));
    $smarty->assign("MESSAGES_LABEL", _tr("Messages"));
    $arrData = array();
    if ($total != 0) {
        $pImap->setMessageByPage($limit);
        $pImap->setOffset($offset);
        $emails = $pImap->readMails($listUID);
        if ($emails !== false) {
            foreach ($emails as $email) {
                $tmp = array();
                $class = 'elx_unseen_email';
                if ($email['SEEN'] == 1) {
                    $class = 'elx_seen_email';
                }
                $tmp[] = "<div class='elx_row {$class}' id={$email['UID']}>";
                $tmp[] = "<div class='ic'>";
                $tmp[] = "<div class='sel'><input type='checkbox' value='{$email['UID']}' class='inp1 checkmail'/></div>";
                //$tmp[]="<div class='icon'><img border='0' src='web/apps/home/images/mail2.png' class='icn_buz'></div>";
                $class = 'elx_unflagged_email';
                if ($email['FLAGGED'] == 1) {
                    $class = 'elx_flagged_email';
                }
                $tmp[] = "<div class='star'><span class='{$class} glyphicon glyphicon-star'></span></div>";
                $tmp[] = "</div>";
                //$tmp[]="<div class='email_msg_attr'>";
                $tmp[] = "<div class='from  elx_row_email_msg'> <span>" . htmlentities($email['from'], ENT_COMPAT, 'UTF-8') . "</span></div>";
                $tmp[] = "<div class='subject elx_row_email_msg'> <span>" . htmlentities($email['subject'], ENT_COMPAT, 'UTF-8') . "</span></div>";
                $tmp[] = "<div class='date elx_row_email_msg'><span>" . $email['date'] . "</span></div>";
                //$tmp[]="</div>";
                $tmp[] = "</div>";
                $arrData[] = $tmp;
            }
            $smarty->assign("MAILS", $arrData);
        } else {
            $jsonObject->set_error($pImap->errMsg);
            $smarty->assign("ERROR_FIELD", $pImap->errMsg);
        }
    }
    $pImap->close_mail_connection();
    $imapAlertErros = cleanAlertsImap();
    $listMailbox = array_diff($listMailbox, array($pImap->getMailbox()));
    $move_folder = array();
    foreach ($listMailbox as $value) {
        $move_folder[$value] = $value;
    }
    $smarty->assign("MOVE_FOLDERS", $move_folder);
    if ($action == 'show_messages_folder') {
        $message['email_content'] = $arrData;
        $message['email_filter1'] = $filter_view;
        $message['move_folders'] = $move_folder;
        $message['imap_alerts'] = $imapAlertErros;
        $message['paging']['total'] = $total;
        $message['paging']['currentPage'] = $currentPage;
        $message['paging']['numPages'] = $numPage;
        $jsonObject->set_message($message);
        return $jsonObject->createJSON();
    }
    $smarty->assign("IMAP_ALERTS", $imapAlertErros);
    $smarty->assign("ICON_TYPE", "web/apps/{$module_name}/images/mail2.png");
    $smarty->assign("FOLDER_LIST_TITLE", _tr("Folders"));
    $mark_opt['seen'] = _tr("Seen");
    $mark_opt['unseen'] = _tr("Unseen");
    $mark_opt['flagged'] = _tr("Important");
    $mark_opt['unflagged'] = _tr("No Important");
    $smarty->assign("ELX_MAIL_MARK_OPT", $mark_opt);
    $smarty->assign("MOVE_TO", _tr("Move to"));
    $smarty->assign("MARK_AS", _tr("Mark message as"));
    $smarty->assign("NO_EMAIL_MSG", _tr("Not messages"));
    $smarty->assign("VIEW", _tr("View"));
    $smarty->assign("SELECTED_VIEW_FILTER", $filter_view);
    $smarty->assign("SEND_MAIL_LABEL", _tr("Send"));
    $smarty->assign("ATTACH_LABEL", _tr("Attach"));
    $smarty->assign("ACTION_MSG", _tr('Actions'));
    $arrActionsMsg['reply'] = _tr('Reply');
    $arrActionsMsg['reply_all'] = _tr('Reply All');
    $arrActionsMsg['forward'] = _tr('Forward');
    $arrActionsMsg['delete'] = _tr('Delete');
    $arrActionsMsg['flag_important'] = _tr('Flag as Important');
    $arrActionsMsg['flag_unimportant'] = _tr('Flag as Unimportant');
    $smarty->assign("ELX_EMAIL_MSG_ACT", $arrActionsMsg);
    $html = $smarty->fetch("file:{$local_templates_dir}/form.tpl");
    $contenidoModulo = "<div>" . $html . "</div>";
    return $contenidoModulo;
}
Exemplo n.º 20
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;
}