Commit 76a104d4 authored by Dries's avatar Dries
Browse files

- Patch #39135 by Zen: Contact module category update issue + _validate, _submit conversion.

parent 10dc538c
......@@ -12,14 +12,28 @@
function contact_help($section) {
switch ($section) {
case 'admin/help#contact':
$output = sprintf('<p>%s</p><p>%s</p><p>%s</p>', t('The contact module enables the use of both personal and site-wide contact forms, thereby facilitating easy communication within the community. While personal contact forms allow users to contact each other by e-mail, site-wide forms allow community members to contact the site administration from a central location. Users can specify a subject and message in the contact form, and also request that a copy of the e-mail be sent to their own address.'), t("Users can activate/deactivate their personal contact forms in their account settings. Upon activation, a contact tab will appear in their user profiles. Privileged users such as site administrators are able to contact users even if they have chosen not to enable this feature."), t('Contact module links:'));
$output .= sprintf('<ul><li>%s</li><li>%s</li><li>%s</li></ul>', t('Default site-wide <a href="%contact-page">contact page</a>.', array('%contact-page' => url('contact'))), t('Site-wide contact form <a href="%configuration-page">category configuration</a>.', array('%configuration-page' => url('admin/contact'))), t('Site-wide contact form <a href="%additional-settings">general settings</a>.', array('%additional-settings' => url('admin/settings/contact'))));
$output .= t('For more information, please read the configuration and customization handbook page for the <a href="%contact">Contact module</a>.', array('%contact' => url('http://drupal.org/handbook/modules/contact/', NULL, NULL, TRUE)));
$output = '<p>'. t('The contact module enables the use of both personal and site-wide contact forms, thereby facilitating easy communication within the community. While personal contact forms allow users to contact each other by e-mail, site-wide forms allow community members to contact the site administration from a central location. Users can specify a subject and message in the contact form, and also request that a copy of the e-mail be sent to their own address.') .'</p>';
$output .= '<p>'. t("Users can activate/deactivate their personal contact forms in their account settings. Upon activation, a contact tab will appear in their user profiles. Privileged users such as site administrators are able to contact users even if they have chosen not to enable this feature.") .'</p>';
$output .= '<p>'. t('If the menu module is enabled, a menu item linking to the site-wide contact page is added to the navigation block. It is disabled by default, but can be enabled via the <a href="%menu-module">menu management</a> page. Links to the contact page may also be added to the primary and secondary links using the same page.', array('%menu-module' => url('admin/menu'))) .'</p>';
$output .= t('Contact module links:') .'<ul>';
$output .= '<li>'. t('Default site-wide <a href="%contact-page">contact page</a>.', array('%contact-page' => url('contact'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%configuration-page">category configuration</a>.', array('%configuration-page' => url('admin/contact'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%additional-settings">general settings</a>.', array('%additional-settings' => url('admin/contact/settings'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%menu-configuration">menu configuration</a>.', array('%menu-configuration' => url('admin/menu'))) .'</li></ul>';
$output .= t('For more information, please read the configuration and customization handbook page for the <a href="%contact">contact module</a>.', array('%contact' => url('http://drupal.org/handbook/modules/contact/', NULL, NULL, TRUE)));
return $output;
case 'admin/modules#description':
return t('Enables the use of both personal and site-wide contact forms.');
case 'admin/contact':
return t('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="%settings">settings page</a> you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('%settings' => url('admin/settings/contact'), '%form' => url('contact')));
$output = t('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="%settings">settings page</a>, you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('%settings' => url('admin/contact/settings'), '%form' => url('contact')));
if (!module_exist('menu')) {
$menu_note = t('The menu item can be customized and configured only once the menu module has been <a href="%modules-page">enabled</a>.', array('%modules-page' => url('admin/modules')));
}
else {
$menu_note = '';
}
$output .= '<p>'. t('The contact module also adds a <a href="%menu-settings">menu item</a> (disabled by default) to the navigation block.', array('%menu-settings' => url('admin/menu'))) .' '. $menu_note .'</p>';
return($output);
}
}
......@@ -27,27 +41,57 @@ function contact_help($section) {
* Implementation of hook_menu().
*/
function contact_menu($may_cache) {
global $user;
$items = array();
if ($may_cache) {
$items[] = array('path' => 'contact', 'title' => t('contact'),
'callback' => 'contact_mail_page', 'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM);
$items[] = array('path' => 'admin/contact', 'title' => t('contact form'),
'callback' => 'contact_admin', 'access' => user_access('administer site configuration'));
$items[] = array('path' => 'admin/contact/list', 'title' => t('list'),
'callback' => 'contact_admin', 'access' => user_access('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
$items[] = array('path' => 'admin/contact/add', 'title' => t('add category'),
'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/contact/edit', 'title' => t('edit contact category'),
'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/contact/delete', 'title' => t('delete contact'),
'callback' => 'contact_admin_delete', 'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/contact',
'title' => t('contact form'),
'callback' => 'contact_admin_categories',
'access' => user_access('administer site configuration'),
);
$items[] = array('path' => 'admin/contact/category',
'title' => t('categories'),
'callback' => 'contact_admin_categories',
'access' => user_access('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array('path' => 'admin/contact/category/list',
'title' => t('list'),
'callback' => 'contact_admin_categories',
'access' => user_access('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array('path' => 'admin/contact/category/add',
'title' => t('add category'),
'callback' => 'contact_admin_edit',
'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items[] = array('path' => 'admin/contact/category/edit',
'title' => t('edit contact category'),
'callback' => 'contact_admin_edit',
'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/contact/category/delete',
'title' => t('delete contact'),
'callback' => 'contact_admin_delete',
'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/contact/settings',
'title' => t('settings'),
'callback' => 'contact_admin_settings',
'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items[] = array('path' => 'contact',
'title' => t('contact'),
'callback' => 'contact_mail_page',
'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM,
);
}
else {
if (arg(0) == 'user' && is_numeric(arg(1))) {
......@@ -59,30 +103,10 @@ function contact_menu($may_cache) {
return $items;
}
/**
* Implementation of hook_settings().
*/
function contact_settings() {
$form['contact_form_information'] = array(
'#type' => 'textarea',
'#title' => t('Additional information'),
'#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')),
'#description' => t('Information to show on the <a href="%form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('%form' => url('contact'))),
);
$form['contact_hourly_threshold'] = array(
'#type' => 'select',
'#title' => t('Hourly threshold'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
'#default_value' => variable_get('contact_hourly_threshold', 3),
'#description' => t('The maximum number of contact form submissions a user can perform per hour.'),
);
return $form;
}
/**
* Implementation of hook_user().
*
* Provides signature customization for the user's comments.
* Allows the user the option of enabling/disabling his personal contact form.
*/
function contact_user($type, $edit, &$user, $category = NULL) {
if ($type == 'form' && $category == 'account') {
......@@ -94,7 +118,7 @@ function contact_user($type, $edit, &$user, $category = NULL) {
$form['contact']['contact'] = array('#type' => 'checkbox',
'#title' => t('Personal contact form'),
'#default_value' => $edit['contact'],
'#description' => t('Allow other users to contact you by e-mail via <a href="%url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('%url' => url("user/$user->uid/contact")))
'#description' => t('Allow other users to contact you by e-mail via <a href="%url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('%url' => url("user/$user->uid/contact"))),
);
return $form;
}
......@@ -103,6 +127,196 @@ function contact_user($type, $edit, &$user, $category = NULL) {
}
}
/**
* Categories/list tab.
*/
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/contact/category/edit/'. $category->cid), l(t('delete'), 'admin/contact/category/delete/'. $category->cid));
}
$header = array(t('Category'), t('Recipients'), t('Selected'), array('data' => t('Operations'), 'colspan' => 2));
return theme('table', $header, $rows);
}
/**
* Category edit page.
*/
function contact_admin_edit($cid = NULL) {
if (arg(3) == "edit" && $cid > 0) {
$category = db_fetch_object(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid));
$edit['cid'] = $category->cid;
$edit['category'] = $category->category;
$edit['recipients'] = $category->recipients;
$edit['reply'] = $category->reply;
$edit['weight'] = $category->weight;
$edit['selected'] = $category->selected;
}
$form['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#maxlength' => 255,
'#default_value' => $edit['category'],
'#description' => t("Example: 'website feedback' or 'product information'."),
'#required' => TRUE,
);
$form['recipients'] = array('#type' => 'textarea',
'#title' => t('Recipients'),
'#default_value' => $edit['recipients'],
'#description' => t("Example: 'webmaster@yoursite.com' or 'sales@yoursite.com'. To specify multiple recipients, separate each e-mail address with a comma."),
'#required' => TRUE,
);
$form['reply'] = array('#type' => 'textarea',
'#title' => t('Auto-reply'),
'#default_value' => $edit['reply'],
'#description' => t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
);
$form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $edit['weight'],
'#description' => t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
);
$form['selected'] = array('#type' => 'select',
'#title' => t('Selected'),
'#options' => array('0' => t('No'), '1' => t('Yes')),
'#default_value' => $edit['selected'],
'#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
);
$form['cid'] = array('#type' => 'hidden',
'#value' => $edit['cid'],
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Submit'),
);
return drupal_get_form('contact_admin_edit', $form);
}
/**
* Validate the contact category edit page form submission.
*/
function contact_admin_edit_validate($form_id, $form_values) {
if (empty($form_values['category'])) {
form_set_error('category', t('You must enter a category.'));
}
if (empty($form_values['recipients'])) {
form_set_error('recipients', t('You must enter one or more recipients.'));
}
else {
$recipients = explode(',', $form_values['recipients']);
foreach($recipients as $recipient) {
if (!valid_email_address(trim($recipient))) {
form_set_error('recipients',t('%recipient is an invalid e-mail address.', array('%recipient' => theme('placeholder', $recipient))));
}
}
}
}
/**
* Process the contact category edit page form submission.
*/
function contact_admin_edit_submit($form_id, $form_values) {
if ($form_values['selected']) {
// Unselect all other contact categories.
db_query('UPDATE {contact} SET selected = 0');
}
$recipients = explode(',', $form_values['recipients']);
foreach($recipients as $key=>$recipient) {
// E-mail address validation has already been done in _validate.
$recipients[$key] = trim($recipient);
}
$form_values['recipients'] = implode(',', $recipients);
if (arg(3) == 'add') {
db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected']);
drupal_set_message(t('Category %category has been added.', array('%category' => theme('placeholder', $form_values['category']))));
watchdog('mail', t('Contact form: category %category added.', array('%category' => theme('placeholder', $form_values['category']))), WATCHDOG_NOTICE, l(t('view'), 'admin/contact'));
}
else {
db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid = %d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
drupal_set_message(t('Category %category has been updated.', array('%category' => theme('placeholder', $form_values['category']))));
watchdog('mail', t('Contact form: category %category updated.', array('%category' => theme('placeholder', $form_values['category']))), WATCHDOG_NOTICE, l(t('view'), 'admin/contact'));
}
return 'admin/contact';
}
/**
* Category delete page.
*/
function contact_admin_delete($cid = NULL) {
if ($info = db_fetch_object(db_query("SELECT category FROM {contact} WHERE cid = %d", $cid))) {
$form['category'] = array('#type' => 'hidden',
'#value' => $info->category,
);
return confirm_form('contact_admin_delete', $form, t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $info->category))), 'admin/contact', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}
else {
drupal_set_message(t('Category not found.'), 'error');
drupal_goto('admin/contact');
}
}
/**
* Process category delete form submission.
*/
function contact_admin_delete_submit($form_id, $form_values) {
db_query("DELETE FROM {contact} WHERE cid = %d", arg(4));
drupal_set_message(t('Category %category has been deleted.', array('%category' => theme('placeholder', $form_values['category']))));
watchdog('mail', t('Contact form: category %category deleted.', array('%category' => theme('placeholder', $form_values['category']))), WATCHDOG_NOTICE);
return 'admin/contact';
}
/**
* Settings tab. Using a form rather than hook_settings().
*/
function contact_admin_settings() {
$form['contact_form_information'] = array('#type' => 'textarea',
'#title' => t('Additional information'),
'#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')),
'#description' => t('Information to show on the <a href="%form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('%form' => url('contact'))),
);
$form['contact_hourly_threshold'] = array('#type' => 'select',
'#title' => t('Hourly threshold'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
'#default_value' => variable_get('contact_hourly_threshold', 3),
'#description' => t('The maximum number of contact form submissions a user can perform per hour.'),
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['reset'] = array('#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return drupal_get_form('contact_admin_settings', $form);
}
/**
* Process settings form submission.
*/
function contact_admin_settings_submit($form_id, $form_values) {
$op = isset($_POST['op']) ? $_POST['op'] : '';
if ($op == t('Reset to defaults')) {
foreach ($form_values as $key => $value) {
variable_del($key);
}
drupal_set_message(t('The configuration options have been reset to their default values.'));
}
else {
foreach ($form_values as $key => $value) {
variable_set($key, $value);
}
drupal_set_message(t('The configuration options have been saved.'));
}
}
/**
* Personal contact page.
*/
function contact_mail_user() {
global $user;
......@@ -145,7 +359,7 @@ function contact_mail_user() {
'#title' => t('Send me a copy.'),
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Send e-mail')
'#value' => t('Send e-mail'),
);
$output = drupal_get_form('contact_mail_user', $form);
}
......@@ -157,6 +371,9 @@ function contact_mail_user() {
}
}
/**
* Process the personal contact page form submission.
*/
function contact_mail_user_submit($form_id, $edit) {
global $user;
......@@ -202,125 +419,17 @@ function contact_mail_user_submit($form_id, $edit) {
return "user/$account->uid";
}
function contact_admin_edit($cid = NULL) {
if (arg(2) == "edit" && $cid > 0) {
$category = db_fetch_object(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid));
$edit['cid'] = $category->cid;
$edit['category'] = $category->category;
$edit['recipients'] = $category->recipients;
$edit['reply'] = $category->reply;
$edit['weight'] = $category->weight;
$edit['selected'] = $category->selected;
}
$form['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#maxlength' => 255,
'#default_value' => $edit['category'],
'#description' => t("Example: 'website feedback' or 'product information'."),
'#required' => TRUE,
);
$form['recipients'] = array('#type' => 'textarea',
'#title' => t('Recipients'),
'#default_value' => $edit['recipients'],
'#description' => t("Example: 'webmaster@yoursite.com' or 'sales@yoursite.com'. To specify multiple recipients, separate each e-mail address with a comma."),
'#required' => TRUE,
);
$form['reply'] = array('#type' => 'textarea',
'#title' => t('Auto-reply'),
'#default_value' => $edit['reply'],
'#description' => t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
);
$form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $edit['weight'],
'#description' => t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
);
$form['selected'] = array('#type' => 'select',
'#title' => t('Selected'),
'#options' => array('0' => t('No'), '1' => t('Yes')),
'#default_value' => $edit['selected'],
'#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
);
$form['cid'] = array('#type' => 'hidden',
'#value' => $edit['cid'],
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Submit'),
);
return drupal_get_form('contact_admin_edit', $form);
}
function contact_admin_edit_validate($form_id, $form_values) {
if (empty($form_values['category'])) {
form_set_error('category', t('You must enter a category.'));
}
if (empty($form_values['recipients'])) {
form_set_error('recipients', t('You must enter one or more recipients.'));
}
else {
$recipients = explode(',', $form_values['recipients']);
foreach($recipients as $recipient) {
if (!valid_email_address(trim($recipient))) {
form_set_error('recipients',t('%recipient is an invalid e-mail address.', array('%recipient' => theme('placeholder', $recipient))));
}
}
}
}
function contact_admin_edit_submit($form_id, $form_values) {
if ($form_values['selected']) {
//Unselect all other contact categories
db_query("UPDATE {contact} SET selected = 0");
}
$recipients = explode(',', $form_values['recipients']);
foreach($recipients as $key=>$recipient) {
$recipients[$key] = trim($recipient);
}
$form_values['recipients'] = implode(',', $recipients);
if (arg(2) == "add") {
db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected']);
}
else {
db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid=%d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
}
drupal_set_message(t('Category %category has been updated.', array('%category' => theme('placeholder', $edit['category']))));
return 'admin/contact';
}
function contact_admin_delete($cid) {
$info = db_fetch_object(db_query("SELECT cid, category FROM {contact} WHERE cid = %d", $cid));
if ($_POST['op'] != t('Delete')) {
return confirm_form('contact_admin_delete',
array(),
t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $info->category))),
'admin/contact',
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
else {
db_query("DELETE FROM {contact} WHERE cid = %d", $cid);
drupal_goto('admin/contact');
}
}
function contact_admin() {
$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/contact/edit/'. $category->cid), l(t('delete'), 'admin/contact/delete/'. $category->cid));
}
$header = array(t('Category'), t('Recipients'), t('Selected'), array('data' => t('Operations'), 'colspan' => 2));
return theme('table', $header, $rows);
}
/**
* Site-wide contact page
*/
function contact_mail_page() {
global $user;
$breadcrumb[] = array('path' => 'contact', 'title' => t('contact'));
menu_set_location($breadcrumb);
if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
$output = t("You can't send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
$output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
}
else {
if ($user->uid) {
......@@ -390,6 +499,9 @@ function contact_mail_page() {
return $output;
}
/**
* Validate the site-wide contact page form submission.
*/
function contact_mail_page_validate($form_id, &$form) {
global $form_values;
if (!$form['cid']) {
......@@ -409,6 +521,9 @@ function contact_mail_page_validate($form_id, &$form) {
}
}
/**
* Process the site-wide contact page form submission.
*/
function contact_mail_page_submit($form_id, $edit) {
// Prepare the sender:
......@@ -449,9 +564,9 @@ function contact_mail_page_submit($form_id, $edit) {
flood_register_event('contact');
watchdog('mail', t('%name-from sent an e-mail regarding %category.', array('%name-from' => theme('placeholder', $edit['name'] ." <$from>"), '%category' => theme('placeholder', $contact->category))));
// Set a status message:subject
// Update user:
drupal_set_message(t('Your message has been sent.'));
// Jump to contact page:
return 'contact';
// Jump to home page rather than back to contact page to avoid contradictory messages if flood control has been activated.
return('');
}
......@@ -12,14 +12,28 @@
function contact_help($section) {
switch ($section) {
case 'admin/help#contact':
$output = sprintf('<p>%s</p><p>%s</p><p>%s</p>', t('The contact module enables the use of both personal and site-wide contact forms, thereby facilitating easy communication within the community. While personal contact forms allow users to contact each other by e-mail, site-wide forms allow community members to contact the site administration from a central location. Users can specify a subject and message in the contact form, and also request that a copy of the e-mail be sent to their own address.'), t("Users can activate/deactivate their personal contact forms in their account settings. Upon activation, a contact tab will appear in their user profiles. Privileged users such as site administrators are able to contact users even if they have chosen not to enable this feature."), t('Contact module links:'));
$output .= sprintf('<ul><li>%s</li><li>%s</li><li>%s</li></ul>', t('Default site-wide <a href="%contact-page">contact page</a>.', array('%contact-page' => url('contact'))), t('Site-wide contact form <a href="%configuration-page">category configuration</a>.', array('%configuration-page' => url('admin/contact'))), t('Site-wide contact form <a href="%additional-settings">general settings</a>.', array('%additional-settings' => url('admin/settings/contact'))));
$output .= t('For more information, please read the configuration and customization handbook page for the <a href="%contact">Contact module</a>.', array('%contact' => url('http://drupal.org/handbook/modules/contact/', NULL, NULL, TRUE)));
$output = '<p>'. t('The contact module enables the use of both personal and site-wide contact forms, thereby facilitating easy communication within the community. While personal contact forms allow users to contact each other by e-mail, site-wide forms allow community members to contact the site administration from a central location. Users can specify a subject and message in the contact form, and also request that a copy of the e-mail be sent to their own address.') .'</p>';
$output .= '<p>'. t("Users can activate/deactivate their personal contact forms in their account settings. Upon activation, a contact tab will appear in their user profiles. Privileged users such as site administrators are able to contact users even if they have chosen not to enable this feature.") .'</p>';
$output .= '<p>'. t('If the menu module is enabled, a menu item linking to the site-wide contact page is added to the navigation block. It is disabled by default, but can be enabled via the <a href="%menu-module">menu management</a> page. Links to the contact page may also be added to the primary and secondary links using the same page.', array('%menu-module' => url('admin/menu'))) .'</p>';
$output .= t('Contact module links:') .'<ul>';
$output .= '<li>'. t('Default site-wide <a href="%contact-page">contact page</a>.', array('%contact-page' => url('contact'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%configuration-page">category configuration</a>.', array('%configuration-page' => url('admin/contact'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%additional-settings">general settings</a>.', array('%additional-settings' => url('admin/contact/settings'))) .'</li>';
$output .= '<li>'. t('Site-wide contact form <a href="%menu-configuration">menu configuration</a>.', array('%menu-configuration' => url('admin/menu'))) .'</li></ul>';
$output .= t('For more information, please read the configuration and customization handbook page for the <a href="%contact">contact module</a>.', array('%contact' => url('http://drupal.org/handbook/modules/contact/', NULL, NULL, TRUE)));
return $output;
case 'admin/modules#description':
return t('Enables the use of both personal and site-wide contact forms.');
case 'admin/contact':
return t('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="%settings">settings page</a> you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('%settings' => url('admin/settings/contact'), '%form' => url('contact')));
$output = t('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="%settings">settings page</a>, you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('%settings' => url('admin/contact/settings'), '%form' => url('contact')));
if (!module_exist('menu')) {
$menu_note = t('The menu item can be customized and configured only once the menu module has been <a href="%modules-page">enabled</a>.', array('%modules-page' => url('admin/modules')));
}
else {
$menu_note = '';
}
$output .= '<p>'. t('The contact module also adds a <a href="%menu-settings">menu item</a> (disabled by default) to the navigation block.', array('%menu-settings' => url('admin/menu'))) .' '. $menu_note .'</p>';
return($output);
}
}
......@@ -27,27 +41,57 @@ function contact_help($section) {
* Implementation of hook_menu().
*/
function contact_menu($may_cache) {
global $user;
$items = array();
if ($may_cache) {
$items[] = array('path' => 'contact', 'title' => t('contact'),
'callback' => 'contact_mail_page', 'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM);
$items[] = array('path' => 'admin/contact', 'title' => t('contact form'),
'callback' => 'contact_admin', 'access' => user_access('administer site configuration'));
$items[] = array('path' => 'admin/contact/list', 'title' => t('list'),
'callback' => 'contact_admin', 'access' => user_access('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
$items[] = array('path' => 'admin/contact/add', 'title' => t('add category'),
'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/contact/edit', 'title' => t('edit contact category'),
'callback' => 'contact_admin_edit', 'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/contact/delete', 'title' => t('delete contact'),
'callback' => 'contact_admin_delete', 'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/contact',
'title' => t('contact form'),
'callback' => 'contact_admin_categories',
'access' => user_access('administer site configuration'),
);
$items[] = array('path' => 'admin/contact/category',
'title' => t('categories'),
'callback' => 'contact_admin_categories',