001
014
015 package com.liferay.portlet.usersadmin.action;
016
017 import com.liferay.portal.AddressCityException;
018 import com.liferay.portal.AddressStreetException;
019 import com.liferay.portal.AddressZipException;
020 import com.liferay.portal.CompanyMaxUsersException;
021 import com.liferay.portal.ContactBirthdayException;
022 import com.liferay.portal.ContactFirstNameException;
023 import com.liferay.portal.ContactFullNameException;
024 import com.liferay.portal.ContactLastNameException;
025 import com.liferay.portal.DuplicateOpenIdException;
026 import com.liferay.portal.DuplicateUserEmailAddressException;
027 import com.liferay.portal.DuplicateUserScreenNameException;
028 import com.liferay.portal.EmailAddressException;
029 import com.liferay.portal.GroupFriendlyURLException;
030 import com.liferay.portal.NoSuchCountryException;
031 import com.liferay.portal.NoSuchListTypeException;
032 import com.liferay.portal.NoSuchRegionException;
033 import com.liferay.portal.NoSuchUserException;
034 import com.liferay.portal.PhoneNumberException;
035 import com.liferay.portal.RequiredUserException;
036 import com.liferay.portal.ReservedUserEmailAddressException;
037 import com.liferay.portal.ReservedUserScreenNameException;
038 import com.liferay.portal.UserEmailAddressException;
039 import com.liferay.portal.UserIdException;
040 import com.liferay.portal.UserPasswordException;
041 import com.liferay.portal.UserReminderQueryException;
042 import com.liferay.portal.UserScreenNameException;
043 import com.liferay.portal.UserSmsException;
044 import com.liferay.portal.WebsiteURLException;
045 import com.liferay.portal.kernel.bean.BeanParamUtil;
046 import com.liferay.portal.kernel.language.LanguageUtil;
047 import com.liferay.portal.kernel.servlet.SessionErrors;
048 import com.liferay.portal.kernel.servlet.SessionMessages;
049 import com.liferay.portal.kernel.util.CalendarFactoryUtil;
050 import com.liferay.portal.kernel.util.CharPool;
051 import com.liferay.portal.kernel.util.Constants;
052 import com.liferay.portal.kernel.util.GetterUtil;
053 import com.liferay.portal.kernel.util.HttpUtil;
054 import com.liferay.portal.kernel.util.LocaleUtil;
055 import com.liferay.portal.kernel.util.ParamUtil;
056 import com.liferay.portal.kernel.util.StringPool;
057 import com.liferay.portal.kernel.util.StringUtil;
058 import com.liferay.portal.kernel.util.Validator;
059 import com.liferay.portal.kernel.workflow.WorkflowConstants;
060 import com.liferay.portal.model.Address;
061 import com.liferay.portal.model.Company;
062 import com.liferay.portal.model.Contact;
063 import com.liferay.portal.model.EmailAddress;
064 import com.liferay.portal.model.Group;
065 import com.liferay.portal.model.Layout;
066 import com.liferay.portal.model.Phone;
067 import com.liferay.portal.model.User;
068 import com.liferay.portal.model.UserGroupRole;
069 import com.liferay.portal.model.Website;
070 import com.liferay.portal.security.auth.PrincipalException;
071 import com.liferay.portal.service.ServiceContext;
072 import com.liferay.portal.service.ServiceContextFactory;
073 import com.liferay.portal.service.UserLocalServiceUtil;
074 import com.liferay.portal.service.UserServiceUtil;
075 import com.liferay.portal.struts.PortletAction;
076 import com.liferay.portal.theme.ThemeDisplay;
077 import com.liferay.portal.util.PortalUtil;
078 import com.liferay.portal.util.PortletKeys;
079 import com.liferay.portal.util.PropsValues;
080 import com.liferay.portal.util.WebKeys;
081 import com.liferay.portlet.InvokerPortletImpl;
082 import com.liferay.portlet.admin.util.AdminUtil;
083 import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
084 import com.liferay.portlet.announcements.model.AnnouncementsEntryConstants;
085 import com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl;
086 import com.liferay.portlet.announcements.service.AnnouncementsDeliveryLocalServiceUtil;
087 import com.liferay.portlet.sites.util.SitesUtil;
088 import com.liferay.portlet.usersadmin.util.UsersAdminUtil;
089
090 import java.util.ArrayList;
091 import java.util.Calendar;
092 import java.util.List;
093 import java.util.Locale;
094
095 import javax.portlet.ActionRequest;
096 import javax.portlet.ActionResponse;
097 import javax.portlet.PortletConfig;
098 import javax.portlet.PortletRequest;
099 import javax.portlet.PortletSession;
100 import javax.portlet.RenderRequest;
101 import javax.portlet.RenderResponse;
102
103 import javax.servlet.http.HttpServletRequest;
104 import javax.servlet.http.HttpServletResponse;
105 import javax.servlet.http.HttpSession;
106
107 import org.apache.struts.Globals;
108 import org.apache.struts.action.ActionForm;
109 import org.apache.struts.action.ActionForward;
110 import org.apache.struts.action.ActionMapping;
111
112
118 public class EditUserAction extends PortletAction {
119
120 @Override
121 public void processAction(
122 ActionMapping actionMapping, ActionForm actionForm,
123 PortletConfig portletConfig, ActionRequest actionRequest,
124 ActionResponse actionResponse)
125 throws Exception {
126
127 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
128
129 try {
130 User user = null;
131 String oldScreenName = StringPool.BLANK;
132 boolean updateLanguageId = false;
133
134 if (cmd.equals(Constants.ADD)) {
135 user = addUser(actionRequest);
136 }
137 else if (cmd.equals(Constants.DEACTIVATE) ||
138 cmd.equals(Constants.DELETE) ||
139 cmd.equals(Constants.RESTORE)) {
140
141 deleteUsers(actionRequest);
142 }
143 else if (cmd.equals("deleteRole")) {
144 deleteRole(actionRequest);
145 }
146 else if (cmd.equals(Constants.UPDATE)) {
147 Object[] returnValue = updateUser(
148 actionRequest, actionResponse);
149
150 user = (User)returnValue[0];
151 oldScreenName = ((String)returnValue[1]);
152 updateLanguageId = ((Boolean)returnValue[2]);
153 }
154 else if (cmd.equals("unlock")) {
155 user = updateLockout(actionRequest);
156 }
157
158 ThemeDisplay themeDisplay =
159 (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
160
161 String redirect = ParamUtil.getString(actionRequest, "redirect");
162
163 if (user != null) {
164 if (Validator.isNotNull(oldScreenName)) {
165
166
167
168
169
170
171 Group group = user.getGroup();
172
173 if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
174 Layout layout = themeDisplay.getLayout();
175
176 String friendlyURLPath = group.getPathFriendlyURL(
177 layout.isPrivateLayout(), themeDisplay);
178
179 String oldPath =
180 friendlyURLPath + StringPool.SLASH + oldScreenName;
181 String newPath =
182 friendlyURLPath + StringPool.SLASH +
183 user.getScreenName();
184
185 redirect = StringUtil.replace(
186 redirect, oldPath, newPath);
187
188 redirect = StringUtil.replace(
189 redirect, HttpUtil.encodeURL(oldPath),
190 HttpUtil.encodeURL(newPath));
191 }
192 }
193
194 if (updateLanguageId && themeDisplay.isI18n()) {
195 String i18nLanguageId = user.getLanguageId();
196 int pos = i18nLanguageId.indexOf(CharPool.UNDERLINE);
197
198 if (pos != -1) {
199 i18nLanguageId = i18nLanguageId.substring(0, pos);
200 }
201
202 String i18nPath = StringPool.SLASH + i18nLanguageId;
203
204 redirect = StringUtil.replace(
205 redirect, themeDisplay.getI18nPath(), i18nPath);
206 }
207
208 redirect = HttpUtil.setParameter(
209 redirect, actionResponse.getNamespace() + "p_u_i_d",
210 user.getUserId());
211 }
212
213 Group scopeGroup = themeDisplay.getScopeGroup();
214
215 if (scopeGroup.isUser()) {
216 try {
217 UserLocalServiceUtil.getUserById(scopeGroup.getClassPK());
218 }
219 catch (NoSuchUserException nsue) {
220 redirect = HttpUtil.setParameter(
221 redirect, "doAsGroupId" , 0);
222 redirect = HttpUtil.setParameter(
223 redirect, "refererPlid" , 0);
224 }
225 }
226
227 sendRedirect(actionRequest, actionResponse, redirect);
228 }
229 catch (Exception e) {
230 if (e instanceof NoSuchUserException ||
231 e instanceof PrincipalException) {
232
233 SessionErrors.add(actionRequest, e.getClass());
234
235 setForward(actionRequest, "portlet.users_admin.error");
236 }
237 else if (e instanceof AddressCityException ||
238 e instanceof AddressStreetException ||
239 e instanceof AddressZipException ||
240 e instanceof CompanyMaxUsersException ||
241 e instanceof ContactBirthdayException ||
242 e instanceof ContactFirstNameException ||
243 e instanceof ContactFullNameException ||
244 e instanceof ContactLastNameException ||
245 e instanceof DuplicateOpenIdException ||
246 e instanceof DuplicateUserEmailAddressException ||
247 e instanceof DuplicateUserScreenNameException ||
248 e instanceof EmailAddressException ||
249 e instanceof GroupFriendlyURLException ||
250 e instanceof NoSuchCountryException ||
251 e instanceof NoSuchListTypeException ||
252 e instanceof NoSuchRegionException ||
253 e instanceof PhoneNumberException ||
254 e instanceof RequiredUserException ||
255 e instanceof ReservedUserEmailAddressException ||
256 e instanceof ReservedUserScreenNameException ||
257 e instanceof UserEmailAddressException ||
258 e instanceof UserIdException ||
259 e instanceof UserPasswordException ||
260 e instanceof UserReminderQueryException ||
261 e instanceof UserScreenNameException ||
262 e instanceof UserSmsException ||
263 e instanceof WebsiteURLException) {
264
265 if (e instanceof NoSuchListTypeException) {
266 NoSuchListTypeException nslte = (NoSuchListTypeException)e;
267
268 SessionErrors.add(
269 actionRequest,
270 e.getClass().getName() + nslte.getType());
271 }
272 else {
273 SessionErrors.add(actionRequest, e.getClass(), e);
274 }
275
276 if (e instanceof CompanyMaxUsersException ||
277 e instanceof RequiredUserException) {
278
279 String redirect = PortalUtil.escapeRedirect(
280 ParamUtil.getString(actionRequest, "redirect"));
281
282 if (Validator.isNotNull(redirect)) {
283 actionResponse.sendRedirect(redirect);
284 }
285 }
286 }
287 else {
288 throw e;
289 }
290 }
291 }
292
293 @Override
294 public ActionForward render(
295 ActionMapping actionMapping, ActionForm actionForm,
296 PortletConfig portletConfig, RenderRequest renderRequest,
297 RenderResponse renderResponse)
298 throws Exception {
299
300 try {
301 PortalUtil.getSelectedUser(renderRequest);
302 }
303 catch (Exception e) {
304 if (e instanceof PrincipalException) {
305 SessionErrors.add(renderRequest, e.getClass());
306
307 return actionMapping.findForward("portlet.users_admin.error");
308 }
309 else {
310 throw e;
311 }
312 }
313
314 return actionMapping.findForward(
315 getForward(renderRequest, "portlet.users_admin.edit_user"));
316 }
317
318 protected User addUser(ActionRequest actionRequest) throws Exception {
319 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
320 WebKeys.THEME_DISPLAY);
321
322 boolean autoPassword = ParamUtil.getBoolean(
323 actionRequest, "autoPassword", true);
324 String password1 = actionRequest.getParameter("password1");
325 String password2 = actionRequest.getParameter("password2");
326
327 String reminderQueryQuestion = ParamUtil.getString(
328 actionRequest, "reminderQueryQuestion");
329
330 if (reminderQueryQuestion.equals(UsersAdminUtil.CUSTOM_QUESTION)) {
331 reminderQueryQuestion = ParamUtil.getString(
332 actionRequest, "reminderQueryCustomQuestion");
333 }
334
335 String reminderQueryAnswer = ParamUtil.getString(
336 actionRequest, "reminderQueryAnswer");
337 boolean autoScreenName = ParamUtil.getBoolean(
338 actionRequest, "autoScreenName");
339 String screenName = ParamUtil.getString(actionRequest, "screenName");
340 String emailAddress = ParamUtil.getString(
341 actionRequest, "emailAddress");
342 long facebookId = 0;
343 String openId = ParamUtil.getString(actionRequest, "openId");
344 String languageId = ParamUtil.getString(actionRequest, "languageId");
345 String timeZoneId = ParamUtil.getString(actionRequest, "timeZoneId");
346 String greeting = ParamUtil.getString(actionRequest, "greeting");
347 String firstName = ParamUtil.getString(actionRequest, "firstName");
348 String middleName = ParamUtil.getString(actionRequest, "middleName");
349 String lastName = ParamUtil.getString(actionRequest, "lastName");
350 int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
351 int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
352 boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
353 int birthdayMonth = ParamUtil.getInteger(
354 actionRequest, "birthdayMonth");
355 int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
356 int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
357 String comments = ParamUtil.getString(actionRequest, "comments");
358 String smsSn = ParamUtil.getString(actionRequest, "smsSn");
359 String aimSn = ParamUtil.getString(actionRequest, "aimSn");
360 String facebookSn = ParamUtil.getString(actionRequest, "facebookSn");
361 String icqSn = ParamUtil.getString(actionRequest, "icqSn");
362 String jabberSn = ParamUtil.getString(actionRequest, "jabberSn");
363 String msnSn = ParamUtil.getString(actionRequest, "msnSn");
364 String mySpaceSn = ParamUtil.getString(actionRequest, "mySpaceSn");
365 String skypeSn = ParamUtil.getString(actionRequest, "skypeSn");
366 String twitterSn = ParamUtil.getString(actionRequest, "twitterSn");
367 String ymSn = ParamUtil.getString(actionRequest, "ymSn");
368 String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
369 long[] groupIds = getLongArray(
370 actionRequest, "groupsSearchContainerPrimaryKeys");
371 long[] organizationIds = getLongArray(
372 actionRequest, "organizationsSearchContainerPrimaryKeys");
373 long[] roleIds = getLongArray(
374 actionRequest, "rolesSearchContainerPrimaryKeys");
375 List<UserGroupRole> userGroupRoles = UsersAdminUtil.getUserGroupRoles(
376 actionRequest);
377 long[] userGroupIds = getLongArray(
378 actionRequest, "userGroupsSearchContainerPrimaryKeys");
379 List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
380 List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(
381 actionRequest);
382 List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
383 List<Website> websites = UsersAdminUtil.getWebsites(actionRequest);
384 List<AnnouncementsDelivery> announcementsDeliveries =
385 getAnnouncementsDeliveries(actionRequest);
386 boolean sendEmail = true;
387
388 ServiceContext serviceContext = ServiceContextFactory.getInstance(
389 User.class.getName(), actionRequest);
390
391 User user = UserServiceUtil.addUser(
392 themeDisplay.getCompanyId(), autoPassword, password1, password2,
393 autoScreenName, screenName, emailAddress, facebookId, openId,
394 LocaleUtil.getDefault(), firstName, middleName, lastName, prefixId,
395 suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
396 groupIds, organizationIds, roleIds, userGroupIds, addresses,
397 emailAddresses, phones, websites, announcementsDeliveries,
398 sendEmail, serviceContext);
399
400 if (!userGroupRoles.isEmpty()) {
401 for (UserGroupRole userGroupRole : userGroupRoles) {
402 userGroupRole.setUserId(user.getUserId());
403 }
404
405 user = UserServiceUtil.updateUser(
406 user.getUserId(), StringPool.BLANK, StringPool.BLANK,
407 StringPool.BLANK, false, reminderQueryQuestion,
408 reminderQueryAnswer, user.getScreenName(),
409 user.getEmailAddress(), facebookId, openId, languageId,
410 timeZoneId, greeting, comments, firstName, middleName, lastName,
411 prefixId, suffixId, male, birthdayMonth, birthdayDay,
412 birthdayYear, smsSn, aimSn, facebookSn, icqSn, jabberSn, msnSn,
413 mySpaceSn, skypeSn, twitterSn, ymSn, jobTitle, groupIds,
414 organizationIds, roleIds, userGroupRoles, userGroupIds,
415 addresses, emailAddresses, phones, websites,
416 announcementsDeliveries, serviceContext);
417 }
418
419 long publicLayoutSetPrototypeId = ParamUtil.getLong(
420 actionRequest, "publicLayoutSetPrototypeId");
421 long privateLayoutSetPrototypeId = ParamUtil.getLong(
422 actionRequest, "privateLayoutSetPrototypeId");
423 boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
424 actionRequest, "publicLayoutSetPrototypeLinkEnabled");
425 boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
426 actionRequest, "privateLayoutSetPrototypeLinkEnabled");
427
428 SitesUtil.updateLayoutSetPrototypesLinks(
429 user.getGroup(), publicLayoutSetPrototypeId,
430 privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
431 privateLayoutSetPrototypeLinkEnabled);
432
433 return user;
434 }
435
436 protected void deleteRole(ActionRequest actionRequest) throws Exception {
437 User user = PortalUtil.getSelectedUser(actionRequest);
438
439 long roleId = ParamUtil.getLong(actionRequest, "roleId");
440
441 UserServiceUtil.deleteRoleUser(roleId, user.getUserId());
442 }
443
444 protected void deleteUsers(ActionRequest actionRequest) throws Exception {
445 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
446
447 long[] deleteUserIds = StringUtil.split(
448 ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);
449
450 for (long deleteUserId : deleteUserIds) {
451 if (cmd.equals(Constants.DEACTIVATE) ||
452 cmd.equals(Constants.RESTORE)) {
453
454 int status = WorkflowConstants.STATUS_APPROVED;
455
456 if (cmd.equals(Constants.DEACTIVATE)) {
457 status = WorkflowConstants.STATUS_INACTIVE;
458 }
459
460 UserServiceUtil.updateStatus(deleteUserId, status);
461 }
462 else {
463 UserServiceUtil.deleteUser(deleteUserId);
464 }
465 }
466 }
467
468 protected List<AnnouncementsDelivery> getAnnouncementsDeliveries(
469 ActionRequest actionRequest) {
470
471 List<AnnouncementsDelivery> announcementsDeliveries =
472 new ArrayList<AnnouncementsDelivery>();
473
474 for (String type : AnnouncementsEntryConstants.TYPES) {
475 boolean email = ParamUtil.getBoolean(
476 actionRequest, "announcementsType" + type + "Email");
477 boolean sms = ParamUtil.getBoolean(
478 actionRequest, "announcementsType" + type + "Sms");
479 boolean website = ParamUtil.getBoolean(
480 actionRequest, "announcementsType" + type + "Website");
481
482 AnnouncementsDelivery announcementsDelivery =
483 new AnnouncementsDeliveryImpl();
484
485 announcementsDelivery.setType(type);
486 announcementsDelivery.setEmail(email);
487 announcementsDelivery.setSms(sms);
488 announcementsDelivery.setWebsite(website);
489
490 announcementsDeliveries.add(announcementsDelivery);
491 }
492
493 return announcementsDeliveries;
494 }
495
496 protected List<AnnouncementsDelivery> getAnnouncementsDeliveries(
497 ActionRequest actionRequest, User user)
498 throws Exception {
499
500 if (actionRequest.getParameter(
501 "announcementsType" + AnnouncementsEntryConstants.TYPES[0] +
502 "Email") == null) {
503
504 return AnnouncementsDeliveryLocalServiceUtil.getUserDeliveries(
505 user.getUserId());
506 }
507
508 return getAnnouncementsDeliveries(actionRequest);
509 }
510
511 protected long[] getLongArray(PortletRequest portletRequest, String name) {
512 String value = portletRequest.getParameter(name);
513
514 if (value == null) {
515 return null;
516 }
517
518 return StringUtil.split(GetterUtil.getString(value), 0L);
519 }
520
521 protected User updateLockout(ActionRequest actionRequest) throws Exception {
522 User user = PortalUtil.getSelectedUser(actionRequest);
523
524 UserServiceUtil.updateLockoutById(user.getUserId(), false);
525
526 return user;
527 }
528
529 protected Object[] updateUser(
530 ActionRequest actionRequest, ActionResponse actionResponse)
531 throws Exception {
532
533 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
534 WebKeys.THEME_DISPLAY);
535
536 User user = PortalUtil.getSelectedUser(actionRequest);
537
538 boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo");
539
540 if (deleteLogo) {
541 UserServiceUtil.deletePortrait(user.getUserId());
542 }
543
544 Contact contact = user.getContact();
545
546 String oldPassword = AdminUtil.getUpdateUserPassword(
547 actionRequest, user.getUserId());
548 String newPassword1 = actionRequest.getParameter("password1");
549 String newPassword2 = actionRequest.getParameter("password2");
550 boolean passwordReset = ParamUtil.getBoolean(
551 actionRequest, "passwordReset");
552
553 String reminderQueryQuestion = BeanParamUtil.getString(
554 user, actionRequest, "reminderQueryQuestion");
555
556 if (reminderQueryQuestion.equals(UsersAdminUtil.CUSTOM_QUESTION)) {
557 reminderQueryQuestion = BeanParamUtil.getStringSilent(
558 user, actionRequest, "reminderQueryCustomQuestion");
559 }
560
561 String reminderQueryAnswer = BeanParamUtil.getString(
562 user, actionRequest, "reminderQueryAnswer");
563 String oldScreenName = user.getScreenName();
564 String screenName = BeanParamUtil.getString(
565 user, actionRequest, "screenName");
566 String oldEmailAddress = user.getEmailAddress();
567 String emailAddress = BeanParamUtil.getString(
568 user, actionRequest, "emailAddress");
569 long facebookId = user.getFacebookId();
570 String openId = BeanParamUtil.getString(user, actionRequest, "openId");
571 String languageId = BeanParamUtil.getString(
572 user, actionRequest, "languageId");
573 String timeZoneId = BeanParamUtil.getString(
574 user, actionRequest, "timeZoneId");
575 String greeting = BeanParamUtil.getString(
576 user, actionRequest, "greeting");
577 String firstName = BeanParamUtil.getString(
578 user, actionRequest, "firstName");
579 String middleName = BeanParamUtil.getString(
580 user, actionRequest, "middleName");
581 String lastName = BeanParamUtil.getString(
582 user, actionRequest, "lastName");
583 int prefixId = BeanParamUtil.getInteger(
584 contact, actionRequest, "prefixId");
585 int suffixId = BeanParamUtil.getInteger(
586 contact, actionRequest, "suffixId");
587 boolean male = BeanParamUtil.getBoolean(
588 user, actionRequest, "male", true);
589
590 Calendar birthdayCal = CalendarFactoryUtil.getCalendar();
591
592 birthdayCal.setTime(contact.getBirthday());
593
594 int birthdayMonth = ParamUtil.getInteger(
595 actionRequest, "birthdayMonth", birthdayCal.get(Calendar.MONTH));
596 int birthdayDay = ParamUtil.getInteger(
597 actionRequest, "birthdayDay", birthdayCal.get(Calendar.DATE));
598 int birthdayYear = ParamUtil.getInteger(
599 actionRequest, "birthdayYear", birthdayCal.get(Calendar.YEAR));
600 String comments = BeanParamUtil.getString(
601 user, actionRequest, "comments");
602 String smsSn = BeanParamUtil.getString(contact, actionRequest, "smsSn");
603 String aimSn = BeanParamUtil.getString(contact, actionRequest, "aimSn");
604 String facebookSn = BeanParamUtil.getString(
605 contact, actionRequest, "facebookSn");
606 String icqSn = BeanParamUtil.getString(contact, actionRequest, "icqSn");
607 String jabberSn = BeanParamUtil.getString(
608 contact, actionRequest, "jabberSn");
609 String msnSn = BeanParamUtil.getString(contact, actionRequest, "msnSn");
610 String mySpaceSn = BeanParamUtil.getString(
611 contact, actionRequest, "mySpaceSn");
612 String skypeSn = BeanParamUtil.getString(
613 contact, actionRequest, "skypeSn");
614 String twitterSn = BeanParamUtil.getString(
615 contact, actionRequest, "twitterSn");
616 String ymSn = BeanParamUtil.getString(contact, actionRequest, "ymSn");
617 String jobTitle = BeanParamUtil.getString(
618 user, actionRequest, "jobTitle");
619 long[] groupIds = getLongArray(
620 actionRequest, "groupsSearchContainerPrimaryKeys");
621 long[] organizationIds = getLongArray(
622 actionRequest, "organizationsSearchContainerPrimaryKeys");
623 long[] roleIds = getLongArray(
624 actionRequest, "rolesSearchContainerPrimaryKeys");
625
626 List<UserGroupRole> userGroupRoles = null;
627
628 if ((actionRequest.getParameter("groupRolesGroupIds") != null) ||
629 (actionRequest.getParameter("groupRolesRoleIds") != null)) {
630
631 userGroupRoles = UsersAdminUtil.getUserGroupRoles(actionRequest);
632 }
633
634 long[] userGroupIds = getLongArray(
635 actionRequest, "userGroupsSearchContainerPrimaryKeys");
636 List<Address> addresses = UsersAdminUtil.getAddresses(
637 actionRequest, user.getAddresses());
638 List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(
639 actionRequest, user.getEmailAddresses());
640 List<Phone> phones = UsersAdminUtil.getPhones(
641 actionRequest, user.getPhones());
642 List<Website> websites = UsersAdminUtil.getWebsites(
643 actionRequest, user.getWebsites());
644 List<AnnouncementsDelivery> announcementsDeliveries =
645 getAnnouncementsDeliveries(actionRequest, user);
646
647 ServiceContext serviceContext = ServiceContextFactory.getInstance(
648 User.class.getName(), actionRequest);
649
650 user = UserServiceUtil.updateUser(
651 user.getUserId(), oldPassword, newPassword1, newPassword2,
652 passwordReset, reminderQueryQuestion, reminderQueryAnswer,
653 screenName, emailAddress, facebookId, openId, languageId,
654 timeZoneId, greeting, comments, firstName, middleName, lastName,
655 prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear,
656 smsSn, aimSn, facebookSn, icqSn, jabberSn, msnSn, mySpaceSn,
657 skypeSn, twitterSn, ymSn, jobTitle, groupIds, organizationIds,
658 roleIds, userGroupRoles, userGroupIds, addresses, emailAddresses,
659 phones, websites, announcementsDeliveries, serviceContext);
660
661 if (oldScreenName.equals(user.getScreenName())) {
662 oldScreenName = StringPool.BLANK;
663 }
664
665 boolean updateLanguageId = false;
666
667 if (user.getUserId() == themeDisplay.getUserId()) {
668
669
670
671 HttpServletRequest request = PortalUtil.getHttpServletRequest(
672 actionRequest);
673 HttpServletResponse response= PortalUtil.getHttpServletResponse(
674 actionResponse);
675 HttpSession session = request.getSession();
676
677 session.removeAttribute(Globals.LOCALE_KEY);
678
679 Locale locale = LocaleUtil.fromLanguageId(languageId);
680
681 LanguageUtil.updateCookie(request, response, locale);
682
683
684
685 PortletSession portletSession = actionRequest.getPortletSession();
686
687 InvokerPortletImpl.clearResponses(portletSession);
688
689
690
691 if (PropsValues.SESSION_STORE_PASSWORD &&
692 Validator.isNotNull(newPassword1)) {
693
694 portletSession.setAttribute(
695 WebKeys.USER_PASSWORD, newPassword1,
696 PortletSession.APPLICATION_SCOPE);
697 }
698
699 updateLanguageId = true;
700 }
701
702 String portletId = serviceContext.getPortletId();
703
704 if (!portletId.equals(PortletKeys.MY_ACCOUNT)) {
705 long publicLayoutSetPrototypeId = ParamUtil.getLong(
706 actionRequest, "publicLayoutSetPrototypeId");
707 long privateLayoutSetPrototypeId = ParamUtil.getLong(
708 actionRequest, "privateLayoutSetPrototypeId");
709 boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
710 actionRequest, "publicLayoutSetPrototypeLinkEnabled");
711 boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
712 actionRequest, "privateLayoutSetPrototypeLinkEnabled");
713
714 SitesUtil.updateLayoutSetPrototypesLinks(
715 user.getGroup(), publicLayoutSetPrototypeId,
716 privateLayoutSetPrototypeId,
717 publicLayoutSetPrototypeLinkEnabled,
718 privateLayoutSetPrototypeLinkEnabled);
719 }
720
721 Company company = PortalUtil.getCompany(actionRequest);
722
723 if (company.isStrangersVerify() &&
724 !oldEmailAddress.equalsIgnoreCase(emailAddress)) {
725
726 SessionMessages.add(actionRequest, "verificationEmailSent");
727 }
728
729 return new Object[] {user, oldScreenName, updateLanguageId};
730 }
731
732 }