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