3 * @file src/Content/Feature.php
6 namespace Friendica\Content;
8 use Friendica\Core\Hook;
14 * check if feature is enabled
16 * @param integer $uid user id
17 * @param string $feature feature
19 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
21 public static function isEnabled(int $uid, $feature)
23 $x = DI::config()->get('feature_lock', $feature, false);
26 $x = DI::pConfig()->get($uid, 'feature', $feature, false);
30 $x = DI::config()->get('feature', $feature, false);
34 $x = self::getDefault($feature);
37 $arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $x];
38 Hook::callAll('isEnabled', $arr);
39 return($arr['enabled']);
43 * check if feature is enabled or disabled by default
45 * @param string $feature feature
47 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
49 private static function getDefault($feature)
52 foreach ($f as $cat) {
53 foreach ($cat as $feat) {
54 if (is_array($feat) && $feat[0] === $feature) {
63 * Get a list of all available features
65 * The array includes the setting group, the setting name,
66 * explainations for the setting and if it's enabled or disabled
69 * @param bool $filtered True removes any locked features
72 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
74 public static function get($filtered = true)
80 DI::l10n()->t('General Features'),
81 //array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')),
82 ['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)],
83 ['export_calendar', DI::l10n()->t('Export Public Calendar'), DI::l10n()->t('Ability for visitors to download the public calendar'), false, DI::config()->get('feature_lock', 'export_calendar', false)],
84 ['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)],
89 DI::l10n()->t('Post Composition Features'),
90 ['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)],
91 ['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)],
94 // Network sidebar widgets
96 DI::l10n()->t('Network Sidebar'),
97 ['archives', DI::l10n()->t('Archives'), DI::l10n()->t('Ability to select posts by date ranges'), false, DI::config()->get('feature_lock', 'archives', false)],
98 ['networks', DI::l10n()->t('Protocol Filter'), DI::l10n()->t('Enable widget to display Network posts only from selected protocols'), false, DI::config()->get('feature_lock', 'networks', false)],
103 DI::l10n()->t('Network Tabs'),
104 ['new_tab', DI::l10n()->t('Network New Tab'), DI::l10n()->t("Enable tab to display only new Network posts \x28from the last 12 hours\x29"), false, DI::config()->get('feature_lock', 'new_tab', false)],
105 ['link_tab', DI::l10n()->t('Network Shared Links Tab'), DI::l10n()->t('Enable tab to display only Network posts with links in them'), false, DI::config()->get('feature_lock', 'link_tab', false)],
110 DI::l10n()->t('Post/Comment Tools'),
111 ['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', 'categories', false)],
114 // Advanced Profile Settings
115 'advanced_profile' => [
116 DI::l10n()->t('Advanced Profile Settings'),
117 ['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)],
118 ['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)],
119 ['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)],
123 // removed any locked features and remove the entire category if this makes it empty
126 foreach ($arr as $k => $x) {
128 $kquantity = count($arr[$k]);
129 for ($y = 0; $y < $kquantity; $y ++) {
130 if (is_array($arr[$k][$y])) {
131 if ($arr[$k][$y][4] === false) {
144 Hook::callAll('get', $arr);