contact_user.inc

  1. cis7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  2. cle7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  3. ecd7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  4. elmsmedia7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  5. harmony7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  6. icor7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
  8. mooc7 sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc

Functions

Namesort descending Description
page_manager_blog_contact_user_access_check Callback to determine if a page is accessible.
page_manager_contact_user Entry point for our overridden user view.
page_manager_contact_user_enable Callback to enable/disable the page from the UI.
page_manager_contact_user_get_arguments Callback to get arguments provided by this task handler.
page_manager_contact_user_get_contexts Callback to get context placeholders provided by this handler.
page_manager_contact_user_menu_alter Callback defined by page_manager_contact_user_page_manager_tasks().
page_manager_contact_user_page_manager_tasks Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for more information.

File

sites/all/modules/ulmus/ctools/page_manager/plugins/tasks/contact_user.inc
View source
  1. <?php
  2. /**
  3. * Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
  4. * more information.
  5. */
  6. function page_manager_contact_user_page_manager_tasks() {
  7. if (!module_exists('contact')) {
  8. return;
  9. }
  10. return array(
  11. // This is a 'page' task and will fall under the page admin UI
  12. 'task type' => 'page',
  13. 'title' => t('User contact'),
  14. 'admin title' => t('User contact'),
  15. 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying the user contact form at <em>user/%user/contact</em>. If no variant is selected, the default Drupal user contact form will be used.'),
  16. 'admin path' => 'user/%user/contact',
  17. // Callback to add items to the page managertask administration form:
  18. 'task admin' => 'page_manager_contact_user_task_admin',
  19. 'hook menu alter' => 'page_manager_contact_user_menu_alter',
  20. // This is task uses 'context' handlers and must implement these to give the
  21. // handler data it needs.
  22. 'handler type' => 'context', // handler type -- misnamed
  23. 'get arguments' => 'page_manager_contact_user_get_arguments',
  24. 'get context placeholders' => 'page_manager_contact_user_get_contexts',
  25. // Allow this to be enabled or disabled:
  26. 'disabled' => variable_get('page_manager_contact_user_disabled', TRUE),
  27. 'enable callback' => 'page_manager_contact_user_enable',
  28. 'access callback' => 'page_manager_contact_user_access_check',
  29. );
  30. }
  31. /**
  32. * Callback defined by page_manager_contact_user_page_manager_tasks().
  33. *
  34. * Alter the user view input so that user view comes to us rather than the
  35. * normal user view process.
  36. */
  37. function page_manager_contact_user_menu_alter(&$items, $task) {
  38. if (variable_get('page_manager_contact_user_disabled', TRUE)) {
  39. return;
  40. }
  41. $callback = $items['user/%user/contact']['page callback'];
  42. if ($callback == 'drupal_get_form') {
  43. $callback = $items['user/%user/contact']['page arguments'][0];
  44. }
  45. // Override the user view handler for our purpose.
  46. if ($callback == 'contact_personal_form' || variable_get('page_manager_override_anyway', FALSE)) {
  47. $items['user/%user/contact']['page callback'] = 'page_manager_contact_user';
  48. $items['user/%user/contact']['file path'] = $task['path'];
  49. $items['user/%user/contact']['file'] = $task['file'];
  50. }
  51. else {
  52. // automatically disable this task if it cannot be enabled.
  53. variable_set('page_manager_contact_user_disabled', TRUE);
  54. if (!empty($GLOBALS['page_manager_enabling_contact_user'])) {
  55. drupal_set_message(t('Page manager module is unable to enable user/%user/contact because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');
  56. }
  57. }
  58. }
  59. /**
  60. * Entry point for our overridden user view.
  61. *
  62. * This function asks its assigned handlers who, if anyone, would like
  63. * to run with it. If no one does, it passes through to Drupal core's
  64. * user view, which is user_page_view().
  65. */
  66. function page_manager_contact_user($form_id, $account) {
  67. // Load my task plugin:
  68. $task = page_manager_get_task('contact_user');
  69. // Load the account into a context.
  70. ctools_include('context');
  71. ctools_include('context-task-handler');
  72. $contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
  73. $output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
  74. if ($output !== FALSE) {
  75. return $output;
  76. }
  77. module_load_include('inc', 'contact', 'contact.pages');
  78. $function = 'contact_personal_form';
  79. foreach (module_implements('page_manager_override') as $module) {
  80. $call = $module . '_page_manager_override';
  81. if (($rc = $call('contact_user')) && function_exists($rc)) {
  82. $function = $rc;
  83. break;
  84. }
  85. }
  86. // Otherwise, fall back.
  87. return drupal_get_form($function, $account);
  88. }
  89. /**
  90. * Callback to get arguments provided by this task handler.
  91. *
  92. * Since this is the node view and there is no UI on the arguments, we
  93. * create dummy arguments that contain the needed data.
  94. */
  95. function page_manager_contact_user_get_arguments($task, $subtask_id) {
  96. return array(
  97. array(
  98. 'keyword' => 'user',
  99. 'identifier' => t('User being viewed'),
  100. 'id' => 1,
  101. 'name' => 'uid',
  102. 'settings' => array(),
  103. ),
  104. );
  105. }
  106. /**
  107. * Callback to get context placeholders provided by this handler.
  108. */
  109. function page_manager_contact_user_get_contexts($task, $subtask_id) {
  110. return ctools_context_get_placeholders_from_argument(page_manager_contact_user_get_arguments($task, $subtask_id));
  111. }
  112. /**
  113. * Callback to enable/disable the page from the UI.
  114. */
  115. function page_manager_contact_user_enable($cache, $status) {
  116. variable_set('page_manager_contact_user_disabled', $status);
  117. // Set a global flag so that the menu routine knows it needs
  118. // to set a message if enabling cannot be done.
  119. if (!$status) {
  120. $GLOBALS['page_manager_enabling_contact_user'] = TRUE;
  121. }
  122. }
  123. /**
  124. * Callback to determine if a page is accessible.
  125. *
  126. * @param $task
  127. * The task plugin.
  128. * @param $subtask_id
  129. * The subtask id
  130. * @param $contexts
  131. * The contexts loaded for the task.
  132. * @return
  133. * TRUE if the current user can access the page.
  134. */
  135. function page_manager_blog_contact_user_access_check($task, $subtask_id, $contexts) {
  136. $context = reset($contexts);
  137. return _contact_personal_tab_access($context->data);
  138. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.