216 lines
9.6 KiB
C++
216 lines
9.6 KiB
C++
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: fac.inc
|
|
Description: handige fac-functies
|
|
Context:
|
|
Note:
|
|
*/
|
|
|
|
// Je mag nog veronderstellen dat deze in shared mag?
|
|
|
|
fac = { myfunctionssqlstring:
|
|
function (prs_key)
|
|
{
|
|
// Maak functie-key-strings om in het IN (..) statement te gebruiken
|
|
// Dit zijn alle functies met ongeacht de disciplines; het kan dus zeker zo zijn
|
|
// dat deze functie niet voor alle bestaande disciplines geldig is.
|
|
lsql = "SELECT DISTINCT fac_functie_key functie"
|
|
+ ", MIN (fac_gebruiker_prs_level_read) prs_level_read"
|
|
+ ", MIN (fac_gebruiker_prs_level_write) prs_level_write"
|
|
+ ", MIN (fac_gebruiker_alg_level_read) alg_level_read"
|
|
+ ", MIN (fac_gebruiker_alg_level_write) alg_level_write"
|
|
+ " FROM fac_v_webgebruiker w"
|
|
+ " WHERE w.prs_perslid_key =" + prs_key
|
|
+ " GROUP BY w.fac_functie_key"
|
|
+ " ORDER BY 1";
|
|
|
|
var loRsF = Oracle.Execute( lsql );
|
|
var lmyfacfunctiekeys = "-1";
|
|
var lmyreadfacfunctiekeys = "-1";
|
|
var lmywritefacfunctiekeys = "-1";
|
|
while (!loRsF.eof){
|
|
var lnew = true;
|
|
if ( loRsF("prs_level_read").value < 9 && loRsF("alg_level_read").value < 9)
|
|
{
|
|
lmyfacfunctiekeys += ", "+loRsF("functie");
|
|
lnew = false;
|
|
lmyreadfacfunctiekeys += ", "+loRsF("functie");
|
|
}
|
|
if ( loRsF("prs_level_write").value < 9 && loRsF("alg_level_write").value < 9)
|
|
{
|
|
if (lnew) lmyfacfunctiekeys += ", "+loRsF("functie");
|
|
lmywritefacfunctiekeys += ", "+loRsF("functie");
|
|
}
|
|
loRsF.MoveNext();
|
|
}
|
|
return {read:lmyreadfacfunctiekeys, write:lmywritefacfunctiekeys, either:lmyfacfunctiekeys};
|
|
},
|
|
|
|
mydisciplinessqlstring:
|
|
function (prs_key, facfunctiecodeArray)
|
|
{
|
|
if (facfunctiecodeArray)
|
|
{
|
|
for (var i = 0; i < facfunctiecodeArray.length; i++)
|
|
{
|
|
facfunctiecodeArray[i] = safe.quoted_sql(facfunctiecodeArray[i]);
|
|
}
|
|
}
|
|
// Maak discipline-key-strings om in het IN (..) statement te gebruiken
|
|
// Dit zijn alle disciplines met ongeacht de functie; we weten dat disciplines
|
|
// uniek zijn over de modules heen.
|
|
lsql = "SELECT DISTINCT ins_discipline_key discipline"
|
|
+ ", MIN (fac_gebruiker_prs_level_read) prs_level_read"
|
|
+ ", MIN (fac_gebruiker_prs_level_write) prs_level_write"
|
|
+ ", MIN (fac_gebruiker_alg_level_read) alg_level_read"
|
|
+ ", MIN (fac_gebruiker_alg_level_write) alg_level_write"
|
|
+ " FROM fac_v_webgebruiker w"
|
|
+ (facfunctiecodeArray
|
|
? ", fac_functie f"
|
|
: "")
|
|
+ " WHERE w.ins_discipline_key IS NOT NULL"
|
|
+ " AND w.prs_perslid_key =" + prs_key
|
|
+ (facfunctiecodeArray
|
|
? " AND w.fac_functie_key = f.fac_functie_key"
|
|
+ " AND f.fac_functie_code IN (" + facfunctiecodeArray.join(",") + ")"
|
|
: "")
|
|
+ " GROUP BY w.ins_discipline_key"
|
|
+ " ORDER BY 1";
|
|
|
|
var loRsF = Oracle.Execute( lsql );
|
|
var lmydisciplineskeys = "-1";
|
|
var lmyreaddisciplineskeys = "-1";
|
|
var lmywritedisciplineskeys = "-1";
|
|
while (!loRsF.eof){
|
|
var lnew = true;
|
|
if ( loRsF("prs_level_read").value < 9 && loRsF("alg_level_read").value < 9)
|
|
{
|
|
lmydisciplineskeys += ", "+loRsF("discipline").Value;
|
|
lnew = false;
|
|
lmyreaddisciplineskeys += ", "+loRsF("discipline").Value;
|
|
}
|
|
if ( loRsF("prs_level_write").value < 9 && loRsF("alg_level_write").value < 9)
|
|
{
|
|
if (lnew) lmydisciplineskeys += ", "+loRsF("discipline").Value;
|
|
lmywritedisciplineskeys += ", "+loRsF("discipline").Value;
|
|
}
|
|
loRsF.MoveNext();
|
|
}
|
|
return {read:lmyreaddisciplineskeys, write:lmywritedisciplineskeys, either:lmydisciplineskeys};
|
|
},
|
|
|
|
localstring: function (st) {
|
|
//__Log(st + " ************************************************************************");
|
|
if (st === null)
|
|
return "";
|
|
mlabel = st;
|
|
if ( st.slice(0,4) == "lcl_" )
|
|
{
|
|
try {
|
|
mlabel = L (st);
|
|
}
|
|
catch(e) { /* mogelijk tijden *hot* upgrade nog niet gedefinieerd. Val terug op lcl_tekst */ };
|
|
}
|
|
return mlabel;
|
|
},
|
|
|
|
createOrClause: function (pfieldstr, pconditionstr, wholeword)
|
|
{
|
|
return fac.createOrClause2([pfieldstr], pconditionstr, wholeword);
|
|
},
|
|
|
|
createOrClause2: function (pfieldstrarr, pconditionstr, wholeword)
|
|
{
|
|
// returns a valid SQL condition given a fieldstring like "UPPER(prs_perslidnaam)"
|
|
// and a conditionstring like "Jan Piert Joris".
|
|
// It would then return
|
|
// "(UPPER(prs_perslidnaam) LIKE '%Jan%' AND UPPER(prs_perslidnaam) LIKE '%Piert%' AND UPPER(prs_perslidnaam) LIKE '%Joris%')"
|
|
// which is of course not what you intended; you should have uppered the conditionstring yourself
|
|
var conditions = pconditionstr.split(" ");
|
|
var resarr = [];
|
|
for (var i=0; i < conditions.length; i++)
|
|
{
|
|
if (conditions[i].length)
|
|
{
|
|
if (wholeword) // REGEXP_LIKE(' ' || fac_faq_answer || ' ', '(\WMelding\W)', 'i')
|
|
{
|
|
var fieldarr = [];
|
|
for (var j in pfieldstrarr)
|
|
{
|
|
fieldarr.push("REGEXP_LIKE(" + pfieldstrarr[j] + ", "+ safe.quoted_sql("(^|\\W)" + conditions[i] + "(\\W|$)") + ", 'i')");
|
|
}
|
|
resarr.push("(" + fieldarr.join(" OR ") + ")");
|
|
}
|
|
else
|
|
{
|
|
var fieldarr = [];
|
|
for (var j in pfieldstrarr)
|
|
{
|
|
fieldarr.push(pfieldstrarr[j] + " LIKE "+ safe.quoted_sql_wild("%"+conditions[i] + "%"));
|
|
}
|
|
resarr.push("(" + fieldarr.join(" OR ") + ")");
|
|
}
|
|
}
|
|
}
|
|
if (resarr.length)
|
|
return "(" + resarr.join(" AND ") + ")";
|
|
else
|
|
return "1=1"
|
|
},
|
|
|
|
createOrOrClause: function (pfieldstr, pconditionstr, wholeword)
|
|
{
|
|
// returns a valid SQL condition given a fieldstring like "UPPER(prs_perslidnaam)"
|
|
// and a conditionstring like "Jan Piert Joris".
|
|
// It would then return
|
|
// "(UPPER(prs_perslidnaam) LIKE '%Jan%' OR UPPER(prs_perslidnaam) LIKE '%Piert%' OR UPPER(prs_perslidnaam) LIKE '%Joris%')"
|
|
// which is of course not what you intended; you should have uppered the conditionstring yourself
|
|
var conditions = pconditionstr.split(" "); // Of split(/[,. ]+/)
|
|
var resarr = [];
|
|
for (i=0; i < conditions.length; i++)
|
|
{
|
|
if (conditions[i].length)
|
|
{
|
|
if (wholeword) // REGEXP_LIKE(' ' || fac_faq_answer || ' ', '(\WMelding\W)', 'i')
|
|
resarr.push("REGEXP_LIKE(" + pfieldstr + ", "+ safe.quoted_sql("(^|\\W)" + conditions[i] + "(\\W|$)") + ", 'i')");
|
|
else
|
|
resarr.push(pfieldstr+ " LIKE "+ safe.quoted_sql_wild("%"+conditions[i] + "%"));
|
|
}
|
|
}
|
|
|
|
if (resarr.length == 0)
|
|
resarr.push("1=1");
|
|
return "(" + resarr.join(" OR ") + ")";
|
|
},
|
|
|
|
getVSqlVerantwoordelijk: function(prsKeys)
|
|
{
|
|
// Kostenplaatsgroepverantwoordelijken
|
|
var v_sql_verantwoordelijk = "(SELECT kg.prs_perslid_key"
|
|
+ " , k.prs_kostenplaats_key"
|
|
+ " FROM prs_kostenplaats k"
|
|
+ " , prs_kostenplaatsgrp kg"
|
|
+ " WHERE kg.prs_kostenplaatsgrp_key = k.prs_kostenplaatsgrp_key"
|
|
+ " AND kg.prs_perslid_key IN (" + prsKeys + ")"
|
|
+ " GROUP BY kg.prs_perslid_key"
|
|
+ " , k.prs_kostenplaats_key)";
|
|
return v_sql_verantwoordelijk;
|
|
},
|
|
|
|
getfaqleveltext:
|
|
// Lever de string behorend bij faq-level p
|
|
function (p) {
|
|
var ps = "??";
|
|
p = parseInt(p, 10);
|
|
switch (p) {
|
|
case 1: { ps = L("lcl_faq_level1"); break; }
|
|
case 2: { ps = L("lcl_faq_level2"); break; }
|
|
case 3: { ps = L("lcl_faq_level3"); break; }
|
|
}
|
|
return ps;
|
|
}
|
|
}
|
|
|
|
%> |