]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
Bugfix: The display hadn't fetched the correct contact for the uid.
[friendica.git] / mod / contacts.php
index 99b1c37c499419093de1a34ed9648b49dc1b5a61..ac7c7d85a1f1e0e85b5ba8d606ba22cbfc13fd08 100644 (file)
@@ -35,10 +35,20 @@ function contacts_init(&$a) {
 
        if($contact_id) {
                        $a->data['contact'] = $r[0];
+
+                       if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
+                               $networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
+                       } else 
+                               $networkname = '';
+
                        $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
                                '$name' => htmlentities($a->data['contact']['name']),
                                '$photo' => $a->data['contact']['photo'],
-                               '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? z_root()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url']
+                               '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? z_root()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
+                               '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
+                               '$network_name' => $networkname,
+                               '$network' => t('Network:'),
+                               'account_type' => (($a->data['contact']['forum'] || $a->data['contact']['prv']) ? t('Forum') : '')
                        ));
                        $finpeople_widget = '';
                        $follow_widget = '';
@@ -335,7 +345,6 @@ function _contact_archive($contact_id, $orig_record) {
        return $r;
 }
 function _contact_drop($contact_id, $orig_record) {
-       require_once('include/Contact.php');
        $a = get_app();
 
        terminate_friendship($a->user,$a->contact,$orig_record);
@@ -570,16 +579,8 @@ function contacts_content(&$a) {
                        $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
 
 
-               $header = $contact["name"];
-
-               if ($contact["addr"] != "")
-                       $header .= " <".$contact["addr"].">";
-
-               $header .= " (".network_to_name($contact['network'], $contact['url']).")";
-
                $o .= replace_macros($tpl, array(
                        //'$header' => t('Contact Editor'),
-                       //'$header' => htmlentities($header),
                        '$tab_str' => $tab_str,
                        '$submit' => t('Submit'),
                        '$lbl_vis1' => t('Profile Visibility'),
@@ -829,7 +830,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
                        'sel' => (($active_tab == 2)?'active':''),
                        'title' => t('Profile Details'),
                        'id' => 'status-tab',
-                       'accesskey' => 'r',
+                       'accesskey' => 'o',
                )
        );
 
@@ -840,7 +841,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
                                'sel' => (($active_tab == 3)?'active':''),
                                'title' => t('View all contacts'),
                                'id' => 'allfriends-tab',
-                               'accesskey' => '');
+                               'accesskey' => 't');
 
        $common = count_common_friends(local_user(),$contact_id);
        if ($common)
@@ -849,7 +850,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
                                'sel' => (($active_tab == 4)?'active':''),
                                'title' => t('View all common friends'),
                                'id' => 'common-loc-tab',
-                               'accesskey' => '');
+                               'accesskey' => 'd');
 
        $tabs[] = array('label' => t('Repair'),
                        'url'   => $a->get_baseurl(true) . '/crepair/' . $contact_id,
@@ -888,65 +889,24 @@ function contacts_tab($a, $contact_id, $active_tab) {
 
 function contact_posts($a, $contact_id) {
 
-       require_once('include/conversation.php');
-
-       $r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($contact_id));
+       $r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
        if ($r) {
                $contact = $r[0];
                $a->page['aside'] = "";
                profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
-       }
-
-       if(get_config('system', 'old_pager')) {
-               $r = q("SELECT COUNT(*) AS `total` FROM `item`
-                       WHERE `item`.`uid` = %d AND `author-link` IN ('%s', '%s')",
-                       intval(local_user()),
-                       dbesc(normalise_link($contact["url"])),
-                       dbesc(str_replace("http://", "https://", $contact["url"])));
-
-               $a->set_pager_total($r[0]['total']);
-       }
-
-       $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
-                       `author-name` AS `name`, `owner-avatar` AS `photo`,
-                       `owner-link` AS `url`, `owner-avatar` AS `thumb`
-               FROM `item` FORCE INDEX (uid_contactid_created)
-               WHERE `item`.`uid` = %d AND `contact-id` = %d
-                       AND `author-link` IN ('%s', '%s')
-               ORDER BY `item`.`created` DESC LIMIT %d, %d",
-               intval(local_user()),
-               intval($contact_id),
-               dbesc(normalise_link($contact["url"])),
-               dbesc(str_replace("http://", "https://", $contact["url"])),
-               intval($a->pager['start']),
-               intval($a->pager['itemspage'])
-       );
-
-       if (!$r)
-               $o = $contact["url"]." - ".$contact_id;
+       } else
+               $profile = "";
 
        $tab_str = contacts_tab($a, $contact_id, 1);
 
-       $header = $contact["name"];
-
-       if ($contact["addr"] != "")
-               $header .= " <".$contact["addr"].">";
-
-       $header .= " (".network_to_name($contact['network'], $contact['url']).")";
-
-       //$tpl = get_markup_template("section_title.tpl");
-       //$o = replace_macros($tpl,array(
-        //        '$title' => htmlentities($header)
-        //));
-
        $o .= $tab_str;
 
-       $o .= conversation($a,$r,'community',false);
+       if ($contact["url"]) {
+               $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
+                       dbesc(normalise_link($contact["url"])));
 
-       if(!get_config('system', 'old_pager')) {
-               $o .= alt_pager($a,count($r));
-       } else {
-               $o .= paginate($a);
+               if ($r[0]["id"] <> 0)
+                       $o .= posts_from_gcontact($a, $r[0]["id"]);
        }
 
        return $o;