Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
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.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_save_config($name, $value, $site_guid=0)
Save a configuration setting.
$value
Definition: longtext.php:26
register_error($error)
Display an error on next page load.
Definition: elgglib.php:452
$key
Definition: summary.php:34
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
const REFERER
Definition: elgglib.php:2029
$type
Definition: add.php:8
forward($location="", $reason= 'system')
Forward to $location.
Definition: elgglib.php:93
$label
Elgg profile plugin edit default profile action.
Definition: add.php:7
if(!$collection_name) $id
Definition: add.php:17
system_message($message)
Display a system message on next page load.
Definition: elgglib.php:438
$fieldlist
Definition: add.php:10