mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:00:16 +00:00
Comstants for features
This commit is contained in:
parent
d824bb536f
commit
c041c65c1d
20 changed files with 273 additions and 274 deletions
|
@ -389,7 +389,7 @@ class Conversation
|
|||
'$title' => $x['title'] ?? '',
|
||||
'$placeholdertitle' => $this->l10n->t('Set title'),
|
||||
'$category' => $x['category'] ?? '',
|
||||
'$placeholdercategory' => Feature::isEnabled($this->session->getLocalUserId(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
||||
'$placeholdercategory' => Feature::isEnabled($this->session->getLocalUserId(), Feature::CATEGORIES) ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
||||
'$scheduled_at' => Temporal::getDateTimeField(
|
||||
new \DateTime(),
|
||||
new \DateTime('now + 6 months'),
|
||||
|
|
|
@ -26,6 +26,16 @@ use Friendica\DI;
|
|||
|
||||
class Feature
|
||||
{
|
||||
const ADD_ABSTRACT = 'add_abstract';
|
||||
const CATEGORIES = 'categories';
|
||||
const EXPLICIT_MENTIONS = 'explicit_mentions';
|
||||
const GROUPS = 'forumlist_profile';
|
||||
const MEMBER_SINCE = 'profile_membersince';
|
||||
const PHOTO_LOCATION = 'photo_location';
|
||||
const PUBLIC_CALENDAR = 'public_calendar';
|
||||
const TAGCLOUD = 'tagadelic';
|
||||
const TRENDING_TAGS = 'trending_tags';
|
||||
|
||||
/**
|
||||
* check if feature is enabled
|
||||
*
|
||||
|
@ -34,7 +44,7 @@ class Feature
|
|||
* @return boolean
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function isEnabled(int $uid, $feature)
|
||||
public static function isEnabled(int $uid, $feature): bool
|
||||
{
|
||||
$x = DI::config()->get('feature_lock', $feature, false);
|
||||
|
||||
|
@ -52,7 +62,7 @@ class Feature
|
|||
|
||||
$arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $x];
|
||||
Hook::callAll('isEnabled', $arr);
|
||||
return($arr['enabled']);
|
||||
return (bool)$arr['enabled'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,36 +105,35 @@ class Feature
|
|||
'general' => [
|
||||
DI::l10n()->t('General Features'),
|
||||
//array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')),
|
||||
['photo_location', DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, DI::config()->get('feature_lock', 'photo_location', false)],
|
||||
['trending_tags', DI::l10n()->t('Trending Tags'), DI::l10n()->t('Show a community page widget with a list of the most popular tags in recent public posts.'), false, DI::config()->get('feature_lock', 'trending_tags', false)],
|
||||
[self::PHOTO_LOCATION, DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, DI::config()->get('feature_lock', self::PHOTO_LOCATION, false)],
|
||||
[self::TRENDING_TAGS, DI::l10n()->t('Trending Tags'), DI::l10n()->t('Show a community page widget with a list of the most popular tags in recent public posts.'), false, DI::config()->get('feature_lock', self::TRENDING_TAGS, false)],
|
||||
],
|
||||
|
||||
// Post composition
|
||||
'composition' => [
|
||||
DI::l10n()->t('Post Composition Features'),
|
||||
['aclautomention', DI::l10n()->t('Auto-mention Groups'), DI::l10n()->t('Add/remove mention when a group page is selected/deselected in ACL window.'), false, DI::config()->get('feature_lock', 'aclautomention', false)],
|
||||
['explicit_mentions', DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, DI::config()->get('feature_lock', 'explicit_mentions', false)],
|
||||
['add_abstract', DI::l10n()->t('Add an abstract from ActivityPub content warnings'), DI::l10n()->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, DI::config()->get('feature_lock', 'add_abstract', false)],
|
||||
[self::EXPLICIT_MENTIONS, DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, DI::config()->get('feature_lock', Feature::EXPLICIT_MENTIONS, false)],
|
||||
[self::ADD_ABSTRACT, DI::l10n()->t('Add an abstract from ActivityPub content warnings'), DI::l10n()->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, DI::config()->get('feature_lock', self::ADD_ABSTRACT, false)],
|
||||
],
|
||||
|
||||
// Item tools
|
||||
'tools' => [
|
||||
DI::l10n()->t('Post/Comment Tools'),
|
||||
['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', 'categories', false)],
|
||||
[self::CATEGORIES, DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', self::CATEGORIES, false)],
|
||||
],
|
||||
|
||||
// Advanced Profile Settings
|
||||
'advanced_profile' => [
|
||||
DI::l10n()->t('Advanced Profile Settings'),
|
||||
['forumlist_profile', DI::l10n()->t('List Groups'), DI::l10n()->t('Show visitors public groups at the Advanced Profile Page'), false, DI::config()->get('feature_lock', 'forumlist_profile', false)],
|
||||
['tagadelic', DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, DI::config()->get('feature_lock', 'tagadelic', false)],
|
||||
['profile_membersince', DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, DI::config()->get('feature_lock', 'profile_membersince', false)],
|
||||
[self::GROUPS, DI::l10n()->t('List Groups'), DI::l10n()->t('Show visitors public groups at the Advanced Profile Page'), false, DI::config()->get('feature_lock', 'forumlist_profile', false)],
|
||||
[self::TAGCLOUD, DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, DI::config()->get('feature_lock', self::TAGCLOUD, false)],
|
||||
[self::MEMBER_SINCE, DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, DI::config()->get('feature_lock', self::MEMBER_SINCE, false)],
|
||||
],
|
||||
|
||||
//Advanced Calendar Settings
|
||||
'advanced_calendar' => [
|
||||
DI::l10n()->t('Advanced Calendar Settings'),
|
||||
['public_calendar', DI::l10n()->t('Allow anonymous access to your calendar'), DI::l10n()->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, DI::config()->get('feature_lock', 'public_calendar', false)],
|
||||
[self::PUBLIC_CALENDAR, DI::l10n()->t('Allow anonymous access to your calendar'), DI::l10n()->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, DI::config()->get('feature_lock', self::PUBLIC_CALENDAR, false)],
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -172,8 +172,7 @@ class GroupManager
|
|||
*/
|
||||
public static function profileAdvanced($uid)
|
||||
{
|
||||
$profile = intval(Feature::isEnabled($uid, 'forumlist_profile'));
|
||||
if (!$profile) {
|
||||
if (!Feature::isEnabled($uid, Feature::GROUPS)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -1045,7 +1045,7 @@ class Item
|
|||
|
||||
public function postProcessPost(array $post, array $recipients = [])
|
||||
{
|
||||
if (!\Friendica\Content\Feature::isEnabled($post['uid'], 'explicit_mentions') && ($post['gravity'] == ItemModel::GRAVITY_COMMENT)) {
|
||||
if (!Feature::isEnabled($post['uid'], Feature::EXPLICIT_MENTIONS) && ($post['gravity'] == ItemModel::GRAVITY_COMMENT)) {
|
||||
Tag::createImplicitMentions($post['uri-id'], $post['thr-parent-id']);
|
||||
}
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ class Widget
|
|||
*/
|
||||
public static function categories(int $uid, string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!Feature::isEnabled($uid, 'categories')) {
|
||||
if (!Feature::isEnabled($uid, Feature::CATEGORIES)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ class Widget
|
|||
return '';
|
||||
}
|
||||
|
||||
if (Feature::isEnabled($uid, 'tagadelic')) {
|
||||
if (Feature::isEnabled($uid, Feature::TAGCLOUD)) {
|
||||
$owner_id = Contact::getPublicIdByUserId($uid);
|
||||
|
||||
if (!$owner_id) {
|
||||
|
@ -598,4 +598,4 @@ class Widget
|
|||
$channelname
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -516,7 +516,7 @@ class Event
|
|||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
}
|
||||
|
||||
if (!DI::userSession()->isAuthenticated() && !Feature::isEnabled($owner['uid'], 'public_calendar')) {
|
||||
if (!DI::userSession()->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class BaseProfile extends BaseModule
|
|||
];
|
||||
} else {
|
||||
$owner = User::getByNickname($nickname, ['uid']);
|
||||
if(DI::userSession()->isAuthenticated() || $owner && Feature::isEnabled($owner['uid'], 'public_calendar')) {
|
||||
if(DI::userSession()->isAuthenticated() || $owner && Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Calendar'),
|
||||
'url' => DI::baseUrl() . '/calendar/show/' . $nickname,
|
||||
|
|
|
@ -78,7 +78,7 @@ class Export extends BaseModule
|
|||
$this->baseUrl->redirect('profile/' . $nickname . '/restricted');
|
||||
}
|
||||
|
||||
if (!$this->session->isAuthenticated() && !Feature::isEnabled($owner['uid'], 'public_calendar')) {
|
||||
if (!$this->session->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
|
||||
$this->sysMessages->addNotice($this->t('Permission denied.'));
|
||||
$this->baseUrl->redirect('profile/' . $nickname);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Show extends BaseModule
|
|||
$this->baseUrl->redirect('profile/' . $nickname . '/restricted');
|
||||
}
|
||||
|
||||
if (!$this->session->isAuthenticated() && !Feature::isEnabled($owner['uid'], 'public_calendar')) {
|
||||
if (!$this->session->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
|
||||
$this->sysMessages->addNotice($this->t('Permission denied.'));
|
||||
return Login::form();
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ class Channel extends Timeline
|
|||
$this->page['aside'] .= $this->getNoSharerWidget('channel');
|
||||
}
|
||||
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), Feature::TRENDING_TAGS)) {
|
||||
$this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class Community extends Timeline
|
|||
$this->page['aside'] .= $this->getNoSharerWidget('community');
|
||||
}
|
||||
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), Feature::TRENDING_TAGS)) {
|
||||
$this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class Network extends Timeline
|
|||
$this->page['aside'] .= $this->getNoSharerWidget('network');
|
||||
}
|
||||
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
|
||||
if (Feature::isEnabled($this->session->getLocalUserId(), Feature::TRENDING_TAGS)) {
|
||||
$this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ class Compose extends BaseModule
|
|||
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
|
||||
'wait' => $this->l10n->t('Please wait'),
|
||||
'placeholdertitle' => $this->l10n->t('Set title'),
|
||||
'placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
|
||||
'placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(), Feature::CATEGORIES) ? $this->l10n->t('Categories (comma-separated list)') : '',
|
||||
'always_open_compose' => $this->pConfig->get(DI::userSession()->getLocalUserId(), 'frio', 'always_open_compose',
|
||||
$this->config->get('frio', 'always_open_compose', false)) ? '' :
|
||||
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
|
||||
|
|
|
@ -156,7 +156,7 @@ class Edit extends BaseModule
|
|||
'$title' => $item['title'],
|
||||
'$placeholdertitle' => $this->t('Set title'),
|
||||
'$category' => Post\Category::getCSVByURIId($item['uri-id'], $this->session->getLocalUserId(), Post\Category::CATEGORY),
|
||||
'$placeholdercategory' => (Feature::isEnabled($this->session->getLocalUserId(), 'categories') ? $this->t("Categories \x28comma-separated list\x29") : ''),
|
||||
'$placeholdercategory' => (Feature::isEnabled($this->session->getLocalUserId(), Feature::CATEGORIES) ? $this->t("Categories \x28comma-separated list\x29") : ''),
|
||||
'$emtitle' => $this->t('Example: bob@example.com, mary@example.com'),
|
||||
'$lockstate' => $lockstate,
|
||||
'$acl' => '',
|
||||
|
|
|
@ -240,7 +240,7 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
|
||||
// Create item container
|
||||
$lat = $lon = null;
|
||||
if (!empty($exif['GPS']) && Feature::isEnabled($this->owner['uid'], 'photo_location')) {
|
||||
if (!empty($exif['GPS']) && Feature::isEnabled($this->owner['uid'], Feature::PHOTO_LOCATION)) {
|
||||
$lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
|
||||
$lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ class Profile extends BaseProfile
|
|||
|
||||
$basic_fields += self::buildField('fullname', $this->t('Full Name:'), $profile['name']);
|
||||
|
||||
if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
|
||||
if (Feature::isEnabled($profile['uid'], Feature::MEMBER_SINCE)) {
|
||||
$basic_fields += self::buildField(
|
||||
'membersince',
|
||||
$this->t('Member since:'),
|
||||
|
@ -255,7 +255,7 @@ class Profile extends BaseProfile
|
|||
}
|
||||
|
||||
//show subscribed group if it is enabled in the usersettings
|
||||
if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
|
||||
if (Feature::isEnabled($profile['uid'], Feature::GROUPS)) {
|
||||
$custom_fields += self::buildField(
|
||||
'group_list',
|
||||
$this->t('Groups:'),
|
||||
|
|
|
@ -1079,13 +1079,13 @@ class Post
|
|||
$owner = User::getOwnerDataById($a->getLoggedInUserId());
|
||||
$item = $this->getData();
|
||||
|
||||
if (!empty($item['content-warning']) && Feature::isEnabled(DI::userSession()->getLocalUserId(), 'add_abstract')) {
|
||||
if (!empty($item['content-warning']) && Feature::isEnabled(DI::userSession()->getLocalUserId(), Feature::ADD_ABSTRACT)) {
|
||||
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
|
||||
} else {
|
||||
$text = '';
|
||||
}
|
||||
|
||||
if (!Feature::isEnabled(DI::userSession()->getLocalUserId(), 'explicit_mentions')) {
|
||||
if (!Feature::isEnabled(DI::userSession()->getLocalUserId(), Feature::EXPLICIT_MENTIONS)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
|
|
@ -1836,7 +1836,7 @@ class Transmitter
|
|||
* }
|
||||
*/
|
||||
|
||||
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) {
|
||||
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], Feature::EXPLICIT_MENTIONS)) {
|
||||
$body = self::prependMentions($body, $item['uri-id'], $item['author-link']);
|
||||
}
|
||||
|
||||
|
|
|
@ -3618,7 +3618,7 @@ class Diaspora
|
|||
if (
|
||||
$item['author-id'] != $thread_parent_item['author-id']
|
||||
&& ($thread_parent_item['gravity'] != Item::GRAVITY_PARENT)
|
||||
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
|
||||
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], Feature::EXPLICIT_MENTIONS))
|
||||
&& !DI::config()->get('system', 'disable_implicit_mentions')
|
||||
) {
|
||||
$body = self::prependParentAuthorMention($body, $thread_parent_item['author-link']);
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue