FSN#35817 Autorisaties via API2/Scaffolding

svn path=/Website/trunk/; revision=28587
This commit is contained in:
Jos Groot Lipman
2016-03-22 21:03:30 +00:00
parent 67e13fa1df
commit bc92fc04a9
16 changed files with 240 additions and 33 deletions

View File

@@ -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);
}
}
}

View File

@@ -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" }
}};
}

View File

@@ -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" }
};
}

View File

@@ -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
};

View File

@@ -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);

View File

@@ -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:
*/
%>
<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../mgt/mgt_tools.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../api2/model_fac_groeprechten.inc" -->
<%
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("<tr><td><label>" + label + "</label></td><td>");
for (var i in LOV)
{
Response.Write("<label><input name=\"" + name + "\" type=\"radio\" value=\"" + i + "\""
+ ((i == val)?" checked":"")
+">");
Response.Write(safe.html(LOV[i]) + "</label>");
}
Response.Write("</td></tr>");
}
%>
<html>
<head>
<% FCLTHeader.Generate()
%>
<script>
function grp_submit()
{
if (!validateForm("u2"))
return false;
$.post($("form[name=u2]")[0].action, $("[name=u2]").serialize(), FcltCallbackClose, "json");
return true; // disable button
}
</script>
</head>
<body class="modal" id="mod_grprecht">
<form name="u2" action="fac_edit_groeprechten_save.asp" method="post">
<% 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();
%>
</form>
</body>
</html>

View File

@@ -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",

View File

@@ -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
{

View File

@@ -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",

View File

@@ -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 });
}

View File

@@ -51,8 +51,7 @@
}
},
"transit": {
"name": "fac_groep",
"val": groep_key
"fac_groep": groep_key
}
};

View File

@@ -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);
%>

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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()