@Override public void onAfterUpdate(Contact contact) { try { exportToLDAP(contact); } catch (Exception e) { _log.error( "Unable to export contact with user ID " + contact.getUserId() + " to LDAP on after update", e); } }
protected void exportToLDAP(Contact contact) throws Exception { if (UserImportTransactionThreadLocal.isOriginatesFromImport()) { return; } User user = _userLocalService.fetchUser(contact.getUserId()); if ((user == null) || user.isDefaultUser()) { return; } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Map<String, Serializable> expandoBridgeAttributes = null; if (serviceContext != null) { expandoBridgeAttributes = serviceContext.getExpandoBridgeAttributes(); } _userExporter.exportUser(contact, expandoBridgeAttributes); }
@Override public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String languageId = ParamUtil.getString(request, "languageId"); Locale locale = LocaleUtil.fromLanguageId(languageId); if (LanguageUtil.isAvailableLocale(themeDisplay.getSiteGroupId(), locale)) { boolean persistState = ParamUtil.getBoolean(request, "persistState", true); if (themeDisplay.isSignedIn() && persistState) { User user = themeDisplay.getUser(); Contact contact = user.getContact(); AdminUtil.updateUser( request, user.getUserId(), user.getScreenName(), user.getEmailAddress(), user.getFacebookId(), user.getOpenId(), languageId, user.getTimeZoneId(), user.getGreeting(), user.getComments(), contact.getSmsSn(), contact.getFacebookSn(), contact.getJabberSn(), contact.getSkypeSn(), contact.getTwitterSn()); } session.setAttribute(Globals.LOCALE_KEY, locale); LanguageUtil.updateCookie(request, response, locale); } // Send redirect String redirect = ParamUtil.getString(request, "redirect"); String layoutURL = StringPool.BLANK; String queryString = StringPool.BLANK; int pos = redirect.indexOf(Portal.FRIENDLY_URL_SEPARATOR); if (pos == -1) { pos = redirect.indexOf(StringPool.QUESTION); } if (pos != -1) { layoutURL = redirect.substring(0, pos); queryString = redirect.substring(pos); } else { layoutURL = redirect; } Layout layout = themeDisplay.getLayout(); if (isGroupFriendlyURL(layout.getGroup(), layout, layoutURL, locale)) { if (PropsValues.LOCALE_PREPEND_FRIENDLY_URL_STYLE == 0) { redirect = layoutURL; } else { redirect = PortalUtil.getGroupFriendlyURL(layout.getLayoutSet(), themeDisplay, locale); } } else { if (PropsValues.LOCALE_PREPEND_FRIENDLY_URL_STYLE == 0) { if (themeDisplay.isI18n()) { redirect = layout.getFriendlyURL(locale); } else { redirect = PortalUtil.getLayoutURL(layout, themeDisplay, locale); } } else { redirect = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay, locale); } } if (layout.isTypeControlPanel()) { redirect = redirect + queryString; } response.sendRedirect(redirect); return null; }
@Override public boolean contains( PermissionChecker permissionChecker, long userId, long[] organizationIds, String actionId) { try { User user = null; if (userId != ResourceConstants.PRIMKEY_DNE) { user = UserLocalServiceUtil.getUserById(userId); if ((actionId.equals(ActionKeys.DELETE) || actionId.equals(ActionKeys.IMPERSONATE) || actionId.equals(ActionKeys.PERMISSIONS) || actionId.equals(ActionKeys.UPDATE) || actionId.equals(ActionKeys.VIEW)) && !permissionChecker.isOmniadmin() && (PortalUtil.isOmniadmin(user) || (!permissionChecker.isCompanyAdmin() && PortalUtil.isCompanyAdmin(user)))) { return false; } Contact contact = user.getContact(); if (permissionChecker.hasOwnerPermission( permissionChecker.getCompanyId(), User.class.getName(), userId, contact.getUserId(), actionId) || (permissionChecker.getUserId() == userId)) { return true; } } if (permissionChecker.hasPermission(0, User.class.getName(), userId, actionId)) { return true; } if (user == null) { return false; } if (organizationIds == null) { organizationIds = user.getOrganizationIds(); } for (long organizationId : organizationIds) { Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId); if (OrganizationPermissionUtil.contains( permissionChecker, organization, ActionKeys.MANAGE_USERS)) { if (permissionChecker.getUserId() == user.getUserId()) { return true; } Group organizationGroup = organization.getGroup(); // Organization administrators can only manage normal users. // Owners can only manage normal users and administrators. if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( user.getUserId(), organizationGroup.getGroupId(), RoleConstants.ORGANIZATION_OWNER, true)) { continue; } else if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( user.getUserId(), organizationGroup.getGroupId(), RoleConstants.ORGANIZATION_ADMINISTRATOR, true) && !UserGroupRoleLocalServiceUtil.hasUserGroupRole( permissionChecker.getUserId(), organizationGroup.getGroupId(), RoleConstants.ORGANIZATION_OWNER, true)) { continue; } return true; } } } catch (Exception e) { _log.error(e, e); } return false; }