diff --git a/boot.php b/boot.php index 2e83d371f6..219e3c466a 100644 --- a/boot.php +++ b/boot.php @@ -11,7 +11,7 @@ require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.0.1361' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1145 ); +define ( 'DB_UPDATE_VERSION', 1146 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 48900839c9..e32bca5ac6 100644 --- a/database.sql +++ b/database.sql @@ -823,6 +823,7 @@ CREATE TABLE IF NOT EXISTS `profile` ( `gender` char(32) NOT NULL, `marital` char(255) NOT NULL, `with` text NOT NULL, + `howlong` datetime NOT NULL default '0000-00-00 00:00:00', `sexual` char(255) NOT NULL, `politic` char(255) NOT NULL, `religion` char(255) NOT NULL, diff --git a/include/datetime.php b/include/datetime.php index f4dcfce62e..3b1491e4d8 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -244,7 +244,7 @@ function timesel($pre,$h,$m) { // Limited to range of timestamps if(! function_exists('relative_date')) { -function relative_date($posted_date) { +function relative_date($posted_date,$format = null) { $localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date); @@ -274,7 +274,9 @@ function relative_date($posted_date) { if ($d >= 1) { $r = round($d); // translators - e.g. 22 hours ago, 1 minute ago - return sprintf( t('%1$d %2$s ago'),$r, (($r == 1) ? $str[0] : $str[1])); + if(! $format) + $format = t('%1$d %2$s ago'); + return sprintf( $format,$r, (($r == 1) ? $str[0] : $str[1])); } } }} diff --git a/include/profile_advanced.php b/include/profile_advanced.php index 8c2acd8e76..2326ae7167 100644 --- a/include/profile_advanced.php +++ b/include/profile_advanced.php @@ -39,6 +39,9 @@ function advanced_profile(&$a) { if($a->profile['with']) $profile['marital']['with'] = $a->profile['with']; + if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') { + $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s')); + } if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] ); diff --git a/mod/profiles.php b/mod/profiles.php index ca3890eb94..e32fdb33db 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -62,9 +62,15 @@ function profiles_post(&$a) { $pub_keywords = notags(trim($_POST['pub_keywords'])); $prv_keywords = notags(trim($_POST['prv_keywords'])); $marital = notags(trim($_POST['marital'])); + $howlong = notags(trim($_POST['howlong'])); $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); + if(! strlen($howlong)) + $howlong = '0000-00-00 00:00:00'; + else + $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong); + // linkify the relationship target if applicable $withchanged = false; @@ -207,6 +213,7 @@ function profiles_post(&$a) { `country-name` = '%s', `marital` = '%s', `with` = '%s', + `howlong` = '%s', `sexual` = '%s', `homepage` = '%s', `politic` = '%s', @@ -237,6 +244,7 @@ function profiles_post(&$a) { dbesc($country_name), dbesc($marital), dbesc($with), + dbesc($howlong), dbesc($sexual), dbesc($homepage), dbesc($politic), @@ -558,6 +566,7 @@ function profiles_content(&$a) { '$lbl_marital' => t(' Marital Status:'), '$lbl_with' => t("Who: \x28if applicable\x29"), '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), + '$lbl_howlong' => t('Since [date]:'), '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_politic' => t('Political Views:'), @@ -595,6 +604,7 @@ function profiles_content(&$a) { '$gender' => gender_selector($r[0]['gender']), '$marital' => marital_selector($r[0]['marital']), '$with' => strip_tags($r[0]['with']), + '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])), '$sexual' => sexpref_selector($r[0]['sexual']), '$about' => $r[0]['about'], '$homepage' => $r[0]['homepage'], diff --git a/update.php b/update.php index f94b89fd31..3ac9d17211 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@
$profile.marital.0
-
$profile.marital.1 {{ if $profile.marital.with }}($profile.marital.with){{ endif }}
+
$profile.marital.1{{ if $profile.marital.with }} ($profile.marital.with){{ endif }}{{ if $profile.howlong }} $profile.howlong{{ endif }}
{{ endif }} diff --git a/view/profile_edit.tpl b/view/profile_edit.tpl index 2139fcf13c..077fb0aaa7 100644 --- a/view/profile_edit.tpl +++ b/view/profile_edit.tpl @@ -108,6 +108,9 @@ $marital + + +