X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FACL.php;h=a4acf58bad4fb0fb54590ad47e63e268379af375;hb=6c767743d1bfdfe44c0df37df10b50ba68cce200;hp=504e5d847d2366a1ce044d1bc4eeb01a4d7376db;hpb=a844fd8f58fbdc5ef95c8db4688fd035ba0c28c5;p=friendica.git
diff --git a/src/Core/ACL.php b/src/Core/ACL.php
index 504e5d847d..a4acf58bad 100644
--- a/src/Core/ACL.php
+++ b/src/Core/ACL.php
@@ -1,6 +1,6 @@
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'));
+ $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
- $o .= "' . PHP_EOL;
+ return $o;
+ }
- if ($preselected) {
- $o .= implode(', ', $receiverlist);
- }
+ /**
+ * 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);
- Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o);
+ $tpl = Renderer::getMarkupTemplate('acl/self_only.tpl');
+ $o = Renderer::replaceMacros($tpl, [
+ '$selfPublicContactId' => $selfPublicContactId,
+ '$explanation' => $explanation,
+ ]);
return $o;
}
@@ -146,6 +154,7 @@ class ACL
'archive' => false,
'deleted' => false,
'pending' => false,
+ 'network' => Protocol::FEDERATED,
'rel' => [Contact::FOLLOWER, Contact::FRIEND]
], $condition),
$params
@@ -158,7 +167,7 @@ class ACL
$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);
@@ -211,7 +220,7 @@ class ACL
* 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:
* [
@@ -227,18 +236,20 @@ class ACL
*/
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'));
@@ -330,4 +341,62 @@ class ACL
return $o;
}
+
+ /**
+ * Checks the validity of the given ACL string
+ *
+ * @param string $acl_string
+ * @param int $uid
+ * @return bool
+ * @throws Exception
+ */
+ public static function isValidContact($acl_string, $uid)
+ {
+ if (empty($acl_string)) {
+ return true;
+ }
+
+ // split into array of cids
+ preg_match_all('/<[A-Za-z0-9]+>/', $acl_string, $array);
+
+ // check for each cid if the contact is valid for the given user
+ $cid_array = $array[0];
+ foreach ($cid_array as $cid) {
+ $cid = str_replace(['<', '>'], ['', ''], $cid);
+ if (!DBA::exists('contact', ['id' => $cid, 'uid' => $uid])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks the validity of the given ACL string
+ *
+ * @param string $acl_string
+ * @param int $uid
+ * @return bool
+ * @throws Exception
+ */
+ public static function isValidGroup($acl_string, $uid)
+ {
+ if (empty($acl_string)) {
+ return true;
+ }
+
+ // split into array of cids
+ preg_match_all('/<[A-Za-z0-9]+>/', $acl_string, $array);
+
+ // check for each cid if the contact is valid for the given user
+ $gid_array = $array[0];
+ foreach ($gid_array as $gid) {
+ $gid = str_replace(['<', '>'], ['', ''], $gid);
+ if (!DBA::exists('group', ['id' => $gid, 'uid' => $uid, 'deleted' => false])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}