]> git.mxchange.org Git - friendica.git/commitdiff
Images that are uploaded to public forums are now public
authorMichael <heluecht@pirati.ca>
Sun, 26 Nov 2017 02:03:59 +0000 (02:03 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 26 Nov 2017 02:03:59 +0000 (02:03 +0000)
mod/item.php

index 4aafa22995667e083bb1f92abd4628280ad26865..8ae99948a103e5addc49cefb83a86259622c410e 100644 (file)
@@ -423,6 +423,112 @@ function item_post(App $a) {
                }
        }
 
+       // 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;
+       }
+
        /*
         * 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,7 +541,7 @@ 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)) {
 
@@ -529,122 +635,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;