aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-09-28 09:41:21 +0200
committerMario <mario@mariovavti.com>2018-09-28 09:41:21 +0200
commit9e87219aead74791cdb68d4fa166326a0bd92d78 (patch)
tree3cec224f7ebca28d3155ff335bf43fc39ea3db39 /Zotlabs/Lib
parent1b7e220de734f30cf22452e36fe6b746676ddf46 (diff)
parent65785ead697056130d01520a917bfc2626788c0c (diff)
downloadvolse-hubzilla-9e87219aead74791cdb68d4fa166326a0bd92d78.tar.gz
volse-hubzilla-9e87219aead74791cdb68d4fa166326a0bd92d78.tar.bz2
volse-hubzilla-9e87219aead74791cdb68d4fa166326a0bd92d78.zip
Merge branch 'patch-10' into 'dev'
rename groups and group_members tables for MySQL 8 compatibility See merge request hubzilla/core!1290
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Group.php42
-rw-r--r--Zotlabs/Lib/Libsync.php26
2 files changed, 34 insertions, 34 deletions
diff --git a/Zotlabs/Lib/Group.php b/Zotlabs/Lib/Group.php
index f136a3614..a4ff4fced 100644
--- a/Zotlabs/Lib/Group.php
+++ b/Zotlabs/Lib/Group.php
@@ -20,11 +20,11 @@ class Group {
// 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.
- $z = q("SELECT * FROM groups WHERE id = %d LIMIT 1",
+ $z = q("SELECT * FROM pgrp WHERE id = %d LIMIT 1",
intval($r)
);
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);
}
return true;
@@ -34,13 +34,13 @@ class Group {
$dups = false;
$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)
$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' ) ",
dbesc($hash),
intval($uid),
@@ -58,7 +58,7 @@ class Group {
static function remove($uid,$name) {
$ret = false;
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),
dbesc($name)
);
@@ -103,13 +103,13 @@ class Group {
}
// 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($group_id)
);
// 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),
dbesc($name)
);
@@ -127,7 +127,7 @@ class Group {
static function byname($uid,$name) {
if((! $uid) || (! strlen($name)))
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),
dbesc($name)
);
@@ -140,7 +140,7 @@ class Group {
static function rec_byhash($uid,$hash) {
if((! $uid) || (! strlen($hash)))
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),
dbesc($hash)
);
@@ -156,7 +156,7 @@ class Group {
return false;
if(! ( $uid && $gid && $member))
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($gid),
dbesc($member)
@@ -174,7 +174,7 @@ class Group {
if((! $gid) || (! $uid) || (! $member))
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($gid),
dbesc($member)
@@ -184,7 +184,7 @@ class Group {
// we indicate success because the group member was in fact created
// -- It was just created at another time
if(! $r)
- $r = q("INSERT INTO group_member (uid, gid, xchan)
+ $r = q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
intval($uid),
intval($gid),
@@ -200,9 +200,9 @@ class Group {
static function members($gid) {
$ret = array();
if(intval($gid)) {
- $r = q("SELECT * FROM group_member
- LEFT JOIN abook ON abook_xchan = group_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 ",
+ $r = q("SELECT * FROM pgrp_member
+ 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 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(local_channel()),
intval(local_channel())
@@ -216,7 +216,7 @@ class Group {
static function members_xchan($gid) {
$ret = [];
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(local_channel())
);
@@ -254,7 +254,7 @@ class Group {
$grps = [];
$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)
);
$grps[] = array('name' => '', 'hash' => '0', 'selected' => '');
@@ -286,7 +286,7 @@ class Group {
$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'])
);
$member_of = array();
@@ -366,7 +366,7 @@ class Group {
stringify_array_elms($x,true);
$groups = implode(',', $x);
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) {
foreach($r as $rr) {
$ret[] = $rr['xchan'];
@@ -379,7 +379,7 @@ class Group {
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)
);
@@ -389,7 +389,7 @@ class Group {
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),
dbesc($c)
);
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index 938d484b7..d037a0058 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -122,13 +122,13 @@ class Libsync {
}
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)
);
if($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)
);
if($r)
@@ -464,7 +464,7 @@ class Libsync {
// sync collections (privacy groups) oh joy...
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'])
);
foreach($arr['collections'] as $cl) {
@@ -480,7 +480,7 @@ class Libsync {
if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible'])
|| ($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']),
intval($cl['visible']),
intval($cl['deleted']),
@@ -489,14 +489,14 @@ class Libsync {
);
}
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'])
);
}
}
}
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' ) ",
dbesc($cl['collection']),
intval($channel['channel_id']),
@@ -520,10 +520,10 @@ class Libsync {
}
}
if(! $found_local) {
- q("delete from group_member where gid = %d",
+ q("delete from pgrp_member where gid = %d",
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($channel['channel_id'])
);
@@ -533,7 +533,7 @@ class Libsync {
}
// 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'])
);
@@ -560,7 +560,7 @@ class Libsync {
if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) {
$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($channel['channel_id']),
dbesc($member)
@@ -571,7 +571,7 @@ class Libsync {
// if somebody is in the group that wasn't before - add them
if(! $found) {
- q("INSERT INTO group_member (uid, gid, xchan)
+ q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
intval($channel['channel_id']),
intval($y['id']),
@@ -582,7 +582,7 @@ class Libsync {
}
// 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($channel['channel_id'])
);
@@ -590,7 +590,7 @@ class Libsync {
foreach($m as $mm) {
// if the local existing member isn't in the list we just received - remove them
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']),
intval($y['id']),
intval($channel['channel_id'])