List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getBoolean
public static boolean getBoolean(String name, boolean defaultValue)
From source file:com.abubusoft.liferay.twitter.TwitterAutoLogin.java
License:Open Source License
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { long companyId = PortalUtil.getCompanyId(request); //boolean twitterAuthEnabled = PrefsPropsUtil.getBoolean(companyId, "twitter.auth.enabled", true); boolean twitterAuthEnabled = PrefsPropsUtil.getBoolean("twitter.auth.enabled", true); if (!twitterAuthEnabled) { return null; }//from w w w . j a v a 2 s . com User user = getUser(request, companyId); if (user == null) { return null; } String[] credentials = new String[3]; credentials[0] = String.valueOf(user.getUserId()); credentials[1] = user.getPassword(); credentials[2] = Boolean.TRUE.toString(); return credentials; }
From source file:com.gleo.groupphoto.web.portlet.action.ViewUserDetailsActionMVCRenderCommand.java
License:Open Source License
/** * Set fields/* ww w . ja v a 2 s .c om*/ * * @param renderRequest * @param contact * @param user * @param company * @param locale * @param birthday * @param gender * @param jobTitle */ private void setFields(RenderRequest renderRequest, Contact contact, User user, Company company, Locale locale, String birthday, String gender, String jobTitle) { boolean isFieldEnableContactBirthday = PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_BIRTHDAY); if (isFieldEnableContactBirthday) { Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale); try { birthday = dateFormatDate.format(user.getBirthday()); } catch (PortalException e) { LOGGER.error(e); } } jobTitle = HtmlUtil.escape(contact.getJobTitle()); boolean isFieldEnableContactMale = PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_MALE); if (isFieldEnableContactMale) { try { gender = LanguageUtil.get(locale, user.isMale() ? "male" : "female"); } catch (PortalException pe) { LOGGER.error(pe); } } renderRequest.setAttribute("birthday", birthday); renderRequest.setAttribute("jobTitle", jobTitle); renderRequest.setAttribute("gender", gender); }
From source file:com.liferay.asset.publisher.web.internal.SitesThatIAdministerItemSelectorView.java
License:Open Source License
@Override public boolean isVisible(ThemeDisplay themeDisplay) { Group siteGroup = themeDisplay.getSiteGroup(); if (siteGroup.isLayoutPrototype()) { return false; }//from ww w. j a va 2 s . c o m if (siteGroup.isLayoutSetPrototype()) { return false; } if (PrefsPropsUtil.getBoolean(themeDisplay.getCompanyId(), PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) { return true; } return false; }
From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java
License:Open Source License
public boolean isScopeIdSelectable(PermissionChecker permissionChecker, String scopeId, long companyGroupId, Layout layout, boolean checkPermission) throws PortalException { long groupId = _assetPublisherUtil.getGroupIdFromScopeId(scopeId, layout.getGroupId(), layout.isPrivateLayout());// w ww . jav a 2s . com if (scopeId.startsWith(AssetPublisherUtil.SCOPE_ID_CHILD_GROUP_PREFIX)) { Group group = _groupLocalService.getGroup(groupId); if (!group.hasAncestor(layout.getGroupId())) { return false; } } else if (scopeId.startsWith(AssetPublisherUtil.SCOPE_ID_PARENT_GROUP_PREFIX)) { Group siteGroup = layout.getGroup(); if (!siteGroup.hasAncestor(groupId)) { return false; } Group group = _groupLocalService.getGroup(groupId); if (SitesUtil.isContentSharingWithChildrenEnabled(group)) { return true; } if (!PrefsPropsUtil.getBoolean(layout.getCompanyId(), PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) { return false; } if (checkPermission) { return GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.UPDATE); } } else if ((groupId != companyGroupId) && checkPermission) { return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE); } return true; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static boolean isScopeIdSelectable(PermissionChecker permissionChecker, String scopeId, long companyGroupId, Layout layout, boolean checkPermission) throws PortalException { long groupId = getGroupIdFromScopeId(scopeId, layout.getGroupId(), layout.isPrivateLayout()); if (scopeId.startsWith(SCOPE_ID_CHILD_GROUP_PREFIX)) { Group group = _groupLocalService.getGroup(groupId); if (!group.hasAncestor(layout.getGroupId())) { return false; }/*from w w w.j a v a 2 s . co m*/ } else if (scopeId.startsWith(SCOPE_ID_PARENT_GROUP_PREFIX)) { Group siteGroup = layout.getGroup(); if (!siteGroup.hasAncestor(groupId)) { return false; } Group group = _groupLocalService.getGroup(groupId); if (SitesUtil.isContentSharingWithChildrenEnabled(group)) { return true; } if (!PrefsPropsUtil.getBoolean(layout.getCompanyId(), PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) { return false; } if (checkPermission) { return GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.UPDATE); } } else if ((groupId != companyGroupId) && checkPermission) { return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE); } return true; }
From source file:com.liferay.content.targeting.analytics.hook.filter.YoutubeVideoHtmlFilter.java
License:Open Source License
@Override public boolean isFilterEnabled(HttpServletRequest request, HttpServletResponse response) { try {// w ww . jav a 2s. c o m Company company = PortalUtil.getCompany(request); long companyId = company.getCompanyId(); boolean youtubeTrackingEnabled = PrefsPropsUtil.getBoolean(companyId, "content.targeting.analytics.youtube.enabled"); if (youtubeTrackingEnabled && !isAlreadyFiltered(request)) { return true; } } catch (Exception e) { } return false; }
From source file:com.liferay.content.targeting.analytics.util.AnalyticsUtil.java
License:Open Source License
private static Boolean _getBoolean(long groupId, String key, boolean defaultValue) { try {//from ww w . java 2s.c o m Group group = GroupLocalServiceUtil.getGroup(groupId); UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties(); boolean companyValue = PrefsPropsUtil.getBoolean(group.getCompanyId(), key); if (!companyValue) { return false; } return GetterUtil.getBoolean(typeSettingsProperties.getProperty(key), companyValue); } catch (Exception e) { return defaultValue; } }
From source file:com.liferay.content.targeting.rule.age.AgeRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context, Map<String, String> values) { int youngerThan = 100; int olderThan = 0; if (!values.isEmpty()) { youngerThan = GetterUtil.getInteger(values.get("youngerThan")); olderThan = GetterUtil.getInteger(values.get("olderThan")); } else if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {//from w ww. j a v a2 s .co m 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); if (!birthdayEnabled) { boolean hasPortalSettingsViewPermission = ContentTargetingContextUtil .hasControlPanelPortletViewPermission(context, PortletKeys.PORTAL_SETTINGS); if (hasPortalSettingsViewPermission) { Map<String, String> params = new HashMap<String, String>(); params.put("historyKey", "_130_users"); context.put("portalSettingsURL", ContentTargetingContextUtil.getControlPanelPortletURL(context, PortletKeys.PORTAL_SETTINGS, params)); } } }
From source file:com.liferay.content.targeting.rule.gender.GenderRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context, Map<String, String> values) { String gender = "male"; if (!values.isEmpty()) { gender = values.get("gender"); } else if (ruleInstance != null) { gender = ruleInstance.getTypeSettings(); }/*from ww w . jav a 2 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); if (!genderEnabled) { boolean hasPortalSettingsViewPermission = ContentTargetingContextUtil .hasControlPanelPortletViewPermission(context, PortletKeys.PORTAL_SETTINGS); if (hasPortalSettingsViewPermission) { Map<String, String> params = new HashMap<String, String>(); params.put("historyKey", "_130_users"); context.put("portalSettingsURL", ContentTargetingContextUtil.getControlPanelPortletURL(context, PortletKeys.PORTAL_SETTINGS, params)); } } }
From source file:com.liferay.content.targeting.util.ContentTargetingUtil.java
License:Open Source License
public static long[] getSharedContentSiteGroupIds(long companyId, long groupId, long userId) throws PortalException, SystemException { Set<Group> groups = new LinkedHashSet<Group>(); Group siteGroup = doGetCurrentSiteGroup(groupId); if (siteGroup != null) { // Current site groups.add(siteGroup);/*ww w . jav a 2 s .c o m*/ // Layout scopes groups.addAll(GroupLocalServiceUtil.getGroups(siteGroup.getCompanyId(), Layout.class.getName(), siteGroup.getGroupId())); } // Administered sites if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) { LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>(); groupParams.put("site", Boolean.TRUE); groupParams.put("usersGroups", userId); groups.addAll(GroupLocalServiceUtil.search(companyId, null, null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)); } // Descendant sites groups.addAll(getDescendants(siteGroup, true)); // Ancestor sites and global site int sitesContentSharingWithChildrenEnabled = PrefsPropsUtil.getInteger(companyId, PropsKeys.SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED); if (sitesContentSharingWithChildrenEnabled != Sites.CONTENT_SHARING_WITH_CHILDREN_DISABLED) { groups.addAll(doGetAncestorSiteGroups(groupId, true)); } long[] groupIds = new long[groups.size()]; int i = 0; for (Group group : groups) { groupIds[i++] = group.getGroupId(); } return groupIds; }