]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
Database stuff. New table "thread". Changing "left join" to "inner join", removing...
[friendica.git] / mod / profiles.php
index 1fc1f484a3035e0043c6b9ef86a5d8df01a73cb5..3e45f1c45121dc2fc829c43fad1590a23e765e24 100644 (file)
@@ -6,8 +6,6 @@ function profiles_init(&$a) {
        nav_set_selected('profiles');
 
        if(! local_user()) {
-               notice( t('Permission denied.') . EOL);
-               killme();
                return;
        }
 
@@ -21,7 +19,7 @@ function profiles_init(&$a) {
                        goaway($a->get_baseurl(true) . '/profiles');
                        return; // NOTREACHED
                }
-               
+
                check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
 
                // move every contact using this profile as their default to the user default
@@ -31,7 +29,7 @@ function profiles_init(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+               $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
                        intval($a->argv[2]),
                        intval(local_user())
                );
@@ -47,7 +45,7 @@ function profiles_init(&$a) {
 
 
        if(($a->argc > 1) && ($a->argv[1] === 'new')) {
-               
+
                check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
 
                $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
@@ -58,7 +56,7 @@ function profiles_init(&$a) {
 
                $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
                        intval(local_user()));
-               
+
                $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
                        VALUES ( %d, '%s', '%s', '%s', '%s' )",
                        intval(local_user()),
@@ -76,12 +74,12 @@ function profiles_init(&$a) {
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
                        goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
-               
+
                goaway($a->get_baseurl(true) . '/profiles');
        } 
 
        if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
-               
+
                check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
 
                $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
@@ -119,9 +117,9 @@ function profiles_init(&$a) {
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
                        goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
-               
+
                goaway($a->get_baseurl(true) . '/profiles');
-               
+
                return; // NOTREACHED
        }
 
@@ -162,7 +160,7 @@ function profiles_post(&$a) {
                        notice( t('Profile not found.') . EOL);
                        return;
                }
-               
+
                check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
                
                $is_default = (($orig[0]['is-default']) ? 1 : 0);
@@ -261,7 +259,7 @@ function profiles_post(&$a) {
                                                        intval(local_user())
                                                );
                                        }*/
-                                       
+
                                        $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                dbesc($newname),
                                                intval(local_user())
@@ -374,9 +372,9 @@ function profiles_post(&$a) {
 
                        profile_activity($changes,$value);
 
-               }                       
-                       
-               $r = q("UPDATE `profile` 
+               }
+
+               $r = q("UPDATE `profile`
                        SET `profile-name` = '%s',
                        `name` = '%s',
                        `pdesc` = '%s',
@@ -410,7 +408,7 @@ function profiles_post(&$a) {
                        `work` = '%s',
                        `education` = '%s',
                        `hide-friends` = %d
-                       WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                       WHERE `id` = %d AND `uid` = %d",
                        dbesc($profile_name),
                        dbesc($name),
                        dbesc($pdesc),
@@ -453,10 +451,14 @@ function profiles_post(&$a) {
 
 
                if($namechanged && $is_default) {
-                       $r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
+                       $r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
                                dbesc(datetime_convert()),
                                intval(local_user())
                        );
+                       $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
+                               dbesc($name),
+                               intval(local_user())
+                       );
                }
 
                if($is_default) {
@@ -552,7 +554,7 @@ function profile_activity($changed, $value) {
        if($i) {
 
                // give it a permanent link
-               q("update item set plink = '%s' where id = %d limit 1",
+               q("update item set plink = '%s' where id = %d",
                        dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
                        intval($i)
                );
@@ -565,6 +567,11 @@ function profile_activity($changed, $value) {
 
 function profiles_content(&$a) {
 
+       if(! local_user()) {
+               notice( t('Permission denied.') . EOL);
+               return;
+       }
+
        $o = '';
 
        if(($a->argc > 1) && (intval($a->argv[1]))) {