]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
generalise wallwall template and fix "via wall-to-wall" float
[friendica.git] / mod / profile.php
index a19f370de9e3cce2e468547612e6fcc2ac4ee7ad..5cab6662afbc21fb76cfa645398f1617d4990612 100644 (file)
@@ -1,53 +1,5 @@
 <?php
 
-if(! function_exists('profile_load')) {
-function profile_load(&$a, $username, $profile = 0) {
-       if(remote_user()) {
-               $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
-                       intval($_SESSION['visitor_id']));
-               if(count($r))
-                       $profile = $r[0]['profile-id'];
-       } 
-
-       $r = null;
-
-       if($profile) {
-               $profile_int = intval($profile);
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
-                       dbesc($username),
-                       intval($profile_int)
-               );
-       }
-       if(! count($r)) {       
-               $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
-                       LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-                       WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
-                       dbesc($username)
-               );
-       }
-
-       if(($r === false) || (! count($r))) {
-               notice( t('No profile') . EOL );
-               $a->error = 404;
-               return;
-       }
-
-       $a->profile = $r[0];
-
-       $a->page['template'] = 'profile';
-
-       $a->page['title'] = $a->profile['name'];
-       $_SESSION['theme'] = $a->profile['theme'];
-
-       if(! (x($a->page,'aside')))
-               $a->page['aside'] = '';
-       $a->page['aside'] .= contact_block();
-
-       return;
-}}
-
 function profile_init(&$a) {
 
        if($a->argc > 1)
@@ -66,13 +18,19 @@ function profile_init(&$a) {
 
        profile_load($a,$which,$profile);
 
+       if(x($a->profile,'openidserver'))                               
+               $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
+       if(x($a->profile,'openid')) {
+               $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
+               $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
+       }
+
        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
        $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
        $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
        header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-  
-       
+       
        $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
        foreach($dfrn_pages as $dfrn)
                $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
@@ -82,7 +40,6 @@ function profile_init(&$a) {
 
 function profile_content(&$a, $update = 0) {
 
-
        require_once("include/bbcode.php");
        require_once('include/security.php');
 
@@ -124,7 +81,7 @@ function profile_content(&$a, $update = 0) {
        }
 
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
-
+       
        if(! $update) {
                if(x($_GET,'tab'))
                        $tab = notags(trim($_GET['tab']));
@@ -145,35 +102,55 @@ function profile_content(&$a, $update = 0) {
                                require_once("view/$profile_lang/profile_advanced.php");
                        else
                                require_once('view/profile_advanced.php');
+
+                       call_hooks('profile_advanced',$o);
+
                        return $o;
                }
 
+               $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
+               $commvisitor = (($commpage && $remote_contact == true) ? true : false);
+
                $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false);
-               if(can_write_wall($a,$a->profile['profile_uid'])) {
 
+               if(can_write_wall($a,$a->profile['profile_uid'])) {
 
-                       $geotag = (($is_owner && $a->profile['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
+                       $geotag = ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
 
                        $tpl = load_view_file('view/jot-header.tpl');
        
                        $a->page['htmlhead'] .= replace_macros($tpl, array(
                                '$baseurl' => $a->get_baseurl(),
-                               '$geotag'  => $geotag
+                               '$geotag'  => $geotag,
+                               '$nickname' => $a->profile['nickname']
                        ));
 
                        require_once('include/acl_selectors.php');
 
-                       $tpl = load_view_file("view/jot.tpl");
+                       $tpl = load_view_file('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';
+       
+                       $jotplugins = '';
+                       $jotnets = '';
+                       call_hooks('jot_tool', $jotplugins); 
+
+                       call_hooks('jot_networks', $jotnets);
+
+                       $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));        
+
                        $o .= replace_macros($tpl,array(
                                '$baseurl' => $a->get_baseurl(),
                                '$defloc' => (($is_owner) ? $a->user['default-location'] : ''),
                                '$return_path' => $a->cmd,
-                               '$visitor' => (($is_owner) ? 'block' : 'none'),
+                               '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),
                                '$lockstate' => $lockstate,
+                               '$emailcc' => t('CC: email addresses'),
+                               '$jotnets' => $jotnets,
+                               '$emtitle' => t('Example: bob@example.com, mary@example.com'),
                                '$bang' => '',
                                '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
                                '$profile_uid' => $a->profile['profile_uid']
@@ -183,11 +160,11 @@ function profile_content(&$a, $update = 0) {
                // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
                // because browser prefetching might change it on us. We have to deliver it with the page.
 
-               if($tab === 'posts' && (! $a->pager['start'])) {
+               if($tab === 'posts') {
                        $o .= '<div id="live-profile"></div>' . "\r\n";
-                       $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] . "; </script>\r\n";
+                       $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] 
+                               . "; var netargs = ''; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                }
-
        }
 
        // Construct permissions
@@ -262,6 +239,10 @@ function profile_content(&$a, $update = 0) {
 
        );
 
+
+       if($is_owner && ! $update)
+               $o .= get_birthdays();
+
        $cmnt_tpl = load_view_file('view/comment_item.tpl');
 
        $like_tpl = load_view_file('view/like.tpl');
@@ -279,7 +260,7 @@ function profile_content(&$a, $update = 0) {
        $alike = array();
        $dlike = array();
 
-       if(count($r)) {
+       if($r !== false && count($r)) {
 
                foreach($r as $item) {
                        like_puller($a,$item,$alike,'like');
@@ -300,8 +281,8 @@ function profile_content(&$a, $update = 0) {
                                && ($item['id'] != $item['parent']))
                                continue;
 
-                       $lock = (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
-                               || strlen($item['deny_cid']) || strlen($item['deny_gid']))
+                       $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
+                               || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
                                ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
                                : '<div class="wall-item-lock"></div>');
 
@@ -311,7 +292,8 @@ function profile_content(&$a, $update = 0) {
                                }
                                if($item['last-child']) {
                                        $comment = replace_macros($cmnt_tpl,array(
-                                               '$return_path' => $_SESSION['return_url'],
+                                               '$return_path' => '', 
+                                               '$jsreload' => '', // $_SESSION['return_url'],
                                                '$type' => 'wall-comment',
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
@@ -327,7 +309,7 @@ function profile_content(&$a, $update = 0) {
 
                        $profile_url = $item['url'];
 
-                       // 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,
+                       // This is my profile page 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']) 
@@ -344,7 +326,7 @@ function profile_content(&$a, $update = 0) {
                        // local contact info at all. In this module you should never encounter a third-party author, but we still will do
                        // the right thing if you ever do. 
 
-                       $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
+                       $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
 
                        $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
                        $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
@@ -371,24 +353,36 @@ function profile_content(&$a, $update = 0) {
                                        $location = '<span class="smalltext">' . $coord . '</span>';
                        }
 
-                       $o .= replace_macros($template,array(
+                       $indent = (($item['parent'] != $item['item_id']) ? ' comment' : '');
+
+                       if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
+                               $indent .= ' shiny'; 
+
+                       $tmp_item = replace_macros($template,array(
                                '$id' => $item['item_id'],
+                               '$linktitle' => t('View $name\'s profile'),
                                '$profile_url' => $profile_link,
                                '$name' => $profile_name,
                                '$thumb' => $profile_avatar,
                                '$sparkle' => $sparkle,
                                '$title' => $item['title'],
-                               '$body' => bbcode($item['body']),
+                               '$body' => smilies(bbcode($item['body'])),
                                '$ago' => relative_date($item['created']),
                                '$lock' => $lock,
                                '$location' => $location, 
-                               '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
+                               '$indent' => $indent, 
+                               '$plink' => get_plink($item),
                                '$drop' => $drop,
                                '$like' => $like,
                                '$vote' => $likebuttons,
                                '$dislike' => $dislike,
                                '$comment' => $comment
                        ));
+
+                       $arr = array('item' => $item, 'output' => $tmp_item);
+                       call_hooks('display_item', $arr);
+
+                       $o .= $arr['output'];
                        
                }
        }
@@ -398,6 +392,8 @@ function profile_content(&$a, $update = 0) {
        }
                
        $o .= paginate($a);
+       $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
+
 
        return $o;
-}
\ No newline at end of file
+}