access.php 780 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Elgg access level input
  4. * Displays a dropdown input field
  5. *
  6. * @uses $vars['value'] The current value, if any
  7. * @uses $vars['name'] The name of the input field
  8. *
  9. */
  10. $class = "elgg-input-access";
  11. if ((!isset($vars['options'])) || (!is_array($vars['options']))) {
  12. $vars['options'] = array();
  13. $vars['options'] = get_write_access_array();
  14. }
  15. if (is_array($vars['options']) && sizeof($vars['options']) > 0) {
  16. ?>
  17. <select name="<?php echo $vars['name']; ?>" class="<?php echo $class; ?>">
  18. <?php
  19. foreach($vars['options'] as $key => $option) {
  20. if ($key != $vars['value']) {
  21. echo "<option value=\"{$key}\">{$option}</option>";
  22. } else {
  23. echo "<option value=\"{$key}\" selected=\"selected\">{$option}</option>";
  24. }
  25. }
  26. ?>
  27. </select>
  28. <?php
  29. }