add.php 929 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Elgg profile plugin edit default profile action
  4. *
  5. */
  6. $label = get_input('label');
  7. $type = get_input('type');
  8. $fieldlist = elgg_get_config('profile_custom_fields');
  9. if (!$fieldlist && $fieldlist !== '0') {
  10. $fieldlist = '';
  11. $id = 0;
  12. } else {
  13. $fieldlistarray = explode(',', $fieldlist);
  14. foreach ($fieldlistarray as $key => $value) {
  15. $fieldlistarray[$key] = (int)$value;
  16. }
  17. $id = max($fieldlistarray) + 1;
  18. }
  19. if (($label) && ($type)) {
  20. if ($fieldlist !== '') {
  21. $fieldlist .= ',';
  22. }
  23. $fieldlist .= "$id";
  24. if (elgg_save_config("admin_defined_profile_$id", $label) &&
  25. elgg_save_config("admin_defined_profile_type_$id", $type) &&
  26. elgg_save_config('profile_custom_fields', $fieldlist)) {
  27. system_message(elgg_echo('profile:editdefault:success'));
  28. } else {
  29. register_error(elgg_echo('profile:editdefault:fail'));
  30. }
  31. } else {
  32. register_error(elgg_echo('profile:editdefault:fail'));
  33. }
  34. forward(REFERER);