Elgg  Version master
settings.php
Go to the documentation of this file.
1 <?php
11 
13 
14 $site->description = get_input('sitedescription');
15 $site->name = strip_tags(get_input('sitename', ''));
16 $site->email = get_input('siteemail');
17 
18 if (!$site->save()) {
19  return elgg_error_response(elgg_echo('admin:configuration:fail'));
20 }
21 
22 // allow new user registration?
23 $allow_registration = (get_input('allow_registration', false) === 'on');
24 elgg_save_config('allow_registration', $allow_registration);
25 
26 // require admin validation for new users?
27 $require_admin_validation = (get_input('require_admin_validation', false) === 'on');
28 elgg_save_config('require_admin_validation', $require_admin_validation);
29 
30 // notify admins about pending validation
31 $admin_validation_notification = get_input('admin_validation_notification');
33  elgg_remove_config('admin_validation_notification');
34 } else {
35  elgg_save_config('admin_validation_notification', $admin_validation_notification);
36 }
37 
38 // remove unvalidated users after x days
39 $remove_unvalidated_users_days = (int) get_input('remove_unvalidated_users_days');
41  elgg_remove_config('remove_unvalidated_users_days');
42 } else {
43  elgg_save_config('remove_unvalidated_users_days', $remove_unvalidated_users_days);
44 }
45 
46 // setup walled garden
47 $walled_garden = (get_input('walled_garden', false) === 'on');
48 elgg_save_config('walled_garden', $walled_garden);
49 
50 elgg_save_config('language', get_input('language'));
51 
52 $allowed_languages = (array) get_input('allowed_languages', []);
53 $allowed_languages[] = 'en'; // always add English (as it's the ultimate fallback)
54 $allowed_languages[] = elgg_get_config('language'); // add default site language
55 elgg_save_config('allowed_languages', implode(',', array_unique($allowed_languages)));
56 
57 elgg_save_config('who_can_change_language', get_input('who_can_change_language'));
58 
59 $default_limit = (int) get_input('default_limit');
60 if ($default_limit < 1) {
61  return elgg_error_response(elgg_echo('admin:configuration:default_limit'));
62 }
63 
64 elgg_save_config('default_limit', $default_limit);
65 
66 $comments_max_depth = (int) get_input('comments_max_depth');
67 if (!in_array($comments_max_depth, [0,2,3,4])) {
69 }
70 
71 elgg_save_config('comments_max_depth', $comments_max_depth);
72 elgg_save_config('comment_box_collapses', (bool) get_input('comment_box_collapses'));
73 elgg_save_config('comments_group_only', (bool) get_input('comments_group_only'));
74 elgg_save_config('comments_latest_first', (bool) get_input('comments_latest_first'));
75 elgg_save_config('comments_per_page', (int) get_input('comments_per_page'));
76 elgg_save_config('pagination_behaviour', get_input('pagination_behaviour', 'ajax-replace'));
77 elgg_save_config('mentions_display_format', get_input('mentions_display_format'));
78 
79 $trash_retention = (int) get_input('trash_retention', 30);
80 if ($trash_retention < 0) {
81  $trash_retention = 30;
82 }
83 
84 elgg_save_config('trash_retention', $trash_retention);
85 elgg_save_config('trash_enabled', (bool) get_input('trash_enabled'));
86 
87 elgg_save_config('user_joined_river', get_input('user_joined_river') === 'on');
88 elgg_save_config('can_change_username', get_input('can_change_username') === 'on');
89 
90 if (!elgg()->config->hasInitialValue('simplecache_enabled')) {
91  if (get_input('simplecache_enabled') === 'on') {
93  } else {
95  }
96 }
97 
98 if (get_input('cache_symlink_enabled') === 'on') {
99  if (!_elgg_symlink_cache()) {
100  elgg_register_error_message(elgg_echo('installation:cache_symlink:error'));
101  }
102 }
103 
104 elgg_save_config('simplecache_minify_js', get_input('simplecache_minify_js') === 'on');
105 elgg_save_config('simplecache_minify_css', get_input('simplecache_minify_css') === 'on');
106 
107 if (get_input('system_cache_enabled') === 'on') {
109 } else {
111 }
112 
113 elgg_save_config('default_access', (int) get_input('default_access', ACCESS_PRIVATE));
114 
115 $user_default_access = (get_input('allow_user_default_access') === 'on');
116 elgg_save_config('allow_user_default_access', $user_default_access);
117 
118 if (!elgg()->config->hasInitialValue('debug')) {
119  $debug = get_input('debug');
120  if ($debug) {
121  elgg_save_config('debug', $debug);
122  } else {
123  elgg_remove_config('debug');
124  }
125 }
126 
127 $remove_branding = (get_input('remove_branding', false) === 'on');
128 elgg_save_config('remove_branding', $remove_branding);
129 
130 elgg_save_config('email_html_part', (bool) get_input('email_html_part'));
131 elgg_save_config('email_html_part_images', get_input('email_html_part_images'));
132 elgg_save_config('enable_delayed_email', (bool) get_input('enable_delayed_email'));
133 
134 $disable_rss = (get_input('disable_rss', false) === 'on');
135 elgg_save_config('disable_rss', $disable_rss);
136 
137 $friendly_time_number_of_days = get_input('friendly_time_number_of_days', 30);
138 if ($friendly_time_number_of_days === '') {
140 }
141 
142 elgg_save_config('friendly_time_number_of_days', (int) $friendly_time_number_of_days);
143 elgg_save_config('message_delay', (int) get_input('message_delay', 6));
144 
146 
147 return elgg_ok_response('', elgg_echo('admin:configuration:success'));
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:78
elgg
Definition: install.js:27
$friendly_time_number_of_days
Definition: settings.php:137
$comments_max_depth
Definition: settings.php:66
$trash_retention
Definition: settings.php:79
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
if(!elgg() ->config->hasInitialValue('debug')) $remove_branding
Definition: settings.php:127
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
_elgg_symlink_cache()
Symlinks /cache directory to views simplecache directory.
Definition: cache.php:235
$require_admin_validation
Definition: settings.php:27
$remove_unvalidated_users_days
Definition: settings.php:39
elgg_disable_system_cache()
Disables the system disk cache.
Definition: cache.php:90
$user_default_access
Definition: settings.php:115
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(!$site->save()) $allow_registration
Definition: settings.php:23
$admin_validation_notification
Definition: settings.php:31
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_invalidate_caches()
Invalidate all the registered caches.
Definition: cache.php:174
Updates the basic settings for the primary site object.
elgg_error_response(string|array $message= '', string $forward_url=REFERRER, int $status_code=ELGG_HTTP_BAD_REQUEST)
Prepare an error response to be returned by a page or an action handler.
const ACCESS_PRIVATE
Definition: constants.php:10
elgg_save_config(string $name, $value)
Save a configuration setting.
$disable_rss
Definition: settings.php:134
$allowed_languages
Definition: settings.php:52
elgg_remove_config(string $name)
Removes a config setting.
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:101
$site
Definition: settings.php:12
elgg_register_error_message(string|array $options)
Registers a error system message.
Definition: elgglib.php:62
$default_limit
Definition: settings.php:59
$walled_garden
Definition: settings.php:47
elgg_disable_simplecache()
Disables the simple cache.
Definition: cache.php:164
elgg_enable_simplecache()
Enables the simple cache.
Definition: cache.php:151