diff options
Diffstat (limited to 'mod/group.php')
-rw-r--r-- | mod/group.php | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/mod/group.php b/mod/group.php index 91b9999dc..15e4ff2a3 100644 --- a/mod/group.php +++ b/mod/group.php @@ -2,12 +2,6 @@ require_once('include/group.php'); -function group_aside(&$a) { - if(local_user()) { - $a->set_widget('groups_edit',group_side('collections','group',false,(($a->argc > 1) ? intval($a->argv[1]) : 0))); - } -} - function group_post(&$a) { @@ -20,7 +14,8 @@ function group_post(&$a) { check_form_security_token_redirectOnErr('/group/new', 'group_edit'); $name = notags(trim($_POST['groupname'])); - $r = group_add(local_user(),$name); + $public = intval($_POST['public']); + $r = group_add(local_user(),$name,$public); if($r) { info( t('Collection created.') . EOL ); $r = group_byname(local_user(),$name); @@ -35,7 +30,7 @@ function group_post(&$a) { if((argc() == 2) && (intval(argv(1)))) { check_form_security_token_redirectOnErr('/group', 'group_edit'); - $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(argv(1)), intval(local_user()) ); @@ -46,14 +41,17 @@ function group_post(&$a) { } $group = $r[0]; $groupname = notags(trim($_POST['groupname'])); - if((strlen($groupname)) && ($groupname != $group['name'])) { - $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", + $public = intval($_POST['public']); + + if((strlen($groupname)) && (($groupname != $group['name']) || ($public != $group['visible']))) { + $r = q("UPDATE `groups` SET `name` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d LIMIT 1", dbesc($groupname), + intval($public), intval(local_user()), intval($group['id']) ); if($r) - info( t('Collection name changed.') . EOL ); + info( t('Collection updated.') . EOL ); } goaway(z_root() . '/group/' . argv(1) . '/' . argv(2)); @@ -85,9 +83,10 @@ function group_content(&$a) { if((argc() == 2) && (argv(1) === 'new')) { return replace_macros($tpl, $context + array( - '$title' => t('Create a collection of connections.'), + '$title' => t('Create a collection of channels.'), '$gname' => array('groupname',t('Collection Name: '), '', ''), '$gid' => 'new', + '$public' => array('public',t('Members are visible to other channels'), false, ''), '$form_security_token' => get_form_security_token("group_edit"), )); @@ -98,7 +97,7 @@ function group_content(&$a) { check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); if(intval(argv(2))) { - $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT `name` FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(argv(2)), intval(local_user()) ); @@ -118,10 +117,10 @@ function group_content(&$a) { check_form_security_token_ForbiddenOnErr('group_member_change', 't'); - $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d) limit 1", + $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and not (xchan_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d) limit 1", dbesc(argv(2)), intval(local_user()), - intval(ABOOK_FLAG_SELF), + intval(XCHAN_FLAGS_DELETED), intval(ABOOK_FLAG_BLOCKED), intval(ABOOK_FLAG_PENDING) ); @@ -133,22 +132,24 @@ function group_content(&$a) { if((argc() > 1) && (intval(argv(1)))) { require_once('include/acl_selectors.php'); - $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", + $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_user()) ); if(! $r) { notice( t('Collection not found.') . EOL ); - goaway($a->get_baseurl() . '/connnections'); + goaway($a->get_baseurl() . '/connections'); } $group = $r[0]; + $members = group_get_members($group['id']); $preselected = array(); if(count($members)) { foreach($members as $member) - $preselected[] = $member['xchan_hash']; + if(! in_array($member['xchan_hash'],$preselected)) + $preselected[] = $member['xchan_hash']; } if($change) { @@ -182,6 +183,7 @@ function group_content(&$a) { '$gname' => array('groupname',t('Collection Name: '),$group['name'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, + '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''), '$form_security_token' => get_form_security_token('group_edit'), ); @@ -201,17 +203,17 @@ function group_content(&$a) { $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { if($member['xchan_url']) { - $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . $member['xchan_hash'] . '\',\'' . $sec_token . '\'); return true;'; + $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . $member['xchan_hash'] . '\',\'' . $sec_token . '\'); return false;'; $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); } else group_rmv_member(local_user(),$group['name'],$member['xchan_hash']); } - $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d) order by xchan_name asc", + $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND not (abook_flags & %d) and not (xchan_flags & %d) and not (abook_flags & %d) order by xchan_name asc", intval(local_user()), intval(ABOOK_FLAG_BLOCKED), - intval(ABOOK_FLAG_SELF), + intval(XCHAN_FLAGS_DELETED), intval(ABOOK_FLAG_PENDING) ); @@ -219,7 +221,7 @@ function group_content(&$a) { $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); foreach($r as $member) { if(! in_array($member['xchan_hash'],$preselected)) { - $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . $member['xchan_hash'] . '\',\'' . $sec_token . '\'); return true;'; + $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . $member['xchan_hash'] . '\',\'' . $sec_token . '\'); return false;'; $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode); } } |