]> git.mxchange.org Git - friendica.git/blob - include/features.php
Merge pull request #3279 from Hypolite/improvement/add-composer
[friendica.git] / include / features.php
1 <?php
2
3 /**
4  * @file include/features.php
5  * @brief Features management
6  */
7
8 /**
9  * @brief check if feature is enabled
10  *
11  * @return boolean
12  */
13 function feature_enabled($uid, $feature) {
14         $x = get_config('feature_lock', $feature);
15
16         if ($x === false) {
17                 $x = get_pconfig($uid, 'feature', $feature);
18                 if ($x === false) {
19                         $x = get_config('feature', $feature);
20                         if ($x === false) {
21                                 $x = get_feature_default($feature);
22                         }
23                 }
24         }
25
26         $arr = array('uid' => $uid, 'feature' => $feature, 'enabled' => $x);
27         call_hooks('feature_enabled',$arr);
28         return($arr['enabled']);
29 }
30
31 /**
32  * @brief check if feature is enabled or disabled by default
33  *
34  * @param string $feature
35  * @return boolean
36  */
37 function get_feature_default($feature) {
38         $f = get_features();
39         foreach($f as $cat) {
40                 foreach($cat as $feat) {
41                         if(is_array($feat) && $feat[0] === $feature)
42                                 return $feat[3];
43                 }
44         }
45         return false;
46 }
47
48 /**
49  * @brief Get a list of all available features
50  *
51  * The array includes the setting group, the setting name,
52  * explainations for the setting and if it's enabled or disabled
53  * by default
54  *
55  * @param bool $filtered True removes any locked features
56  *
57  * @return array
58  */
59 function get_features($filtered = true) {
60
61         $arr = array(
62
63                 // General
64                 'general' => array(
65                         t('General Features'),
66                         //array('expire',         t('Content Expiration'),              t('Remove old posts/comments after a period of time')),
67                         array('multi_profiles', t('Multiple Profiles'),                 t('Ability to create multiple profiles'), false, get_config('feature_lock','multi_profiles')),
68                         array('photo_location', t('Photo Location'),                    t('Photo metadata is normally stripped. This extracts the location (if present) prior to stripping metadata and links it to a map.'), false, get_config('feature_lock','photo_location')),
69                         array('export_calendar', t('Export Public Calendar'),           t('Ability for visitors to download the public calendar'), false, get_config('feature_lock','export_calendar')),
70                 ),
71
72                 // Post composition
73                 'composition' => array(
74                         t('Post Composition Features'),
75                         array('preview',        t('Post Preview'),                      t('Allow previewing posts and comments before publishing them'), false, get_config('feature_lock','preview')),
76                         array('aclautomention', t('Auto-mention Forums'),               t('Add/remove mention when a forum page is selected/deselected in ACL window.'), false, get_config('feature_lock','aclautomention')),
77                 ),
78
79                 // Network sidebar widgets
80                 'widgets' => array(
81                         t('Network Sidebar Widgets'),
82                         array('archives',       t('Search by Date'),                    t('Ability to select posts by date ranges'), false, get_config('feature_lock','archives')),
83                         array('forumlist_widget', t('List Forums'),                     t('Enable widget to display the forums your are connected with'), true, get_config('feature_lock','forumlist_widget')),
84                         array('groups',         t('Group Filter'),                      t('Enable widget to display Network posts only from selected group'), false, get_config('feature_lock','groups')),
85                         array('networks',       t('Network Filter'),                    t('Enable widget to display Network posts only from selected network'), false, get_config('feature_lock','networks')),
86                         array('savedsearch',    t('Saved Searches'),                    t('Save search terms for re-use'), false, get_config('feature_lock','savedsearch')),
87                 ),
88
89                 // Network tabs
90                 'net_tabs' => array(
91                         t('Network Tabs'),
92                         array('personal_tab',   t('Network Personal Tab'),              t('Enable tab to display only Network posts that you\'ve interacted on'), false, get_config('feature_lock','personal_tab')),
93                         array('new_tab',        t('Network New Tab'),                   t('Enable tab to display only new Network posts (from the last 12 hours)'), false, get_config('feature_lock','new_tab')),
94                         array('link_tab',       t('Network Shared Links Tab'),          t('Enable tab to display only Network posts with links in them'), false, get_config('feature_lock','link_tab')),
95                 ),
96
97                 // Item tools
98                 'tools' => array(
99                         t('Post/Comment Tools'),
100                         array('multi_delete',   t('Multiple Deletion'),                 t('Select and delete multiple posts/comments at once'), false, get_config('feature_lock','multi_delete')),
101                         array('edit_posts',     t('Edit Sent Posts'),                   t('Edit and correct posts and comments after sending'), false, get_config('feature_lock','edit_posts')),
102                         array('commtag',        t('Tagging'),                           t('Ability to tag existing posts'), false, get_config('feature_lock','commtag')),
103                         array('categories',     t('Post Categories'),                   t('Add categories to your posts'), false, get_config('feature_lock','categories')),
104                         array('filing',         t('Saved Folders'),                     t('Ability to file posts under folders'), false, get_config('feature_lock','filing')),
105                         array('dislike',        t('Dislike Posts'),                     t('Ability to dislike posts/comments'), false, get_config('feature_lock','dislike')),
106                         array('star_posts',     t('Star Posts'),                        t('Ability to mark special posts with a star indicator'), false, get_config('feature_lock','star_posts')),
107                         array('ignore_posts',   t('Mute Post Notifications'),           t('Ability to mute notifications for a thread'), false, get_config('feature_lock','ignore_posts')),
108                 ),
109
110                 // Advanced Profile Settings
111                 'advanced_profile' => array(
112                         t('Advanced Profile Settings'),
113                         array('forumlist_profile', t('List Forums'),                    t('Show visitors public community forums at the Advanced Profile Page'), false, get_config('feature_lock','forumlist_profile')),
114                 ),
115         );
116
117         // removed any locked features and remove the entire category if this makes it empty
118
119         if($filtered) {
120                 foreach($arr as $k => $x) {
121                         $has_items = false;
122                         $kquantity = count($arr[$k]);
123                         for($y = 0; $y < $kquantity; $y ++) {
124                                 if(is_array($arr[$k][$y])) {
125                                         if($arr[$k][$y][4] === false) {
126                                                 $has_items = true;
127                                         }
128                                         else {
129                                                 unset($arr[$k][$y]);
130                                         }
131                                 }
132                         }
133                         if(! $has_items) {
134                                 unset($arr[$k]);
135                         }
136                 }
137         }
138
139         call_hooks('get_features',$arr);
140         return $arr;
141 }