mirror of
https://github.com/friendica/friendica
synced 2025-04-22 01:50:11 +00:00
Replace "group" with "circle" in the rest of the code
- Remaining mentions already mean "forum"
This commit is contained in:
parent
4f6e02357a
commit
4f7740264e
120 changed files with 1308 additions and 1304 deletions
|
@ -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,
|
||||
* check that the contact belongs to this $owner_id
|
||||
* and load the groups the visitor belongs to.
|
||||
* and load the circles the visitor belongs to.
|
||||
* If pre-verified, the caller is expected to have already
|
||||
* done this and passed the groups into this function.
|
||||
* done this and passed the circles into this function.
|
||||
*/
|
||||
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
|
||||
|
||||
|
|
|
@ -414,9 +414,9 @@ class Photo
|
|||
* @param integer $scale Scale
|
||||
* @param integer $type Photo type, optional, default: Photo::DEFAULT
|
||||
* @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 = ""
|
||||
* @param string $desc Photo caption. optional, default = ""
|
||||
*
|
||||
* @return boolean True on success
|
||||
|
@ -836,7 +836,7 @@ class Photo
|
|||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny)
|
||||
public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny)
|
||||
{
|
||||
// Simplify image codes
|
||||
$img_body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
|
||||
|
@ -881,7 +881,7 @@ class Photo
|
|||
* Then set the permissions to public.
|
||||
*/
|
||||
|
||||
self::setPermissionForResource($image_rid, $uid, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
self::setPermissionForResource($image_rid, $uid, $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -894,15 +894,15 @@ class Photo
|
|||
* @param string $image_rid
|
||||
* @param integer $uid
|
||||
* @param string $str_contact_allow
|
||||
* @param string $str_group_allow
|
||||
* @param string $str_circle_allow
|
||||
* @param string $str_contact_deny
|
||||
* @param string $str_group_deny
|
||||
* @param string $str_circle_deny
|
||||
* @return void
|
||||
*/
|
||||
public static function setPermissionForResource(string $image_rid, int $uid, string $str_contact_allow, string $str_group_allow, string $str_contact_deny, string $str_group_deny)
|
||||
public static function setPermissionForResource(string $image_rid, int $uid, string $str_contact_allow, string $str_circle_allow, string $str_contact_deny, string $str_circle_deny)
|
||||
{
|
||||
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
|
||||
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
|
||||
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow,
|
||||
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny,
|
||||
'accessible' => DI::pConfig()->get($uid, 'system', 'accessible-photos', false)];
|
||||
|
||||
$condition = ['resource-id' => $image_rid, 'uid' => $uid];
|
||||
|
@ -1228,9 +1228,9 @@ class Photo
|
|||
* @param string $album Album name
|
||||
* @param string $description Photo caption
|
||||
* @param string $allow_cid Permissions, allowed contacts
|
||||
* @param string $allow_gid Permissions, allowed groups
|
||||
* @param string $allow_gid Permissions, allowed circles
|
||||
* @param string $deny_cid Permissions, denied contacts
|
||||
* @param string $deny_gid Permissions, denied group
|
||||
* @param string $deny_gid Permissions, denied circles
|
||||
*
|
||||
* @return integer preview photo size
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
|
|
|
@ -483,23 +483,23 @@ class User
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the default group for a given user and network
|
||||
* Returns the default circle for a given user and network
|
||||
*
|
||||
* @param int $uid User id
|
||||
*
|
||||
* @return int group id
|
||||
* @return int circle id
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getDefaultGroup(int $uid): int
|
||||
public static function getDefaultCircle(int $uid): int
|
||||
{
|
||||
$user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]);
|
||||
if (DBA::isResult($user)) {
|
||||
$default_group = $user["def_gid"];
|
||||
$default_circle = $user['def_gid'];
|
||||
} else {
|
||||
$default_group = 0;
|
||||
$default_circle = 0;
|
||||
}
|
||||
|
||||
return $default_group;
|
||||
return $default_circle;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1188,13 +1188,13 @@ class User
|
|||
throw new Exception(DI::l10n()->t('An error occurred creating your self contact. Please try again.'));
|
||||
}
|
||||
|
||||
// Create a group with no members. This allows somebody to use it
|
||||
// right away as a default group for new contacts.
|
||||
$def_gid = Group::create($uid, DI::l10n()->t('Friends'));
|
||||
// Create a circle with no members. This allows somebody to use it
|
||||
// right away as a default circle for new contacts.
|
||||
$def_gid = Circle::create($uid, DI::l10n()->t('Friends'));
|
||||
if (!$def_gid) {
|
||||
DBA::delete('user', ['uid' => $uid]);
|
||||
|
||||
throw new Exception(DI::l10n()->t('An error occurred creating your default contact group. Please try again.'));
|
||||
throw new Exception(DI::l10n()->t('An error occurred creating your default contact circle. Please try again.'));
|
||||
}
|
||||
|
||||
$fields = ['def_gid' => $def_gid];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue