]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Add probe data return if Contact::getDetailsByURL didn't yield a result in Contact...
[friendica.git] / src / Model / Profile.php
index 24db78a00acedc86c3aa947d3eb2554933fdaaa9..2b1546db49ef077eee04f0e763bf4a4a2532859e 100644 (file)
@@ -27,7 +27,6 @@ use Friendica\Content\Widget\ContactBlock;
 use Friendica\Core\Cache\Duration;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
-use Friendica\Network\Probe;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session;
@@ -601,7 +600,7 @@ class Profile
 
                        while ($rr = DBA::fetch($s)) {
                                $condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => public_contact(),
-                                       'activity' => [Item::activityToIndex( Activity::ATTEND), Item::activityToIndex(Activity::ATTENDMAYBE)],
+                                       'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
                                        'visible' => true, 'deleted' => false];
                                if (!Item::exists($condition)) {
                                        continue;
@@ -772,7 +771,7 @@ class Profile
                $_SESSION['visitor_handle'] = $visitor['addr'];
                $_SESSION['visitor_home'] = $visitor['url'];
                $_SESSION['my_url'] = $visitor['url'];
-               $_SESSION['remote_comment'] = Probe::getRemoteFollowLink($visitor['url']);
+               $_SESSION['remote_comment'] = $visitor['subscribe'];
 
                Session::setVisitorsContacts();
 
@@ -887,13 +886,11 @@ class Profile
         */
        public static function searchProfiles($start = 0, $count = 100, $search = null)
        {
-               $publish = (DI::config()->get('system', 'publish_all') ? 'true' : "`publish` = 1");
-               $total = 0;
-
                if (!empty($search)) {
+                       $publish = (DI::config()->get('system', 'publish_all') ? '' : "AND `publish` ");
                        $searchTerm = '%' . $search . '%';
-                       $cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` FROM `owner-view`
-                               WHERE $publish AND NOT `blocked` AND NOT `account_removed`
+                       $condition = ["NOT `blocked` AND NOT `account_removed`
+                               $publish
                                AND ((`name` LIKE ?) OR
                                (`nickname` LIKE ?) OR
                                (`about` LIKE ?) OR
@@ -902,55 +899,24 @@ class Profile
                                (`country-name` LIKE ?) OR
                                (`pub_keywords` LIKE ?) OR
                                (`prv_keywords` LIKE ?))",
-                               $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm);
+                               $searchTerm, $searchTerm, $searchTerm, $searchTerm,
+                               $searchTerm, $searchTerm, $searchTerm, $searchTerm];
                } else {
-                       $cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total`
-                               FROM `owner-view` WHERE $publish AND NOT `blocked` AND NOT `account_removed`");
-               }
-
-               if (DBA::isResult($cnt)) {
-                       $total = $cnt['total'];
+                       $condition = ['blocked' => false, 'account_removed' => false];
+                       if (!DI::config()->get('system', 'publish_all')) {
+                               $condition['publish'] = true;
+                       }
                }
 
-               $order = " ORDER BY `name` ASC ";
-               $profiles = [];
+               $total = DBA::count('owner-view', $condition);
 
                // If nothing found, don't try to select details
                if ($total > 0) {
-                       if (!empty($search)) {
-                               $searchTerm = '%' . $search . '%';
-
-                               $profiles = DBA::p("SELECT * FROM `owner-view`
-                                       WHERE $publish AND NOT `blocked` AND NOT `account_removed`
-                                       AND ((`name` LIKE ?) OR
-                                               (`nickname` LIKE ?) OR
-                                               (`about` LIKE ?) OR
-                                               (`locality` LIKE ?) OR
-                                               (`region` LIKE ?) OR
-                                               (`country-name` LIKE ?) OR
-                                               (`pub_keywords` LIKE ?) OR
-                                               (`prv_keywords` LIKE ?))
-                                       $order LIMIT ?,?",
-                                       $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm,
-                                       $start, $count
-                               );
-                       } else {
-                               $profiles = DBA::p("SELECT * FROM `owner-view`
-                                       WHERE $publish AND NOT `blocked` AND NOT `account_removed` $order LIMIT ?,?", $start, $count);
-                       }
-               }
-
-               if (DBA::isResult($profiles) && $total > 0) {
-                       return [
-                               'total'   => $total,
-                               'entries' => DBA::toArray($profiles),
-                       ];
-
+                       $profiles = DBA::selectToArray('owner-view', [], $condition, ['order' => ['name'], 'limit' => [$start, $count]]);
                } else {
-                       return [
-                               'total'   => $total,
-                               'entries' => [],
-                       ];
+                       $profiles = [];
                }
+
+               return ['total' => $total, 'entries' => $profiles];
        }
 }