]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
mongo checkin, global directory, redir rework, location basics
[friendica.git] / mod / profile.php
index 07c5357ff8026bfc3c3770b979ab931c83b7bba9..808ceedb8e862a4d5e2e6f689caa4315d352acbe 100644 (file)
@@ -34,6 +34,7 @@ function profile_load(&$a, $username, $profile = 0) {
        $a->page['template'] = 'profile';
 
        $a->page['title'] = $a->profile['name'];
+       $_SESSION['theme'] = $a->profile['theme'];
 
        return;
 }}
@@ -63,7 +64,11 @@ function profile_init(&$a) {
                $profile = $a->argv[1];         
        }
        profile_load($a,$which,$profile);
-       $a->page['htmlhead'] .= "<meta name=\"dfrn-template\" content=\"" . $a->get_baseurl() . "/profile/%s" . "\" />\r\n";
+        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
+
+        $a->page['htmlhead'] .= '<meta name="dfrn-template" content="' . $a->get_baseurl() . "/profile/%s" . '" />' . "\r\n" ;
+        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
+  
        
        $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
        foreach($dfrn_pages as $dfrn)
@@ -89,9 +94,18 @@ function profile_content(&$a, $update = false) {
        if(remote_user()) {
                $contact_id = $_SESSION['visitor_id'];
                $groups = init_groups_visitor($contact_id);
+               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                       intval($contact_id),
+                       intval($a->profile['uid'])
+               );
+               if(count($r))
+                       $contact = $r[0];
        }
-       if(local_user()) {
-               $contact_id = $_SESSION['cid'];
+       else {
+               if(local_user()) {
+                       $contact_id = $_SESSION['cid'];
+                       $contact = $a->contact;
+               }
        }
 
        if($update) {
@@ -106,7 +120,8 @@ function profile_content(&$a, $update = false) {
                $tpl = file_get_contents('view/profile_tabs.tpl');
 
                $o .= replace_macros($tpl,array(
-                       '$url' => $a->get_baseurl() . '/' . $a->cmd
+                       '$url' => $a->get_baseurl() . '/' . $a->cmd,
+                       '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname']
                ));
 
 
@@ -122,13 +137,16 @@ function profile_content(&$a, $update = false) {
                        require_once('view/acl_selectors.php');
 
                        $tpl = file_get_contents("view/jot.tpl");
-
+                       if(is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))
+                               $lockstate = 'lock';
+                       else
+                               $lockstate = 'unlock';
                        $o .= replace_macros($tpl,array(
                                '$baseurl' => $a->get_baseurl(),
                                '$return_path' => $a->cmd,
                                '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'),
-                               '$lockstate' => 'unlock',
-                               '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl() : ''),
+                               '$lockstate' => $lockstate,
+                               '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl($a->user) : ''),
                                '$profile_uid' => $a->profile['profile_uid']
                        ));
                }
@@ -180,7 +198,8 @@ function profile_content(&$a, $update = false) {
        $r = q("SELECT COUNT(*) AS `total`
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
-               AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
+               AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
+               AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote')
                $sql_extra ",
                intval($a->profile['uid'])
 
@@ -189,14 +208,14 @@ function profile_content(&$a, $update = false) {
        if(count($r))
                $a->set_pager_total($r[0]['total']);
 
-
        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
                `contact`.`name`, `contact`.`photo`, `contact`.`url`, 
                `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, 
                `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
-               AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+               AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+               AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote')
                $sql_extra
                ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
                intval($a->profile['uid']),
@@ -232,6 +251,9 @@ function profile_content(&$a, $update = false) {
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
                                                '$profile_uid' =>  $a->profile['uid'],
+                                               '$mylink' => $contact['url'],
+                                               '$mytitle' => t('Me'),
+                                               '$myphoto' => $contact['thumb'],
                                                '$ww' => ''
                                        ));
                                }
@@ -243,7 +265,8 @@ function profile_content(&$a, $update = false) {
                        // This is my profile but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend,
                        // I can go directly to their profile as an authenticated guest.
 
-                       if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
+                       if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) 
+                               && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && (! $item['self'] ))
                                $profile_url = $redirect_url;
 
                        // FIXME tryng to solve the mishmash of profile photos. 
@@ -276,10 +299,12 @@ function profile_content(&$a, $update = false) {
                                '$title' => $item['title'],
                                '$body' => bbcode($item['body']),
                                '$ago' => relative_date($item['created']),
+                               '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
                                '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
                                '$drop' => $drop,
                                '$comment' => $comment
                        ));
+                       
                }
        }