]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
fix intro bug
[friendica.git] / mod / profile.php
index 7a3858ba260c40bb0ae8e20d1f785db04fcbdf9a..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()) {
@@ -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']),