mirror of
https://github.com/friendica/friendica
synced 2024-11-10 04:22:54 +00:00
Merge pull request #13235 from annando/group-circle
Dedicated circle name for groups
This commit is contained in:
commit
582e05fcff
11 changed files with 290 additions and 241 deletions
|
@ -537,6 +537,14 @@ class Item
|
||||||
$item['private'] = $private_group ? ItemModel::PRIVATE : ItemModel::UNLISTED;
|
$item['private'] = $private_group ? ItemModel::PRIVATE : ItemModel::UNLISTED;
|
||||||
|
|
||||||
if ($only_to_group) {
|
if ($only_to_group) {
|
||||||
|
$cdata = Contact::getPublicAndUserContactID($group_contact['id'], $item['uid']);
|
||||||
|
if (!empty($cdata['user'])) {
|
||||||
|
$item['owner-id'] = $cdata['user'];
|
||||||
|
unset($item['owner-link']);
|
||||||
|
unset($item['owner-name']);
|
||||||
|
unset($item['owner-avatar']);
|
||||||
|
}
|
||||||
|
|
||||||
$item['postopts'] = '';
|
$item['postopts'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ class Circle
|
||||||
public static function countUnseen()
|
public static function countUnseen()
|
||||||
{
|
{
|
||||||
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
|
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
|
||||||
(SELECT COUNT(*) FROM `post-user`
|
(SELECT COUNT(*) FROM `post-user-view`
|
||||||
WHERE `uid` = ?
|
WHERE `uid` = ?
|
||||||
AND `unseen`
|
AND `unseen`
|
||||||
AND `contact-id` IN
|
AND `contact-id` IN
|
||||||
|
@ -481,12 +481,13 @@ class Circle
|
||||||
* Returns a templated circle selection list
|
* Returns a templated circle selection list
|
||||||
*
|
*
|
||||||
* @param int $uid User id
|
* @param int $uid User id
|
||||||
* @param int $gid An optional pre-selected circle
|
* @param int $gid A pre-selected circle
|
||||||
* @param string $label An optional label of the list
|
* @param string $id The id of the option group
|
||||||
|
* @param string $label The label of the option group
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getSelectorHTML(int $uid, int $gid = 0, string $label = ''): string
|
public static function getSelectorHTML(int $uid, int $gid, string $id, string $label): string
|
||||||
{
|
{
|
||||||
$display_circles = [
|
$display_circles = [
|
||||||
[
|
[
|
||||||
|
@ -508,11 +509,8 @@ class Circle
|
||||||
|
|
||||||
Logger::info('Got circles', $display_circles);
|
Logger::info('Got circles', $display_circles);
|
||||||
|
|
||||||
if ($label == '') {
|
|
||||||
$label = DI::l10n()->t('Default privacy circle for new contacts');
|
|
||||||
}
|
|
||||||
|
|
||||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('circle_selection.tpl'), [
|
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('circle_selection.tpl'), [
|
||||||
|
'$id' => $id,
|
||||||
'$label' => $label,
|
'$label' => $label,
|
||||||
'$circles' => $display_circles
|
'$circles' => $display_circles
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -3098,31 +3098,32 @@ class Contact
|
||||||
|
|
||||||
// create contact record
|
// create contact record
|
||||||
self::insert([
|
self::insert([
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'created' => DateTimeFormat::utcNow(),
|
'created' => DateTimeFormat::utcNow(),
|
||||||
'url' => $ret['url'],
|
'url' => $ret['url'],
|
||||||
'nurl' => Strings::normaliseLink($ret['url']),
|
'nurl' => Strings::normaliseLink($ret['url']),
|
||||||
'addr' => $ret['addr'],
|
'addr' => $ret['addr'],
|
||||||
'alias' => $ret['alias'],
|
'alias' => $ret['alias'],
|
||||||
'batch' => $ret['batch'],
|
'batch' => $ret['batch'],
|
||||||
'notify' => $ret['notify'],
|
'notify' => $ret['notify'],
|
||||||
'poll' => $ret['poll'],
|
'poll' => $ret['poll'],
|
||||||
'poco' => $ret['poco'],
|
'poco' => $ret['poco'],
|
||||||
'name' => $ret['name'],
|
'name' => $ret['name'],
|
||||||
'nick' => $ret['nick'],
|
'nick' => $ret['nick'],
|
||||||
'network' => $ret['network'],
|
'network' => $ret['network'],
|
||||||
'baseurl' => $ret['baseurl'],
|
'baseurl' => $ret['baseurl'],
|
||||||
'gsid' => $ret['gsid'] ?? null,
|
'gsid' => $ret['gsid'] ?? null,
|
||||||
'protocol' => $protocol,
|
'contact-type' => $ret['account-type'] ?? self::TYPE_PERSON,
|
||||||
'pubkey' => $ret['pubkey'],
|
'protocol' => $protocol,
|
||||||
'rel' => $new_relation,
|
'pubkey' => $ret['pubkey'],
|
||||||
'priority' => $ret['priority'],
|
'rel' => $new_relation,
|
||||||
'writable' => $writeable,
|
'priority' => $ret['priority'],
|
||||||
'hidden' => $hidden,
|
'writable' => $writeable,
|
||||||
'blocked' => 0,
|
'hidden' => $hidden,
|
||||||
'readonly' => 0,
|
'blocked' => 0,
|
||||||
'pending' => $pending,
|
'readonly' => 0,
|
||||||
'subhub' => $subhub
|
'pending' => $pending,
|
||||||
|
'subhub' => $subhub
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3135,7 +3136,11 @@ class Contact
|
||||||
$contact_id = $contact['id'];
|
$contact_id = $contact['id'];
|
||||||
$result['cid'] = $contact_id;
|
$result['cid'] = $contact_id;
|
||||||
|
|
||||||
Circle::addMember(User::getDefaultCircle($uid), $contact_id);
|
if ($contact['contact-type'] == self::TYPE_COMMUNITY) {
|
||||||
|
Circle::addMember(User::getDefaultGroupCircle($uid), $contact_id);
|
||||||
|
} else {
|
||||||
|
Circle::addMember(User::getDefaultCircle($uid), $contact_id);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the avatar
|
// Update the avatar
|
||||||
self::updateAvatar($contact_id, $ret['photo']);
|
self::updateAvatar($contact_id, $ret['photo']);
|
||||||
|
@ -3265,7 +3270,7 @@ class Contact
|
||||||
|
|
||||||
Post\UserNotification::insertNotification($pub_contact['id'], Activity::FOLLOW, $importer['uid']);
|
Post\UserNotification::insertNotification($pub_contact['id'], Activity::FOLLOW, $importer['uid']);
|
||||||
|
|
||||||
$contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]);
|
$contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo', 'contact-type'], ['id' => $contact_id]);
|
||||||
|
|
||||||
/// @TODO Encapsulate this into a function/method
|
/// @TODO Encapsulate this into a function/method
|
||||||
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
|
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
|
||||||
|
@ -3281,7 +3286,11 @@ class Contact
|
||||||
DI::intro()->save($intro);
|
DI::intro()->save($intro);
|
||||||
}
|
}
|
||||||
|
|
||||||
Circle::addMember(User::getDefaultCircle($importer['uid']), $contact_record['id']);
|
if ($contact_record['contact-type'] == self::TYPE_COMMUNITY) {
|
||||||
|
Circle::addMember(User::getDefaultGroupCircle($importer['uid']), $contact_record['id']);
|
||||||
|
} else {
|
||||||
|
Circle::addMember(User::getDefaultCircle($importer['uid']), $contact_record['id']);
|
||||||
|
}
|
||||||
|
|
||||||
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
|
if (($user['notify-flags'] & Notification\Type::INTRO) && $user['page-flags'] == User::PAGE_FLAGS_NORMAL) {
|
||||||
DI::notify()->createFromArray([
|
DI::notify()->createFromArray([
|
||||||
|
|
|
@ -483,7 +483,7 @@ class User
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default circle for a given user and network
|
* Returns the default circle for a given user
|
||||||
*
|
*
|
||||||
* @param int $uid User id
|
* @param int $uid User id
|
||||||
*
|
*
|
||||||
|
@ -502,6 +502,24 @@ class User
|
||||||
return $default_circle;
|
return $default_circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default circle for groups for a given user
|
||||||
|
*
|
||||||
|
* @param int $uid User id
|
||||||
|
*
|
||||||
|
* @return int circle id
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function getDefaultGroupCircle(int $uid): int
|
||||||
|
{
|
||||||
|
$default_circle = DI::pConfig()->get($uid, 'system', 'default-group-gid');
|
||||||
|
if (empty($default_circle)) {
|
||||||
|
$default_circle = self::getDefaultCircle($uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default_circle;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate a user with a clear text password
|
* Authenticate a user with a clear text password
|
||||||
*
|
*
|
||||||
|
@ -1208,6 +1226,11 @@ class User
|
||||||
|
|
||||||
DBA::update('user', $fields, ['uid' => $uid]);
|
DBA::update('user', $fields, ['uid' => $uid]);
|
||||||
|
|
||||||
|
$def_gid_groups = Circle::create($uid, DI::l10n()->t('Groups'));
|
||||||
|
if ($def_gid_groups) {
|
||||||
|
DI::pConfig()->set($uid, 'system', 'default-group-gid', $def_gid_groups);
|
||||||
|
}
|
||||||
|
|
||||||
// if we have no OpenID photo try to look up an avatar
|
// if we have no OpenID photo try to look up an avatar
|
||||||
if (!strlen($photo)) {
|
if (!strlen($photo)) {
|
||||||
$photo = Network::lookupAvatarByEmail($email);
|
$photo = Network::lookupAvatarByEmail($email);
|
||||||
|
|
|
@ -305,9 +305,9 @@ class Network extends BaseModule
|
||||||
|
|
||||||
protected function parseRequest(array $get)
|
protected function parseRequest(array $get)
|
||||||
{
|
{
|
||||||
self::$circleId = $this->parameters['circle_id'] ?? 0;
|
self::$circleId = (int)($this->parameters['circle_id'] ?? 0);
|
||||||
|
|
||||||
self::$groupContactId = $this->parameters['contact_id'] ?? 0;
|
self::$groupContactId = (int)($this->parameters['contact_id'] ?? 0);
|
||||||
|
|
||||||
self::$selectedTab = self::getTimelineOrderBySession(DI::userSession(), DI::pConfig());
|
self::$selectedTab = self::getTimelineOrderBySession(DI::userSession(), DI::pConfig());
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ class Account extends BaseSettings
|
||||||
|
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', !empty($request['unlisted']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', !empty($request['unlisted']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
|
||||||
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', intval($request['circle-selection-group'] ?? $def_gid));
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'allow_cid' => $str_contact_allow,
|
'allow_cid' => $str_contact_allow,
|
||||||
|
@ -592,7 +593,8 @@ class Account extends BaseSettings
|
||||||
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
|
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
|
||||||
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
|
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
|
||||||
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
|
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
|
||||||
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid']),
|
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid'], 'circle-selection', DI::l10n()->t('Default privacy circle for new contacts')),
|
||||||
|
'$circle_select_group' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', $user['def_gid']), 'circle-selection-group', DI::l10n()->t('Default privacy circle for new group contacts')),
|
||||||
'$permissions' => DI::l10n()->t('Default Post Permissions'),
|
'$permissions' => DI::l10n()->t('Default Post Permissions'),
|
||||||
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
|
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ class Processor
|
||||||
if ($activity['thread-completion'] != $item['owner-id']) {
|
if ($activity['thread-completion'] != $item['owner-id']) {
|
||||||
$actor = Contact::getById($activity['thread-completion'], ['url']);
|
$actor = Contact::getById($activity['thread-completion'], ['url']);
|
||||||
$item['causer-link'] = $actor['url'];
|
$item['causer-link'] = $actor['url'];
|
||||||
$item['causer-id'] = $activity['thread-completion'];
|
$item['causer-id'] = $activity['thread-completion'];
|
||||||
Logger::info('Use inherited actor as causer.', ['id' => $item['owner-id'], 'activity' => $activity['thread-completion'], 'owner' => $item['owner-link'], 'actor' => $actor['url']]);
|
Logger::info('Use inherited actor as causer.', ['id' => $item['owner-id'], 'activity' => $activity['thread-completion'], 'owner' => $item['owner-link'], 'actor' => $actor['url']]);
|
||||||
} else {
|
} else {
|
||||||
// Store the original actor in the "causer" fields to enable the check for ignored or blocked contacts
|
// Store the original actor in the "causer" fields to enable the check for ignored or blocked contacts
|
||||||
|
@ -431,7 +431,7 @@ class Processor
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['owner-link'] = $item['author-link'];
|
$item['owner-link'] = $item['author-link'];
|
||||||
$item['owner-id'] = $item['author-id'];
|
$item['owner-id'] = $item['author-id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$item['isGroup'] && !empty($activity['receiver_urls']['as:audience'])) {
|
if (!$item['isGroup'] && !empty($activity['receiver_urls']['as:audience'])) {
|
||||||
|
@ -440,7 +440,8 @@ class Processor
|
||||||
if (($actor['type'] ?? 'Person') == 'Group') {
|
if (($actor['type'] ?? 'Person') == 'Group') {
|
||||||
Logger::debug('Group post detected via audience.', ['audience' => $audience, 'actor' => $activity['actor'], 'author' => $activity['author']]);
|
Logger::debug('Group post detected via audience.', ['audience' => $audience, 'actor' => $activity['actor'], 'author' => $activity['author']]);
|
||||||
$item['isGroup'] = true;
|
$item['isGroup'] = true;
|
||||||
$item['group-link'] = $audience;
|
$item['group-link'] = $item['owner-link'] = $audience;
|
||||||
|
$item['owner-id'] = Contact::getIdForURL($audience);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -457,13 +458,13 @@ class Processor
|
||||||
|
|
||||||
if (!$item['isGroup'] && (($causer['type'] ?? 'Person') == 'Group')) {
|
if (!$item['isGroup'] && (($causer['type'] ?? 'Person') == 'Group')) {
|
||||||
Logger::debug('Group post detected via causer.', ['actor' => $activity['actor'], 'author' => $activity['author'], 'causer' => $item['causer-link']]);
|
Logger::debug('Group post detected via causer.', ['actor' => $activity['actor'], 'author' => $activity['author'], 'causer' => $item['causer-link']]);
|
||||||
$item['isGroup'] = true;
|
$item['isGroup'] = true;
|
||||||
$item['group-link'] = $item['causer-link'];
|
$item['group-link'] = $item['causer-link'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item['group-link']) && empty($item['causer-link'])) {
|
if (!empty($item['group-link']) && empty($item['causer-link'])) {
|
||||||
$item['causer-link'] = $item['group-link'];
|
$item['causer-link'] = $item['group-link'];
|
||||||
$item['causer-id'] = Contact::getIdForURL($item['causer-link']);
|
$item['causer-id'] = Contact::getIdForURL($item['causer-link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['uri'] = $activity['id'];
|
$item['uri'] = $activity['id'];
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
<div class="field custom">
|
<div class="field custom">
|
||||||
<label for="circle-selection" id="circle-selection-lbl">{{$label}}</label>
|
<label for="{{$id}}" id="circle-selection-lbl">{{$label}}</label>
|
||||||
<select name="circle-selection" id="circle-selection">
|
<select name="{{$id}}" id="{{$id}}">
|
||||||
{{foreach $circles as $circle}}
|
{{foreach $circles as $circle}}
|
||||||
<option value="{{$circle.id}}"{{if $circle.selected}} selected="selected"{{/if}}>{{$circle.name}}</option>
|
<option value="{{$circle.id}}"{{if $circle.selected}} selected="selected"{{/if}}>{{$circle.name}}</option>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
{{include file="field_input.tpl" field=$cntunkmail}}
|
{{include file="field_input.tpl" field=$cntunkmail}}
|
||||||
|
|
||||||
{{$circle_select nofilter}}
|
{{$circle_select nofilter}}
|
||||||
|
{{$circle_select_group nofilter}}
|
||||||
{{if not $is_community}}
|
{{if not $is_community}}
|
||||||
<h3>{{$permissions}}</h3>
|
<h3>{{$permissions}}</h3>
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@
|
||||||
|
|
||||||
{{$circle_select nofilter}}
|
{{$circle_select nofilter}}
|
||||||
|
|
||||||
|
{{$circle_select_group nofilter}}
|
||||||
|
|
||||||
{{if not $is_community}}
|
{{if not $is_community}}
|
||||||
<h3>{{$permissions}}</h3>
|
<h3>{{$permissions}}</h3>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue