]> git.mxchange.org Git - friendica.git/blobdiff - mod/directory.php
Adjusted implementation to a better one (thanks to Michael Vogel)
[friendica.git] / mod / directory.php
index 1179b6c53afbdc1c97c89192e423c4efca050f7c..411024dc1aace31a38e12b6f735d5a693a5a0fd7 100644 (file)
@@ -2,15 +2,17 @@
 /**
  * @file mod/directory.php
  */
+
 use Friendica\App;
 use Friendica\Content\Nav;
 use Friendica\Content\Widget;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Util\Proxy as ProxyUtils;
 
 function directory_init(App $a)
 {
@@ -34,8 +36,6 @@ function directory_post(App $a)
 
 function directory_content(App $a)
 {
-       require_once("mod/proxy.php");
-
        if ((Config::get('system', 'block_public') && !local_user() && !remote_user())
                || (Config::get('system', 'block_local_dir') && !local_user() && !remote_user())
        ) {
@@ -59,7 +59,7 @@ function directory_content(App $a)
        }
 
        if ($search) {
-               $search = dbesc($search);
+               $search = DBA::escape($search);
 
                $sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
                                (`user`.`nickname` LIKE '%$search%') OR
@@ -76,15 +76,17 @@ function directory_content(App $a)
                                (`profile`.`education` LIKE '%$search%') OR
                                (`profile`.`pub_keywords` LIKE '%$search%') OR
                                (`profile`.`prv_keywords` LIKE '%$search%'))";
+       } else {
+               $sql_extra = '';
        }
 
        $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
 
 
-       $cnt = dba::fetch_first("SELECT COUNT(*) AS `total` FROM `profile`
+       $cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` FROM `profile`
                                LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
-                               WHERE `is-default` $publish AND NOT `user`.`blocked` $sql_extra");
-       if (DBM::is_result($cnt)) {
+                               WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
+       if (DBA::isResult($cnt)) {
                $a->set_pager_total($cnt['total']);
        }
 
@@ -92,20 +94,21 @@ function directory_content(App $a)
 
        $limit = intval($a->pager['start'])."," . intval($a->pager['itemspage']);
 
-       $r = dba::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
+       $r = DBA::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
                        `contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
                        LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
                        LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
-                       WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit
+                       WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
+                       $sql_extra $order LIMIT $limit"
        );
-       if (DBM::is_result($r)) {
+       if (DBA::isResult($r)) {
                if (in_array('small', $a->argv)) {
                        $photo = 'thumb';
                } else {
                        $photo = 'photo';
                }
 
-               while ($rr = dba::fetch($r)) {
+               while ($rr = DBA::fetch($r)) {
                        $itemurl= '';
 
                        $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@@ -146,6 +149,8 @@ function directory_content(App $a)
                                || (x($profile, 'country-name') == 1)
                        ) {
                                $location = L10n::t('Location:');
+                       } else {
+                               $location = '';
                        }
 
                        $gender   = ((x($profile, 'gender')   == 1) ? L10n::t('Gender:')   : false);
@@ -156,14 +161,14 @@ function directory_content(App $a)
                        $location_e = $location;
 
                        $photo_menu = [
-                               'profile' => [L10n::t("View Profile"), Profile::zrl($profile_link)]
+                               'profile' => [L10n::t("View Profile"), Contact::magicLink($profile_link)]
                        ];
 
                        $entry = [
                                'id'           => $rr['id'],
                                'url'          => $profile_link,
                                'itemurl'      => $itemurl,
-                               'thumb'        => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
+                               'thumb'        => ProxyUtils::proxifyUrl($rr[$photo], false, ProxyUtils::SIZE_THUMB),
                                'img_hover'    => $rr['name'],
                                'name'         => $rr['name'],
                                'details'      => $details,
@@ -193,7 +198,7 @@ function directory_content(App $a)
 
                        $entries[] = $arr['entry'];
                }
-               dba::close($r);
+               DBA::close($r);
 
                $tpl = get_markup_template('directory_header.tpl');