mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Add "Yourself" ACL choice and allow multiple ACL selectors on a single page
This commit is contained in:
parent
ebf60cee33
commit
f0474c07ce
2 changed files with 96 additions and 54 deletions
|
@ -228,19 +228,34 @@ class ACL
|
|||
/**
|
||||
* Returns the ACL list of contacts for a given user id
|
||||
*
|
||||
* @param int $user_id
|
||||
* @param int $user_id
|
||||
* @param array $condition Additional contact lookup table conditions
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getContactListByUserId(int $user_id)
|
||||
public static function getContactListByUserId(int $user_id, array $condition = [])
|
||||
{
|
||||
$fields = ['id', 'name', 'addr', 'micro'];
|
||||
$params = ['order' => ['name']];
|
||||
$acl_contacts = Contact::selectToArray($fields,
|
||||
['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
|
||||
'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]], $params
|
||||
$acl_contacts = Contact::selectToArray(
|
||||
$fields,
|
||||
array_merge([
|
||||
'uid' => $user_id,
|
||||
'self' => false,
|
||||
'blocked' => false,
|
||||
'archive' => false,
|
||||
'deleted' => false,
|
||||
'pending' => false,
|
||||
'rel' => [Contact::FOLLOWER, Contact::FRIEND]
|
||||
], $condition),
|
||||
$params
|
||||
);
|
||||
|
||||
$acl_yourself = Contact::selectFirst($fields, ['uid' => $user_id, 'self' => true]);
|
||||
$acl_yourself['name'] = L10n::t('Yourself');
|
||||
|
||||
$acl_contacts[] = $acl_yourself;
|
||||
|
||||
$acl_forums = Contact::selectToArray($fields,
|
||||
['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
|
||||
'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
|
||||
|
@ -295,26 +310,38 @@ class ACL
|
|||
/**
|
||||
* Return the full jot ACL selector HTML
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $user User array
|
||||
* @param bool $for_federation
|
||||
* @param array $default_permissions Static defaults permission array:
|
||||
* [
|
||||
* @param Page $page
|
||||
* @param array $user User array
|
||||
* @param bool $for_federation
|
||||
* @param array $default_permissions Static defaults permission array:
|
||||
* [
|
||||
* 'allow_cid' => [],
|
||||
* 'allow_gid' => [],
|
||||
* 'deny_cid' => [],
|
||||
* 'deny_gid' => [],
|
||||
* 'hidewall' => true/false
|
||||
* ]
|
||||
* ]
|
||||
* @param array $condition
|
||||
* @param string $form_prefix
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getFullSelectorHTML(Page $page, array $user = null, bool $for_federation = false, array $default_permissions = [])
|
||||
{
|
||||
public static function getFullSelectorHTML(
|
||||
Page $page,
|
||||
array $user = null,
|
||||
bool $for_federation = false,
|
||||
array $default_permissions = [],
|
||||
array $condition = [],
|
||||
$form_prefix = ''
|
||||
) {
|
||||
if (empty($user['uid'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
static $input_group_id = 0;
|
||||
|
||||
$input_group_id++;
|
||||
|
||||
$page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
|
||||
$page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
|
||||
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
||||
|
@ -373,12 +400,21 @@ class ACL
|
|||
}
|
||||
}
|
||||
|
||||
$acl_contacts = self::getContactListByUserId($user['uid']);
|
||||
$acl_contacts = self::getContactListByUserId($user['uid'], $condition);
|
||||
|
||||
$acl_groups = self::getGroupListByUserId($user['uid']);
|
||||
|
||||
$acl_list = array_merge($acl_groups, $acl_contacts);
|
||||
|
||||
$input_names = [
|
||||
'visibility' => $form_prefix ? $form_prefix . '[visibility]' : 'visibility',
|
||||
'group_allow' => $form_prefix ? $form_prefix . '[group_allow]' : 'group_allow',
|
||||
'contact_allow' => $form_prefix ? $form_prefix . '[contact_allow]' : 'contact_allow',
|
||||
'group_deny' => $form_prefix ? $form_prefix . '[group_deny]' : 'group_deny',
|
||||
'contact_deny' => $form_prefix ? $form_prefix . '[contact_deny]' : 'contact_deny',
|
||||
'emailcc' => $form_prefix ? $form_prefix . '[emailcc]' : 'emailcc',
|
||||
];
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('acl_selector.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$public_title' => DI::l10n()->t('Public'),
|
||||
|
@ -402,6 +438,8 @@ class ACL
|
|||
'$for_federation' => $for_federation,
|
||||
'$jotnets_fields' => $jotnets_fields,
|
||||
'$user_hidewall' => $default_permissions['hidewall'],
|
||||
'$input_names' => $input_names,
|
||||
'$input_group_id' => $input_group_id,
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue