[Vtigercrm-commits] [vtiger-commits] r10612 - in /vtigercrm/branches/5.0.3: Smarty/templates/ImportStep1.tpl include/js/en_us.lang.js include/js/general.js modules/Users/Forms.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Apr 10 04:02:36 EDT 2007


Author: richie
Date: Tue Apr 10 02:02:25 2007
New Revision: 10612

Log:
* Validation has been added in file selection of Import Step1, Fixed #3366

Modified:
    vtigercrm/branches/5.0.3/Smarty/templates/ImportStep1.tpl
    vtigercrm/branches/5.0.3/include/js/en_us.lang.js
    vtigercrm/branches/5.0.3/include/js/general.js
    vtigercrm/branches/5.0.3/modules/Users/Forms.php

Modified: vtigercrm/branches/5.0.3/Smarty/templates/ImportStep1.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/ImportStep1.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/ImportStep1.tpl Tue Apr 10 02:02:25 2007
@@ -12,7 +12,29 @@
 
 
 <script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script type="text/javascript" language="Javascript">
+function validateFile(form) 
+	{ldelim}
 
+	if(!emptyCheck("userfile","File Location","any"))
+		{ldelim}
+                
+			form.userfile.focus();
+		        return false;
+		{rdelim}
+
+
+    	if(! upload_filter("userfile", "csv") )
+		{ldelim}
+        
+                	form.userfile.focus();
+	                return false;
+	
+		{rdelim}
+	
+		return true;
+	{rdelim}
+</script>
 <!-- header - level 2 tabs -->
 {include file='Buttons_List1.tpl'}	
 
@@ -86,7 +108,7 @@
 				   <tr ><td colspan="2" height="50">&nbsp;</td></tr>
 				    <tr >
 						<td colspan="2" align="right" style="padding-right:40px;" class="reportCreateBottom">
-							<input title="{$MOD.LBL_NEXT}" accessKey="" class="crmButton small save" type="submit" name="button" value="  {$MOD.LBL_NEXT} &rsaquo; "  onclick="this.form.action.value='Import';this.form.step.value='2'; return verify_data(this.form);">
+							<input title="{$MOD.LBL_NEXT}" accessKey="" class="crmButton small save" type="submit" name="button" value="  {$MOD.LBL_NEXT} &rsaquo; "  onclick="this.form.action.value='Import';this.form.step.value='2'; return validateFile(this.form);">
 						&nbsp;
  <input title="{$APP.LBL_CANCEL_BUTTON_LABEL}" accessKey="" class="crmButton small cancel" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" onclick="window.history.back()">
 

Modified: vtigercrm/branches/5.0.3/include/js/en_us.lang.js
==============================================================================
--- vtigercrm/branches/5.0.3/include/js/en_us.lang.js (original)
+++ vtigercrm/branches/5.0.3/include/js/en_us.lang.js Tue Apr 10 02:02:25 2007
@@ -106,5 +106,6 @@
 				GREATER_OR_EQUALS:'greater or equal',
 
 				NO_SPECIAL_CHARS:'Special Characters are not allowed in Invoice String',
-				SHARED_EVENT_DEL_MSG:'The User does not have permission to Delete this record.'
+				SHARED_EVENT_DEL_MSG:'The User does not have permission to Delete this record.',
+				PLS_SELECT_VALID_FILE:'Please select a file with the following extension:\n'
                        };

Modified: vtigercrm/branches/5.0.3/include/js/general.js
==============================================================================
--- vtigercrm/branches/5.0.3/include/js/general.js (original)
+++ vtigercrm/branches/5.0.3/include/js/general.js Tue Apr 10 02:02:25 2007
@@ -768,7 +768,7 @@
 					if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0)
 					{	 
 						if (type[1]=="M")
-							if (!emptyCheck(type[2],fieldlabel[i],getObj(type[2]).type))
+							if (!emptyCheck(fieldname[2],fieldlabel[i],getObj(type[2]).type))
 								return false
 
 									if(typeof(type[3])=="undefined") var currdatechk="OTH"
@@ -2023,3 +2023,35 @@
   }
   return true;
 }
+
+/** Check Upload file is in specified format(extension).
+  * @param fldname -- name of the file field
+  * @param fldLabel -- Lable of the file field
+  * @param filter -- List of file extensions to allow. each extension must be seperated with a | sybmol.
+  * Example: upload_filter("imagename","Image", "jpg|gif|bmp|png") 
+  * @returns true -- if the extension is IN  specified extension.
+  * @returns false -- if the extension is NOT IN specified extension.
+  *
+  * NOTE: If this field is mandatory,  please call emptyCheck() function before calling this function.
+ */
+
+function upload_filter(fldName, filter)
+{
+	var currObj=getObj(fldName)
+	if(currObj.value !="")
+	{
+		var file=currObj.value;
+		var type=file.split(".");
+		var valid_extn=filter.split("|");	
+	
+		if(valid_extn.indexOf(type[type.length-1]) == -1)
+		{
+			alert(alert_arr.PLS_SELECT_VALID_FILE+valid_extn)
+			currObj.focus();
+		 	return false;
+		}
+	}	
+	return true
+	
+}
+

Modified: vtigercrm/branches/5.0.3/modules/Users/Forms.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Users/Forms.php (original)
+++ vtigercrm/branches/5.0.3/modules/Users/Forms.php Tue Apr 10 02:02:25 2007
@@ -41,7 +41,6 @@
 $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
 $err_invalid_email_address = $app_strings['ERR_INVALID_EMAIL_ADDRESS'];
 $lbl_user_image=$mod_strings['User Image'];
-$err_select_valid_image = $app_strings['SELECT_VALID_IMAGE'];
 $the_emailid = $app_strings['THE_EMAILID'];
 $email_field_is = $app_strings['EMAIL_FILED_IS'].$err_invalid_email_address;
 $other_email_field_is = $app_strings['OTHER_EMAIL_FILED_IS'].$err_invalid_email_address;
@@ -116,22 +115,13 @@
 		exit();
 	}
 
-// fix for new user upload image validation
-	if (trim(form.imagename.value) != "")
 
- {
-	var valimg=form.imagename.value;	
-	    var aUpload=valimg.split(".");
-            if((aUpload[aUpload.length-1]!="jpg") &&  (aUpload[aUpload.length-1]!="gif") &&  (aUpload[aUpload.length-1]!="bmp") &&  (aUpload[aUpload.length-1]!="png"))
-		{
 
-		alert("$err_select_valid_image");
-		form.imagename.focus();                                                                                                    exit();
-
-		}
-	
- }
-
+	if(! upload_filter("imagename", "jpg|gif|bmp|png") )
+	{
+		form.imagename.focus();
+		return false;
+	}
 
 
 	if(form.mode.value != 'edit')





More information about the vtigercrm-commits mailing list