Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
edit.php
Go to the documentation of this file.
1 <?php
12 $entity = elgg_extract('entity', $vars);
13 
14 echo elgg_view_input('text', array(
15  'name' => 'name',
16  'value' => $entity->name,
17  'label' => elgg_echo('user:name:label'),
18  'maxlength' => 50, // hard coded in /actions/profile/edit
19 ));
20 
22 
23 $profile_fields = elgg_get_config('profile_fields');
24 if (is_array($profile_fields) && count($profile_fields) > 0) {
25  foreach ($profile_fields as $shortname => $valtype) {
27  'guid' => $entity->guid,
28  'metadata_name' => $shortname,
29  'limit' => false
30  ));
31  if ($metadata) {
32  if (is_array($metadata)) {
33  $value = '';
34  foreach ($metadata as $md) {
35  if (!empty($value)) {
36  $value .= ', ';
37  }
38  $value .= $md->value;
39  $access_id = $md->access_id;
40  }
41  } else {
42  $value = $metadata->value;
43  $access_id = $metadata->access_id;
44  }
45  } else {
46  $value = '';
47  $access_id = ACCESS_DEFAULT;
48  }
49 
50  // sticky form values take precedence over saved ones
51  if (isset($sticky_values[$shortname])) {
52  $value = $sticky_values[$shortname];
53  }
54  if (isset($sticky_values['accesslevel'][$shortname])) {
55  $access_id = $sticky_values['accesslevel'][$shortname];
56  }
57 
58  $id = "profile-$shortname";
59  $input = elgg_view("input/$valtype", [
60  'name' => $shortname,
61  'value' => $value,
62  'id' => $id,
63  ]);
64  $access_input = elgg_view('input/access', [
65  'name' => "accesslevel[$shortname]",
66  'value' => $access_id,
67  ]);
68 
69  echo elgg_view('elements/forms/field', [
70  'input' => $input . $access_input,
71  'label' => elgg_view('elements/forms/label', [
72  'label' => elgg_echo("profile:$shortname"),
73  'id' => $id,
74  ])
75  ]);
76  }
77 }
78 
79 elgg_clear_sticky_form('profile:edit');
80 
81 echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $entity->guid));
82 echo elgg_view_input('submit', [
83  'value' => elgg_echo('save'),
84  'field_class' => 'elgg-foot',
85 ]);
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$id
Edit a custom profile field.
Definition: edit.php:6
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
Definition: edit.php:19
$metadata
Definition: entity.php:19
$value
Definition: longtext.php:26
$vars['entity']
elgg_view_input($input_type, array $vars=array())
Renders a form field.
Definition: views.php:1332
if(!is_array($accesslevel)) $profile_fields
Definition: edit.php:26
$entity
Edit profile form.
Definition: edit.php:12
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1310
elgg_get_metadata(array $options=array())
Returns metadata.
Definition: metadata.php:143
const ACCESS_DEFAULT
Definition: elgglib.php:1987
$sticky_values
Definition: edit.php:21
elgg_clear_sticky_form($form_name)
Remove form submission data from the session.
Definition: input.php:119
elgg_get_sticky_values($form_name, $filter_result=true)
Get all submission data cached for a form.
Definition: input.php:161