"howlong" added to marital status.

This commit is contained in:
friendica 2012-06-02 02:30:26 -07:00
parent 29bdf432f0
commit 608d424b0b
8 changed files with 33 additions and 5 deletions

View File

@ -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', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View File

@ -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,

View File

@ -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]));
}
}
}}

View File

@ -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'] );

View File

@ -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('<span class="heart">&hearts;</span> 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'],

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1145 );
define( 'UPDATE_VERSION' , 1146 );
/**
*
@ -1259,3 +1259,12 @@ function update_1144() {
return UPDATE_FAILED ;
return UPDATE_SUCCESS ;
}
function update_1145() {
$r = q("alter table profile add howlong datetime not null default '0000-00-00 00:00:00' after `with`");
if(! $r)
return UPDATE_FAILED ;
return UPDATE_SUCCESS ;
}

View File

@ -29,7 +29,7 @@
{{ if $profile.marital }}
<dl id="aprofile-marital" class="aprofile">
<dt><span class="heart">&hearts;</span> $profile.marital.0</dt>
<dd>$profile.marital.1 {{ if $profile.marital.with }}($profile.marital.with){{ endif }}</dd>
<dd>$profile.marital.1{{ if $profile.marital.with }} ($profile.marital.with){{ endif }}{{ if $profile.howlong }} $profile.howlong{{ endif }}</dd>
</dl>
{{ endif }}

View File

@ -108,6 +108,9 @@ $marital
</div>
<label id="profile-edit-with-label" for="profile-edit-with" > $lbl_with </label>
<input type="text" size="32" name="with" id="profile-edit-with" title="$lbl_ex1" value="$with" />
<label id="profile-edit-howlong-label" for="profile-edit-howlong" > $lbl_howlong </label>
<input type="text" size="32" name="howlong" id="profile-edit-howlong" title="$lbl_howlong" value="$howlong" />
<div id="profile-edit-marital-end"></div>
<div id="profile-edit-sexual-wrapper" >