]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Fix formatting in mod/settings
[friendica.git] / mod / item.php
index 0bb0d17dbe2813127b121fdfac488b13c3be3d37..ffac1c8e445deb4dddb6c824212d77d83b7bb3fe 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+/**
+ * @file mod/item.php
+ */
 
 /*
  * This is the POST destination for most all locally posted
  * Posts that originate externally or do not fall into the above
  * posting categories go through item_store() instead of this function.
  */
-
 use Friendica\App;
+use Friendica\Core\Config;
 use Friendica\Core\System;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Model\GlobalContact;
+use Friendica\Network\Probe;
+use Friendica\Object\Contact;
+use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\Email;
+use Friendica\Util\Emailer;
 
 require_once 'include/crypto.php';
 require_once 'include/enotify.php';
-require_once 'include/email.php';
 require_once 'include/tags.php';
 require_once 'include/files.php';
 require_once 'include/threads.php';
 require_once 'include/text.php';
 require_once 'include/items.php';
-require_once 'include/probe.php';
-require_once 'include/diaspora.php';
-require_once 'include/Contact.php';
 
 function item_post(App $a) {
 
@@ -105,7 +112,7 @@ function item_post(App $a) {
                }
 
                // if this isn't the real parent of the conversation, find it
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        $parid = $r[0]['parent'];
                        $parent_uri = $r[0]['uri'];
                        if ($r[0]['id'] != $r[0]['parent']) {
@@ -115,7 +122,7 @@ function item_post(App $a) {
                        }
                }
 
-               if (! dbm::is_result($r)) {
+               if (! DBM::is_result($r)) {
                        notice( t('Unable to locate original post.') . EOL);
                        if (x($_REQUEST, 'return')) {
                                goaway($return_path);
@@ -134,18 +141,18 @@ function item_post(App $a) {
                                intval($parent_item['contact-id']),
                                intval($uid)
                        );
-                       if (dbm::is_result($r)) {
+                       if (DBM::is_result($r)) {
                                $parent_contact = $r[0];
                        }
 
                        // If the contact id doesn't fit with the contact, then set the contact to null
                        $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
-                       if (dbm::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS)
+                       if (DBM::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS)
                                && (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
-                               $parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]);
+                               $parent_contact = Contact::getDetailsByURL($thrparent[0]["author-link"]);
 
                                if (!isset($parent_contact["nick"])) {
-                                       $probed_contact = probe_url($thrparent[0]["author-link"]);
+                                       $probed_contact = Probe::uri($thrparent[0]["author-link"]);
                                        if ($probed_contact["network"] != NETWORK_FEED) {
                                                $parent_contact = $probed_contact;
                                                $parent_contact["nurl"] = normalise_link($probed_contact["url"]);
@@ -182,7 +189,7 @@ function item_post(App $a) {
                        intval($profile_uid)
                );
 
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
                        return;
                }
@@ -224,7 +231,7 @@ function item_post(App $a) {
                        intval($profile_uid),
                        intval($post_id)
                );
-               if (! dbm::is_result($i)) {
+               if (! DBM::is_result($i)) {
                        killme();
                }
                $orig_post = $i[0];
@@ -235,7 +242,7 @@ function item_post(App $a) {
        $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($profile_uid)
        );
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                $user = $r[0];
        }
 
@@ -327,13 +334,13 @@ function item_post(App $a) {
                // if using the API, we won't see pubmail_enable - figure out if it should be set
 
                if ($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) {
-                       $mail_disabled = ((function_exists('imap_open') && (! get_config('system', 'imap_disabled'))) ? 0 : 1);
+                       $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
                        if (! $mail_disabled) {
                                /// @TODO Check if only pubmail is loaded, * loads all columns
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                        intval(local_user())
                                );
-                               if (dbm::is_result($r) && intval($r[0]['pubmail'])) {
+                               if (DBM::is_result($r) && intval($r[0]['pubmail'])) {
                                        $pubmail_enabled = true;
                                }
                        }
@@ -390,7 +397,7 @@ function item_post(App $a) {
                }
        }
 
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                $author = $r[0];
                $contact_id = $author['id'];
        }
@@ -403,7 +410,7 @@ function item_post(App $a) {
                $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
                        intval($profile_uid)
                );
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        $contact_record = $r[0];
                }
        }
@@ -418,6 +425,114 @@ 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'];
+                       }
+               }
+       }
+
+       $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
@@ -430,22 +545,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",
@@ -454,7 +569,7 @@ function item_post(App $a) {
                                        intval($profile_uid)
                                );
 
-                               if (! dbm::is_result($r)) {
+                               if (! DBM::is_result($r)) {
                                        continue;
                                }
 
@@ -466,7 +581,7 @@ function item_post(App $a) {
                                        dbesc($str_group_deny),
                                        dbesc($image_uri),
                                        intval($profile_uid),
-                                       dbesc( t('Wall Photos'))
+                                       dbesc(t('Wall Photos'))
                                );
                        }
                }
