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 
78 elgg_save_config('user_joined_river', get_input('user_joined_river') === 'on');
79 elgg_save_config('can_change_username', get_input('can_change_username') === 'on');
80 
81 if (!elgg()->config->hasInitialValue('simplecache_enabled')) {
82  if (get_input('simplecache_enabled') === 'on') {
84  } else {
86  }
87 }
88 
89 if (get_input('cache_symlink_enabled') === 'on') {
90  if (!_elgg_symlink_cache()) {
91  elgg_register_error_message(elgg_echo('installation:cache_symlink:error'));
92  }
93 }
94 
95 elgg_save_config('simplecache_minify_js', get_input('simplecache_minify_js') === 'on');
96 elgg_save_config('simplecache_minify_css', get_input('simplecache_minify_css') === 'on');
97 
98 if (get_input('system_cache_enabled') === 'on') {
100 } else {
102 }
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_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:78
$friendly_time_number_of_days
Definition: settings.php:128
$comments_max_depth
Definition: settings.php:66
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.
_elgg_symlink_cache()
Symlinks /cache directory to views simplecache directory.
Definition: cache.php:244
$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: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
$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:183
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:52
elgg_remove_config(string $name)
Removes a config setting.
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:98
$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:173
elgg_enable_simplecache()
Enables the simple cache.
Definition: cache.php:160
var elgg
Definition: elgglib.js:4