user_edit.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Plugin to provide an argument handler for a Taxonomy term.
  5. */
  6. /**
  7. * Plugins are described by creating a $plugin array which will be used
  8. * by the system that includes this file.
  9. */
  10. $plugin = array(
  11. 'title' => t("User edit form: User ID"),
  12. // Keyword to use for %substitution.
  13. 'keyword' => 'user',
  14. 'description' => t('Creates a user edit form context from a user ID argument.'),
  15. 'context' => 'ctools_user_edit_context',
  16. 'placeholder form' => array(
  17. '#type' => 'textfield',
  18. '#description' => t('Enter the user ID for this argument.'),
  19. ),
  20. );
  21. /**
  22. * Discover if this argument gives us the term we crave.
  23. */
  24. function ctools_user_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
  25. // If unset it wants a generic, unfilled context.
  26. if ($empty) {
  27. return ctools_context_create_empty('user_edit_form');
  28. }
  29. if (is_object($arg)) {
  30. return ctools_context_create('user_edit_form', $arg);
  31. }
  32. if (!is_numeric($arg)) {
  33. return FALSE;
  34. }
  35. $account = user_load($arg);
  36. if (!$account) {
  37. return NULL;
  38. }
  39. // This will perform a node_access check, so we don't have to.
  40. return ctools_context_create('user_edit_form', $account);
  41. }