@@ -486,7 +601,7 @@ function item_post(App $a) {
                                        intval($profile_uid),
                                        intval($attach)
                                );
-                               if (dbm::is_result($r)) {
+                               if (DBM::is_result($r)) {
                                        $r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
                                                WHERE `uid` = %d AND `id` = %d",
                                                dbesc($str_contact_allow),
@@ -524,102 +639,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;
-
-       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 = true;
-                               $private_id = $success['contact']['id'];
-                       }
-               }
-       }
-
-       if ($private_forum && !$parent && !$private) {
-               // we tagged a private forum in a top level post and the message was public.
-               // Restrict it.
-               $private = 1;
-               $str_contact_allow = '<' . $private_id . '>';
-       }
-
        $attachments = '';
        $match = false;
 
@@ -629,7 +658,7 @@ function item_post(App $a) {
                                intval($profile_uid),
                                intval($mtch)
                        );
-                       if (dbm::is_result($r)) {
+                       if (DBM::is_result($r)) {
                                if (strlen($attachments)) {
                                        $attachments .= ',';
                                }
@@ -641,7 +670,7 @@ function item_post(App $a) {
 
        $wall = 0;
 
-       if ($post_type === 'wall' || $post_type === 'wall-comment') {
+       if (($post_type === 'wall' || $post_type === 'wall-comment') && !count($forum_contact)) {
                $wall = 1;
        }
 
@@ -679,11 +708,11 @@ function item_post(App $a) {
        $datarray['owner-name']    = $contact_record['name'];
        $datarray['owner-link']    = $contact_record['url'];
        $datarray['owner-avatar']  = $contact_record['thumb'];
-       $datarray['owner-id']      = get_contact($datarray['owner-link'], 0);
+       $datarray['owner-id']      = Contact::getIdForURL($datarray['owner-link'], 0);
        $datarray['author-name']   = $author['name'];
        $datarray['author-link']   = $author['url'];
        $datarray['author-avatar'] = $author['thumb'];
-       $datarray['author-id']     = get_contact($datarray['author-link'], 0);
+       $datarray['author-id']     = Contact::getIdForURL($datarray['author-link'], 0);
        $datarray['created']       = datetime_convert();
        $datarray['edited']        = datetime_convert();
        $datarray['commented']     = datetime_convert();
@@ -714,7 +743,7 @@ function item_post(App $a) {
        $datarray['postopts']      = $postopts;
        $datarray['origin']        = $origin;
        $datarray['moderated']     = $allow_moderated;
-       $datarray['gcontact-id']   = get_gcontact_id(array("url" => $datarray['author-link'], "network" => $datarray['network'],
+       $datarray['gcontact-id']   = GlobalContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
                                                        "photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
        $datarray['object']        = $object;
 
@@ -738,7 +767,7 @@ function item_post(App $a) {
        $datarray['protocol'] = PROTOCOL_DFRN;
 
        $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']);
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                if ($r['conversation-uri'] != '') {
                        $datarray['conversation-uri'] = $r['conversation-uri'];
                }
@@ -810,7 +839,7 @@ function item_post(App $a) {
                // update filetags in pconfig
                file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
 
-               proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id);
+               Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $post_id);
                if ((x($_REQUEST, 'return')) && strlen($return_path)) {
                        logger('return: ' . $return_path);
                        goaway($return_path);
@@ -897,7 +926,7 @@ function item_post(App $a) {
                intval($datarray['visible'])
        );
 
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                $post_id = dba::lastInsertId();
        } else {
                logger('mod_item: unable to create post.');
@@ -960,7 +989,7 @@ function item_post(App $a) {
 
 
                // Store the comment signature information in case we need to relay to Diaspora
-               Diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
+               Diaspora::storeCommentSignature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
 
        } else {
                $parent = $post_id;
@@ -969,7 +998,7 @@ function item_post(App $a) {
                        intval($parent),
                        intval($post_id));
 
-               if ($contact_record != $author) {
+               if (($contact_record != $author) && !count($forum_contact)) {
                        notification(array(
                                'type'         => NOTIFY_WALL,
                                'notify_flags' => $user['notify-flags'],
@@ -1003,22 +1032,22 @@ 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 href="' . System::baseUrl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
                                $html    = prepare_body($datarray);
                                $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
                                include_once 'include/html2plain.php';
                                $params = array (
-                                   'fromName' => $a->user['username'],
-                                   'fromEmail' => $a->user['email'],
-                                   'toEmail' => $addr,
-                                   'replyTo' => $a->user['email'],
-                                   'messageSubject' => $subject,
-                                   'htmlVersion' => $message,
-                                   'textVersion' => html2plain($html.$disclaimer),
+                                       'fromName' => $a->user['username'],
+                                       'fromEmail' => $a->user['email'],
+                                       'toEmail' => $addr,
+                                       'replyTo' => $a->user['email'],
+                                       'messageSubject' => $subject,
+                                       'htmlVersion' => $message,
+                                       'textVersion' => html2plain($html.$disclaimer)
                                );
                                Emailer::send($params);
                        }
@@ -1040,10 +1069,10 @@ function item_post(App $a) {
        // We now do it in the background to save some time.
        // This is important in interactive environments like the frontend or the API.
        // We don't fork a new process since this is done anyway with the following command
-       proc_run(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "include/create_shadowentry.php", $post_id);
+       Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id);
 
        // Call the background process that is delivering the item to the receivers
-       proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $post_id);
+       Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
 
        logger('post_complete');
 
@@ -1109,9 +1138,8 @@ function item_content(App $a) {
  *
  * @return boolean true if replaced, false if not replaced
  */
-function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") {
-       require_once 'include/socgraph.php';
-
+function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "")
+{
        $replaced = false;
        $r = null;
        $tag_type = '@';
@@ -1135,14 +1163,14 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
 
                                $r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
                                        normalise_link($matches[1]));
-                               if (!dbm::is_result($r)) {
+                               if (!DBM::is_result($r)) {
                                        $r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
                                                normalise_link($matches[1]));
                                }
-                               if (dbm::is_result($r)) {
+                               if (DBM::is_result($r)) {
                                        $data = $r[0];
                                } else {
-                                       $data = probe_url($matches[1]);
+                                       $data = Probe::uri($matches[1]);
                                }
 
                                if ($data["alias"] != "") {
@@ -1172,7 +1200,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        // Is it in format @user@domain.tld or @http://domain.tld/...?
 
                        // First check the contact table for the address
-                       $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
+                       $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify`, `forum`, `prv` FROM `contact`
                                WHERE `addr` = '%s' AND `uid` = %d AND
                                        (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
                                LIMIT 1",
@@ -1182,8 +1210,8 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        );
 
                        // Then check in the contact table for the url
-                       if (!dbm::is_result($r)) {
-                               $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
+                       if (!DBM::is_result($r)) {
+                               $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify`, `forum`, `prv` FROM `contact`
                                        WHERE `nurl` = '%s' AND `uid` = %d AND
                                                (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
                                        LIMIT 1",
@@ -1194,7 +1222,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
 
                        // Then check in the global contacts for the address
-                       if (!dbm::is_result($r)) {
+                       if (!DBM::is_result($r)) {
                                $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
                                        WHERE `addr` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
                                        LIMIT 1",
@@ -1204,7 +1232,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
 
                        // Then check in the global contacts for the url
-                       if (!dbm::is_result($r)) {
+                       if (!DBM::is_result($r)) {
                                $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
                                        WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
                                        LIMIT 1",
@@ -1213,10 +1241,10 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                                );
                        }
 
-                       if (!dbm::is_result($r)) {
-                               $probed = probe_url($name);
+                       if (!DBM::is_result($r)) {
+                               $probed = Probe::uri($name);
                                if ($result['network'] != NETWORK_PHANTOM) {
-                                       update_gcontact($probed);
+                                       GlobalContact::update($probed);
                                        $r = q("SELECT `url`, `name`, `nick`, `network`, `alias`, `notify` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
                                                dbesc(normalise_link($probed["url"])));
                                }
@@ -1234,7 +1262,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
 
                        // select someone by attag or nick and the name passed in the current network
-                       if(!dbm::is_result($r) && ($network != ""))
+                       if(!DBM::is_result($r) && ($network != ""))
                                $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
                                                dbesc($name),
                                                dbesc($name),
@@ -1243,7 +1271,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                                );
 
                        //select someone from this user's contacts by name in the current network
-                       if (!dbm::is_result($r) && ($network != "")) {
+                       if (!DBM::is_result($r) && ($network != "")) {
                                $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
                                                dbesc($name),
                                                dbesc($network),
@@ -1252,7 +1280,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
 
                        // select someone by attag or nick and the name passed in
-                       if(!dbm::is_result($r)) {
+                       if(!DBM::is_result($r)) {
                                $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
                                                dbesc($name),
                                                dbesc($name),
@@ -1261,7 +1289,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
 
                        // select someone from this user's contacts by name
-                       if(!dbm::is_result($r)) {
+                       if(!DBM::is_result($r)) {
                                $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                dbesc($name),
                                                intval($profile_uid)
@@ -1269,7 +1297,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        }
                }
 
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        if (strlen($inform) && (isset($r[0]["notify"]) || isset($r[0]["id"]))) {
                                $inform .= ',';
                        }