Elgg  Version 1.11
add.php
Go to the documentation of this file.
1 <?php
7 $label = get_input('label');
8 $type = get_input('type');
9 
10 $fieldlist = elgg_get_config('profile_custom_fields');
11 if (!$fieldlist && $fieldlist !== '0') {
12  $fieldlist = '';
13  $id = 0;
14 } else {
15  $fieldlistarray = explode(',', $fieldlist);
16  foreach ($fieldlistarray as $key => $value) {
17  $fieldlistarray[$key] = (int)$value;
18  }
19  $id = max($fieldlistarray) + 1;
20 }
21 
22 if (($label) && ($type)) {
23  if ($fieldlist !== '') {
24  $fieldlist .= ',';
25  }
26  $fieldlist .= "$id";
27 
28  if (elgg_save_config("admin_defined_profile_$id", $label) &&
29  elgg_save_config("admin_defined_profile_type_$id", $type) &&
30  elgg_save_config('profile_custom_fields', $fieldlist)) {
31 
32  system_message(elgg_echo('profile:editdefault:success'));
33  } else {
34  register_error(elgg_echo('profile:editdefault:fail'));
35  }
36 } else {
37  register_error(elgg_echo('profile:editdefault:fail'));
38 }
39 
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_save_config($name, $value, $site_guid=0)
Save a configuration setting.
$value
Definition: longtext.php:26
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:419
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$key
Definition: summary.php:34
const REFERER
Definition: elgglib.php:1995
$type
Definition: add.php:8
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:374
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:383
$label
Elgg profile plugin edit default profile action.
Definition: add.php:7
if(!$collection_name) $id
Definition: add.php:17
$fieldlist
Definition: add.php:10