3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Content;
24 use Friendica\Core\Hook;
30 * check if feature is enabled
32 * @param integer $uid user id
33 * @param string $feature feature
35 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
37 public static function isEnabled(int $uid, $feature)
39 $x = DI::config()->get('feature_lock', $feature, false);
42 $x = DI::pConfig()->get($uid, 'feature', $feature, false);
46 $x = DI::config()->get('feature', $feature, false);
50 $x = self::getDefault($feature);
53 $arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $x];
54 Hook::callAll('isEnabled', $arr);
55 return($arr['enabled']);
59 * check if feature is enabled or disabled by default
61 * @param string $feature feature
63 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
65 private static function getDefault($feature)
68 foreach ($f as $cat) {
69 foreach ($cat as $feat) {
70 if (is_array($feat) && $feat[0] === $feature) {
79 * Get a list of all available features
81 * The array includes the setting group, the setting name,
82 * explanations for the setting and if it's enabled or disabled
85 * @param bool $filtered True removes any locked features
88 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
90 public static function get($filtered = true)
96 DI::l10n()->t('General Features'),
97 //array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')),
98 ['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)],
99 ['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)],
104 DI::l10n()->t('Post Composition Features'),
105 ['aclautomention', DI::l10n()->t('Auto-mention Forums'), DI::l10n()->t('Add/remove mention when a forum page is selected/deselected in ACL window.'), false, DI::config()->get('feature_lock', 'aclautomention', false)],
106 ['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)],
107 ['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)],
112 DI::l10n()->t('Post/Comment Tools'),
113 ['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', 'categories', false)],
116 // Advanced Profile Settings
117 'advanced_profile' => [
118 DI::l10n()->t('Advanced Profile Settings'),
119 ['forumlist_profile', DI::l10n()->t('List Forums'), DI::l10n()->t('Show visitors public community forums at the Advanced Profile Page'), false, DI::config()->get('feature_lock', 'forumlist_profile', false)],
120 ['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)],
121 ['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)],
124 //Advanced Calendar Settings
125 'advanced_calendar' => [
126 DI::l10n()->t('Advanced Calendar Settings'),
127 ['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)],
131 // removed any locked features and remove the entire category if this makes it empty
134 foreach ($arr as $k => $x) {
136 $kquantity = count($arr[$k]);
137 for ($y = 0; $y < $kquantity; $y ++) {
138 if (is_array($arr[$k][$y])) {
139 if ($arr[$k][$y][4] === false) {
152 Hook::callAll('get', $arr);