]> git.mxchange.org Git - friendica.git/blob - include/features.php
correction of typos
[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                         array('export_calendar', t('Export Public Calendar'),           t('Ability for visitors to download the public calendar'), false, get_config('feature_lock','export_calendar')),
68                 ),
69
70                 // Post composition
71                 'composition' => array(
72                         t('Post Composition Features'),
73                         array('richtext',       t('Richtext Editor'),                   t('Enable richtext editor'), false, get_config('feature_lock','richtext')),
74                         array('preview',        t('Post Preview'),                      t('Allow previewing posts and comments before publishing them'), false, get_config('feature_lock','preview')),
75                         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')),
76                 ),
77
78                 // Network sidebar widgets
79                 'widgets' => array(
80                         t('Network Sidebar Widgets'),
81                         array('archives',       t('Search by Date'),                    t('Ability to select posts by date ranges'), false, get_config('feature_lock','archives')),
82                         array('forumlist_widget', t('List Forums'),                     t('Enable widget to display the forums your are connected with'), true, get_config('feature_lock','forumlist_widget')),
83                         array('groups',         t('Group Filter'),                      t('Enable widget to display Network posts only from selected group'), false, get_config('feature_lock','groups')),
84                         array('networks',       t('Network Filter'),                    t('Enable widget to display Network posts only from selected network'), false, get_config('feature_lock','networks')),
85                         array('savedsearch',    t('Saved Searches'),                    t('Save search terms for re-use'), false, get_config('feature_lock','savedsearch')),
86                 ),
87
88                 // Network tabs
89                 'net_tabs' => array(
90                         t('Network Tabs'),
91                         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')),
92                         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')),
93                         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')),
94                 ),
95
96                 // Item tools
97                 'tools' => array(
98                         t('Post/Comment Tools'),
99                         array('multi_delete',   t('Multiple Deletion'),                 t('Select and delete multiple posts/comments at once'), false, get_config('feature_lock','multi_delete')),
100                         array('edit_posts',     t('Edit Sent Posts'),                   t('Edit and correct posts and comments after sending'), false, get_config('feature_lock','edit_posts')),
101                         array('commtag',        t('Tagging'),                           t('Ability to tag existing posts'), false, get_config('feature_lock','commtag')),
102                         array('categories',     t('Post Categories'),                   t('Add categories to your posts'), false, get_config('feature_lock','categories')),
103                         array('filing',         t('Saved Folders'),                     t('Ability to file posts under folders'), false, get_config('feature_lock','filing')),
104                         array('dislike',        t('Dislike Posts'),                     t('Ability to dislike posts/comments'), false, get_config('feature_lock','dislike')),
105                         array('star_posts',     t('Star Posts'),                        t('Ability to mark special posts with a star indicator'), false, get_config('feature_lock','star_posts')),
106                         array('ignore_posts',   t('Mute Post Notifications'),           t('Ability to mute notifications for a thread'), false, get_config('feature_lock','ignore_posts')),
107                 ),
108
109                 // Advanced Profile Settings
110                 'advanced_profile' => array(
111                         t('Advanced Profile Settings'),
112                         array('forumlist_profile', t('List Forums'),                    t('Show visitors public community forums at the Advanced Profile Page'), false, get_config('feature_lock','forumlist_profile')),
113                 ),
114         );
115
116         // removed any locked features and remove the entire category if this makes it empty
117
118         if($filtered) {
119                 foreach($arr as $k => $x) {
120                         $has_items = false;
121                         $kquantity = count($arr[$k]);
122                         for($y = 0; $y < $kquantity; $y ++) {
123                                 if(is_array($arr[$k][$y])) {
124                                         if($arr[$k][$y][4] === false) {
125                                                 $has_items = true;
126                                         }
127                                         else {
128                                                 unset($arr[$k][$y]);
129                                         }
130                                 }
131                         }
132                         if(! $has_items) {
133                                 unset($arr[$k]);
134                         }
135                 }
136         }
137
138         call_hooks('get_features',$arr);
139         return $arr;
140 }