use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Config;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
XML::addElement($doc, $author, "poco:displayName", $profile["name"]);
XML::addElement($doc, $author, "poco:updated", $namdate);
- if (trim($profile["dob"]) > '0001-01-01') {
+ if (trim($profile["dob"]) > DBA::NULL_DATE) {
XML::addElement($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"])));
}
}
foreach ($mentioned as $mention) {
- $condition = ['uid' => $owner["uid"], 'nurl' => normalise_link($mention)];
+ $condition = ['uid' => $owner["uid"], 'nurl' => Strings::normaliseLink($mention)];
$contact = DBA::selectFirst('contact', ['forum', 'prv'], $condition);
if (DBA::isResult($contact) && ($contact["forum"] || $contact["prv"])) {
return intval($res->status);
}
- /**
- * @brief Add new birthday event for this person
- *
- * @param array $contact Contact record
- * @param string $birthday Birthday of the contact
- * @return void
- * @todo Add array type-hint for $contact
- */
- private static function birthdayEvent($contact, $birthday)
- {
- // Check for duplicates
- $condition = ['uid' => $contact['uid'], 'cid' => $contact['id'],
- 'start' => DateTimeFormat::utc($birthday), 'type' => 'birthday'];
- if (DBA::exists('event', $condition)) {
- return;
- }
-
- Logger::log('updating birthday: ' . $birthday . ' for contact ' . $contact['id']);
-
- $bdtext = L10n::t('%s\'s birthday', $contact['name']);
- $bdtext2 = L10n::t('Happy Birthday %s', ' [url=' . $contact['url'] . ']' . $contact['name'] . '[/url]');
-
- $r = q(
- "INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
- intval($contact['uid']),
- intval($contact['id']),
- DBA::escape(DateTimeFormat::utcNow()),
- DBA::escape(DateTimeFormat::utcNow()),
- DBA::escape(DateTimeFormat::utc($birthday)),
- DBA::escape(DateTimeFormat::utc($birthday . ' + 1 day ')),
- DBA::escape($bdtext),
- DBA::escape($bdtext2),
- DBA::escape('birthday')
- );
- }
-
/**
* @brief Fetch the author data from head or entry items
*
$fields = ['id', 'uid', 'url', 'network', 'avatar-date', 'avatar', 'name-date', 'uri-date', 'addr',
'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
$condition = ["`uid` = ? AND `nurl` = ? AND `network` != ?",
- $importer["importer_uid"], normalise_link($author["link"]), Protocol::STATUSNET];
+ $importer["importer_uid"], Strings::normaliseLink($author["link"]), Protocol::STATUSNET];
$contact_old = DBA::selectFirst('contact', $fields, $condition);
if (DBA::isResult($contact_old)) {
// "poco:birthday" is the birthday in the format "yyyy-mm-dd"
$value = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context);
- if (!in_array($value, ["", "0000-00-00", "0001-01-01"])) {
+ if (!in_array($value, ["", "0000-00-00", DBA::NULL_DATE])) {
$bdyear = date("Y");
- $value = str_replace("0000", $bdyear, $value);
+ $value = str_replace(["0000", "0001"], $bdyear, $value);
if (strtotime($value) < time()) {
$value = str_replace($bdyear, $bdyear + 1, $value);
$contact = array_merge($contact_old, $poco);
if ($contact_old["bdyear"] != $contact["bdyear"]) {
- self::birthdayEvent($contact, $birthday);
+ Event::createBirthday($contact, $birthday);
}
// Get all field names
*
* @see https://github.com/friendica/friendica/pull/3254#discussion_r107315246
*/
- $condition = ['name' => $suggest["name"], 'nurl' => normalise_link($suggest["url"]),
+ $condition = ['name' => $suggest["name"], 'nurl' => Strings::normaliseLink($suggest["url"]),
'uid' => $suggest["uid"]];
if (DBA::exists('contact', $condition)) {
return false;
$relocate["server_url"] = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $relocate["url"]);
$fields = ['name' => $relocate["name"], 'photo' => $relocate["avatar"],
- 'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
+ 'url' => $relocate["url"], 'nurl' => Strings::normaliseLink($relocate["url"]),
'addr' => $relocate["addr"], 'connect' => $relocate["addr"],
'notify' => $relocate["notify"], 'server_url' => $relocate["server_url"]];
- DBA::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
+ DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($old["url"])]);
// Update the contact table. We try to find every entry.
$fields = ['name' => $relocate["name"], 'avatar' => $relocate["avatar"],
- 'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
+ 'url' => $relocate["url"], 'nurl' => Strings::normaliseLink($relocate["url"]),
'addr' => $relocate["addr"], 'request' => $relocate["request"],
'confirm' => $relocate["confirm"], 'notify' => $relocate["notify"],
'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
- $condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], normalise_link($old["url"])];
+ $condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], Strings::normaliseLink($old["url"])];
DBA::update('contact', $fields, $condition);
$item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry);
$item["body"] = str_replace([' ',"\t","\r","\n"], ['','','',''], $item["body"]);
// make sure nobody is trying to sneak some html tags by us
- $item["body"] = Strings::removeTags(Strings::base64UrlDecode($item["body"]));
+ $item["body"] = Strings::escapeTags(Strings::base64UrlDecode($item["body"]));
$item["body"] = BBCode::limitBodySize($item["body"]);
return;
}
$baseurl = substr($baseurl, $domain_st + 3);
- $nurl = normalise_link($baseurl);
+ $nurl = Strings::normaliseLink($baseurl);
/// @todo Why is there a query for "url" *and* "nurl"? Especially this normalising is strange.
$r = q("SELECT `id` FROM `contact` WHERE `uid` = (SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1)
$community_page = ($user['page-flags'] == Contact::PAGE_COMMUNITY);
$prvgroup = ($user['page-flags'] == Contact::PAGE_PRVGROUP);
- $link = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
+ $link = Strings::normaliseLink(System::baseUrl() . '/profile/' . $user['nickname']);
/*
* Diaspora uses their own hardwired link URL in @-tags
* instead of the one we supply with webfinger
*/
- $dlink = normalise_link(System::baseUrl() . '/u/' . $user['nickname']);
+ $dlink = Strings::normaliseLink(System::baseUrl() . '/u/' . $user['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism', $item['body'], $matches, PREG_SET_ORDER);
if ($cnt) {