mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-21 20:35:21 +00:00
rename groups and group_members tables
This commit is contained in:
parent
cd8150f20d
commit
cf0df9a507
23 changed files with 98 additions and 78 deletions
|
@ -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' => '');
|
||||
|
@ -282,7 +282,7 @@ class Group {
|
|||
|
||||
$groups = [];
|
||||
|
||||
$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 = [];
|
||||
|
@ -362,7 +362,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'];
|
||||
|
@ -375,7 +375,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)
|
||||
);
|
||||
|
||||
|
@ -385,7 +385,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)
|
||||
);
|
||||
|
|
|
@ -119,13 +119,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)
|
||||
|
@ -567,7 +567,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) {
|
||||
|
@ -583,7 +583,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']),
|
||||
|
@ -592,14 +592,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']),
|
||||
|
@ -623,10 +623,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'])
|
||||
);
|
||||
|
@ -636,7 +636,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'])
|
||||
);
|
||||
|
||||
|
@ -663,7 +663,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)
|
||||
|
@ -674,7 +674,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']),
|
||||
|
@ -685,7 +685,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'])
|
||||
);
|
||||
|
@ -693,7 +693,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'])
|
||||
|
|
|
@ -84,7 +84,7 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||
|
||||
|
||||
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) ? "%@%'" : "%'")) . ") ";
|
||||
|
||||
// This horrible mess is needed because position also returns 0 if nothing is found.
|
||||
|
@ -131,13 +131,13 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||
|
||||
// Normal privacy groups
|
||||
|
||||
$r = q("SELECT groups.id, groups.hash, groups.gname
|
||||
FROM groups, group_member
|
||||
WHERE groups.deleted = 0 AND groups.uid = %d
|
||||
AND group_member.gid = groups.id
|
||||
$r = q("SELECT pgrp.id, pgrp.hash, pgrp.gname
|
||||
FROM pgrp, pgrp_member
|
||||
WHERE pgrp.deleted = 0 AND pgrp.uid = %d
|
||||
AND pgrp_member.gid = pgrp.id
|
||||
$sql_extra
|
||||
GROUP BY groups.id
|
||||
ORDER BY groups.gname
|
||||
GROUP BY pgrp.id
|
||||
ORDER BY pgrp.gname
|
||||
LIMIT %d OFFSET %d",
|
||||
intval(local_channel()),
|
||||
intval($count),
|
||||
|
|
|
@ -216,7 +216,7 @@ class Connections extends \Zotlabs\Web\Controller {
|
|||
$sql_extra .= (($searching) ? protect_sprintf(" AND xchan_name like '%$search_txt%' ") : "");
|
||||
|
||||
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
|
||||
|
|
|
@ -23,7 +23,7 @@ class Contactgroup extends \Zotlabs\Web\Controller {
|
|||
|
||||
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(local_channel())
|
||||
);
|
||||
|
|
|
@ -43,7 +43,7 @@ class Group extends \Zotlabs\Web\Controller {
|
|||
if((argc() == 2) && (intval(argv(1)))) {
|
||||
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(local_channel())
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ class Group extends \Zotlabs\Web\Controller {
|
|||
$public = intval($_POST['public']);
|
||||
|
||||
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),
|
||||
intval($public),
|
||||
intval(local_channel()),
|
||||
|
@ -96,7 +96,7 @@ class Group extends \Zotlabs\Web\Controller {
|
|||
|
||||
$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())
|
||||
);
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Group extends \Zotlabs\Web\Controller {
|
|||
check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
|
||||
|
||||
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(local_channel())
|
||||
);
|
||||
|
@ -173,7 +173,7 @@ class Group extends \Zotlabs\Web\Controller {
|
|||
if((argc() > 1) && (intval(argv(1)))) {
|
||||
|
||||
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(local_channel())
|
||||
);
|
||||
|
|
|
@ -411,9 +411,9 @@ class Import extends \Zotlabs\Web\Controller {
|
|||
unset($group['id']);
|
||||
$group['uid'] = $channel['channel_id'];
|
||||
|
||||
create_table_from_array('groups', $group);
|
||||
create_table_from_array('pgrp', $group);
|
||||
}
|
||||
$r = q("select * from groups where uid = %d",
|
||||
$r = q("select * from pgrp where uid = %d",
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if($r) {
|
||||
|
@ -433,7 +433,7 @@ class Import extends \Zotlabs\Web\Controller {
|
|||
if($x['old'] == $group_member['gid'])
|
||||
$group_member['gid'] = $x['new'];
|
||||
}
|
||||
create_table_from_array('group_member', $group_member);
|
||||
create_table_from_array('pgrp_member', $group_member);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ class Lockview extends \Zotlabs\Web\Controller {
|
|||
}
|
||||
|
||||
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)
|
||||
foreach($r as $rr)
|
||||
$l[] = '<div class="dropdown-item"><b>' . $rr['gname'] . '</b></div>';
|
||||
|
@ -156,7 +156,7 @@ class Lockview extends \Zotlabs\Web\Controller {
|
|||
|
||||
|
||||
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)
|
||||
foreach($r as $rr)
|
||||
$l[] = '<div class="dropdown-item"><b><strike>' . $rr['gname'] . '</strike></b></div>';
|
||||
|
|
|
@ -108,7 +108,7 @@ class Network extends \Zotlabs\Web\Controller {
|
|||
// filter by collection (e.g. group)
|
||||
|
||||
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(local_channel())
|
||||
);
|
||||
|
|
|
@ -66,7 +66,7 @@ class Channel {
|
|||
}
|
||||
$hide_presence = 1 - (intval($role_permissions['online']));
|
||||
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()),
|
||||
dbesc( t('Friends') )
|
||||
);
|
||||
|
@ -74,7 +74,7 @@ class Channel {
|
|||
|
||||
Group::add(local_channel(), t('Friends'));
|
||||
Group::member_add(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()),
|
||||
dbesc( t('Friends') )
|
||||
);
|
||||
|
|
20
Zotlabs/Update/_1221.php
Normal file
20
Zotlabs/Update/_1221.php
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ class Activity_filter {
|
|||
}
|
||||
|
||||
|
||||
$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())
|
||||
);
|
||||
|
||||
|
|
2
boot.php
2
boot.php
|
@ -38,7 +38,7 @@ define ( 'PLATFORM_ARCHITECTURE', 'osada' );
|
|||
define ( 'STD_VERSION', '1.2' );
|
||||
define ( 'ZOT_REVISION', '6.0' );
|
||||
|
||||
define ( 'DB_UPDATE_VERSION', 1220 );
|
||||
define ( 'DB_UPDATE_VERSION', 1221 );
|
||||
|
||||
define ( 'PROJECT_BASE', __DIR__ );
|
||||
|
||||
|
|
|
@ -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())
|
||||
);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -448,7 +448,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)
|
||||
|
@ -2566,8 +2566,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));
|
||||
|
|
|
@ -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' )",
|
||||
|
@ -405,7 +405,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)
|
||||
);
|
||||
|
|
|
@ -4164,7 +4164,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)
|
||||
);
|
||||
|
|
|
@ -542,7 +542,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) {
|
||||
|
|
|
@ -2727,7 +2727,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) {
|
||||
|
|
|
@ -251,7 +251,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',
|
||||
|
|
|
@ -464,7 +464,7 @@ CREATE TABLE IF NOT EXISTS `event` (
|
|||
KEY `event_priority` (`event_priority`)
|
||||
) 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,
|
||||
`hash` char(191) NOT NULL DEFAULT '',
|
||||
`uid` int(10) unsigned NOT NULL DEFAULT 0 ,
|
||||
|
@ -479,7 +479,7 @@ CREATE TABLE IF NOT EXISTS `groups` (
|
|||
KEY `gname` (`gname`)
|
||||
) 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,
|
||||
`uid` int(10) unsigned NOT NULL DEFAULT 0 ,
|
||||
`gid` int(10) unsigned NOT NULL DEFAULT 0 ,
|
||||
|
|
|
@ -436,7 +436,7 @@ create index "event_status_idx" on event ("event_status");
|
|||
create index "event_sequence_idx" on event ("event_sequence");
|
||||
create index "event_priority_idx" on event ("event_priority");
|
||||
|
||||
CREATE TABLE "group_member" (
|
||||
CREATE TABLE "pgrp_member" (
|
||||
"id" serial NOT NULL,
|
||||
"uid" bigint NOT NULL,
|
||||
"gid" bigint NOT NULL,
|
||||
|
@ -447,7 +447,7 @@ create index "groupmember_uid" on group_member ("uid");
|
|||
create index "groupmember_gid" on group_member ("gid");
|
||||
create index "groupmember_xchan" on group_member ("xchan");
|
||||
|
||||
CREATE TABLE "groups" (
|
||||
CREATE TABLE "pgrp" (
|
||||
"id" serial NOT NULL,
|
||||
"hash" text NOT NULL DEFAULT '',
|
||||
"uid" bigint NOT NULL,
|
||||
|
|
Loading…
Reference in a new issue