]> git.mxchange.org Git - friendica.git/commitdiff
Bugfix: "default_group" behaviour wasn't implemented correctly
authorMichael Vogel <icarus@dabo.de>
Wed, 13 Apr 2016 20:21:23 +0000 (22:21 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 13 Apr 2016 20:21:23 +0000 (22:21 +0200)
include/diaspora.php
include/follow.php
include/items.php
mod/dfrn_confirm.php
mod/dfrn_request.php

index e3a3dcd78c2e05d37d177b9f5b4a6e78db2cceb5..1ceeef605e7aa25d0c8b79a13f7654627bbf6a4d 100644 (file)
@@ -1819,12 +1819,10 @@ class diaspora {
                        return;
                }
 
-               $g = q("SELECT `def_gid` FROM `user` WHERE `uid` = %d LIMIT 1",
-                       intval($importer["uid"])
-               );
+               $def_gid = get_default_group($importer['uid'], $ret["network"]);
 
-               if($g && intval($g[0]["def_gid"]))
-                       group_add_member($importer["uid"], "", $contact_record["id"], $g[0]["def_gid"]);
+               if(intval($def_gid))
+                       group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
 
                if($importer["page-flags"] == PAGE_NORMAL) {
 
index d0411a466af0411045ed9455f2c25019a67a3c00..2461bf0356b63ae9fd0ffd2d31f3dbbb89fa2fd3 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 require_once("include/Scrape.php");
 require_once("include/socgraph.php");
+require_once('include/group.php');
 
 function update_contact($id) {
        /*
@@ -259,10 +260,8 @@ function new_contact($uid,$url,$interactive = false) {
        $result['cid'] = $contact_id;
 
        $def_gid = get_default_group($uid, $contact["network"]);
-       if (intval($def_gid)) {
-               require_once('include/group.php');
+       if (intval($def_gid))
                group_add_member($uid, '', $contact_id, $def_gid);
-       }
 
        require_once("include/Photo.php");
 
index 4627b10ca29491955e1db5bef9c22c47901c728d..b32ed2b16f1227baef96c70a942f77920462d02a 100644 (file)
@@ -18,6 +18,7 @@ require_once('include/Contact.php');
 require_once('mod/share.php');
 require_once('include/enotify.php');
 require_once('include/dfrn.php');
+require_once('include/group.php');
 
 require_once('library/defuse/php-encryption-1.2.1/Crypto.php');
 
@@ -1378,7 +1379,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                        dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS),
                        intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER)
                );
-               $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
+               $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
                                intval($importer['uid']),
                                dbesc($url)
                );
@@ -1415,10 +1416,10 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                                );
                        }
 
-                       if(intval($r[0]['def_gid'])) {
-                               require_once('include/group.php');
-                               group_add_member($r[0]['uid'],'',$contact_record['id'],$r[0]['def_gid']);
-                       }
+                       $def_gid = get_default_group($importer['uid'], $contact_record["network"]);
+
+                       if(intval($def_gid))
+                               group_add_member($importer['uid'],'',$contact_record['id'],$def_gid);
 
                        if(($r[0]['notify-flags'] & NOTIFY_INTRO) &&
                                in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
@@ -1648,7 +1649,6 @@ function compare_permissions($obj1,$obj2) {
 // returns an array of contact-ids that are allowed to see this object
 
 function enumerate_permissions($obj) {
-       require_once('include/group.php');
        $allow_people = expand_acl($obj['allow_cid']);
        $allow_groups = expand_groups(expand_acl($obj['allow_gid']));
        $deny_people  = expand_acl($obj['deny_cid']);
index 5e0e5c85c5173197b6dd802ace0a6bc916cbedc2..9c70ba21ab4c19c4721d7b8d345d489af4eb350f 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 require_once('include/enotify.php');
+require_once('include/group.php');
 
 function dfrn_confirm_post(&$a,$handsfree = null) {
 
@@ -491,10 +492,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                }
 
                $def_gid = get_default_group($uid, $contact["network"]);
-               if($contact && intval($def_gid)) {
-                       require_once('include/group.php');
+               if($contact && intval($def_gid))
                        group_add_member($uid, '', $contact['id'], $def_gid);
-               }
 
                // Let's send our user to the contact editor in case they want to
                // do anything special with this new friend.
index 837eec2dd244ef222e9013ccb8160439c00011f0..32e835b71557450863c161e5eed197dd02e09bb9 100644 (file)
@@ -11,6 +11,7 @@
 
 require_once('include/enotify.php');
 require_once('include/Scrape.php');
+require_once('include/group.php');
 
 if(! function_exists('dfrn_request_init')) {
 function dfrn_request_init(&$a) {
@@ -181,10 +182,9 @@ function dfrn_request_post(&$a) {
                                );
                                if(count($r)) {
                                        $def_gid = get_default_group(local_user(), $r[0]["network"]);
-                                       if(intval($def_gid)) {
-                                               require_once('include/group.php');
+                                       if(intval($def_gid))
                                                group_add_member(local_user(), '', $r[0]['id'], $def_gid);
-                                       }
+
                                        $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
                                } else
                                        $forwardurl = $a->get_baseurl()."/contacts";
@@ -394,10 +394,8 @@ function dfrn_request_post(&$a) {
                                $contact_id = $r[0]['id'];
 
                                $def_gid = get_default_group($uid, $r[0]["network"]);
-                               if (intval($def_gid)) {
-                                       require_once('include/group.php');
+                               if (intval($def_gid))
                                        group_add_member($uid, '', $contact_id, $def_gid);
-                               }
 
                                $photo = avatar_img($addr);