Dedicated circle name for groups
This commit is contained in:
@@ -177,7 +177,7 @@ class Circle
|
||||
public static function countUnseen()
|
||||
{
|
||||
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
|
||||
(SELECT COUNT(*) FROM `post-user`
|
||||
(SELECT COUNT(*) FROM `post-user-view`
|
||||
WHERE `uid` = ?
|
||||
AND `unseen`
|
||||
AND `contact-id` IN
|
||||
@@ -481,12 +481,13 @@ class Circle
|
||||
* Returns a templated circle selection list
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param int $gid An optional pre-selected circle
|
||||
* @param string $label An optional label of the list
|
||||
* @param int $gid A pre-selected circle
|
||||
* @param string $id The id of the option group
|
||||
* @param string $label The label of the option group
|
||||
* @return string
|
||||
* @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 = [
|
||||
[
|
||||
@@ -508,11 +509,8 @@ class Circle
|
||||
|
||||
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'), [
|
||||
'$id' => $id,
|
||||
'$label' => $label,
|
||||
'$circles' => $display_circles
|
||||
]);
|
||||
|
||||
@@ -3100,29 +3100,30 @@ class Contact
|
||||
self::insert([
|
||||
'uid' => $uid,
|
||||
'created' => DateTimeFormat::utcNow(),
|
||||
'url' => $ret['url'],
|
||||
'nurl' => Strings::normaliseLink($ret['url']),
|
||||
'addr' => $ret['addr'],
|
||||
'alias' => $ret['alias'],
|
||||
'batch' => $ret['batch'],
|
||||
'notify' => $ret['notify'],
|
||||
'poll' => $ret['poll'],
|
||||
'poco' => $ret['poco'],
|
||||
'name' => $ret['name'],
|
||||
'nick' => $ret['nick'],
|
||||
'network' => $ret['network'],
|
||||
'baseurl' => $ret['baseurl'],
|
||||
'gsid' => $ret['gsid'] ?? null,
|
||||
'protocol' => $protocol,
|
||||
'pubkey' => $ret['pubkey'],
|
||||
'rel' => $new_relation,
|
||||
'priority' => $ret['priority'],
|
||||
'writable' => $writeable,
|
||||
'hidden' => $hidden,
|
||||
'blocked' => 0,
|
||||
'readonly' => 0,
|
||||
'pending' => $pending,
|
||||
'subhub' => $subhub
|
||||
'url' => $ret['url'],
|
||||
'nurl' => Strings::normaliseLink($ret['url']),
|
||||
'addr' => $ret['addr'],
|
||||
'alias' => $ret['alias'],
|
||||
'batch' => $ret['batch'],
|
||||
'notify' => $ret['notify'],
|
||||
'poll' => $ret['poll'],
|
||||
'poco' => $ret['poco'],
|
||||
'name' => $ret['name'],
|
||||
'nick' => $ret['nick'],
|
||||
'network' => $ret['network'],
|
||||
'baseurl' => $ret['baseurl'],
|
||||
'gsid' => $ret['gsid'] ?? null,
|
||||
'contact-type' => $ret['account-type'] ?? self::TYPE_PERSON,
|
||||
'protocol' => $protocol,
|
||||
'pubkey' => $ret['pubkey'],
|
||||
'rel' => $new_relation,
|
||||
'priority' => $ret['priority'],
|
||||
'writable' => $writeable,
|
||||
'hidden' => $hidden,
|
||||
'blocked' => 0,
|
||||
'readonly' => 0,
|
||||
'pending' => $pending,
|
||||
'subhub' => $subhub
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -3135,7 +3136,11 @@ class Contact
|
||||
$contact_id = $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
|
||||
self::updateAvatar($contact_id, $ret['photo']);
|
||||
@@ -3265,7 +3270,7 @@ class Contact
|
||||
|
||||
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
|
||||
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
|
||||
@@ -3281,7 +3286,11 @@ class Contact
|
||||
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) {
|
||||
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
|
||||
*
|
||||
@@ -502,6 +502,24 @@ class User
|
||||
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
|
||||
*
|
||||
@@ -1208,6 +1226,11 @@ class User
|
||||
|
||||
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 (!strlen($photo)) {
|
||||
$photo = Network::lookupAvatarByEmail($email);
|
||||
|
||||
Reference in New Issue
Block a user