user_picture.inc 1.4 KB

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