aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/acl_selectors.php2
-rw-r--r--include/api_zot.php8
-rw-r--r--include/channel.php10
-rw-r--r--include/connections.php4
-rw-r--r--include/group.php42
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/security.php2
-rw-r--r--include/text.php2
-rw-r--r--include/xchan.php2
-rw-r--r--include/zot.php26
10 files changed, 50 insertions, 50 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index bada3e528..c7a87afee 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -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())
);
diff --git a/include/api_zot.php b/include/api_zot.php
index 921242152..6a5b9a268 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -350,20 +350,20 @@
$r = null;
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($_REQUEST['group_id'])
);
}
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()),
dbesc($_REQUEST['group_name'])
);
}
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",
intval($r[0]['id'])
);
@@ -376,7 +376,7 @@
if(api_user() === false)
return false;
- $r = q("select * from groups where uid = %d",
+ $r = q("select * from pgrp where uid = %d",
intval(api_user())
);
json_return_and_die($r);
diff --git a/include/channel.php b/include/channel.php
index 7f49deb2e..33e438e53 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -447,7 +447,7 @@ function create_identity($arr) {
// if our role_permissions indicate that we're using a default collection ACL, add it.
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),
dbesc( t('Friends') )
);
@@ -837,14 +837,14 @@ function identity_basic_export($channel_id, $sections = null) {
$ret['hubloc'] = $r;
}
- $r = q("select * from groups where uid = %d ",
+ $r = q("select * from pgrp where uid = %d ",
intval($channel_id)
);
if($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)
);
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 conv WHERE uid = %d", intval($channel_id));
- q("DELETE FROM groups WHERE uid = %d", intval($channel_id));
- q("DELETE FROM group_member WHERE uid = %d", intval($channel_id));
+ q("DELETE FROM pgrp 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 mail WHERE channel_id = %d", intval($channel_id));
q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id));
diff --git a/include/connections.php b/include/connections.php
index 129bcdc8d..d97ea3887 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -296,7 +296,7 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
$r = q("delete from event where event_xchan = '%s'",
dbesc($xchan)
);
- $r = q("delete from group_member where xchan = '%s'",
+ $r = q("delete from pgrp_member where xchan = '%s'",
dbesc($xchan)
);
$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)
);
- $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']),
intval($channel_id)
);
diff --git a/include/group.php b/include/group.php
index 79d70aca4..6011af08f 100644
--- a/include/group.php
+++ b/include/group.php
@@ -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
// 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;
@@ -28,13 +28,13 @@ function group_add($uid,$name,$public = 0) {
$dups = false;
$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)
$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),
@@ -53,7 +53,7 @@ function group_add($uid,$name,$public = 0) {
function group_rmv($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)
);
@@ -98,13 +98,13 @@ function group_rmv($uid,$name) {
}
// 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)
);
@@ -121,7 +121,7 @@ function group_rmv($uid,$name) {
function group_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)
);
@@ -134,7 +134,7 @@ function group_byname($uid,$name) {
function group_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)
);
@@ -149,7 +149,7 @@ function group_rmv_member($uid,$name,$member) {
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)
@@ -169,7 +169,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
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)
@@ -179,7 +179,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
// 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),
@@ -194,9 +194,9 @@ function group_add_member($uid,$name,$member,$gid = 0) {
function group_get_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())
@@ -210,7 +210,7 @@ function group_get_members($gid) {
function group_get_members_xchan($gid) {
$ret = array();
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())
);
@@ -248,7 +248,7 @@ function mini_group_select($uid,$group = '') {
$grps = array();
$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' => '');
@@ -280,7 +280,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$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();
@@ -361,7 +361,7 @@ function expand_groups($g) {
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'];
@@ -375,7 +375,7 @@ function expand_groups($g) {
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)
);
@@ -385,7 +385,7 @@ function member_of($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),
dbesc($c)
);
diff --git a/include/items.php b/include/items.php
index c817c5afb..58461cc3a 100755
--- a/include/items.php
+++ b/include/items.php
@@ -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));
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($uid)
);
diff --git a/include/security.php b/include/security.php
index ffdd1d7ea..493d34699 100644
--- a/include/security.php
+++ b/include/security.php
@@ -577,7 +577,7 @@ function init_groups_visitor($contact_id) {
// 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)
);
if($r) {
diff --git a/include/text.php b/include/text.php
index 4b5442985..7782eac40 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2737,7 +2737,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$grp = group_byname($profile_uid,$name);
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)
);
if($g && $exclusive) {
diff --git a/include/xchan.php b/include/xchan.php
index 8c9c09c72..aad56063f 100644
--- a/include/xchan.php
+++ b/include/xchan.php
@@ -176,7 +176,7 @@ function xchan_change_key($oldx,$newx,$data) {
$tables = [
'abook' => 'abook_xchan',
'abconfig' => 'xchan',
- 'group_member' => 'xchan',
+ 'pgrp_member' => 'xchan',
'chat' => 'chat_xchan',
'chatpresence' => 'cp_xchan',
'event' => 'event_xchan',
diff --git a/include/zot.php b/include/zot.php
index e31d650d2..1a632cf87 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3320,13 +3320,13 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
}
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)
@@ -3734,7 +3734,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
// 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) {
@@ -3750,7 +3750,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
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']),
@@ -3759,14 +3759,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
);
}
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']),
@@ -3790,10 +3790,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
}
}
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'])
);
@@ -3803,7 +3803,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
}
// 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'])
);
@@ -3830,7 +3830,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
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)
@@ -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(! $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']),
@@ -3852,7 +3852,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
}
// 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'])
);
@@ -3860,7 +3860,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
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'])