diff --git a/doc/Addons.md b/doc/Addons.md
index 54363cb1d..c1861c791 100644
--- a/doc/Addons.md
+++ b/doc/Addons.md
@@ -604,10 +604,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('post_local_end', $arr);
-### mod/lockview.php
-
- Hook::callAll('lockview_content', $item);
-
### mod/uexport.php
Hook::callAll('uexport_options', $options);
@@ -679,6 +675,10 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('register_account', $uid);
Hook::callAll('remove_user', $user);
+### src/Module/PermissionTooltip.php
+
+ Hook::callAll('lockview_content', $item);
+
### src/Content/ContactBlock.php
Hook::callAll('contact_block_end', $arr);
diff --git a/doc/de/Addons.md b/doc/de/Addons.md
index 745010ff4..2ff749549 100644
--- a/doc/de/Addons.md
+++ b/doc/de/Addons.md
@@ -312,10 +312,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('post_local_end', $arr);
-### mod/lockview.php
-
- Hook::callAll('lockview_content', $item);
-
### mod/uexport.php
Hook::callAll('uexport_options', $options);
@@ -422,6 +418,10 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('storage_instance', $data);
+### src/Module/PermissionTooltip.php
+
+ Hook::callAll('lockview_content', $item);
+
### src/Worker/Directory.php
Hook::callAll('globaldir_update', $arr);
diff --git a/mod/lockview.php b/mod/lockview.php
deleted file mode 100644
index e48debfc6..000000000
--- a/mod/lockview.php
+++ /dev/null
@@ -1,161 +0,0 @@
-.
- *
- */
-
-use Friendica\App;
-use Friendica\Core\Hook;
-use Friendica\Database\DBA;
-use Friendica\DI;
-use Friendica\Model\Group;
-use Friendica\Model\Item;
-
-function lockview_content(App $a)
-{
- $type = (($a->argc > 1) ? $a->argv[1] : 0);
- if (is_numeric($type)) {
- $item_id = intval($type);
- $type = 'item';
- } else {
- $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
- }
-
- if (!$item_id) {
- exit();
- }
-
- if (!in_array($type, ['item','photo','event'])) {
- exit();
- }
-
- $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
- $condition = ['id' => $item_id];
-
- if ($type != 'item') {
- $item = DBA::selectFirst($type, $fields, $condition);
- } else {
- $fields[] = 'private';
- $item = Item::selectFirst($fields, $condition);
- }
-
- if (!DBA::isResult($item)) {
- exit();
- }
-
- Hook::callAll('lockview_content', $item);
-
- if ($item['uid'] != local_user()) {
- echo DI::l10n()->t('Remote privacy information not available.') . '
';
- exit();
- }
-
- if (isset($item['private'])
- && $item['private'] == Item::PRIVATE
- && empty($item['allow_cid'])
- && empty($item['allow_gid'])
- && empty($item['deny_cid'])
- && empty($item['deny_gid']))
- {
- echo DI::l10n()->t('Remote privacy information not available.') . '
';
- exit();
- }
-
- $aclFormatter = DI::aclFormatter();
-
- $allowed_users = $aclFormatter->expand($item['allow_cid']);
- $allowed_groups = $aclFormatter->expand($item['allow_gid']);
- $deny_users = $aclFormatter->expand($item['deny_cid']);
- $deny_groups = $aclFormatter->expand($item['deny_gid']);
-
- $o = DI::l10n()->t('Visible to:') . '
';
- $l = [];
-
- if (count($allowed_groups)) {
- $key = array_search(Group::FOLLOWERS, $allowed_groups);
- if ($key !== false) {
- $l[] = '' . DI::l10n()->t('Followers') . '';
- unset($allowed_groups[$key]);
- }
-
- $key = array_search(Group::MUTUALS, $allowed_groups);
- if ($key !== false) {
- $l[] = '' . DI::l10n()->t('Mutuals') . '';
- unset($allowed_groups[$key]);
- }
-
-
- $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ', $allowed_groups))
- );
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $l[] = '' . $rr['name'] . '';
- }
- }
- }
-
- if (count($allowed_users)) {
- $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ', $allowed_users))
- );
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $l[] = $rr['name'];
- }
- }
- }
-
- if (count($deny_groups)) {
- $key = array_search(Group::FOLLOWERS, $deny_groups);
- if ($key !== false) {
- $l[] = '' . DI::l10n()->t('Followers') . '';
- unset($deny_groups[$key]);
- }
-
- $key = array_search(Group::MUTUALS, $deny_groups);
- if ($key !== false) {
- $l[] = '' . DI::l10n()->t('Mutuals') . '';
- unset($deny_groups[$key]);
- }
-
- $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ', $deny_groups))
- );
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $l[] = '' . $rr['name'] . '';
- }
- }
- }
-
- if (count($deny_users)) {
- $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ', $deny_users))
- );
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- $l[] = '' . $rr['name'] . '';
- }
- }
- }
-
- echo $o . implode(', ', $l);
- exit();
-
-}
diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php
new file mode 100644
index 000000000..3e760ef1e
--- /dev/null
+++ b/src/Module/PermissionTooltip.php
@@ -0,0 +1,120 @@
+t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
+ }
+
+ $condition = ['id' => $referenceId];
+ if ($type == 'item') {
+ $fields = ['uid', 'psid', 'private'];
+ $model = Item::selectFirst($fields, $condition);
+ } else {
+ $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
+ $model = DBA::selectFirst($type, $fields, $condition);
+ }
+
+ if (!DBA::isResult($model)) {
+ throw new HttpException\NotFoundException(DI::l10n()->t('Model not found'));
+ }
+
+ if (isset($model['psid'])) {
+ $permissionSet = DI::permissionSet()->selectFirst(['id' => $model['psid']]);
+ $model['allow_cid'] = $permissionSet->allow_cid;
+ $model['allow_gid'] = $permissionSet->allow_gid;
+ $model['deny_cid'] = $permissionSet->deny_cid;
+ $model['deny_gid'] = $permissionSet->deny_gid;
+ }
+
+ // Kept for backwards compatiblity
+ Hook::callAll('lockview_content', $model);
+
+ if ($model['uid'] != local_user() ||
+ isset($model['private'])
+ && $model['private'] == Item::PRIVATE
+ && empty($model['allow_cid'])
+ && empty($model['allow_gid'])
+ && empty($model['deny_cid'])
+ && empty($model['deny_gid']))
+ {
+ echo DI::l10n()->t('Remote privacy information not available.');
+ exit;
+ }
+
+ $aclFormatter = DI::aclFormatter();
+
+ $allowed_users = $aclFormatter->expand($model['allow_cid']);
+ $allowed_groups = $aclFormatter->expand($model['allow_gid']);
+ $deny_users = $aclFormatter->expand($model['deny_cid']);
+ $deny_groups = $aclFormatter->expand($model['deny_gid']);
+
+ $o = DI::l10n()->t('Visible to:') . '
';
+ $l = [];
+
+ if (count($allowed_groups)) {
+ $key = array_search(Group::FOLLOWERS, $allowed_groups);
+ if ($key !== false) {
+ $l[] = '' . DI::l10n()->t('Followers') . '';
+ unset($allowed_groups[$key]);
+ }
+
+ $key = array_search(Group::MUTUALS, $allowed_groups);
+ if ($key !== false) {
+ $l[] = '' . DI::l10n()->t('Mutuals') . '';
+ unset($allowed_groups[$key]);
+ }
+
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
+ $l[] = '' . $group['name'] . '';
+ }
+ }
+
+ foreach (DI::dba()->selectToArray('contact', ['name'], ['id' => $allowed_users]) as $contact) {
+ $l[] = $contact['name'];
+ }
+
+ if (count($deny_groups)) {
+ $key = array_search(Group::FOLLOWERS, $deny_groups);
+ if ($key !== false) {
+ $l[] = '' . DI::l10n()->t('Followers') . '';
+ unset($deny_groups[$key]);
+ }
+
+ $key = array_search(Group::MUTUALS, $deny_groups);
+ if ($key !== false) {
+ $l[] = '' . DI::l10n()->t('Mutuals') . '';
+ unset($deny_groups[$key]);
+ }
+
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
+ $l[] = '' . $group['name'] . '';
+ }
+ }
+
+ foreach (DI::dba()->selectToArray('contact', ['name'], ['id' => $deny_users]) as $contact) {
+ $l[] = '' . $contact['name'] . '';
+ }
+
+ echo $o . implode(', ', $l);
+ exit();
+ }
+}
diff --git a/static/routes.config.php b/static/routes.config.php
index 8c3fba99b..ddfabd778 100644
--- a/static/routes.config.php
+++ b/static/routes.config.php
@@ -237,6 +237,8 @@ return [
'/openid' => [Module\Security\OpenID::class, [R::GET]],
'/opensearch' => [Module\OpenSearch::class, [R::GET]],
+ '/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
+
'/photo' => [
'/{name}' => [Module\Photo::class, [R::GET]],
'/{type}/{name}' => [Module\Photo::class, [R::GET]],
diff --git a/view/js/main.js b/view/js/main.js
index 60337918b..36c9cbb88 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -750,26 +750,23 @@ function getPosition(e) {
var lockvisible = false;
-function lockview(event,id) {
+function lockview(event, type, id) {
event = event || window.event;
cursor = getPosition(event);
if (lockvisible) {
- lockviewhide();
+ lockvisible = false;
+ $('#panel').hide();
} else {
lockvisible = true;
- $.get('lockview/' + id, function(data) {
- $('#panel').html(data);
- $('#panel').css({'left': cursor.x + 5 , 'top': cursor.y + 5});
- $('#panel').show();
+ $.get('permission/tooltip/' + type + '/' + id, function(data) {
+ $('#panel')
+ .html(data)
+ .css({'left': cursor.x + 5 , 'top': cursor.y + 5})
+ .show();
});
}
}
-function lockviewhide() {
- lockvisible = false;
- $('#panel').hide();
-}
-
function post_comment(id) {
unpause();
commentBusy = true;
@@ -940,14 +937,6 @@ function groupChangeMember(gid, cid, sec_token) {
});
}
-function profChangeMember(gid,cid) {
- $('body .fakelink').css('cursor', 'wait');
- $.get('profperm/' + gid + '/' + cid, function(data) {
- $('#prof-update-wrapper').html(data);
- $('body .fakelink').css('cursor', 'auto');
- });
-}
-
function contactgroupChangeMember(checkbox, gid, cid) {
let url;
// checkbox.checked is the checkbox state after the click
diff --git a/view/templates/photo_view.tpl b/view/templates/photo_view.tpl
index 7170ceb33..0d7ccb20f 100644
--- a/view/templates/photo_view.tpl
+++ b/view/templates/photo_view.tpl
@@ -17,7 +17,7 @@
| {{$tools.profile.1}}
{{/if}}
{{if $tools.lock}}
- |
+ |
{{/if}}
{{/if}}
diff --git a/view/templates/search_item.tpl b/view/templates/search_item.tpl
index 38aa94749..1a756db8a 100644
--- a/view/templates/search_item.tpl
+++ b/view/templates/search_item.tpl
@@ -17,7 +17,7 @@