user_picture.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Plugins are described by creating a $plugin array which will be used
  4. * by the system that includes this file.
  5. */
  6. $plugin = array(
  7. 'single' => TRUE,
  8. 'title' => t('User picture'),
  9. 'icon' => 'icon_user.png',
  10. 'description' => t('The picture of a user.'),
  11. 'required context' => new ctools_context_required(t('User'), 'user'),
  12. 'category' => t('User'),
  13. );
  14. function ctools_user_picture_content_type_render($subtype, $conf, $panel_args, $context) {
  15. global $user;
  16. if (empty($context->data)) {
  17. return;
  18. }
  19. $account = clone $context->data;
  20. // Check if user has permissions to access the user
  21. if ($user->uid != $account->uid && (!user_access('access user profiles') && !user_access('administer users'))) {
  22. return;
  23. }
  24. $block = new stdClass();
  25. $block->module = 'user-profile';
  26. $block->title = check_plain($account->name);
  27. $element['user_picture'] = array(
  28. '#theme' => 'user_picture',
  29. '#account' => $account,
  30. );
  31. $block->content = $element;
  32. return $block;
  33. }
  34. /**
  35. * Display the administrative title for a panel pane in the drag & drop UI
  36. */
  37. function ctools_user_picture_content_type_admin_title($subtype, $conf, $context) {
  38. return t('"@s" user picture', array('@s' => $context->identifier));
  39. }
  40. function ctools_user_picture_content_type_edit_form($form, &$form_state) {
  41. // provide a blank form so we have a place to have context setting.
  42. return $form;
  43. }