Passed
Push — master ( f13f78...5c1b24 )
by Ismayil
04:22
created

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

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Updates the advanced settings for the primary site object.
4
 *
5
 * Options are saved among metadata on the site object
6
 * and entries in the config table.
7
 *
8
 * @package Elgg.Core
9
 * @subpackage Administration.Site
10
 */
11
12
$site = elgg_get_site_entity();
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
if (!_elgg_config()->hasInitialValue('simplecache_enabled')) {
21
	if ('on' === get_input('simplecache_enabled')) {
22
		elgg_enable_simplecache();
23
	} else {
24
		elgg_disable_simplecache();
25
	}
26
}
27
28
if ('on' === get_input('cache_symlink_enabled')) {
29
	if (!_elgg_symlink_cache()) {
30
		register_error(elgg_echo('installation:cache_symlink:error'));
31
	}
32
}
33
34
elgg_save_config('simplecache_minify_js', 'on' === get_input('simplecache_minify_js'));
35
elgg_save_config('simplecache_minify_css', 'on' === get_input('simplecache_minify_css'));
36
37
if ('on' === get_input('system_cache_enabled')) {
38
	elgg_enable_system_cache();
39
} else {
40
	elgg_disable_system_cache();
41
}
42
43
elgg_save_config('default_access', (int) get_input('default_access', ACCESS_PRIVATE));
44
45
$user_default_access = ('on' === get_input('allow_user_default_access'));
46
elgg_save_config('allow_user_default_access', $user_default_access);
47
48 View Code Duplication
if (!_elgg_config()->hasInitialValue('debug')) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
	$debug = get_input('debug');
50
	if ($debug) {
51
		elgg_save_config('debug', $debug);
52
	} else {
53
		elgg_remove_config('debug');
54
	}
55
}
56
57
$regenerate_site_secret = get_input('regenerate_site_secret', false);
58
if ($regenerate_site_secret) {
59
	// if you cancel this even you should present a message to the user
60
	if (elgg_trigger_before_event('regenerate_site_secret', 'system')) {
61
		init_site_secret();
62
		elgg_reset_system_cache();
63
		elgg_trigger_after_event('regenerate_site_secret', 'system');
64
65
		system_message(elgg_echo('admin:site:secret_regenerated'));
66
67
		elgg_delete_admin_notice('weak_site_key');
68
	}
69
}
70
71
if (!$site->save()) {
72
	return elgg_error_response(elgg_echo('admin:configuration:fail'));
73
}
74
75
return elgg_ok_response('', elgg_echo('admin:configuration:success'));
76