X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=1faef960163c7845bad16b15a814d58a747dd667;hb=54d598ce7c66308dbcf5d5aa0b14b3aec73885a8;hp=4aafa22995667e083bb1f92abd4628280ad26865;hpb=5ec011c7be97c295fbb9256d6a7a3f2e99fed099;p=friendica.git
diff --git a/mod/item.php b/mod/item.php
index 4aafa22995..1faef96016 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -1,4 +1,7 @@
')) {
+ $private_forum = false;
+ $only_to_forum = true;
+ $private_id = $success['contact']['id'];
+ $forum_contact = $success['contact'];
+ }
+ }
+ }
+
+ $original_contact_id = $contact_id;
+
+ if (!$parent && count($forum_contact) && ($private_forum || $only_to_forum)) {
+ // we tagged a forum in a top level post. Now we change the post
+ $private = $private_forum;
+
+ $str_group_allow = '';
+ $str_contact_deny = '';
+ $str_group_deny = '';
+ if ($private_forum) {
+ $str_contact_allow = '<' . $private_id . '>';
+ } else {
+ $str_contact_allow = '';
+ }
+ $contact_id = $private_id;
+ $contact_record = $forum_contact;
+ $_REQUEST['origin'] = false;
+ }
+
/*
* When a photo was uploaded into the message using the (profile wall) ajax
* uploader, The permissions are initially set to disallow anybody but the
@@ -435,22 +547,22 @@ function item_post(App $a) {
$match = null;
- if ((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
+ if (!$preview && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[2];
if (count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE;
foreach ($images as $image) {
- if (! stristr($image,System::baseUrl() . '/photo/')) {
+ if (!stristr($image, System::baseUrl() . '/photo/')) {
continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
- if (! strlen($image_uri)) {
+ if (!strlen($image_uri)) {
continue;
}
- $srch = '<' . intval($contact_id) . '>';
+ $srch = '<' . intval($original_contact_id) . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
AND `resource-id` = '%s' AND `uid` = %d LIMIT 1",
@@ -471,7 +583,7 @@ function item_post(App $a) {
dbesc($str_group_deny),
dbesc($image_uri),
intval($profile_uid),
- dbesc( t('Wall Photos'))
+ dbesc(t('Wall Photos'))
);
}
}
@@ -529,122 +641,16 @@ function item_post(App $a) {
require_once 'include/plaintext.php';
$objectdata = get_attached_data($body);
- if ($post["type"] == "link") {
+ if ($objectdata["type"] == "link") {
$objecttype = ACTIVITY_OBJ_BOOKMARK;
- } elseif ($post["type"] == "video") {
+ } elseif ($objectdata["type"] == "video") {
$objecttype = ACTIVITY_OBJ_VIDEO;
- } elseif ($post["type"] == "photo") {
+ } elseif ($objectdata["type"] == "photo") {
$objecttype = ACTIVITY_OBJ_IMAGE;
}
}
- // Look for any tags and linkify them
- $str_tags = '';
- $inform = '';
-
- $tags = get_tags($body);
-
- /*
- * add a statusnet style reply tag if the original post was from there
- * and we are replying, and there isn't one already
- */
- if ($parent && ($parent_contact['network'] == NETWORK_OSTATUS)) {
- $contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
-
- if (!in_array($contact, $tags)) {
- $body = $contact . ' ' . $body;
- $tags[] = $contact;
- }
-
- $toplevel_contact = "";
- $toplevel_parent = q("SELECT `contact`.* FROM `contact`
- INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `contact`.`url` = `item`.`author-link`
- WHERE `item`.`id` = `item`.`parent` AND `item`.`parent` = %d", intval($parent));
- if (DBM::is_result($toplevel_parent)) {
- if (!empty($toplevel_parent[0]['addr'])) {
- $toplevel_contact = '@' . $toplevel_parent[0]['addr'];
- } else {
- $toplevel_contact = '@' . $toplevel_parent[0]['nick'] . '+' . $toplevel_parent[0]['id'];
- }
- } else {
- $toplevel_parent = q("SELECT `author-link`, `author-name` FROM `item` WHERE `id` = `parent` AND `parent` = %d", intval($parent));
- $toplevel_contact = '@[url=' . $toplevel_parent[0]['author-link'] . ']' . $toplevel_parent[0]['author-name'] . '[/url]';
- }
-
- if (!in_array($toplevel_contact, $tags)) {
- $tags[] = $toplevel_contact;
- }
- }
-
- $tagged = array();
-
- $private_forum = false;
- $only_to_forum = false;
- $forum_contact = array();
-
- if (count($tags)) {
- foreach ($tags as $tag) {
-
- $tag_type = substr($tag, 0, 1);
-
- if ($tag_type == '#') {
- continue;
- }
-
- /*
- * If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
- * Robert Johnson should be first in the $tags array
- */
- $fullnametagged = false;
- /// @TODO $tagged is initialized above if() block and is not filled, maybe old-lost code?
- foreach ($tagged as $nextTag) {
- if (stristr($nextTag, $tag . ' ')) {
- $fullnametagged = true;
- break;
- }
- }
- if ($fullnametagged) {
- continue;
- }
-
- $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
- if ($success['replaced']) {
- $tagged[] = $tag;
- }
- // When the forum is private or the forum is addressed with a "!" make the post private
- if (is_array($success['contact']) && ($success['contact']['prv'] || ($tag_type == '!'))) {
- $private_forum = $success['contact']['prv'];
- $only_to_forum = ($tag_type == '!');
- $private_id = $success['contact']['id'];
- $forum_contact = $success['contact'];
- } elseif (is_array($success['contact']) && $success['contact']['forum'] &&
- ($str_contact_allow == '<' . $success['contact']['id'] . '>')) {
- $private_forum = false;
- $only_to_forum = true;
- $private_id = $success['contact']['id'];
- $forum_contact = $success['contact'];
- }
- }
- }
-
- if (!$parent && count($forum_contact) && ($private_forum || $only_to_forum)) {
- // we tagged a forum in a top level post. Now we change the post
- $private = $private_forum;
-
- $str_group_allow = '';
- $str_contact_deny = '';
- $str_group_deny = '';
- if ($private_forum) {
- $str_contact_allow = '<' . $private_id . '>';
- } else {
- $str_contact_allow = '';
- }
- $contact_id = $private_id;
- $contact_record = $forum_contact;
- $_REQUEST['origin'] = false;
- }
-
$attachments = '';
$match = false;
@@ -739,7 +745,7 @@ function item_post(App $a) {
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['moderated'] = $allow_moderated;
- $datarray['gcontact-id'] = GlobalContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
+ $datarray['gcontact-id'] = GContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
$datarray['object'] = $object;
@@ -1028,9 +1034,9 @@ function item_post(App $a) {
$disclaimer .= sprintf( t('You may visit them online at %s'), System::baseUrl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
if (!$datarray['title']=='') {
- $subject = email_header_encode($datarray['title'], 'UTF-8');
+ $subject = Email::encodeHeader($datarray['title'], 'UTF-8');
} else {
- $subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'), $a->user['username']), 'UTF-8');
+ $subject = Email::encodeHeader('[Friendica]' . ' ' . sprintf( t('%s posted an update.'), $a->user['username']), 'UTF-8');
}
$link = '![' . $a->user['username'] . '](' . $author['thumb'] . ')
';
$html = prepare_body($datarray);
@@ -1240,7 +1246,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
if (!DBM::is_result($r)) {
$probed = Probe::uri($name);
if ($result['network'] != NETWORK_PHANTOM) {
- GlobalContact::update($probed);
+ GContact::update($probed);
$r = q("SELECT `url`, `name`, `nick`, `network`, `alias`, `notify` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($probed["url"])));
}