$item["entry:cid"] = defaults($item, "entry:cid", 0);
$entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
- $root->appendChild($entry);
+ if (isset($entry)) {
+ $root->appendChild($entry);
+ }
}
return trim($doc->saveXML());
}
$entry = self::entry($doc, $type, $item, $owner, true);
- $root->appendChild($entry);
+ if (isset($entry)) {
+ $root->appendChild($entry);
+ }
}
$atom = trim($doc->saveXML());
foreach ($items as $item) {
$entry = self::entry($doc, $type, $item, $owner, true, 0);
- $root->appendChild($entry);
+ if (isset($entry)) {
+ $root->appendChild($entry);
+ }
}
} else {
$root = self::entry($doc, $type, $item, $owner, true, 0, true);
/**
* @brief Adds the header elements for the DFRN protocol
*
- * @param object $doc XML document
- * @param array $owner Owner record
- * @param string $authorelement Element name for the author
- * @param string $alternatelink link to profile or category
- * @param bool $public Is it a header for public posts?
+ * @param DOMDocument $doc XML document
+ * @param array $owner Owner record
+ * @param string $authorelement Element name for the author
+ * @param string $alternatelink link to profile or category
+ * @param bool $public Is it a header for public posts?
*
* @return object XML root object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints
*/
- private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
+ private static function addHeader(DOMDocument $doc, $owner, $authorelement, $alternatelink = "", $public = false)
{
if ($alternatelink == "") {
/**
* @brief Adds the author element in the header for the DFRN protocol
*
- * @param object $doc XML document
- * @param array $owner Owner record
- * @param string $authorelement Element name for the author
- * @param boolean $public boolean
+ * @param DOMDocument $doc XML document
+ * @param array $owner Owner record
+ * @param string $authorelement Element name for the author
+ * @param boolean $public boolean
*
- * @return object XML author object
+ * @return \DOMElement XML author object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints
*/
- private static function addAuthor($doc, $owner, $authorelement, $public)
+ private static function addAuthor(DOMDocument $doc, array $owner, $authorelement, $public)
{
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
$r = q(
/**
* @brief Adds the author elements in the "entry" elements of the DFRN protocol
*
- * @param object $doc XML document
+ * @param DOMDocument $doc XML document
* @param string $element Element name for the author
* @param string $contact_url Link of the contact
* @param array $item Item elements
*
- * @return object XML author object
+ * @return \DOMElement XML author object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints
*/
- private static function addEntryAuthor($doc, $element, $contact_url, $item)
+ private static function addEntryAuthor(DOMDocument $doc, $element, $contact_url, $item)
{
- $contact = Contact::getDetailsByURL($contact_url, $item["uid"]);
-
$author = $doc->createElement($element);
- XML::addElement($doc, $author, "name", $contact["name"]);
- XML::addElement($doc, $author, "uri", $contact["url"]);
- XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]);
- /// @Todo
- /// - Check real image type and image size
- /// - Check which of these boths elements we should use
- $attributes = [
+ $contact = Contact::getDetailsByURL($contact_url, $item["uid"]);
+ if (!empty($contact)) {
+ XML::addElement($doc, $author, "name", $contact["name"]);
+ XML::addElement($doc, $author, "uri", $contact["url"]);
+ XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]);
+
+ /// @Todo
+ /// - Check real image type and image size
+ /// - Check which of these boths elements we should use
+ $attributes = [
"rel" => "photo",
"type" => "image/jpeg",
"media:width" => 80,
"media:height" => 80,
"href" => $contact["photo"]];
- XML::addElement($doc, $author, "link", "", $attributes);
+ XML::addElement($doc, $author, "link", "", $attributes);
- $attributes = [
+ $attributes = [
"rel" => "avatar",
"type" => "image/jpeg",
"media:width" => 80,
"media:height" => 80,
"href" => $contact["photo"]];
- XML::addElement($doc, $author, "link", "", $attributes);
+ XML::addElement($doc, $author, "link", "", $attributes);
+ }
return $author;
}
/**
* @brief Adds the activity elements
*
- * @param object $doc XML document
- * @param string $element Element name for the activity
- * @param string $activity activity value
+ * @param DOMDocument $doc XML document
+ * @param string $element Element name for the activity
+ * @param string $activity activity value
*
- * @return object XML activity object
+ * @return \DOMElement XML activity object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints
*/
- private static function createActivity($doc, $element, $activity)
+ private static function createActivity(DOMDocument $doc, $element, $activity)
{
if ($activity) {
$entry = $doc->createElement($element);
/**
* @brief Adds the "entry" elements for the DFRN protocol
*
- * @param object $doc XML document
- * @param string $type "text" or "html"
- * @param array $item Item element
- * @param array $owner Owner record
- * @param bool $comment Trigger the sending of the "comment" element
- * @param int $cid Contact ID of the recipient
- * @param bool $single If set, the entry is created as an XML document with a single "entry" element
+ * @param DOMDocument $doc XML document
+ * @param string $type "text" or "html"
+ * @param array $item Item element
+ * @param array $owner Owner record
+ * @param bool $comment Trigger the sending of the "comment" element
+ * @param int $cid Contact ID of the recipient
+ * @param bool $single If set, the entry is created as an XML document with a single "entry" element
*
- * @return object XML entry object
+ * @return null|\DOMElement XML entry object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
* @todo Find proper type-hints
*/
- private static function entry($doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
+ private static function entry(DOMDocument $doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
{
$mentioned = [];
if (!$item['parent']) {
- return;
+ Logger::notice('Item without parent found.', ['type' => $type, 'item' => $item]);
+ return null;
}
if ($item['deleted']) {
$author["network"] = $contact_old["network"];
} else {
if (!$onlyfetch) {
- Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, Logger::DEBUG);
+ Logger::debug("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml);
}
$author["contact-unknown"] = true;
if (empty($author['avatar'])) {
Logger::log('Empty author: ' . $xml);
+ $author['avatar'] = '';
}
if (DBA::isResult($contact_old) && !$onlyfetch) {
DBA::escape($suggest["photo"]),
DBA::escape($suggest["request"])
);
+ $fid = $r[0]["id"];
}
$condition = ['url' => $suggest["url"], 'name' => $suggest["name"], 'request' => $suggest["request"]];
exit();
}
- $fid = $r[0]["id"];
-
$hash = Strings::getRandomHex();
q(
if (($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) {
// somebody was poked/prodded. Was it me?
+ $Blink = '';
foreach ($xo->link as $l) {
$atts = $l->attributes();
switch ($atts["rel"]) {
* @param object $xpath XPath object
* @param object $entry entry elements
* @param array $importer Record of the importer user mixed with contact of the content
- * @param object $xml xml
+ * @param string $xml xml
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
DBA::update('contact', ['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
}
// A forum contact can either have set "forum" or "prv" - but not both
- if ($accounttype == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($accounttype == User::ACCOUNT_TYPE_COMMUNITY) {
// It's a forum, so either set the public or private forum flag
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer['id']];
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);