Merge branch 'patch-10' into 'dev'

rename groups and group_members tables for MySQL 8 compatibility

See merge request hubzilla/core!1290
This commit is contained in:
Mario 2018-09-28 09:41:21 +02:00
commit 9e87219aea
25 changed files with 137 additions and 118 deletions

View File

@ -20,11 +20,11 @@ class Group {
// access lists. What we're doing here is reviving the dead group, but old content which // access lists. What we're doing here is reviving the dead group, but old content which
// was restricted to this group may now be seen by the new group members. // was restricted to this group may now be seen by the new group members.
$z = q("SELECT * FROM groups WHERE id = %d LIMIT 1", $z = q("SELECT * FROM pgrp WHERE id = %d LIMIT 1",
intval($r) intval($r)
); );
if(($z) && $z[0]['deleted']) { if(($z) && $z[0]['deleted']) {
q('UPDATE groups SET deleted = 0 WHERE id = %d', intval($z[0]['id'])); q('UPDATE pgrp SET deleted = 0 WHERE id = %d', intval($z[0]['id']));
notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL); notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
} }
return true; return true;
@ -34,13 +34,13 @@ class Group {
$dups = false; $dups = false;
$hash = random_string(32) . str_replace(['<','>'],['.','.'], $name); $hash = random_string(32) . str_replace(['<','>'],['.','.'], $name);
$r = q("SELECT id FROM groups WHERE hash = '%s' LIMIT 1", dbesc($hash)); $r = q("SELECT id FROM pgrp WHERE hash = '%s' LIMIT 1", dbesc($hash));
if($r) if($r)
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
$r = q("INSERT INTO groups ( hash, uid, visible, gname ) $r = q("INSERT INTO pgrp ( hash, uid, visible, gname )
VALUES( '%s', %d, %d, '%s' ) ", VALUES( '%s', %d, %d, '%s' ) ",
dbesc($hash), dbesc($hash),
intval($uid), intval($uid),
@ -58,7 +58,7 @@ class Group {
static function remove($uid,$name) { static function remove($uid,$name) {
$ret = false; $ret = false;
if(x($uid) && x($name)) { if(x($uid) && x($name)) {
$r = q("SELECT id, hash FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", $r = q("SELECT id, hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -103,13 +103,13 @@ class Group {
} }
// remove all members // remove all members
$r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d ", $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d ",
intval($uid), intval($uid),
intval($group_id) intval($group_id)
); );
// remove group // remove group
$r = q("UPDATE groups SET deleted = 1 WHERE uid = %d AND gname = '%s'", $r = q("UPDATE pgrp SET deleted = 1 WHERE uid = %d AND gname = '%s'",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -127,7 +127,7 @@ class Group {
static function byname($uid,$name) { static function byname($uid,$name) {
if((! $uid) || (! strlen($name))) if((! $uid) || (! strlen($name)))
return false; return false;
$r = q("SELECT * FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -140,7 +140,7 @@ class Group {
static function rec_byhash($uid,$hash) { static function rec_byhash($uid,$hash) {
if((! $uid) || (! strlen($hash))) if((! $uid) || (! strlen($hash)))
return false; return false;
$r = q("SELECT * FROM groups WHERE uid = %d AND hash = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($hash) dbesc($hash)
); );
@ -156,7 +156,7 @@ class Group {
return false; return false;
if(! ( $uid && $gid && $member)) if(! ( $uid && $gid && $member))
return false; return false;
$r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' ", $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' ",
intval($uid), intval($uid),
intval($gid), intval($gid),
dbesc($member) dbesc($member)
@ -174,7 +174,7 @@ class Group {
if((! $gid) || (! $uid) || (! $member)) if((! $gid) || (! $uid) || (! $member))
return false; return false;
$r = q("SELECT * FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1",
intval($uid), intval($uid),
intval($gid), intval($gid),
dbesc($member) dbesc($member)
@ -184,7 +184,7 @@ class Group {
// we indicate success because the group member was in fact created // we indicate success because the group member was in fact created
// -- It was just created at another time // -- It was just created at another time
if(! $r) if(! $r)
$r = q("INSERT INTO group_member (uid, gid, xchan) $r = q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ", VALUES( %d, %d, '%s' ) ",
intval($uid), intval($uid),
intval($gid), intval($gid),
@ -200,9 +200,9 @@ class Group {
static function members($gid) { static function members($gid) {
$ret = array(); $ret = array();
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT * FROM group_member $r = q("SELECT * FROM pgrp_member
LEFT JOIN abook ON abook_xchan = group_member.xchan left join xchan on xchan_hash = abook_xchan LEFT JOIN abook ON abook_xchan = pgrp_member.xchan left join xchan on xchan_hash = abook_xchan
WHERE gid = %d AND abook_channel = %d and group_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ", WHERE gid = %d AND abook_channel = %d and pgrp_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ",
intval($gid), intval($gid),
intval(local_channel()), intval(local_channel()),
intval(local_channel()) intval(local_channel())
@ -216,7 +216,7 @@ class Group {
static function members_xchan($gid) { static function members_xchan($gid) {
$ret = []; $ret = [];
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT xchan FROM group_member WHERE gid = %d AND uid = %d", $r = q("SELECT xchan FROM pgrp_member WHERE gid = %d AND uid = %d",
intval($gid), intval($gid),
intval(local_channel()) intval(local_channel())
); );
@ -254,7 +254,7 @@ class Group {
$grps = []; $grps = [];
$o = ''; $o = '';
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval($uid) intval($uid)
); );
$grps[] = array('name' => '', 'hash' => '0', 'selected' => ''); $grps[] = array('name' => '', 'hash' => '0', 'selected' => '');
@ -286,7 +286,7 @@ class Group {
$groups = array(); $groups = array();
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
$member_of = array(); $member_of = array();
@ -366,7 +366,7 @@ class Group {
stringify_array_elms($x,true); stringify_array_elms($x,true);
$groups = implode(',', $x); $groups = implode(',', $x);
if($groups) { if($groups) {
$r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from groups where hash in ( $groups ))"); $r = q("SELECT xchan FROM pgrp_member WHERE gid IN ( select id from pgrp where hash in ( $groups ))");
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
$ret[] = $rr['xchan']; $ret[] = $rr['xchan'];
@ -379,7 +379,7 @@ class Group {
static function member_of($c) { static function member_of($c) {
$r = q("SELECT groups.gname, groups.id FROM groups LEFT JOIN group_member ON group_member.gid = groups.id WHERE group_member.xchan = '%s' AND groups.deleted = 0 ORDER BY groups.gname ASC ", $r = q("SELECT pgrp.gname, pgrp.id FROM pgrp LEFT JOIN pgrp_member ON pgrp_member.gid = pgrp.id WHERE pgrp_member.xchan = '%s' AND pgrp.deleted = 0 ORDER BY pgrp.gname ASC ",
dbesc($c) dbesc($c)
); );
@ -389,7 +389,7 @@ class Group {
static function containing($uid,$c) { static function containing($uid,$c) {
$r = q("SELECT gid FROM group_member WHERE uid = %d AND group_member.xchan = '%s' ", $r = q("SELECT gid FROM pgrp_member WHERE uid = %d AND pgrp_member.xchan = '%s' ",
intval($uid), intval($uid),
dbesc($c) dbesc($c)
); );

View File

@ -122,13 +122,13 @@ class Libsync {
} }
if($groups_changed) { if($groups_changed) {
$r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d", $r = q("select hash as collection, visible, deleted, gname as name from pgrp where uid = %d",
intval($uid) intval($uid)
); );
if($r) if($r)
$info['collections'] = $r; $info['collections'] = $r;
$r = q("select groups.hash as collection, group_member.xchan as member from groups left join group_member on groups.id = group_member.gid where group_member.uid = %d", $r = q("select pgrp.hash as collection, pgrp_member.xchan as member from pgrp left join pgrp_member on pgrp.id = pgrp_member.gid where pgrp_member.uid = %d",
intval($uid) intval($uid)
); );
if($r) if($r)
@ -464,7 +464,7 @@ class Libsync {
// sync collections (privacy groups) oh joy... // sync collections (privacy groups) oh joy...
if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) { if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) {
$x = q("select * from groups where uid = %d", $x = q("select * from pgrp where uid = %d",
intval($channel['channel_id']) intval($channel['channel_id'])
); );
foreach($arr['collections'] as $cl) { foreach($arr['collections'] as $cl) {
@ -480,7 +480,7 @@ class Libsync {
if(($y['gname'] != $cl['name']) if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible']) || ($y['visible'] != $cl['visible'])
|| ($y['deleted'] != $cl['deleted'])) { || ($y['deleted'] != $cl['deleted'])) {
q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d", q("update pgrp set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d",
dbesc($cl['name']), dbesc($cl['name']),
intval($cl['visible']), intval($cl['visible']),
intval($cl['deleted']), intval($cl['deleted']),
@ -489,14 +489,14 @@ class Libsync {
); );
} }
if(intval($cl['deleted']) && (! intval($y['deleted']))) { if(intval($cl['deleted']) && (! intval($y['deleted']))) {
q("delete from group_member where gid = %d", q("delete from pgrp_member where gid = %d",
intval($y['id']) intval($y['id'])
); );
} }
} }
} }
if(! $found) { if(! $found) {
$r = q("INSERT INTO groups ( hash, uid, visible, deleted, gname ) $r = q("INSERT INTO pgrp ( hash, uid, visible, deleted, gname )
VALUES( '%s', %d, %d, %d, '%s' ) ", VALUES( '%s', %d, %d, %d, '%s' ) ",
dbesc($cl['collection']), dbesc($cl['collection']),
intval($channel['channel_id']), intval($channel['channel_id']),
@ -520,10 +520,10 @@ class Libsync {
} }
} }
if(! $found_local) { if(! $found_local) {
q("delete from group_member where gid = %d", q("delete from pgrp_member where gid = %d",
intval($y['id']) intval($y['id'])
); );
q("update groups set deleted = 1 where id = %d and uid = %d", q("update pgrp set deleted = 1 where id = %d and uid = %d",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -533,7 +533,7 @@ class Libsync {
} }
// reload the group list with any updates // reload the group list with any updates
$x = q("select * from groups where uid = %d", $x = q("select * from pgrp where uid = %d",
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -560,7 +560,7 @@ class Libsync {
if(isset($y['hash']) && isset($members[$y['hash']])) { if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) { foreach($members[$y['hash']] as $member) {
$found = false; $found = false;
$z = q("select xchan from group_member where gid = %d and uid = %d and xchan = '%s' limit 1", $z = q("select xchan from pgrp_member where gid = %d and uid = %d and xchan = '%s' limit 1",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']), intval($channel['channel_id']),
dbesc($member) dbesc($member)
@ -571,7 +571,7 @@ class Libsync {
// if somebody is in the group that wasn't before - add them // if somebody is in the group that wasn't before - add them
if(! $found) { if(! $found) {
q("INSERT INTO group_member (uid, gid, xchan) q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ", VALUES( %d, %d, '%s' ) ",
intval($channel['channel_id']), intval($channel['channel_id']),
intval($y['id']), intval($y['id']),
@ -582,7 +582,7 @@ class Libsync {
} }
// now retrieve a list of members we have on this site // now retrieve a list of members we have on this site
$m = q("select xchan from group_member where gid = %d and uid = %d", $m = q("select xchan from pgrp_member where gid = %d and uid = %d",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -590,7 +590,7 @@ class Libsync {
foreach($m as $mm) { foreach($m as $mm) {
// if the local existing member isn't in the list we just received - remove them // if the local existing member isn't in the list we just received - remove them
if(! in_array($mm['xchan'],$members[$y['hash']])) { if(! in_array($mm['xchan'],$members[$y['hash']])) {
q("delete from group_member where xchan = '%s' and gid = %d and uid = %d", q("delete from pgrp_member where xchan = '%s' and gid = %d and uid = %d",
dbesc($mm['xchan']), dbesc($mm['xchan']),
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])

View File

@ -81,7 +81,7 @@ class Acl extends \Zotlabs\Web\Controller {
if($search) { if($search) {
$sql_extra = " AND groups.gname LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; $sql_extra = " AND pgrp.gname LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ";
$sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") "; $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
// This horrible mess is needed because position also returns 0 if nothing is found. // This horrible mess is needed because position also returns 0 if nothing is found.
@ -128,13 +128,13 @@ class Acl extends \Zotlabs\Web\Controller {
// Normal privacy groups // Normal privacy groups
$r = q("SELECT groups.id, groups.hash, groups.gname $r = q("SELECT pgrp.id, pgrp.hash, pgrp.gname
FROM groups, group_member FROM pgrp, pgrp_member
WHERE groups.deleted = 0 AND groups.uid = %d WHERE pgrp.deleted = 0 AND pgrp.uid = %d
AND group_member.gid = groups.id AND pgrp_member.gid = pgrp.id
$sql_extra $sql_extra
GROUP BY groups.id GROUP BY pgrp.id
ORDER BY groups.gname ORDER BY pgrp.gname
LIMIT %d OFFSET %d", LIMIT %d OFFSET %d",
intval(local_channel()), intval(local_channel()),
intval($count), intval($count),

View File

@ -220,7 +220,7 @@ class Connections extends \Zotlabs\Web\Controller {
$sql_extra .= (($searching) ? protect_sprintf(" AND xchan_name like '%$search_txt%' ") : ""); $sql_extra .= (($searching) ? protect_sprintf(" AND xchan_name like '%$search_txt%' ") : "");
if($_REQUEST['gid']) { if($_REQUEST['gid']) {
$sql_extra .= " and xchan_hash in ( select xchan from group_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) "; $sql_extra .= " and xchan_hash in ( select xchan from pgrp_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) ";
} }
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash

View File

@ -23,7 +23,7 @@ class Contactgroup extends \Zotlabs\Web\Controller {
if((argc() > 1) && (intval(argv(1)))) { if((argc() > 1) && (intval(argv(1)))) {
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1", $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1",
intval(argv(1)), intval(argv(1)),
intval(local_channel()) intval(local_channel())
); );

View File

@ -53,7 +53,7 @@ class Group extends Controller {
if((argc() == 2) && (intval(argv(1)))) { if((argc() == 2) && (intval(argv(1)))) {
check_form_security_token_redirectOnErr('/group', 'group_edit'); check_form_security_token_redirectOnErr('/group', 'group_edit');
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d LIMIT 1", $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
intval(argv(1)), intval(argv(1)),
intval(local_channel()) intval(local_channel())
); );
@ -67,7 +67,7 @@ class Group extends Controller {
$public = intval($_POST['public']); $public = intval($_POST['public']);
if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) { if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) {
$r = q("UPDATE groups SET gname = '%s', visible = %d WHERE uid = %d AND id = %d", $r = q("UPDATE pgrp SET gname = '%s', visible = %d WHERE uid = %d AND id = %d",
dbesc($groupname), dbesc($groupname),
intval($public), intval($public),
intval(local_channel()), intval(local_channel()),
@ -115,7 +115,7 @@ class Group extends Controller {
$new = (((argc() == 2) && (argv(1) === 'new')) ? true : false); $new = (((argc() == 2) && (argv(1) === 'new')) ? true : false);
$groups = q("SELECT id, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $groups = q("SELECT id, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel()) intval(local_channel())
); );
@ -160,7 +160,7 @@ class Group extends Controller {
check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
if(intval(argv(2))) { if(intval(argv(2))) {
$r = q("SELECT gname FROM groups WHERE id = %d AND uid = %d LIMIT 1", $r = q("SELECT gname FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
intval(argv(2)), intval(argv(2)),
intval(local_channel()) intval(local_channel())
); );
@ -192,7 +192,7 @@ class Group extends Controller {
if((argc() > 1) && (intval(argv(1)))) { if((argc() > 1) && (intval(argv(1)))) {
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1", $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1",
intval(argv(1)), intval(argv(1)),
intval(local_channel()) intval(local_channel())
); );

View File

@ -428,7 +428,7 @@ class Import extends \Zotlabs\Web\Controller {
create_table_from_array('groups', $group); create_table_from_array('groups', $group);
} }
$r = q("select * from groups where uid = %d", $r = q("select * from pgrp where uid = %d",
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) { if($r) {

View File

@ -118,7 +118,7 @@ class Lockview extends \Zotlabs\Web\Controller {
} }
if(count($allowed_groups)) { if(count($allowed_groups)) {
$r = q("SELECT gname FROM groups WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); $r = q("SELECT gname FROM pgrp WHERE hash IN ( " . implode(', ', $allowed_groups) . " )");
if($r) if($r)
foreach($r as $rr) foreach($r as $rr)
$l[] = '<div class="dropdown-item"><b>' . $rr['gname'] . '</b></div>'; $l[] = '<div class="dropdown-item"><b>' . $rr['gname'] . '</b></div>';
@ -156,7 +156,7 @@ class Lockview extends \Zotlabs\Web\Controller {
if(count($deny_groups)) { if(count($deny_groups)) {
$r = q("SELECT gname FROM groups WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); $r = q("SELECT gname FROM pgrp WHERE hash IN ( " . implode(', ', $deny_groups) . " )");
if($r) if($r)
foreach($r as $rr) foreach($r as $rr)
$l[] = '<div class="dropdown-item"><b><strike>' . $rr['gname'] . '</strike></b></div>'; $l[] = '<div class="dropdown-item"><b><strike>' . $rr['gname'] . '</strike></b></div>';

View File

@ -108,7 +108,7 @@ class Network extends \Zotlabs\Web\Controller {
// filter by collection (e.g. group) // filter by collection (e.g. group)
if($gid) { if($gid) {
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d LIMIT 1", $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
intval($gid), intval($gid),
intval(local_channel()) intval(local_channel())
); );

View File

@ -63,7 +63,7 @@ class Channel {
} }
$hide_presence = 1 - (intval($role_permissions['online'])); $hide_presence = 1 - (intval($role_permissions['online']));
if($role_permissions['default_collection']) { if($role_permissions['default_collection']) {
$r = q("select hash from groups where uid = %d and gname = '%s' limit 1", $r = q("select hash from pgrp where uid = %d and gname = '%s' limit 1",
intval(local_channel()), intval(local_channel()),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );
@ -71,7 +71,7 @@ class Channel {
require_once('include/group.php'); require_once('include/group.php');
group_add(local_channel(), t('Friends')); group_add(local_channel(), t('Friends'));
group_add_member(local_channel(),t('Friends'),$channel['channel_hash']); group_add_member(local_channel(),t('Friends'),$channel['channel_hash']);
$r = q("select hash from groups where uid = %d and gname = '%s' limit 1", $r = q("select hash from pgrp where uid = %d and gname = '%s' limit 1",
intval(local_channel()), intval(local_channel()),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );

20
Zotlabs/Update/_1221.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace Zotlabs\Update;
class _1221 {
function run() {
$r1 = q("ALTER table " . TQUOT . 'groups' . TQUOT . " rename to pgrp ");
$r2 = q("ALTER table " . TQUOT . 'group_member' . TQUOT . " rename to pgrp_member ");
if($r1 && $r2) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
}

View File

@ -47,7 +47,7 @@ class Activity_filter {
} }
if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) { if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) {
$groups = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel()) intval(local_channel())
); );

View File

@ -54,7 +54,7 @@ define ( 'STD_VERSION', '3.7.4' );
define ( 'ZOT_REVISION', '6.0a' ); define ( 'ZOT_REVISION', '6.0a' );
define ( 'DB_UPDATE_VERSION', 1220 ); define ( 'DB_UPDATE_VERSION', 1221 );
define ( 'PROJECT_BASE', __DIR__ ); define ( 'PROJECT_BASE', __DIR__ );

View File

@ -89,7 +89,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
} }
} }
$r = q("SELECT id, hash, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel()) intval(local_channel())
); );

View File

@ -350,20 +350,20 @@
$r = null; $r = null;
if($_REQUEST['group_id']) { if($_REQUEST['group_id']) {
$r = q("select * from groups where uid = %d and id = %d limit 1", $r = q("select * from pgrp where uid = %d and id = %d limit 1",
intval(api_user()), intval(api_user()),
intval($_REQUEST['group_id']) intval($_REQUEST['group_id'])
); );
} }
elseif($_REQUEST['group_name']) { elseif($_REQUEST['group_name']) {
$r = q("select * from groups where uid = %d and gname = '%s' limit 1", $r = q("select * from pgrp where uid = %d and gname = '%s' limit 1",
intval(api_user()), intval(api_user()),
dbesc($_REQUEST['group_name']) dbesc($_REQUEST['group_name'])
); );
} }
if($r) { if($r) {
$x = q("select * from group_member left join abook on abook_xchan = xchan and abook_channel = group_member.uid left join xchan on group_member.xchan = xchan.xchan_hash $x = q("select * from pgrp_member left join abook on abook_xchan = xchan and abook_channel = pgrp_member.uid left join xchan on pgrp_member.xchan = xchan.xchan_hash
where gid = %d", where gid = %d",
intval($r[0]['id']) intval($r[0]['id'])
); );
@ -376,7 +376,7 @@
if(api_user() === false) if(api_user() === false)
return false; return false;
$r = q("select * from groups where uid = %d", $r = q("select * from pgrp where uid = %d",
intval(api_user()) intval(api_user())
); );
json_return_and_die($r); json_return_and_die($r);

View File

@ -447,7 +447,7 @@ function create_identity($arr) {
// if our role_permissions indicate that we're using a default collection ACL, add it. // if our role_permissions indicate that we're using a default collection ACL, add it.
if(is_array($role_permissions) && $role_permissions['default_collection']) { if(is_array($role_permissions) && $role_permissions['default_collection']) {
$r = q("select hash from groups where uid = %d and gname = '%s' limit 1", $r = q("select hash from pgrp where uid = %d and gname = '%s' limit 1",
intval($newuid), intval($newuid),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );
@ -837,14 +837,14 @@ function identity_basic_export($channel_id, $sections = null) {
$ret['hubloc'] = $r; $ret['hubloc'] = $r;
} }
$r = q("select * from groups where uid = %d ", $r = q("select * from pgrp where uid = %d ",
intval($channel_id) intval($channel_id)
); );
if($r) if($r)
$ret['group'] = $r; $ret['group'] = $r;
$r = q("select * from group_member where uid = %d ", $r = q("select * from pgrp_member where uid = %d ",
intval($channel_id) intval($channel_id)
); );
if($r) if($r)
@ -2573,8 +2573,8 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id)); q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id));
q("DELETE FROM conv WHERE uid = %d", intval($channel_id)); q("DELETE FROM conv WHERE uid = %d", intval($channel_id));
q("DELETE FROM groups WHERE uid = %d", intval($channel_id)); q("DELETE FROM pgrp WHERE uid = %d", intval($channel_id));
q("DELETE FROM group_member WHERE uid = %d", intval($channel_id)); q("DELETE FROM pgrp_member WHERE uid = %d", intval($channel_id));
q("DELETE FROM event WHERE uid = %d", intval($channel_id)); q("DELETE FROM event WHERE uid = %d", intval($channel_id));
q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id)); q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id));
q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id)); q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id));

View File

@ -296,7 +296,7 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
$r = q("delete from event where event_xchan = '%s'", $r = q("delete from event where event_xchan = '%s'",
dbesc($xchan) dbesc($xchan)
); );
$r = q("delete from group_member where xchan = '%s'", $r = q("delete from pgrp_member where xchan = '%s'",
dbesc($xchan) dbesc($xchan)
); );
$r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )", $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )",
@ -402,7 +402,7 @@ function contact_remove($channel_id, $abook_id) {
intval($channel_id) intval($channel_id)
); );
$r = q("delete from group_member where xchan = '%s' and uid = %d", $r = q("delete from pgrp_member where xchan = '%s' and uid = %d",
dbesc($abook['abook_xchan']), dbesc($abook['abook_xchan']),
intval($channel_id) intval($channel_id)
); );

View File

@ -14,11 +14,11 @@ function group_add($uid,$name,$public = 0) {
// access lists. What we're doing here is reviving the dead group, but old content which // access lists. What we're doing here is reviving the dead group, but old content which
// was restricted to this group may now be seen by the new group members. // was restricted to this group may now be seen by the new group members.
$z = q("SELECT * FROM groups WHERE id = %d LIMIT 1", $z = q("SELECT * FROM pgrp WHERE id = %d LIMIT 1",
intval($r) intval($r)
); );
if(($z) && $z[0]['deleted']) { if(($z) && $z[0]['deleted']) {
q('UPDATE groups SET deleted = 0 WHERE id = %d', intval($z[0]['id'])); q('UPDATE pgrp SET deleted = 0 WHERE id = %d', intval($z[0]['id']));
notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL); notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
} }
return true; return true;
@ -28,13 +28,13 @@ function group_add($uid,$name,$public = 0) {
$dups = false; $dups = false;
$hash = random_string() . $name; $hash = random_string() . $name;
$r = q("SELECT id FROM groups WHERE hash = '%s' LIMIT 1", dbesc($hash)); $r = q("SELECT id FROM pgrp WHERE hash = '%s' LIMIT 1", dbesc($hash));
if($r) if($r)
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
$r = q("INSERT INTO groups ( hash, uid, visible, gname ) $r = q("INSERT INTO pgrp ( hash, uid, visible, gname )
VALUES( '%s', %d, %d, '%s' ) ", VALUES( '%s', %d, %d, '%s' ) ",
dbesc($hash), dbesc($hash),
intval($uid), intval($uid),
@ -53,7 +53,7 @@ function group_add($uid,$name,$public = 0) {
function group_rmv($uid,$name) { function group_rmv($uid,$name) {
$ret = false; $ret = false;
if(x($uid) && x($name)) { if(x($uid) && x($name)) {
$r = q("SELECT id, hash FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", $r = q("SELECT id, hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -98,13 +98,13 @@ function group_rmv($uid,$name) {
} }
// remove all members // remove all members
$r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d ", $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d ",
intval($uid), intval($uid),
intval($group_id) intval($group_id)
); );
// remove group // remove group
$r = q("UPDATE groups SET deleted = 1 WHERE uid = %d AND gname = '%s'", $r = q("UPDATE pgrp SET deleted = 1 WHERE uid = %d AND gname = '%s'",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -121,7 +121,7 @@ function group_rmv($uid,$name) {
function group_byname($uid,$name) { function group_byname($uid,$name) {
if((! $uid) || (! strlen($name))) if((! $uid) || (! strlen($name)))
return false; return false;
$r = q("SELECT * FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -134,7 +134,7 @@ function group_byname($uid,$name) {
function group_rec_byhash($uid,$hash) { function group_rec_byhash($uid,$hash) {
if((! $uid) || (! strlen($hash))) if((! $uid) || (! strlen($hash)))
return false; return false;
$r = q("SELECT * FROM groups WHERE uid = %d AND hash = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($hash) dbesc($hash)
); );
@ -149,7 +149,7 @@ function group_rmv_member($uid,$name,$member) {
return false; return false;
if(! ( $uid && $gid && $member)) if(! ( $uid && $gid && $member))
return false; return false;
$r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' ", $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' ",
intval($uid), intval($uid),
intval($gid), intval($gid),
dbesc($member) dbesc($member)
@ -169,7 +169,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
if((! $gid) || (! $uid) || (! $member)) if((! $gid) || (! $uid) || (! $member))
return false; return false;
$r = q("SELECT * FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1", $r = q("SELECT * FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1",
intval($uid), intval($uid),
intval($gid), intval($gid),
dbesc($member) dbesc($member)
@ -179,7 +179,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
// we indicate success because the group member was in fact created // we indicate success because the group member was in fact created
// -- It was just created at another time // -- It was just created at another time
if(! $r) if(! $r)
$r = q("INSERT INTO group_member (uid, gid, xchan) $r = q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ", VALUES( %d, %d, '%s' ) ",
intval($uid), intval($uid),
intval($gid), intval($gid),
@ -194,9 +194,9 @@ function group_add_member($uid,$name,$member,$gid = 0) {
function group_get_members($gid) { function group_get_members($gid) {
$ret = array(); $ret = array();
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT * FROM group_member $r = q("SELECT * FROM pgrp_member
LEFT JOIN abook ON abook_xchan = group_member.xchan left join xchan on xchan_hash = abook_xchan LEFT JOIN abook ON abook_xchan = pgrp_member.xchan left join xchan on xchan_hash = abook_xchan
WHERE gid = %d AND abook_channel = %d and group_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ", WHERE gid = %d AND abook_channel = %d and pgrp_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ",
intval($gid), intval($gid),
intval(local_channel()), intval(local_channel()),
intval(local_channel()) intval(local_channel())
@ -210,7 +210,7 @@ function group_get_members($gid) {
function group_get_members_xchan($gid) { function group_get_members_xchan($gid) {
$ret = array(); $ret = array();
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT xchan FROM group_member WHERE gid = %d AND uid = %d", $r = q("SELECT xchan FROM pgrp_member WHERE gid = %d AND uid = %d",
intval($gid), intval($gid),
intval(local_channel()) intval(local_channel())
); );
@ -248,7 +248,7 @@ function mini_group_select($uid,$group = '') {
$grps = array(); $grps = array();
$o = ''; $o = '';
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval($uid) intval($uid)
); );
$grps[] = array('name' => '', 'hash' => '0', 'selected' => ''); $grps[] = array('name' => '', 'hash' => '0', 'selected' => '');
@ -280,7 +280,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$groups = array(); $groups = array();
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
$member_of = array(); $member_of = array();
@ -361,7 +361,7 @@ function expand_groups($g) {
stringify_array_elms($x,true); stringify_array_elms($x,true);
$groups = implode(',', $x); $groups = implode(',', $x);
if($groups) { if($groups) {
$r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from groups where hash in ( $groups ))"); $r = q("SELECT xchan FROM pgrp_member WHERE gid IN ( select id from pgrp where hash in ( $groups ))");
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
$ret[] = $rr['xchan']; $ret[] = $rr['xchan'];
@ -375,7 +375,7 @@ function expand_groups($g) {
function member_of($c) { function member_of($c) {
$r = q("SELECT groups.gname, groups.id FROM groups LEFT JOIN group_member ON group_member.gid = groups.id WHERE group_member.xchan = '%s' AND groups.deleted = 0 ORDER BY groups.gname ASC ", $r = q("SELECT pgrp.gname, pgrp.id FROM pgrp LEFT JOIN pgrp_member ON pgrp_member.gid = pgrp.id WHERE pgrp_member.xchan = '%s' AND pgrp.deleted = 0 ORDER BY pgrp.gname ASC ",
dbesc($c) dbesc($c)
); );
@ -385,7 +385,7 @@ function member_of($c) {
function groups_containing($uid,$c) { function groups_containing($uid,$c) {
$r = q("SELECT gid FROM group_member WHERE uid = %d AND group_member.xchan = '%s' ", $r = q("SELECT gid FROM pgrp_member WHERE uid = %d AND pgrp_member.xchan = '%s' ",
intval($uid), intval($uid),
dbesc($c) dbesc($c)
); );

View File

@ -4159,7 +4159,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY)); $sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY));
if($arr['gid'] && $uid) { if($arr['gid'] && $uid) {
$r = q("SELECT * FROM groups WHERE id = %d AND uid = %d LIMIT 1", $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
intval($arr['group']), intval($arr['group']),
intval($uid) intval($uid)
); );

View File

@ -577,7 +577,7 @@ function init_groups_visitor($contact_id) {
// physical groups this channel is a member of // physical groups this channel is a member of
$r = q("SELECT hash FROM groups left join group_member on groups.id = group_member.gid WHERE xchan = '%s' ", $r = q("SELECT hash FROM pgrp left join pgrp_member on pgrp.id = pgrp_member.gid WHERE xchan = '%s' ",
dbesc($contact_id) dbesc($contact_id)
); );
if($r) { if($r) {

View File

@ -2737,7 +2737,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$grp = group_byname($profile_uid,$name); $grp = group_byname($profile_uid,$name);
if($grp) { if($grp) {
$g = q("select hash from groups where id = %d and visible = 1 limit 1", $g = q("select hash from pgrp where id = %d and visible = 1 limit 1",
intval($grp) intval($grp)
); );
if($g && $exclusive) { if($g && $exclusive) {

View File

@ -176,7 +176,7 @@ function xchan_change_key($oldx,$newx,$data) {
$tables = [ $tables = [
'abook' => 'abook_xchan', 'abook' => 'abook_xchan',
'abconfig' => 'xchan', 'abconfig' => 'xchan',
'group_member' => 'xchan', 'pgrp_member' => 'xchan',
'chat' => 'chat_xchan', 'chat' => 'chat_xchan',
'chatpresence' => 'cp_xchan', 'chatpresence' => 'cp_xchan',
'event' => 'event_xchan', 'event' => 'event_xchan',

View File

@ -3320,13 +3320,13 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
} }
if($groups_changed) { if($groups_changed) {
$r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d", $r = q("select hash as collection, visible, deleted, gname as name from pgrp where uid = %d",
intval($uid) intval($uid)
); );
if($r) if($r)
$info['collections'] = $r; $info['collections'] = $r;
$r = q("select groups.hash as collection, group_member.xchan as member from groups left join group_member on groups.id = group_member.gid where group_member.uid = %d", $r = q("select pgrp.hash as collection, pgrp_member.xchan as member from pgrp left join pgrp_member on pgrp.id = pgrp_member.gid where pgrp_member.uid = %d",
intval($uid) intval($uid)
); );
if($r) if($r)
@ -3734,7 +3734,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
// sync collections (privacy groups) oh joy... // sync collections (privacy groups) oh joy...
if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) { if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) {
$x = q("select * from groups where uid = %d", $x = q("select * from pgrp where uid = %d",
intval($channel['channel_id']) intval($channel['channel_id'])
); );
foreach($arr['collections'] as $cl) { foreach($arr['collections'] as $cl) {
@ -3750,7 +3750,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(($y['gname'] != $cl['name']) if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible']) || ($y['visible'] != $cl['visible'])
|| ($y['deleted'] != $cl['deleted'])) { || ($y['deleted'] != $cl['deleted'])) {
q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d", q("update pgrp set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d",
dbesc($cl['name']), dbesc($cl['name']),
intval($cl['visible']), intval($cl['visible']),
intval($cl['deleted']), intval($cl['deleted']),
@ -3759,14 +3759,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
); );
} }
if(intval($cl['deleted']) && (! intval($y['deleted']))) { if(intval($cl['deleted']) && (! intval($y['deleted']))) {
q("delete from group_member where gid = %d", q("delete from pgrp_member where gid = %d",
intval($y['id']) intval($y['id'])
); );
} }
} }
} }
if(! $found) { if(! $found) {
$r = q("INSERT INTO groups ( hash, uid, visible, deleted, gname ) $r = q("INSERT INTO pgrp ( hash, uid, visible, deleted, gname )
VALUES( '%s', %d, %d, %d, '%s' ) ", VALUES( '%s', %d, %d, %d, '%s' ) ",
dbesc($cl['collection']), dbesc($cl['collection']),
intval($channel['channel_id']), intval($channel['channel_id']),
@ -3790,10 +3790,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
} }
} }
if(! $found_local) { if(! $found_local) {
q("delete from group_member where gid = %d", q("delete from pgrp_member where gid = %d",
intval($y['id']) intval($y['id'])
); );
q("update groups set deleted = 1 where id = %d and uid = %d", q("update pgrp set deleted = 1 where id = %d and uid = %d",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -3803,7 +3803,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
} }
// reload the group list with any updates // reload the group list with any updates
$x = q("select * from groups where uid = %d", $x = q("select * from pgrp where uid = %d",
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -3830,7 +3830,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(isset($y['hash']) && isset($members[$y['hash']])) { if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) { foreach($members[$y['hash']] as $member) {
$found = false; $found = false;
$z = q("select xchan from group_member where gid = %d and uid = %d and xchan = '%s' limit 1", $z = q("select xchan from pgrp_member where gid = %d and uid = %d and xchan = '%s' limit 1",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']), intval($channel['channel_id']),
dbesc($member) dbesc($member)
@ -3841,7 +3841,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
// if somebody is in the group that wasn't before - add them // if somebody is in the group that wasn't before - add them
if(! $found) { if(! $found) {
q("INSERT INTO group_member (uid, gid, xchan) q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ", VALUES( %d, %d, '%s' ) ",
intval($channel['channel_id']), intval($channel['channel_id']),
intval($y['id']), intval($y['id']),
@ -3852,7 +3852,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
} }
// now retrieve a list of members we have on this site // now retrieve a list of members we have on this site
$m = q("select xchan from group_member where gid = %d and uid = %d", $m = q("select xchan from pgrp_member where gid = %d and uid = %d",
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -3860,7 +3860,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($m as $mm) { foreach($m as $mm) {
// if the local existing member isn't in the list we just received - remove them // if the local existing member isn't in the list we just received - remove them
if(! in_array($mm['xchan'],$members[$y['hash']])) { if(! in_array($mm['xchan'],$members[$y['hash']])) {
q("delete from group_member where xchan = '%s' and gid = %d and uid = %d", q("delete from pgrp_member where xchan = '%s' and gid = %d and uid = %d",
dbesc($mm['xchan']), dbesc($mm['xchan']),
intval($y['id']), intval($y['id']),
intval($channel['channel_id']) intval($channel['channel_id'])

View File

@ -1,4 +1,3 @@
CREATE TABLE IF NOT EXISTS `abconfig` ( CREATE TABLE IF NOT EXISTS `abconfig` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`chan` int(10) unsigned NOT NULL DEFAULT 0 , `chan` int(10) unsigned NOT NULL DEFAULT 0 ,
@ -462,7 +461,7 @@ CREATE TABLE IF NOT EXISTS `event` (
KEY `event_priority` (`event_priority`) KEY `event_priority` (`event_priority`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `groups` ( CREATE TABLE IF NOT EXISTS `pgrp` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`hash` char(191) NOT NULL DEFAULT '', `hash` char(191) NOT NULL DEFAULT '',
`uid` int(10) unsigned NOT NULL DEFAULT 0 , `uid` int(10) unsigned NOT NULL DEFAULT 0 ,
@ -477,7 +476,7 @@ CREATE TABLE IF NOT EXISTS `groups` (
KEY `gname` (`gname`) KEY `gname` (`gname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `group_member` ( CREATE TABLE IF NOT EXISTS `pgrp_member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL DEFAULT 0 , `uid` int(10) unsigned NOT NULL DEFAULT 0 ,
`gid` int(10) unsigned NOT NULL DEFAULT 0 , `gid` int(10) unsigned NOT NULL DEFAULT 0 ,

View File

@ -434,18 +434,18 @@ create index "event_status_idx" on event ("event_status");
create index "event_sequence_idx" on event ("event_sequence"); create index "event_sequence_idx" on event ("event_sequence");
create index "event_priority_idx" on event ("event_priority"); create index "event_priority_idx" on event ("event_priority");
CREATE TABLE "group_member" ( CREATE TABLE "pgrp_member" (
"id" serial NOT NULL, "id" serial NOT NULL,
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
"gid" bigint NOT NULL, "gid" bigint NOT NULL,
"xchan" text NOT NULL DEFAULT '', "xchan" text NOT NULL DEFAULT '',
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "groupmember_uid" on group_member ("uid"); create index "groupmember_uid" on pgrp_member ("uid");
create index "groupmember_gid" on group_member ("gid"); create index "groupmember_gid" on pgrp_member ("gid");
create index "groupmember_xchan" on group_member ("xchan"); create index "groupmember_xchan" on pgrp_member ("xchan");
CREATE TABLE "groups" ( CREATE TABLE "pgrp" (
"id" serial NOT NULL, "id" serial NOT NULL,
"hash" text NOT NULL DEFAULT '', "hash" text NOT NULL DEFAULT '',
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
@ -455,10 +455,10 @@ CREATE TABLE "groups" (
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "groups_uid_idx" on groups ("uid"); create index "groups_uid_idx" on pgrp ("uid");
create index "groups_visible_idx" on groups ("visible"); create index "groups_visible_idx" on pgrp ("visible");
create index "groups_deleted_idx" on groups ("deleted"); create index "groups_deleted_idx" on pgrp ("deleted");
create index "groups_hash_idx" on groups ("hash"); create index "groups_hash_idx" on pgrp ("hash");
CREATE TABLE "hook" ( CREATE TABLE "hook" (
"id" serial NOT NULL, "id" serial NOT NULL,