]> git.mxchange.org Git - friendica.git/commitdiff
Remove group_member.uid
authorHypolite Petovan <mrpetovan@gmail.com>
Fri, 15 Dec 2017 03:47:58 +0000 (22:47 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Fri, 15 Dec 2017 03:47:58 +0000 (22:47 -0500)
- Use contact.uid alternatively
- Use JOIN with group table

include/acl_selectors.php
include/uimport.php
mod/uexport.php
src/Database/DBStructure.php
src/Model/Contact.php
src/Model/Group.php

index d1b791136f6aec05c84d7d0d3a51b6be7e4cb209..7a488ca40bb6511b211ea57c2d45703373787e9a 100644 (file)
@@ -529,7 +529,7 @@ function acl_lookup(App $a, $out_type = 'json') {
                // This can be done when we can delete cache entries via wildcard
                $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
                                FROM `group`
-                               INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
+                               INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id`
                                WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
                                        $sql_extra
                                GROUP BY `group`.`name`, `group`.`id`
index e3c2f4e6c1f69c0b67953cf895ffd55e30b0d558..d9b040597fdc6c8affe2af20354a437821dba064 100644 (file)
@@ -232,8 +232,6 @@ function import_account(App $a, $file) {
        }
 
        foreach ($account['group_member'] as &$group_member) {
-               $group_member['uid'] = $newuid;
-
                $import = 0;
                foreach ($account['group'] as $group) {
                        if ($group['id'] == $group_member['gid'] && isset($group['newid'])) {
index 5a897f4abe23355a4aab37f69b82155f7a5dbdd3..39608250805d123041bb24805e132460abce6406 100644 (file)
@@ -109,7 +109,7 @@ function uexport_account($a) {
        );
 
        $group_member = _uexport_multirow(
-               sprintf("SELECT * FROM `group_member` WHERE uid = %d", intval(local_user()))
+               sprintf("SELECT `group_member`.`gid`, `group_member`.`contact-id` FROM `group_member` INNER JOIN `group` ON `group`.`id` = `group_member`.`gid` WHERE `group`.`uid` = %d", intval(local_user()))
        );
 
        $output = array(
index c118d862f726ace5eb155fe6980324511fad4f15..3dc555c861f3a980ea497a9bb2c9b0c6f533a186 100644 (file)
@@ -990,7 +990,6 @@ class DBStructure {
                $database["group_member"] = array(
                                "fields" => array(
                                                "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
-                                               "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
                                                "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
                                                "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
                                                ),
@@ -998,7 +997,6 @@ class DBStructure {
                                                "PRIMARY" => array("id"),
                                                "contactid" => array("contact-id"),
                                                "gid_contactid" => array("gid", "contact-id"),
-                                               "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
                                                )
                                );
                $database["gserver"] = array(
index 2e1bc01c741c070fe27b9c3e37310330a3f5670e..444ecf3c00bcfaef602bbb63ae2d5313f590996c 100644 (file)
@@ -42,7 +42,7 @@ class Contact extends BaseObject
                                INNER JOIN `group_member`
                                        ON `contact`.`id` = `group_member`.`contact-id`
                                WHERE `gid` = ?
-                               AND `group_member`.`uid` = ?
+                               AND `contact`.`uid` = ?
                                AND NOT `contact`.`self`
                                AND NOT `contact`.`blocked`
                                AND NOT `contact`.`pending`
@@ -73,7 +73,7 @@ class Contact extends BaseObject
                                INNER JOIN `group_member`
                                        ON `contact`.`id` = `group_member`.`contact-id`
                                WHERE `gid` = ?
-                               AND `group_member`.`uid` = ?
+                               AND `contact`.`uid` = ?
                                AND `contact`.`network` = ?
                                AND `contact`.`notify` != ""',
                                $gid,
@@ -605,7 +605,9 @@ class Contact extends BaseObject
                        AND NOT `pending`
                        AND `id` NOT IN (
                                SELECT DISTINCT(`contact-id`)
-                               FROM `group_member` WHERE `uid` = %d
+                               FROM `group_member`
+                               JOIN `group` ON `group`.`id` = `group_member`.`gid`
+                               WHERE `group`.`uid` = %d
                        )
                        LIMIT %d, %d", intval($uid), intval($uid), intval($start), intval($count)
                );
index cdc2a821d081ca2f93da0829c571d16afd397831..542827151039e72bcf31a982c4083b52a8534259 100644 (file)
@@ -96,8 +96,7 @@ class Group extends BaseObject
                                        AND `contact-id` IN
                                                (SELECT `contact-id`
                                                FROM `group_member`
-                                               WHERE `group_member`.`gid` = `group`.`id`
-                                               AND `group_member`.`uid` = ?)
+                                               WHERE `group_member`.`gid` = `group`.`id`)
                                        ) AS `count`
                                FROM `group`
                                WHERE `group`.`uid` = ?;",