X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fgroup.php;h=099ae7dd3682e42cef34b6506c78e1e66fa91e0e;hb=6d7b0182376d6ce0cfa2c4e01500ff321b9e9b51;hp=57e879206a846525ef14f58b873562666e700b10;hpb=323697d9dc2b321da494f1cde0f22d8052587320;p=friendica.git diff --git a/mod/group.php b/mod/group.php index 57e879206a..099ae7dd36 100644 --- a/mod/group.php +++ b/mod/group.php @@ -1,10 +1,12 @@ page['aside'] .= group_side(); + $a->page['aside'] = group_side(); } @@ -28,10 +30,53 @@ function group_post(&$a) { } else notice("Could not create group." . EOL ); -// goaway($a->get_baseurl() . '/group'); + 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']) + ); + if($r) + notice("Group name changed." . EOL ); + } + $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']) + ); + $result = true; + 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) + ); + if(! $r) + $result = false; + } + } + if($result) + notice("Membership list updated." . EOL); + $a->page['aside'] = group_side(); + } + } function group_content(&$a) {