Merge remote-tracking branch 'upstream/3.6-rc' into url-shorten-ostatus
This commit is contained in:
commit
318de2f590
31 changed files with 7673 additions and 7386 deletions
|
@ -1598,8 +1598,8 @@ class BBCode
|
|||
if (strpos($text, '[/map]') !== false) {
|
||||
$text = preg_replace_callback(
|
||||
"/\[map\](.*?)\[\/map\]/ism",
|
||||
function ($match) {
|
||||
return str_replace($match[0], '<p class="map">' . Map::byLocation($match[1]) . '</p>', $match[0]);
|
||||
function ($match) use ($simple_html) {
|
||||
return str_replace($match[0], '<p class="map">' . Map::byLocation($match[1], $simple_html) . '</p>', $match[0]);
|
||||
},
|
||||
$text
|
||||
);
|
||||
|
@ -1607,14 +1607,14 @@ class BBCode
|
|||
if (strpos($text, '[map=') !== false) {
|
||||
$text = preg_replace_callback(
|
||||
"/\[map=(.*?)\]/ism",
|
||||
function ($match) {
|
||||
return str_replace($match[0], '<p class="map">' . Map::byCoordinates(str_replace('/', ' ', $match[1])) . '</p>', $match[0]);
|
||||
function ($match) use ($simple_html) {
|
||||
return str_replace($match[0], '<p class="map">' . Map::byCoordinates(str_replace('/', ' ', $match[1]), $simple_html) . '</p>', $match[0]);
|
||||
},
|
||||
$text
|
||||
);
|
||||
}
|
||||
if (strpos($text, '[map]') !== false) {
|
||||
$text = preg_replace("/\[map\]/", '<div class="map"></div>', $text);
|
||||
$text = preg_replace("/\[map\]/", '<p class="map"></p>', $text);
|
||||
}
|
||||
|
||||
// Check for headers
|
||||
|
|
|
@ -199,12 +199,13 @@ class DBStructure
|
|||
*
|
||||
* @param bool $verbose
|
||||
* @param bool $action Whether to actually apply the update
|
||||
* @param bool $install Is this the initial update during the installation?
|
||||
* @param array $tables An array of the database tables
|
||||
* @param array $definition An array of the definition tables
|
||||
* @return string Empty string if the update is successful, error messages otherwise
|
||||
*/
|
||||
public static function update($verbose, $action, array $tables = null, array $definition = null) {
|
||||
if ($action) {
|
||||
public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
|
||||
if ($action && !$install) {
|
||||
Config::set('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
|
||||
}
|
||||
|
@ -455,7 +456,9 @@ class DBStructure
|
|||
}
|
||||
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
|
||||
if (!$install) {
|
||||
Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
|
||||
}
|
||||
|
||||
// Ensure index conversion to unique removes duplicates
|
||||
if ($is_unique && ($temp_name != $name)) {
|
||||
|
@ -505,15 +508,15 @@ class DBStructure
|
|||
}
|
||||
}
|
||||
|
||||
if ($action) {
|
||||
if ($action && !$install) {
|
||||
Config::set('system', 'maintenance', 0);
|
||||
Config::set('system', 'maintenance_reason', '');
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
|
||||
} else {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
|
||||
if ($errors) {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
|
||||
} else {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
|
|
|
@ -514,7 +514,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
$sparkle = false;
|
||||
if ($contact['network'] === NETWORK_DFRN) {
|
||||
if (($contact['network'] === NETWORK_DFRN) && !$contact['self']) {
|
||||
$sparkle = true;
|
||||
$profile_link = System::baseUrl() . '/redir/' . $contact['id'];
|
||||
} else {
|
||||
|
@ -531,18 +531,21 @@ class Contact extends BaseObject
|
|||
$profile_link = $profile_link . '?url=profile';
|
||||
}
|
||||
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA]) && !$contact['self']) {
|
||||
$pm_url = System::baseUrl() . '/message/new/' . $contact['id'];
|
||||
}
|
||||
|
||||
if ($contact['network'] == NETWORK_DFRN) {
|
||||
if (($contact['network'] == NETWORK_DFRN) && !$contact['self']) {
|
||||
$poke_link = System::baseUrl() . '/poke/?f=&c=' . $contact['id'];
|
||||
}
|
||||
|
||||
$contact_url = System::baseUrl() . '/contacts/' . $contact['id'];
|
||||
|
||||
$posts_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/posts';
|
||||
$contact_drop_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
|
||||
if (!$contact['self']) {
|
||||
$contact_drop_link = System::baseUrl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu array:
|
||||
|
|
|
@ -37,56 +37,53 @@ class GContact
|
|||
*/
|
||||
public static function searchByName($search, $mode = '')
|
||||
{
|
||||
if ($search) {
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$diaspora = NETWORK_DIASPORA;
|
||||
} else {
|
||||
$diaspora = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$ostatus = NETWORK_OSTATUS;
|
||||
} else {
|
||||
$ostatus = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
// check if we search only communities or every contact
|
||||
if ($mode === "community") {
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$search .= "%";
|
||||
|
||||
$results = q(
|
||||
"SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
|
||||
`gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
|
||||
FROM `gcontact`
|
||||
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
|
||||
AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
|
||||
WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
|
||||
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
|
||||
(`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
|
||||
(`gcontact`.`addr` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR `gcontact`.`nick` LIKE '%s') $extra_sql
|
||||
GROUP BY `gcontact`.`nurl`
|
||||
ORDER BY `gcontact`.`nurl` DESC
|
||||
LIMIT 1000",
|
||||
intval(local_user()),
|
||||
dbesc(CONTACT_IS_SHARING),
|
||||
dbesc(CONTACT_IS_FRIEND),
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc($ostatus),
|
||||
dbesc($diaspora),
|
||||
dbesc(escape_tags($search)),
|
||||
dbesc(escape_tags($search)),
|
||||
dbesc(escape_tags($search))
|
||||
);
|
||||
|
||||
return $results;
|
||||
if (empty($search)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$diaspora = NETWORK_DIASPORA;
|
||||
} else {
|
||||
$diaspora = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$ostatus = NETWORK_OSTATUS;
|
||||
} else {
|
||||
$ostatus = NETWORK_DFRN;
|
||||
}
|
||||
|
||||
// check if we search only communities or every contact
|
||||
if ($mode === "community") {
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$search .= "%";
|
||||
|
||||
$results = dba::p("SELECT `nurl` FROM `gcontact`
|
||||
WHERE NOT `hide` AND `network` IN (?, ?, ?) AND
|
||||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
|
||||
GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
|
||||
NETWORK_DFRN, $ostatus, $diaspora, $search, $search, $search
|
||||
);
|
||||
|
||||
$gcontacts = [];
|
||||
while ($result = dba::fetch($results)) {
|
||||
$urlparts = parse_url($result["nurl"]);
|
||||
|
||||
// Ignore results that look strange.
|
||||
// For historic reasons the gcontact table does contain some garbage.
|
||||
if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$gcontacts[] = Contact::getDetailsByURL($result["nurl"], local_user());
|
||||
}
|
||||
return $gcontacts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -356,6 +356,10 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($item['thr-parent'])) {
|
||||
$item['parent-uri'] = $item['thr-parent'];
|
||||
}
|
||||
|
||||
if (x($item, 'gravity')) {
|
||||
$item['gravity'] = intval($item['gravity']);
|
||||
} elseif ($item['parent-uri'] === $item['uri']) {
|
||||
|
|
|
@ -2079,8 +2079,8 @@ class DFRN
|
|||
return false;
|
||||
}
|
||||
|
||||
$fields = ['title' => $item["title"], 'body' => $item["body"],
|
||||
'tag' => $item["tag"], 'changed' => DateTimeFormat::utcNow(),
|
||||
$fields = ['title' => defaults($item, 'title', ''), 'body' => defaults($item, 'body', ''),
|
||||
'tag' => defaults($item, 'tag', ''), 'changed' => DateTimeFormat::utcNow(),
|
||||
'edited' => DateTimeFormat::utc($item["edited"])];
|
||||
|
||||
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
|
||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Util\Crypto;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Util\Map;
|
||||
use dba;
|
||||
use SimpleXMLElement;
|
||||
|
||||
|
@ -3217,13 +3218,14 @@ class Diaspora
|
|||
}
|
||||
|
||||
$logid = random_string(4);
|
||||
$dest_url = ($public_batch ? $contact["batch"] : $contact["notify"]);
|
||||
|
||||
// Fetch the fcontact entry when there is missing data
|
||||
// Will possibly happen when data is transmitted to a DFRN contact
|
||||
if (empty($dest_url) && !empty($contact['addr'])) {
|
||||
// We always try to use the data from the fcontact table.
|
||||
// This is important for transmitting data to Friendica servers.
|
||||
if (!empty($contact['addr'])) {
|
||||
$fcontact = self::personByHandle($contact['addr']);
|
||||
$dest_url = ($public_batch ? $fcontact["batch"] : $fcontact["notify"]);
|
||||
} else {
|
||||
$dest_url = ($public_batch ? $contact["batch"] : $contact["notify"]);
|
||||
}
|
||||
|
||||
if (!$dest_url) {
|
||||
|
@ -3617,10 +3619,18 @@ class Diaspora
|
|||
$eventdata['description'] = html_entity_decode(bb2diaspora($event['desc']));
|
||||
}
|
||||
if ($event['location']) {
|
||||
$event['location'] = preg_replace("/\[map\](.*?)\[\/map\]/ism", '$1', $event['location']);
|
||||
$coord = Map::getCoordinates($event['location']);
|
||||
|
||||
$location = [];
|
||||
$location["address"] = html_entity_decode(bb2diaspora($event['location']));
|
||||
$location["lat"] = 0;
|
||||
$location["lng"] = 0;
|
||||
if (!empty($coord['lat']) && !empty($coord['lon'])) {
|
||||
$location["lat"] = $coord['lat'];
|
||||
$location["lng"] = $coord['lon'];
|
||||
} else {
|
||||
$location["lat"] = 0;
|
||||
$location["lng"] = 0;
|
||||
}
|
||||
$eventdata['location'] = $location;
|
||||
}
|
||||
|
||||
|
@ -3714,7 +3724,13 @@ class Diaspora
|
|||
if (count($event)) {
|
||||
$message['event'] = $event;
|
||||
|
||||
/// @todo Once Diaspora supports it, we will remove the body
|
||||
if (!empty($event['location']['address']) &&
|
||||
!empty($event['location']['lat']) &&
|
||||
!empty($event['location']['lng'])) {
|
||||
$message['location'] = $event['location'];
|
||||
}
|
||||
|
||||
/// @todo Once Diaspora supports it, we will remove the body and the location hack above
|
||||
// $message['text'] = '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1288,6 +1288,13 @@ class OStatus
|
|||
"rel" => "self", "type" => "application/atom+xml"];
|
||||
XML::addElement($doc, $root, "link", "", $attributes);
|
||||
|
||||
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
||||
$condition = ['uid' => $owner['uid'], 'self' => false, 'pending' => false,
|
||||
'archive' => false, 'hidden' => false, 'blocked' => false];
|
||||
$members = dba::count('contact', $condition);
|
||||
XML::addElement($doc, $root, "statusnet:group_info", "", ["member_count" => $members]);
|
||||
}
|
||||
|
||||
return $root;
|
||||
}
|
||||
|
||||
|
@ -1379,16 +1386,22 @@ class OStatus
|
|||
*
|
||||
* @return object author element
|
||||
*/
|
||||
private static function addAuthor($doc, $owner)
|
||||
private static function addAuthor($doc, $owner, $show_profile = true)
|
||||
{
|
||||
$profile = dba::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
|
||||
$author = $doc->createElement("author");
|
||||
XML::addElement($doc, $author, "id", $owner["url"]);
|
||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_GROUP);
|
||||
} else {
|
||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
}
|
||||
XML::addElement($doc, $author, "uri", $owner["url"]);
|
||||
XML::addElement($doc, $author, "name", $owner["nick"]);
|
||||
XML::addElement($doc, $author, "email", $owner["addr"]);
|
||||
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
|
||||
if ($show_profile) {
|
||||
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
|
||||
}
|
||||
|
||||
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
|
||||
XML::addElement($doc, $author, "link", "", $attributes);
|
||||
|
@ -1413,15 +1426,17 @@ class OStatus
|
|||
|
||||
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
|
||||
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
|
||||
XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
|
||||
if ($show_profile) {
|
||||
XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
|
||||
|
||||
if (trim($owner["location"]) != "") {
|
||||
$element = $doc->createElement("poco:address");
|
||||
XML::addElement($doc, $element, "poco:formatted", $owner["location"]);
|
||||
$author->appendChild($element);
|
||||
if (trim($owner["location"]) != "") {
|
||||
$element = $doc->createElement("poco:address");
|
||||
XML::addElement($doc, $element, "poco:formatted", $owner["location"]);
|
||||
$author->appendChild($element);
|
||||
}
|
||||
}
|
||||
|
||||
if (DBM::is_result($profile)) {
|
||||
if (DBM::is_result($profile) && !$show_profile) {
|
||||
if (trim($profile["homepage"]) != "") {
|
||||
$urls = $doc->createElement("poco:urls");
|
||||
XML::addElement($doc, $urls, "poco:type", "homepage");
|
||||
|
@ -1432,11 +1447,12 @@ class OStatus
|
|||
|
||||
XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
|
||||
XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
|
||||
|
||||
if ($profile["publish"]) {
|
||||
XML::addElement($doc, $author, "mastodon:scope", "public");
|
||||
}
|
||||
}
|
||||
|
||||
if ($profile["publish"]) {
|
||||
XML::addElement($doc, $author, "mastodon:scope", "public");
|
||||
}
|
||||
return $author;
|
||||
}
|
||||
|
||||
|
@ -1598,7 +1614,7 @@ class OStatus
|
|||
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$title = self::entryHeader($doc, $entry, $owner, $toplevel);
|
||||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
$r = q(
|
||||
"SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' AND NOT `private` AND `network` IN ('%s', '%s', '%s') LIMIT 1",
|
||||
|
@ -1627,7 +1643,7 @@ class OStatus
|
|||
|
||||
self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false);
|
||||
|
||||
$author = self::addAuthor($doc, $contact);
|
||||
$author = self::addAuthor($doc, $contact, false);
|
||||
$as_object->appendChild($author);
|
||||
|
||||
$as_object2 = $doc->createElement("activity:object");
|
||||
|
@ -1669,7 +1685,7 @@ class OStatus
|
|||
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$title = self::entryHeader($doc, $entry, $owner, $toplevel);
|
||||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
$verb = NAMESPACE_ACTIVITY_SCHEMA."favorite";
|
||||
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
|
||||
|
@ -1792,7 +1808,7 @@ class OStatus
|
|||
|
||||
$item["body"] = sprintf($message, $owner["nick"], $contact["nick"]);
|
||||
|
||||
self::entryHeader($doc, $entry, $owner, $toplevel);
|
||||
self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
self::entryContent($doc, $entry, $item, $owner, $title);
|
||||
|
||||
|
@ -1820,7 +1836,7 @@ class OStatus
|
|||
logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$title = self::entryHeader($doc, $entry, $owner, $toplevel);
|
||||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
|
||||
|
||||
|
@ -1841,12 +1857,18 @@ class OStatus
|
|||
*
|
||||
* @return string The title for the element
|
||||
*/
|
||||
private static function entryHeader($doc, &$entry, $owner, $toplevel)
|
||||
private static function entryHeader($doc, &$entry, $owner, $item, $toplevel)
|
||||
{
|
||||
/// @todo Check if this title stuff is really needed (I guess not)
|
||||
if (!$toplevel) {
|
||||
$entry = $doc->createElement("entry");
|
||||
$title = sprintf("New note by %s", $owner["nick"]);
|
||||
|
||||
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
||||
$contact = self::contactEntry($item['author-link'], $owner);
|
||||
$author = self::addAuthor($doc, $contact, false);
|
||||
$entry->appendChild($author);
|
||||
}
|
||||
} else {
|
||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, "entry");
|
||||
|
||||
|
@ -2001,12 +2023,10 @@ class OStatus
|
|||
$mentioned = $newmentions;
|
||||
|
||||
foreach ($mentioned as $mention) {
|
||||
$r = q(
|
||||
"SELECT `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
|
||||
intval($owner["uid"]),
|
||||
dbesc(normalise_link($mention))
|
||||
);
|
||||
if ($r[0]["forum"] || $r[0]["prv"]) {
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($mention)];
|
||||
$contact = dba::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
|
||||
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == ACCOUNT_TYPE_COMMUNITY) ||
|
||||
($contact['self'] && ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY))) {
|
||||
XML::addElement($doc, $entry, "link", "",
|
||||
[
|
||||
"rel" => "mentioned",
|
||||
|
@ -2023,6 +2043,12 @@ class OStatus
|
|||
}
|
||||
}
|
||||
|
||||
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
||||
XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
|
||||
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
|
||||
"href" => $owner['url']]);
|
||||
}
|
||||
|
||||
if (!$item["private"]) {
|
||||
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
|
||||
"href" => "http://activityschema.org/collection/public"]);
|
||||
|
|
|
@ -945,6 +945,15 @@ class PortableContact
|
|||
$register_policy = $gserver["register_policy"];
|
||||
$registered_users = $gserver["registered-users"];
|
||||
|
||||
// See discussion under https://forum.friendi.ca/display/0b6b25a8135aabc37a5a0f5684081633
|
||||
// It can happen that a zero date is in the database, but storing it again is forbidden.
|
||||
if ($last_contact < NULL_DATE) {
|
||||
$last_contact = NULL_DATE;
|
||||
}
|
||||
if ($last_failure < NULL_DATE) {
|
||||
$last_failure = NULL_DATE;
|
||||
}
|
||||
|
||||
if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) {
|
||||
logger("Use cached data for server ".$server_url, LOGGER_DEBUG);
|
||||
return ($last_contact >= $last_failure);
|
||||
|
@ -1302,7 +1311,7 @@ class PortableContact
|
|||
if (isset($data->version)) {
|
||||
$network = NETWORK_DFRN;
|
||||
|
||||
$noscrape = $data->no_scrape_url;
|
||||
$noscrape = defaults($data->no_scrape_url, '');
|
||||
$version = $data->version;
|
||||
$site_name = $data->site_name;
|
||||
$info = $data->info;
|
||||
|
|
|
@ -10,17 +10,23 @@ use Friendica\Core\Addon;
|
|||
* Leaflet Map related functions
|
||||
*/
|
||||
class Map {
|
||||
public static function byCoordinates($coord) {
|
||||
public static function byCoordinates($coord, $html_mode = 0) {
|
||||
$coord = trim($coord);
|
||||
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
|
||||
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'html' => ''];
|
||||
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => ''];
|
||||
Addon::callHooks('generate_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $coord;
|
||||
}
|
||||
|
||||
public static function byLocation($location) {
|
||||
$arr = ['location' => $location, 'html' => ''];
|
||||
public static function byLocation($location, $html_mode = 0) {
|
||||
$arr = ['location' => $location, 'mode' => $html_mode, 'html' => ''];
|
||||
Addon::callHooks('generate_named_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $location;
|
||||
}
|
||||
|
||||
public static function getCoordinates($location) {
|
||||
$arr = ['location' => $location, 'lat' => false, 'lon' => false];
|
||||
Addon::callHooks('Map::getCoordinates', $arr);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue