use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class ScooldUtils method getDefaultThemeObject.
private Sysprop getDefaultThemeObject() {
String themeName = "default";
Sysprop s = new Sysprop("theme" + Config.SEPARATOR + "custom");
s.setName(themeName);
s.addProperty("theme", "");
FILE_CACHE.put("theme", themeName);
FILE_CACHE.put(getThemeKey(themeName), loadResource(getThemeKey(themeName)));
return s;
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class ScooldUtils method getSpaceIdFromCookie.
public String getSpaceIdFromCookie(Profile authUser, HttpServletRequest req) {
if (isAdmin(authUser) && req.getParameter("space") != null) {
// API override
Sysprop s = pc.read(getSpaceId(req.getParameter("space")));
if (s != null) {
return s.getId() + Config.SEPARATOR + s.getName();
}
}
String spaceAttr = (String) req.getAttribute(SPACE_COOKIE);
String spaceValue = StringUtils.isBlank(spaceAttr) ? Utils.base64dec(getCookieValue(req, SPACE_COOKIE)) : spaceAttr;
String space = getValidSpaceId(authUser, spaceValue);
return (isAllSpaces(space) && isMod(authUser)) ? DEFAULT_SPACE : verifyExistingSpace(authUser, space);
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class ScooldUtils method setCustomTheme.
public void setCustomTheme(String themeName, String themeCSS) {
String id = "theme" + Config.SEPARATOR + "custom";
boolean isCustom = "custom".equalsIgnoreCase(themeName);
String css = isCustom ? themeCSS : "";
Sysprop custom = new Sysprop(id);
custom.setName(StringUtils.isBlank(css) && isCustom ? "default" : themeName);
custom.addProperty("theme", css);
customTheme = pc.create(custom);
FILE_CACHE.put("theme", themeName);
FILE_CACHE.put(getThemeKey(themeName), isCustom ? css : loadResource(getThemeKey(themeName)));
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class ScooldUtils method unsubscribeFromNotifications.
@SuppressWarnings("unchecked")
public void unsubscribeFromNotifications(String email, String channelId) {
if (!StringUtils.isBlank(email) && !StringUtils.isBlank(channelId)) {
Sysprop s = pc.read(channelId);
if (s == null || !s.hasProperty("emails")) {
s = new Sysprop(channelId);
s.addProperty("emails", new LinkedList<>());
}
Set<String> emails = new HashSet<>((List<String>) s.getProperty("emails"));
if (emails.remove(email)) {
s.addProperty("emails", emails);
pc.create(s);
}
}
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class ScooldUtils method buildSpaceObject.
public Sysprop buildSpaceObject(String space) {
space = Utils.abbreviate(space, 255);
space = space.replaceAll(Config.SEPARATOR, "");
String spaceId = getSpaceId(Utils.noSpaces(Utils.stripAndTrim(space, " "), "-"));
Sysprop s = new Sysprop(spaceId);
s.setType("scooldspace");
s.setName(space);
return s;
}
Aggregations