From bc92fc04a9a3daf3563414f2f7226fc48ab7f725 Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Tue, 22 Mar 2016 21:03:30 +0000 Subject: [PATCH] FSN#35817 Autorisaties via API2/Scaffolding svn path=/Website/trunk/; revision=28587 --- APPL/API2/api2.inc | 5 +- APPL/API2/model_fac_functie.inc | 10 +- APPL/API2/model_fac_groep.inc | 3 +- APPL/API2/model_fac_groeprechten.inc | 13 ++- APPL/API2/model_ins_tab_discipline.inc | 6 +- APPL/MGT/fac_edit_groeprechten.asp | 149 +++++++++++++++++++++++++ APPL/MGT/fac_functie.asp | 11 +- APPL/MGT/fac_functie.js | 5 +- APPL/MGT/fac_groep.asp | 15 ++- APPL/MGT/fac_groep.js | 10 +- APPL/MGT/fac_groeprechten.asp | 3 +- APPL/MGT/ins_tab_discipline.asp | 16 ++- APPL/MGT/ins_tab_discipline.js | 3 +- APPL/SCF/scaffolding_search.inc | 9 ++ APPL/Shared/default.csx | 1 + APPL/Shared/m_connections.inc | 14 +++ 16 files changed, 240 insertions(+), 33 deletions(-) create mode 100644 APPL/MGT/fac_edit_groeprechten.asp diff --git a/APPL/API2/api2.inc b/APPL/API2/api2.inc index c943ab6793..cbb6ebe210 100644 --- a/APPL/API2/api2.inc +++ b/APPL/API2/api2.inc @@ -601,7 +601,10 @@ api2 = { // gedrag wel fijn. orderbys.push(inc.model.aliasprefix + inc.model.primary); // simpel op joinfield - wheres.push ( model.table + "." + model.primary + "=" + inc.model.table + "." + inc.model.fields[inc.joinfield].dbs + "(+)"); + var outer = "(+)"; + if ("outertoggle" in inc && params.filter.scf_outer != "on") + outer = inc.outertoggle.def?"(+)":""; + wheres.push ( model.table + "." + model.primary + "=" + inc.model.table + "." + inc.model.fields[inc.joinfield].dbs + outer); } } } diff --git a/APPL/API2/model_fac_functie.inc b/APPL/API2/model_fac_functie.inc index bcf939a80a..6184c316e2 100644 --- a/APPL/API2/model_fac_functie.inc +++ b/APPL/API2/model_fac_functie.inc @@ -71,6 +71,13 @@ function model_fac_functie (functie_key, params) "typ": "number", "hidden_fld": true }, + "nn_discipline": { + "dbs": "nn_discipline", + //"label": L("fac_functie_omschrijving"), + "typ": "varchar", + "sql": "(SELECT COUNT(*) FROM ins_tab_discipline WHERE ins_discipline_verwijder IS NULL AND ins_discipline_module = fac_functie_module)", + "hidden_fld": true + }, "description": { "dbs": "fac_functie_omschrijving", "label": L("fac_functie_omschrijving"), @@ -90,7 +97,8 @@ function model_fac_functie (functie_key, params) { this.includes = {"authorization": { "model": new model_fac_groeprechten(params), - "joinfield": "fac_functie" + "joinfield": "fac_functie", + "outertoggle": { def: false, lbl: "Toon alle functies" } }}; } diff --git a/APPL/API2/model_fac_groep.inc b/APPL/API2/model_fac_groep.inc index 0221c2a982..3c95db4bfb 100644 --- a/APPL/API2/model_fac_groep.inc +++ b/APPL/API2/model_fac_groep.inc @@ -62,7 +62,8 @@ function model_fac_groep(groep_key, params) this.includes["authorization"] = { "model": new model_fac_groeprechten(params), - "joinfield": "fac_groep" + "joinfield": "fac_groep", + outertoggle: { def: false, lbl: "Toon alle groepen" } }; } diff --git a/APPL/API2/model_fac_groeprechten.inc b/APPL/API2/model_fac_groeprechten.inc index aa19c1eece..eeae233744 100644 --- a/APPL/API2/model_fac_groeprechten.inc +++ b/APPL/API2/model_fac_groeprechten.inc @@ -55,7 +55,7 @@ function model_fac_groeprechten (params) }, "fac_groep": { "dbs": "fac_groep_key", - "label": L("fac_groep_key"), + "label": L("fac_groep"), "typ": "key", "hidden_fld": true, "foreign": { @@ -115,9 +115,12 @@ function model_fac_groeprechten (params) function fnDisc(oRs, field, model) { + if (!oRs("fac_functie_discipline").Value) + return ""; // N.v.t. var nn_disc = oRs(api2.sqlfield_alias(model, "ins_discipline")).Value; - if (nn_disc > 0) - return nn_disc; + var nn_total = oRs("nn_discipline").Value; + if (nn_total > 0) + return nn_disc + "/" + nn_total; return ""; }; function fnGroep(oRs, field, model) @@ -136,7 +139,7 @@ function model_fac_groeprechten (params) + " AND fac_groep_key = " + params.groep_key + ") fac_groeprechten"; } - if (params.functie_key > 0 && params.disc_key > 0) + else if (params.functie_key > 0 && params.disc_key > 0) { this.tablesql = "(SELECT *" + " FROM fac_groeprechten" @@ -162,7 +165,7 @@ function model_fac_groeprechten (params) { "dbs": "nn_disc", "label": L("ins_discipline_key"), - "typ": "number", + "typ": "varchar", val: fnDisc, "hidden_fld": true }; diff --git a/APPL/API2/model_ins_tab_discipline.inc b/APPL/API2/model_ins_tab_discipline.inc index 93067e8646..52654eef10 100644 --- a/APPL/API2/model_ins_tab_discipline.inc +++ b/APPL/API2/model_ins_tab_discipline.inc @@ -121,12 +121,14 @@ function model_ins_tab_discipline(disc_key, params) } this.autfunction = "WEB_PRSSYS"; - this.record_title = L("res_v_res_catalogus"); // TODO: De generieke termen + this.record_title = L("ins_discipline_key"); // TODO: De generieke termen this.records_title = L("res_v_res_catalogus_m"); var xparams = null; if (params.functie_key > 0) - xparams = { GET: { wheres: ["ins_discipline_module IN (SELECT fac_functie_module FROM fac_functie WHERE fac_functie_key = " + params.functie_key + ")"] } } + { + xparams = { GET: { wheres: ["ins_discipline_module = (SELECT fac_functie_module FROM fac_functie WHERE fac_functie_key = " + params.functie_key + ")"] } } + } this.REST_GET = generic_REST_GET(this, xparams); this.REST_POST = generic_REST_POST(this); diff --git a/APPL/MGT/fac_edit_groeprechten.asp b/APPL/MGT/fac_edit_groeprechten.asp new file mode 100644 index 0000000000..e07bac9a69 --- /dev/null +++ b/APPL/MGT/fac_edit_groeprechten.asp @@ -0,0 +1,149 @@ +<%@ language = "JavaScript" %> +<% /* + $Revision$ + $Id$ + + File: fac_edit_groeprechten.asp + Description: Toon een dialoog om rechten te bewerken + Parameters: + fac_groep + fac_functie + disc + Context: Popup vanuit fac_groep/fac_functie/ins_tab_discipline + Note: +*/ + %> + + + + +<% +var groep_key = getQParamInt("fac_groep"); +var functie_key = getQParamInt("fac_functie"); + +user.checkAutorisation("WEB_PRSSYS"); + +var sql = "SELECT * " + + " FROM fac_functie" + + " WHERE fac_functie_key = " + functie_key; +var oRs = Oracle.Execute(sql); +var flevel = oRs("fac_functie_min_level").Value; +var fdisc = oRs("fac_functie_discipline").Value; +if (fdisc) + var disc_key = getQParamInt("disc"); +var fdesc = oRs("fac_functie_omschrijving").Value; +oRs.Close(); + +var sql = "SELECT * " + + " FROM fac_groep" + + " WHERE fac_groep_key = " + groep_key; +var oRs = Oracle.Execute(sql); +var gdesc = oRs("fac_groep_omschrijving").Value; +var gremark = oRs("fac_groep_opmerking").Value; +oRs.Close(); + +function radioTR(name, label, LOV, val) +{ + Response.Write(""); + for (var i in LOV) + { + Response.Write(""); + + } + Response.Write(""); +} +%> + + +<% FCLTHeader.Generate() + + +%> + + + +
+ +<% BLOCK_START("grpRechten", L("lcl_res_deel_head1")); + + ROFIELDTR("fldtxt", L("fac_groep"), gdesc); + ROFIELDTR("fldtxt", L("fac_groep_opmerking"), gremark, { suppressEmpty: true} ); + ROFIELDTR("fldtxt", L("fac_functie"), fdesc); + if (disc_key > 0) + ROFIELDTR("fldtxt", L("ins_discipline_key"), Oracle.Get("ins_discipline_omschrijving", "ins_tab_discipline", "ins_discipline_key", disc_key)); + + var prsLOV = api2.splitLOV(buildPrsLevelLOV()); + var algLOV = api2.splitLOV(buildAlgLevelLOV()); + var jnLOV = { "-1": L("lcl_Yes"), "9": L("lcl_No") }; + + var prsread = 9; + var prswrite = 9; + var algread = 9; + var algwrite = 9; + var sql = "SELECT *" + + " FROM fac_groeprechten" + + " WHERE fac_groep_key = " + groep_key + + " AND fac_functie_key = " + functie_key; + if (fdisc) + sql += " AND ins_discipline_key = " + disc_key; + var oRs = Oracle.Execute(sql); + if (!oRs.Eof) + { + var prsread = oRs("fac_gebruiker_prs_level_read").Value; + var prswrite = oRs("fac_gebruiker_prs_level_write").Value; + var algread = oRs("fac_gebruiker_alg_level_read").Value; + var algwrite = oRs("fac_gebruiker_alg_level_read").Value; + } + oRs.Close(); + + // 0 is Ja/Nee + // 1 is Ja/Nee (alleen FAC_FAQUSE en PRS_MODAAN) + // 3 is Lees Ja/Nee en Schrijf Ja/Nee + // 7 is PRS lezen/schrijven WEB_FACMAN en WEB_BEZPAF + // 11 is ALG lezen/schrijven diversen + // 15 is PRS+ALG lezen/schrijven diversen + if (flevel & 4) // PRS + { + radioTR("prsread", L("fac_gebruiker_prs_level_read"), prsLOV, prsread); + radioTR("prswrite", L("fac_gebruiker_prs_level_write"), prsLOV, prswrite); + } + if (flevel & 8) // ALG + { + radioTR("algread", L("fac_gebruiker_alg_level_read"), algLOV, algread); + radioTR("algwrite", L("fac_gebruiker_alg_level_write"), algLOV, algwrite); + } + if ((flevel & (4 + 8)) == 0) + { + if (flevel == 1) + radioTR("algread", L("fac_gebruiker_toegang"), jnLOV, algread); + else + { + radioTR("algread", L("fac_gebruiker_lezen"), jnLOV, algread); + radioTR("algwrite", L("fac_gebruiker_schrijven"), jnLOV, algwrite); + } + + } + + BLOCK_END(); + buttons = []; + buttons.push({ title: L("lcl_submit"), action: "grp_submit()" }); + buttons.push({ title: L("lcl_cancel"), action: "gen_cancel()" }); + + CreateButtons(buttons); + IFACE.FORM_END(); +%> +
+ + \ No newline at end of file diff --git a/APPL/MGT/fac_functie.asp b/APPL/MGT/fac_functie.asp index 4d20618ec8..4d49eab82e 100644 --- a/APPL/MGT/fac_functie.asp +++ b/APPL/MGT/fac_functie.asp @@ -9,6 +9,8 @@ var disc_key = getQParamInt("disc", -1); var model = new model_fac_functie(null, { groep_key: groep_key, disc_key: disc_key }); + settings.overrule_setting("qp_maxrows", 250); // Toon alle 186 (2015.6) functies direkt + function fnrowData(oRs) { var funcdisc = oRs.Fields("discipline").Value; @@ -44,13 +46,14 @@ } }, "transit": { - "name": groep_key>0?"fac_groep":"disc", - "val": groep_key>0?groep_key:disc_key + "fac_groep": groep_key, + "disc" : disc_key } }; if (groep_key > 0) { - scf_params.search.labels.push({ "lbl": "GROEP", "txt" : groep_key }); + scf_params.search.labels.push({ "lbl": L("fac_groep"), "txt" : Oracle.Get("fac_groep_omschrijving", "fac_groep", groep_key)}); + scf_params.search.labels.push({ "lbl": L("fac_groep_opmerking"), "txt" : Oracle.Get("fac_groep_opmerking", "fac_groep", groep_key)}); scf_params.list.columns = scf_params.list.columns.concat([ "authorization.ins_discipline", @@ -62,7 +65,7 @@ } if (disc_key > 0) { - scf_params.search.labels.push({ "lbl": "DISC", "txt" : disc_key }); + scf_params.search.labels.push({ "lbl": L("ins_discipline_key"), "txt" : Oracle.Get("ins_discipline_omschrijving", "ins_tab_discipline", "ins_discipline_key", disc_key)}); scf_params.list.columns = scf_params.list.columns.concat([ "authorization.fac_groep", diff --git a/APPL/MGT/fac_functie.js b/APPL/MGT/fac_functie.js index 79d0989384..d3a84c7c1e 100644 --- a/APPL/MGT/fac_functie.js +++ b/APPL/MGT/fac_functie.js @@ -10,12 +10,13 @@ function edit_rechten(row) if (funData.groep_key > 0 && funData.funcdisc) // naar het overzicht per discipline { - var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + funData.groep_key + "&fac_functie=" + functie_key; + var url = "appl/mgt/ins_tab_discipline.asp?fac_groep=" + funData.groep_key + "&fac_functie=" + functie_key; FcltMgr.openDetail(url, { reuse: true }); } else if (funData.groep_key > 0) { - alert("Todo: rechten popupje groep {0} functie {1}".format(funData.groep_key, functie_key)); + var url = "fac_edit_groeprechten.asp?fac_groep={0}&fac_functie={1}".format(funData.groep_key, functie_key); + FcltMgr.openModalDetail(url, L("fac_groeprechten")); } else // eerst nog een groep erbij kiezen { diff --git a/APPL/MGT/fac_groep.asp b/APPL/MGT/fac_groep.asp index 193626a0a2..13df1d9d8b 100644 --- a/APPL/MGT/fac_groep.asp +++ b/APPL/MGT/fac_groep.asp @@ -38,21 +38,20 @@ js: ["./fac_groep.js"] }, "fnRowData": fnrowData, - "default_action": "edit_rechten" - // TODO: Maar via de knop de originele mode=wrap ondersteunen - //"actions": [ - // { action: "edit_rechten", caption: L("lcl_rechten") } - //] + "default_action": "edit_rechten", + // Via een knop de originele mode=wrap ondersteunen + "actions": [ + { action: "edit_groep", caption: L("fac_groep_edit") } + ] }, "transit": { - "name": "fac_functie", - "val": functie_key + "fac_functie": functie_key } }; if (functie_key > 0) { - scf_params.search.labels.push({ "lbl": "FUNCTIE", "txt" : functie_key }); + scf_params.search.labels.push({ "lbl": L("fac_functie"), "txt" : Oracle.Get("fac_functie_omschrijving", "fac_functie", functie_key)}); scf_params.list.columns = scf_params.list.columns.concat([ "authorization.ins_discipline", diff --git a/APPL/MGT/fac_groep.js b/APPL/MGT/fac_groep.js index 58dda167fd..6c2ca72625 100644 --- a/APPL/MGT/fac_groep.js +++ b/APPL/MGT/fac_groep.js @@ -15,7 +15,8 @@ function edit_rechten(row) } else if (grpData.functie_key > 0) { - alert("Todo: rechten popupje groep {0} functie {1}".format(groep_key, grpData.functie_key)); + var url = "fac_edit_groeprechten.asp?fac_groep={0}&fac_functie={1}".format(groep_key, grpData.functie_key); + FcltMgr.openModalDetail(url, L("fac_groeprechten")); } else // eerst nog een functie erbij kiezen { @@ -23,3 +24,10 @@ function edit_rechten(row) FcltMgr.openDetail(url, { reuse: true }); } } + +function edit_groep(row) +{ + var groep_key = row.getAttribute("ROWKEY"); + var url = "appl/mgt/fac_groep.asp?mode=wrap&id=" + groep_key; + FcltMgr.openDetail(url, { reuse: true }); +} \ No newline at end of file diff --git a/APPL/MGT/fac_groeprechten.asp b/APPL/MGT/fac_groeprechten.asp index 3770f85008..875930fce7 100644 --- a/APPL/MGT/fac_groeprechten.asp +++ b/APPL/MGT/fac_groeprechten.asp @@ -51,8 +51,7 @@ } }, "transit": { - "name": "fac_groep", - "val": groep_key + "fac_groep": groep_key } }; diff --git a/APPL/MGT/ins_tab_discipline.asp b/APPL/MGT/ins_tab_discipline.asp index 3c610d4cae..dc38a0050c 100644 --- a/APPL/MGT/ins_tab_discipline.asp +++ b/APPL/MGT/ins_tab_discipline.asp @@ -36,9 +36,9 @@ { "search": { "autosearch": true, + "labels" : [], "filters": [ - "name", - "module" + "name" ] }, "list": { @@ -58,21 +58,27 @@ } }, "transit": { - "name": "fac_groep", - "val": groep_key + "fac_groep": groep_key, + "fac_functie": functie_key } }; if (groep_key > 0 && functie_key > 0) { + scf_params.search.labels.push({ "lbl": L("fac_groep"), "txt" : Oracle.Get("fac_groep_omschrijving", "fac_groep", groep_key)}); + scf_params.search.labels.push({ "lbl": L("fac_groep_opmerking"), "txt" : Oracle.Get("fac_groep_opmerking", "fac_groep", groep_key)}); + scf_params.search.labels.push({ "lbl": L("fac_functie"), "txt" : Oracle.Get("fac_functie_omschrijving", "fac_functie", functie_key)}); scf_params.list.columns = scf_params.list.columns.concat([ - //"authorization.ins_discipline", "authorization.prs_level_read", "authorization.prs_level_write", "authorization.alg_level_read", "authorization.alg_level_write" ]); } + else + { + scf_params.search.filters.push("module"); + } scaffolding(model, scf_params); %> diff --git a/APPL/MGT/ins_tab_discipline.js b/APPL/MGT/ins_tab_discipline.js index 91bc9b632a..425c35e904 100644 --- a/APPL/MGT/ins_tab_discipline.js +++ b/APPL/MGT/ins_tab_discipline.js @@ -10,7 +10,8 @@ function edit_rechten(row) if (grpData.functie_key > 0 && grpData.groep_key) { - alert("Todo: rechten popupje groep {0} functie {1}".format(grpData.groep_key, grpData.functie_key)); + var url = "fac_edit_groeprechten.asp?fac_groep={0}&fac_functie={1}&disc={2}".format(grpData.groep_key, grpData.functie_key, disc_key); + FcltMgr.openModalDetail(url, L("fac_groeprechten")); } else if (grpData.functie_key > 0) { diff --git a/APPL/SCF/scaffolding_search.inc b/APPL/SCF/scaffolding_search.inc index 433bdb8d03..8faac65076 100644 --- a/APPL/SCF/scaffolding_search.inc +++ b/APPL/SCF/scaffolding_search.inc @@ -228,6 +228,15 @@ function scaffolding_search(model, scf_params) if (model.soft_delete) RWCHECKBOXTR("show_deleted", "fldcheck", L("lcl_scf_show_deleted"), defaults["show_deleted"]); + if (model.includes) + { + for (var i in model.includes) + { + if ("outertoggle" in model.includes[i]) + RWCHECKBOXTR("scf_outer", "fldcheck", model.includes[i]["outertoggle"].lbl, model.includes[i]["outertoggle"].def); + } + } + if ((model.list.autoGraph & 1) == 1) { var on = (model.list.autoGraph & 2) == 2; diff --git a/APPL/Shared/default.csx b/APPL/Shared/default.csx index 204f8e6190..f80b1695cb 100644 --- a/APPL/Shared/default.csx +++ b/APPL/Shared/default.csx @@ -2619,6 +2619,7 @@ body#mod_resmulti div#show_date_from { height: 250px } } #mod_wfexpression { width: 700px; } #mod_signature { height: 320px; } +#mod_grprecht { width: 800px; } div#mldsimilar { padding: 4px 4px 4px 10px; diff --git a/APPL/Shared/m_connections.inc b/APPL/Shared/m_connections.inc index 78d0ddb232..7eb072d7ec 100644 --- a/APPL/Shared/m_connections.inc +++ b/APPL/Shared/m_connections.inc @@ -148,6 +148,20 @@ SafeOracle.prototype.rs2hash = function _rs2hash (oRs) } return result; } +SafeOracle.prototype.Get = function _get (descfield, table, keyname, key) +{ + if (typeof key == "undefined") + { + key = keyname; + keyname = table + "_KEY"; + } + var sql = "SELECT {0} FROM {1} WHERE {2} = {3}".format(descfield, table, keyname, key); + var oRs = this.Execute(sql); + var res = oRs.Fields(0).Value; + oRs.Close(); + return res; +} + // Logfilename is eigenlijk al nodig *voordat* je naar de database gaat // Daarom cachen we die bij wijze van uitzondering in Application()