List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getBoolean
public static boolean getBoolean(String name, boolean defaultValue)
From source file:com.liferay.contenttargeting.rules.age.AgeRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context) { int youngerThan = 100; int olderThan = 0; if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {//from w ww .j a va 2 s . com JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); youngerThan = jsonObj.getInt("youngerThan"); olderThan = jsonObj.getInt("olderThan"); } catch (JSONException jse) { } } context.put("youngerThan", youngerThan); context.put("olderThan", olderThan); boolean birthdayEnabled = false; Company company = (Company) context.get("company"); try { birthdayEnabled = PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_BIRTHDAY); } catch (SystemException se) { } context.put("birthdayEnabled", birthdayEnabled); }
From source file:com.liferay.contenttargeting.rules.gender.GenderRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context) { String gender = StringPool.BLANK; if (ruleInstance != null) { gender = ruleInstance.getTypeSettings(); }/*from ww w. j ava2 s . c o m*/ context.put("gender", gender); boolean genderEnabled = false; Company company = (Company) context.get("company"); try { genderEnabled = PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_MALE); } catch (SystemException se) { } context.put("genderEnabled", genderEnabled); }
From source file:com.liferay.contenttargeting.trackingactions.form.FormTrackingAction.java
License:Open Source License
@Override protected void populateContext(TrackingActionInstance trackingActionInstance, Map<String, Object> context) { String alias = StringPool.BLANK; String elementId = StringPool.BLANK; String eventType = StringPool.BLANK; if (trackingActionInstance != null) { alias = trackingActionInstance.getAlias(); elementId = trackingActionInstance.getElementId(); eventType = trackingActionInstance.getEventType(); }//from www .j a va2s. c om context.put("alias", alias); context.put("elementId", elementId); context.put("eventType", eventType); context.put("eventTypes", getEventTypes()); boolean trackingFormEnabled = false; Company company = (Company) context.get("company"); try { trackingFormEnabled = PrefsPropsUtil.getBoolean(company.getCompanyId(), "content.targeting.analytics.form.enabled"); } catch (SystemException se) { } context.put("trackingFormEnabled", trackingFormEnabled); }
From source file:com.liferay.contenttargeting.trackingactions.link.LinkTrackingAction.java
License:Open Source License
@Override protected void populateContext(TrackingActionInstance trackingActionInstance, Map<String, Object> context) { String alias = StringPool.BLANK; String elementId = StringPool.BLANK; String eventType = StringPool.BLANK; if (trackingActionInstance != null) { alias = trackingActionInstance.getAlias(); elementId = trackingActionInstance.getElementId(); eventType = trackingActionInstance.getEventType(); }//from www. j a va 2 s . co m context.put("alias", alias); context.put("elementId", elementId); context.put("eventType", eventType); context.put("eventTypes", getEventTypes()); boolean trackingLinkEnabled = false; Company company = (Company) context.get("company"); try { trackingLinkEnabled = PrefsPropsUtil.getBoolean(company.getCompanyId(), "content.targeting.analytics.link.enabled"); } catch (SystemException se) { } context.put("trackingLinkEnabled", trackingLinkEnabled); }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
@Override public LearningActivity addLearningActivity(LearningActivity learningActivity, ServiceContext serviceContext) throws SystemException, PortalException { LearningActivity retorno = this.addLearningActivity(learningActivity.getTitle(), learningActivity.getDescription(), learningActivity.getCreateDate(), learningActivity.getStartdate(), learningActivity.getEnddate(), learningActivity.getTypeId(), learningActivity.getTries(), learningActivity.getPasspuntuation(), learningActivity.getModuleId(), learningActivity.getExtracontent(), learningActivity.getFeedbackCorrect(), learningActivity.getFeedbackNoCorrect(), serviceContext); retorno.setPrecedence(learningActivity.getPrecedence()); retorno.setPriority(learningActivity.getPriority()); retorno.setWeightinmodule(learningActivity.getWeightinmodule()); learningActivityPersistence.update(retorno, true); //auditing// w ww .jav a2s .c om AuditingLogFactory.audit(retorno.getCompanyId(), retorno.getGroupId(), LearningActivity.class.getName(), retorno.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.ADD, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(retorno.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && learningActivity.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(retorno.getGroupId()); if (!listaUsuarios.isEmpty()) { Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission(retorno.getGroupId(), "com.liferay.lms.model", retorno.getGroupId(), "VIEW_RESULTS") && !retorno.isInactive() && !retorno.isExpired() && !moduleService.isLocked(retorno.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(retorno.getGroupId()).isInactive() && !courseLocalService.getCourseByGroupCreatedId(retorno.getGroupId()).isExpired() && !courseLocalService.getCourseByGroupCreatedId(retorno.getGroupId()).isClosed()) { String courseTitle = courseLocalService.getCourseByGroupCreatedId(retorno.getGroupId()) .getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.new.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.new.body", new String[] { retorno.getTitle(u.getLocale()), courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, retorno.getStartdate(), retorno.getEnddate(), u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } return retorno; }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
public LearningActivity addLearningActivity(String title, String description, java.util.Date createDate, java.util.Date startDate, java.util.Date endDate, int typeId, long tries, int passpuntuation, long moduleId, String extracontent, String feedbackCorrect, String feedbackNoCorrect, ServiceContext serviceContext) throws SystemException, PortalException { String titleAux = title;/* w ww . j a va2 s . c om*/ long userId = serviceContext.getUserId(); LearningActivity larn = learningActivityPersistence .create(counterLocalService.increment(LearningActivity.class.getName())); larn.setCompanyId(serviceContext.getCompanyId()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setUserId(userId); larn.setUserName(userLocalService.getUser(userId).getFullName()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setDescription(description); larn.setTypeId(typeId); larn.setTitle(title); larn.setStartdate(startDate); larn.setCreateDate(new java.util.Date(System.currentTimeMillis())); larn.setModifiedDate(new java.util.Date(System.currentTimeMillis())); larn.setEnddate(endDate); larn.setTries(tries); larn.setPasspuntuation(passpuntuation); larn.setStatus(WorkflowConstants.STATUS_APPROVED); larn.setModuleId(moduleId); larn.setExtracontent(extracontent); larn.setPriority(larn.getActId()); larn.setFeedbackCorrect(feedbackCorrect); larn.setFeedbackNoCorrect(feedbackNoCorrect); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "title"); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "description"); learningActivityPersistence.update(larn, true); resourceLocalService.addModelResources(larn, serviceContext); assetEntryLocalService.updateEntry(userId, larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), larn.getUuid(), typeId, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, larn.getTitle().length() < 255 ? larn.getTitle() : larn.getTitle(Locale.getDefault()), null, larn.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); socialActivityLocalService.addUniqueActivity(larn.getUserId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), 0, StringPool.BLANK, 0); //auditing AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.ADD, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(larn.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && larn.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(larn.getGroupId()); Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission(larn.getGroupId(), "com.liferay.lms.model", larn.getGroupId(), "VIEW_RESULTS") && !larn.isInactive() && !larn.isExpired() && !moduleService.isLocked(larn.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isInactive() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isExpired() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isClosed()) { String courseTitle = courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()) .getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.new.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.new.body", new String[] { titleAux, courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, startDate, endDate, u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return larn; }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
public LearningActivity addLearningActivity(long userId, long groupId, int status, Map<Locale, String> title, Map<Locale, String> description, int typeId, Date startdate, Date enddate, long precedence, long tries, int passpuntuation, long moduleId, String extracontent, String feedbackCorrect, String feedbackNoCorrect, long weightinmodule, long teamId, ServiceContext serviceContext) throws PortalException, SystemException { User user = userLocalService.getUser(userId); String titleAux = title.get(user.getLocale()); Date now = new Date(); LearningActivity learningActivity = learningActivityPersistence .create(counterLocalService.increment(LearningActivity.class.getName())); learningActivity.setCompanyId(user.getCompanyId()); learningActivity.setGroupId(groupId); learningActivity.setUserId(user.getUserId()); learningActivity.setUserName(user.getFullName()); learningActivity.setCreateDate(serviceContext.getCreateDate(now)); learningActivity.setModifiedDate(serviceContext.getModifiedDate(now)); learningActivity.setStatus(status);//from ww w. j a v a2s . c om learningActivity.setStatusByUserId(user.getUserId()); learningActivity.setStatusByUserName(user.getFullName()); learningActivity.setStatusDate(serviceContext.getModifiedDate(now)); learningActivity.setTitleMap(title, serviceContext.getLocale()); learningActivity.setDescriptionMap(description, serviceContext.getLocale()); learningActivity.setTypeId(typeId); learningActivity.setStartdate(startdate); learningActivity.setEnddate(enddate); learningActivity.setPrecedence(precedence); learningActivity.setTries(tries); learningActivity.setPasspuntuation(passpuntuation); learningActivity.setPriority(learningActivity.getActId()); learningActivity.setModuleId(moduleId); learningActivity.setExtracontent(extracontent); learningActivity.setFeedbackCorrect(feedbackCorrect); learningActivity.setFeedbackNoCorrect(feedbackNoCorrect); learningActivity.setWeightinmodule(weightinmodule); learningActivity.setExpandoBridgeAttributes(serviceContext); learningActivity = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, learningActivity, "title"); learningActivity = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, learningActivity, "description"); learningActivityPersistence.update(learningActivity, true); resourceLocalService.addModelResources(learningActivity, serviceContext); assetEntryLocalService.updateEntry(userId, learningActivity.getGroupId(), LearningActivity.class.getName(), learningActivity.getActId(), learningActivity.getUuid(), typeId, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, learningActivity.getTitle().length() < 255 ? learningActivity.getTitle() : learningActivity.getTitle(Locale.getDefault()), null, learningActivity.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); socialActivityLocalService.addUniqueActivity(learningActivity.getUserId(), learningActivity.getGroupId(), LearningActivity.class.getName(), learningActivity.getActId(), 0, StringPool.BLANK, 0); Role siteMemberRole = RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER); if (Validator.isNull(teamId)) { if ((moduleId != 0) && (GetterUtil.getBoolean( PrefsPropsUtil.getString("learningactivity.default.hidenewactivity", StringPool.FALSE)))) { resourcePermissionLocalService.removeResourcePermission(siteMemberRole.getCompanyId(), LearningActivity.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long.toString(learningActivity.getActId()), siteMemberRole.getRoleId(), ActionKeys.VIEW); } else { resourcePermissionLocalService.setResourcePermissions(siteMemberRole.getCompanyId(), LearningActivity.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long.toString(learningActivity.getActId()), siteMemberRole.getRoleId(), new String[] { ActionKeys.VIEW }); } } else { Team team = teamLocalService.getTeam(teamId); Role teamMemberRole = roleLocalService.getTeamRole(team.getCompanyId(), team.getTeamId()); if ((moduleId != 0) && (GetterUtil.getBoolean( PrefsPropsUtil.getString("learningactivity.default.hidenewactivity", StringPool.FALSE)))) { resourcePermissionLocalService.removeResourcePermission(team.getCompanyId(), LearningActivity.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long.toString(learningActivity.getActId()), teamMemberRole.getRoleId(), ActionKeys.VIEW); } else { resourcePermissionLocalService.setResourcePermissions(team.getCompanyId(), LearningActivity.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long.toString(learningActivity.getActId()), teamMemberRole.getRoleId(), new String[] { ActionKeys.VIEW }); } } //auditing AuditingLogFactory.audit(learningActivity.getCompanyId(), learningActivity.getGroupId(), LearningActivity.class.getName(), learningActivity.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.ADD, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(learningActivity.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && learningActivity.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(learningActivity.getGroupId()); Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission( learningActivity.getGroupId(), "com.liferay.lms.model", learningActivity.getGroupId(), "VIEW_RESULTS") && !learningActivity.isInactive() && !learningActivity.isExpired() && !moduleService.isLocked(learningActivity.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(learningActivity.getGroupId()) .isInactive() && !courseLocalService.getCourseByGroupCreatedId(learningActivity.getGroupId()) .isExpired() && !courseLocalService.getCourseByGroupCreatedId(learningActivity.getGroupId()) .isClosed()) { String courseTitle = courseLocalService .getCourseByGroupCreatedId(learningActivity.getGroupId()).getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.new.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.new.body", new String[] { titleAux, courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, startdate, enddate, u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return learningActivity; }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
public LearningActivity modLearningActivity(long actId, String title, String description, java.util.Date createDate, java.util.Date startDate, java.util.Date endDate, int typeId, long tries, int passpuntuation, long moduleId, String extracontent, String feedbackCorrect, String feedbackNoCorrect, ServiceContext serviceContext) throws SystemException, PortalException { long userId = serviceContext.getUserId(); LearningActivity larn = this.getLearningActivity(actId); String titleAux = larn.getTitle(serviceContext.getLocale()); larn.setCompanyId(serviceContext.getCompanyId()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setUserId(userId);/* w ww . j av a 2 s .co m*/ larn.setDescription(description); larn.setTitle(title); larn.setStartdate(startDate); larn.setEnddate(endDate); larn.setTries(tries); larn.setPasspuntuation(passpuntuation); larn.setStatus(WorkflowConstants.STATUS_APPROVED); larn.setModuleId(moduleId); larn.setExtracontent(extracontent); larn.setFeedbackCorrect(feedbackCorrect); larn.setFeedbackNoCorrect(feedbackNoCorrect); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "title"); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "description"); learningActivityPersistence.update(larn, true); try { assetEntryLocalService.updateEntry(userId, larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), larn.getUuid(), larn.getTypeId(), serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, larn.getTitle(), null, larn.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); SocialActivityLocalServiceUtil.addActivity(larn.getUserId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), 1, StringPool.BLANK, 0); } catch (Exception e) { } //auditing AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.UPDATE, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(larn.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && larn.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(larn.getGroupId()); Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission(larn.getGroupId(), "com.liferay.lms.model", larn.getGroupId(), "VIEW_RESULTS") && !larn.isInactive() && !larn.isExpired() && !moduleService.isLocked(larn.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isInactive() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isExpired() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isClosed()) { String courseTitle = courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()) .getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.larn.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.larn.body", new String[] { titleAux, courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, startDate, endDate, u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return larn; }
From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteRecycleBinFormNavigatorEntry.java
License:Open Source License
@Override public boolean isVisible(User user, Group group) { if (group == null) { return false; }//w w w . j a v a 2 s .c o m boolean trashEnabled = PrefsPropsUtil.getBoolean(group.getCompanyId(), PropsKeys.TRASH_ENABLED); if (!trashEnabled) { return false; } return true; }
From source file:com.liferay.so.hook.events.ServicePostAction.java
License:Open Source License
protected void checkSocialOfficeUsersConfigured(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return;/* w w w .ja v a 2s . co m*/ } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (!permissionChecker.isCompanyAdmin() || isSocialOfficeUsersConfigured(themeDisplay.getCompanyId())) { return; } User user = themeDisplay.getUser(); if (user.isPasswordReset()) { return; } if (!user.isAgreedToTermsOfUse()) { boolean termsOfUseRequired = false; try { termsOfUseRequired = PrefsPropsUtil.getBoolean(user.getCompanyId(), PropsKeys.TERMS_OF_USE_REQUIRED); } catch (Exception e) { } if (termsOfUseRequired) { return; } } if (Validator.isNull(user.getReminderQueryQuestion()) || Validator.isNull(user.getReminderQueryAnswer())) { if (PrefsPropsUtil.getBoolean(user.getCompanyId(), PropsKeys.USERS_REMINDER_QUERIES_ENABLED)) { return; } } if (Validator.isNotNull(request.getParameter("_1_WAR_soconfigurationsportlet_mvcPath"))) { setSocialOfficeUsersConfigured(themeDisplay.getCompanyId(), true); return; } Group group = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), GroupConstants.CONTROL_PANEL); PortletURL portletURL = PortletURLFactoryUtil.create(request, "1_WAR_soconfigurationsportlet", group.getDefaultPrivatePlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/view.jsp"); portletURL.setPortletMode(PortletMode.VIEW); portletURL.setWindowState(WindowState.MAXIMIZED); response.sendRedirect(portletURL.toString()); }