public void execute(Event<UIGroupMemberSelector> event) throws Exception {
   UIGroupMemberSelector uiGroupMemberSelector = event.getSource();
   if (uiGroupMemberSelector.getCurrentGroup() == null) return;
   String groupId = uiGroupMemberSelector.getCurrentGroup().getId();
   String permission = event.getRequestContext().getRequestParameter(OBJECTID);
   String value = "";
   if (uiGroupMemberSelector.isSelectedUser()) {
     value = permission;
   } else {
     value = permission + ":" + groupId;
   }
   String returnField = uiGroupMemberSelector.getReturnField();
   ((UISelectable) uiGroupMemberSelector.getSourceComponent()).doSelect(returnField, value);
   if (uiGroupMemberSelector.isUsePopup) {
     UIPopupWindow uiPopup = uiGroupMemberSelector.getParent();
     uiPopup.setShow(false);
     UIComponent uicomp = uiGroupMemberSelector.getSourceComponent().getParent();
     event.getRequestContext().addUIComponentToUpdateByAjax(uicomp);
     if (!uiPopup.getId().equals("PopupComponent"))
       event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
   } else {
     event
         .getRequestContext()
         .addUIComponentToUpdateByAjax(uiGroupMemberSelector.getSourceComponent());
   }
 }
 public void execute(Event<UIModeratorManagementForm> event) throws Exception {
   UIModeratorManagementForm uiForm = event.getSource();
   uiForm.isEdit = false;
   UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
   popupWindow.setWindowSize(760, 350);
   event.getRequestContext().addUIComponentToUpdateByAjax(popupWindow.getParent());
 }
 /**
  * Initializes search form fields.
  *
  * @throws Exception
  */
 public UISpaceSearch() throws Exception {
   addUIFormInput(new UIFormStringInput(SPACE_SEARCH, null, DEFAULT_SPACE_NAME_SEARCH));
   UIPopupWindow uiPopup = createUIComponent(UIPopupWindow.class, null, POPUP_ADD_SPACE);
   uiPopup.setShow(false);
   uiPopup.setWindowSize(400, 0);
   addChild(uiPopup);
 }
Exemple #4
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIAddAttachment component = event.getSource();
   EventUIComponent eventUIComponent = component.getTargetAttachEvent();
   UIPortletApplication portlet = component.getAncestorOfType(UIPortletApplication.class);
   UIComponent targerComponent = portlet.findComponentById(eventUIComponent.getId());
   Event<UIComponent> xEvent =
       targerComponent.createEvent(
           eventUIComponent.getEventName(), Event.Phase.PROCESS, event.getRequestContext());
   if (!StringUtils.isEmpty(getSelectedFile(event))) {
     processEvent(event);
   } else {
     event
         .getRequestContext()
         .getUIApplication()
         .addMessage(
             new ApplicationMessage(
                 "UIAddAttachment.msg.not-a-file", null, ApplicationMessage.WARNING));
     ((PortalRequestContext) event.getRequestContext().getParentAppRequestContext())
         .ignoreAJAXUpdateOnPortlets(true);
     return;
   }
   if (xEvent != null) {
     xEvent.broadcast();
   }
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setRendered(false);
   uiPopupWindow.setUIComponent(null);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }
 public UIUserInGroup() throws Exception {
   UIGrid uiGrid = addChild(UIGridUser.class, "UIGridUser", null);
   uiGrid.configure("id", USER_BEAN_FIELD, USER_ACTION);
   uiGrid.getUIPageIterator().setId("UIUserInGroupIterator");
   addChild(UIGroupMembershipForm.class, null, null);
   UIPopupWindow editMemberPopup = addChild(UIPopupWindow.class, null, "EditMembership");
   editMemberPopup.setWindowSize(400, 0);
 }
 public void execute(Event<UIPopupWindow> event) throws Exception {
   UICLVTemplatesManager uiTemplateManager =
       event.getSource().getAncestorOfType(UICLVTemplatesManager.class);
   UICLVTemplateContainer uiTemplateContainer =
       uiTemplateManager.getChildById(uiTemplateManager.getSelectedTabId());
   UIPopupWindow uiPopupWindow = uiTemplateContainer.getChild(UIPopupWindow.class);
   uiPopupWindow.setRendered(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiTemplateManager);
 }
  public UISpaceNavigationManagement() throws Exception {
    UIPopupWindow uiPopup = createUIComponent(UIPopupWindow.class, "AddNode", null);
    uiPopup.setWindowSize(800, 445);
    uiPopup.setShow(false);
    addChild(uiPopup);

    addChild(UISpaceNavigationNodeSelector.class, null, null);
    reloadTreeData();
  }
