Commit 3b6192ec authored by KR Moorhouse's avatar KR Moorhouse

Resolved merge conflicts.

parents 30cf7232 e644ebd7
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -19,6 +19,7 @@ define([], function() {
format: dateFormat,
outputFormat: dateFormat,
classes: jQuery( el ).attr( "class" ),
placeholder: view.model.get( 'placeholder' ),
pikadayOptions: {
yearRange: this.getYearRange( view.model ),
minDate: this.getMinDate( view.model ),
......
define([], function() {
var controller = Marionette.Object.extend({
htmlFields: [],
trackedMergeTags: [],
initialize: function () {
this.listenTo( Backbone.Radio.channel( 'fields-html' ), 'init:model', this.setupFieldMergeTagTracking );
},
setupFieldMergeTagTracking: function( fieldModel ) {
this.htmlFields.push( fieldModel );
var formID = fieldModel.get( 'formID' );
this.listenTo( nfRadio.channel( 'form-' + formID ), 'init:model', function( formModel ){
var mergeTags = fieldModel.get( 'default' ).match( new RegExp( /{field:(.*?)}/g ) );
if ( ! mergeTags ) return;
_.each( mergeTags, function( mergeTag ) {
var fieldKey = mergeTag.replace( '{field:', '' ).replace( '}', '' );
var fieldModel = formModel.get( 'fields' ).findWhere({ key: fieldKey });
if( 'undefined' == typeof fieldModel ) return;
this.trackedMergeTags.push( fieldModel );
this.listenTo( nfRadio.channel( 'field-' + fieldModel.get( 'id' ) ), 'change:modelValue', this.updateFieldMergeTags );
}, this );
// Let's get this party started!
this.updateFieldMergeTags();
}, this );
},
updateFieldMergeTags: function( fieldModel ) {
_.each( this.htmlFields, function( htmlFieldModel ){
var value = htmlFieldModel.get( 'default' );
_.each( this.trackedMergeTags, function( fieldModel ){
var mergeTag = '{field:' + fieldModel.get( 'key' ) + '}';
value = value.replace( mergeTag, fieldModel.get( 'value' ) );
}, this ) ;
htmlFieldModel.set( 'value', value );
htmlFieldModel.trigger( 'reRender' );
}, this );
}
});
return controller;
});
......@@ -93,6 +93,9 @@ define([], function() {
if( 'listmultiselect' == this.type ){
otherAttributes = otherAttributes + ' multiple';
var multiSize = this.multi_size || 5;
otherAttributes = otherAttributes + ' size="' + multiSize + '"';
}
return otherAttributes;
......@@ -133,4 +136,4 @@ define([], function() {
});
return controller;
} );
\ No newline at end of file
} );
......@@ -26,6 +26,7 @@ define(
'controllers/calculations',
'controllers/fieldDate',
'controllers/fieldRecaptcha',
'controllers/fieldHTML',
'controllers/helpText',
'controllers/fieldTextareaRTE',
'controllers/fieldStarRating',
......@@ -64,6 +65,7 @@ define(
Calculations,
FieldDate,
FieldRecaptcha,
FieldHTML,
HelpText,
FieldTextareaRTE,
FieldStarRating,
......@@ -97,6 +99,7 @@ define(
new FieldTotal();
new FieldQuantity();
new FieldRecaptcha();
new FieldHTML();
new HelpText();
new FieldTextareaRTE();
new FieldStarRating();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -42,7 +42,7 @@ abstract class NF_Abstracts_MergeTags
if( empty( $matches[0] ) ) return $subject;
foreach( $this->merge_tags as $merge_tag ){
if( ! in_array( $merge_tag[ 'tag' ], $matches[0] ) ) continue;
if( ! isset( $merge_tag[ 'tag' ] ) || ! in_array( $merge_tag[ 'tag' ], $matches[0] ) ) continue;
if( ! isset($merge_tag[ 'callback' ])) continue;
......
......@@ -127,6 +127,14 @@ class NF_Abstracts_ModelFactory
*/
public function import_form( $import, $id = FALSE, $is_conversion = FALSE )
{
/*
* Remove any unwated (corrupted?) characters from either side of our object.
*/
$l_trim = strpos( $import, '{' );
$r_trim = strrpos( $import, '}' ) - $l_trim + 1;
$import = substr( $import, $l_trim, $r_trim );
if( ! is_array( $import ) ){
$data = WPN_Helper::utf8_decode( json_decode( html_entity_decode( $import ), true ) );
......
......@@ -61,7 +61,7 @@ final class NF_Actions_CollectPayment extends NF_Abstracts_Action
$payment_gateway_class = $this->payment_gateways[ $payment_gateway ];
/*
* Get our payment total.
* Get our payment total if we have old data. (not used in current version)
*
* If we have selected "Calc" as our total type, then we want to use payment_total_calc
*
......
......@@ -47,6 +47,8 @@ final class NF_Actions_Email extends NF_Abstracts_Action
public function process( $action_settings, $form_id, $data )
{
$action_settings = $this->sanitize_address_fields( $action_settings );
$errors = $this->check_for_errors( $action_settings );
$headers = $this->_get_headers( $action_settings );
......@@ -103,6 +105,55 @@ final class NF_Actions_Email extends NF_Abstracts_Action
return $data;
}
/**
* Sanitizes email address settings
* @since 3.2.2
*
* @param array $action_settings
* @return array
*/
protected function sanitize_address_fields( $action_settings )
{
// Build a look array to compare our email address settings to.
$email_address_settings = array( 'to', 'from_address', 'reply_to', 'cc', 'bcc' );
// Loop over the look up values.
foreach( $email_address_settings as $setting ) {
// If the loop up values are not set in the action settings continue.
if ( ! isset( $action_settings[ $setting ] ) ) continue;
// If action settings do not match the look up values continue.
if ( ! $action_settings[ $setting ] ) continue;
// This is the array that will contain the sanitized email address values.
$sanitized_array = array();
/*
* Checks to see action settings is array,
* if not explodes to comma delimited array.
*/
if( is_array( $action_settings[ $setting ] ) ) {
$email_addresses = $action_settings[ $setting ];
} else {
$email_addresses = explode( ',', $action_settings[ $setting ] );
}
// Loop over our email addresses.
foreach( $email_addresses as $email ) {
// Updated to trim values in case there is a value with spaces/tabs/etc to remove whitespace
$email = trim( $email );
if ( empty( $email ) ) continue;
// Build our array of the email addresses.
$sanitized_array[] = $email;
}
// Sanitized our array of settings.
$action_settings[ $setting ] = implode( ',' ,$sanitized_array );
}
return $action_settings;
}
protected function check_for_errors( $action_settings )
{
$errors = array();
......@@ -115,6 +166,7 @@ final class NF_Actions_Email extends NF_Abstracts_Action
$email_addresses = is_array( $action_settings[ $setting ] ) ? $action_settings[ $setting ] : explode( ',', $action_settings[ $setting ] );
foreach( (array) $email_addresses as $email ){
$email = trim( $email );
if ( false !== strpos( $email, '<' ) && false !== strpos( $email, '>' ) ) {
......
......@@ -10,7 +10,10 @@ final class NF_Admin_Menus_Addons extends NF_Abstracts_Submenu
public function __construct()
{
parent::__construct();
$disable_marketing = false;
if ( ! apply_filters( 'ninja_forms_disable_marketing', $disable_marketing ) ) {
parent::__construct();
}
}
public function get_page_title()
......
......@@ -377,7 +377,7 @@ final class NF_Admin_Menus_Submissions extends NF_Abstracts_Submenu
*/
private function custom_columns_sub_date( $sub )
{
return $sub->get_sub_date();
return $sub->get_sub_date( 'm/d/Y h:i A' );
}
/**
......@@ -418,6 +418,9 @@ final class NF_Admin_Menus_Submissions extends NF_Abstracts_Submenu
$begin_date = $_GET[ 'begin_date' ];
$end_date = $_GET[ 'end_date' ];
// Include submissions on the end_date.
$end_date = date( 'm/d/Y', strtotime( '+1 day', strtotime( $end_date ) ) );
if( $begin_date > $end_date ){
$temp_date = $begin_date;
$begin_date = $end_date;
......
......@@ -85,4 +85,8 @@ return apply_filters( 'ninja_forms_currency', array(
'label' => __( 'U.S. Dollars', 'ninja-forms' ),
'value' => 'USD'
),
'ZAR' => array(
'label' => __( 'South African Rand', 'ninja-forms' ),
'value' => 'ZAR'
),
));
\ No newline at end of file
......@@ -611,6 +611,22 @@ return apply_filters( 'ninja_forms_field_settings', array(
'help' => __( 'This column in the submissions table will sort by number.', 'ninja-forms' ),
),
/*
|--------------------------------------------------------------------------
| Display Settings
|--------------------------------------------------------------------------
*/
// Multi-Select List Only
'multi_size' => array(
'name' => 'multi_size',
'type' => 'number',
'label' => __( 'Multi-Select Box Size', 'ninja-forms'),
'width' => 'one-half',
'group' => 'primary',
'value' => 5,
),
/*
|--------------------------------------------------------------------------
| Un-Grouped Settings
......
......@@ -26,6 +26,19 @@ return apply_filters( 'ninja_forms_merge_tags_other', array(
'callback' => 'system_date'
),
/*
|--------------------------------------------------------------------------
| System Date
|--------------------------------------------------------------------------
*/
'time' => array(
'id' => 'time',
'tag' => '{other:time}',
'label' => __( 'Time', 'ninja_forms' ),
'callback' => 'system_time'
),
/*
|--------------------------------------------------------------------------
| System IP Address
......@@ -39,4 +52,4 @@ return apply_filters( 'ninja_forms_merge_tags_other', array(
'callback' => 'user_ip'
),
));
\ No newline at end of file
));
......@@ -158,6 +158,19 @@ return apply_filters( 'ninja_forms_merge_tags_wp', array(
'callback' => 'user_url'
),
/*
|--------------------------------------------------------------------------
| Post Meta
|--------------------------------------------------------------------------
*/
'user_meta' => array(
'id' => 'user_meta',
'tag' => '{user_meta:YOUR_META_KEY}',
'label' => __( 'User Meta', 'ninja_forms' ),
'callback' => null
),
/*
|--------------------------------------------------------------------------
| Site Title
......@@ -197,4 +210,4 @@ return apply_filters( 'ninja_forms_merge_tags_wp', array(
'callback' => 'admin_email'
),
));
\ No newline at end of file
));
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class NF_Fields_Confirm
*/
class NF_Fields_Confirm extends NF_Abstracts_Input
{
protected $_name = 'confirm';
protected $_type = 'confirm';
protected $_nicename = 'Confirm';
protected $_section = 'misc';
protected $_icon = 'check-circle-o';
protected $_error_message = '';
protected $_settings = array( 'confirm_field' );
public function __construct()
{
parent::__construct();
$this->_nicename = __( 'Confirm', 'ninja-forms' );
$this->_settings[ 'confirm_field' ][ 'field_value_format' ] = 'key';
add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) );
}
function hide_field_type( $field_types )
{
$field_types[] = $this->_name;
return $field_types;
}
public function validate( $field, $data )
{
if( false ){
$errors[] = __( 'Fields do not match.', 'ninja-forms' );
}
return $errors;
}
}
......@@ -21,7 +21,7 @@ class NF_Fields_Date extends NF_Fields_Textbox
protected $_settings = array( 'date_default', 'date_format', 'year_range' );
protected $_settings_exclude = array( 'default', 'placeholder', 'input_limit_set', 'disable_input' );
protected $_settings_exclude = array( 'default', 'input_limit_set', 'disable_input' );
public function __construct()
{
......
......@@ -17,6 +17,8 @@ class NF_Fields_ListMultiselect extends NF_Abstracts_List
protected $_old_classname = 'list-multiselect';
protected $_settings = array( 'multi_size' );
public function __construct()
{
parent::__construct();
......@@ -51,4 +53,4 @@ class NF_Fields_ListMultiselect extends NF_Abstracts_List
}
return $value;
}
}
\ No newline at end of file
}
......@@ -89,6 +89,11 @@ final class NF_MergeTags_Other extends NF_Abstracts_MergeTags
return date( $format, time() );
}
protected function system_time()
{
return date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) );
}
protected function user_ip()
{
$ip = '127.0.0.1';
......
......@@ -36,26 +36,13 @@ final class NF_MergeTags_WP extends NF_Abstracts_MergeTags
$this->setup_post_meta( $this->post_id() );
}
/**
* Custom replace() method for custom post meta or user meta.
* @param string|array $subject
* @return string
*/
public function replace( $subject )
{
/*
* If we are dealing with a post meta merge tag, we need to overwrite the parent replace() method.
*
* Otherwise, we use the parent's method.
*/
/**
* {post_meta:foo} --> meta key is 'foo'
*/
if (is_string($subject)) {
preg_match_all("/{post_meta:(.*?)}/", $subject, $matches );
}
// If not matching merge tags are found, then return early.
if( empty( $matches[0] ) ) return parent::replace( $subject );
// Recursively replace merge tags.
if( is_array( $subject ) ){
foreach( $subject as $i => $s ){
......@@ -65,13 +52,40 @@ final class NF_MergeTags_WP extends NF_Abstracts_MergeTags
}
/**
* $matches[0][$i] merge tag match {post_meta:foo}
* $matches[1][$i] captured meta key foo
* Replace Custom Post Meta
* {post_meta:foo} --> meta key is 'foo'
*/
foreach( $matches[0] as $i => $search ){
$meta_key = $matches[ 1 ][ $i ];
if( ! isset( $this->post_meta[ $meta_key ] ) ) continue;
$subject = str_replace( $search, $this->post_meta[ $meta_key ], $subject );
preg_match_all( "/{post_meta:(.*?)}/", $subject, $post_meta_matches );
if( ! empty( $post_meta_matches[0] ) ) {
/**
* $matches[0][$i] merge tag match {post_meta:foo}
* $matches[1][$i] captured meta key foo
*/
foreach( $post_meta_matches[0] as $i => $search ) {
$meta_key = $post_meta_matches[1][$i];
if ( isset( $this->post_meta[ $meta_key ] ) ) {
$subject = str_replace( $search, $this->post_meta[$meta_key], $subject );
} else {
$subject = str_replace( $search, '', $subject );
}
}
}
/**
* Replace Custom User Meta
* {user_meta:foo} --> meta key is 'foo'
*/
preg_match_all( "/{user_meta:(.*?)}/", $subject, $user_meta_matches );
if( ! empty( $user_meta_matches[0] ) && $user_id = get_current_user_id() ) {
/**
* $matches[0][$i] merge tag match {user_meta:foo}
* $matches[1][$i] captured meta key foo
*/
foreach( $user_meta_matches[0] as $i => $search ) {
$meta_key = $user_meta_matches[1][$i];
$meta_value = get_user_meta( $user_id, $meta_key, /* $single */ true );
$subject = str_replace( $search, $meta_value, $subject );
}
}
return parent::replace( $subject );
......
......@@ -372,6 +372,20 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
if ( isset ( $_GET[ 'nf-upgrade' ] ) && 'complete' == $_GET[ 'nf-upgrade' ] ) {
Ninja_Forms()->dispatcher()->send( 'upgrade' );
}
add_filter( 'ninja_forms_dashboard_menu_items', array( $this, 'maybe_hide_dashboard_items' ) );
}
public function maybe_hide_dashboard_items( $items )
{
$disable_marketing = false;
if ( apply_filters( 'ninja_forms_disable_marketing', $disable_marketing ) ) {
unset(
$items[ 'apps' ],
$items[ 'memberships' ]
);
}
return $items;
}
public function scrub_available_actions( $actions )
......@@ -536,7 +550,7 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
*/
public function get_setting( $key = '', $default = false )
{
if( empty( $key ) || ! isset( $this->settings[ $key ] ) ) return $default;
if( empty( $key ) || ! isset( $this->settings[ $key ] ) || empty( $this->settings[ $key ] ) ) return $default;
return $this->settings[ $key ];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment