3 * @copyright Copyright (C) 2010-2022, 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 * explainations 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)],
111 DI::l10n()->t('Post/Comment Tools'),
112 ['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', 'categories', false)],
115 // Advanced Profile Settings
116 'advanced_profile' => [
117 DI::l10n()->t('Advanced Profile Settings'),
118 ['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)],
119 ['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)],
120 ['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 // removed any locked features and remove the entire category if this makes it empty
127 foreach ($arr as $k => $x) {
129 $kquantity = count($arr[$k]);
130 for ($y = 0; $y < $kquantity; $y ++) {
131 if (is_array($arr[$k][$y])) {
132 if ($arr[$k][$y][4] === false) {
145 Hook::callAll('get', $arr);