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