function loadCurrency($idOrganization)
 {
     $pORGZ = new paloSantoOrganization($this->_DB);
     $currency = $pORGZ->getOrganizationProp($idOrganization, 'currency');
     if ($currency === false) {
         $this->errMsg = $pORGZ->errMsg;
     }
     return $currency;
 }
示例#2
0
function getGroups(&$pDB, $arrCredentiasls)
{
    $pACL = new paloACL($pDB);
    $pORGZ = new paloSantoOrganization($pDB);
    $jsonObject = new PaloSantoJSON();
    $idOrgSel = getParameter("idOrganization");
    $arrGrupos = array();
    if ($idOrgSel == 0) {
        $arrGrupos = array();
    } else {
        if ($arrCredentiasls['userlevel'] != 'superadmin') {
            if ($idOrgSel != $arrCredentiasls['id_organization']) {
                $jsonObject->set_error("Invalid Action");
                $arrGrupos = array();
            }
        } else {
            $arrGrupos[0] = array("country_code", $pORGZ->getOrganizationProp($idOrgSel, "country_code"));
            $arrGrupos[1] = array("area_code", $pORGZ->getOrganizationProp($idOrgSel, "area_code"));
            $arrGrupos[2] = array("email_quota", $pORGZ->getOrganizationProp($idOrgSel, "email_quota"));
            $temp = $pACL->getGroupsPaging(null, null, $idOrgSel);
            if ($temp === false) {
                $jsonObject->set_error(_tr($pACL->errMsg));
            } else {
                $i = 3;
                foreach ($temp as $value) {
                    $arrGrupos[$i] = array($value[0], $value[1]);
                    $i++;
                }
            }
        }
    }
    $jsonObject->set_message($arrGrupos);
    return $jsonObject->createJSON();
}
示例#3
0
function get_language()
{
    global $elxPath;
    require_once "{$elxPath}/configs/default.conf.php";
    include "{$elxPath}/configs/languages.conf.php";
    include_once "{$elxPath}/libs/paloSantoOrganization.class.php";
    global $arrConf;
    $lang = "";
    $pdB = new paloDB($arrConf['elastix_dsn']['elastix']);
    $pACL = new paloACL($pdB);
    $pOrgz = new paloSantoOrganization($pdB);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $uid = $pACL->getIdUser($user);
    if (empty($pDB->errMsg)) {
        if ($uid === false) {
            $lang = $pOrgz->getOrganizationProp(1, 'language');
        } else {
            $lang = $pACL->getUserProp($uid, 'language');
        }
    }
    //si no se encuentra tomar del archivo de configuracion
    if (empty($lang) || $lang === false) {
        $lang = isset($arrConf['language']) ? $arrConf['language'] : "en";
    }
    //verificar que exista en el arreglo de idiomas, sino por defecto en
    if (!array_key_exists($lang, $languages)) {
        $lang = "en";
    }
    return $lang;
}
示例#4
0
function viewFormOrganization($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    $pOrganization = new paloSantoOrganization($pDB);
    $pACL = new paloACL($pDB);
    $dataOrgz = false;
    $arrFill = $_POST;
    $action = getParameter("action");
    $id = getParameter("id");
    $check_e = isset($_POST["max_num_exten_chk"]) ? "checked" : "";
    $check_q = isset($_POST["max_num_queues_chk"]) ? "checked" : "";
    $check_u = isset($_POST["max_num_user_chk"]) ? "checked" : "";
    $smarty->assign("edit_entity", 0);
    if ($action == "view" || getParameter("edit") || getParameter("save_edit")) {
        if ($id == "1") {
            //no se puede editar ni observar la organizacion principal
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Invalid ID Organization"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        if ($credentials['userlevel'] != "superadmin" && $id != $credentials['id_organization']) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("Invalid Organization"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        $dataOrgz = $pOrganization->getOrganizationById($id);
        if (is_array($dataOrgz) & count($dataOrgz) > 0) {
            $num_exten = $pOrganization->getOrganizationProp($id, "max_num_exten");
            $num_queues = $pOrganization->getOrganizationProp($id, "max_num_queues");
            $num_users = $pOrganization->getOrganizationProp($id, "max_num_user");
            if ($credentials['userlevel'] != "superadmin") {
                $check_e = empty($num_exten) ? _tr("unlimited") : $num_exten;
                $check_q = empty($num_queues) ? _tr("unlimited") : $num_queues;
                $check_u = empty($num_users) ? _tr("unlimited") : $num_users;
            }
            if (!getParameter("save_edit")) {
                $arrFill['name'] = $dataOrgz['name'];
                $arrFill['country'] = $dataOrgz['country'];
                $arrFill['city'] = $dataOrgz['city'];
                $arrFill['address'] = $dataOrgz['address'];
                $arrFill['email_contact'] = $dataOrgz['email_contact'];
                $arrFill['country_code'] = $pOrganization->getOrganizationProp($id, "country_code");
                $arrFill['area_code'] = $pOrganization->getOrganizationProp($id, "area_code");
                $arrFill['quota'] = $pOrganization->getOrganizationProp($id, "email_quota");
                $arrFill['domain'] = $dataOrgz['domain'];
                if ($credentials['userlevel'] == "superadmin") {
                    if (empty($num_exten)) {
                        $check_e = "checked";
                    } else {
                        $check_e = "";
                        $arrFill["max_num_exten"] = $num_exten;
                    }
                    if (empty($num_queues)) {
                        $check_q = "checked";
                    } else {
                        $check_q = "";
                        $arrFill["max_num_queues"] = $num_queues;
                    }
                    if (empty($num_users)) {
                        $check_u = "checked";
                    } else {
                        $check_u = "";
                        $arrFill["max_num_user"] = $num_users;
                    }
                }
            }
            $smarty->assign("domain_name", $dataOrgz['domain']);
        } else {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("An error has ocurred to try retrieve organization data"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    } else {
        //solo el superadmin tiene permitido crear organizaciones
        if ($credentials['userlevel'] != "superadmin") {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("You are not authorized to perform this action"));
            return reportOrganization($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
        if (getParameter("new_organization")) {
            $arrFill['quota'] = 30;
            $check_e = "checked";
            $check_u = "checked";
            $check_q = "checked";
        }
    }
    $smarty->assign("ID", $id);
    //persistence id with input hidden in tpl
    $smarty->assign("ORG_RESTRINCTION", _tr("Organization Limits"));
    $smarty->assign("UNLIMITED", _tr("unlimited"));
    $smarty->assign("CHECK_U", $check_u);
    $smarty->assign("CHECK_E", $check_e);
    $smarty->assign("CHECK_Q", $check_q);
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("APLICAR_CAMBIOS", _tr("Apply Changes"));
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("DELETE", _tr("Delete"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?"));
    // $smarty->assign("icon", "web/apps/organizaciones/images/organization.png");
    //variable usadas en el tpl
    //estas acciones solosp pueden ser realizadas por el susperadmin
    global $arrPermission;
    if ($credentials['userlevel'] == "superadmin") {
        if (in_array('create_org', $arrPermission)) {
            $smarty->assign('CREATE_ORG', TRUE);
        }
        if (in_array('delete_org', $arrPermission)) {
            $smarty->assign('DELETE_ORG', TRUE);
        }
    }
    if (in_array('edit_org', $arrPermission)) {
        $smarty->assign('EDIT_ORG', TRUE);
    }
    $arrFormOrgz = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormOrgz);
    if ($action == "view") {
        $oForm->setViewMode();
        $smarty->assign("edit_entity", 1);
    } else {
        if (getParameter("edit") || getParameter("save_edit")) {
            $oForm->setEditMode();
            $smarty->assign("edit_entity", 1);
        }
    }
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Organization"), $arrFill);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
 function HTTP_GET()
 {
     global $arrConf;
     $jsonObject = new PaloSantoJSON();
     $where = "";
     if (!$this->isSuperAdmin()) {
         $this->invalidCredentials($jsonObject);
         return $jsonObject->createJSON();
     }
     $this->setSession();
     $validOrgs = array();
     if (is_array($this->arrIdOrgs)) {
         foreach ($this->arrIdOrgs as $idOrg) {
             if ($this->validateIdOrg($idOrg) && $idOrg != "1") {
                 $validOrgs[] = $idOrg;
             }
         }
     }
     if (is_array($this->arrIdOrgs)) {
         if (count($validOrgs) == 0) {
             //ningun id pasado en la peticion es valido. Devolvemos 404 not found
             $this->resourceNotExis($jsonObject);
             return $jsonObject->createJSON();
         } else {
             $q = str_repeat("?,", count($validOrgs));
             $where = "where id in (" . substr($q, 0, -1) . ")";
         }
     } else {
         $where = "where id!=1";
     }
     $pOrg = new paloSantoOrganization($arrConf['elastix_dsn']["elastix"]);
     $query = "SELECT * FROM organization {$where}";
     $result = $pOrg->_DB->fetchTable($query, true, $validOrgs);
     if ($result === false) {
         $this->error = $pOrg->_DB->errMsg;
         $this->errSever($jsonObject);
         return $jsonObject->createJSON();
     } elseif ($result == false) {
         $this->resourceNotExis($jsonObject);
         return $jsonObject->createJSON();
     } else {
         $arrORGS = array();
         $sBaseUrl = '/rest.php/organization/organization';
         foreach ($result as $x => $org) {
             $arrORGS["organization"][$x]['name'] = $org['name'];
             $arrORGS["organization"][$x]['domain'] = $org['domain'];
             $arrORGS["organization"][$x]['state'] = $org['state'];
             $arrORGS["organization"][$x]['country_code'] = $pOrg->getOrganizationProp($org['id'], "country_code");
             $arrORGS["organization"][$x]['area_code'] = $pOrg->getOrganizationProp($org['id'], "area_code");
             $arrORGS["organization"][$x]['email_quota'] = $pOrg->getOrganizationProp($org['id'], "email_quota");
             $arrORGS["organization"][$x]['max_num_user'] = $pOrg->getOrganizationProp($org['id'], "max_num_user");
             $arrORGS["organization"][$x]['max_num_exten'] = $pOrg->getOrganizationProp($org['id'], "max_num_exten");
             $arrORGS["organization"][$x]['max_num_queues'] = $pOrg->getOrganizationProp($org['id'], "max_num_queues");
             $arrORGS["organization"][$x]['url'] = $sBaseUrl . '/' . $org['id'];
         }
         $json = new Services_JSON();
         return $json->encode($arrORGS);
     }
 }