aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-03 13:44:38 +0100
committerMario <mario@mariovavti.com>2021-03-03 13:44:38 +0100
commitf8f15f526f68073baa1e4e846ab87a66c2d5b291 (patch)
treef038aea1118379f1e23353a5ad03d147de8fd23a
parent48bae9d4219735bc44f4ee72228d19d3e6b9efc9 (diff)
downloadvolse-hubzilla-f8f15f526f68073baa1e4e846ab87a66c2d5b291.tar.gz
volse-hubzilla-f8f15f526f68073baa1e4e846ab87a66c2d5b291.tar.bz2
volse-hubzilla-f8f15f526f68073baa1e4e846ab87a66c2d5b291.zip
group_add(): return hash if success
-rw-r--r--include/group.php52
1 files changed, 29 insertions, 23 deletions
diff --git a/include/group.php b/include/group.php
index efda389d6..bb1ed5ed8 100644
--- a/include/group.php
+++ b/include/group.php
@@ -4,23 +4,23 @@ use Zotlabs\Lib\Libsync;
function group_add($uid,$name,$public = 0) {
- $ret = false;
+ $success = false;
if(x($uid) && x($name)) {
$r = group_byname($uid,$name); // check for dups
if($r !== false) {
- // This could be a problem.
+ // This could be a problem.
// Let's assume we've just created a group which we once deleted
// all the old members are gone, but the group remains so we don't break any security
// 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 pgrp WHERE id = %d LIMIT 1",
intval($r)
);
if(($z) && $z[0]['deleted']) {
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;
}
@@ -42,12 +42,18 @@ function group_add($uid,$name,$public = 0) {
intval($public),
dbesc($name)
);
- $ret = $r;
- }
- Libsync::build_sync_packet($uid,null,true);
+ if($r)
+ $success = true;
+ }
- return $ret;
+
+ if($success) {
+ Libsync::build_sync_packet($uid,null,true);
+ return $hash;
+ }
+
+ return false;
}
@@ -88,7 +94,7 @@ function group_rmv($uid,$name) {
}
if($change) {
- q("UPDATE channel SET channel_default_group = '%s', channel_allow_gid = '%s', channel_deny_gid = '%s'
+ q("UPDATE channel SET channel_default_group = '%s', channel_allow_gid = '%s', channel_deny_gid = '%s'
WHERE channel_id = %d",
intval($user_info['channel_default_group']),
dbesc($user_info['channel_allow_gid']),
@@ -159,7 +165,7 @@ function group_rmv_member($uid,$name,$member) {
Libsync::build_sync_packet($uid,null,true);
return $r;
-
+
}
@@ -170,13 +176,13 @@ function group_add_member($uid,$name,$member,$gid = 0) {
if((! $gid) || (! $uid) || (! $member))
return false;
- $r = q("SELECT * FROM pgrp_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)
);
if($r)
- return true; // You might question this, but
+ return true; // You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
if(! $r)
@@ -195,7 +201,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
function group_get_members($gid) {
$ret = array();
if(intval($gid)) {
- $r = q("SELECT * FROM pgrp_member
+ $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),
@@ -245,7 +251,7 @@ function group_get_profile_members_xchan($uid,$gid) {
function mini_group_select($uid,$group = '') {
-
+
$grps = array();
$o = '';
@@ -263,7 +269,7 @@ function mini_group_select($uid,$group = '') {
$o = replace_macros(get_markup_template('group_selection.tpl'), array(
'$label' => t('Add new connections to this privacy group'),
- '$groups' => $grps
+ '$groups' => $grps
));
return $o;
}
@@ -287,12 +293,12 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$member_of = array();
if($cid) {
$member_of = groups_containing(local_channel(),$cid);
- }
+ }
if($r) {
foreach($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
-
+
if ($edit) {
$groupedit = array(
'href' => "group/".$rr['id'],
@@ -301,7 +307,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
} else {
$groupedit = null;
}
-
+
$groups[] = array(
'id' => $rr['id'],
'enc_cid' => base64url_encode($cid),
@@ -314,8 +320,8 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
);
}
}
-
-
+
+
$tpl = get_markup_template("group_side.tpl");
$o = replace_macros($tpl, array(
'$title' => t('Privacy Groups'),
@@ -325,8 +331,8 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
'$groups' => $groups,
'$add' => t('add'),
));
-
-
+
+
return $o;
}
@@ -356,7 +362,7 @@ function expand_groups($g) {
else {
$x[] = $gv;
}
- }
+ }
if($x) {
stringify_array_elms($x,true);