X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fgroup.php;h=099ae7dd3682e42cef34b6506c78e1e66fa91e0e;hb=6d7b0182376d6ce0cfa2c4e01500ff321b9e9b51;hp=538277a0c624d7f08ab20ace19dbfde65d45fcec;hpb=7e16f8cdae597cc8329c3cc9ce769d512ba84085;p=friendica.git diff --git a/mod/group.php b/mod/group.php index 538277a0c6..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) { @@ -49,7 +94,9 @@ function group_content(&$a) { } -dbg(2); + + + if(($a->argc == 2) && (intval($a->argv[1]))) { require_once('view/acl_selectors.php'); $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -60,14 +107,21 @@ dbg(2); notice("Group not found." . EOL ); goaway($a->get_baseurl() . '/contacts'); } - $ret = group_get_members($r[0]['id']); + $group = $r[0]; + $ret = group_get_members($group['id']); $preselected = array(); if(count($ret)) { foreach($ret as $p) $preselected[] = $p['id']; } - $sel = contact_select('group_members_select','group_members_select',$preselected); - $o .= $sel; + + $tpl = file_get_contents('view/group_edit.tpl'); + $o .= replace_macros($tpl, array( + '$gid' => $group['id'], + '$name' => $group['name'], + '$selector' => contact_select('group_members_select','group_members_select',$preselected,25) + )); + }