]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
fix intro bug
[friendica.git] / mod / profile.php
index 7b54340a91e66e0481d44361c33bafb13fb7177e..bb7357e5b7e70e1aefd9bb94cee15160c24cf2d5 100644 (file)
@@ -1,11 +1,7 @@
 <?php
 
 if(! function_exists('profile_load')) {
-function profile_load(&$a,$uid,$profile = 0) {
-
-       $sql_extra = (($uid) && (intval($uid)) 
-               ? " WHERE `user`.`uid` = " . intval($uid) 
-               : " WHERE `user`.`nickname` = '" . dbesc($uid) . "' " ); 
+function profile_load(&$a, $username, $profile = 0) {
 
        if(remote_user()) {
                $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
@@ -23,7 +19,8 @@ function profile_load(&$a,$uid,$profile = 0) {
 
        $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` 
                LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
-               $sql_extra $sql_which LIMIT 1"
+               WHERE `user`.`nickname` = '%s' $sql_which LIMIT 1",
+               dbesc($username)
        );
 
        if(($r === false) || (! count($r))) {
@@ -129,8 +126,17 @@ function profile_content(&$a) {
 
        // Profile owner - everything is visible
 
-       if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid']))
+       if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid'])) {
                $sql_extra = ''; 
+               
+               // 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",
+                       intval($_SESSION['uid'])
+               );
+
+       }
 
        // authenticated visitor - here lie dragons
        elseif(remote_user()) {
@@ -141,9 +147,9 @@ function profile_content(&$a) {
                } 
                $sql_extra = sprintf(
                        " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) 
-                       AND ( `deny_cid` = '' OR  NOT `deny_cid` REGEXP '<%d>' ) 
-                       AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
-                       AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
+                         AND ( `deny_cid`  = '' OR  NOT `deny_cid` REGEXP '<%d>' ) 
+                         AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
+                         AND ( `deny_gid`  = '' OR NOT `deny_gid` REGEXP '%s') ",
 
                        intval($_SESSION['visitor_id']),
                        intval($_SESSION['visitor_id']),
@@ -155,7 +161,7 @@ function profile_content(&$a) {
        $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 `item`.`type` != 'remote' AND `contact`.`blocked` = 0 
+               AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
                $sql_extra ",
                intval($a->profile['uid'])
 
@@ -171,7 +177,7 @@ function profile_content(&$a) {
                `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 `item`.`type` != 'remote' AND `contact`.`blocked` = 0 
+               AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                $sql_extra
                ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
                intval($a->profile['uid']),
@@ -196,6 +202,7 @@ function profile_content(&$a) {
                        if(can_write_wall($a,$a->profile['profile_uid'])) {
                                if($item['last-child']) {
                                        $comment = replace_macros($cmnt_tpl,array(
+                                               '$return_path' => $a->cmd,
                                                '$id' => $item['item_id'],
                                                '$parent' => $item['parent'],
                                                '$profile_uid' =>  $a->profile['profile_uid'],
@@ -223,8 +230,8 @@ function profile_content(&$a) {
                        // known to us and is reflected in the contact-id for this item. We can use the contact url or redirect rather than 
                        // use the link in the feed. This is different than on the network page where we may not know the author.
  
-                       $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']);
-                       $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $item['thumb']);
+                       $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
+                       $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
                        $profile_link = $profile_url;
 
                        $o .= replace_macros($template,array(