Exemple #8
0
    @Override
    public void execute(Event<UIAvatarUploader> event) throws Exception {
      WebuiRequestContext ctx = event.getRequestContext();
      UIApplication uiApplication = ctx.getUIApplication();
      UIAvatarUploader uiAvatarUploader = event.getSource();
      UIFormUploadInput uiAvatarUploadInput = uiAvatarUploader.getChild(UIFormUploadInput.class);
      UIPopupWindow uiPopup = uiAvatarUploader.getParent();
      InputStream uploadedStream = uiAvatarUploadInput.getUploadDataAsStream();

      if (uploadedStream == null) {
        uiApplication.addMessage(
            new ApplicationMessage(MSG_IMG_NOT_UPLOADED, null, ApplicationMessage.ERROR));
        ctx.addUIComponentToUpdateByAjax(uiAvatarUploader);
        return;
      }
      UploadResource uploadResource = uiAvatarUploadInput.getUploadResource();

      String mimeType = uploadResource.getMimeType();
      String uploadId = uiAvatarUploadInput.getUploadId();
      if (!uiAvatarUploader.isAcceptedMimeType(mimeType)) {
        UploadService uploadService =
            (UploadService) PortalContainer.getComponent(UploadService.class);
        uploadService.removeUploadResource(uploadId);
        uiApplication.addMessage(
            new ApplicationMessage(MSG_MIMETYPE_NOT_ACCEPTED, null, ApplicationMessage.ERROR));
        ctx.addUIComponentToUpdateByAjax(uiAvatarUploader);
      } else {
        MimeTypeResolver mimeTypeResolver = new MimeTypeResolver();
        String fileName = uploadResource.getFileName();

        // @since 1.1.3
        String extension = mimeTypeResolver.getExtension(mimeType);
        if ("".equals(extension)) {
          mimeType = uiAvatarUploader.getStandardMimeType(mimeType);
        }

        // Resize avatar to fixed width if can't(avatarAttachment == null) keep
        // origin avatar
        AvatarAttachment avatarAttachment =
            ImageUtils.createResizedAvatarAttachment(
                uploadedStream, WIDTH, 0, null, fileName, mimeType, null);
        if (avatarAttachment == null) {
          avatarAttachment =
              new AvatarAttachment(
                  null, fileName, mimeType, uploadedStream, null, System.currentTimeMillis());
        }

        UploadService uploadService =
            (UploadService) PortalContainer.getComponent(UploadService.class);
        uploadService.removeUploadResource(uploadId);
        UIAvatarUploadContent uiAvatarUploadContent =
            uiAvatarUploader.createUIComponent(UIAvatarUploadContent.class, null, null);
        uiAvatarUploadContent.setAvatarAttachment(avatarAttachment);
        uiPopup.setUIComponent(uiAvatarUploadContent);
        ctx.addUIComponentToUpdateByAjax(uiPopup);
      }
    }
 @Override
 public void execute(Event<UIPageNodeForm> event) throws Exception {
   UIPageNodeForm uiPageNode = event.getSource();
   UserNavigation contextNavigation = uiPageNode.getContextPageNavigation();
   UISpaceNavigationManagement uiSpaceNavManagement =
       uiPageNode.getAncestorOfType(UISpaceNavigationManagement.class);
   UIPopupWindow uiPopup = uiSpaceNavManagement.getChild(UIPopupWindow.class);
   uiPopup.setShow(false);
 }
 @Override
 public void execute(Event<UISpaceSearch> event) throws Exception {
   UISpaceSearch uiSpaceSearch = event.getSource();
   UIPopupWindow uiPopup = uiSpaceSearch.getChild(UIPopupWindow.class);
   UISpaceAddForm uiAddSpaceForm =
       uiSpaceSearch.createUIComponent(UISpaceAddForm.class, null, null);
   uiPopup.setUIComponent(uiAddSpaceForm);
   uiPopup.setWindowSize(500, 0);
   uiPopup.setShow(true);
 }
 public void execute(Event<UIUserSelector> event) throws Exception {
   UIUserSelector uiForm = event.getSource();
   UIPermissionManagerBase uiParent = uiForm.getAncestorOfType(UIPermissionManagerBase.class);
   UIPermissionFormBase uiPermissionForm = uiParent.getChild(UIPermissionFormBase.class);
   uiPermissionForm.doSelect(UIPermissionInputSet.FIELD_USERORGROUP, uiForm.getSelectedUsers());
   UIPopupWindow uiPopup = uiParent.getChild(UIPopupWindow.class);
   uiPopup.setUIComponent(null);
   uiPopup.setShow(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiParent);
 }
