]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
Merge pull request #2104 from rabuzarus/2611_contacts_directory
[friendica.git] / mod / contacts.php
index 6e1bbe05b8823975d93ddeca65d9c51d445ce86e..992f8ed6b2e43d51aba7db7fcd168131452d518e 100644 (file)
@@ -38,7 +38,7 @@ function contacts_init(&$a) {
                        $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) ? $a->get_baseurl()."/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']
                        ));
                        $finpeople_widget = '';
                        $follow_widget = '';
@@ -55,8 +55,7 @@ function contacts_init(&$a) {
                $findpeople_widget .= findpeople_widget();
        }
 
-       if ($a->argv[2] != "posts")
-               $groups_widget .= group_side('contacts','group','full',0,$contact_id);
+       $groups_widget .= group_side('contacts','group','full',0,$contact_id);
 
        $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
                '$vcard_widget' => $vcard_widget,
@@ -66,7 +65,7 @@ function contacts_init(&$a) {
                '$networks_widget' => $networks_widget
        ));
 
-       $base = $a->get_baseurl();
+       $base = z_root();
        $tpl = get_markup_template("contacts-head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl,array(
                '$baseurl' => $a->get_baseurl(true),
@@ -787,7 +786,7 @@ function contacts_content(&$a) {
 
        $tpl = get_markup_template("contacts-template.tpl");
        $o .= replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => z_root(),
                '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
                '$tabs' => $t,
                '$total' => $total,
@@ -882,19 +881,24 @@ function contact_posts($a, $contact_id) {
                profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
        }
 
-       $r = q("SELECT COUNT(*) AS `total` FROM `item`
-               WHERE `item`.`uid` = %d AND `contact-id` = %d AND `item`.`id` = `item`.`parent`",
-               intval(local_user()), intval($contact_id));
+       if(get_config('system', 'old_pager')) {
+               $r = q("SELECT COUNT(*) AS `total` FROM `item`
+                       WHERE `item`.`uid` = %d AND (`author-link` = '%s')",
+                       intval(local_user()), dbesc($contact["url"]));
 
-       $a->set_pager_total($r[0]['total']);
+               $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` WHERE `item`.`uid` = %d AND `contact-id` = %d AND `item`.`id` = `item`.`parent`
+               FROM `item` FORCE INDEX (uid_contactid_created)
+               WHERE `item`.`uid` = %d AND `contact-id` = %d
+                       AND (`author-link` = '%s')
                ORDER BY `item`.`created` DESC LIMIT %d, %d",
                intval(local_user()),
                intval($contact_id),
+               dbesc($contact["url"]),
                intval($a->pager['start']),
                intval($a->pager['itemspage'])
        );
@@ -927,6 +931,9 @@ function contact_posts($a, $contact_id) {
 }
 
 function _contact_detail_for_template($rr){
+
+       $community = '';
+
        switch($rr['rel']) {
                case CONTACT_IS_FRIEND:
                        $dir_icon = 'images/lrarrow.gif';
@@ -952,6 +959,10 @@ function _contact_detail_for_template($rr){
                $sparkle = '';
        }
 
+       //test if contact is a forum page
+       if (isset($rr['forum']) OR isset($rr['prv']))
+                               $community = ($rr['forum'] OR $rr['prv']);
+
 
        return array(
                'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
@@ -963,6 +974,7 @@ function _contact_detail_for_template($rr){
                'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
                'name' => htmlentities($rr['name']),
                'username' => htmlentities($rr['name']),
+               'account_type' => ($community ? t('Forum') : ''),
                'sparkle' => $sparkle,
                'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
                'url' => $url,