Index: modules/contact/contact.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.admin.inc,v retrieving revision 1.5 diff -u -p -r1.5 contact.admin.inc --- modules/contact/contact.admin.inc 2 Jul 2008 20:05:11 -0000 1.5 +++ modules/contact/contact.admin.inc 30 Nov 2008 09:45:46 -0000 @@ -13,9 +13,23 @@ function contact_admin_categories() { $result = db_query('SELECT cid, category, recipients, selected FROM {contact} ORDER BY weight, category'); $rows = array(); while ($category = db_fetch_object($result)) { - $rows[] = array($category->category, $category->recipients, ($category->selected ? t('Yes') : t('No')), l(t('edit'), 'admin/build/contact/edit/' . $category->cid), l(t('delete'), 'admin/build/contact/delete/' . $category->cid)); + $rows[] = array( + $category->category, + $category->recipients, + ($category->selected ? t('Yes') : t('No')), + l(t('contact form'), 'contact/'. $category->cid), + l(t('edit'), 'admin/build/contact/edit/' . $category->cid), + l(t('delete'), 'admin/build/contact/delete/' . $category->cid), + ); } - $header = array(t('Category'), t('Recipients'), t('Selected'), array('data' => t('Operations'), 'colspan' => 2)); + $header = array( + t('Category'), + t('Recipients'), + t('Selected'), + t('Link'), + array('data' => t('Operations'), + 'colspan' => 2), + ); return theme('table', $header, $rows); } @@ -28,6 +42,7 @@ function contact_admin_edit($form_state if (empty($contact) || $op == 'add') { $contact = array( 'category' => '', + 'information' => '', 'recipients' => '', 'reply' => '', 'weight' => 0, @@ -43,6 +58,12 @@ function contact_admin_edit($form_state '#description' => t("Example: 'website feedback' or 'product information'."), '#required' => TRUE, ); + $form['information'] = array('#type' => 'textarea', + '#title' => t('Additional infromation for this category'), + '#default_value' => $contact['information'], + '#description' => t("Leave empty if you want to use default"), + '#required' => FALSE, + ); $form['recipients'] = array('#type' => 'textarea', '#title' => t('Recipients'), '#default_value' => $contact['recipients'], Index: modules/contact/contact.install =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v retrieving revision 1.11 diff -u -p -r1.11 contact.install --- modules/contact/contact.install 15 Nov 2008 13:01:05 -0000 1.11 +++ modules/contact/contact.install 30 Nov 2008 09:45:46 -0000 @@ -41,6 +41,12 @@ function contact_schema() { 'default' => '', 'description' => 'Category name.', ), + 'information' => array( + 'type' => 'text', + 'not null' => TRUE, + 'size' => 'big', + 'description' => 'Additional information.', + ), 'recipients' => array( 'type' => 'text', 'not null' => TRUE, @@ -79,3 +85,19 @@ function contact_schema() { return $schema; } + +/** + * Implementation of hook_update_N(). + */ +function contact_update_7000() { + $ret = array(); + db_add_field($ret, 'contact', 'information', + array( + 'type' => 'text', + 'not null' => TRUE, + 'size' => 'big', + 'description' => 'Additional information.', + 'initial' => '', + )); + return $ret; +} \ No newline at end of file Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.111 diff -u -p -r1.111 contact.module --- modules/contact/contact.module 9 Oct 2008 15:15:51 -0000 1.111 +++ modules/contact/contact.module 30 Nov 2008 09:45:47 -0000 @@ -99,6 +99,14 @@ function contact_menu() { 'access arguments' => array('access site-wide contact form'), 'type' => MENU_SUGGESTED_ITEM, ); + $items['contact/%contact'] = array( + 'title callback' => 'contact_page_title', + 'title arguments' => array(1), + 'page callback' => 'contact_site_page', + 'page arguments' => array(1), + 'access arguments' => array('access site-wide contact form'), + 'type' => MENU_SUGGESTED_ITEM, + ); $items['user/%user/contact'] = array( 'title' => 'Contact', 'page callback' => 'contact_user_page', @@ -131,7 +139,12 @@ function _contact_user_tab_access($accou * Load the data for a single contact category. */ function contact_load($cid) { - $contact = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid)); + if (is_numeric($cid)) { + $contact = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid)); + } + else { + $contact = db_fetch_array(db_query("SELECT * FROM {contact} WHERE category = '%s'", $cid)); + } return empty($contact) ? FALSE : $contact; } @@ -199,3 +212,10 @@ function contact_mail($key, &$message, $ break; } } + +/** + * Set the page title for the contact pages. + */ +function contact_page_title($contact) { + return t('Contact @category', array('@category' => $contact['category'])); +} \ No newline at end of file Index: modules/contact/contact.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v retrieving revision 1.15 diff -u -p -r1.15 contact.pages.inc --- modules/contact/contact.pages.inc 13 Oct 2008 00:33:02 -0000 1.15 +++ modules/contact/contact.pages.inc 30 Nov 2008 09:45:47 -0000 @@ -9,36 +9,63 @@ /** * Site-wide contact page. + * + * @param $contact + * A keyed array containing the current data of the contact. + * + * @return + * The generated page. */ -function contact_site_page() { +function contact_site_page($contact = NULL) { global $user; if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3)) && !user_access('administer site-wide contact form')) { $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3))); } else { - $output = drupal_get_form('contact_mail_page'); + $output = drupal_get_form('contact_mail_page', $contact); } return $output; } -function contact_mail_page() { +/** + * Contact form. + * + * @param $form_state + * A keyed array containing the current state of the form. + * @param $contact + * A keyed array containing the current data of the contact. + * @return + * The contact form. + */ +function contact_mail_page($form_state, $contact = NULL) { global $user; $form = $categories = array(); - - $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); - while ($category = db_fetch_object($result)) { - $categories[$category->cid] = $category->category; - if ($category->selected) { - $default_category = $category->cid; + if (is_array($contact)) { + $categories[] = $contact; + } + else { + $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); + while ($category = db_fetch_object($result)) { + $categories[$category->cid] = $category->category; + if ($category->selected) { + $default_category = $category->cid; + } } } if (count($categories) > 0) { $form['#token'] = $user->uid ? $user->name . $user->mail : ''; - $form['contact_information'] = array('#markup' => filter_xss_admin(variable_get('contact_form_information', t('You can leave a message using the contact form below.')))); + + if (is_array($contact) && trim($contact['information']) != '') { + $information = $contact['information']; + } + else { + $information = variable_get('contact_form_information', t('You can leave a message using the contact form below.')); + } + $form['contact_information'] = array('#markup' => filter_xss_admin($information)); $form['name'] = array('#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 255, @@ -55,6 +82,7 @@ function contact_mail_page() { '#title' => t('Subject'), '#maxlength' => 255, '#required' => TRUE, + '#default_value' => arg(2), ); if (count($categories) > 1) { // If there is more than one category available and no default category has been selected,