Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.9.5.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Apr 9, 2015
2 parents 2dbbd63 + a022b61 commit 6fdcb12
Show file tree
Hide file tree
Showing 102 changed files with 5,166 additions and 5,620 deletions.
180 changes: 179 additions & 1 deletion change_log.txt

Large diffs are not rendered by default.

83 changes: 68 additions & 15 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,34 @@ public static function trim_all( $text ) {
return $text;
}

public static function format_number( $number, $number_format ) {
public static function format_number( $number, $number_format, $currency = '', $include_thousands_sep = false ) {
if ( ! is_numeric( $number ) ) {
return $number;
}

//replacing commas with dots and dots with commas
if ( $number_format == 'currency' ) {
if ( empty( $currency ) ) {
$currency = GFCommon::get_currency();
}

if ( false === class_exists( 'RGCurrency' ) ) {
require_once( GFCommon::get_base_path() . '/currency.php' );
}
$currency = new RGCurrency( GFCommon::get_currency() );
$currency = new RGCurrency( $currency );
$number = $currency->to_money( $number );
} elseif ( $number_format == 'decimal_comma' ) {
$number = str_replace( ',', '|', $number );
$number = str_replace( '.', ',', $number );
$number = str_replace( '|', '.', $number );
} else {
if ( $number_format == 'decimal_comma' ) {
$dec_point = ',';
$thousands_sep = $include_thousands_sep ? '.' : '';
} else {
$dec_point = '.';
$thousands_sep = $include_thousands_sep ? ',' : '';
}

$number = explode( '.', $number );
$number[0] = number_format( $number[0], 0, '', $thousands_sep );
$number = implode( $dec_point, $number );
}

return $number;
Expand Down Expand Up @@ -271,6 +283,7 @@ public static function is_valid_url( $url ) {
}

public static function is_valid_email( $email ) {

return filter_var( $email, FILTER_VALIDATE_EMAIL );
}

Expand Down Expand Up @@ -756,12 +769,12 @@ public static function implode_non_blank( $separator, $array ) {
return implode( $separator, $ary );
}

public static function format_variable_value( $value, $url_encode, $esc_html, $format ) {
public static function format_variable_value( $value, $url_encode, $esc_html, $format, $nl2br = true ) {
if ( $esc_html ) {
$value = esc_html( $value );
}

if ( $format == 'html' ) {
if ( $format == 'html' && $nl2br ) {
$value = nl2br( $value );
}

Expand Down Expand Up @@ -794,7 +807,7 @@ public static function replace_variables( $text, $form, $lead, $url_encode = fal
$value = rgar( $value, $input_id );
}

$value = self::format_variable_value( $value, $url_encode, $esc_html, $format );
$value = self::format_variable_value( $value, $url_encode, $esc_html, $format, $nl2br );

$modifier = strtolower( rgar( $match, 4 ) );

Expand Down Expand Up @@ -1463,6 +1476,7 @@ public static function send_notification( $notification, $form, $lead ) {
if ( empty( $email_to ) && rgar( $notification, 'toType' ) == 'routing' ) {
$email_to = array();
foreach ( $notification['routing'] as $routing ) {
GFCommon::log_debug( __METHOD__ . '(): Evaluating Routing - rule => ' . print_r( $routing, 1 ) );

$source_field = RGFormsModel::get_field( $form, $routing['fieldId'] );
$field_value = RGFormsModel::get_lead_field_value( $lead, $source_field );
Expand All @@ -1471,6 +1485,10 @@ public static function send_notification( $notification, $form, $lead ) {
if ( $is_value_match ) {
$email_to[] = $routing['email'];
}

GFCommon::log_debug( __METHOD__ . '(): Evaluating Routing - field value => ' . print_r( $field_value, 1 ) );
$is_value_match = $is_value_match ? 'Yes' : 'No';
GFCommon::log_debug( __METHOD__ . '(): Evaluating Routing - is value match? ' . $is_value_match );
}

$email_to = join( ',', $email_to );
Expand Down Expand Up @@ -1509,13 +1527,14 @@ public static function send_notification( $notification, $form, $lead ) {
}

public static function send_notifications( $notification_ids, $form, $lead, $do_conditional_logic = true, $event = 'form_submission' ) {
$entry_id = rgar( $lead, 'id' );
if ( ! is_array( $notification_ids ) || empty( $notification_ids ) ) {
GFCommon::log_debug( "GFCommon::send_notifications(): Aborting. No notifications to process for {$event} event." );
GFCommon::log_debug( "GFCommon::send_notifications(): Aborting. No notifications to process for {$event} event for entry #{$entry_id}." );

return;
}

GFCommon::log_debug( "GFCommon::send_notifications(): Processing notifications for {$event} event: " . print_r( $notification_ids, true ) . "\n(only active/applicable notifications are sent)" );
GFCommon::log_debug( "GFCommon::send_notifications(): Processing notifications for {$event} event for entry #{$entry_id}: " . print_r( $notification_ids, true ) . "\n(only active/applicable notifications are sent)" );

foreach ( $notification_ids as $notification_id ) {
if ( ! isset( $form['notifications'][ $notification_id ] ) ) {
Expand Down Expand Up @@ -1608,6 +1627,8 @@ public static function has_user_notification( $form ) {
}

private static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '' ) {

global $phpmailer;

$to = str_replace( ' ', '', $to );
$bcc = str_replace( ' ', '', $bcc );
Expand Down Expand Up @@ -1668,6 +1689,10 @@ private static function send_email( $from, $to, $bcc, $reply_to, $subject, $mess
if ( has_filter( 'phpmailer_init' ) ) {
GFCommon::log_debug( __METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.' );
}

if ( ! empty( $phpmailer->ErrorInfo ) ) {
GFCommon::log_debug( __METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo );
}
} else {
GFCommon::log_debug( 'GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.' );
}
Expand Down Expand Up @@ -2023,14 +2048,18 @@ public static function cache_remote_message() {
update_option( 'rg_gforms_message', $message );
}

public static function post_to_manager( $file, $query, $options ) {
public static function post_to_manager( $file, $query, $options ){

$request_url = GRAVITY_MANAGER_URL . '/' . $file . '?' . $query;
$request_url = GRAVITY_MANAGER_URL . '/' . $file . '?' . $query;
self::log_debug( 'Posting to manager: ' . $request_url );
$raw_response = wp_remote_post( $request_url, $options );
self::log_debug( print_r( $raw_response, true ) );

if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code'] ) {
$request_url = GRAVITY_MANAGER_PROXY_URL . '/proxy.php?f=' . $file . '&' . $query;
if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code'] ){
self::log_error( 'Error from manager. Sending to proxy...' );
$request_url = GRAVITY_MANAGER_PROXY_URL . '/proxy.php?f=' . $file . '&' . $query;
$raw_response = wp_remote_post( $request_url, $options );
self::log_debug( print_r( $raw_response, true ) );
}

return $raw_response;
Expand Down Expand Up @@ -2635,6 +2664,30 @@ public static function file_name_has_disallowed_extension( $file_name ) {
return self::match_file_extension( $file_name, self::get_disallowed_file_extensions() ) || strpos( strtolower( $file_name ), '.php.' ) !== false;
}

public static function check_type_and_ext( $file, $file_name = ''){
if ( empty( $file_name ) ) {
$file_name = $file['name'];
}
$tmp_name = $file['tmp_name'];
// Whitelist the mime type and extension
$wp_filetype = wp_check_filetype_and_ext( $tmp_name, $file_name );
$ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext'];
$type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type'];
$proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];

if ( $proper_filename ) {
return new WP_Error( 'invalid_file', __( 'There was an problem while verifying your file.' ) );
}
if ( ! $ext ) {
return new WP_Error( 'illegal_extension', __( 'Sorry, this file extension is not permitted for security reasons.' ) );
}
if ( ! $type ) {
return new WP_Error( 'illegal_type', __( 'Sorry, this file type is not permitted for security reasons.' ) );
}

return true;
}

public static function to_money( $number, $currency_code = '' ) {
if ( ! class_exists( 'RGCurrency' ) ) {
require_once( 'currency.php' );
Expand Down
6 changes: 6 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,18 @@ label.float_label {
float: left;
margin-bottom: 4px;
}
.gfield_date_year {
width: 65px;
}

.gfield_date_month input,
.gfield_date_day input,
.gfield_date_year input {
width: 80% !important;
}
.gfield_date_year input {
width: 83% !important;
}

.gfield_date_dropdown_month,
.gfield_date_dropdown_day,
Expand Down
4 changes: 4 additions & 0 deletions css/admin.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 6fdcb12

Please sign in to comment.