Elgg  Version master
security_txt.php
Go to the documentation of this file.
1 <?php
6 $fields = [
7  'contact' => true,
8  'expires' => true,
9  'encryption' => false,
10  'acknowledgments' => false,
11  'language' => false,
12  'canonical' => false,
13  'policy' => false,
14  'hiring' => false,
15  'csaf' => false,
16 ];
17 
18 // first validate all required inputs
19 foreach ($fields as $name => $required) {
21  if (!$required || !empty($value)) {
22  continue;
23  }
24 
25  return elgg_error_response(elgg_echo('error:missing_data'));
26 }
27 
28 // save all data
29 foreach ($fields as $name => $required) {
30  elgg_save_config("security_txt_{$name}", get_input($name) ?: null);
31 }
32 
33 return elgg_ok_response('', elgg_echo('save:success'));
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
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_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$value
Definition: generic.php:51
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
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.
$fields
Save the configuration of the security.txt contents.
Definition: security_txt.php:6
elgg_save_config(string $name, $value)
Save a configuration setting.
$required
Definition: label.php:12