Exemple #12
0
 public void execute(Event<UIUserContainer> event) throws Exception {
   UIUserContainer uiUserContainer = event.getSource();
   UIUserSelector uiUserSelector = uiUserContainer.getChild(UIUserSelector.class);
   UIPermissionManager uiParent = uiUserContainer.getAncestorOfType(UIPermissionManager.class);
   UIPermissionForm uiPermissionForm = uiParent.getChild(UIPermissionForm.class);
   uiPermissionForm.doSelect(
       UIPermissionInputSet.FIELD_USERORGROUP, uiUserSelector.getSelectedUsers());
   UIPopupWindow uiPopup = uiParent.findComponentById("PopupUserSelector");
   uiPopup.setShow(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiParent);
 }
Exemple #13
0
 public void onEvent(Event<UICategoryForm> event, UICategoryForm uiForm, String id)
     throws Exception {
   uiForm.id = Integer.parseInt(id);
   UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
   if (uiForm.id == 1) {
     popupWindow.setWindowSize(550, 440);
   } else {
     popupWindow.setWindowSize(550, 380);
   }
   Util.getPortalRequestContext().setResponseComplete(true);
 }
 public void execute(Event<UIUserInGroup> event) throws Exception {
   UIUserInGroup uiUserInGroup = event.getSource();
   String id = event.getRequestContext().getRequestParameter(OBJECTID);
   OrganizationService service =
       uiUserInGroup.getApplicationComponent(OrganizationService.class);
   MembershipHandler handler = service.getMembershipHandler();
   UIPopupWindow uiPopup = uiUserInGroup.getChild(UIPopupWindow.class);
   UIGroupEditMembershipForm uiEditMemberShip =
       uiUserInGroup.createUIComponent(UIGroupEditMembershipForm.class, null, null);
   uiEditMemberShip.setValue(handler.findMembership(id), uiUserInGroup.getSelectedGroup());
   uiPopup.setUIComponent(uiEditMemberShip);
   uiPopup.setShow(true);
 }
Exemple #15
0
 public void execute(Event<UIBreadcumbs> event) throws Exception {
   UIBreadcumbs uiBreadcumbs = event.getSource();
   UIGroupMemberSelector uiGroupMemberSelector = uiBreadcumbs.getParent();
   String objectId = event.getRequestContext().getRequestParameter(OBJECTID);
   uiBreadcumbs.setSelectPath(objectId);
   String selectGroupId = uiBreadcumbs.getSelectLocalPath().getId();
   uiGroupMemberSelector.changeGroup(selectGroupId);
   if (uiGroupMemberSelector.isUsePopup) {
     UIPopupWindow uiPopup = uiBreadcumbs.getAncestorOfType(UIPopupWindow.class);
     uiPopup.setShow(true);
     uiPopup.setShowMask(true);
   }
   event.getRequestContext().addUIComponentToUpdateByAjax(uiGroupMemberSelector);
 }
 @Override
 public void execute(Event<UIPopupWindow> event) throws Exception {
   UIPopupWindow uiPopup = event.getSource();
   UISpaceNavigationManagement uiSpaceNavManagement =
       uiPopup.getAncestorOfType(UISpaceNavigationManagement.class);
   UISpaceNavigationNodeSelector selector =
       uiSpaceNavManagement.getChild(UISpaceNavigationNodeSelector.class);
   UserNavigation contextNavigation = selector.getEdittedNavigation();
   uiPopup.setShow(false);
   uiSpaceNavManagement.setOwner(contextNavigation.getKey().getName());
   uiSpaceNavManagement.setOwnerType(contextNavigation.getKey().getTypeName());
   selector.setEdittedNavigation(contextNavigation);
   selector.initTreeData();
   event.getRequestContext().addUIComponentToUpdateByAjax(uiSpaceNavManagement);
 }
 public void onEvent(
     Event<UIModeratorManagementForm> event, UIModeratorManagementForm uiForm, String userId)
     throws Exception {
   uiForm.editUserProfile =
       uiForm.getForumService().updateUserProfileSetting(uiForm.getUserProfile(userId));
   uiForm.removeChildById("ForumUserProfile");
   uiForm.removeChildById("ForumUserOption");
   uiForm.removeChildById("ForumUserBan");
   uiForm.removeChild(UIPageListTopicByUser.class);
   uiForm.removeChild(UIPageListPostByUser.class);
   uiForm.initUserProfileForm();
   uiForm.isEdit = true;
   UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
   popupWindow.setWindowSize(950, 540);
   event.getRequestContext().addUIComponentToUpdateByAjax(popupWindow.getParent());
 }
    public void execute(Event<UIBreadcumbs> event) throws Exception {
      UIBreadcumbs uiBreadcumbs = event.getSource();
      UISocialGroupSelector uiSelector = uiBreadcumbs.getParent();
      String objectId = event.getRequestContext().getRequestParameter(OBJECTID);
      uiBreadcumbs.setSelectPath(objectId);
      String selectGroupId = uiBreadcumbs.getSelectLocalPath().getId();
      uiSelector.changeGroup(selectGroupId);

      UIPopupWindow uiPopup = uiSelector.getParent();
      uiPopup.setShow(true);

      UIForm uiForm = event.getSource().getAncestorOfType(UIForm.class);
      if (uiForm != null) {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
      } else {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
      }
    }
