From 26017e66070f34a84efa0b22b86bb47502e379dc Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 14 Mar 2008 08:43:30 +0000 Subject: [PATCH] Add new 'Custom Date Format' option for message list date format git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13035 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/date.php | 18 +++++++++++------- include/load_prefs.php | 1 + include/options/display.php | 9 +++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/functions/date.php b/functions/date.php index a0e0f417..c776b787 100644 --- a/functions/date.php +++ b/functions/date.php @@ -291,11 +291,12 @@ function date_intl( $date_format, $stamp ) { $ret = date('w#m#'. $ret, $stamp ); // extract day and month in order to replace later by intl day and month $aParts = explode('#',$ret); - $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]), - getMonthAbrv($aParts[1]), - getMonthName($aParts[1]), - getDayName($aParts[0])), - $aParts[2]); + $ret = str_replace(array('$1','$4','$2','$3',), + array(getDayAbrv($aParts[0]), + getMonthAbrv($aParts[1]), + getMonthName($aParts[1]), + getDayName($aParts[0])), + $aParts[2]); return( $ret ); } @@ -338,7 +339,7 @@ function getLongDateString( $stamp, $fallback = '' ) { */ function getDateString( $stamp ) { - global $invert_time, $hour_format, $show_full_date; + global $invert_time, $hour_format, $show_full_date, $custom_date_format; if ( $stamp == -1 ) { return ''; @@ -364,7 +365,10 @@ function getDateString( $stamp ) { } $nextmid = $midnight + 86400; - if (($show_full_date == 1) || ($nextmid < $stamp)) { + $custom_date_format = trim($custom_date_format); + if (!empty($custom_date_format)) { + $date_format = $custom_date_format; + } else if ($show_full_date == 1 || $nextmid < $stamp) { $date_format = _("M j, Y"); } else if ($midnight < $stamp) { /* Today */ diff --git a/include/load_prefs.php b/include/load_prefs.php index 5cc69749..c3d5f56d 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -323,6 +323,7 @@ $mailbox_select_style = getPref($data_dir, $username, 'mailbox_select_style', SM /* Allow user to customize, and display the full date, instead of day, or time based on time distance from date of message */ +$custom_date_format = getPref($data_dir, $username, 'custom_date_format', ''); $show_full_date = getPref($data_dir, $username, 'show_full_date', SMPREF_OFF); /* Allow user to customize length of from field */ diff --git a/include/options/display.php b/include/options/display.php index a5f1c777..85a0c299 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -286,6 +286,15 @@ function load_optpage_data_display() { 'refresh' => SMOPT_REFRESH_NONE ); + $optvals[SMOPT_GRP_MAILBOX][] = array( + 'name' => 'custom_date_format', + 'caption' => _("Custom Date Format"), + 'trailing_text' => ' ' . _("(Uses format of PHP date() function)"), + 'type' => SMOPT_TYPE_STRING, + 'refresh' => SMOPT_REFRESH_NONE, + 'size' => SMOPT_SIZE_TINY, + ); + $optvals[SMOPT_GRP_MAILBOX][] = array( 'name' => 'truncate_sender', 'caption' => _("Length of From/To Field (0 for full)"), -- 2.25.1