<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Model\User;
/**
* Handle ACL management and display
*/
class ACL
{
+ /**
+ * Returns the default lock state for the given user id
+ * @param int $uid
+ * @return bool "true" if the default settings are non public
+ */
+ public static function getLockstateForUserId(int $uid)
+ {
+ $user = User::getById($uid, ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);
+ return !empty($user['allow_cid']) || !empty($user['allow_gid']) || !empty($user['deny_cid']) || !empty($user['deny_gid']);
+ }
+
/**
* Returns a select input tag for private message recipient
*
return $o;
}
+ /**
+ * Returns a minimal ACL block for self-only permissions
+ *
+ * @param int $localUserId
+ * @param string $explanation
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function getSelfOnlyHTML(int $localUserId, string $explanation)
+ {
+ $selfPublicContactId = Contact::getPublicIdByUserId($localUserId);
+
+ $tpl = Renderer::getMarkupTemplate('acl/self_only.tpl');
+ $o = Renderer::replaceMacros($tpl, [
+ '$selfPublicContactId' => $selfPublicContactId,
+ '$explanation' => $explanation,
+ ]);
+
+ return $o;
+ }
+
/**
* Return the default permission of the provided user array
*
'archive' => false,
'deleted' => false,
'pending' => false,
+ 'network' => Protocol::FEDERATED,
'rel' => [Contact::FOLLOWER, Contact::FRIEND]
], $condition),
$params
$acl_forums = Contact::selectToArray($fields,
['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
- 'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
+ 'network' => Protocol::FEDERATED, 'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
);
$acl_contacts = array_merge($acl_forums, $acl_contacts);
* Return the full jot ACL selector HTML
*
* @param Page $page
- * @param array $user User array
+ * @param int $uid User ID
* @param bool $for_federation
* @param array $default_permissions Static defaults permission array:
* [
*/
public static function getFullSelectorHTML(
Page $page,
- array $user = null,
+ int $uid = null,
bool $for_federation = false,
array $default_permissions = [],
array $condition = [],
$form_prefix = ''
) {
- if (empty($user['uid'])) {
+ if (empty($uid)) {
return '';
}
static $input_group_id = 0;
+ $user = User::getById($uid);
+
$input_group_id++;
$page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));