Exemple #19
0
 public void execute(Event<UIAnyPermission> event) throws Exception {
   UIAnyPermission uiAnyPermission = event.getSource();
   UIGroupMemberSelector uiGroupMemberSelector = uiAnyPermission.getParent();
   String returnField = uiGroupMemberSelector.getReturnField();
   String value = IdentityConstants.ANY;
   ((UISelectable) uiGroupMemberSelector.getSourceComponent()).doSelect(returnField, value);
   if (uiGroupMemberSelector.isUsePopup()) {
     UIPopupWindow uiPopup = uiGroupMemberSelector.getParent();
     uiPopup.setShow(false);
     UIComponent uicomp = uiGroupMemberSelector.getSourceComponent().getParent();
     event.getRequestContext().addUIComponentToUpdateByAjax(uicomp);
     if (!uiPopup.getId().equals("PopupComponent"))
       event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
   } else {
     event
         .getRequestContext()
         .addUIComponentToUpdateByAjax(uiGroupMemberSelector.getSourceComponent());
   }
 }
 public void initPopupPermission(UIComponent uiSelector) throws Exception {
   removeChildById(UIPermissionForm.POPUP_SELECT);
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, UIPermissionForm.POPUP_SELECT);
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(560, 300);
   uiPopup.setRendered(true);
   uiPopup.setUIComponent(uiSelector);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
  public UIUserSelector() throws Exception {
    addUIFormInput(new UIFormStringInput(FIELD_KEYWORD, FIELD_KEYWORD, null));
    addUIFormInput(new UIFormSelectBox(FIELD_FILTER, FIELD_FILTER, getFilters()));
    addUIFormInput(new UIFormStringInput(FIELD_GROUP, FIELD_GROUP, null));
    isShowSearch_ = true;
    OrganizationService service = getApplicationComponent(OrganizationService.class);
    ObjectPageList objPageList =
        new ObjectPageList(service.getUserHandler().findUsers(new Query()).getAll(), 10);
    uiIterator_ = new UIPageIterator();
    uiIterator_.setPageList(objPageList);
    uiIterator_.setId("UISelectUserPage");

    // create group selector
    UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "UIPopupGroupSelector");
    uiPopup.setWindowSize(540, 0);
    UIGroupSelector uiGroup = createUIComponent(UIGroupSelector.class, null, null);
    uiPopup.setUIComponent(uiGroup);
    uiGroup.setId("GroupSelector");
    uiGroup.getChild(UITree.class).setId("TreeGroupSelector");
    uiGroup.getChild(UIBreadcumbs.class).setId("BreadcumbsGroupSelector");
  }
 public void initPopupPermission(UIComponent uiSelector) throws Exception {
   UIPopupWindow uiPopup = getChildById(UIPermissionFormBase.POPUP_SELECT);
   if (uiPopup == null) {
     uiPopup = addChild(UIPopupWindow.class, null, UIPermissionFormBase.POPUP_SELECT);
     uiPopup.setWindowSize(560, 345);
     uiPopup.setShowMask(true);
   } else {
     uiPopup.setShowMask(true);
     uiPopup.setRendered(true);
   }
   uiPopup.setUIComponent(uiSelector);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
 private void initTaggingFormPopup(Node selectedTag) throws Exception {
   removeChildById("TagPopup");
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "TagPopup");
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(600, 200);
   UITagForm uiForm = createUIComponent(UITagForm.class, null, null);
   uiForm.setTag(selectedTag);
   uiPopup.setUIComponent(uiForm);
   uiPopup.setRendered(true);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
    public void execute(Event<UISocialGroupSelector> event) throws Exception {
      UISocialGroupSelector uiSelector = event.getSource();
      UIComponent uiPermission = uiSelector.<UIComponent>getParent().getParent();
      WebuiRequestContext pcontext = event.getRequestContext();

      UIPopupWindow uiPopup = uiSelector.getParent();
      UIForm uiForm = event.getSource().getAncestorOfType(UIForm.class);
      if (uiForm != null) {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
      } else {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
      }
      if (uiSelector.getCurrentGroup() == null) {
        UIApplication uiApp = pcontext.getUIApplication();
        uiApp.addMessage(new ApplicationMessage("UIGroupSelector.msg.selectGroup", null));
        // pcontext.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
        uiPopup.setShow(true);
        return;
      }

      uiPermission.broadcast(event, event.getExecutionPhase());
      uiPopup.setShow(false);
    }
 public void initPopup(UIComponent uiComponent, String popupId) throws Exception {
   removeChildById(popupId);
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, popupId);
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(600, 300);
   uiPopup.setUIComponent(uiComponent);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
 public void initUserSelector() throws Exception {
   UIPopupWindow uiPopup = getChildById("PopupUserSelector");
   if (uiPopup == null) {
     uiPopup = addChild(UIPopupWindow.class, null, "PopupUserSelector");
   }
   uiPopup.setWindowSize(790, 400);
   UIUserContainer uiUserContainer = this.createUIComponent(UIUserContainer.class, null, null);
   uiPopup.setUIComponent(uiUserContainer);
   uiPopup.setShow(true);
   uiPopup.setShowMask(true);
   uiPopup.setResizable(true);
 }
    public void onEvent(
        Event<UIModeratorManagementForm> event, UIModeratorManagementForm uiForm, String userId)
        throws Exception {
      UserProfile userProfile = uiForm.editUserProfile;
      UIFormInputWithActions inputSetProfile = uiForm.getChildById(FIELD_USERPROFILE_FORM);
      String userTitle = inputSetProfile.getUIStringInput(FIELD_USERTITLE_INPUT).getValue();
      String screenName = inputSetProfile.getUIStringInput(FIELD_SCREENNAME_INPUT).getValue();
      screenName = CommonUtils.encodeSpecialCharInTitle(screenName);
      long userRole = 2;
      boolean isAdmin = inputSetProfile.getUICheckBoxInput(FIELD_USERROLE_CHECKBOX).isChecked();
      if (isAdmin || uiForm.isAdmin(userProfile.getUserId())) {
        isAdmin = true;
        userRole = 0;
      }
      //
      if (ForumUtils.isEmpty(userTitle)) {
        if (isAdmin) {
          userTitle = Utils.ADMIN;
        } else {
          userTitle = userProfile.getUserTitle();
        }
      } else {
        userTitle = CommonUtils.encodeSpecialCharInTitle(userTitle);
      }
      // -----------------
      List<String> oldModerateForum =
          uiForm.getModerateList(Arrays.asList(userProfile.getModerateForums()));
      List<String> newModeratorsForum = new ArrayList<String>();
      List<String> removeModerateForum = new ArrayList<String>();
      List<String> forumIdsMod = new ArrayList<String>();
      //
      newModeratorsForum = uiForm.getModerateList(uiForm.listModerate);
      forumIdsMod.addAll(newModeratorsForum);
      if (newModeratorsForum.isEmpty()) {
        removeModerateForum = oldModerateForum;
      } else {
        for (String string : oldModerateForum) {
          if (newModeratorsForum.contains(string)) {
            newModeratorsForum.remove(string);
          } else {
            removeModerateForum.add(string);
          }
        }
        if (!newModeratorsForum.isEmpty())
          uiForm
              .getForumService()
              .saveModerateOfForums(newModeratorsForum, userProfile.getUserId(), false);
      }
      if (!removeModerateForum.isEmpty()) {
        uiForm
            .getForumService()
            .saveModerateOfForums(removeModerateForum, userProfile.getUserId(), true);
      }

      uiForm
          .getForumService()
          .saveUserModerator(userProfile.getUserId(), uiForm.listModerate, false);

      List<String> moderateCates = new ArrayList<String>();
      moderateCates.addAll(uiForm.listModCate);
      List<String> newModeratorsCate = new ArrayList<String>();
      List<String> categoryIdsMod = new ArrayList<String>();
      List<String> oldModerateCate =
          uiForm.getModerateList(Arrays.asList(userProfile.getModerateCategory()));
      List<String> removeModerateCate = new ArrayList<String>();
      // set moderator category
      newModeratorsCate = uiForm.getModerateList(moderateCates);
      categoryIdsMod.addAll(newModeratorsCate);
      if (newModeratorsCate.isEmpty()) {
        removeModerateCate = oldModerateCate;
      } else {
        for (String string : oldModerateCate) {
          if (newModeratorsCate.contains(string)) {
            newModeratorsCate.remove(string);
          } else {
            removeModerateCate.add(string);
          }
        }
        if (!newModeratorsCate.isEmpty()) {
          uiForm
              .getForumService()
              .saveModOfCategory(newModeratorsCate, userProfile.getUserId(), true);
          if (userRole > 1) userRole = 1;
        }
      }
      if (removeModerateCate.size() > 0) {
        uiForm
            .getForumService()
            .saveModOfCategory(removeModerateCate, userProfile.getUserId(), false);
      }

      if (userRole > 1) {
        uiForm.listModerate =
            uiForm.getForumService().getUserModerator(userProfile.getUserId(), false);
        if (uiForm.listModerate.size() >= 1 && !uiForm.listModerate.get(0).equals(" "))
          userRole = 1;
      }

      if (userTitle == null || userTitle.trim().length() < 1) {
        userTitle = userProfile.getUserTitle();
      } else if (!isAdmin) {
        int newPos = Arrays.asList(uiForm.permissionUser).indexOf(userTitle.toLowerCase());
        if (newPos >= 0 && newPos < userRole) {
          if (Arrays.asList(uiForm.permissionUser).indexOf(userProfile.getUserTitle().toLowerCase())
              < 0) userTitle = userProfile.getUserTitle();
          else userTitle = uiForm.titleUser[(int) userRole];
        }
      } else {
        if (userTitle.equalsIgnoreCase(uiForm.titleUser[1])
            || userTitle.equalsIgnoreCase(uiForm.titleUser[2])) userTitle = uiForm.titleUser[0];
      }
      if (userRole == 1 && userTitle.equalsIgnoreCase(uiForm.titleUser[2])) {
        userTitle = uiForm.titleUser[1];
      }

      String signature =
          inputSetProfile.getUIFormTextAreaInput(FIELD_SIGNATURE_TEXTAREA).getValue();
      signature = CommonUtils.encodeSpecialCharInTitle(signature);
      boolean isDisplaySignature =
          inputSetProfile.getUICheckBoxInput(FIELD_ISDISPLAYSIGNATURE_CHECKBOX).isChecked();
      Boolean isDisplayAvatar =
          inputSetProfile.getUICheckBoxInput(FIELD_ISDISPLAYAVATAR_CHECKBOX).isChecked();

      UIFormInputWithActions inputSetOption = uiForm.getChildById(FIELD_USEROPTION_FORM);
      double timeZone =
          Double.parseDouble(
              inputSetOption.getUIFormSelectBox(FIELD_TIMEZONE_SELECTBOX).getValue());
      String shortDateFormat =
          inputSetOption.getUIFormSelectBox(FIELD_SHORTDATEFORMAT_SELECTBOX).getValue();
      String longDateFormat =
          inputSetOption.getUIFormSelectBox(FIELD_LONGDATEFORMAT_SELECTBOX).getValue();
      String timeFormat = inputSetOption.getUIFormSelectBox(FIELD_TIMEFORMAT_SELECTBOX).getValue();
      long maxTopic =
          Long.parseLong(
              inputSetOption.getUIFormSelectBox(FIELD_MAXTOPICS_SELECTBOX).getValue().substring(2));
      long maxPost =
          Long.parseLong(
              inputSetOption.getUIFormSelectBox(FIELD_MAXPOSTS_SELECTBOX).getValue().substring(2));

      UIFormInputWithActions inputSetBan = uiForm.getChildById(FIELD_USERBAN_FORM);
      boolean wasBanned = userProfile.getIsBanned();
      boolean isBanned = inputSetBan.getUICheckBoxInput(FIELD_ISBANNED_CHECKBOX).isChecked();
      String until = inputSetBan.getUIFormSelectBox(FIELD_BANUNTIL_SELECTBOX).getValue();
      long banUntil = 0;
      if (!ForumUtils.isEmpty(until)) {
        banUntil = Long.parseLong(until.substring(6));
      }
      String banReason = inputSetBan.getUIFormTextAreaInput(FIELD_BANREASON_TEXTAREA).getValue();
      String[] banReasonSummaries = userProfile.getBanReasonSummary();
      Date date = CommonUtils.getGreenwichMeanTime().getTime();
      int banCounter = userProfile.getBanCounter();
      date.setTime(banUntil);
      StringBuffer stringBuffer = new StringBuffer();
      if (!ForumUtils.isEmpty(banReason)) {
        stringBuffer.append("Ban Reason: ").append(banReason).append(" ");
      }
      stringBuffer
          .append("From Date: ")
          .append(
              TimeConvertUtils.getFormatDate(
                  "MM-dd-yyyy hh:mm a", CommonUtils.getGreenwichMeanTime().getTime()))
          .append(" GMT+0 To Date: ")
          .append(TimeConvertUtils.getFormatDate("MM-dd-yyyy hh:mm a", date))
          .append(" GMT+0");
      if (isBanned) {
        if (banReasonSummaries != null && banReasonSummaries.length > 0) {
          if (wasBanned) {
            banReasonSummaries[0] = stringBuffer.toString();
          } else {
            String[] temp = new String[banReasonSummaries.length + 1];
            int i = 1;
            for (String string : banReasonSummaries) {
              temp[i++] = string;
            }
            temp[0] = stringBuffer.toString();
            banReasonSummaries = temp;
            banCounter = banCounter + 1;
          }
        } else {
          banReasonSummaries = new String[] {stringBuffer.toString()};
          banCounter = 1;
        }
      }
      userProfile.setUserTitle(userTitle);
      userProfile.setScreenName(screenName);
      userProfile.setUserRole(userRole);
      userProfile.setSignature(signature);
      userProfile.setIsDisplaySignature(isDisplaySignature);
      userProfile.setModerateCategory(moderateCates.toArray(new String[] {}));
      userProfile.setIsDisplayAvatar(isDisplayAvatar);

      userProfile.setTimeZone(-timeZone);
      userProfile.setShortDateFormat(shortDateFormat);
      userProfile.setLongDateFormat(longDateFormat.replace('=', ' '));
      userProfile.setTimeFormat(timeFormat.replace('=', ' '));
      userProfile.setMaxPostInPage(maxPost);
      userProfile.setMaxTopicInPage(maxTopic);
      userProfile.setIsBanned(isBanned);
      userProfile.setBanUntil(banUntil);
      userProfile.setBanReason(banReason);
      userProfile.setBanCounter(banCounter);
      userProfile.setBanReasonSummary(banReasonSummaries);
      try {
        uiForm.getForumService().saveUserProfile(userProfile, true, true);
      } catch (Exception e) {
        uiForm.log.trace("\nSave user profile fail: " + e.getMessage() + "\n" + e.getCause());
      }
      uiForm.isEdit = false;
      if (ForumUtils.isEmpty(uiForm.valueSearch)) {
        uiForm.isViewSearchUser = false;
      } else {
        uiForm.searchUserProfileByKey(uiForm.valueSearch);
      }
      UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
      popupWindow.setWindowSize(760, 350);
      event.getRequestContext().addUIComponentToUpdateByAjax(popupWindow.getParent());
    }
Exemple #28
0
 @Override
 public void execute(Event<UIAvatarUploader> event) throws Exception {
   UIAvatarUploader uiAvatarUploader = event.getSource();
   UIPopupWindow uiPopup = uiAvatarUploader.getParent();
   uiPopup.setShow(false);
 }
Exemple #29
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setUIComponent(null);
   uiPopupWindow.setRendered(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }
 public void execute(Event<UIPermissionManager> event) throws Exception {
   UIPopupWindow popupAction = event.getSource().getAncestorOfType(UIPopupWindow.class);
   popupAction.setRendered(false);
   popupAction.setShow(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }