File: scotts\widgets\external_links\server.js
(function () {
/**
*
* @class ExternalLinks.Server
* @constructor
* @extends Widget.Server
* @module Widgets
*/
data.links = [];
var links = new GlideRecord("sc_ordered_item_link"),
portal = $sp.getPortalRecord(),
date = new GlideDateTime(),
query,
link;
query = links.addQuery("u_commencement", "<=", date);
query.addOrCondition("u_commencement", "");
query = links.addQuery("u_expiration", ">=", date);
query.addOrCondition("u_expiration", "");
links.addQuery("u_select_string", $sp.getParameter("selection") || options.select_string);
// Require the portal to match the current portal
links.addQuery("u_sp_portal", portal.sys_id);
// The below replace the above line to allow the portal to be empty
// links.addQuery("u_sp_portal", portal.sys_id)
// .addOrCondition("u_sp_portal", "");
links.addQuery("u_active", true);
links.query();
while(links.next()) {
link = {};
link.order = parseInt(links.getValue("u_order"));
link.underlying_url = links.getValue("u_underlying_url");
link.select_string = links.getValue("u_select_string");
link.description = links.getValue("u_description");
link.portal = links.getValue("u_sp_portal");
link.label = links.getValue("link_text");
link.active = links.getValue("u_active");
link.sys_id = links.getValue("sys_id");
link.target = links.getValue("target");
link.url = links.getValue("link_url");
link.icon = links.getValue("u_icon");
link.name = links.getValue("name");
if(link.select_string || link.portal) {
// Don't add the link if select string & portal are not defined
data.links.push(link);
}
}
options.transparentBackground = options.transparentBackground === "true";
options.pageExpansion = options.pageExpansion || "quicklinks";
options.panel_grouping = options.panel_grouping || "default";
options.inlineExpansion = options.inlineExpansion == "true";
options.displayed = parseInt(options.displayed) || 5;
options.showColumn = options.showColumn == "true";
options.showHeader = options.showHeader == "true";
options.showFooter = options.showFooter == "true";
options.asRow = options.asRow === "true";
data.links.sort(function(a, b) {
return b.order - a.order;
});
data.expands = data.links.splice(options.displayed);
})();