X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fgroup.php;h=cae76eb6d2c6fdfbcb6f556f49dc4c3c11a6b5ba;hb=a86fd26bd86945fe75b7220e149b8986f88feb01;hp=fd3439b8524fc17b36c635d39c92cfc83bcb8a28;hpb=b1aa77584f972b8c62fd099fa7fe08c36201b631;p=friendica.git diff --git a/include/group.php b/include/group.php index fd3439b852..cae76eb6d2 100644 --- a/include/group.php +++ b/include/group.php @@ -6,8 +6,26 @@ function group_add($uid,$name) { $ret = false; if(x($uid) && x($name)) { $r = group_byname($uid,$name); // check for dups - if($r !== false) + if($r !== false) { + + // 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. + + $z = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1", + intval($r) + ); + if(count($z) && $z[0]['deleted']) { + $r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", + intval($uid), + dbesc($name) + ); + notice( t('A deleted group with this name was revived. Existing item permissions may 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; + } $r = q("INSERT INTO `group` ( `uid`, `name` ) VALUES( %d, '%s' ) ", intval($uid), @@ -124,9 +142,10 @@ function group_public_members($gid) { $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` WHERE `gid` = %d AND `group_member`.`uid` = %d - AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' AND `contact`.`network` != 'face' ", + AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", intval($gid), - intval(local_user()) + intval(local_user()), + dbesc(NETWORK_OSTATUS) ); if(count($r)) $ret = count($r); @@ -136,41 +155,66 @@ function group_public_members($gid) { -function group_side($every="contacts",$each="group",$edit = false, $group_id = 0) { +function group_side($every="contacts",$each="group",$edit = false, $group_id = 0, $cid = 0) { $o = ''; if(! local_user()) return ''; - $createtext = t('Create a new group'); - $linktext= t('Everybody'); - $selected = (($group_id == 0 && $every !== 'contacts') ? ' class="group-selected" ' : ''); -$o .= <<< EOT - -
-

Groups

- - + $groups = array(); + + $groups[] = array( + 'text' => t('Everybody'), + 'selected' => (($group_id == 0) ? 'group-selected' : ''), + 'href' => $every, + ); -\r\n
"; - + + + $tpl = get_markup_template("group_side.tpl"); + $o = replace_macros($tpl, array( + '$title' => t('Groups'), + '$createtext' => t('Create a new group'), + '$groups' => $groups, + '$add' => t('add'), + )); + + return $o; } @@ -198,3 +242,18 @@ function member_of($c) { } +function groups_containing($uid,$c) { + + $r = q("SELECT `gid` FROM `group_member` WHERE `uid` = %d AND `group_member`.`contact-id` = %d ", + intval($uid), + intval($c) + ); + + $ret = array(); + if(count($r)) { + foreach($r as $rr) + $ret[] = $rr['gid']; + } + + return $ret; +}