Replace "group" with "circle" in the rest of the code
- Remaining mentions already mean "forum"pull/13121/head
46
README.md
|
@ -17,29 +17,29 @@ Have a look at the [installation documentation](doc/Install.md) for further info
|
|||
|
||||
### Friendica Screenshots
|
||||
|
||||
|  
|
||||
|:--:|
|
||||
|*Frio theme, mobile browser. Timeline and composer view.*|
|
||||
|
|
||||
|*Frio theme, desktop browser. Timeline view, contact info popped up, control menu open.*|
|
||||
|
|
||||
|*Frio theme, desktop browser. Menu open for controlling individual posts.*|
|
||||
|
|
||||
|*Frio theme, desktop browser. Profile view, notification menu open.*|
|
||||
|
|
||||
|*Number of new posts, in total and by group.*|
|
||||
|
|
||||
|*Calender with popup of event.*|
|
||||
|
|
||||
|*Notifications menu and private messages counter, standard browser on tablet.*|
|
||||
|
|
||||
|*Number of visible contacts, standard browser.*|
|
||||
|
|
||||
|*Network posts chronologically ordered, standard browser.*|
|
||||
|
|
||||
|*Vier theme, desktop browser. Public timeline view.*|
|
||||
|
|
||||
|*Vier theme, desktop browser. Community post displayed.*|
|
||||
|   |
|
||||
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
| *Frio theme, mobile browser. Timeline and composer view.* |
|
||||
|  |
|
||||
| *Frio theme, desktop browser. Timeline view, contact info popped up, control menu open.* |
|
||||
|  |
|
||||
| *Frio theme, desktop browser. Menu open for controlling individual posts.* |
|
||||
|  |
|
||||
| *Frio theme, desktop browser. Profile view, notification menu open.* |
|
||||
|  |
|
||||
| *Number of new posts, in total and by circle.* |
|
||||
|  |
|
||||
| *Calendar with popup of event.* |
|
||||
|  |
|
||||
| *Notifications menu and private messages counter, standard browser on tablet.* |
|
||||
|  |
|
||||
| *Number of visible contacts, standard browser.* |
|
||||
|  |
|
||||
| *Network posts chronologically ordered, standard browser.* |
|
||||
|  |
|
||||
| *Vier theme, desktop browser. Public timeline view.* |
|
||||
|  |
|
||||
| *Vier theme, desktop browser. Community post displayed.* |
|
||||
|
||||
## Endorsements
|
||||
|
||||
|
|
Before Width: | Height: | Size: 598 B |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 543 B |
Before Width: | Height: | Size: 852 B After Width: | Height: | Size: 852 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
@ -1,6 +1,6 @@
|
|||
|
||||
IMAGES=add.png edit.png gear.png info.png menu.png \
|
||||
notify_off.png star.png delete.png feed.png group.png \
|
||||
notify_off.png star.png delete.png feed.png circle.png \
|
||||
lock.png notice.png notify_on.png user.png link.png \
|
||||
play.png plugin.png unlock.png zip.png audio.png video.png \
|
||||
image.png text.png
|
||||
|
@ -10,7 +10,7 @@ DESTS=10/ 16/ 22/ 48/ \
|
|||
$(addprefix 16/, $(IMAGES)) \
|
||||
$(addprefix 22/, $(IMAGES)) \
|
||||
$(addprefix 48/, $(IMAGES))
|
||||
|
||||
|
||||
all: $(DESTS)
|
||||
|
||||
%/:
|
||||
|
@ -18,7 +18,7 @@ all: $(DESTS)
|
|||
|
||||
10/%.png: %.png
|
||||
convert $< -resize 10x10 $@
|
||||
|
||||
|
||||
16/%.png: %.png
|
||||
convert $< -resize 16x16 $@
|
||||
|
||||
|
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
@ -163,14 +163,14 @@ function photos_post(App $a)
|
|||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
$str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
|
||||
$str_group_allow = isset($_REQUEST['group_allow']) ? $aclFormatter->toString($_REQUEST['group_allow']) : $owner_record['allow_gid'] ?? '';
|
||||
$str_circle_allow = isset($_REQUEST['circle_allow']) ? $aclFormatter->toString($_REQUEST['circle_allow']) : $owner_record['allow_gid'] ?? '';
|
||||
$str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $owner_record['deny_cid'] ?? '';
|
||||
$str_group_deny = isset($_REQUEST['group_deny']) ? $aclFormatter->toString($_REQUEST['group_deny']) : $owner_record['deny_gid'] ?? '';
|
||||
$str_circle_deny = isset($_REQUEST['circle_deny']) ? $aclFormatter->toString($_REQUEST['circle_deny']) : $owner_record['deny_gid'] ?? '';
|
||||
|
||||
$visibility = $_REQUEST['visibility'] ?? '';
|
||||
if ($visibility === 'public') {
|
||||
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
|
||||
$str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
|
||||
$str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_deny = '';
|
||||
} else if ($visibility === 'custom') {
|
||||
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
|
||||
// case that would make it public. So we always append the author's contact id to the allowed contacts.
|
||||
|
@ -338,7 +338,7 @@ function photos_post(App $a)
|
|||
$photo = $photos[0];
|
||||
$ext = $phototypes[$photo['type']];
|
||||
Photo::update(
|
||||
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny],
|
||||
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny],
|
||||
['resource-id' => $resource_id, 'uid' => $page_owner_uid]
|
||||
);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ use Friendica\Model\Attach;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item as ItemModel;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -542,7 +542,7 @@ class Item
|
|||
|
||||
if ($private_forum) {
|
||||
$item['allow_cid'] = '<' . $private_id . '>';
|
||||
$item['allow_gid'] = '<' . Group::getIdForForum($forum_contact['id']) . '>';
|
||||
$item['allow_gid'] = '<' . Circle::getIdForForum($forum_contact['id']) . '>';
|
||||
} else {
|
||||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '';
|
||||
|
@ -863,9 +863,9 @@ class Item
|
|||
}
|
||||
|
||||
$post['allow_cid'] = isset($request['contact_allow']) ? $this->aclFormatter->toString($request['contact_allow']) : $user['allow_cid'] ?? '';
|
||||
$post['allow_gid'] = isset($request['group_allow']) ? $this->aclFormatter->toString($request['group_allow']) : $user['allow_gid'] ?? '';
|
||||
$post['allow_gid'] = isset($request['circle_allow']) ? $this->aclFormatter->toString($request['circle_allow']) : $user['allow_gid'] ?? '';
|
||||
$post['deny_cid'] = isset($request['contact_deny']) ? $this->aclFormatter->toString($request['contact_deny']) : $user['deny_cid'] ?? '';
|
||||
$post['deny_gid'] = isset($request['group_deny']) ? $this->aclFormatter->toString($request['group_deny']) : $user['deny_gid'] ?? '';
|
||||
$post['deny_gid'] = isset($request['circle_deny']) ? $this->aclFormatter->toString($request['circle_deny']) : $user['deny_gid'] ?? '';
|
||||
|
||||
$visibility = $request['visibility'] ?? '';
|
||||
if ($visibility === 'public') {
|
||||
|
|
|
@ -531,7 +531,7 @@ class HTML
|
|||
$ignore = false;
|
||||
|
||||
// A list of some links that should be ignored
|
||||
$list = ["/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
$list = ["/user/", "/tag/", "/group/", "/circle/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
"//plus.google.com/", "//twitter.com/"];
|
||||
foreach ($list as $listitem) {
|
||||
if (strpos($treffer[1], $listitem) !== false) {
|
||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Core\Search;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -194,29 +194,29 @@ class Widget
|
|||
}
|
||||
|
||||
/**
|
||||
* Return group membership widget
|
||||
* Return circle membership widget
|
||||
*
|
||||
* @param string $baseurl
|
||||
* @param string $selected
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function groups(string $baseurl, string $selected = ''): string
|
||||
public static function circles(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$options = array_map(function ($group) {
|
||||
$options = array_map(function ($circle) {
|
||||
return [
|
||||
'ref' => $group['id'],
|
||||
'name' => $group['name']
|
||||
'ref' => $circle['id'],
|
||||
'name' => $circle['name']
|
||||
];
|
||||
}, Group::getByUserId(DI::userSession()->getLocalUserId()));
|
||||
}, Circle::getByUserId(DI::userSession()->getLocalUserId()));
|
||||
|
||||
return self::filter(
|
||||
'group',
|
||||
DI::l10n()->t('Groups'),
|
||||
'circle',
|
||||
DI::l10n()->t('Circles'),
|
||||
'',
|
||||
DI::l10n()->t('Everyone'),
|
||||
$baseurl,
|
||||
|
|
|
@ -25,7 +25,7 @@ use Friendica\App\Page;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Circle;
|
||||
use Friendica\Model\User;
|
||||
|
||||
/**
|
||||
|
@ -182,40 +182,40 @@ class ACL
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the ACL list of groups (including meta-groups) for a given user id
|
||||
* Returns the ACL list of circles (including meta-circles) for a given user id
|
||||
*
|
||||
* @param int $user_id
|
||||
* @return array
|
||||
*/
|
||||
public static function getGroupListByUserId(int $user_id)
|
||||
public static function getCircleListByUserId(int $user_id)
|
||||
{
|
||||
$acl_groups = [
|
||||
$acl_circles = [
|
||||
[
|
||||
'id' => Group::FOLLOWERS,
|
||||
'id' => Circle::FOLLOWERS,
|
||||
'name' => DI::l10n()->t('Followers'),
|
||||
'addr' => '',
|
||||
'micro' => 'images/twopeople.png',
|
||||
'type' => 'group',
|
||||
'type' => 'circle',
|
||||
],
|
||||
[
|
||||
'id' => Group::MUTUALS,
|
||||
'id' => Circle::MUTUALS,
|
||||
'name' => DI::l10n()->t('Mutuals'),
|
||||
'addr' => '',
|
||||
'micro' => 'images/twopeople.png',
|
||||
'type' => 'group',
|
||||
'type' => 'circle',
|
||||
]
|
||||
];
|
||||
foreach (Group::getByUserId($user_id) as $group) {
|
||||
$acl_groups[] = [
|
||||
'id' => $group['id'],
|
||||
'name' => $group['name'],
|
||||
foreach (Circle::getByUserId($user_id) as $circle) {
|
||||
$acl_circles[] = [
|
||||
'id' => $circle['id'],
|
||||
'name' => $circle['name'],
|
||||
'addr' => '',
|
||||
'micro' => 'images/twopeople.png',
|
||||
'type' => 'group',
|
||||
'type' => 'circle',
|
||||
];
|
||||
}
|
||||
|
||||
return $acl_groups;
|
||||
return $acl_circles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,7 +279,7 @@ class ACL
|
|||
} else {
|
||||
$visibility = 'public';
|
||||
// Default permission display for custom panel
|
||||
$default_permissions['allow_gid'] = [Group::FOLLOWERS];
|
||||
$default_permissions['allow_gid'] = [Circle::FOLLOWERS];
|
||||
}
|
||||
|
||||
$jotnets_fields = [];
|
||||
|
@ -303,15 +303,15 @@ class ACL
|
|||
|
||||
$acl_contacts = self::getContactListByUserId($user['uid'], $condition);
|
||||
|
||||
$acl_groups = self::getGroupListByUserId($user['uid']);
|
||||
$acl_circles = self::getCircleListByUserId($user['uid']);
|
||||
|
||||
$acl_list = array_merge($acl_groups, $acl_contacts);
|
||||
$acl_list = array_merge($acl_circles, $acl_contacts);
|
||||
|
||||
$input_names = [
|
||||
'visibility' => $form_prefix ? $form_prefix . '[visibility]' : 'visibility',
|
||||
'group_allow' => $form_prefix ? $form_prefix . '[group_allow]' : 'group_allow',
|
||||
'circle_allow' => $form_prefix ? $form_prefix . '[circle_allow]' : 'circle_allow',
|
||||
'contact_allow' => $form_prefix ? $form_prefix . '[contact_allow]' : 'contact_allow',
|
||||
'group_deny' => $form_prefix ? $form_prefix . '[group_deny]' : 'group_deny',
|
||||
'circle_deny' => $form_prefix ? $form_prefix . '[circle_deny]' : 'circle_deny',
|
||||
'contact_deny' => $form_prefix ? $form_prefix . '[contact_deny]' : 'contact_deny',
|
||||
'emailcc' => $form_prefix ? $form_prefix . '[emailcc]' : 'emailcc',
|
||||
];
|
||||
|
@ -321,7 +321,7 @@ class ACL
|
|||
'$public_title' => DI::l10n()->t('Public'),
|
||||
'$public_desc' => DI::l10n()->t('This content will be shown to all your followers and can be seen in the community pages and by anyone with its link.'),
|
||||
'$custom_title' => DI::l10n()->t('Limited/Private'),
|
||||
'$custom_desc' => DI::l10n()->t('This content will be shown only to the people in the first box, to the exception of the people mentioned in the second box. It won\'t appear anywhere public.') . DI::l10n()->t('Start typing the name of a contact or a group to show a filtered list. You can also mention the special groups "Followers" and "Mutuals".'),
|
||||
'$custom_desc' => DI::l10n()->t('This content will be shown only to the people in the first box, to the exception of the people mentioned in the second box. It won\'t appear anywhere public.') . DI::l10n()->t('Start typing the name of a contact or a circle to show a filtered list. You can also mention the special circles "Followers" and "Mutuals".'),
|
||||
'$allow_label' => DI::l10n()->t('Show to:'),
|
||||
'$deny_label' => DI::l10n()->t('Except to:'),
|
||||
'$emailcc' => DI::l10n()->t('CC: email addresses'),
|
||||
|
@ -329,12 +329,12 @@ class ACL
|
|||
'$jotnets_summary' => DI::l10n()->t('Connectors'),
|
||||
'$visibility' => $visibility,
|
||||
'$acl_contacts' => json_encode($acl_contacts),
|
||||
'$acl_groups' => json_encode($acl_groups),
|
||||
'$acl_circles' => json_encode($acl_circles),
|
||||
'$acl_list' => json_encode($acl_list),
|
||||
'$contact_allow' => implode(',', $default_permissions['allow_cid']),
|
||||
'$group_allow' => implode(',', $default_permissions['allow_gid']),
|
||||
'$circle_allow' => implode(',', $default_permissions['allow_gid']),
|
||||
'$contact_deny' => implode(',', $default_permissions['deny_cid']),
|
||||
'$group_deny' => implode(',', $default_permissions['deny_gid']),
|
||||
'$circle_deny' => implode(',', $default_permissions['deny_gid']),
|
||||
'$for_federation' => $for_federation,
|
||||
'$jotnets_fields' => $jotnets_fields,
|
||||
'$input_names' => $input_names,
|
||||
|
@ -381,7 +381,7 @@ class ACL
|
|||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function isValidGroup($acl_string, $uid)
|
||||
public static function isValidCircle($acl_string, $uid)
|
||||
{
|
||||
if (empty($acl_string)) {
|
||||
return true;
|
||||
|
@ -394,7 +394,7 @@ class ACL
|
|||
$gid_array = $array[0];
|
||||
foreach ($gid_array as $gid) {
|
||||
$gid = str_replace(['<', '>'], ['', ''], $gid);
|
||||
if (!DBA::exists('group', ['id' => $gid, 'uid' => $uid, 'deleted' => false])) {
|
||||
if (!DBA::exists('circle', ['id' => $gid, 'uid' => $uid, 'deleted' => false])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Network\HTTPException;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Friendica\Factory\Api\Twitter\User as TwitterUser;
|
||||
|
||||
class Group extends BaseFactory
|
||||
class Circle extends BaseFactory
|
||||
{
|
||||
/** @var twitterUser entity */
|
||||
private $twitterUser;
|
||||
|
@ -43,19 +43,19 @@ class Group extends BaseFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $id id of the group
|
||||
* @param int $id id of the circle
|
||||
* @return array
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function createFromId(int $id): array
|
||||
{
|
||||
$group = $this->dba->selectFirst('group', [], ['id' => $id, 'deleted' => false]);
|
||||
if (empty($group)) {
|
||||
$circle = $this->dba->selectFirst('group', [], ['id' => $id, 'deleted' => false]);
|
||||
if (empty($circle)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$user = $this->twitterUser->createFromUserId($group['uid'])->toArray();
|
||||
$object = new \Friendica\Object\Api\Friendica\Group($group, $user);
|
||||
$user = $this->twitterUser->createFromUserId($circle['uid'])->toArray();
|
||||
$object = new \Friendica\Object\Api\Friendica\Circle($circle, $user);
|
||||
|
||||
return $object->toArray();
|
||||
}
|
|
@ -40,9 +40,9 @@ class ListEntity extends BaseFactory
|
|||
/**
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function createFromGroupId(int $id): \Friendica\Object\Api\Mastodon\ListEntity
|
||||
public function createFromCircleId(int $id): \Friendica\Object\Api\Mastodon\ListEntity
|
||||
{
|
||||
$group = $this->dba->selectFirst('group', ['name'], ['id' => $id, 'deleted' => false]);
|
||||
return new \Friendica\Object\Api\Mastodon\ListEntity($id, $group['name'] ?? '', 'list');
|
||||
$circle = $this->dba->selectFirst('group', ['name'], ['id' => $id, 'deleted' => false]);
|
||||
return new \Friendica\Object\Api\Mastodon\ListEntity($id, $circle['name'] ?? '', 'list');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,9 +190,9 @@ class Attach
|
|||
* @param string $filetype Mimetype. optional, default = ''
|
||||
* @param integer $filesize File size in bytes. optional, default = null
|
||||
* @param string $allow_cid Permissions, allowed contacts. optional, default = ''
|
||||
* @param string $allow_gid Permissions, allowed groups. optional, default = ''
|
||||
* @param string $deny_cid Permissions, denied contacts.optional, default = ''
|
||||
* @param string $deny_gid Permissions, denied group.optional, default = ''
|
||||
* @param string $allow_gid Permissions, allowed circles. optional, default = ''
|
||||
* @param string $deny_cid Permissions, denied contacts. optional, default = ''
|
||||
* @param string $deny_gid Permissions, denied circle. optional, default = ''
|
||||
*
|
||||
* @return boolean|integer Row id on success, False on errors
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
|
|
|
@ -34,16 +34,16 @@ use Friendica\Protocol\ActivityPub;
|
|||
/**
|
||||
* functions for interacting with the group database table
|
||||
*/
|
||||
class Group
|
||||
class Circle
|
||||
{
|
||||
const FOLLOWERS = '~';
|
||||
const MUTUALS = '&';
|
||||
|
||||
/**
|
||||
* Fetches group record by user id and maybe includes deleted groups as well
|
||||
* Fetches circle record by user id and maybe includes deleted circles as well
|
||||
*
|
||||
* @param int $uid User id to fetch group(s) for
|
||||
* @param bool $includesDeleted Whether deleted groups should be included
|
||||
* @param int $uid User id to fetch circle(s) for
|
||||
* @param bool $includesDeleted Whether deleted circles should be included
|
||||
* @return array|bool Array on success, bool on error
|
||||
*/
|
||||
public static function getByUserId(int $uid, bool $includesDeleted = false)
|
||||
|
@ -58,16 +58,16 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether given group id is found in database
|
||||
* Checks whether given circle id is found in database
|
||||
*
|
||||
* @param int $group_id Group id
|
||||
* @param int $circle_id Circle id
|
||||
* @param int $uid Optional user id
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function exists(int $group_id, int $uid = null): bool
|
||||
public static function exists(int $circle_id, int $uid = null): bool
|
||||
{
|
||||
$condition = ['id' => $group_id, 'deleted' => false];
|
||||
$condition = ['id' => $circle_id, 'deleted' => false];
|
||||
|
||||
if (!is_null($uid)) {
|
||||
$condition = [
|
||||
|
@ -79,13 +79,13 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new contact group
|
||||
* Create a new contact circle
|
||||
*
|
||||
* Note: If we found a deleted group with the same name, we restore it
|
||||
* Note: If we found a deleted circle with the same name, we restore it
|
||||
*
|
||||
* @param int $uid User id to create group for
|
||||
* @param string $name Name of group
|
||||
* @return int|boolean Id of newly created group or false on error
|
||||
* @param int $uid User id to create circle for
|
||||
* @param string $name Name of circle
|
||||
* @return int|boolean Id of newly created circle or false on error
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function create(int $uid, string $name)
|
||||
|
@ -95,14 +95,14 @@ class Group
|
|||
$gid = self::getIdByName($uid, $name); // check for dupes
|
||||
if ($gid !== 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.
|
||||
$group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
|
||||
if (DBA::isResult($group) && $group['deleted']) {
|
||||
// Let's assume we've just created a circle which we once deleted
|
||||
// all the old members are gone, but the circle remains, so we don't break any security
|
||||
// access lists. What we're doing here is reviving the dead circle, but old content which
|
||||
// was restricted to this circle may now be seen by the new circle members.
|
||||
$circle = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
|
||||
if (DBA::isResult($circle) && $circle['deleted']) {
|
||||
DBA::update('group', ['deleted' => 0], ['id' => $gid]);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('A deleted circle with this name was revived. Existing item permissions <strong>may</strong> apply to this circle and any future members. If this is not what you intended, please create another circle with a different name.'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Update group information.
|
||||
* Update circle information.
|
||||
*
|
||||
* @param int $id Group ID
|
||||
* @param string $name Group name
|
||||
* @param int $id Circle ID
|
||||
* @param string $name Circle name
|
||||
*
|
||||
* @return bool Was the update successful?
|
||||
* @throws \Exception
|
||||
|
@ -130,10 +130,10 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a list of group ids a contact belongs to
|
||||
* Get a list of circle ids a contact belongs to
|
||||
*
|
||||
* @param int $cid Contact id
|
||||
* @return array Group ids
|
||||
* @return array Circle ids
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getIdsByContactId(int $cid): array
|
||||
|
@ -143,50 +143,50 @@ class Group
|
|||
return [];
|
||||
}
|
||||
|
||||
$groupIds = [];
|
||||
$circleIds = [];
|
||||
|
||||
$stmt = DBA::select('group_member', ['gid'], ['contact-id' => $cid]);
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$groupIds[] = $group['gid'];
|
||||
while ($circle = DBA::fetch($stmt)) {
|
||||
$circleIds[] = $circle['gid'];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
// Meta-groups
|
||||
// Meta-circles
|
||||
if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) {
|
||||
$groupIds[] = self::FOLLOWERS;
|
||||
$circleIds[] = self::FOLLOWERS;
|
||||
}
|
||||
|
||||
if ($contact['rel'] == Contact::FRIEND) {
|
||||
$groupIds[] = self::MUTUALS;
|
||||
$circleIds[] = self::MUTUALS;
|
||||
}
|
||||
|
||||
return $groupIds;
|
||||
return $circleIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* count unread group items
|
||||
* count unread circle items
|
||||
*
|
||||
* Count unread items of each groups of the local user
|
||||
* Count unread items of each circle of the local user
|
||||
*
|
||||
* @return array
|
||||
* 'id' => group id
|
||||
* 'name' => group name
|
||||
* 'count' => counted unseen group items
|
||||
* 'id' => circle id
|
||||
* 'name' => circle name
|
||||
* 'count' => counted unseen circle items
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function countUnseen()
|
||||
{
|
||||
$stmt = DBA::p("SELECT `group`.`id`, `group`.`name`,
|
||||
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
|
||||
(SELECT COUNT(*) FROM `post-user`
|
||||
WHERE `uid` = ?
|
||||
AND `unseen`
|
||||
AND `contact-id` IN
|
||||
(SELECT `contact-id`
|
||||
FROM `group_member`
|
||||
WHERE `group_member`.`gid` = `group`.`id`)
|
||||
FROM `group_member` AS `circle_member`
|
||||
WHERE `circle_member`.`gid` = `circle`.`id`)
|
||||
) AS `count`
|
||||
FROM `group`
|
||||
WHERE `group`.`uid` = ?;",
|
||||
FROM `group` AS `circle`
|
||||
WHERE `circle`.`uid` = ?;",
|
||||
DI::userSession()->getLocalUserId(),
|
||||
DI::userSession()->getLocalUserId()
|
||||
);
|
||||
|
@ -195,13 +195,13 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the group id for a user/name couple
|
||||
* Get the circle id for a user/name couple
|
||||
*
|
||||
* Returns false if no group has been found.
|
||||
* Returns false if no circle has been found.
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param string $name Group name
|
||||
* @return int|boolean Groups' id number or false on error
|
||||
* @param string $name Circle name
|
||||
* @return int|boolean Circle's id number or false on error
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getIdByName(int $uid, string $name)
|
||||
|
@ -210,16 +210,16 @@ class Group
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = DBA::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
|
||||
if (DBA::isResult($group)) {
|
||||
return $group['id'];
|
||||
$circle = DBA::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
|
||||
if (DBA::isResult($circle)) {
|
||||
return $circle['id'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a group as deleted
|
||||
* Mark a circle as deleted
|
||||
*
|
||||
* @param int $gid
|
||||
* @return boolean
|
||||
|
@ -231,13 +231,13 @@ class Group
|
|||
return false;
|
||||
}
|
||||
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (!DBA::isResult($group)) {
|
||||
$circle = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (!DBA::isResult($circle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove group from default posting lists
|
||||
$user = DBA::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
|
||||
// remove circle from default posting lists
|
||||
$user = DBA::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $circle['uid']]);
|
||||
if (DBA::isResult($user)) {
|
||||
$change = false;
|
||||
|
||||
|
@ -255,21 +255,21 @@ class Group
|
|||
}
|
||||
|
||||
if ($change) {
|
||||
DBA::update('user', $user, ['uid' => $group['uid']]);
|
||||
DBA::update('user', $user, ['uid' => $circle['uid']]);
|
||||
}
|
||||
}
|
||||
|
||||
// remove all members
|
||||
DBA::delete('group_member', ['gid' => $gid]);
|
||||
|
||||
// remove group
|
||||
// remove circle
|
||||
$return = DBA::update('group', ['deleted' => 1], ['id' => $gid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a contact to a group
|
||||
* Adds a contact to a circle
|
||||
*
|
||||
* @param int $gid
|
||||
* @param int $cid
|
||||
|
@ -283,12 +283,12 @@ class Group
|
|||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($group)) {
|
||||
throw new HTTPException\NotFoundException('Group not found.');
|
||||
$circle = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($circle)) {
|
||||
throw new HTTPException\NotFoundException('Circle not found.');
|
||||
}
|
||||
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $group['uid']);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $circle['uid']);
|
||||
if (empty($cdata['user'])) {
|
||||
throw new HTTPException\NotFoundException('Invalid contact.');
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes a contact from a group
|
||||
* Removes a contact from a circle
|
||||
*
|
||||
* @param int $gid
|
||||
* @param int $cid
|
||||
|
@ -311,12 +311,12 @@ class Group
|
|||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($group)) {
|
||||
throw new HTTPException\NotFoundException('Group not found.');
|
||||
$circle = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($circle)) {
|
||||
throw new HTTPException\NotFoundException('Circle not found.');
|
||||
}
|
||||
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $group['uid']);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $circle['uid']);
|
||||
if (empty($cdata['user'])) {
|
||||
throw new HTTPException\NotFoundException('Invalid contact.');
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds contacts to a group
|
||||
* Adds contacts to a circle
|
||||
*
|
||||
* @param int $gid
|
||||
* @param array $contacts Array with contact ids
|
||||
|
@ -339,13 +339,13 @@ class Group
|
|||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($group)) {
|
||||
throw new HTTPException\NotFoundException('Group not found.');
|
||||
$circle = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($circle)) {
|
||||
throw new HTTPException\NotFoundException('Circle not found.');
|
||||
}
|
||||
|
||||
foreach ($contacts as $cid) {
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $group['uid']);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $circle['uid']);
|
||||
if (empty($cdata['user'])) {
|
||||
throw new HTTPException\NotFoundException('Invalid contact.');
|
||||
}
|
||||
|
@ -355,9 +355,9 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes contacts from a group
|
||||
* Removes contacts from a circle
|
||||
*
|
||||
* @param int $gid Group id
|
||||
* @param int $gid Circle id
|
||||
* @param array $contacts Contact ids
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
|
@ -369,15 +369,15 @@ class Group
|
|||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
$group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($group)) {
|
||||
throw new HTTPException\NotFoundException('Group not found.');
|
||||
$circle = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
|
||||
if (empty($circle)) {
|
||||
throw new HTTPException\NotFoundException('Circle not found.');
|
||||
}
|
||||
|
||||
$contactIds = [];
|
||||
|
||||
foreach ($contacts as $cid) {
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $group['uid']);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $circle['uid']);
|
||||
if (empty($cdata['user'])) {
|
||||
throw new HTTPException\NotFoundException('Invalid contact.');
|
||||
}
|
||||
|
@ -390,18 +390,18 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the combined list of contact ids from a group id list
|
||||
* Returns the combined list of contact ids from a circle id list
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param array $group_ids Groups ids
|
||||
* @param array $circle_ids Circles ids
|
||||
* @param boolean $check_dead Whether check "dead" records (?)
|
||||
* @param boolean $expand_followers Expand the list of followers
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function expand(int $uid, array $group_ids, bool $check_dead = false, bool $expand_followers = true): array
|
||||
public static function expand(int $uid, array $circle_ids, bool $check_dead = false, bool $expand_followers = true): array
|
||||
{
|
||||
if (!is_array($group_ids) || !count($group_ids)) {
|
||||
if (!is_array($circle_ids) || !count($circle_ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ class Group
|
|||
$networks = array_diff($networks, [Protocol::MAIL]);
|
||||
}
|
||||
|
||||
$key = array_search(self::FOLLOWERS, $group_ids);
|
||||
$key = array_search(self::FOLLOWERS, $circle_ids);
|
||||
if ($key !== false) {
|
||||
if ($expand_followers) {
|
||||
$followers = Contact::selectToArray(['id'], [
|
||||
|
@ -438,10 +438,10 @@ class Group
|
|||
} else {
|
||||
$followers_collection = true;
|
||||
}
|
||||
unset($group_ids[$key]);
|
||||
unset($circle_ids[$key]);
|
||||
}
|
||||
|
||||
$key = array_search(self::MUTUALS, $group_ids);
|
||||
$key = array_search(self::MUTUALS, $circle_ids);
|
||||
if ($key !== false) {
|
||||
$mutuals = Contact::selectToArray(['id'], [
|
||||
'uid' => $uid,
|
||||
|
@ -457,12 +457,12 @@ class Group
|
|||
$return[] = $mutual['id'];
|
||||
}
|
||||
|
||||
unset($group_ids[$key]);
|
||||
unset($circle_ids[$key]);
|
||||
}
|
||||
|
||||
$stmt = DBA::select('group_member', ['contact-id'], ['gid' => $group_ids]);
|
||||
while ($group_member = DBA::fetch($stmt)) {
|
||||
$return[] = $group_member['contact-id'];
|
||||
$stmt = DBA::select('group_member', ['contact-id'], ['gid' => $circle_ids]);
|
||||
while ($circle_member = DBA::fetch($stmt)) {
|
||||
$return[] = $circle_member['contact-id'];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
|
@ -478,17 +478,17 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a templated group selection list
|
||||
* Returns a templated circle selection list
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param int $gid An optional pre-selected group
|
||||
* @param int $gid An optional pre-selected circle
|
||||
* @param string $label An optional label of the list
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function displayGroupSelection(int $uid, int $gid = 0, string $label = ''): string
|
||||
public static function getSelectorHTML(int $uid, int $gid = 0, string $label = ''): string
|
||||
{
|
||||
$display_groups = [
|
||||
$display_circles = [
|
||||
[
|
||||
'name' => '',
|
||||
'id' => '0',
|
||||
|
@ -497,53 +497,53 @@ class Group
|
|||
];
|
||||
|
||||
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null], ['order' => ['name']]);
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$display_groups[] = [
|
||||
'name' => $group['name'],
|
||||
'id' => $group['id'],
|
||||
'selected' => $gid == $group['id'] ? 'true' : ''
|
||||
while ($circle = DBA::fetch($stmt)) {
|
||||
$display_circles[] = [
|
||||
'name' => $circle['name'],
|
||||
'id' => $circle['id'],
|
||||
'selected' => $gid == $circle['id'] ? 'true' : ''
|
||||
];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
Logger::info('Got groups', $display_groups);
|
||||
Logger::info('Got circles', $display_circles);
|
||||
|
||||
if ($label == '') {
|
||||
$label = DI::l10n()->t('Default privacy group for new contacts');
|
||||
$label = DI::l10n()->t('Default privacy circle for new contacts');
|
||||
}
|
||||
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('group_selection.tpl'), [
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('circle_selection.tpl'), [
|
||||
'$label' => $label,
|
||||
'$groups' => $display_groups
|
||||
'$circles' => $display_circles
|
||||
]);
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create group sidebar widget
|
||||
* Create circle sidebar widget
|
||||
*
|
||||
* @param string $every
|
||||
* @param string $each
|
||||
* @param string $editmode
|
||||
* 'standard' => include link 'Edit groups'
|
||||
* 'extended' => include link 'Create new group'
|
||||
* 'full' => include link 'Create new group' and provide for each group a link to edit this group
|
||||
* @param string|int $group_id Distinct group id or 'everyone'
|
||||
* 'standard' => include link 'Edit circles'
|
||||
* 'extended' => include link 'Create new circle'
|
||||
* 'full' => include link 'Create new circle' and provide for each circle a link to edit this circle
|
||||
* @param string|int $circle_id Distinct circle id or 'everyone'
|
||||
* @param int $cid Contact id
|
||||
* @return string Sidebar widget HTML code
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
|
||||
public static function sidebarWidget(string $every = 'contact', string $each = 'circle', string $editmode = 'standard', $circle_id = '', int $cid = 0)
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$display_groups = [
|
||||
$display_circles = [
|
||||
[
|
||||
'text' => DI::l10n()->t('Everybody'),
|
||||
'id' => 0,
|
||||
'selected' => (($group_id === 'everyone') ? 'group-selected' : ''),
|
||||
'selected' => (($circle_id === 'everyone') ? 'circle-selected' : ''),
|
||||
'href' => $every,
|
||||
]
|
||||
];
|
||||
|
@ -554,66 +554,66 @@ class Group
|
|||
}
|
||||
|
||||
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => DI::userSession()->getLocalUserId(), 'cid' => null], ['order' => ['name']]);
|
||||
while ($group = DBA::fetch($stmt)) {
|
||||
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
||||
while ($circle = DBA::fetch($stmt)) {
|
||||
$selected = (($circle_id == $circle['id']) ? ' circle-selected' : '');
|
||||
|
||||
if ($editmode == 'full') {
|
||||
$groupedit = [
|
||||
'href' => 'group/' . $group['id'],
|
||||
$circleedit = [
|
||||
'href' => 'circle/' . $circle['id'],
|
||||
'title' => DI::l10n()->t('edit'),
|
||||
];
|
||||
} else {
|
||||
$groupedit = null;
|
||||
$circleedit = null;
|
||||
}
|
||||
|
||||
if ($each == 'group') {
|
||||
$count = DBA::count('group_member', ['gid' => $group['id']]);
|
||||
$group_name = sprintf('%s (%d)', $group['name'], $count);
|
||||
if ($each == 'circle') {
|
||||
$count = DBA::count('group_member', ['gid' => $circle['id']]);
|
||||
$circle_name = sprintf('%s (%d)', $circle['name'], $count);
|
||||
} else {
|
||||
$group_name = $group['name'];
|
||||
$circle_name = $circle['name'];
|
||||
}
|
||||
|
||||
$display_groups[] = [
|
||||
'id' => $group['id'],
|
||||
$display_circles[] = [
|
||||
'id' => $circle['id'],
|
||||
'cid' => $cid,
|
||||
'text' => $group_name,
|
||||
'href' => $each . '/' . $group['id'],
|
||||
'edit' => $groupedit,
|
||||
'text' => $circle_name,
|
||||
'href' => $each . '/' . $circle['id'],
|
||||
'edit' => $circleedit,
|
||||
'selected' => $selected,
|
||||
'ismember' => in_array($group['id'], $member_of),
|
||||
'ismember' => in_array($circle['id'], $member_of),
|
||||
];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
// Don't show the groups on the network page when there is only one
|
||||
if ((count($display_groups) <= 2) && ($each == 'network')) {
|
||||
// Don't show the circles on the network page when there is only one
|
||||
if ((count($display_circles) <= 2) && ($each == 'network')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('group_side.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('circle_side.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$add' => DI::l10n()->t('add'),
|
||||
'$title' => DI::l10n()->t('Groups'),
|
||||
'$groups' => $display_groups,
|
||||
'newgroup' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
|
||||
'grouppage' => 'group/',
|
||||
'$edittext' => DI::l10n()->t('Edit group'),
|
||||
'$ungrouped' => $every === 'contact' ? DI::l10n()->t('Contacts not in any group') : '',
|
||||
'$ungrouped_selected' => (($group_id === 'none') ? 'group-selected' : ''),
|
||||
'$createtext' => DI::l10n()->t('Create a new group'),
|
||||
'$creategroup' => DI::l10n()->t('Group Name: '),
|
||||
'$editgroupstext' => DI::l10n()->t('Edit groups'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('group_edit'),
|
||||
'$title' => DI::l10n()->t('Circles'),
|
||||
'$circles' => $display_circles,
|
||||
'$new_circle' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
|
||||
'$circle_page' => 'circle/',
|
||||
'$edittext' => DI::l10n()->t('Edit circle'),
|
||||
'$uncircled' => $every === 'contact' ? DI::l10n()->t('Contacts not in any circle') : '',
|
||||
'$uncircled_selected' => (($circle_id === 'none') ? 'circle-selected' : ''),
|
||||
'$createtext' => DI::l10n()->t('Create a new circle'),
|
||||
'$create_circle' => DI::l10n()->t('Circle Name: '),
|
||||
'$edit_circles_text' => DI::l10n()->t('Edit circles'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('circle_edit'),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the group id for the given contact id
|
||||
* Fetch the circle id for the given contact id
|
||||
*
|
||||
* @param integer $id Contact ID
|
||||
* @return integer Group IO
|
||||
* @return integer Circle ID
|
||||
*/
|
||||
public static function getIdForForum(int $id): int
|
||||
{
|
||||
|
@ -623,8 +623,8 @@ class Group
|
|||
return 0;
|
||||
}
|
||||
|
||||
$group = DBA::selectFirst('group', ['id'], ['uid' => $contact['uid'], 'cid' => $id]);
|
||||
if (empty($group)) {
|
||||
$circle = DBA::selectFirst('group', ['id'], ['uid' => $contact['uid'], 'cid' => $id]);
|
||||
if (empty($circle)) {
|
||||
$fields = [
|
||||
'uid' => $contact['uid'],
|
||||
'name' => $contact['name'],
|
||||
|
@ -633,14 +633,14 @@ class Group
|
|||
DBA::insert('group', $fields);
|
||||
$gid = DBA::lastInsertId();
|
||||
} else {
|
||||
$gid = $group['id'];
|
||||
$gid = $circle['id'];
|
||||
}
|
||||
|
||||
return $gid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the followers of a given contact id and store them as group members
|
||||
* Fetch the followers of a given contact id and store them as circle members
|
||||
*
|
||||
* @param integer $id Contact ID
|
||||
* @return void
|
||||
|
@ -664,9 +664,9 @@ class Group
|
|||
return;
|
||||
}
|
||||
|
||||
$group_members = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $gid]);
|
||||
if (!empty($group_members)) {
|
||||
$current = array_unique(array_column($group_members, 'contact-id'));
|
||||
$circle_members = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $gid]);
|
||||
if (!empty($circle_members)) {
|
||||
$current = array_unique(array_column($circle_members, 'contact-id'));
|
||||
} else {
|
||||
$current = [];
|
||||
}
|
|
@ -3097,7 +3097,7 @@ class Contact
|
|||
$contact_id = $contact['id'];
|
||||
$result['cid'] = $contact_id;
|
||||
|
||||
Group::addMember(User::getDefaultGroup($uid), $contact_id);
|
||||
Circle::addMember(User::getDefaultCircle($uid), $contact_id);
|
||||
|
||||
// Update the avatar
|
||||
self::updateAvatar($contact_id, $ret['photo']);
|
||||
|
@ -3238,7 +3238,7 @@ class Contact
|
|||
DI::intro()->save($intro);
|
||||
}
|
||||
|
||||
Group::addMember(User::getDefaultGroup($importer['uid']), $contact_record['id']);
|
||||
Circle::addMember(User::getDefaultCircle($importer['uid']), $contact_record['id']);
|
||||
|
||||
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
|
||||
DI::notify()->createFromArray([
|
||||
|
|
|
@ -26,12 +26,12 @@ use Friendica\DI;
|
|||
use Friendica\Model\Contact;
|
||||
|
||||
/**
|
||||
* This class provides information about contact groups based on the "group_member" table.
|
||||
* This class provides information about contact circles based on the "group_member" table.
|
||||
*/
|
||||
class Group
|
||||
class Circle
|
||||
{
|
||||
/**
|
||||
* Returns a list of contacts belonging in a group
|
||||
* Returns a list of contacts belonging in a circle
|
||||
*
|
||||
* @param int $gid
|
||||
* @return array
|
||||
|
@ -42,10 +42,10 @@ class Group
|
|||
$return = [];
|
||||
|
||||
if (intval($gid)) {
|
||||
$stmt = DBA::p('SELECT `group_member`.`contact-id`, `contact`.*
|
||||
$stmt = DBA::p('SELECT `circle_member`.`contact-id`, `contact`.*
|
||||
FROM `contact`
|
||||
INNER JOIN `group_member`
|
||||
ON `contact`.`id` = `group_member`.`contact-id`
|
||||
INNER JOIN `group_member` AS `circle_member`
|
||||
ON `contact`.`id` = `circle_member`.`contact-id`
|
||||
WHERE `gid` = ?
|
||||
AND `contact`.`uid` = ?
|
||||
AND NOT `contact`.`self`
|
||||
|
@ -66,24 +66,24 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns ungrouped contact count or list for user
|
||||
* Returns uncircled contact count or list for user
|
||||
*
|
||||
* Returns either the total number of ungrouped contacts for the given user
|
||||
* id or a paginated list of ungrouped contacts.
|
||||
* Returns either the total number of uncircled contacts for the given user
|
||||
* id or a paginated list of uncircled contacts.
|
||||
*
|
||||
* @param int $uid uid
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function listUngrouped(int $uid)
|
||||
public static function listUncircled(int $uid)
|
||||
{
|
||||
return Contact::selectToArray([], ["`uid` = ? AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `failed`
|
||||
AND `id` NOT IN (SELECT DISTINCT(`contact-id`) FROM `group_member` INNER JOIN `group` ON `group`.`id` = `group_member`.`gid`
|
||||
WHERE `group`.`uid` = ? AND `contact-id` = `contact`.`id`)", $uid, $uid]);
|
||||
AND `id` NOT IN (SELECT DISTINCT(`contact-id`) FROM `group_member` AS `circle_member` INNER JOIN `group` AS `circle` ON `circle`.`id` = `circle_member`.`gid`
|
||||
WHERE `circle`.`uid` = ? AND `contact-id` = `contact`.`id`)", $uid, $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a contact from all groups
|
||||
* Remove a contact from all circles
|
||||
*
|
||||
* @param integer $contact_id
|
||||
*
|
|
@ -2254,7 +2254,7 @@ class Item
|
|||
|
||||
if ($owner['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
|
||||
$allow_cid = '';
|
||||
$allow_gid = '<' . Group::FOLLOWERS . '>';
|
||||
$allow_gid = '<' . Circle::FOLLOWERS . '>';
|
||||
$deny_cid = '';
|
||||
$deny_gid = '';
|
||||
self::performActivity($item['id'], 'announce', $uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
||||
|
@ -2528,13 +2528,13 @@ class Item
|
|||
$expand_followers = true;
|
||||
}
|
||||
|
||||
$allow_people = $aclFormatter->expand($obj['allow_cid']);
|
||||
$allow_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['allow_gid']), $check_dead, $expand_followers);
|
||||
$deny_people = $aclFormatter->expand($obj['deny_cid']);
|
||||
$deny_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['deny_gid']), $check_dead);
|
||||
$recipients = array_unique(array_merge($allow_people, $allow_groups));
|
||||
$deny = array_unique(array_merge($deny_people, $deny_groups));
|
||||
$recipients = array_diff($recipients, $deny);
|
||||
$allow_people = $aclFormatter->expand($obj['allow_cid']);
|
||||
$allow_circles = Circle::expand($obj['uid'], $aclFormatter->expand($obj['allow_gid']), $check_dead, $expand_followers);
|
||||
$deny_people = $aclFormatter->expand($obj['deny_cid']);
|
||||
$deny_circles = Circle::expand($obj['uid'], $aclFormatter->expand($obj['deny_gid']), $check_dead);
|
||||
$recipients = array_unique(array_merge($allow_people, $allow_circles));
|
||||
$deny = array_unique(array_merge($deny_people, $deny_circles));
|
||||
$recipients = array_diff($recipients, $deny);
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
|
@ -2900,9 +2900,9 @@ class Item
|
|||
/*
|
||||
* Authenticated visitor. Unless pre-verified,
|
||||