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 elgg_save_config('admin_validation_notification', (bool) get_input('admin_validation_notification'));
32 
33 // remove unvalidated users after x days
34 $remove_unvalidated_users_days = (int) get_input('remove_unvalidated_users_days');
36  elgg_remove_config('remove_unvalidated_users_days');
37 } else {
38  elgg_save_config('remove_unvalidated_users_days', $remove_unvalidated_users_days);
39 }
40 
41 // setup walled garden
42 $walled_garden = (get_input('walled_garden', false) === 'on');
43 elgg_save_config('walled_garden', $walled_garden);
44 
45 elgg_save_config('language', get_input('language'));
46 
47 $allowed_languages = (array) get_input('allowed_languages', []);
48 $allowed_languages[] = 'en'; // always add English (as it's the ultimate fallback)
49 $allowed_languages[] = elgg_get_config('language'); // add default site language
50 elgg_save_config('allowed_languages', implode(',', array_unique($allowed_languages)));
51 
52 elgg_save_config('who_can_change_language', get_input('who_can_change_language'));
53 
54 $default_limit = (int) get_input('default_limit');
55 if ($default_limit < 1) {
56  return elgg_error_response(elgg_echo('admin:configuration:default_limit'));
57 }
58 
59 elgg_save_config('default_limit', $default_limit);
60 
61 $comments_max_depth = (int) get_input('comments_max_depth');
62 if (!in_array($comments_max_depth, [0,2,3,4])) {
64 }
65 
66 elgg_save_config('comments_max_depth', $comments_max_depth);
67 elgg_save_config('comment_box_collapses', (bool) get_input('comment_box_collapses'));
68 elgg_save_config('comments_group_only', (bool) get_input('comments_group_only'));
69 elgg_save_config('comments_latest_first', (bool) get_input('comments_latest_first'));
70 elgg_save_config('comments_per_page', (int) get_input('comments_per_page'));
71 elgg_save_config('pagination_behaviour', get_input('pagination_behaviour', 'ajax-replace'));
72 elgg_save_config('mentions_display_format', get_input('mentions_display_format'));
73 
74 $trash_retention = (int) get_input('trash_retention', 30);
75 if ($trash_retention < 0) {
76  $trash_retention = 30;
77 }
78 
79 elgg_save_config('trash_retention', $trash_retention);
80 elgg_save_config('trash_enabled', (bool) get_input('trash_enabled'));
81 
82 elgg_save_config('user_joined_river', get_input('user_joined_river') === 'on');
83 elgg_save_config('can_change_username', get_input('can_change_username') === 'on');
84 
85 if (!elgg()->config->hasInitialValue('simplecache_enabled')) {
86  if (get_input('simplecache_enabled') === 'on') {
87  _elgg_services()->simpleCache->enable();
88  } else {
89  _elgg_services()->simpleCache->disable();
90  }
91 }
92 
93 if (get_input('cache_symlink_enabled') === 'on') {
94  if (!_elgg_services()->simpleCache->createSymbolicLink()) {
95  elgg_register_error_message(elgg_echo('installation:cache_symlink:error'));
96  }
97 }
98 
99 elgg_save_config('simplecache_minify_js', get_input('simplecache_minify_js') === 'on');
100 elgg_save_config('simplecache_minify_css', get_input('simplecache_minify_css') === 'on');
101 
102 elgg_save_config('system_cache_enabled', get_input('system_cache_enabled') === 'on');
103 
104 elgg_save_config('default_access', (int) get_input('default_access', ACCESS_PRIVATE));
105 
106 $user_default_access = (get_input('allow_user_default_access') === 'on');
107 elgg_save_config('allow_user_default_access', $user_default_access);
108 
109 if (!elgg()->config->hasInitialValue('debug')) {
110  $debug = get_input('debug');
111  if ($debug) {
112  elgg_save_config('debug', $debug);
113  } else {
114  elgg_remove_config('debug');
115  }
116 }
117 
118 $remove_branding = (get_input('remove_branding', false) === 'on');
119 elgg_save_config('remove_branding', $remove_branding);
120 
121 elgg_save_config('email_html_part', (bool) get_input('email_html_part'));
122 elgg_save_config('email_html_part_images', get_input('email_html_part_images'));
123 elgg_save_config('enable_delayed_email', (bool) get_input('enable_delayed_email'));
124 
125 $disable_rss = (get_input('disable_rss', false) === 'on');
126 elgg_save_config('disable_rss', $disable_rss);
127 
128 $friendly_time_number_of_days = get_input('friendly_time_number_of_days', 30);
129 if ($friendly_time_number_of_days === '') {
131 }
132 
133 elgg_save_config('friendly_time_number_of_days', (int) $friendly_time_number_of_days);
134 elgg_save_config('message_delay', (int) get_input('message_delay', 6));
135 
137 
138 return elgg_ok_response('', elgg_echo('admin:configuration:success'));
elgg
Definition: install.js:27
$friendly_time_number_of_days
Definition: settings.php:128
$comments_max_depth
Definition: settings.php:61
$trash_retention
Definition: settings.php:74
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
if(!elgg() ->config->hasInitialValue('debug')) $remove_branding
Definition: settings.php:118
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.
$require_admin_validation
Definition: settings.php:27
$remove_unvalidated_users_days
Definition: settings.php:34
$user_default_access
Definition: settings.php:106
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
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:88
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:125
$allowed_languages
Definition: settings.php:47
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:54
$walled_garden
Definition: settings.php:42
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351