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;
use HTMLPurifier;
use HTMLPurifier_Config;
-require_once 'boot.php';
-require_once 'include/dba.php';
-require_once "include/enotify.php";
-require_once "include/items.php";
-require_once "include/text.php";
-
/**
* @brief This class contain functions to create and send DFRN XML files
*/
*/
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
{
- $a = get_app();
+ $a = \get_app();
$sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic
$public_feed = (($dfrn_id) ? false : true);
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"])));
}
*/
public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false)
{
- $a = get_app();
+ $a = \get_app();
// At first try the Diaspora transport layer
if (!$dissolve && !$legacy_transport) {
*/
public static function transmit($owner, $contact, $atom, $public_batch = false)
{
- $a = get_app();
+ $a = \get_app();
if (!$public_batch) {
if (empty($contact['addr'])) {
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
*
// "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
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $msg,
+ "parent" => $msg["parent-uri"],
"source_name" => $msg["from-name"],
"source_link" => $importer["url"],
"source_photo" => $importer["thumb"],
*/
private static function processSuggestion($xpath, $suggestion, $importer)
{
- $a = get_app();
+ $a = \get_app();
Logger::log("Processing suggestions");
$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"]);
/// @todo Do we really need this check for HTML elements? (It was copied from the old function)
if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) {
- $base_url = get_app()->getBaseURL();
+ $base_url = \get_app()->getBaseURL();
$item['body'] = HTML::relToAbs($item['body'], $base_url);
$item['body'] = HTML::toBBCodeVideo($item['body']);
if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) {
Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG);
$ev = Event::fromBBCode($item["body"]);
- if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
+ if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
Logger::log("Event in item ".$item["uri"]." was found.", Logger::DEBUG);
$ev["cid"] = $importer["id"];
$ev["uid"] = $importer["importer_uid"];
public static function autoRedir(App $a, $contact_nick)
{
// prevent looping
- if (x($_REQUEST, 'redir') && intval($_REQUEST['redir'])) {
+ if (!empty($_REQUEST['redir'])) {
return;
}
*/
private static function isEditedTimestampNewer($existing, $update)
{
- if (!x($existing, 'edited') || !$existing['edited']) {
+ if (empty($existing['edited'])) {
return true;
}
- if (!x($update, 'edited') || !$update['edited']) {
+ if (empty($update['edited'])) {
return false;
}