Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 lines
5.8 KiB

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