Bugfix: "default_group" behaviour wasn't implemented correctly

This commit is contained in:
Michael Vogel 2016-04-13 22:21:23 +02:00
parent a7d6fa1bc9
commit d6a79abb68
5 changed files with 17 additions and 23 deletions

View file

@ -1819,12 +1819,10 @@ class diaspora {
return; return;
} }
$g = q("SELECT `def_gid` FROM `user` WHERE `uid` = %d LIMIT 1", $def_gid = get_default_group($importer['uid'], $ret["network"]);
intval($importer["uid"])
);
if($g && intval($g[0]["def_gid"])) if(intval($def_gid))
group_add_member($importer["uid"], "", $contact_record["id"], $g[0]["def_gid"]); group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
if($importer["page-flags"] == PAGE_NORMAL) { if($importer["page-flags"] == PAGE_NORMAL) {

View file

@ -1,6 +1,7 @@
<?php <?php
require_once("include/Scrape.php"); require_once("include/Scrape.php");
require_once("include/socgraph.php"); require_once("include/socgraph.php");
require_once('include/group.php');
function update_contact($id) { function update_contact($id) {
/* /*
@ -259,10 +260,8 @@ function new_contact($uid,$url,$interactive = false) {
$result['cid'] = $contact_id; $result['cid'] = $contact_id;
$def_gid = get_default_group($uid, $contact["network"]); $def_gid = get_default_group($uid, $contact["network"]);
if (intval($def_gid)) { if (intval($def_gid))
require_once('include/group.php');
group_add_member($uid, '', $contact_id, $def_gid); group_add_member($uid, '', $contact_id, $def_gid);
}
require_once("include/Photo.php"); require_once("include/Photo.php");

View file

@ -18,6 +18,7 @@ require_once('include/Contact.php');
require_once('mod/share.php'); require_once('mod/share.php');
require_once('include/enotify.php'); require_once('include/enotify.php');
require_once('include/dfrn.php'); require_once('include/dfrn.php');
require_once('include/group.php');
require_once('library/defuse/php-encryption-1.2.1/Crypto.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), dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS),
intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER) 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']), intval($importer['uid']),
dbesc($url) dbesc($url)
); );
@ -1415,10 +1416,10 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
); );
} }
if(intval($r[0]['def_gid'])) { $def_gid = get_default_group($importer['uid'], $contact_record["network"]);
require_once('include/group.php');
group_add_member($r[0]['uid'],'',$contact_record['id'],$r[0]['def_gid']); if(intval($def_gid))
} group_add_member($importer['uid'],'',$contact_record['id'],$def_gid);
if(($r[0]['notify-flags'] & NOTIFY_INTRO) && if(($r[0]['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) { 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 // returns an array of contact-ids that are allowed to see this object
function enumerate_permissions($obj) { function enumerate_permissions($obj) {
require_once('include/group.php');
$allow_people = expand_acl($obj['allow_cid']); $allow_people = expand_acl($obj['allow_cid']);
$allow_groups = expand_groups(expand_acl($obj['allow_gid'])); $allow_groups = expand_groups(expand_acl($obj['allow_gid']));
$deny_people = expand_acl($obj['deny_cid']); $deny_people = expand_acl($obj['deny_cid']);

View file

@ -15,6 +15,7 @@
*/ */
require_once('include/enotify.php'); require_once('include/enotify.php');
require_once('include/group.php');
function dfrn_confirm_post(&$a,$handsfree = null) { 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"]); $def_gid = get_default_group($uid, $contact["network"]);
if($contact && intval($def_gid)) { if($contact && intval($def_gid))
require_once('include/group.php');
group_add_member($uid, '', $contact['id'], $def_gid); group_add_member($uid, '', $contact['id'], $def_gid);
}
// Let's send our user to the contact editor in case they want to // Let's send our user to the contact editor in case they want to
// do anything special with this new friend. // do anything special with this new friend.

View file

@ -11,6 +11,7 @@
require_once('include/enotify.php'); require_once('include/enotify.php');
require_once('include/Scrape.php'); require_once('include/Scrape.php');
require_once('include/group.php');
if(! function_exists('dfrn_request_init')) { if(! function_exists('dfrn_request_init')) {
function dfrn_request_init(&$a) { function dfrn_request_init(&$a) {
@ -181,10 +182,9 @@ function dfrn_request_post(&$a) {
); );
if(count($r)) { if(count($r)) {
$def_gid = get_default_group(local_user(), $r[0]["network"]); $def_gid = get_default_group(local_user(), $r[0]["network"]);
if(intval($def_gid)) { if(intval($def_gid))
require_once('include/group.php');
group_add_member(local_user(), '', $r[0]['id'], $def_gid); group_add_member(local_user(), '', $r[0]['id'], $def_gid);
}
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id']; $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
} else } else
$forwardurl = $a->get_baseurl()."/contacts"; $forwardurl = $a->get_baseurl()."/contacts";
@ -394,10 +394,8 @@ function dfrn_request_post(&$a) {
$contact_id = $r[0]['id']; $contact_id = $r[0]['id'];
$def_gid = get_default_group($uid, $r[0]["network"]); $def_gid = get_default_group($uid, $r[0]["network"]);
if (intval($def_gid)) { if (intval($def_gid))
require_once('include/group.php');
group_add_member($uid, '', $contact_id, $def_gid); group_add_member($uid, '', $contact_id, $def_gid);
}
$photo = avatar_img($addr); $photo = avatar_img($addr);