user_contact.inc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. if (module_exists('contact')) {
  3. /**
  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 contact form'),
  10. 'icon' => 'icon_contact.png',
  11. 'description' => t('The site contact form that allows users to contact other users.'),
  12. 'category' => t('User'),
  13. 'required context' => new ctools_context_required(t('User'), 'user'),
  14. );
  15. }
  16. /**
  17. * Render the custom content type.
  18. */
  19. function ctools_user_contact_content_type_render($subtype, $conf, $panel_args, $context) {
  20. if (empty($context) || empty($context->data)) {
  21. return;
  22. }
  23. if (!_contact_personal_tab_access($context->data)) {
  24. return;
  25. }
  26. // Build the content type block.
  27. $block = new stdClass();
  28. $block->module = 'contact';
  29. $block->delta = 'form';
  30. $block->title = t('Contact @name', array('@name' => $context->data->name));
  31. module_load_include('inc', 'contact', 'contact.pages');
  32. $block->content = drupal_get_form('contact_personal_form', $context->data);
  33. return $block;
  34. }
  35. /**
  36. * Returns an edit form for custom type settings.
  37. */
  38. function ctools_user_contact_content_type_edit_form($form, &$form_state) {
  39. // Empty so that we can have title override.
  40. return $form;
  41. }
  42. /**
  43. * Submit handler for contact form.
  44. */
  45. function ctools_user_contact_content_type_edit_form_submit(&$form, &$form_state) {
  46. // Copy everything from our defaults.
  47. /*
  48. foreach (array_keys($form_state['plugin']['defaults']) as $key) {
  49. $form_state['conf'][$key] = $form_state['values'][$key];
  50. }
  51. */
  52. }
  53. /**
  54. * Returns the administrative title for a type.
  55. */
  56. function ctools_user_contact_content_type_admin_title($subtype, $conf, $context) {
  57. return t('User contact form');
  58. }