mirror of
https://github.com/friendica/friendica
synced 2025-04-28 17:04:23 +02:00
Move Temporal::convert() to DateTimeFormat::convert()
This commit is contained in:
parent
b7a7355292
commit
5e7285b9ba
64 changed files with 568 additions and 551 deletions
|
@ -26,8 +26,8 @@ use Friendica\Model\User;
|
|||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
|
||||
|
@ -229,7 +229,7 @@ class DFRN
|
|||
}
|
||||
}
|
||||
|
||||
$check_date = Temporal::utc($last_update);
|
||||
$check_date = DateTimeFormat::utc($last_update);
|
||||
|
||||
$r = q(
|
||||
"SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
|
@ -421,7 +421,7 @@ class DFRN
|
|||
|
||||
XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
|
||||
XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
|
||||
XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::utc($item['created'] . '+00:00', Temporal::ATOM));
|
||||
XML::addElement($doc, $mail, "dfrn:sentdate", DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
|
||||
XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
|
||||
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
|
||||
|
||||
|
@ -587,7 +587,7 @@ class DFRN
|
|||
|
||||
/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
|
||||
|
||||
XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
|
||||
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
|
||||
|
||||
$author = self::addAuthor($doc, $owner, $authorelement, $public);
|
||||
$root->appendChild($author);
|
||||
|
@ -622,9 +622,9 @@ class DFRN
|
|||
|
||||
$author = $doc->createElement($authorelement);
|
||||
|
||||
$namdate = Temporal::utc($owner['name-date'].'+00:00', Temporal::ATOM);
|
||||
$uridate = Temporal::utc($owner['uri-date'].'+00:00', Temporal::ATOM);
|
||||
$picdate = Temporal::utc($owner['avatar-date'].'+00:00', Temporal::ATOM);
|
||||
$namdate = DateTimeFormat::utc($owner['name-date'].'+00:00', DateTimeFormat::ATOM);
|
||||
$uridate = DateTimeFormat::utc($owner['uri-date'].'+00:00', DateTimeFormat::ATOM);
|
||||
$picdate = DateTimeFormat::utc($owner['avatar-date'].'+00:00', DateTimeFormat::ATOM);
|
||||
|
||||
$attributes = [];
|
||||
|
||||
|
@ -903,7 +903,7 @@ class DFRN
|
|||
}
|
||||
|
||||
if ($item['deleted']) {
|
||||
$attributes = ["ref" => $item['uri'], "when" => Temporal::utc($item['edited'] . '+00:00', Temporal::ATOM)];
|
||||
$attributes = ["ref" => $item['uri'], "when" => DateTimeFormat::utc($item['edited'] . '+00:00', DateTimeFormat::ATOM)];
|
||||
return XML::createElement($doc, "at:deleted-entry", "", $attributes);
|
||||
}
|
||||
|
||||
|
@ -983,8 +983,8 @@ class DFRN
|
|||
XML::addElement($doc, $entry, "id", $item["uri"]);
|
||||
XML::addElement($doc, $entry, "title", $item["title"]);
|
||||
|
||||
XML::addElement($doc, $entry, "published", Temporal::utc($item["created"] . "+00:00", Temporal::ATOM));
|
||||
XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"] . "+00:00", Temporal::ATOM));
|
||||
XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"] . "+00:00", DateTimeFormat::ATOM));
|
||||
XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"] . "+00:00", DateTimeFormat::ATOM));
|
||||
|
||||
// "dfrn:env" is used to read the content
|
||||
XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
|
||||
|
@ -1388,7 +1388,7 @@ class DFRN
|
|||
"SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
|
||||
intval($contact["uid"]),
|
||||
intval($contact["id"]),
|
||||
dbesc(Temporal::utc($birthday)),
|
||||
dbesc(DateTimeFormat::utc($birthday)),
|
||||
dbesc("birthday")
|
||||
);
|
||||
|
||||
|
@ -1406,10 +1406,10 @@ class DFRN
|
|||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
|
||||
intval($contact["uid"]),
|
||||
intval($contact["id"]),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(Temporal::utc($birthday)),
|
||||
dbesc(Temporal::utc($birthday . " + 1 day ")),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc(DateTimeFormat::utc($birthday)),
|
||||
dbesc(DateTimeFormat::utc($birthday . " + 1 day ")),
|
||||
dbesc($bdtext),
|
||||
dbesc($bdtext2),
|
||||
dbesc("birthday")
|
||||
|
@ -1889,7 +1889,7 @@ class DFRN
|
|||
intval($suggest["cid"]),
|
||||
dbesc($suggest["body"]),
|
||||
dbesc($hash),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
intval(0)
|
||||
);
|
||||
|
||||
|
@ -2081,13 +2081,13 @@ class DFRN
|
|||
|
||||
if (self::isEditedTimestampNewer($current, $item)) {
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if (Temporal::utc($item["edited"]) < $current["edited"]) {
|
||||
if (DateTimeFormat::utc($item["edited"]) < $current["edited"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = ['title' => $item["title"], 'body' => $item["body"],
|
||||
'tag' => $item["tag"], 'changed' => Temporal::utcNow(),
|
||||
'edited' => Temporal::utc($item["edited"])];
|
||||
'tag' => $item["tag"], 'changed' => DateTimeFormat::utcNow(),
|
||||
'edited' => DateTimeFormat::utc($item["edited"])];
|
||||
|
||||
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
|
||||
dba::update('item', $fields, $condition);
|
||||
|
@ -2422,7 +2422,7 @@ class DFRN
|
|||
|
||||
// Is there an existing item?
|
||||
if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
|
||||
&& (Temporal::utc($item["edited"]) < $current[0]["edited"])
|
||||
&& (DateTimeFormat::utc($item["edited"]) < $current[0]["edited"])
|
||||
) {
|
||||
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
|
||||
return;
|
||||
|
@ -2753,9 +2753,9 @@ class DFRN
|
|||
}
|
||||
}
|
||||
if ($when) {
|
||||
$when = Temporal::utc($when);
|
||||
$when = DateTimeFormat::utc($when);
|
||||
} else {
|
||||
$when = Temporal::utcNow();
|
||||
$when = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
if (!$uri || !$importer["id"]) {
|
||||
|
@ -2836,7 +2836,7 @@ class DFRN
|
|||
`body` = '', `title` = ''
|
||||
WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
|
||||
dbesc($when),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc($uri),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
|
@ -2849,7 +2849,7 @@ class DFRN
|
|||
`body` = '', `title` = ''
|
||||
WHERE `uri` = '%s' AND `uid` IN (0, %d)",
|
||||
dbesc($when),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc($uri),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
|
@ -3157,8 +3157,8 @@ class DFRN
|
|||
return false;
|
||||
}
|
||||
|
||||
$existing_edited = Temporal::utc($existing['edited']);
|
||||
$update_edited = Temporal::utc($update['edited']);
|
||||
$existing_edited = DateTimeFormat::utc($existing['edited']);
|
||||
$update_edited = DateTimeFormat::utc($update['edited']);
|
||||
|
||||
return (strcmp($existing_edited, $update_edited) < 0);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
*/
|
||||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -26,8 +25,8 @@ use Friendica\Model\Queue;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
use SimpleXMLElement;
|
||||
|
@ -77,7 +76,7 @@ class Diaspora
|
|||
$r = q(
|
||||
"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`)
|
||||
VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
|
||||
Temporal::utcNow(),
|
||||
DateTimeFormat::utcNow(),
|
||||
dbesc($addr),
|
||||
dbesc($addr),
|
||||
dbesc($server),
|
||||
|
@ -85,9 +84,9 @@ class Diaspora
|
|||
dbesc($batch),
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval(CONTACT_IS_FOLLOWER),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(Temporal::utcNow())
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow())
|
||||
);
|
||||
|
||||
$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
|
||||
|
@ -871,7 +870,7 @@ class Diaspora
|
|||
dbesc($arr["confirm"]),
|
||||
dbesc($arr["alias"]),
|
||||
dbesc($arr["pubkey"]),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc($arr["url"]),
|
||||
dbesc($arr["network"])
|
||||
);
|
||||
|
@ -894,7 +893,7 @@ class Diaspora
|
|||
dbesc($arr["network"]),
|
||||
dbesc($arr["alias"]),
|
||||
dbesc($arr["pubkey"]),
|
||||
dbesc(Temporal::utcNow())
|
||||
dbesc(DateTimeFormat::utcNow())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1654,9 +1653,9 @@ class Diaspora
|
|||
$text = unxmlify($data->text);
|
||||
|
||||
if (isset($data->created_at)) {
|
||||
$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
|
||||
$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
|
||||
} else {
|
||||
$created_at = Temporal::utcNow();
|
||||
$created_at = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
if (isset($data->thread_parent_guid)) {
|
||||
|
@ -1786,7 +1785,7 @@ class Diaspora
|
|||
$msg_guid = notags(unxmlify($mesg->guid));
|
||||
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
|
||||
$msg_text = unxmlify($mesg->text);
|
||||
$msg_created_at = Temporal::utc(notags(unxmlify($mesg->created_at)));
|
||||
$msg_created_at = DateTimeFormat::utc(notags(unxmlify($mesg->created_at)));
|
||||
|
||||
if ($msg_conversation_guid != $guid) {
|
||||
logger("message conversation guid does not belong to the current conversation.");
|
||||
|
@ -1831,7 +1830,7 @@ class Diaspora
|
|||
|
||||
dba::unlock();
|
||||
|
||||
dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
|
||||
dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||
|
||||
notification(
|
||||
[
|
||||
|
@ -1865,7 +1864,7 @@ class Diaspora
|
|||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$subject = notags(unxmlify($data->subject));
|
||||
$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
|
||||
$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
|
||||
$participants = notags(unxmlify($data->participants));
|
||||
|
||||
$messages = $data->message;
|
||||
|
@ -1897,7 +1896,7 @@ class Diaspora
|
|||
dbesc($guid),
|
||||
dbesc($author),
|
||||
dbesc($created_at),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc($subject),
|
||||
dbesc($participants)
|
||||
);
|
||||
|
@ -2098,7 +2097,7 @@ class Diaspora
|
|||
$guid = notags(unxmlify($data->guid));
|
||||
$conversation_guid = notags(unxmlify($data->conversation_guid));
|
||||
$text = unxmlify($data->text);
|
||||
$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
|
||||
$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
|
||||
|
||||
$contact = self::allowedContactByHandle($importer, $author, true);
|
||||
if (!$contact) {
|
||||
|
@ -2164,7 +2163,7 @@ class Diaspora
|
|||
|
||||
dba::unlock();
|
||||
|
||||
dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
|
||||
dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2315,7 +2314,7 @@ class Diaspora
|
|||
$birthday = str_replace("1000", "1901", $birthday);
|
||||
|
||||
if ($birthday != "") {
|
||||
$birthday = Temporal::utc($birthday, "Y-m-d");
|
||||
$birthday = DateTimeFormat::utc($birthday, "Y-m-d");
|
||||
}
|
||||
|
||||
// this is to prevent multiple birthday notifications in a single year
|
||||
|
@ -2331,7 +2330,7 @@ class Diaspora
|
|||
dbesc($name),
|
||||
dbesc($nick),
|
||||
dbesc($author),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc($birthday),
|
||||
dbesc($location),
|
||||
dbesc($about),
|
||||
|
@ -2537,7 +2536,7 @@ class Diaspora
|
|||
intval($importer["uid"]),
|
||||
dbesc($ret["network"]),
|
||||
dbesc($ret["addr"]),
|
||||
Temporal::utcNow(),
|
||||
DateTimeFormat::utcNow(),
|
||||
dbesc($ret["url"]),
|
||||
dbesc(normalise_link($ret["url"])),
|
||||
dbesc($batch),
|
||||
|
@ -2580,7 +2579,7 @@ class Diaspora
|
|||
0,
|
||||
dbesc(L10n::t("Sharing notification from Diaspora network")),
|
||||
dbesc($hash),
|
||||
dbesc(Temporal::utcNow())
|
||||
dbesc(DateTimeFormat::utcNow())
|
||||
);
|
||||
} else {
|
||||
// automatic friend approval
|
||||
|
@ -2611,8 +2610,8 @@ class Diaspora
|
|||
WHERE `id` = %d
|
||||
",
|
||||
intval($new_relation),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(Temporal::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
dbesc(DateTimeFormat::utcNow()),
|
||||
intval($contact_record["id"])
|
||||
);
|
||||
|
||||
|
@ -2716,7 +2715,7 @@ class Diaspora
|
|||
{
|
||||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
|
||||
$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
|
||||
$root_author = notags(unxmlify($data->root_author));
|
||||
$root_guid = notags(unxmlify($data->root_guid));
|
||||
/// @todo handle unprocessed property "provider_display_name"
|
||||
|
@ -2852,8 +2851,8 @@ class Diaspora
|
|||
'deleted' => true,
|
||||
'title' => '',
|
||||
'body' => '',
|
||||
'edited' => Temporal::utcNow(),
|
||||
'changed' => Temporal::utcNow()],
|
||||
'edited' => DateTimeFormat::utcNow(),
|
||||
'changed' => DateTimeFormat::utcNow()],
|
||||
['id' => $item["id"]]
|
||||
);
|
||||
|
||||
|
@ -2930,7 +2929,7 @@ class Diaspora
|
|||
{
|
||||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
|
||||
$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
|
||||
$public = notags(unxmlify($data->public));
|
||||
$text = unxmlify($data->text);
|
||||
$provider_display_name = notags(unxmlify($data->provider_display_name));
|
||||
|
@ -3593,7 +3592,7 @@ class Diaspora
|
|||
$eventdata['guid'] = $event['guid'];
|
||||
}
|
||||
|
||||
$mask = Temporal::ATOM;
|
||||
$mask = DateTimeFormat::ATOM;
|
||||
|
||||
/// @todo - establish "all day" events in Friendica
|
||||
$eventdata["all_day"] = "false";
|
||||
|
@ -3607,10 +3606,10 @@ class Diaspora
|
|||
}
|
||||
|
||||
if ($event['start']) {
|
||||
$eventdata['start'] = Temporal::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
|
||||
$eventdata['start'] = DateTimeFormat::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
|
||||
}
|
||||
if ($event['finish'] && !$event['nofinish']) {
|
||||
$eventdata['end'] = Temporal::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
|
||||
$eventdata['end'] = DateTimeFormat::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
|
||||
}
|
||||
if ($event['summary']) {
|
||||
$eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary']));
|
||||
|
@ -3652,7 +3651,7 @@ class Diaspora
|
|||
|
||||
$public = (($item["private"]) ? "false" : "true");
|
||||
|
||||
$created = Temporal::utc($item["created"], Temporal::ATOM);
|
||||
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
|
||||
|
||||
// Detect a share element and do a reshare
|
||||
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
|
||||
|
@ -3855,7 +3854,7 @@ class Diaspora
|
|||
$parent = $p[0];
|
||||
|
||||
$text = html_entity_decode(bb2diaspora($item["body"]));
|
||||
$created = Temporal::utc($item["created"], Temporal::ATOM);
|
||||
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
|
||||
|
||||
$comment = ["author" => self::myHandle($owner),
|
||||
"guid" => $item["guid"],
|
||||
|
@ -4086,12 +4085,12 @@ class Diaspora
|
|||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
|
||||
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
"participants" => $cnv["recips"]
|
||||
];
|
||||
|
||||
$body = bb2diaspora($item["body"]);
|
||||
$created = Temporal::utc($item["created"], Temporal::ATOM);
|
||||
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
|
||||
|
||||
$msg = [
|
||||
"author" => $myaddr,
|
||||
|
@ -4109,7 +4108,7 @@ class Diaspora
|
|||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
|
||||
"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
"participants" => $cnv["recips"],
|
||||
"message" => $msg];
|
||||
|
||||
|
@ -4217,7 +4216,7 @@ class Diaspora
|
|||
if ($year < 1004) {
|
||||
$year = 1004;
|
||||
}
|
||||
$dob = Temporal::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
|
||||
$dob = DateTimeFormat::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
|
||||
}
|
||||
|
||||
$about = $profile['about'];
|
||||
|
|
|
@ -16,9 +16,9 @@ use Friendica\Model\GContact;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Lock;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
|
@ -199,7 +199,7 @@ class OStatus
|
|||
$contact["location"] = $value;
|
||||
}
|
||||
|
||||
$contact['name-date'] = Temporal::utcNow();
|
||||
$contact['name-date'] = DateTimeFormat::utcNow();
|
||||
|
||||
dba::update('contact', $contact, ['id' => $contact["id"]], $current);
|
||||
|
||||
|
@ -220,7 +220,7 @@ class OStatus
|
|||
'nurl' => normalise_link($author["author-link"]),
|
||||
'nick' => $contact["nick"], 'alias' => $contact["alias"],
|
||||
'about' => $contact["about"], 'location' => $contact["location"],
|
||||
'success_update' => Temporal::utcNow(), 'last-update' => Temporal::utcNow()];
|
||||
'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
|
||||
|
||||
dba::update('contact', $fields, ['id' => $cid], $old_contact);
|
||||
|
||||
|
@ -558,7 +558,7 @@ class OStatus
|
|||
dba::update(
|
||||
'item',
|
||||
['deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
|
||||
'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
|
||||
['id' => $deleted["id"]]
|
||||
);
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ class OStatus
|
|||
XML::addElement($doc, $root, "title", $title);
|
||||
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
|
||||
XML::addElement($doc, $root, "logo", $owner["photo"]);
|
||||
XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
|
||||
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
|
||||
|
||||
$author = self::addAuthor($doc, $owner);
|
||||
$root->appendChild($author);
|
||||
|
@ -1539,7 +1539,7 @@ class OStatus
|
|||
XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
|
||||
XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
|
||||
XML::addElement($doc, $source, "icon", $contact["photo"]);
|
||||
XML::addElement($doc, $source, "updated", Temporal::utc($contact["success_update"]."+00:00", Temporal::ATOM));
|
||||
XML::addElement($doc, $source, "updated", DateTimeFormat::utc($contact["success_update"]."+00:00", DateTimeFormat::ATOM));
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
@ -1923,8 +1923,8 @@ class OStatus
|
|||
|
||||
XML::addElement($doc, $entry, "activity:verb", $verb);
|
||||
|
||||
XML::addElement($doc, $entry, "published", Temporal::utc($item["created"]."+00:00", Temporal::ATOM));
|
||||
XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"]."+00:00", Temporal::ATOM));
|
||||
XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM));
|
||||
XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2127,7 +2127,7 @@ class OStatus
|
|||
$last_update = 'now -30 days';
|
||||
}
|
||||
|
||||
$check_date = Temporal::utc($last_update);
|
||||
$check_date = DateTimeFormat::utc($last_update);
|
||||
$authorid = Contact::getIdForURL($owner["url"], 0);
|
||||
|
||||
$sql_extra = '';
|
||||
|
|
|
@ -15,8 +15,8 @@ use Friendica\Database\DBM;
|
|||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
|
@ -144,7 +144,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (isset($entry->updated)) {
|
||||
$updated = date(Temporal::MYSQL, strtotime($entry->updated));
|
||||
$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
|
||||
}
|
||||
|
||||
if (isset($entry->network)) {
|
||||
|
@ -315,7 +315,7 @@ class PortableContact
|
|||
$contact = ["url" => $profile];
|
||||
|
||||
if ($gcontacts[0]["created"] <= NULL_DATE) {
|
||||
$contact['created'] = Temporal::utcNow();
|
||||
$contact['created'] = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
if ($force) {
|
||||
|
@ -338,7 +338,7 @@ class PortableContact
|
|||
if ($server_url != "") {
|
||||
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if ($force) {
|
||||
$fields = ['last_failure' => Temporal::utcNow()];
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
}
|
||||
|
||||
|
@ -412,14 +412,14 @@ class PortableContact
|
|||
|
||||
// Set the date of the last contact
|
||||
/// @todo By now the function "update_gcontact" doesn't work with this field
|
||||
//$contact["last_contact"] = Temporal::utcNow();
|
||||
//$contact["last_contact"] = DateTimeFormat::utcNow();
|
||||
|
||||
$contact = array_merge($contact, $noscrape);
|
||||
|
||||
GContact::update($contact);
|
||||
|
||||
if (trim($noscrape["updated"]) != "") {
|
||||
$fields = ['last_contact' => Temporal::utcNow()];
|
||||
$fields = ['last_contact' => DateTimeFormat::utcNow()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
|
||||
|
@ -468,7 +468,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
|
||||
$fields = ['last_failure' => Temporal::utcNow()];
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
|
||||
|
@ -484,7 +484,7 @@ class PortableContact
|
|||
$feedret = Network::curl($data["poll"]);
|
||||
|
||||
if (!$feedret["success"]) {
|
||||
$fields = ['last_failure' => Temporal::utcNow()];
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
|
||||
|
@ -533,7 +533,7 @@ class PortableContact
|
|||
|
||||
public static function updateNeeded($created, $updated, $last_failure, $last_contact)
|
||||
{
|
||||
$now = strtotime(Temporal::utcNow());
|
||||
$now = strtotime(DateTimeFormat::utcNow());
|
||||
|
||||
if ($updated > $last_contact) {
|
||||
$contact_time = strtotime($updated);
|
||||
|
@ -922,7 +922,7 @@ class PortableContact
|
|||
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($gserver)) {
|
||||
if ($gserver["created"] <= NULL_DATE) {
|
||||
$fields = ['created' => Temporal::utcNow()];
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$condition = ['nurl' => normalise_link($server_url)];
|
||||
dba::update('gserver', $fields, $condition);
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ class PortableContact
|
|||
// Mastodon uses the "@" for user profiles.
|
||||
// But this can be misunderstood.
|
||||
if (parse_url($server_url, PHP_URL_USER) != '') {
|
||||
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -985,7 +985,7 @@ class PortableContact
|
|||
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
|
||||
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ class PortableContact
|
|||
// Quit if there is a timeout
|
||||
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1332,9 +1332,9 @@ class PortableContact
|
|||
|
||||
if ($failure) {
|
||||
$last_contact = $orig_last_contact;
|
||||
$last_failure = Temporal::utcNow();
|
||||
$last_failure = DateTimeFormat::utcNow();
|
||||
} else {
|
||||
$last_contact = Temporal::utcNow();
|
||||
$last_contact = DateTimeFormat::utcNow();
|
||||
$last_failure = $orig_last_failure;
|
||||
}
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ class PortableContact
|
|||
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
|
||||
} elseif (!$failure) {
|
||||
$fields['nurl'] = normalise_link($server_url);
|
||||
$fields['created'] = Temporal::utcNow();
|
||||
$fields['created'] = DateTimeFormat::utcNow();
|
||||
dba::insert('gserver', $fields);
|
||||
}
|
||||
logger("End discovery for server " . $server_url, LOGGER_DEBUG);
|
||||
|
@ -1507,7 +1507,7 @@ class PortableContact
|
|||
$timeframe = 30;
|
||||
}
|
||||
|
||||
$updatedSince = date(Temporal::MYSQL, time() - $timeframe * 86400);
|
||||
$updatedSince = date(DateTimeFormat::MYSQL, time() - $timeframe * 86400);
|
||||
|
||||
// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
|
||||
$url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
||||
|
@ -1526,7 +1526,7 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
$fields = ['last_poco_query' => Temporal::utcNow()];
|
||||
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return true;
|
||||
|
@ -1535,7 +1535,7 @@ class PortableContact
|
|||
self::checkServer($server["url"], $server["network"], true);
|
||||
|
||||
// If we couldn't reach the server, we will try it some time later
|
||||
$fields = ['last_poco_query' => Temporal::utcNow()];
|
||||
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return false;
|
||||
|
@ -1561,7 +1561,7 @@ class PortableContact
|
|||
foreach ($r as $server) {
|
||||
if (!self::checkServer($server["url"], $server["network"])) {
|
||||
// The server is not reachable? Okay, then we will try it later
|
||||
$fields = ['last_poco_query' => Temporal::utcNow()];
|
||||
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
continue;
|
||||
}
|
||||
|
@ -1654,7 +1654,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (isset($entry->updated)) {
|
||||
$updated = date(Temporal::MYSQL, strtotime($entry->updated));
|
||||
$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
|
||||
}
|
||||
|
||||
if (isset($entry->network)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue