7 use Elgg\Traits\Loggable;
152 private $initial_values;
157 private $cookies_configured =
false;
162 private $cookies = [];
169 protected $locked_values = [
183 protected $deprecated = [
191 protected $config_defaults = [
192 'admin_validation_notification' =>
false,
193 'allow_phpinfo' =>
false,
194 'authentication_failures_lifetime' => 600,
195 'authentication_failures_limit' => 5,
196 'auto_disable_plugins' =>
true,
197 'batch_run_time_in_secs' => 4,
198 'boot_cache_ttl' => 3600,
199 'can_change_username' =>
false,
200 'class_loader_verify_file_existence' =>
true,
201 'comment_box_collapses' =>
true,
202 'comments_group_only' =>
true,
203 'comments_latest_first' =>
true,
204 'comments_max_depth' => 0,
205 'comments_per_page' => 25,
206 'db_query_cache_limit' => 50,
207 'default_limit' => 10,
208 'elgg_maintenance_mode' =>
false,
209 'email_html_part' =>
true,
210 'email_html_part_images' =>
'no',
211 'email_subject_limit' => 998,
212 'enable_delayed_email' =>
true,
213 'friendly_time_number_of_days' => 30,
215 'topbar' => [
'w' => 16,
'h' => 16,
'square' =>
true,
'upscale' =>
true],
216 'tiny' => [
'w' => 25,
'h' => 25,
'square' =>
true,
'upscale' =>
true],
217 'small' => [
'w' => 40,
'h' => 40,
'square' =>
true,
'upscale' =>
true],
218 'medium' => [
'w' => 100,
'h' => 100,
'square' =>
true,
'upscale' =>
true],
219 'large' => [
'w' => 200,
'h' => 200,
'square' =>
true,
'upscale' =>
true],
220 'master' => [
'w' => 10240,
'h' => 10240,
'square' =>
false,
'upscale' =>
false,
'crop' =>
false],
223 'language_detect_from_browser' =>
true,
225 'mentions_display_format' =>
'display_name',
226 'message_delay' => 6,
227 'min_password_length' => 6,
229 'notifications_max_runtime' => 45,
230 'notifications_queue_delay' => 0,
231 'pagination_behaviour' =>
'ajax-replace',
232 'require_admin_validation' =>
false,
233 'security_email_require_confirmation' =>
true,
234 'security_email_require_password' =>
true,
235 'security_notify_admins' =>
true,
236 'security_notify_user_password' =>
true,
237 'security_protect_upgrade' =>
true,
238 'session_bound_entity_icons' =>
false,
239 'simplecache_enabled' =>
false,
240 'subresource_integrity_enabled' =>
false,
241 'system_cache_enabled' =>
false,
242 'testing_mode' =>
false,
243 'trash_enabled' =>
false,
244 'trash_retention' => 30,
245 'user_joined_river' =>
false,
246 'webp_enabled' =>
true,
247 'who_can_change_language' =>
'everyone',
255 protected $path_properties = [
267 const ENTITY_TYPES = [
'group',
'object',
'site',
'user'];
274 const SENSITIVE_PROPERTIES = [
290 $this->saveInitialValues($values);
292 $this->values = array_merge($this->config_defaults, $values);
295 $this->getCookieConfig();
308 unset($values[
$name]);
311 $this->initial_values = $values;
321 public static function factory(
string $settings_path =
''): static {
322 $settings_path = self::resolvePath($settings_path);
324 return self::fromFile($settings_path);
340 if (!is_readable(
$path)) {
346 if (isset($GLOBALS[
'CONFIG'])) {
348 $global = $GLOBALS[
'CONFIG'];
349 unset($GLOBALS[
'CONFIG']);
354 Includer::requireFile(
$path);
356 if (empty($GLOBALS[
'CONFIG']->
dataroot)) {
357 throw new ConfigurationException(__METHOD__ .
': Reading configs failed: The Elgg settings file is missing $CONFIG->dataroot.');
360 if (empty($GLOBALS[
'CONFIG']->
wwwroot)) {
361 throw new ConfigurationException(__METHOD__ .
': Reading configs failed: The Elgg settings file is missing $CONFIG->wwwroot.');
364 $config =
new self(get_object_vars($GLOBALS[
'CONFIG']));
366 if ($global !==
null) {
368 $GLOBALS[
'CONFIG'] = $global;
370 unset($GLOBALS[
'CONFIG']);
373 if (
$config->{
'X-Sendfile-Type'}) {
375 unset(
$config->{
'X-Sendfile-Type'});
378 if (
$config->{
'X-Accel-Mapping'}) {
380 unset(
$config->{
'X-Accel-Mapping'});
393 public static function resolvePath(
string $settings_path =
''): string {
394 if (empty($settings_path)) {
395 $settings_path = Paths::settingsFile(Paths::SETTINGS_PHP);
398 return Paths::sanitize($settings_path,
false);
416 if ($this->cookies_configured) {
417 return $this->cookies;
421 if ($this->hasInitialValue(
'cookies')) {
422 $cookies = $this->getInitialValue(
'cookies');
426 if (!isset($cookies[
'session'])) {
427 $cookies[
'session'] = [];
430 $session_defaults = session_get_cookie_params();
431 $session_defaults[
'name'] =
'Elgg';
432 $cookies[
'session'] = array_merge($session_defaults, $cookies[
'session']);
435 if (!isset($cookies[
'remember_me'])) {
436 $cookies[
'remember_me'] = [];
439 $session_defaults[
'name'] =
'elggperm';
440 $session_defaults[
'expire'] = strtotime(
'+30 days');
441 $cookies[
'remember_me'] = array_merge($session_defaults, $cookies[
'remember_me']);
443 $this->cookies = $cookies;
444 $this->cookies_configured =
true;
460 if (array_key_exists(
$name, $this->deprecated)) {
464 if (!isset($this->values[
$name])) {
469 if (in_array(
$name, $this->path_properties)) {
494 return $this->initial_values[
$name] ??
null;
516 $testing = $this->values[
'testing_mode'] ?? false;
517 return !$testing && in_array(
$name, $this->locked_values) && $this->hasValue(
$name);
530 if ($this->wasWarnedLocked(
$name)) {
534 if (in_array(
$name, $this->path_properties)) {
558 if ($this->wasWarnedLocked(
$name)) {
562 unset($this->values[
$name]);
574 if ($this->wasWarnedLocked(
$name)) {
578 if (strlen(
$name) > 255) {
579 $this->getLogger()->error(
'The name length for configuration variables cannot be greater than 255');
585 return $this->
remove(
$name);
602 public function remove(
string $name):
bool {
603 if ($this->wasWarnedLocked(
$name)) {
609 unset($this->values[
$name]);
625 $this->getLogger()->warning(
"The property {$name} is read-only.");
if(! $user||! $user->canDelete()) $name
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
foreach( $paths as $path)
hasValue(string $name)
Test if we have a set value.
isLocked(string $name)
Is this value locked?
static fromFile($path)
Build a config from a file.
__construct(array $values=[])
Constructor.
getCookieConfig()
Set up and return the cookie configuration array resolved from settings.
save(string $name, $value)
Save a configuration setting to the database.
hasInitialValue(string $name)
Was a value available at construction time? (From settings.php)
getInitialValue(string $name)
Get a value set at construction time.
static factory(string $settings_path='')
Build a config from default settings locations.
saveInitialValues(array $values)
Stores the inital values.
static resolvePath(string $settings_path='')
Resolve settings path.
wasWarnedLocked(string $name)
Log a read-only warning if the name is read-only.
__set(string $name, $value)
Set an Elgg configuration value.
__isset(string $name)
Handle isset()
__unset(string $name)
Handle unset()
getValues()
Get all values.
__get(string $name)
Get an Elgg configuration value if it's been set or loaded during the boot process.
A generic parent class for Configuration exceptions.
Find Elgg and project paths.
$config
Advanced site settings, debugging section.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
_elgg_services()
Get the global service provider.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
$CONFIG wwwroot
The installation root URL of the site.
if(!isset($CONFIG)) $CONFIG dataroot
The full file path for Elgg data storage.