]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
using pre - one less str_replace for log viewing
[friendica.git] / mod / profile.php
index eea6b92a5894613ae7c436b50c5094a005d0a0ca..587ac6288e7b1cfa60b7a5dded955091bddf6a95 100644 (file)
@@ -2,6 +2,9 @@
 
 function profile_init(&$a) {
 
+       if((get_config('system','block_public')) && (! local_user()) && (! remote_user()))
+               return;
+
        if($a->argc > 1)
                $which = $a->argv[1];
        else {
@@ -48,10 +51,14 @@ function profile_init(&$a) {
 
 function profile_content(&$a, $update = 0) {
 
+       if(get_config('system','block_public') && (! local_user()) && (! remote_user())) {
+               return login();
+       }
+
        require_once("include/bbcode.php");
        require_once('include/security.php');
        require_once('include/conversation.php');
-
+       require_once('include/acl_selectors.php');
        $groups = array();
 
        $tab = 'posts';
@@ -90,19 +97,27 @@ function profile_content(&$a, $update = 0) {
        }
 
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
+
+       if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
+               notice( t('Access to this profile has been restricted.') . EOL);
+               return;
+       }
+
        
        if(! $update) {
                if(x($_GET,'tab'))
                        $tab = notags(trim($_GET['tab']));
 
-               $tpl = load_view_file('view/profile_tabs.tpl');
+               $tpl = get_markup_template('profile_tabs.tpl');
 
                $o .= replace_macros($tpl,array(
                        '$url' => $a->get_baseurl() . '/' . $a->cmd,
                        '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'],
                        '$status' => t('Status'),
                        '$profile' => t('Profile'),
-                       '$photos' => t('Photos')
+                       '$photos' => t('Photos'),
+                       '$events' => (($is_owner) ?     '<a href="events" id="profile-tab-events-link" class="profile-tabs" >' . t('Events') . '</a>' : ''),
+                       '$notes' => (($is_owner) ?      '<a href="notes" id="profile-tab-notes-link" class="profile-tabs" >' . t('Personal Notes') . '</a>' : '')
                ));
 
 
@@ -113,6 +128,9 @@ function profile_content(&$a, $update = 0) {
                        return $o;
                }
 
+               if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner)
+                       $o .= '<a href="newmember">' . t('Tips for New Members') . '</a>' . EOL;
+
                $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
                $commvisitor = (($commpage && $remote_contact == true) ? true : false);
 
@@ -159,7 +177,7 @@ function profile_content(&$a, $update = 0) {
                // Oh - while we're here... reset the Unseen messages
 
                $r = q("UPDATE `item` SET `unseen` = 0 
-                       WHERE `type` != 'remote' AND `unseen` = 1 AND `uid` = %d",
+                       WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
                        intval($_SESSION['uid'])
                );
 
@@ -228,12 +246,13 @@ function profile_content(&$a, $update = 0) {
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, 
                        `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
                        `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-                       FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                       FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent` = `p`.`id`) AS `parentitem`, `contact`
                        WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+                       AND `contact`.`id` = `item`.`contact-id`
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
-                       AND `item`.`parent` IN ( %s )
+                       AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )
                        $sql_extra
-                       ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
+                       ORDER BY `parentitem`.`created` DESC, `gravity` ASC, `item`.`created` ASC ",
                        intval($a->profile['profile_uid']),
                        dbesc($parents_str)
                );
@@ -242,11 +261,8 @@ function profile_content(&$a, $update = 0) {
        if($is_owner && ! $update)
                $o .= get_birthdays();
 
-
-
        $o .= conversation($a,$r,'profile',$update);
 
-
        if(! $update) {
                
                $o .= paginate($a);