Пример #1
0
function viewFormShortcutApps($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials)
{
    global $arrPermission;
    $error = "";
    $arrShortcutApps = array();
    $action = getParameter("action");
    $idShortcutApps = getParameter("id");
    if ($action == "view" || $action == "view_edit" || getParameter("edit") || getParameter("save_edit")) {
        if (!isset($idShortcutApps)) {
            $error = _tr("Invalid ShortcutApps ID");
        } else {
            $domain = getParameter('organization');
            if ($credentials['userlevel'] != 'superadmin') {
                $domain = $credentials['domain'];
            }
            $pShortcutApps = new paloSantoShortcutApps($pDB, $domain);
            $arrShortcutApps = $pShortcutApps->getShortcutAppsById($idShortcutApps);
            if ($arrShortcutApps === false) {
                $error = _tr($pShortcutApps->errMsg);
            } else {
                if (count($arrShortcutApps) == 0) {
                    $error = _tr("ShortcutApps doesn't exist");
                } else {
                    if (getParameter("save_edit")) {
                        $arrShortcutApps = $_POST;
                    }
                }
            }
        }
        if ($error != "") {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", $error);
            return reportShortcutApps($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials);
        }
    } else {
        // new, create
        if ($credentials['userlevel'] == 'superadmin') {
            if (getParameter("create_shortcut_apps")) {
                $domain = getParameter('organization_add');
                //este parametro solo es selecionable cuando es el superadmin quien crea la ruta
            } else {
                $domain = getParameter('organization');
            }
        } else {
            $domain = $credentials['domain'];
        }
        $pShortcutApps = new paloSantoShortcutApps($pDB, $domain);
        if (getParameter("create_shortcut_apps")) {
            $arrShortcutApps["description"] = "";
            $arrShortcutApps["exten"] = "";
            $arrShortcutApps["destination"] = "";
            $arrShortcutApps["goto"] = "";
        } else {
            $arrShortcutApps = $_POST;
        }
    }
    $goto = $pShortcutApps->getCategoryDefault($domain);
    if ($goto === false) {
        $goto = array();
    }
    $res = $pShortcutApps->getDefaultDestination($domain, $arrShortcutApps["goto"]);
    $destiny = $res == false ? array() : $res;
    $arrFormOrgz = createFieldForm($goto, $destiny, $pDB, $domain);
    $oForm = new paloForm($smarty, $arrFormOrgz);
    if ($action == "view") {
        $oForm->setViewMode();
    } else {
        if ($action == "view_edit" || getParameter("edit") || getParameter("save_edit")) {
            $oForm->setEditMode();
        }
    }
    //permission
    $smarty->assign("EDIT_SCA", in_array('edit', $arrPermission));
    $smarty->assign("CREATE_SCA", in_array('create', $arrPermission));
    $smarty->assign("DEL_SCA", in_array('delete', $arrPermission));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("OPTIONS", _tr("Options"));
    $smarty->assign("APPLY_CHANGES", _tr("Apply changes"));
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("DELETE", _tr("Delete"));
    $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?"));
    $smarty->assign("MODULE_NAME", $module_name);
    $smarty->assign("id", $idShortcutApps);
    $smarty->assign("USERLEVEL", $credentials['userlevel']);
    $smarty->assign("ORGANIZATION_LABEL", _tr("Organization Domain"));
    $smarty->assign("ORGANIZATION", $domain);
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("ShortcutApps"), $arrShortcutApps);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}