Changeset 1531594
- Timestamp:
- 11/10/2016 12:23:04 PM (9 years ago)
- Location:
- files-addon-for-event-espresso-4/trunk
- Files:
-
- 5 added
- 9 edited
-
EE_FILE_Validation_Strategy.php (modified) (3 diffs)
-
EE_File.class.php (modified) (3 diffs)
-
EE_File_Display_Strategy.php (modified) (1 diff)
-
EE_SSA_FILE.php (modified) (2 diffs)
-
css/admin-screen.css (added)
-
css/admin-screen.css~ (added)
-
css/ssa_style.css (modified) (1 diff)
-
css/ssa_style.css~ (added)
-
eea-file.php (modified) (5 diffs)
-
js/admin-js.js (added)
-
js/ssa_file_upload.js (modified) (3 diffs)
-
readme.txt (modified) (6 diffs)
-
readme.txt~ (added)
-
ssa_run_filters.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
files-addon-for-event-espresso-4/trunk/EE_FILE_Validation_Strategy.php
r1481341 r1531594 8 8 public function __construct($validation_error_message = null) 9 9 { 10 10 11 if (! $validation_error_message) { 11 12 $validation_error_message = __("Please enter a valid URL", "event_espresso"); … … 25 26 public function validate($normalized_value) 26 27 { 27 28 28 $filetype = wp_check_filetype($normalized_value); 29 29 $data = parse_url($normalized_value); … … 35 35 throw new EE_Validation_Error($this->get_validation_error_message(), 'regex'); 36 36 } 37 38 parent::validate($normalized_value); 37 parent::validate($normalized_value); 39 38 } 40 39 } -
files-addon-for-event-espresso-4/trunk/EE_File.class.php
r1449260 r1531594 10 10 define('EE_FILE_ADMIN', EE_FILE_PATH . 'admin/file/'); 11 11 12 /** 13 * 14 * Class EE_File 15 * 16 * @package Event Espresso 17 * @subpackage eea-file 18 * 19 */ 12 20 13 class EE_File extends EE_Addon 21 14 { … … 45 38 ) 46 39 ); 40 add_action('admin_enqueue_scripts', array('EE_File','ssa_load_scripts')); 47 41 require_once "EE_FILE_Validation_Strategy.php"; 48 42 require_once "EE_File_Display_Strategy.php"; … … 51 45 include_once "ssa_run_filters.php"; 52 46 } 47 public static function ssa_load_scripts($hook) 48 { 49 50 global $wpdb; 51 $table = $wpdb->prefix.'esp_question_allowed_ext'; 52 $ext =''; 53 if ($hook == 'event-espresso_page_espresso_registration_form') { 54 if (isset($_GET['QST_ID']) && $_GET['QST_ID'] != '') { 55 $que_id = $_GET['QST_ID']; 56 $ext = $wpdb->get_var("SELECT ext FROM $table WHERE qst_id='$que_id'"); 57 58 } 59 60 wp_enqueue_style('admin-file-css', plugins_url('css/admin-screen.css', __FILE__)); 61 wp_enqueue_script('file-js', plugins_url('js/admin-js.js', __FILE__), array('jquery')); 62 wp_localize_script('file-js', 'ssa_var_ds', array('ext'=>$ext)); 63 } 64 } 53 65 } 66 add_action('AHEE__Extend_Registration_Form_Admin_Page___redirect_after_action__before_redirect_modification_insert_question', 'update_ext_function', 10, 1); 67 68 add_action('AHEE__Extend_Registration_Form_Admin_Page___redirect_after_action__before_redirect_modification_update_question', 'update_ext_function', 10, 1); 69 70 function update_ext_function($args) 71 { 72 global $wpdb; 73 $table = $wpdb->prefix.'esp_question_allowed_ext'; 74 $question_id = $args['QST_ID']; 75 76 $count = $wpdb->get_var("SELECT COUNT(id) FROM $table WHERE qst_id='{$question_id}'"); 77 $ext = $_POST['question_ext']; 78 79 80 if ($count > 0) { 81 82 $wpdb->update( 83 $table, 84 array('ext'=>$ext), 85 array('qst_id'=>$question_id), 86 array('%s'), 87 array('%d') 88 ); 89 } else { 90 91 $wpdb->insert( 92 $table, 93 array('ext'=>$ext, 94 'qst_id'=>$question_id), 95 array( '%s', 96 '%d') 97 ); 98 } 99 100 101 } -
files-addon-for-event-espresso-4/trunk/EE_File_Display_Strategy.php
r1481341 r1531594 31 31 public function display() 32 32 { 33 33 34 $value = $this->_input->raw_value_in_form(); 34 $input ='<input type="text">';35 35 $input = '<input type="'. $this->get_type() .'"'; 36 $input .= ' name="ssa_' . $this->_input->html_name() . '"'; 37 $input .= ' id="ssa_' . $this->_input->html_id() . '"'; 36 38 $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); 37 $input .= ' class=" ssa-file ' . $class . '"';39 $input .= ' class="' . $class . ' ssa-file"'; 38 40 $input .= $this->_input->required() ? ' required' : ''; 39 41 $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; 40 42 $input .= ' style="' . $this->_input->html_style() . '"'; 41 $input .= $this->_input-> html_other_attributes();43 $input .= $this->_input->other_html_attributes(); 42 44 $input .= '/>'; 43 45 $input .= "<span class='ssa-remove'></span>"; 44 46 $input .= "<span class='ssa-loading'></span>"; 45 $input .= '<input type="hidden"';47 $input .= '<input type="hidden"'; 46 48 $input .= ' name="' . $this->_input->html_name() . '"'; 47 49 $input .= ' id="' . $this->_input->html_id() . '"'; 48 50 $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); 49 50 51 $input .= ' class="file_value ' . $class . '"'; 52 // add html5 required 53 $input .= $this->_input->required() ? ' required' : ''; 54 $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; 51 55 $input .= ' style="' . $this->_input->html_style() . '"'; 52 $input .= $this->_input-> html_other_attributes();56 $input .= $this->_input->other_html_attributes(); 53 57 $input .= '/>'; 54 58 if ($value != '') { -
files-addon-for-event-espresso-4/trunk/EE_SSA_FILE.php
r1449260 r1531594 20 20 static function ssa_enqueue_scripts() 21 21 { 22 global $wpdb; 23 $table = $wpdb->prefix.'esp_question_allowed_ext'; 24 $ext = $wpdb->get_results("SELECT * FROM $table"); 25 $arr = array(); 26 foreach ($ext as $extension) { 27 $id = $extension->qst_id; 28 $et = $extension->ext; 29 $arr[$id] = $et; 30 } 31 $d = json_encode($arr); 22 32 wp_enqueue_style('ssa_file_css', plugins_url('css/ssa_style.css', __FILE__)); 23 33 $year = date('Y'); … … 30 40 wp_localize_script( 31 41 'ssa_file_upload', 32 'ssa_var ',42 'ssa_var_ds', 33 43 array( 34 44 'ajax_path' =>$ajax_path, 35 45 'ssa_upload'=>$uploads, 36 'ssa_url'=>$uploads_url) 46 'ssa_url'=>$uploads_url, 47 'extensions'=> $d) 37 48 ); 38 49 } -
files-addon-for-event-espresso-4/trunk/css/ssa_style.css
r1481341 r1531594 21 21 display:none !important; 22 22 } 23 .ssa-loading+label 24 { 25 display:none !important; 26 } -
files-addon-for-event-espresso-4/trunk/eea-file.php
r1497941 r1531594 3 3 * Plugin Name: Files Addon for Event Espresso 4 4 4 * Description: Files add on plugin allows to create file type question in event registration form. Attendees will be able to upload files while registering for an event. 5 * Author: WordGenie 5 * Author: WordGeniee 6 6 * License:GPL2 7 * Version: 1.0. 37 * Version: 1.0.4 8 8 * TextDomain: wordfile 9 9 */ 10 10 // define versions and this file 11 11 define('EE_FILE_CORE_VERSION_REQUIRED', '4.8.0.rc.0000'); 12 define('EE_FILE_VERSION', '1.0. 0');12 define('EE_FILE_VERSION', '1.0.4'); 13 13 define('EE_FILE_PLUGIN_FILE', __FILE__); 14 14 … … 78 78 function ssa_upload_file() 79 79 { 80 global $wpdb; 81 82 $table = $wpdb->prefix.'esp_question_allowed_ext'; 80 83 $data = array(); 81 84 if (isset($_FILES)) { … … 85 88 86 89 $uploadedfile = $_FILES['file']; 90 $qid = $_POST['qst_id']; 91 $ext = $wpdb->get_var("SELECT ext FROM $table WHERE qst_id='$qid'"); 92 $allowed = array('gif','png' ,'jpg','jpeg','bmp'); 93 if ($ext !='') { 94 $allowed = explode(',', $ext); 95 } 87 96 88 $allowed = array('gif','png' ,'jpg','jpeg','bmp'); 97 $allowed=array_map('trim', $allowed); 98 89 99 $filename = $_FILES['file']['name']; 90 100 $extn = pathinfo($filename, PATHINFO_EXTENSION); 91 101 if (!in_array($extn, $allowed)) { 92 $data = array('error' => "Only formats are allowed : ".implode(', ', $allowed));102 $data = array('error' => __("Only formats are allowed : ".implode(', ', $allowed),'wordfile')); 93 103 } 94 104 95 105 $upload_overrides = array( 'test_form' => false ); 96 106 … … 108 118 } 109 119 } else { 110 $data = array('error' => 'No file submitted');120 $data = array('error' => __('No file submitted','wordfile')); 111 121 } 112 122 113 echo json_encode($data);123 echo json_encode($data); 114 124 die(); 115 125 } … … 122 132 } 123 133 134 135 function ssa_create_ext_tbl() 136 { 137 $val = get_option('file_db_created'); 138 if($val != 1) 139 { 140 global $wpdb; 141 $tbl = $wpdb->prefix.'esp_question_allowed_ext'; 142 143 144 if ($wpdb->get_var("show tables like '$tbl'") != $tbl) { 145 $sql = "CREATE TABLE " . $tbl . " ( 146 id int NOT NULL AUTO_INCREMENT, 147 qst_id int, 148 ext varchar(100), 149 UNIQUE KEY id (id) 150 );"; 151 152 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 153 dbDelta($sql); 154 } 155 update_option('file_db_created',1); 156 } 157 } 158 add_action('admin_head', 'ssa_create_ext_tbl'); -
files-addon-for-event-espresso-4/trunk/js/ssa_file_upload.js
r1481341 r1531594 1 1 jQuery(document).ready(function(){ 2 2 exts = JSON.parse(ssa_var_ds.extensions); 3 // console.log(exts); 3 4 jQuery('.ssa-file').on('change',function(event){ 4 5 var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp']; 5 id = jQuery(this).prev('label').attr('id'); 6 piece = id.split('-'); 7 qid = piece[2]; 8 9 var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp']; 10 if(exts[qid] != '' && typeof exts[qid] != 'undefined') 11 { 12 var fileExtension = exts[qid].split(','); 13 for(i=0;i<fileExtension.length;i++) 14 fileExtension[i] = fileExtension[i].trim(); 15 } 16 6 17 if (jQuery.inArray(jQuery(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) { 7 18 alert("Only formats are allowed : "+fileExtension.join(', ')); 8 jQuery( '.ssa-file').val('');19 jQuery(this).val(''); 9 20 return; 10 21 } … … 17 28 data.append("file", file_data); 18 29 data.append("action", 'ssa_upload_file'); 19 path = ssa_var.ajax_path; 30 data.append("qst_id", qid); 31 path = ssa_var_ds.ajax_path; 20 32 jQuery(this).siblings('.ssa-loading').css('display','inline-block'); 21 33 jQuery.ajax({ … … 29 41 success: function(data, textStatus, jqXHR) 30 42 { 31 //console.log(data.files.url);43 console.log(data.files.url); 32 44 33 45 if(typeof data.error === 'undefined') -
files-addon-for-event-espresso-4/trunk/readme.txt
r1497941 r1531594 5 5 Tested up to: 4.5 6 6 Requires Event espresso version: 4.8.0 7 Stable tag: 1.0. 37 Stable tag: 1.0.4 8 8 License: GPL2 9 9 … … 12 12 == Description == 13 13 14 Files add on plugin allows to create file type question which can be used in event registration form. Attendees will be able to upload image files while registerting for an event using this addon.14 Files add on plugin allows to create file type question which can be used in event registration form. Attendees will be able to upload files while registerting for an event using this addon. Admin will be able to restrict the file type by setting file extensions for each question. 15 15 16 16 == Installation == … … 21 21 * PHP version 5.2.4 or greater 22 22 * MySQL version 5.0 or greater 23 * Event espresso version: 4.8.0 or greater 23 24 * This add on will not work in Internet explorer version 9 or below, because formData (javascript object used to upload file on server) is not supported in IE 9 or its below version. 24 25 … … 27 28 Following steps should be followed to install plugin manually 28 29 29 1. Upload 'files-addon-for-event-espresso-4' folder to the '/wp-content/plugins/' directory or upload 'files-addon-for-event-espresso-4.1.0. 1.zip' through WordPress admin panel30 1. Upload 'files-addon-for-event-espresso-4' folder to the '/wp-content/plugins/' directory or upload 'files-addon-for-event-espresso-4.1.0.4.zip' through WordPress admin panel 30 31 2. Activate the plugin through the 'Plugins' menu in WordPress 31 32 3. You are ready to create file type question. … … 58 59 59 60 == Changelog == 61 = 1.0.4 = 60 62 61 = 1.0.0 = 62 Plugin release 63 1. Added feature to set different file extensions for each file type question 64 2. If extensions are not set then uploaded file is validated against following extensions ['gif','png' ,'jpg','jpeg','bmp'] 63 65 64 = 1.0. 1=66 = 1.0.3 = 65 67 66 Fixed file upload security issue. Added EE_FILE_Validation_Strategy class for validating uploaded file. 68 1. Added filter 'ssa_change_file_upload_path' to change directory path of uploaded file 69 2. Added standard code to return file type question. 67 70 68 71 = 1.0.2 = … … 71 74 2. Added link to image. 72 75 73 = 1.0. 3=76 = 1.0.1 = 74 77 75 1. Added filter 'ssa_change_file_upload_path' to change directory path of uploaded file 76 2. Added standard code to return file type question. 78 Fixed file upload security issue. Added EE_FILE_Validation_Strategy class for validating uploaded file. 77 79 80 = 1.0.0 = 81 Plugin release 82 83 -
files-addon-for-event-espresso-4/trunk/ssa_run_filters.php
r1497941 r1531594 3 3 function ssa_add_file_type($question_types) 4 4 { 5 $question_types['file']= __('File', ' event_espresso');5 $question_types['file']= __('File', 'wordfile'); 6 6 return $question_types; 7 7 }
Note: See TracChangeset
for help on using the changeset viewer.