]> git.mxchange.org Git - friendica.git/blobdiff - include/contact_widgets.php
Issue 3857: There is the possibility of a bad handling of dislikes
[friendica.git] / include / contact_widgets.php
index 3cd18c7792cb257178a1e00b3f388e19ca83a210..b359781ffd734b818187caaa65df898bc57ac9ba 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 
 use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Core\Config;
+
+require_once 'include/contact_selectors.php';
 
 function follow_widget($value = "") {
 
@@ -18,6 +22,7 @@ function findpeople_widget() {
        require_once 'include/Contact.php';
 
        $a = get_app();
+       $global_dir = Config::get('system', 'directory');
 
        if (get_config('system', 'invitation_only')) {
                $x = get_pconfig(local_user(), 'system', 'invites_remaining');
@@ -37,7 +42,9 @@ function findpeople_widget() {
                '$suggest' => t('Friend Suggestions'),
                '$similar' => t('Similar Interests'),
                '$random' => t('Random Profile'),
-               '$inv' => t('Invite Friends')
+               '$inv' => t('Invite Friends'),
+               '$directory' => t('View Global Directory'),
+               '$global_dir' => $global_dir
        ));
 
 }
@@ -104,20 +111,18 @@ function networks_widget($baseurl, $selected = '') {
 
        $extra_sql = unavailable_networks();
 
-       $r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `network` != '' $extra_sql ORDER BY `network`",
-               intval(local_user())
+       $r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
+               local_user()
        );
 
        $nets = array();
-       if (dbm::is_result($r)) {
-               require_once 'include/contact_selectors.php';
-               foreach ($r as $rr) {
-                       /// @TODO If 'network' is not there, this triggers an E_NOTICE
-                       if ($rr['network']) {
-                               $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
-                       }
+       while ($rr = dba::fetch($r)) {
+               /// @TODO If 'network' is not there, this triggers an E_NOTICE
+               if ($rr['network']) {
+                       $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
                }
        }
+       dba::close($r);
 
        if (count($nets) < 2) {
                return '';
@@ -225,18 +230,14 @@ function common_friends_visitor_widget($profile_uid) {
 
        if (! $cid) {
                if (get_my_url()) {
-                       $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
-                               dbesc(normalise_link(get_my_url())),
-                               intval($profile_uid)
-                       );
+                       $r = dba::select('contact', array('id'),
+                                       array('nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid), array('limit' => 1));
                        if (dbm::is_result($r)) {
-                               $cid = $r[0]['id'];
+                               $cid = $r['id'];
                        } else {
-                               $r = q("select id from gcontact where nurl = '%s' limit 1",
-                                       dbesc(normalise_link(get_my_url()))
-                               );
+                               $r = dba::select('gcontact', array('id'), array('nurl' => normalise_link(get_my_url())), array('limit' => 1));
                                if (dbm::is_result($r))
-                                       $zcid = $r[0]['id'];
+                                       $zcid = $r['id'];
                        }
                }
        }
@@ -264,7 +265,7 @@ function common_friends_visitor_widget($profile_uid) {
 
        return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
                '$desc' =>  sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
-               '$base' => App::get_baseurl(),
+               '$base' => System::baseUrl(),
                '$uid' => $profile_uid,
                '$cid' => (($cid) ? $cid : '0'),
                '$linkmore' => (($t > 5) ? 'true' : ''),