Files
Facilitor/APPL/API2/model_fac_gebruikersgroep.inc
Maykel Geerdink 755dd14f09 AAIT#33956: Tracking uitbreiden op grondbeginselen financiele & rechten inrichting.
svn path=/Website/trunk/; revision=33192
2017-03-20 14:29:39 +00:00

116 lines
3.5 KiB
PHP

<% /*
$Revision$
$Id$
File: model_fac_gebruikersgroep.inc
Description: Model voor fac_gebruikersgroep
Welke gebruiker zit in welke groep?
Context:
Notes:
*/
%>
<%
function model_fac_gebruikersgroep()
{
this.records_name = "usergroup";
this.record_name = "usergroups";
this.table = "fac_gebruikersgroep";
this.primary = "fac_gebruikersgroep_key";
this.autfunction = "WEB_PRSMSU";
this.record_title = L("fac_gebruikersgroep");
this.records_title = L("fac_gebruikersgroep_m");
this.fields = {
"id": {
"dbs": "fac_gebruikersgroep_key",
"label": L("lcl_key"),
"typ": "key",
"hidden_fld": true,
"required": true,
"filter": "exact",
"seq": "fac_s_fac_gebruikersgroep_key"
},
"authorizationgroup": {
"dbs": "fac_groep_key",
"label": L("fac_groep"),
"typ": "key",
"required": true,
"foreign": {
"tbl": "fac_groep",
"key": "fac_groep_key",
"desc": "fac_groep_omschrijving"
},
"uniquewith": "person"
},
"person": {
"dbs": "prs_perslid_key",
"label": L("prs_perslid"),
"typ": "key",
"required": true,
"foreign": "prs_perslid",
"uniquewith": "authorizationgroup"
}
};
this.list = {
"columns": [
//"id",
"authorizationgroup",
"person"
]
};
this.edit = {
modal: true
};
// Lidmaatschap van groepen met PRSSYS, FACTAB en FACFAC mag je alleen
// manipuleren als je zelf die rechten hebt
this._checkprotected = function(groep_key)
{
var exclude = [];
if (!user.has("WEB_PRSSYS"))
exclude.push("WEB_PRSSYS");
if (!user.has("WEB_FACTAB"))
exclude.push("WEB_FACTAB");
if (!user.has("WEB_FACFAC"))
exclude.push("WEB_FACFAC");
if (exclude.length)
{
var sql = "SELECT fac_groep_key"
+ " FROM fac_groeprechten fgr,"
+ " fac_functie ff"
+ " WHERE fgr.fac_functie_key = ff.fac_functie_key"
+ " AND fac_groep_key = " + groep_key
+ " AND ff.fac_functie_code in (" + safe.quoted_sql_join(exclude) + ")";
var oRs = Oracle.Execute(sql);
user.auth_required_or_abort(oRs.Eof);
oRs.Close()
}
}
this.REST_GET = generic_REST_GET(this);
this.REST_POST = function (params, jsondata)
{
this._checkprotected(jsondata.authorizationgroup);
return generic_REST_POST(this)(params, jsondata);
}
// this.REST_PUT = generic_REST_PUT(this); // updated is wat overkill
this.REST_DELETE = function (params, the_key)
{
var sql = "SELECT fac_groep_key"
+ " FROM fac_gebruikersgroep"
+ " WHERE fac_gebruikersgroep_key = " + the_key;
var oRs = Oracle.Execute(sql);
if (!oRs.Eof)
this._checkprotected(oRs("fac_groep_key").Value);
oRs.Close();
return generic_REST_DELETE(this)(params, the_key);
}
}
%>