1 31 32 package org.opencms.workplace.commons; 33 34 import org.opencms.db.CmsUserSettings; 35 import org.opencms.file.CmsObject; 36 import org.opencms.file.CmsProject; 37 import org.opencms.file.CmsResource; 38 import org.opencms.file.CmsUser; 39 import org.opencms.i18n.CmsEncoder; 40 import org.opencms.i18n.CmsLocaleManager; 41 import org.opencms.jsp.CmsJspActionElement; 42 import org.opencms.main.CmsException; 43 import org.opencms.main.CmsLog; 44 import org.opencms.main.OpenCms; 45 import org.opencms.report.I_CmsReport; 46 import org.opencms.security.CmsPasswordInfo; 47 import org.opencms.site.CmsSite; 48 import org.opencms.site.CmsSiteManager; 49 import org.opencms.synchronize.CmsSynchronizeSettings; 50 import org.opencms.util.CmsStringUtil; 51 import org.opencms.workflow.CmsTaskService; 52 import org.opencms.workplace.CmsTabDialog; 53 import org.opencms.workplace.CmsWorkplace; 54 import org.opencms.workplace.CmsWorkplaceManager; 55 import org.opencms.workplace.CmsWorkplaceMessages; 56 import org.opencms.workplace.CmsWorkplaceSettings; 57 import org.opencms.workplace.CmsWorkplaceView; 58 import org.opencms.workplace.editors.CmsWorkplaceEditorConfiguration; 59 import org.opencms.workplace.explorer.CmsExplorerTypeSettings; 60 61 import java.io.IOException ; 62 import java.util.ArrayList ; 63 import java.util.Enumeration ; 64 import java.util.HashMap ; 65 import java.util.Iterator ; 66 import java.util.List ; 67 import java.util.Locale ; 68 import java.util.Map ; 69 import java.util.SortedMap ; 70 import java.util.TreeMap ; 71 72 import javax.servlet.ServletException ; 73 import javax.servlet.http.HttpServletRequest ; 74 import javax.servlet.http.HttpServletResponse ; 75 import javax.servlet.http.HttpSession ; 76 import javax.servlet.jsp.JspException ; 77 import javax.servlet.jsp.PageContext ; 78 79 import org.apache.commons.logging.Log; 80 81 96 public class CmsPreferences extends CmsTabDialog { 97 98 99 public static final int ACTION_CHPWD = 202; 100 101 102 public static final int ACTION_ERROR = 203; 103 104 105 public static final int ACTION_RELOAD = 201; 106 107 108 public static final String DIALOG_CHPWD = "chpwd"; 109 110 111 public static final String DIALOG_RELOAD = "reload"; 112 113 114 public static final String DIALOG_TYPE = "preferences"; 115 116 117 public static final String INPUT_DEFAULT = "default"; 118 119 120 public static final String PARAM_DIALOGS_COPYFILEMODE = "tabdicopyfilemode"; 121 122 123 public static final String PARAM_DIALOGS_COPYFOLDERMODE = "tabdicopyfoldermode"; 124 125 126 public static final String PARAM_DIALOGS_DELETEFILEMODE = "tabdideletefilemode"; 127 128 129 public static final String PARAM_DIALOGS_PERMISSIONS_EXPANDINHERITED = "tabdipermissionsexpandinherited"; 130 131 132 public static final String PARAM_DIALOGS_PERMISSIONS_EXPANDUSER = "tabdipermissionsexpanduser"; 133 134 135 public static final String PARAM_DIALOGS_PERMISSIONS_INHERITONFOLDER = "tabdipermissionsinheritonfolder"; 136 137 138 public static final String PARAM_DIALOGS_PUBLISHFILEMODE = "tabdipublishfilemode"; 139 140 141 public static final String PARAM_DIALOGS_SHOWLOCK = "tabdishowlock"; 142 143 144 public static final String PARAM_DIRECTEDIT_BUTTONSTYLE = "tabeddirecteditbuttonstyle"; 145 146 147 public static final String PARAM_EDITOR_BUTTONSTYLE = "tabedbuttonstyle"; 148 149 150 public static final String PARAM_EXPLORER_BUTTONSTYLE = "tabexbuttonstyle"; 151 152 153 public static final String PARAM_EXPLORER_FILEDATECREATED = "tabexfiledatecreated"; 154 155 156 public static final String PARAM_EXPLORER_FILEDATEEXPIRED = "tabexfiledateexpired"; 157 158 159 public static final String PARAM_EXPLORER_FILEDATELASTMODIFIED = "tabexfiledatelastmodified"; 160 161 162 public static final String PARAM_EXPLORER_FILEDATERELEASED = "tabexfiledatereleased"; 163 164 165 public static final String PARAM_EXPLORER_FILEENTRIES = "tabexfileentries"; 166 167 168 public static final String PARAM_EXPLORER_FILELOCKEDBY = "tabexfilelockedby"; 169 170 171 public static final String PARAM_EXPLORER_FILEPERMISSIONS = "tabexfilepermissions"; 172 173 174 public static final String PARAM_EXPLORER_FILESIZE = "tabexfilesize"; 175 176 177 public static final String PARAM_EXPLORER_FILESTATE = "tabexfilestate"; 178 179 180 public static final String PARAM_EXPLORER_FILETITLE = "tabexfiletitle"; 181 182 183 public static final String PARAM_EXPLORER_FILETYPE = "tabexfiletype"; 184 185 186 public static final String PARAM_EXPLORER_FILEUSERCREATED = "tabexfileusercreated"; 187 188 189 public static final String PARAM_EXPLORER_FILEUSERLASTMODIFIED = "tabexfileuserlastmodified"; 190 191 192 public static final String PARAM_NEWPASSWORD = "newpassword"; 193 194 195 public static final String PARAM_OLDPASSWORD = "oldpassword"; 196 197 198 public static final String PARAM_PREFERREDEDITOR_PREFIX = "tabedprefed_"; 199 200 201 public static final String PARAM_WORKFLOW_FILTER = "tabwffilter"; 202 203 204 public static final String PARAM_WORKFLOW_MESSAGEACCEPTED = "tabwfmessageaccepted"; 205 206 207 public static final String PARAM_WORKFLOW_MESSAGECOMPLETED = "tabwfmessagecompleted"; 208 209 210 public static final String PARAM_WORKFLOW_MESSAGEFORWARDED = "tabwfmessageforwarded"; 211 212 213 public static final String PARAM_WORKFLOW_MESSAGEMEMBERS = "tabwfmessagemembers"; 214 215 216 public static final String PARAM_WORKFLOW_SHOWALLPROJECTS = "tabwfshowallprojects"; 217 218 219 public static final String PARAM_WORKPLACE_BUTTONSTYLE = "tabwpbuttonstyle"; 220 221 222 public static final String PARAM_WORKPLACE_FOLDER = "tabwpfolder"; 223 224 225 public static final String PARAM_WORKPLACE_LANGUAGE = "tabwplanguage"; 226 227 228 public static final String PARAM_WORKPLACE_PROJECT = "tabwpproject"; 229 230 231 public static final String PARAM_WORKPLACE_REPORTTYPE = "tabwpreporttype"; 232 233 234 public static final String PARAM_WORKPLACE_RESTRICTEXPLORERVIEW = "tabwprestrictexplorerview"; 235 236 237 public static final String PARAM_WORKPLACE_SITE = "tabwpsite"; 238 239 240 public static final String PARAM_WORKPLACE_USEUPLOADAPPLET = "tabwpuseuploadapplet"; 241 242 243 public static final String PARAM_WORKPLACE_VIEW = "tabwpview"; 244 245 246 private static final Log LOG = CmsLog.getLog(CmsPreferences.class); 247 248 249 private static final String SPACER = "------------------------------------------------"; 250 251 private String m_paramNewPassword; 252 private String m_paramOldPassword; 253 254 255 private CmsUserSettings m_userSettings; 256 257 262 public CmsPreferences(CmsJspActionElement jsp) { 263 264 super(jsp); 265 } 266 267 274 public CmsPreferences(PageContext context, HttpServletRequest req, HttpServletResponse res) { 275 276 this(new CmsJspActionElement(context, req, res)); 277 } 278 279 284 public void actionChangePassword() throws JspException { 285 286 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 288 String newPwd = getParamNewPassword(); 289 String oldPwd = getParamOldPassword(); 290 setAction(ACTION_DEFAULT); 292 setParamOldPassword(null); 293 setParamNewPassword(null); 294 295 try { 296 CmsPasswordInfo pwdInfo = new CmsPasswordInfo(getCms()); 297 pwdInfo.setCurrentPwd(oldPwd); 298 pwdInfo.setNewPwd(newPwd); 299 pwdInfo.setConfirmation(newPwd); 300 pwdInfo.applyChanges(); 301 } catch (Throwable e) { 302 setAction(ACTION_ERROR); 304 includeErrorpage(this, e); 305 } 306 } 307 308 311 public void actionSave() { 312 313 HttpServletRequest request = getJsp().getRequest(); 314 request.setAttribute(SESSION_WORKPLACE_CLASS, this); 316 317 CmsUserSettings userSettings = new CmsUserSettings(getCms(), getSettings().getUser()); 319 m_userSettings.setEditorSettings(userSettings.getEditorSettings()); 321 m_userSettings.setSynchronizeSettings(userSettings.getSynchronizeSettings()); 323 Enumeration en = request.getParameterNames(); 324 while (en.hasMoreElements()) { 325 String paramName = (String )en.nextElement(); 327 if (paramName.startsWith(PARAM_PREFERREDEDITOR_PREFIX)) { 328 String paramValue = request.getParameter(paramName); 329 if (paramValue != null && !INPUT_DEFAULT.equals(paramValue.trim())) { 330 m_userSettings.setPreferredEditor( 332 paramName.substring(PARAM_PREFERREDEDITOR_PREFIX.length()), 333 CmsEncoder.decode(paramValue)); 334 } else { 335 m_userSettings.setPreferredEditor(paramName.substring(PARAM_PREFERREDEDITOR_PREFIX.length()), null); 337 } 338 } 339 } 340 341 m_userSettings.setUser(getSettings().getUser()); 343 try { 344 m_userSettings.save(getCms()); 346 } catch (CmsException e) { 347 if (LOG.isInfoEnabled()) { 349 LOG.info(e.getLocalizedMessage()); 350 } 351 } 352 353 updatePreferences(getCms(), getJsp().getRequest()); 355 356 try { 357 String projectName = m_userSettings.getStartProject(); 358 CmsProject project = getCms().readProject(projectName); 359 getCms().getRequestContext().setCurrentProject(project); 360 getSettings().setProject(project.getId()); 361 } catch (Exception e) { 362 LOG.error(e.getLocalizedMessage()); 364 } 365 366 try { 368 if (DIALOG_SET.equals(getParamAction())) { 369 Map params = new HashMap (); 371 params.put(PARAM_TAB, String.valueOf(getActiveTab())); 372 params.put(PARAM_SETPRESSED, Boolean.TRUE.toString()); 373 sendForward(getJsp().getRequestContext().getUri(), params); 374 } else { 375 Map params = new HashMap (); 377 params.put(PARAM_ACTION, DIALOG_RELOAD); 378 sendForward(getJsp().getRequestContext().getUri(), params); 379 } 380 } catch (IOException e) { 381 if (LOG.isInfoEnabled()) { 383 LOG.info(e.getLocalizedMessage()); 384 } 385 } catch (ServletException e) { 386 if (LOG.isInfoEnabled()) { 388 LOG.info(e.getLocalizedMessage()); 389 } 390 } 391 } 392 393 399 public String buildSelectCopyFileMode(String htmlAttributes) { 400 401 List options = new ArrayList (2); 402 options.add(key(Messages.GUI_PREF_COPY_AS_SIBLING_0)); 403 options.add(key(Messages.GUI_COPY_AS_NEW_0)); 404 List values = new ArrayList (2); 405 values.add(String.valueOf(CmsResource.COPY_AS_SIBLING)); 406 values.add(String.valueOf(CmsResource.COPY_AS_NEW)); 407 int selectedIndex = values.indexOf(getParamTabDiCopyFileMode()); 408 return buildSelect(htmlAttributes, options, values, selectedIndex); 409 } 410 411 417 public String buildSelectCopyFolderMode(String htmlAttributes) { 418 419 List options = new ArrayList (3); 420 options.add(key(Messages.GUI_PREF_COPY_AS_SIBLINGS_0)); 421 options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_RESOURCES_0)); 422 options.add(key(Messages.GUI_PREF_COPY_AS_NEW_0)); 423 List values = new ArrayList (3); 424 values.add(String.valueOf(CmsResource.COPY_AS_SIBLING)); 425 values.add(String.valueOf(CmsResource.COPY_PRESERVE_SIBLING)); 426 values.add(String.valueOf(CmsResource.COPY_AS_NEW)); 427 int selectedIndex = values.indexOf(getParamTabDiCopyFolderMode()); 428 return buildSelect(htmlAttributes, options, values, selectedIndex); 429 } 430 431 437 public String buildSelectDeleteFileMode(String htmlAttributes) { 438 439 List options = new ArrayList (2); 440 options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_0)); 441 options.add(key(Messages.GUI_PREF_DELETE_SIBLINGS_0)); 442 List values = new ArrayList (2); 443 values.add(String.valueOf(CmsResource.DELETE_PRESERVE_SIBLINGS)); 444 values.add(String.valueOf(CmsResource.DELETE_REMOVE_SIBLINGS)); 445 int selectedIndex = values.indexOf(getParamTabDiDeleteFileMode()); 446 return buildSelect(htmlAttributes, options, values, selectedIndex); 447 } 448 449 455 public String buildSelectDirectEditButtonStyle(String htmlAttributes) { 456 457 int selectedIndex = Integer.parseInt(getParamTabEdDirectEditButtonStyle()); 458 return buildSelectButtonStyle(htmlAttributes, selectedIndex); 459 } 460 461 467 public String buildSelectEditorButtonStyle(String htmlAttributes) { 468 469 int selectedIndex = Integer.parseInt(getParamTabEdButtonStyle()); 470 return buildSelectButtonStyle(htmlAttributes, selectedIndex); 471 } 472 473 479 public String buildSelectExplorerButtonStyle(String htmlAttributes) { 480 481 int selectedIndex = Integer.parseInt(getParamTabExButtonStyle()); 482 return buildSelectButtonStyle(htmlAttributes, selectedIndex); 483 } 484 485 491 public String buildSelectExplorerFileEntries(String htmlAttributes) { 492 493 String [] opts = new String [] {"10", "25", "50", "100", key(Messages.GUI_LABEL_UNLIMITED_0)}; 494 List options = new ArrayList (java.util.Arrays.asList(opts)); 495 String [] vals = new String [] {"10", "25", "50", "100", "" + Integer.MAX_VALUE}; 496 int selectedIndex = 2; 497 for (int i = 0; i < vals.length; i++) { 498 if (vals[i].equals(getParamTabExFileEntries())) { 499 selectedIndex = i; 500 } 501 } 502 List values = new ArrayList (java.util.Arrays.asList(vals)); 503 return buildSelect(htmlAttributes, options, values, selectedIndex); 504 } 505 506 512 public String buildSelectFilter(String htmlAttributes) { 513 514 List options = new ArrayList (16); 515 List values = new ArrayList (16); 516 int selectedIndex = -1; 517 int counter = 0; 518 519 for (int i = 1; i < 4; i++) { 520 for (char k = 'a'; k < 'd'; k++) { 521 options.add(key( 522 Messages.getTaskKey(CmsTaskService.TASK_FILTER + k + i))); 523 values.add("" + k + i); 524 if (("" + k + i).equals(getParamTabWfFilter())) { 525 selectedIndex = counter; 526 } 527 counter++; 528 } 529 options.add(SPACER); 530 values.add(""); 531 counter++; 532 } 533 for (int i = 1; i < 4; i++) { 534 options.add(key(Messages.getTaskKey(CmsTaskService.TASK_FILTER + "d" + i))); 535 values.add("d" + i); 536 if (("d" + i).equals(getParamTabWfFilter())) { 537 selectedIndex = counter; 538 } 539 counter++; 540 } 541 return buildSelect(htmlAttributes, options, values, selectedIndex); 542 } 543 544 550 public String buildSelectLanguage(String htmlAttributes) { 551 552 List locales = OpenCms.getWorkplaceManager().getLocales(); 554 List options = new ArrayList (locales.size()); 555 List values = new ArrayList (locales.size()); 556 int checkedIndex = 0; 557 int counter = 0; 558 Iterator i = locales.iterator(); 559 Locale setLocale = getSettings().getUserSettings().getLocale(); 560 while (i.hasNext()) { 561 Locale currentLocale = (Locale )i.next(); 562 String language = currentLocale.getDisplayLanguage(setLocale); 564 if (CmsStringUtil.isNotEmpty(currentLocale.getCountry())) { 565 language = language + " (" + currentLocale.getDisplayCountry(setLocale) + ")"; 566 } 567 if (CmsStringUtil.isNotEmpty(currentLocale.getVariant())) { 568 language = language + " (" + currentLocale.getDisplayVariant(setLocale) + ")"; 569 } 570 options.add(language); 571 values.add(currentLocale.toString()); 572 if (getParamTabWpLanguage().equals(currentLocale.toString())) { 573 checkedIndex = counter; 575 } 576 counter++; 577 } 578 return buildSelect(htmlAttributes, options, values, checkedIndex); 579 } 580 581 587 public String buildSelectPreferredEditors(String htmlAttributes) { 588 589 StringBuffer result = new StringBuffer (1024); 590 HttpServletRequest request = getJsp().getRequest(); 591 if (htmlAttributes != null) { 592 htmlAttributes += " name=\"" + PARAM_PREFERREDEDITOR_PREFIX; 593 } 594 Map resourceEditors = OpenCms.getWorkplaceManager().getWorkplaceEditorManager().getConfigurableEditors(); 595 if (resourceEditors != null) { 596 Iterator i = resourceEditors.keySet().iterator(); 598 599 SortedMap rankResources = new TreeMap (); 600 while (i.hasNext()) { 601 String currentResourceType = (String )i.next(); 602 CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting( 603 currentResourceType); 604 rankResources.put(new Float (settings.getNewResourceOrder()), currentResourceType); 605 } 606 607 while (rankResources.size() > 0) { 608 Float keyVal = (Float )rankResources.firstKey(); 610 String currentResourceType = (String )rankResources.get(keyVal); 611 612 SortedMap availableEditors = (TreeMap )resourceEditors.get(currentResourceType); 613 if (availableEditors != null && availableEditors.size() > 0) { 614 String preSelection = computeEditorPreselection(request, currentResourceType); 615 List options = new ArrayList (availableEditors.size() + 1); 616 List values = new ArrayList (availableEditors.size() + 1); 617 options.add(key(Messages.GUI_PREF_EDITOR_BEST_0)); 618 values.add(INPUT_DEFAULT); 619 int selectedIndex = 0; 621 int counter = 1; 622 while (availableEditors.size() > 0) { 623 Float key = (Float )availableEditors.lastKey(); 624 CmsWorkplaceEditorConfiguration conf = (CmsWorkplaceEditorConfiguration)availableEditors.get(key); 625 options.add(keyDefault(conf.getEditorLabel(), conf.getEditorLabel())); 626 values.add(conf.getEditorUri()); 627 if (conf.getEditorUri().equals(preSelection)) { 628 selectedIndex = counter; 629 } 630 counter++; 631 availableEditors.remove(key); 632 } 633 634 result.append("<tr>\n\t<td style=\"white-space: nowrap;\">"); 636 String localizedName = CmsWorkplaceMessages.getResourceName(this, currentResourceType); 637 result.append(localizedName); 638 result.append("</td>\n\t<td>"); 639 result.append(buildSelect( 640 htmlAttributes + currentResourceType + "\"", 641 options, 642 values, 643 selectedIndex)); 644 result.append("</td>\n</tr>\n"); 645 } 646 rankResources.remove(keyVal); 647 } 648 } 649 return result.toString(); 650 } 651 652 658 public String buildSelectProject(String htmlAttributes) { 659 660 try { 661 List allProjects = getCms().getAllAccessibleProjects(); 662 List options = new ArrayList (allProjects.size()); 663 List values = new ArrayList (allProjects.size()); 664 int checkedIndex = 0; 665 String startProject = ""; 666 667 startProject = getParamTabWpProject(); 668 669 for (int i = 0, n = allProjects.size(); i < n; i++) { 670 CmsProject project = (CmsProject)allProjects.get(i); 671 options.add(project.getName()); 672 values.add(project.getName()); 674 if (startProject.equals(project.getName())) { 675 checkedIndex = i; 676 } 677 } 678 return buildSelect(htmlAttributes, options, values, checkedIndex); 679 } catch (CmsException e) { 680 LOG.error(e.getLocalizedMessage()); 682 return getSettings().getProject() + ""; 683 } 684 } 685 686 692 public String buildSelectPublishSiblings(String htmlAttributes) { 693 694 List options = new ArrayList (2); 695 options.add(key(Messages.GUI_PREF_PUBLISH_SIBLINGS_0)); 696 options.add(key(Messages.GUI_PREF_PUBLISH_ONLY_SELECTED_0)); 697 List values = new ArrayList (2); 698 values.add(CmsStringUtil.TRUE); 699 values.add(CmsStringUtil.FALSE); 700 int selectedIndex = values.indexOf(getParamTabDiPublishFileMode()); 701 return buildSelect(htmlAttributes, options, values, selectedIndex); 702 } 703 704 710 public String buildSelectReportType(String htmlAttributes) { 711 712 List options = new ArrayList (2); 713 options.add(key(Messages.GUI_LABEL_SIMPLE_0)); 714 options.add(key(Messages.GUI_LABEL_EXTENDED_0)); 715 String [] vals = new String [] {I_CmsReport.REPORT_TYPE_SIMPLE, I_CmsReport.REPORT_TYPE_EXTENDED}; 716 List values = new ArrayList (java.util.Arrays.asList(vals)); 717 int selectedIndex = 0; 718 if (I_CmsReport.REPORT_TYPE_EXTENDED.equals(getParamTabWpReportType())) { 719 selectedIndex = 1; 720 } 721 return buildSelect(htmlAttributes, options, values, selectedIndex); 722 } 723 724 730 public String buildSelectSite(String htmlAttributes) { 731 732 List options = new ArrayList (); 733 List values = new ArrayList (); 734 int selectedIndex = 0; 735 736 List sites = CmsSiteManager.getAvailableSites(getCms(), true); 737 738 Iterator i = sites.iterator(); 739 int pos = 0; 740 while (i.hasNext()) { 741 CmsSite site = (CmsSite)i.next(); 742 String siteRoot = site.getSiteRoot(); 743 if (!siteRoot.endsWith("/")) { 744 siteRoot += "/"; 745 } 746 values.add(siteRoot); 747 options.add(site.getTitle()); 748 if (siteRoot.equals(getParamTabWpSite())) { 749 selectedIndex = pos; 751 } 752 pos++; 753 } 754 755 return buildSelect(htmlAttributes, options, values, selectedIndex); 756 } 757 758 764 public String buildSelectView(String htmlAttributes) { 765 766 List options = new ArrayList (); 767 List values = new ArrayList (); 768 int selectedIndex = 0; 769 770 Iterator i = OpenCms.getWorkplaceManager().getViews().iterator(); 772 int count = -1; 773 while (i.hasNext()) { 774 count++; 775 CmsWorkplaceView view = (CmsWorkplaceView)i.next(); 776 777 boolean visible = true; 778 try { 779 getCms().readResource(view.getUri()); 780 } catch (CmsException e) { 781 if (LOG.isInfoEnabled()) { 783 LOG.info(e.getLocalizedMessage()); 784 } 785 visible = false; 786 } 787 if (visible) { 788 String localizedKey = resolveMacros(view.getKey()); 789 options.add(localizedKey); 790 values.add(view.getUri()); 791 792 if (view.getUri().equals(getParamTabWpView())) { 793 selectedIndex = count; 794 } 795 } 796 } 797 798 return buildSelect(htmlAttributes, options, values, selectedIndex); 799 } 800 801 807 public String buildSelectWorkplaceButtonStyle(String htmlAttributes) { 808 809 int selectedIndex = Integer.parseInt(getParamTabWpButtonStyle()); 810 return buildSelectButtonStyle(htmlAttributes, selectedIndex); 811 } 812 813 818 public String buildUserInformation() { 819 820 StringBuffer result = new StringBuffer (512); 821 CmsUser user = getSettings().getUser(); 822 823 result.append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">\n"); 824 result.append("<tr>\n"); 825 result.append("\t<td style=\"width: 25%;\">"); 826 result.append(key(Messages.GUI_LABEL_USER_0)); 827 result.append("</td>\n"); 828 result.append("\t<td class=\"textbold\" style=\"width: 25%;\">"); 829 result.append(user.getName()); 830 result.append("</td>\n"); 831 result.append("\t<td style=\"width: 25%;\">"); 832 result.append(key(Messages.GUI_LABEL_EMAIL_0)); 833 result.append("</td>\n"); 834 result.append("\t<td class=\"textbold\" style=\"width: 25%;\">"); 835 result.append(user.getEmail()); 836 result.append("</td>\n"); 837 result.append("</tr>\n"); 838 839 result.append("<tr>\n"); 840 result.append("\t<td>"); 841 result.append(key(Messages.GUI_LABEL_LASTNAME_0)); 842 result.append("</td>\n"); 843 result.append("\t<td class=\"textbold\">"); 844 result.append(user.getLastname()); 845 result.append("</td>\n"); 846 result.append("\t<td rowspan=\"3\" style=\"vertical-align: top;\">"); 847 result.append(key(Messages.GUI_INPUT_ADRESS_0)); 848 result.append("</td>\n"); 849 850 String address = user.getAddress(); 851 852 result.append("\t<td rowspan=\"3\" class=\"textbold\" style=\"vertical-align: top;\">"); 853 result.append(address); 854 result.append("</td>\n"); 855 result.append("</tr>\n"); 856 857 result.append("<tr>\n"); 858 result.append("\t<td>"); 859 result.append(key(Messages.GUI_LABEL_FIRSTNAME_0)); 860 result.append("</td>\n"); 861 result.append("\t<td class=\"textbold\">"); 862 result.append(user.getFirstname()); 863 result.append("</td>\n"); 864 result.append("</tr>\n"); 865 866 result.append("<tr>\n"); 867 result.append("\t<td>"); 868 result.append(key(Messages.GUI_LABEL_DESCRIPTION_0)); 869 result.append("</td>\n"); 870 result.append("\t<td class=\"textbold\">"); 871 result.append(user.getDescription()); 872 result.append("</td>\n"); 873 result.append("</tr>\n"); 874 result.append("</table>\n"); 875 876 return result.toString(); 877 } 878 879 884 public String getParamNewPassword() { 885 886 return m_paramNewPassword; 887 } 888 889 894 public String getParamOldPassword() { 895 896 return m_paramOldPassword; 897 } 898 899 904 public String getParamTabDiCopyFileMode() { 905 906 return "" + m_userSettings.getDialogCopyFileMode(); 907 } 908 909 914 public String getParamTabDiCopyFolderMode() { 915 916 return "" + m_userSettings.getDialogCopyFolderMode(); 917 } 918 919 924 public String getParamTabDiDeleteFileMode() { 925 926 return "" + m_userSettings.getDialogDeleteFileMode(); 927 } 928 929 934 public String getParamTabDiPermissionsExpandInherited() { 935 936 return isParamEnabled(m_userSettings.getDialogExpandInheritedPermissions()); 937 } 938 939 944 public String getParamTabDiPermissionsExpandUser() { 945 946 return isParamEnabled(m_userSettings.getDialogExpandUserPermissions()); 947 } 948 949 954 public String getParamTabDiPermissionsInheritOnFolder() { 955 956 return isParamEnabled(m_userSettings.getDialogPermissionsInheritOnFolder()); 957 } 958 959 964 public String getParamTabDiPublishFileMode() { 965 966 return "" + m_userSettings.getDialogPublishSiblings(); 967 } 968 969 974 public String getParamTabDiShowLock() { 975 976 return isParamEnabled(m_userSettings.getDialogShowLock()); 977 } 978 979 984 public String getParamTabEdButtonStyle() { 985 986 return "" + m_userSettings.getEditorButtonStyle(); 987 } 988 989 994 public String getParamTabEdDirectEditButtonStyle() { 995 996 return "" + m_userSettings.getDirectEditButtonStyle(); 997 } 998 999 1004 public String getParamTabExButtonStyle() { 1005 1006 return "" + m_userSettings.getExplorerButtonStyle(); 1007 } 1008 1009 1014 public String getParamTabExFileDateCreated() { 1015 1016 return isParamEnabled(m_userSettings.showExplorerFileDateCreated()); 1017 } 1018 1019 1024 public String getParamTabExFileDateExpired() { 1025 1026 return isParamEnabled(m_userSettings.showExplorerFileDateExpired()); 1027 } 1028 1029 1034 public String getParamTabExFileDateLastModified() { 1035 1036 return isParamEnabled(m_userSettings.showExplorerFileDateLastModified()); 1037 } 1038 1039 1044 public String getParamTabExFileDateReleased() { 1045 1046 return isParamEnabled(m_userSettings.showExplorerFileDateReleased()); 1047 } 1048 1049 1054 public String getParamTabExFileEntries() { 1055 1056 return "" + m_userSettings.getExplorerFileEntries(); 1057 } 1058 1059 1064 public String getParamTabExFileLockedBy() { 1065 1066 return isParamEnabled(m_userSettings.showExplorerFileLockedBy()); 1067 } 1068 1069 1074 public String getParamTabExFilePermissions() { 1075 1076 return isParamEnabled(m_userSettings.showExplorerFilePermissions()); 1077 } 1078 1079 1084 public String getParamTabExFileSize() { 1085 1086 return isParamEnabled(m_userSettings.showExplorerFileSize()); 1087 } 1088 1089 1094 public String getParamTabExFileState() { 1095 1096 return isParamEnabled(m_userSettings.showExplorerFileState()); 1097 } 1098 1099 1104 public String getParamTabExFileTitle() { 1105 1106 return isParamEnabled(m_userSettings.showExplorerFileTitle()); 1107 } 1108 1109 1114 public String getParamTabExFileType() { 1115 1116 return isParamEnabled(m_userSettings.showExplorerFileType()); 1117 } 1118 1119 1124 public String getParamTabExFileUserCreated() { 1125 1126 return isParamEnabled(m_userSettings.showExplorerFileUserCreated()); 1127 } 1128 1129 1134 public String getParamTabExFileUserLastModified() { 1135 1136 return isParamEnabled(m_userSettings.showExplorerFileUserLastModified()); 1137 } 1138 1139 1144 public String getParamTabWfFilter() { 1145 1146 return m_userSettings.getTaskStartupFilter(); 1147 } 1148 1149 1154 public String getParamTabWfMessageAccepted() { 1155 1156 return isParamEnabled(m_userSettings.getTaskMessageAccepted()); 1157 } 1158 1159 1164 public String getParamTabWfMessageCompleted() { 1165 1166 return isParamEnabled(m_userSettings.getTaskMessageCompleted()); 1167 } 1168 1169 1174 public String getParamTabWfMessageForwarded() { 1175 1176 return isParamEnabled(m_userSettings.getTaskMessageForwarded()); 1177 } 1178 1179 1184 public String getParamTabWfMessageMembers() { 1185 1186 return isParamEnabled(m_userSettings.getTaskMessageMembers()); 1187 } 1188 1189 1194 public String getParamTabWfShowAllProjects() { 1195 1196 return isParamEnabled(m_userSettings.getTaskShowAllProjects()); 1197 } 1198 1199 1204 public String getParamTabWpButtonStyle() { 1205 1206 return "" + m_userSettings.getWorkplaceButtonStyle(); 1207 } 1208 1209 1214 public String getParamTabWpFolder() { 1215 1216 return m_userSettings.getStartFolder(); 1217 } 1218 1219 1224 public String getParamTabWpLanguage() { 1225 1226 return m_userSettings.getLocale().toString(); 1227 } 1228 1229 1234 public String getParamTabWpProject() { 1235 1236 return m_userSettings.getStartProject(); 1237 } 1238 1239 1244 public String getParamTabWpReportType() { 1245 1246 return m_userSettings.getWorkplaceReportType(); 1247 } 1248 1249 1254 public String getParamTabWpRestrictExplorerView() { 1255 1256 return "" + m_userSettings.getRestrictExplorerView(); 1257 } 1258 1259 1264 public String getParamTabWpSite() { 1265 1266 return m_userSettings.getStartSite(); 1267 } 1268 1269 1274 public String getParamTabWpUseUploadApplet() { 1275 1276 return isParamEnabled(m_userSettings.useUploadApplet()); 1277 } 1278 1279 1284 public String getParamTabWpView() { 1285 1286 return m_userSettings.getStartView(); 1287 } 1288 1289 1292 public List getTabParameterOrder() { 1293 1294 ArrayList orderList = new ArrayList (5); 1295 orderList.add("tabwp"); 1296 orderList.add("tabex"); 1297 orderList.add("tabdi"); 1298 orderList.add("tabed"); 1299 orderList.add("tabwf"); 1300 orderList.add("tabup"); 1301 return orderList; 1302 } 1303 1304 1307 public List getTabs() { 1308 1309 ArrayList tabList = new ArrayList (6); 1310 tabList.add(key(Messages.GUI_PREF_PANEL_WORKPLACE_0)); 1311 tabList.add(key(Messages.GUI_PREF_PANEL_EXPLORER_0)); 1312 tabList.add(key(Messages.GUI_PREF_PANEL_DIALOGS_0)); 1313 tabList.add(key(Messages.GUI_PREF_PANEL_EDITORS_0)); 1314 tabList.add(key(Messages.GUI_PREF_PANEL_TASK_0)); 1315 tabList.add(key(Messages.GUI_PREF_PANEL_USER_0)); 1316 return tabList; 1317 } 1318 1319 1325 public String isChecked(String paramValue) { 1326 1327 if (Boolean.valueOf(paramValue).booleanValue()) { 1328 return " checked=\"checked\""; 1329 } 1330 return ""; 1331 } 1332 1333 1338 public void setParamNewPassword(String newPwd) { 1339 1340 m_paramNewPassword = newPwd; 1341 } 1342 1343 1348 public void setParamOldPassword(String oldPwd) { 1349 1350 m_paramOldPassword = oldPwd; 1351 } 1352 1353 1358 public void setParamTabDiCopyFileMode(String value) { 1359 1360 try { 1361 m_userSettings.setDialogCopyFileMode(Integer.parseInt(value)); 1362 } catch (Throwable t) { 1363 } 1365 } 1366 1367 1372 public void setParamTabDiCopyFolderMode(String value) { 1373 1374 try { 1375 m_userSettings.setDialogCopyFolderMode(Integer.parseInt(value)); 1376 } catch (Throwable t) { 1377 } 1379 } 1380 1381 1386 public void setParamTabDiDeleteFileMode(String value) { 1387 1388 try { 1389 m_userSettings.setDialogDeleteFileMode(Integer.parseInt(value)); 1390 } catch (Throwable t) { 1391 } 1393 } 1394 1395 1400 public void setParamTabDiPermissionsExpandInherited(String value) { 1401 1402 m_userSettings.setDialogExpandInheritedPermissions(Boolean.valueOf(value).booleanValue()); 1403 } 1404 1405 1410 public void setParamTabDiPermissionsExpandUser(String value) { 1411 1412 m_userSettings.setDialogExpandUserPermissions(Boolean.valueOf(value).booleanValue()); 1413 } 1414 1415 1420 public void setParamTabDiPermissionsInheritOnFolder(String value) { 1421 1422 m_userSettings.setDialogPermissionsInheritOnFolder(Boolean.valueOf(value).booleanValue()); 1423 } 1424 1425 1430 public void setParamTabDiPublishFileMode(String value) { 1431 1432 m_userSettings.setDialogPublishSiblings(Boolean.valueOf(value).booleanValue()); 1433 } 1434 1435 1440 public void setParamTabDiShowLock(String value) { 1441 1442 m_userSettings.setDialogShowLock(Boolean.valueOf(value).booleanValue()); 1443 } 1444 1445 1450 public void setParamTabEdButtonStyle(String value) { 1451 1452 try { 1453 m_userSettings.setEditorButtonStyle(Integer.parseInt(value)); 1454 } catch (Throwable t) { 1455 } 1457 } 1458 1459 1464 public void setParamTabEdDirectEditButtonStyle(String value) { 1465 1466 try { 1467 m_userSettings.setDirectEditButtonStyle(Integer.parseInt(value)); 1468 } catch (Throwable t) { 1469 } 1471 } 1472 1473 1478 public void setParamTabExButtonStyle(String value) { 1479 1480 try { 1481 m_userSettings.setExplorerButtonStyle(Integer.parseInt(value)); 1482 } catch (Throwable t) { 1483 } 1485 } 1486 1487 1492 public void setParamTabExFileDateCreated(String value) { 1493 1494 m_userSettings.setShowExplorerFileDateCreated(Boolean.valueOf(value).booleanValue()); 1495 } 1496 1497 1502 public void setParamTabExFileDateExpired(String value) { 1503 1504 m_userSettings.setShowExplorerFileDateExpired(Boolean.valueOf(value).booleanValue()); 1505 } 1506 1507 1512 public void setParamTabExFileDateLastModified(String value) { 1513 1514 m_userSettings.setShowExplorerFileDateLastModified(Boolean.valueOf(value).booleanValue()); 1515 } 1516 1517 1522 public void setParamTabExFileDateReleased(String value) { 1523 1524 m_userSettings.setShowExplorerFileDateReleased(Boolean.valueOf(value).booleanValue()); 1525 } 1526 1527 1532 public void setParamTabExFileEntries(String value) { 1533 1534 try { 1535 m_userSettings.setExplorerFileEntries(Integer.parseInt(value)); 1536 } catch (Throwable t) { 1537 } 1539 } 1540 1541 1546 public void setParamTabExFileLockedBy(String value) { 1547 1548 m_userSettings.setShowExplorerFileLockedBy(Boolean.valueOf(value).booleanValue()); 1549 } 1550 1551 1556 public void setParamTabExFilePermissions(String value) { 1557 1558 m_userSettings.setShowExplorerFilePermissions(Boolean.valueOf(value).booleanValue()); 1559 } 1560 1561 1566 public void setParamTabExFileSize(String value) { 1567 1568 m_userSettings.setShowExplorerFileSize(Boolean.valueOf(value).booleanValue()); 1569 } 1570 1571 1576 public void setParamTabExFileState(String value) { 1577 1578 m_userSettings.setShowExplorerFileState(Boolean.valueOf(value).booleanValue()); 1579 } 1580 1581 1586 public void setParamTabExFileTitle(String value) { 1587 1588 m_userSettings.setShowExplorerFileTitle(Boolean.valueOf(value).booleanValue()); 1589 } 1590 1591 1596 public void setParamTabExFileType(String value) { 1597 1598 m_userSettings.setShowExplorerFileType(Boolean.valueOf(value).booleanValue()); 1599 } 1600 1601 1606 public void setParamTabExFileUserCreated(String value) { 1607 1608 m_userSettings.setShowExplorerFileUserCreated(Boolean.valueOf(value).booleanValue()); 1609 } 1610 1611 1616 public void setParamTabExFileUserLastModified(String value) { 1617 1618 m_userSettings.setShowExplorerFileUserLastModified(Boolean.valueOf(value).booleanValue()); 1619 } 1620 1621 1626 public void setParamTabWfFilter(String filter) { 1627 1628 if ("".equals(filter)) { 1629 filter = "a1"; 1630 } 1631 m_userSettings.setTaskStartupFilter(filter); 1632 } 1633 1634 1639 public void setParamTabWfMessageAccepted(String value) { 1640 1641 m_userSettings.setTaskMessageAccepted(Boolean.valueOf(value).booleanValue()); 1642 } 1643 1644 1649 public void setParamTabWfMessageCompleted(String value) { 1650 1651 m_userSettings.setTaskMessageCompleted(Boolean.valueOf(value).booleanValue()); 1652 } 1653 1654 1659 public void setParamTabWfMessageForwarded(String value) { 1660 1661 m_userSettings.setTaskMessageForwarded(Boolean.valueOf(value).booleanValue()); 1662 } 1663 1664 1669 public void setParamTabWfMessageMembers(String value) { 1670 1671 m_userSettings.setTaskMessageMembers(Boolean.valueOf(value).booleanValue()); 1672 } 1673 1674 1679 public void setParamTabWfShowAllProjects(String value) { 1680 1681 m_userSettings.setTaskShowAllProjects(Boolean.valueOf(value).booleanValue()); 1682 } 1683 1684 1689 public void setParamTabWpButtonStyle(String value) { 1690 1691 try { 1692 m_userSettings.setWorkplaceButtonStyle(Integer.parseInt(value)); 1693 } catch (Throwable t) { 1694 } 1696 } 1697 1698 1703 public void setParamTabWpFolder(String value) { 1704 1705 m_userSettings.setStartFolder(value); 1706 } 1707 1708 1713 public void setParamTabWpLanguage(String value) { 1714 1715 m_userSettings.setLocale(CmsLocaleManager.getLocale(value)); 1716 } 1717 1718 1723 public void setParamTabWpProject(String value) { 1724 1725 m_userSettings.setStartProject(value); 1726 } 1727 1728 1733 public void setParamTabWpReportType(String value) { 1734 1735 if (I_CmsReport.REPORT_TYPE_SIMPLE.equals(value) || I_CmsReport.REPORT_TYPE_EXTENDED.equals(value)) { 1736 m_userSettings.setWorkplaceReportType(value); 1738 } 1739 } 1740 1741 1746 public void setParamTabWpRestrictExplorerView(String value) { 1747 1748 m_userSettings.setRestrictExplorerView(Boolean.valueOf(value).booleanValue()); 1749 } 1750 1751 1756 public void setParamTabWpSite(String value) { 1757 1758 m_userSettings.setStartSite(value); 1759 } 1760 1761 1766 public void setParamTabWpUseUploadApplet(String value) { 1767 1768 m_userSettings.setUseUploadApplet(Boolean.valueOf(value).booleanValue()); 1769 } 1770 1771 1776 public void setParamTabWpView(String value) { 1777 1778 m_userSettings.setStartView(value); 1779 } 1780 1781 1784 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 1785 1786 m_userSettings = new CmsUserSettings(); 1788 fillParamValues(request); 1790 1791 getActiveTab(); 1793 1794 setParamDialogtype(DIALOG_TYPE); 1796 if (DIALOG_SET.equals(getParamAction())) { 1798 setAction(ACTION_SET); 1799 } else if (DIALOG_OK.equals(getParamAction())) { 1800 setAction(ACTION_OK); 1801 } else if (DIALOG_RELOAD.equals(getParamAction())) { 1802 setAction(ACTION_RELOAD); 1803 } else if (DIALOG_CANCEL.equals(getParamAction())) { 1804 setAction(ACTION_CANCEL); 1805 } else if (DIALOG_CHPWD.equals(getParamAction())) { 1806 setAction(ACTION_CHPWD); 1807 } else { 1808 if (!DIALOG_SWITCHTAB.equals(getParamAction())) { 1809 fillUserSettings(); 1811 } 1812 1813 setAction(ACTION_DEFAULT); 1814 setParamTitle(key(Messages.GUI_PREF_0)); 1816 } 1817 1818 } 1819 1820 1827 protected Map paramValues() { 1828 1829 Map map = super.paramValues(); 1830 HttpServletRequest request = getJsp().getRequest(); 1831 Enumeration en = request.getParameterNames(); 1832 while (en.hasMoreElements()) { 1833 String paramName = (String )en.nextElement(); 1834 if (paramName.startsWith(PARAM_PREFERREDEDITOR_PREFIX)) { 1835 String paramValue = request.getParameter(paramName); 1836 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(paramValue)) { 1837 map.put(paramName, CmsEncoder.decode(paramValue)); 1838 } 1839 } 1840 } 1841 return map; 1842 } 1843 1844 1850 protected void updatePreferences(CmsObject cms, HttpServletRequest req) { 1851 1852 HttpSession session = req.getSession(false); 1853 if (session == null) { 1854 return; 1855 } 1856 CmsWorkplaceSettings settings = (CmsWorkplaceSettings)session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS); 1857 if (settings == null) { 1858 return; 1859 } 1860 CmsSynchronizeSettings synchronizeSettings = settings.getUserSettings().getSynchronizeSettings(); 1862 settings = CmsWorkplace.initWorkplaceSettings(cms, settings, true); 1863 settings.getUserSettings().setSynchronizeSettings(synchronizeSettings); 1864 } 1865 1866 1873 private String buildSelectButtonStyle(String htmlAttributes, int selectedIndex) { 1874 1875 List options = new ArrayList (3); 1876 options.add(key(Messages.GUI_PREF_BUTTONSTYLE_IMG_0)); 1877 options.add(key(Messages.GUI_PREF_BUTTONSTYLE_IMGTXT_0)); 1878 options.add(key(Messages.GUI_PREF_BUTTONSTYLE_TXT_0)); 1879 String [] vals = new String [] {"0", "1", "2"}; 1880 List values = new ArrayList (java.util.Arrays.asList(vals)); 1881 return buildSelect(htmlAttributes, options, values, selectedIndex); 1882 } 1883 1884 1891 private String computeEditorPreselection(HttpServletRequest request, String resourceType) { 1892 1893 String preSelection = request.getParameter(PARAM_PREFERREDEDITOR_PREFIX + resourceType); 1895 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(preSelection)) { 1896 return CmsEncoder.decode(preSelection); 1897 } else { 1898 CmsUserSettings userSettings = new CmsUserSettings(getCms(), getSettings().getUser()); 1900 return userSettings.getPreferredEditor(resourceType); 1901 1902 } 1903 } 1904 1905 1910 private void fillUserSettings() { 1911 1912 m_userSettings = new CmsUserSettings(getCms(), getSettings().getUser()); 1913 } 1914 1915 1921 private String isParamEnabled(boolean isEnabled) { 1922 1923 if (isEnabled) { 1924 return CmsStringUtil.TRUE; 1925 } 1926 return ""; 1927 } 1928} | Popular Tags |