Files
Facilitor/APPL/PDA/portalnews.inc
Jos Groot Lipman b30badcae2 Merge 2025.2 Gold A patches
svn path=/Website/trunk/; revision=69758
2025-07-14 08:13:36 +00:00

156 lines
6.4 KiB
SQL

<% /*
$Revision$
$Id$
Shared function for showing the news
*/
// Toon het algemene nieuws, evt. specifiek voor deze locatie
function portalnews(ploc, pgeb, pshowInt, mode, fac_nieuws_key)
{
mode = mode || 0; // 0; All news; 1; Horizontal scrollable preview mode
// Algemene berichten zonder plaatsaanduiding
var sqln = "SELECT DISTINCT " + lcl.xsqla('fac_nieuws_titel', 'fac_nieuws_key')
+ " ," + lcl.xsqla('fac_nieuws_omschrijving', 'fac_nieuws_key')
+ " , fac_nieuws_key"
+ " , fac_nieuws_image"
+ " , fac_nieuws_van"
+ " , fac_nieuws_aanmaak"
+ " FROM fac_nieuws n"
+ " WHERE n.fac_nieuws_onrgoed_key IS NULL"
+ " AND (n.fac_nieuws_van IS NULL OR SYSDATE >= n.fac_nieuws_van)"
+ " AND (n.fac_nieuws_tot IS NULL OR SYSDATE < n.fac_nieuws_tot + 1)"
+ " AND ( (n.fac_groep_key IN (SELECT fac_groep_key"
+ " FROM fac_gebruikersgroep"
+ " WHERE prs_perslid_key = " + user_key
+ " )"
+ " )"
+ " OR (fac_groep_key IS NULL)"
+ " )"
+ " AND n.fac_nieuws_parentkey IS NULL"
+ (fac_nieuws_key > 0
? " AND fac_nieuws_key = " + fac_nieuws_key
: " AND BITAND(fac_nieuws_show, "+pshowInt+") = " + pshowInt);
// Nieuwsberichten die plaatsgebonden zijn en gerelateerd aan de actieve plaats
if (ploc && ploc > -1)
{
sqln += " UNION "
+ "SELECT DISTINCT " + lcl.xsqla('fac_nieuws_titel', 'fac_nieuws_key')
+ " ," + lcl.xsqla('fac_nieuws_omschrijving', 'fac_nieuws_key')
+ " , fac_nieuws_key"
+ " , fac_nieuws_image"
+ " , fac_nieuws_van"
+ " , fac_nieuws_aanmaak"
+ " FROM fac_nieuws n"
+ " WHERE n.fac_nieuws_onrgoed_niveau = 'L'"
+ " AND n.fac_nieuws_onrgoed_key = " + ploc
+ " AND (n.fac_nieuws_van IS NULL OR SYSDATE >= n.fac_nieuws_van)"
+ " AND (n.fac_nieuws_tot IS NULL OR SYSDATE < n.fac_nieuws_tot + 1)"
+ " AND n.fac_nieuws_parentkey IS NULL"
+ (fac_nieuws_key > 0
? " AND fac_nieuws_key = " + fac_nieuws_key
: " AND BITAND(fac_nieuws_show, "+pshowInt+") = " + pshowInt);
if (pgeb && pgeb > -1) { // Als ik het gebouw weet, doe ik het gebouwnieuws er ook bij
sqln += " UNION "
+ "SELECT DISTINCT " + lcl.xsqla('fac_nieuws_titel', 'fac_nieuws_key')
+ " , " + lcl.xsqla('fac_nieuws_omschrijving', 'fac_nieuws_key')
+ " , fac_nieuws_key"
+ " , fac_nieuws_image"
+ " , fac_nieuws_van"
+ " , fac_nieuws_aanmaak"
+ " FROM fac_nieuws n "
+ " WHERE n.fac_nieuws_onrgoed_niveau = 'G'"
+ " AND n.fac_nieuws_onrgoed_key = " + pgeb
+ " AND (n.fac_nieuws_van IS NULL OR SYSDATE >= n.fac_nieuws_van)"
+ " AND (n.fac_nieuws_tot IS NULL OR SYSDATE < n.fac_nieuws_tot + 1)"
+ " AND n.fac_nieuws_parentkey IS NULL"
+ (fac_nieuws_key > 0
? " AND fac_nieuws_key = " + fac_nieuws_key
: " AND BITAND(fac_nieuws_show, "+pshowInt+") = " + pshowInt);
}
}
sqln += " ORDER BY fac_nieuws_van DESC";
function fnNieuwIcon (oRs) {
var icon = oRs("fac_nieuws_image").Value;
var result = "";
if (icon && icon.match(/^fa-/)) {
result = I(icon, { "fa_fw": false });
} else {
var props = flexProps("NEWS", oRs("fac_nieuws_key").Value, undefined, undefined, { cacheablehmac: true });
if (props.files && props.files.length) {
result = "<img src='" + safe.htmlattr(props.files[0].deepurl) + "'>";
}
}
return result;
}
function fnNieuwsOmschrijving (oRs)
{
var allowHtml = S("fac_html_strictness") == 0; // Deprecated, maar nog wel backwards compatible voor oude berichten
if (allowHtml) {
var sql_v = "SELECT adm_tracking_date" // Berichten gemaakt voor deze datum mogen nog html bevatten
+ " FROM adm_tracking"
+ " WHERE adm_tracking_name = 'upgrade20232.inc'";
var oRs_v = Oracle.Execute(sql_v);
if (!oRs_v.EoF) {
allowHtml = new Date(oRs("fac_nieuws_aanmaak").Value).getTime() < new Date(oRs_v("adm_tracking_date").Value).getTime();
}
oRs_v.Close();
}
var safe_oms = "";
if (mode === 1) {
return safe.html(shared.stripbbcodes(oRs("fac_nieuws_omschrijving").value));
} else if (allowHtml) {
safe_oms = oRs("fac_nieuws_omschrijving").value;
} else {
safe_oms = safe.fclthtml(oRs("fac_nieuws_omschrijving").value, { "file_params": { "module": "MSG", "key": oRs("fac_nieuws_key").value }});
}
return (oRs("fac_nieuws_omschrijving").Value? "<div class='portalnewstext'>" + safe_oms + "</div>" : "");
}
function fnLinkColumn(oRs) {
if (fac_nieuws_key > 0 || !mode) {
return "";
}
return "portalnews.asp?fac_nieuws_key=" + oRs("fac_nieuws_key").Value;
}
function fnNieuwsTitel (oRs) {
var titel = oRs("fac_nieuws_titel").Value || "";
if (S("fac_html_strictness") == 1) {
titel = safe.html(titel);
}
return titel;
}
var params = {
sql: sqln,
headerColumn: fnNieuwsTitel,
ID: "newstable",
layout: "card",
iconColumn: fnNieuwIcon,
contentColumn: fnNieuwsOmschrijving,
linkColumn: fnLinkColumn,
emptySetString: "",
noSearch: true,
showAll: true
};
if (mode === 1) {
params.wrapper = {
"layout": "horizontal",
"title": L("lcl_mynews"),
"moreLink": "portalnews.asp"
}
}
var rst = new ResultsetTable(params);
var cnt = rst.processResultset();
}
%>