Passed
Branch master (739723)
by Ismayil
05:58
created

actions/admin/site/update_basic.php (1 issue)

Severity
1
<?php
2
/**
3
 * Updates the basic settings for the primary site object.
4
 *
5
 * Basic site settings are saved as metadata on the site object,
6
 * with the exception of the default language, which is saved in
7
 * the config table.
8
 *
9
 * @package Elgg.Core
10
 * @subpackage Administration.Site
11
 */
12
13
$site = elgg_get_site_entity();
14
if (!$site) {
0 ignored issues
show
The condition ! $site can never be false.
Loading history...
15
	throw new InstallationException("The system is missing an ElggSite entity!");
16
}
17
if (!($site instanceof ElggSite)) {
18
	throw new InstallationException("Passing a non-ElggSite to an ElggSite constructor!");
19
}
20
21
$site->description = get_input('sitedescription');
22
$site->name = strip_tags(get_input('sitename'));
23
$site->email = get_input('siteemail');
24
$site->save();
25
26
// allow new user registration?
27
$allow_registration = ('on' === get_input('allow_registration', false));
28
elgg_save_config('allow_registration', $allow_registration);
29
30
// setup walled garden
31
$walled_garden = ('on' === get_input('walled_garden', false));
32
elgg_save_config('walled_garden', $walled_garden);
33
34
elgg_save_config('language', get_input('language'));
35
36
$default_limit = (int) get_input('default_limit');
37
if ($default_limit < 1) {
38
	return elgg_error_response(elgg_echo('admin:configuration:default_limit'));
39
}
40
41
elgg_save_config('default_limit', $default_limit);
42
43
$forward = elgg_normalize_site_url(get_input('after_save')) ?: REFERER;
44
return elgg_ok_response('', elgg_echo('admin:configuration:success'), $forward);
45