Produced by Araxis Merge on Fri Oct 19 14:26:01 2007 UTC. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Internet Explorer. For optimum results when printing this report, enable printing of background images and colours in your browser and use landscape orientation.
| # | File | Location | Last Modified |
|---|---|---|---|
| 1 | process_post.inc | C:\jahia\template_diff\V2_JAHIA_5_0_2\src\jsp\form_generator | Fri Oct 19 14:17:32 2007 UTC |
| 2 | process_post.inc | C:\jahia\template_diff\V2_JAHIA_5_0_3\src\jsp\form_generator | Fri Oct 19 14:16:51 2007 UTC |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Blocks | Lines | |
| Unchanged | 8 | 174 |
| Changed | 1 | 2 |
| Inserted | 4 | 10 |
| Removed | 2 | 5 |
| Whitespace | All differences in whitespace within lines are ignored |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Hidden in comparison detail |
No regular expressions were active.
| 1 | <%-- | 1 | <%-- | |||
| 2 | Copyright 2002-2006 Jahia Ltd | 2 | Copyright 2002-2006 Jahia Ltd | |||
| 3 | 3 | |||||
| 4 | Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (JCDDL), | 4 | Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (JCDDL), | |||
| 5 | Version 1.0 (the "License"), or (at your option) any later version; you may | 5 | Version 1.0 (the "License"), or (at your option) any later version; you may | |||
| 6 | not use this file except in compliance with the License. You should have | 6 | not use this file except in compliance with the License. You should have | |||
| 7 | received a copy of the License along with this program; if not, you may obtain | 7 | received a copy of the License along with this program; if not, you may obtain | |||
| 8 | a copy of the License at | 8 | a copy of the License at | |||
| 9 | 9 | |||||
| 10 | http://www.jahia.org/license/ | 10 | http://www.jahia.org/license/ | |||
| 11 | 11 | |||||
| 12 | Unless required by applicable law or agreed to in writing, software | 12 | Unless required by applicable law or agreed to in writing, software | |||
| 13 | distributed under the License is distributed on an "AS IS" BASIS, | 13 | distributed under the License is distributed on an "AS IS" BASIS, | |||
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| 15 | See the License for the specific language governing permissions and | 15 | See the License for the specific language governing permissions and | |||
| 16 | limitations under the License. | 16 | limitations under the License. | |||
| 17 | --%><% | 17 | --%><% | |||
| 18 | final String formIdStr; | 18 | final String formIdStr; | |||
| 19 | final org.jahia.tools.files.FileUpload fupload; | 19 | final org.jahia.tools.files.FileUpload fupload; | |||
| 20 | if (ProcessingContext.isMultipartRequest(request)) { | 20 | if (ProcessingContext.isMultipartRequest(request)) { | |||
| 21 | fupload = jData.params().getFileUpload(); | 21 | fupload = jData.params().getFileUpload(); | |||
| 22 | formIdStr = fupload.getParameterValues("formId")[0]; | 22 | formIdStr = fupload.getParameterValues("formId")[0]; | |||
| 23 | } else { | 23 | } else { | |||
| 24 | formIdStr = request.getParameter("formId"); | 24 | formIdStr = request.getParameter("formId"); | |||
| 25 | fupload = null; | 25 | fupload = null; | |||
| 26 | } | 26 | } | |||
| 27 | 27 | |||||
| 28 | boolean forHasBeenPosted = false; | 28 | boolean forHasBeenPosted = false; | |||
| 29 | String displayTextAfterPostValue = ""; | 29 | String displayTextAfterPostValue = ""; | |||
| 30 | if (formIdStr != null) { | 30 | if (formIdStr != null) { | |||
| 31 | logger.debug("Form has been posted"); | 31 | logger.debug("Form has been posted"); | |||
| 32 | forHasBeenPosted = true; | 32 | forHasBeenPosted = true; | |||
| 33 | } | 33 | } | |||
| 34 | JahiaContainerList forms = jData.containers().getContainerList( "forms" ); | 34 | JahiaContainerList forms = jData.containers().getContainerList( "forms" ); | |||
| 35 | Enumeration formsEnum = forms.getContainers(); | 35 | Enumeration formsEnum = forms.getContainers(); | |||
| 36 | if (formsEnum.hasMoreElements()) { | 36 | if (formsEnum.hasMoreElements()) { | |||
| 37 | JahiaContainer form = (JahiaContainer) formsEnum.nextElement(); | 37 | JahiaContainer form = (JahiaContainer) formsEnum.nextElement(); | |||
| 38 | String sender = form.getFieldValue("sender","Please insert a sender"); | 38 | String sender = form.getFieldValue("sender","Please insert a sender"); | |||
| 39 | String recipients = form.getFieldValue("recipients","Please insert a sender"); | 39 | String recipients = form.getFieldValue("recipients","Please insert a sender"); | |||
| 40 | String recipientsCC = form.getFieldValue("recipientsCC",""); | 40 | String recipientsCC = form.getFieldValue("recipientsCC",""); | |||
| 41 | String subject = form.getFieldValue("subject",""); | 41 | String subject = form.getFieldValue("subject",""); | |||
| 42 | storePostedValues = "true".equals(form.getFieldValue("storePostedValues","false")); | 42 | storePostedValues = "true".equals(form.getFieldValue("storePostedValues","false")); | |||
| 43 | boolean sendMail = "true".equals(form.getFieldValue("sendMail","false")); | 43 | boolean sendMail = "true".equals(form.getFieldValue("sendMail","false")); | |||
| 44 | boolean showPostedValues = "true".equals(form.getFieldValue("showPostedValues","false")); | 44 | boolean showPostedValues = "true".equals(form.getFieldValue("showPostedValues","false")); | |||
| 45 | String alertText = form.getFieldValue("alertText",""); | 45 | String alertText = form.getFieldValue("alertText",""); | |||
| 46 | displayTextAfterPostValue = form.getFieldValue("displayTextAfterPost", | 46 | displayTextAfterPostValue = form.getFieldValue("displayTextAfterPost", | |||
| 47 | getResourceBundle("form.displayTextAfterPostValue", | 47 | getResourceBundle("form.displayTextAfterPostValue", | |||
| 48 | "Thank you. Your form has been sent.",jData)); | 48 | "Thank you. Your form has been sent.",jData)); | |||
| 49 | 49 | |||||
| 50 | logger.debug("new form -----------------------------"); | 50 | logger.debug("new form -----------------------------"); | |||
| 51 | logger.debug("sender: " + sender); | 51 | logger.debug("sender: " + sender); | |||
| 52 | logger.debug("recipients: " + recipients); | 52 | logger.debug("recipients: " + recipients); | |||
| 53 | logger.debug("recipientsCC: " + recipientsCC); | 53 | logger.debug("recipientsCC: " + recipientsCC); | |||
| 54 | logger.debug("subject: " + subject); | 54 | logger.debug("subject: " + subject); | |||
| 55 | logger.debug("displayTextAfterPostValue: " + displayTextAfterPostValue); | 55 | logger.debug("displayTextAfterPostValue: " + displayTextAfterPostValue); | |||
| 56 | logger.debug("storePostedValues: " + storePostedValues); | 56 | logger.debug("storePostedValues: " + storePostedValues); | |||
| 57 | logger.debug("sendMail: " + sendMail); | 57 | logger.debug("sendMail: " + sendMail); | |||
| 58 | 58 | |||||
| 59 | StringBuffer mailBody = new StringBuffer(); | 59 | StringBuffer mailBody = new StringBuffer(); | |||
| 60 | // get all values posted | 60 | // get all values posted | |||
| 61 | JahiaContainerList fields = form.getContainerList( "fields" ); | 61 | JahiaContainerList fields = form.getContainerList( "fields" ); | |||
| 62 | String id = String.valueOf(System.currentTimeMillis()); | 62 | String id = String.valueOf(System.currentTimeMillis()); | |||
| 63 | if (fields != null) { | 63 | if (fields != null) { | |||
| 64 | Vector filesContainerFields = new Vector(); | 64 | Vector filesContainerFields = new Vector(); | |||
| 65 | Enumeration fieldsEnum = fields.getContainers(); | 65 | Enumeration fieldsEnum = fields.getContainers(); | |||
| 66 | while (fieldsEnum.hasMoreElements()) { | 66 | while (fieldsEnum.hasMoreElements()) { | |||
| 67 | JahiaContainer currentField = (JahiaContainer) fieldsEnum.nextElement(); | 67 | JahiaContainer currentField = (JahiaContainer) fieldsEnum.nextElement(); | |||
| 68 | String type = currentField.getFieldValue("type",""); | 68 | String type = currentField.getFieldValue("type",""); | |||
| 69 | 69 | |||||
| 70 | String path = null; | 70 | String path = null; | |||
| 71 | String storePath = null ; | |||||
| 71 | final boolean isFileUploadType = ResourceBundleMarker.drawMarker(resBundleID,"fileUpload","").equals(type); | 72 | final boolean isFileUploadType = ResourceBundleMarker.drawMarker(resBundleID,"fileUpload","").equals(type); | |||
| 72 | if (isFileUploadType) { | 73 | if (isFileUploadType) { | |||
| 73 | final org.jahia.engines.filemanager.DAVFilemanager_Engine davEngine = org.jahia.engines.filemanager.DAVFilemanager_Engine.getInstance(); | 74 | final org.jahia.engines.filemanager.DAVFilemanager_Engine davEngine = org.jahia.engines.filemanager.DAVFilemanager_Engine.getInstance(); | |||
| 74 | final String uploadPath = currentField.getFieldValue("defaultValue",""); | 75 | final String uploadPath = currentField.getFieldValue("defaultValue",""); | |||
| 76 | if (uploadPath.equals("")) { | |||||
| 77 | // uses a default path if none specified (generated folder) | |||||
| 78 | // this will be displayed next to the file field when in edit mode | |||||
| 79 | path = davEngine.uploadAndRenameAutomatically("/shared/forms/missing_path", jData.params(), "field_" + currentField.getID()) ; | |||||
| 80 | } else { | |||||
| 75 | path = davEngine.uploadAndRenameAutomatically(uploadPath, jData.params(), "field_" + currentField.getID()); | 81 | path = davEngine.uploadAndRenameAutomatically(uploadPath, jData.params(), "field_" + currentField.getID()); | |||
| 76 | } | 82 | } | |||
| 83 | DAVFileAccess dfa = new DAVFileAccess(jParams, jParams.getSite(), jParams.getUser(), path); | |||||
| 84 | storePath = dfa.getFullPath(jParams) ; | |||||
| 85 | } | |||||
| 77 | 86 | |||||
| 78 | if (! ResourceBundleMarker.drawMarker(resBundleID,"submitButton","").equals(type)) { | 87 | if (! ResourceBundleMarker.drawMarker(resBundleID,"submitButton","").equals(type)) { | |||
| 79 | String fieldTitle = currentField.getFieldValue("fieldTitle",""); | 88 | String fieldTitle = currentField.getFieldValue("fieldTitle",""); | |||
| 80 | String isMandatoryStr = currentField.getFieldValue("isMandatory","false"); | 89 | String isMandatoryStr = currentField.getFieldValue("isMandatory","false"); | |||
| 81 | boolean isMandatory = "true".equals(isMandatoryStr); | 90 | boolean isMandatory = "true".equals(isMandatoryStr); | |||
| 82 | final String[] postedValues; | 91 | final String[] postedValues; | |||
| 83 | if (isFileUploadType) { | 92 | if (isFileUploadType) { | |||
| 84 | postedValues = new String[] {(path == null ? "" : path)}; | 93 | postedValues = new String[] {(path == null ? "" : storePath)}; | |||
| 85 | } else { | 94 | } else { | |||
| 86 | if (fupload == null) { | 95 | if (fupload == null) { | |||
| 87 | postedValues = request.getParameterValues("field_" + currentField.getID()); | 96 | postedValues = request.getParameterValues("field_" + currentField.getID()); | |||
| 88 | } else { | 97 | } else { | |||
| 89 | postedValues = fupload.getParameterValues("field_" + currentField.getID()); | 98 | postedValues = fupload.getParameterValues("field_" + currentField.getID()); | |||
| 90 | } | 99 | } | |||
| 91 | } | 100 | } | |||
| 92 | StringBuffer postedValuesSB = new StringBuffer(""); | 101 | StringBuffer postedValuesSB = new StringBuffer(""); | |||
| 93 | if (postedValues != null) { | 102 | if (postedValues != null) { | |||
| 94 | for (int i = 0; i < postedValues.length; i++){ | 103 | for (int i = 0; i < postedValues.length; i++){ | |||
| 95 | if (i > 0){ | 104 | if (i > 0){ | |||
| 96 | postedValuesSB.append(" - "); | 105 | postedValuesSB.append(" - "); | |||
| 97 | } | 106 | } | |||
| 98 | postedValuesSB.append(postedValues[i]); | 107 | postedValuesSB.append(postedValues[i]); | |||
| 99 | } | 108 | } | |||
| 100 | } | 109 | } | |||
| 101 | logger.debug("-- " + fieldTitle + ": " + postedValuesSB.toString()); | 110 | logger.debug("-- " + fieldTitle + ": " + postedValuesSB.toString()); | |||
| 102 | if (isFileUploadType) { | |||||
| 103 | mailBody.append(fieldTitle).append(" : ").append(request.getScheme()).append("://").append(request.getServerName()). | |||||
| 104 | append(":").append(request.getServerPort()).append(postedValuesSB.toString()).append("\n"); | |||||
| 105 | } else { | |||||
| 106 | mailBody.append(fieldTitle).append(" : ").append(postedValuesSB.toString()).append("\n"); | 111 | mailBody.append(fieldTitle).append(" : ").append(postedValuesSB.toString()).append("\n"); | |||
| 107 | } | |||||
| 108 | if (isMandatory && "".equals(postedValuesSB.toString())) { | 112 | if (isMandatory && "".equals(postedValuesSB.toString())) { | |||
| 109 | logger.debug("Field [" + fieldTitle + "] is mandatory"); | 113 | logger.debug("Field [" + fieldTitle + "] is mandatory"); | |||
| 110 | emptyMandatoryFields.add(new Integer(currentField.getID())); | 114 | emptyMandatoryFields.add(new Integer(currentField.getID())); | |||
| 111 | } | 115 | } | |||
| 112 | if (storePostedValues) { | 116 | if (storePostedValues) { | |||
| 113 | JahiaContainerList storePostedForm; | 117 | JahiaContainerList storePostedForm; | |||
| 114 | if (isFileUploadType) { | 118 | if (isFileUploadType) { | |||
| 115 | storePostedForm = currentField.getContainerList("fileValues"); | 119 | storePostedForm = currentField.getContainerList("fileValues"); | |||
| 116 | } else { | 120 | } else { | |||
| 117 | storePostedForm = currentField.getContainerList("textValues"); | 121 | storePostedForm = currentField.getContainerList("textValues"); | |||
| 118 | } | 122 | } | |||
| 119 | if ( storePostedForm !=null && storePostedForm.getID()==0 ) { | 123 | if ( storePostedForm !=null && storePostedForm.getID()==0 ) { | |||
| 120 | logger.debug("storePostedForm !=null && storePostedForm.getID()==0"); | 124 | logger.debug("storePostedForm !=null && storePostedForm.getID()==0"); | |||
| 121 | ContainerListBean storePostedFormBean = new ContainerListBean(storePostedForm,jParams); | 125 | ContainerListBean storePostedFormBean = new ContainerListBean(storePostedForm,jParams); | |||
| 122 | ServicesRegistry.getInstance().getJahiaContainersService(). | 126 | ServicesRegistry.getInstance().getJahiaContainersService(). | |||
| 123 | saveContainerListInfo(storePostedForm, jParams.getContentPage().getAclID(), jParams); | 127 | saveContainerListInfo(storePostedForm, jParams.getContentPage().getAclID(), jParams); | |||
| 124 | storePostedForm = storePostedFormBean.getJahiaContainerList(); | 128 | storePostedForm = storePostedFormBean.getJahiaContainerList(); | |||
| 125 | } | 129 | } | |||
| 126 | ContainerListBean storePostedFormBean = new ContainerListBean(storePostedForm,jParams); | 130 | ContainerListBean storePostedFormBean = new ContainerListBean(storePostedForm,jParams); | |||
| 127 | pageContext.setAttribute("storePostedFormBean",storePostedFormBean); | 131 | pageContext.setAttribute("storePostedFormBean",storePostedFormBean); | |||
| 128 | 132 | |||||
| 129 | if (forHasBeenPosted && emptyMandatoryFields.isEmpty()) { | 133 | if (forHasBeenPosted && emptyMandatoryFields.isEmpty()) { | |||
| 130 | Map map = new HashMap(); | 134 | Map map = new HashMap(); | |||
| 131 | final Map oldMap; | 135 | final Map oldMap; | |||
| 132 | if (fupload == null) { | 136 | if (fupload == null) { | |||
| 133 | oldMap = jData.getProcessingContext().getParameterMap(); | 137 | oldMap = jData.getProcessingContext().getParameterMap(); | |||
| 134 | } else { | 138 | } else { | |||
| 135 | oldMap = fupload.getParameterMap(); | 139 | oldMap = fupload.getParameterMap(); | |||
| 136 | } | 140 | } | |||
| 137 | 141 | |||||
| 138 | if (isFileUploadType) { | 142 | if (isFileUploadType) { | |||
| 139 | map.put("fileValue", new String[] {(path == null ? "" : path)}); | 143 | map.put("fileValue", new String[] {(path == null ? "" : path)}); | |||
| 140 | } else { | 144 | } else { | |||
| 141 | if (fupload == null) { | 145 | if (fupload == null) { | |||
| 142 | map.put("textValue",request.getParameterValues("field_" + currentField.getID())); | 146 | map.put("textValue",request.getParameterValues("field_" + currentField.getID())); | |||
| 143 | } else { | 147 | } else { | |||
| 144 | map.put("textValue",fupload.getParameterValues("field_" + currentField.getID())); | 148 | map.put("textValue",fupload.getParameterValues("field_" + currentField.getID())); | |||
| 145 | } | 149 | } | |||
| 146 | } | 150 | } | |||
| 147 | map.put("id",new String[] {id}); | 151 | map.put("id",new String[] {id}); | |||
| 148 | jData.getProcessingContext().setParameterMap(map); | 152 | jData.getProcessingContext().setParameterMap(map); | |||
| 149 | %> | 153 | %> | |||
| 150 | <content:formContentMapperHandler listName='storePostedFormBean' | 154 | <content:formContentMapperHandler listName='storePostedFormBean' | |||
| 151 | submitMarker="formId" immediatePublication="true"/> | 155 | submitMarker="formId" immediatePublication="true"/> | |||
| 152 | <% | 156 | <% | |||
| 153 | jData.getProcessingContext().setParameterMap(oldMap); | 157 | jData.getProcessingContext().setParameterMap(oldMap); | |||
| 154 | } | 158 | } | |||
| 155 | } | 159 | } | |||
| 156 | } | 160 | } | |||
| 157 | } | 161 | } | |||
| 158 | } | 162 | } | |||
| 159 | if (emptyMandatoryFields.isEmpty()) { | 163 | if (emptyMandatoryFields.isEmpty()) { | |||
| 160 | //Send the mail | 164 | //Send the mail | |||
| 161 | if (forHasBeenPosted && sendMail) { | 165 | if (forHasBeenPosted && sendMail) { | |||
| 162 | sender = JahiaTools.html2text(sender); | 166 | sender = JahiaTools.html2text(sender); | |||
| 163 | recipients = JahiaTools.html2text(recipients); | 167 | recipients = JahiaTools.html2text(recipients); | |||
| 164 | recipientsCC = JahiaTools.html2text(recipientsCC); | 168 | recipientsCC = JahiaTools.html2text(recipientsCC); | |||
| 169 | if (recipientsCC.equals("")) recipientsCC = null ; // avoid exception if CC is an empty string | |||||
| 165 | subject = JahiaTools.html2text(subject); | 170 | subject = JahiaTools.html2text(subject); | |||
| 166 | String body = JahiaTools.html2text(mailBody.toString()); | 171 | String body = JahiaTools.html2text(mailBody.toString()); | |||
| 167 | org.jahia.services.mail.MailService mailService = | 172 | org.jahia.services.mail.MailService mailService = | |||
| 168 | ServicesRegistry.getInstance().getMailService(); | 173 | ServicesRegistry.getInstance().getMailService(); | |||
| 169 | try { | 174 | try { | |||
| 170 | mailService.sendMessage (sender, recipients, | 175 | mailService.sendMessage (sender, recipients, | |||
| 171 | recipientsCC, null, subject, body); | 176 | recipientsCC, null, subject, body); | |||
| 172 | } catch (Throwable th) { | 177 | } catch (Throwable th) { | |||
| 173 | %>Error while sending mail : <%=th.getMessage()%><% | 178 | %>Error while sending mail : <%=th.getMessage()%><% | |||
| 174 | 179 | |||||
| 175 | } | 180 | } | |||
| 176 | logger.debug("Mail sent"); | 181 | logger.debug("Mail sent"); | |||
| 177 | } | 182 | } | |||
| 178 | } | 183 | } | |||
| 179 | } | 184 | } | |||
| 180 | %> | 185 | %> | |||
Araxis Merge (but not this generated report) is Copyright © 1993-2003 Araxis Ltd (www.araxis.com). All rights reserved.