Skip to:
Content

BuddyPress.org

Changeset 5131


Ignore:
Timestamp:
09/09/2011 05:47:59 PM (15 years ago)
Author:
boonebgorges
Message:

Switches date picker xprofile fields to save in MySQL date format rather than UNIX timestamp, to prevent problems with UNIX epoch. Fixes #2240. Props cnorris23, r-a-y

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-signup.php

    r5014 r5131  
    7777                                        if ( !isset( $_POST['field_' . $field_id] ) ) {
    7878                                                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    79                                                         $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
     79                                                        $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) );
    8080                                        }
    8181
     
    128128                                        if ( !isset( $_POST['field_' . $field_id] ) ) {
    129129                                                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    130                                                         $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
     130                                                        $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) );
    131131                                        }
    132132
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r4961 r5131  
    110110}
    111111
     112/**
     113 * xprofile_filter_format_field_value()
     114 *
     115 * Runs stripslashes on XProfile fields. If is field_type is 'datebox'
     116 * then the date will be formatted by bp_format_time().
     117 *
     118 * @since 1.0.0
     119 *
     120 * @param string $field_value XProfile field_value to be filtered.
     121 * @param string $field_type XProfile field_type to be filtered.
     122 *
     123 * @uses bp_format_time()
     124 *
     125 * @return string $field_value Filtered XProfile field_value. False on failure.
     126 */
    112127function xprofile_filter_format_field_value( $field_value, $field_type = '' ) {
    113128        if ( !isset( $field_value ) || empty( $field_value ) )
    114129                return false;
    115130
    116         if ( 'datebox' == $field_type )
    117                 $field_value = bp_format_time( $field_value, true, false );
    118         else
     131        if ( 'datebox' == $field_type ) {
     132
     133                // If Unix timestamp
     134                if ( is_numeric( $field_value ) )
     135                        $field_value = bp_format_time( $field_value, true, false );
     136
     137                // If MySQL timestamp
     138                else
     139                        $field_value = bp_format_time( strtotime( $field_value ), true, false );
     140
     141        } else {
    119142                $field_value = str_replace(']]>', ']]>', $field_value );
     143        }
    120144
    121145        return stripslashes( $field_value );
  • trunk/bp-xprofile/bp-xprofile-screens.php

    r4961 r5131  
    7171
    7272                                        // Turn the concatenated value into a timestamp
    73                                         $_POST['field_' . $field_id] = strtotime( $date_value );
     73                                        $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    7474                                }
    7575
  • trunk/bp-xprofile/bp-xprofile-template.php

    r5045 r5131  
    570570
    571571                                if ( !empty( $date ) ) {
    572                                         $day   = date( 'j', $date );
    573                                         $month = date( 'F', $date );
    574                                         $year  = date( 'Y', $date );
     572                                        // If Unix timestamp
     573                                        if ( is_numeric( $date ) ) {
     574                                                $day   = date( 'j', $date );
     575                                                $month = date( 'F', $date );
     576                                                $year  = date( 'Y', $date );
     577
     578                                        // If MySQL timestamp
     579                                        } else {
     580                                                $day   = mysql2date( 'j', $date );
     581                                                $month = mysql2date( 'F', $date );
     582                                                $year  = mysql2date( 'Y', $date );
     583                                        }
    575584                                }
    576585
Note: See TracChangeset for help on using the changeset viewer.