From e0545a6ca4b02dc28f8772b6d20d895507e37249 Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Mon, 21 Mar 2016 09:02:54 +0000 Subject: [PATCH] FSN#35817 Autorisaties via API2/Scaffolding svn path=/Website/trunk/; revision=28548 --- APPL/API2/model_fac_functie.inc | 28 ++---- APPL/API2/model_fac_groep.inc | 7 +- APPL/API2/model_fac_groeprechten.inc | 39 ++++++-- APPL/API2/model_ins_tab_discipline.inc | 131 +++++++++++++++++++++++++ APPL/MGT/fac_functie.asp | 34 ++++--- APPL/MGT/fac_functie.js | 13 ++- APPL/MGT/fac_groep.asp | 28 ++++-- APPL/MGT/fac_groep.js | 20 +++- APPL/MGT/fac_groeprechten.asp | 60 +++++++++++ APPL/MGT/ins_tab_discipline.asp | 74 ++++++++++++++ APPL/MGT/ins_tab_discipline.js | 25 +++++ APPL/MGT/mgt_tools.inc | 4 +- 12 files changed, 400 insertions(+), 63 deletions(-) create mode 100644 APPL/API2/model_ins_tab_discipline.inc create mode 100644 APPL/MGT/fac_groeprechten.asp create mode 100644 APPL/MGT/ins_tab_discipline.asp create mode 100644 APPL/MGT/ins_tab_discipline.js diff --git a/APPL/API2/model_fac_functie.inc b/APPL/API2/model_fac_functie.inc index d2cb5b1743..78b3e59900 100644 --- a/APPL/API2/model_fac_functie.inc +++ b/APPL/API2/model_fac_functie.inc @@ -16,7 +16,7 @@ <% -function model_fac_functie (params) +function model_fac_functie (functie_key, params) { this.table = "fac_functie"; this.primary = "fac_functie_key"; @@ -77,21 +77,18 @@ function model_fac_functie (params) } }; - this.includes = { - "authorization": { - "model": new model_fac_groeprechten(params), - "joinfield": "fac_functie" - } - }; + if (params.groep_key > 0) + { + this.includes = {"authorization": + { "model": new model_fac_groeprechten(params), + "joinfield": "fac_functie" + }}; + } this.autfunction = "WEB_PRSMSU"; this.record_title = L("fac_functie"); this.records_title = L("fac_functie_m"); - this.search = { - title : L("lcl_rechten") - }; - this.edit = { "modal": true } @@ -101,13 +98,4 @@ function model_fac_functie (params) this.REST_PUT = generic_REST_PUT(this); this.REST_DELETE = generic_REST_DELETE(this); } - -/* -FACXSL_LCL('fac_functie_code', 'Code', 'Code', 'Kode', 'Code') -FACXSL_LCL('fac_functie_omschrijving', 'Omschrijving', 'Description', 'Umschreibung', 'Description') -FACXSL_LCL('fac_functie_module', 'Module', 'Module', 'Modul', 'Module') -FACXSL_LCL('fac_functie_info', 'Info', 'Info', 'Info', 'Info') -FACXSL_LCL('fac_functie', 'Facilitor functie', '@@', '@@', '@@') -FACXSL_LCL('fac_functie_m', 'FACILITOR functies', '@@', '@@', '@@') -*/ %> \ No newline at end of file diff --git a/APPL/API2/model_fac_groep.inc b/APPL/API2/model_fac_groep.inc index a7df4b4708..0221c2a982 100644 --- a/APPL/API2/model_fac_groep.inc +++ b/APPL/API2/model_fac_groep.inc @@ -4,7 +4,7 @@ File: model_fac_groep.inc - Description: Vanuit CodeCharge gegenereerd model voor fac_groep + Description: Model voor fac_groep Context: @@ -15,7 +15,7 @@ <% -function model_fac_groep(params) +function model_fac_groep(groep_key, params) { this.table = "fac_groep"; this.primary = "fac_groep_key"; @@ -56,7 +56,8 @@ function model_fac_groep(params) "joinfield": "fac_groep" } }; - if (params.groep_key > 0) + + if (params.functie_key > 0) { this.includes["authorization"] = { diff --git a/APPL/API2/model_fac_groeprechten.inc b/APPL/API2/model_fac_groeprechten.inc index f3b46c97f3..52173d6d74 100644 --- a/APPL/API2/model_fac_groeprechten.inc +++ b/APPL/API2/model_fac_groeprechten.inc @@ -8,13 +8,14 @@ Context: - Notes: + Notes: fac-groeprechten heeft drie 1-op-n relaties: fac_groep, + fac_functie en ins_discipline + We *eisen* dat je altijd minstens 1 van de drie bij een + instantiatie van het model moet meegeven + */ -%> -<% -// fac-groeprechten heeft drie 1-op-n relaties + // params kan bevatten een group_key, een disc_key en een functie_key -// function model_fac_groeprechten (params) { if (params && (params.groep_key > 0 || params.disc_key > 0 || params.functie_key > 0)) @@ -24,8 +25,13 @@ function model_fac_groeprechten (params) this.table = "fac_groeprechten"; this.primary = "fac_groeprechten_key"; - this.records_name = "fac_groeprechtens"; + this.records_name = "fac_groeprecht"; this.record_name = "fac_groeprechten"; + + this.autfunction = "WEB_PRSSYS"; + this.record_title = L("fac_groeprechten"); + this.records_title = L("fac_groeprechten_m"); + this.fields = { "id": { "dbs": "fac_groeprechten_key", @@ -40,7 +46,12 @@ function model_fac_groeprechten (params) "dbs": "fac_groep_key", "label": L("fac_groep_key"), "typ": "key", - "hidden_fld": true + "hidden_fld": true, + "foreign": { + "tbl": "fac_groep", + "key": "fac_groep_KEY", + "desc": "fac_groep_omschrijving" + } }, "fac_functie": { "dbs": "fac_functie_key", @@ -107,6 +118,14 @@ function model_fac_groeprechten (params) + " AND fac_groep_key = " + params.groep_key + ") fac_groeprechten"; } + if (params.functie_key > 0 && params.disc_key > 0) + { + this.tablesql = "(SELECT *" + + " FROM fac_groeprechten" + + " WHERE fac_functie_key = " + params.functie_key + + " AND ins_discipline_key = " + params.disc_key + + ") fac_groeprechten"; + } else if (params.functie_key > 0) { this.tablesql = "(SELECT MIN(fac_groeprechten_key) fac_groeprechten_key," @@ -120,6 +139,7 @@ function model_fac_groeprechten (params) + " FROM fac_groeprechten" + " WHERE fac_functie_key = " + params.functie_key + " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten"; + this.record_title += " TODO Functie: " + params.functie_key; this.fields["ins_discipline"] = { "dbs": "nn_disc", @@ -142,6 +162,7 @@ function model_fac_groeprechten (params) + " FROM fac_groeprechten" + " WHERE fac_groep_key = " + params.groep_key + " GROUP BY fac_groep_key, fac_functie_key) fac_groeprechten"; + this.record_title += " TODO Groep: " + params.groep_key; this.fields["ins_discipline"] = { "dbs": "nn_disc", @@ -156,6 +177,7 @@ function model_fac_groeprechten (params) "columns": [ "id", "fac_functie", + "fac_groep", "ins_discipline", "prs_level_read", "prs_level_write", @@ -163,9 +185,6 @@ function model_fac_groeprechten (params) "alg_level_write" ] }; - this.autfunction = "WEB_PRSSYS"; - this.record_title = L("fac_groeprechten"); - this.records_title = L("fac_groeprechten_m"); this.REST_GET = generic_REST_GET(this); this.REST_POST = generic_REST_POST(this); diff --git a/APPL/API2/model_ins_tab_discipline.inc b/APPL/API2/model_ins_tab_discipline.inc new file mode 100644 index 0000000000..d1618f5ea0 --- /dev/null +++ b/APPL/API2/model_ins_tab_discipline.inc @@ -0,0 +1,131 @@ +<% /* + $Revision$ + $Id$ + + File: model_ins_tab_discipline.inc + + Description: Model voor ins_tab_catalogus + + Context: + + Notes: Vooralsnog alleen gebruikt voor autorisie bewerkingen + Zou waarschijnlijk als basis kunnen dienen voor de diverse + 'discipline' van modules +*/ +%> + +<% +// Krijgt in params altijd een functie_key en groep_key +function model_ins_tab_discipline(disc_key, params) +{ + this.table = "ins_tab_discipline"; + this.primary = "ins_discipline_key"; + this.records_name = "reservationcatalogs"; + this.record_name = "reservationcatalog"; + this.fields = { + "id": { + "dbs": "ins_discipline_key", + "label": "Key", + "typ": "key", + "required": true, + "filter": "exact", + "seq": "ins_s_ins_discipline_key" + }, + "ins_discipline_module": { + "dbs": "ins_discipline_module", + "label": L("ins_discipline_module"), + "typ": "varchar", + "required": true, + "defaultvalue": "RES", + "hidden_fld": true + }, + "ins_discipline_min_level": { + "dbs": "ins_discipline_min_level", + "label": L("ins_discipline_min_level"), + "typ": "key", + "required": true, + "insertonly": true, + "LOV": L("ins_discipline_min_levelLOV"), + "LOVinit": "" + }, + "name": { + "dbs": "ins_discipline_omschrijving", + "label": L("ins_discipline_omschrijving"), + "typ": "varchar", + "filter": "like", + "translate": true, + "required": true + }, + "sequence": { + "dbs": "ins_discipline_volgnr", + "label": L("ins_discipline_volgnr"), + "typ": "number" + }, + "costtype": { + "dbs": "prs_kostensoort_key", + "label": L("prs_kostensoort_key"), + "typ": "key", + "foreign": "prs_kostensoort", + "LOVinit": "" + }, + "ins_discipline_kpnverplicht": { + "dbs": "ins_discipline_kpnverplicht", + "label": L("ins_discipline_kpnverplicht"), + "typ": "check" + }, + "ins_discipline_email": { + "dbs": "ins_discipline_email", + "label": L("ins_discipline_email"), + "typ": "varchar" + }, + "ins_discipline_ktopercentage": { + "dbs": "ins_discipline_ktopercentage", + "label": L("ins_discipline_ktopercentage"), + "typ": "number" + }, + "ins_discipline_ktodrempel": { + "dbs": "ins_discipline_ktodrempel", + "label": L("ins_discipline_ktodrempel"), + "typ": "number" + } + } + this.soft_delete = "ins_discipline_verwijder"; + this.list = { + "columns": [ + "id", + "ins_discipline_min_level", + "name", + "costtype", + "sequence" + ] + }; + this.search = { + "autosearch": true, + "filters": [ + "ins_discipline_min_level", + "costtype", + "name" + ] + }; + + if (params.groep_key > 0 && params.functie_key > 0) + { + this.includes = {"authorization": + { "model": new model_fac_groeprechten(params), + "joinfield": "ins_discipline" + }}; + } + + this.autfunction = "WEB_PRSSYS"; + this.record_title = L("res_v_res_catalogus"); // 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 + ")"] } } + this.REST_GET = generic_REST_GET(this, xparams); + this.REST_POST = generic_REST_POST(this); + this.REST_PUT = generic_REST_PUT(this); + this.REST_DELETE = generic_REST_DELETE(this); +} +%> \ No newline at end of file diff --git a/APPL/MGT/fac_functie.asp b/APPL/MGT/fac_functie.asp index ff24a373c6..1752777aea 100644 --- a/APPL/MGT/fac_functie.asp +++ b/APPL/MGT/fac_functie.asp @@ -5,16 +5,14 @@ <% - var fac_groep_key = getQParamInt("fac_groep", -1); + var groep_key = getQParamInt("fac_groep", -1); var disc_key = getQParamInt("disc", -1); - var functie_key = getQParamInt("id", getQParamInt("fac_functie", -1)); - var model = new model_fac_functie({ groep_key: fac_groep_key, disc_key: disc_key, functie_key: functie_key }); - + var model = new model_fac_functie(null, { groep_key: groep_key, disc_key: disc_key }); function fnrowData(oRs) { var funcdisc = oRs.Fields("discipline").Value; - var data = {funcdisc: funcdisc, groep_key: fac_groep_key}; + var data = {funcdisc: funcdisc, groep_key: groep_key}; return JSON.stringify(data); } @@ -29,14 +27,15 @@ "list": { "columns": [ "id", - "description", + //"module", "name", - "authorization.ins_discipline", - "authorization.prs_level_read", - "authorization.prs_level_write", - "authorization.alg_level_read", - "authorization.alg_level_write" + "description" ], + "orderby": [ + "module", + "name", + "description" + ], "default_action": "edit_rechten", "fnRowData": fnrowData, "requires": { @@ -45,8 +44,19 @@ }, "transit": { "name": "fac_groep", - "val": fac_groep_key + "val": groep_key } }; + if (groep_key > 0) + { + 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" + ]); + } scaffolding(model, scf_params); %> diff --git a/APPL/MGT/fac_functie.js b/APPL/MGT/fac_functie.js index b377023b9c..bd1802971c 100644 --- a/APPL/MGT/fac_functie.js +++ b/APPL/MGT/fac_functie.js @@ -8,16 +8,19 @@ function edit_rechten(row) var functie_key = row.getAttribute("ROWKEY"); var funData = eval("(" + row.getAttribute("ROWDATA") + ")"); - if (funData.funcdisc) + if (funData.groep_key > 0 && funData.funcdisc) // naar het overzicht per discipline { - var url = "appl/mgt/fac_functie.asp?id=" + functie_key + "&fac_groep=" + funData.groep_key; + var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + funData.groep_key + "&fac_functie=" + functie_key; FcltMgr.openDetail(url, { reuse: true }); } - else + else if (funData.groep_key > 0) { - var url = "appl/mgt/fac_functie.asp?fac_groep=" + funData.groep_key; alert("Todo: rechten popupje groep {0} functie {1}".format(funData.groep_key, functie_key)); - //FcltMgr.openDetail(url, { reuse: true }); + } + else // eerst nog een groep erbij kiezen + { + var url = "appl/mgt/fac_groep.asp?fac_functie=" + functie_key; + FcltMgr.openDetail(url, { reuse: true }); } } \ No newline at end of file diff --git a/APPL/MGT/fac_groep.asp b/APPL/MGT/fac_groep.asp index 884c87e582..46aa35365f 100644 --- a/APPL/MGT/fac_groep.asp +++ b/APPL/MGT/fac_groep.asp @@ -5,11 +5,17 @@ <% - var fac_groep_key = getQParamInt("id", getQParamInt("fac_groep", -1)); + var functie_key = getQParamInt("fac_functie", -1); var disc_key = getQParamInt("disc", -1); - var functie_key = getQParamInt("functie_key", -1); - var model = new model_fac_groep({ groep_key: fac_groep_key, disc_key: disc_key, functie_key: functie_key }); + var model = new model_fac_groep(null, { disc_key: disc_key, functie_key: functie_key }); + + function fnrowData(oRs) + { + var funcdisc = oRs.Fields("discipline").Value; + var data = {funcdisc: funcdisc, functie_key: functie_key}; + return JSON.stringify(data); + } scf_params = { @@ -29,18 +35,23 @@ "requires": { js: ["./fac_groep.js"] }, - "actions": [ - { action: "edit_rechten", caption: L("lcl_rechten") } - ] + "fnRowData": fnrowData, + "default_action": "edit_rechten" + // TODO: Maar via de knop de originele mode=wrap ondersteunen + //"actions": [ + // { action: "edit_rechten", caption: L("lcl_rechten") } + //] }, "transit": { "name": "fac_functie", "val": functie_key } }; - if (fac_groep_key) + + if (functie_key > 0) { - scf_params.list.columns.concat([ + scf_params.list.columns = + scf_params.list.columns.concat([ "authorization.ins_discipline", "authorization.prs_level_read", "authorization.prs_level_write", @@ -48,5 +59,6 @@ "authorization.alg_level_write" ]); } + scaffolding(model, scf_params); %> diff --git a/APPL/MGT/fac_groep.js b/APPL/MGT/fac_groep.js index 0ba1b7ae9a..58dda167fd 100644 --- a/APPL/MGT/fac_groep.js +++ b/APPL/MGT/fac_groep.js @@ -6,6 +6,20 @@ function edit_rechten(row) { var groep_key = row.getAttribute("ROWKEY"); - var url = "appl/mgt/fac_functie.asp?fac_groep=" + groep_key; - FcltMgr.openDetail(url, { reuse: true }); -} \ No newline at end of file + var grpData = eval("(" + row.getAttribute("ROWDATA") + ")"); + + if (grpData.functie_key > 0 && grpData.funcdisc) // naar het overzicht per discipline + { + var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + groep_key + "&fac_functie=" + grpData.functie_key; + FcltMgr.openDetail(url, { reuse: true }); + } + else if (grpData.functie_key > 0) + { + alert("Todo: rechten popupje groep {0} functie {1}".format(groep_key, grpData.functie_key)); + } + else // eerst nog een functie erbij kiezen + { + var url = "appl/mgt/fac_functie.asp?fac_groep=" + groep_key; + FcltMgr.openDetail(url, { reuse: true }); + } +} diff --git a/APPL/MGT/fac_groeprechten.asp b/APPL/MGT/fac_groeprechten.asp new file mode 100644 index 0000000000..3770f85008 --- /dev/null +++ b/APPL/MGT/fac_groeprechten.asp @@ -0,0 +1,60 @@ +<%@language = "javascript" %> +<% /* + $Revision$ + $Id$ + + File: model_fac_groeprechten.inc + + Description: Dit is het model om de *rechten* van een groep voor diverse + functies te beheren. + Veronderstelt dat groep en functie al bekend zijn + Context: + + Notes: +*/ +%> + + + + + +<% + var groep_key = getQParamInt("fac_groep"); + var functie_key = getQParamInt("fac_functie"); + var model = new model_fac_groeprechten({ groep_key: groep_key, functie_key: functie_key }); + + var scf_params = + { + "search": { + "autosearch": true, + "filters": [ + "module" + ] + }, + "list": { + "columns": [ + "id", + "ins_discipline", + "prs_level_read", + "prs_level_write", + "alg_level_read", + "alg_level_write" + ], + "xxxorderby": [ + "module", + "name", + "description" + ], + "default_action": "edit_rechten", + "requires": { + js: ["./fac_functie.js"] + } + }, + "transit": { + "name": "fac_groep", + "val": groep_key + } + }; + + scaffolding(model, scf_params); +%> diff --git a/APPL/MGT/ins_tab_discipline.asp b/APPL/MGT/ins_tab_discipline.asp new file mode 100644 index 0000000000..4c96f92c36 --- /dev/null +++ b/APPL/MGT/ins_tab_discipline.asp @@ -0,0 +1,74 @@ +<%@language = "javascript" %> +<% /* + $Revision$ + $Id$ + + File: ins_tab_discipline.inc + + Description: Dit is het model om de *rechten* van een discipline voor diverse + functies te beheren. + Veronderstelt vooralsnog dat groep en functie al bekend zijn + Context: + + Notes: +*/ +%> + + + + + +<% + var groep_key = getQParamInt("fac_groep", -1); + var functie_key = getQParamInt("fac_functie", -1); + var model = new model_ins_tab_discipline(null, { groep_key: groep_key, functie_key: functie_key }); + + function fnrowData(oRs) + { + var data = {functie_key: functie_key, groep_key: groep_key}; + return JSON.stringify(data); + } + + var scf_params = + { + "search": { + "autosearch": true, + "filters": [ + "name" + ] + }, + "list": { + "columns": [ + "id", + "name" + ], + "xxxorderby": [ + "module", + "name", + "description" + ], + "default_action": "edit_rechten", + "fnRowData": fnrowData, + "requires": { + js: ["./ins_tab_discipline.js"] + } + }, + "transit": { + "name": "fac_groep", + "val": groep_key + } + }; + + if (groep_key > 0 && functie_key > 0) + { + 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" + ]); + } + scaffolding(model, scf_params); +%> diff --git a/APPL/MGT/ins_tab_discipline.js b/APPL/MGT/ins_tab_discipline.js new file mode 100644 index 0000000000..8a78fd81f9 --- /dev/null +++ b/APPL/MGT/ins_tab_discipline.js @@ -0,0 +1,25 @@ +/* + $Revision$ + $Id$ +*/ + +function edit_rechten(row) +{ + var disc_key = row.getAttribute("ROWKEY"); + var grpData = eval("(" + row.getAttribute("ROWDATA") + ")"); + + if (grpData.functie_key > 0 && grpData.groep_key) + { + alert("Todo: rechten popupje groep {0} functie {1}".format(grpData.groep_key, grpData.functie_key)); + } + else if (grpData.functie_key > 0) + { + var url = "appl/mgt/ins_tab_discipline.asp?mode=list&fac_groep=" + grpData.groep_key + "&fac_functie=" + grpData.functie_key; + FcltMgr.openDetail(url, { reuse: true }); + } + else // eerst nog een functie erbij kiezen + { + var url = "appl/mgt/fac_functie.asp?fac_groep=" + grpData.groep_key; + FcltMgr.openDetail(url, { reuse: true }); + } +} diff --git a/APPL/MGT/mgt_tools.inc b/APPL/MGT/mgt_tools.inc index be7f1f15ab..d05aa801ad 100644 --- a/APPL/MGT/mgt_tools.inc +++ b/APPL/MGT/mgt_tools.inc @@ -308,7 +308,7 @@ function buildAlgLevelLOV() + ";3;" + L("lcl_building") + ";4;" + L("lcl_building") + ";5;" + L("lcl_room") - + ";9;" + L("Geen"); + + ";9;" + L("fac_functie_auth_none"); return AlgLevelLOV; } @@ -321,7 +321,7 @@ function buildPrsLevelLOV() + ";3;" + L("lcl_dep_name_level3") + ";4;" + L("lcl_dep_name_level4") + ";5;" + L("lcl_dep_name_level5") - + ";9;" + L("Geen"); + + ";9;" + L("fac_functie_auth_none"); return PrsLevelLOV; } %> \ No newline at end of file