Hook::callAll('post_local_end', $arr);
-### mod/lockview.php
-
- Hook::callAll('lockview_content', $item);
-
### mod/uexport.php
Hook::callAll('uexport_options', $options);
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);
Hook::callAll('post_local_end', $arr);
-### mod/lockview.php
-
- Hook::callAll('lockview_content', $item);
-
### mod/uexport.php
Hook::callAll('uexport_options', $options);
Hook::callAll('storage_instance', $data);
+### src/Module/PermissionTooltip.php
+
+ Hook::callAll('lockview_content', $item);
+
### src/Worker/Directory.php
Hook::callAll('globaldir_update', $arr);
--- /dev/null
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\Core\Hook;
+use Friendica\Database\DBA;
+use Friendica\DI;
+use Friendica\Model\Item;
+use Friendica\Model\Group;
+use Friendica\Network\HTTPException;
+
+/**
+ * Outputs the permission tooltip HTML content for the provided item, photo or event id.
+ */
+class PermissionTooltip extends \Friendica\BaseModule
+{
+ public static function rawContent(array $parameters = [])
+ {
+ parent::rawContent($parameters); // TODO: Change the autogenerated stub
+
+ $type = $parameters['type'];
+ $referenceId = $parameters['id'];
+
+ $expectedTypes = ['item', 'photo', 'event'];
+ if (!in_array($type, $expectedTypes)) {
+ throw new HTTPException\BadRequestException(DI::l10n()->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:') . '<br />';
+ $l = [];
+
+ if (count($allowed_groups)) {
+ $key = array_search(Group::FOLLOWERS, $allowed_groups);
+ if ($key !== false) {
+ $l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
+ unset($allowed_groups[$key]);
+ }
+
+ $key = array_search(Group::MUTUALS, $allowed_groups);
+ if ($key !== false) {
+ $l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
+ unset($allowed_groups[$key]);
+ }
+
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
+ $l[] = '<b>' . $group['name'] . '</b>';
+ }
+ }
+
+ 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[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
+ unset($deny_groups[$key]);
+ }
+
+ $key = array_search(Group::MUTUALS, $deny_groups);
+ if ($key !== false) {
+ $l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
+ unset($deny_groups[$key]);
+ }
+
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
+ $l[] = '<b><strike>' . $group['name'] . '</strike></b>';
+ }
+ }
+
+ foreach (DI::dba()->selectToArray('contact', ['name'], ['id' => $deny_users]) as $contact) {
+ $l[] = '<strike>' . $contact['name'] . '</strike>';
+ }
+
+ echo $o . implode(', ', $l);
+ exit();
+ }
+}
'/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]],
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;
});
}
-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
| <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
{{/if}}
{{if $tools.lock}}
- | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+ | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event, 'photo', {{$id}});" />
{{/if}}
{{/if}}
</div>
</div>
<div class="wall-item-photo-end"></div>
<div class="wall-item-wrapper" id="wall-item-wrapper-{{$item.id}}" >
- {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event,{{$item.id}});" /></div>
+ {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event, 'item', {{$item.id}});" /></div>
{{else}}<div class="wall-item-lock"></div>{{/if}}
<div class="wall-item-location" id="wall-item-location-{{$item.id}}">{{$item.location nofilter}}</div>
</div>
</div>
<div class="wall-item-photo-end"></div>
<div class="wall-item-wrapper" id="wall-item-wrapper-{{$item.id}}" >
- {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event,{{$item.id}});" /></div>
+ {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event, 'item', {{$item.id}});" /></div>
{{else}}<div class="wall-item-lock"></div>{{/if}}
<div class="wall-item-location" id="wall-item-location-{{$item.id}}">{{$item.location nofilter}}</div>
</div>
{{/if}}
{{if $tools.lock}}
<span class="icon-padding"> </span>
- <a id="photo-lock-link" onclick="lockview(event,'photo/{{$id}}');" title="{{$tools.lock}}" data-toggle="tooltip">
+ <a id="photo-lock-link" onclick="lockview(event, 'photo', {{$id}});" title="{{$tools.lock}}" data-toggle="tooltip">
<i class="page-action faded-icon fa fa-lock"></i>
</a>
{{/if}}
<!-- TODO => Unknow block -->
<div class="wall-item-decor" style="display:none;">
<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>
- {{if $item.lock}}<span class="navicon lock fakelink" onclick="lockview(event, {{$item.id}});" title="{{$item.lock}}"></span><span class="fa fa-lock" aria-hidden="true"></span>{{/if}}
+ {{if $item.lock}}<span class="navicon lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}"></span><span class="fa fa-lock" aria-hidden="true"></span>{{/if}}
</div>
<!-- ./TODO => Unknow block -->
</a>
{{/if}}
{{if $item.lock}}
- <span class="navicon lock fakelink" onClick="lockview(event, {{$item.id}});" title="{{$item.lock}}">
+ <span class="navicon lock fakelink" onClick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}">
<small><i class="fa fa-lock" aria-hidden="true"></i></small>
</span>
{{/if}}
{{if $item.star}}
<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>
{{/if}}
- {{if $item.lock}}<span class="navicon lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}"></span><span class="fa fa-lock"></span>{{/if}}
+ {{if $item.lock}}<span class="navicon lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}"></span><span class="fa fa-lock"></span>{{/if}}
</div>
{{* /TODO => Unknown block *}}
</a>
{{/if}}
{{if $item.lock}}
- <span class="navicon lock fakelink" onClick="lockview(event,{{$item.id}});" title="{{$item.lock}}" data-toggle="tooltip">
+ <span class="navicon lock fakelink" onClick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}" data-toggle="tooltip">
<small><i class="fa fa-lock" aria-hidden="true"></i></small>
</span>
{{/if}}
| <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
{{/if}}
{{if $tools.lock}}
- | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+ | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event, 'photo', {{$id}});" />
{{/if}}
{{/if}}
</div>
<div class="wall-item-decor">
{{if $item.star}}<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>{{/if}}
- {{if $item.lock}}<span class="icon s22 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
+ {{if $item.lock}}<span class="icon s22 lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
</div>
<div class="wall-item-decor">
{{if $item.star}}<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>{{/if}}
- {{if $item.lock}}<span class="icon s22 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
+ {{if $item.lock}}<span class="icon s22 lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
</div>
<div class="wall-item-location" id="wall-item-location-{{$item.id}}">{{if $item.location}}<span class="icon globe"></span>{{$item.location nofilter}} {{/if}}</div>
</div>
<div class="wall-item-lock-wrapper">
- {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event,{{$item.id}});" /></div>
+ {{if $item.lock}}<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event, 'item', {{$item.id}});" /></div>
{{else}}<div class="wall-item-lock"></div>{{/if}}
</div>
<div class="wall-item-tools" id="wall-item-tools-{{$item.id}}">
<div class="wall-item-lock-wrapper">
{{if $item.lock}}
<div class="wall-item-lock">
- <img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event,{{$item.id}});" />
+ <img src="images/lock_icon.gif" class="lockview" alt="{{$item.lock}}" onclick="lockview(event, 'item', {{$item.id}});" />
</div>
{{else}}
<div class="wall-item-lock"></div>
<a href="{{$profile_url}}" target="redir" title="{{$linktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$sparkle}}">{{$name}}</span></a>
<span class="wall-item-ago">
{{if $plink}}<a class="link" title="{{$plink.title}}" href="{{$plink.href}}" style="color: #999">{{$ago}}</a>{{else}} {{$ago}} {{/if}}
- {{if $lock}}<span class="fakelink" style="color: #999" onclick="lockview(event,{{$id}});">{{$lock}}</span> {{/if}}
+ {{if $lock}}<span class="fakelink" style="color: #999" onclick="lockview(event, 'item', {{$id}});">{{$lock}}</span> {{/if}}
</span>
</div>
<div class="wall-item-content">
| <a id="photo-toprofile-link" href="{{$tools.profile.0}}">{{$tools.profile.1}}</a>
{{/if}}
{{if $tools.lock}}
- | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event,'photo/{{$id}}');" />
+ | <img src="images/lock_icon.gif" class="lockview" alt="{{$tools.lock}}" onclick="lockview(event, 'photo', {{$id}});" />
{{/if}}
{{/if}}
</div>
<div class="wall-item-decor">
{{if $item.star}}<span class="icon star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>{{/if}}
- {{if $item.lock}}<span class="icon lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
+ {{if $item.lock}}<span class="icon lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
</div>
<a href="{{$item.profile_url}}" target="redir" title="{{$item.linktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$item.sparkle}}">{{$item.name}}</span></a>
<span class="wall-item-ago">
{{if $item.plink}}<a class="link" title="{{$item.plink.title}}" href="{{$item.plink.href}}" style="color: #999">{{$item.ago}}</a>{{else}} {{$item.ago}} {{/if}}
- {{if $item.lock}}<span class="fakelink" style="color: #999" onclick="lockview(event,{{$item.id}});">{{$item.lock}}</span> {{/if}}
+ {{if $item.lock}}<span class="fakelink" style="color: #999" onclick="lockview(event, 'item', {{$item.id}});">{{$item.lock}}</span> {{/if}}
</span>
</div>
<div class="wall-item-content">
{{/if}}
<span class="pinned">{{$item.pinned}}</span>
</span>
- {{if $item.lock}}<span class="icon s10 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
+ {{if $item.lock}}<span class="icon s10 lock fakelink" onclick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
<span class="wall-item-network" title="{{$item.app}}">
{{$item.network_name}}
</span>