diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-07-13 04:05:23 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-07-13 04:05:23 -0700 |
commit | c3273dfcdc6d4dec893e7ae755a647e88665c815 (patch) | |
tree | 43232b5d01b63f7e579bb7ac52d82b75fda7d189 /mod | |
parent | 323697d9dc2b321da494f1cde0f22d8052587320 (diff) | |
download | volse-hubzilla-c3273dfcdc6d4dec893e7ae755a647e88665c815.tar.gz volse-hubzilla-c3273dfcdc6d4dec893e7ae755a647e88665c815.tar.bz2 volse-hubzilla-c3273dfcdc6d4dec893e7ae755a647e88665c815.zip |
group editor cleanup
Diffstat (limited to 'mod')
-rw-r--r-- | mod/group.php | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/mod/group.php b/mod/group.php index 57e879206..4ab810242 100644 --- a/mod/group.php +++ b/mod/group.php @@ -1,6 +1,8 @@ <?php - +function validate_members(&$item) { + $item = intval($item); +} function group_init(&$a) { require_once('include/group.php'); @@ -31,7 +33,42 @@ function group_post(&$a) { // goaway($a->get_baseurl() . '/group'); return; // NOTREACHED } - + if(($a->argc == 2) && (intval($a->argv[1]))) { + $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($a->argv[1]), + intval($_SESSION['uid']) + ); + if(! count($r)) { + notice("Group not found." . EOL ); + goaway($a->get_baseurl() . '/contacts'); + } + $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", + dbesc($groupname), + intval($_SESSION['uid']), + intval($group['id']) + ); + } + $members = $_POST['group_members_select']; + array_walk($members,'validate_members'); + $r = q("DELETE FROM `group_member` WHERE `gid` = %d AND `uid` = %d", + intval($a->argv[1]), + intval($_SESSION['uid']) + ); + if(count($members)) { + foreach($members as $member) { + $r = q("INSERT INTO `group_member` ( `uid`, `gid`, `contact-id`) + VALUES ( %d, %d, %d )", + intval($_SESSION['uid']), + intval($group['id']), + intval($member) + ); + } + } + } + } function group_content(&$a) { |