Birthdays are now transmitted reliably to Diaspora

This commit is contained in:
Michael 2018-01-23 22:51:30 +00:00
parent 6502cd6d66
commit 3fbc873ffe
6 changed files with 18 additions and 20 deletions

View file

@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Asparagus');
define('FRIENDICA_VERSION', '3.6-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
define('DB_UPDATE_VERSION', 1245);
define('DB_UPDATE_VERSION', 1246);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**

View file

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 3.6-dev (Asparagus)
-- DB_UPDATE_VERSION 1244
-- DB_UPDATE_VERSION 1246
-- ------------------------------------------
@ -781,7 +781,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`hide-friends` boolean NOT NULL DEFAULT '0' COMMENT '',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`pdesc` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`dob` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
`dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT '',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -1006,7 +1006,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`guid` varchar(64) NOT NULL DEFAULT '' COMMENT '',
`username` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`legacy_password` boolean NOT NULL DEFAULT 0 COMMENT 'Is the password hash double-hashed?',
`legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',

View file

@ -181,13 +181,13 @@ function dob($dob)
{
list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');
if ($dob <= '0001-01-01') {
if ($dob < '0000-01-01') {
$value = '';
} else {
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
$value = (($year > 1000) ? datetime_convert('UTC', 'UTC', $dob, 'Y-m-d') : datetime_convert('UTC', 'UTC', '1000-' . $month . '-'. $day, 'm-d'));
}
$age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
$age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
$o = replace_macros(get_markup_template("field_input.tpl"), [
'$field' => [
@ -200,12 +200,6 @@ function dob($dob)
]
]);
/// @TODO Old-lost code?
// if ($dob && $dob > '0001-01-01')
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year), 'dob');
// else
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob');
return $o;
}

View file

@ -201,7 +201,7 @@ function profiles_post(App $a) {
return;
}
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0001-01-01'; // FIXME: Needs to be validated?
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00';
$y = substr($dob, 0, 4);
if ((! ctype_digit($y)) || ($y < 1900)) {
@ -217,7 +217,7 @@ function profiles_post(App $a) {
$dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
if ($ignore_year) {
$dob = '0001-' . $dob;
$dob = '0000-' . $dob;
}
}

View file

@ -1472,7 +1472,7 @@ class DBStructure {
"hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"pdesc" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01", "comment" => ""],
"dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => ""],
"address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"locality" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"region" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],

View file

@ -4207,10 +4207,14 @@ class Diaspora
$searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false');
if ($searchable === 'true') {
$dob = '1000-00-00';
$dob = '';
if (($profile['dob']) && ($profile['dob'] > '0001-01-01')) {
$dob = ((intval($profile['dob'])) ? intval($profile['dob']) : '1000') .'-'. datetime_convert('UTC', 'UTC', $profile['dob'],'m-d');
if ($profile['dob'] && ($profile['dob'] > '0000-00-00')) {
list($year, $month, $day) = sscanf($profile['dob'], '%4d-%2d-%2d');
if ($year < 1004) {
$year = 1004;
}
$dob = datetime_convert('UTC', 'UTC', $year . '-' . $month . '-'. $day, 'Y-m-d');
}
$about = $profile['about'];
@ -4284,7 +4288,7 @@ class Diaspora
foreach ($recips as $recip) {
logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG);
self::buildAndTransmit($owner, $recip, "profile", $message, false, "", true);
self::buildAndTransmit($owner, $recip, "profile", $message, false, "", false);
}
}