$owner = $r[0];
$owner_id = $owner['uid'];
- $owner_nick = $owner['nickname'];
$sql_post_table = "";
if (! $public_feed) {
- $sql_extra = '';
switch ($direction) {
case (-1):
$sql_extra = sprintf(" AND `issued-id` = '%s' ", DBA::escape($dfrn_id));
- $my_id = $dfrn_id;
break;
case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
- $my_id = '1:' . $dfrn_id;
break;
case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
- $my_id = '0:' . $dfrn_id;
break;
default:
return false;
intval(TERM_CATEGORY),
intval($owner_id)
);
- //$sql_extra .= FileTag::fileQuery('item',$category,'category');
}
if ($public_feed && ! $converse) {
/**
* @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 == "") {
}
// For backward compatibility we keep this element
- if ($owner['page-flags'] == Contact::PAGE_COMMUNITY) {
+ if ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
XML::addElement($doc, $root, "dfrn:community", 1);
}
// The former element is replaced by this one
XML::addElement($doc, $root, "dfrn:account_type", $owner["account-type"]);
- /// @todo We need a way to transmit the different page flags like "Contact::PAGE_PRVGROUP"
+ /// @todo We need a way to transmit the different page flags like "User::PAGE_FLAGS_PRVGROUP"
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
/**
* @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"]);
/**
* @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 \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 = [];
*/
public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false)
{
- $a = \get_app();
-
// At first try the Diaspora transport layer
if (!$dissolve && !$legacy_transport) {
$curlResult = self::transmit($owner, $contact, $atom);
Logger::log("Local rino version: ". $rino, Logger::DEBUG);
$ssl_val = intval(Config::get('system', 'ssl_policy'));
- $ssl_policy = '';
switch ($ssl_val) {
case SSL_POLICY_FULL:
$perm = (($res->perm) ? $res->perm : null);
$dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0);
$rino_remote_version = intval($res->rino);
- $page = (($owner['page-flags'] == Contact::PAGE_COMMUNITY) ? 1 : 0);
+ $page = (($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? 1 : 0);
Logger::log("Remote rino version: ".$rino_remote_version." for ".$contact["url"], Logger::DEBUG);
- if ($owner['page-flags'] == Contact::PAGE_PRVGROUP) {
+ if ($owner['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
$page = 2;
}
}
if (($contact['duplex'] && strlen($contact['pubkey']))
- || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
+ || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
$postvars['dissolve'] = '1';
}
- if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
+ if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
} else {
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
- || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
+ || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
}
} else {
- if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
+ if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
} else {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
*/
public static function transmit($owner, $contact, $atom, $public_batch = false)
{
- $a = \get_app();
-
if (!$public_batch) {
if (empty($contact['addr'])) {
Logger::log('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
if (strtotime($value) < time()) {
$value = str_replace($bdyear, $bdyear + 1, $value);
- $bdyear = $bdyear + 1;
}
$poco["bd"] = $value;
*/
private static function processSuggestion($xpath, $suggestion, $importer)
{
- $a = \get_app();
-
Logger::log("Processing suggestions");
/// @TODO Rewrite this to one statement
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();
- $r = q(
+ q(
"INSERT INTO `intro` (`uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked`)
VALUES(%d, %d, %d, '%s', '%s', '%s', %d)",
intval($suggest["uid"]),
if ($item["parent-uri"] != $item["uri"]) {
$community = false;
- if ($importer["page-flags"] == Contact::PAGE_COMMUNITY || $importer["page-flags"] == Contact::PAGE_PRVGROUP) {
+ if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) {
$sql_extra = "";
$community = true;
Logger::log("possible community action");
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"]) {
$item["plink"] = $href;
break;
case "enclosure":
- $enclosure = $href;
-
if (!empty($item["attach"])) {
$item["attach"] .= ",";
} else {
* @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
}
}
- $enclosure = "";
-
$links = $xpath->query("atom:link", $entry);
if ($links) {
self::parseLinks($links, $item);
if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
$posted_id = Item::insert($item);
- $parent = 0;
-
if ($posted_id) {
Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, Logger::DEBUG);
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);
return false;
}
- $community_page = ($user['page-flags'] == Contact::PAGE_COMMUNITY);
- $prvgroup = ($user['page-flags'] == Contact::PAGE_PRVGROUP);
+ $community_page = ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY);
+ $prvgroup = ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP);
$link = Strings::normaliseLink(System::baseUrl() . '/profile/' . $user['nickname']);