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