| 1 |
<?php |
<?php |
| 2 |
// $Id: contact_forms.module,v 1.12 2008/12/31 12:37:41 gpdinoz Exp $ |
// $Id: contact_forms.module,v 1.13 2009/10/11 05:41:04 gpdinoz Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 20 |
// Alter all contact forms except for /contact |
// Alter all contact forms except for /contact |
| 21 |
if ($form_id == 'contact_mail_page' && $path != 'contact') { |
if ($form_id == 'contact_mail_page' && $path != 'contact') { |
| 22 |
|
|
| 23 |
$category = str_replace( '_' , ' ' , arg(1)); |
$category = str_replace( array('-','_') , ' ' , arg(1)); |
| 24 |
$query = db_query("SELECT * FROM {contact} WHERE category = '%s'", $category); |
$query = db_query("SELECT * FROM {contact} WHERE LOWER(category) = LOWER('%s')", $category); |
| 25 |
$num = db_result(db_query("SELECT COUNT(*) FROM {contact} WHERE category = '%s'", $category)); |
$num = db_result(db_query("SELECT COUNT(*) FROM {contact} WHERE LOWER(category) = LOWER('%s')", $category)); |
| 26 |
//if category doesn't exist redirect to 'contact' or User Defined Page |
//if category doesn't exist redirect to 'contact' or User Defined Page |
| 27 |
if (!$num) { |
if (!$num) { |
| 28 |
drupal_goto(variable_get('contactform_redirect', 'contact')); |
drupal_goto(variable_get('contactform_redirect', 'contact')); |
| 34 |
|
|
| 35 |
$form['contact_information'] = array( |
$form['contact_information'] = array( |
| 36 |
'#type' => 'markup', |
'#type' => 'markup', |
| 37 |
'#value' => t(variable_get('contactforms_information' , 'You can send !category a message using the contact form below.') , array('!category' => $categories_data['category'])), |
'#value' => t((!$categories_data['page_info'] ? variable_get('contactforms_information' , 'You can send !category a message using the contact form below.') : $categories_data['page_info']) , array('!category' => $categories_data['category'])), |
| 38 |
); |
); |
| 39 |
|
|
| 40 |
$subject = str_replace( '_' , ' ' , arg(2)); |
$subject = str_replace( array('-','_') , ' ' , arg(2)); |
| 41 |
|
|
| 42 |
$form['subject'] = array('#type' => 'textfield', |
$form['subject'] = array('#type' => 'textfield', |
| 43 |
'#title' => t('Subject'), |
'#title' => t('Subject'), |
| 53 |
); |
); |
| 54 |
} |
} |
| 55 |
|
|
| 56 |
|
//Alter the contact Category Forms |
| 57 |
|
if($form_id == 'contact_admin_edit'){ |
| 58 |
|
$cid = $form['cid']['#value']; |
| 59 |
|
if ($cid) { |
| 60 |
|
$contact = db_fetch_object(db_query('SELECT * FROM {contact} WHERE cid = %d', $cid)); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
//Adds a text area that will hold category specific info for the contact page information |
| 64 |
|
$form['page_info'] = array( |
| 65 |
|
'#type' => 'textarea', |
| 66 |
|
'#title' => t('Additional Information'), |
| 67 |
|
'#weight' => 0, |
| 68 |
|
'#default_value' => $contact->page_info, |
| 69 |
|
'#description' => t('Information to show on the individual contact page. If this is left empty the "Default Additional Information" will be displayed'), |
| 70 |
|
); |
| 71 |
|
//Set the weight of the category name so It appears above our inserted info area |
| 72 |
|
$form['category']['#weight']='-1'; |
| 73 |
|
|
| 74 |
|
$form['selected'] = array( |
| 75 |
|
'#type' => 'hidden', |
| 76 |
|
'#value' => 0, |
| 77 |
|
); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
// Alter contact settings form |
// Alter contact settings form |
| 81 |
if ($form_id == 'contact_admin_settings') { |
if ($form_id == 'contact_admin_settings') { |
| 82 |
|
|
| 86 |
|
|
| 87 |
$form['contact_form_information'] = array( |
$form['contact_form_information'] = array( |
| 88 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 89 |
'#title' => t('Default Contact Form Additional information'), |
'#title' => t('Standard Contact Form Additional Information'), |
| 90 |
'#weight' => -1, |
'#weight' => -1, |
| 91 |
'#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')), |
'#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')), |
| 92 |
'#description' => t('Information to show on the standard <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))), |
'#description' => t('Information to show on the standard <a href="@form">contact page</a> which has the path of /contact. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))), |
| 93 |
|
|
| 94 |
); |
); |
| 95 |
|
|
| 96 |
$form['contactforms_information'] = array( |
$form['contactforms_information'] = array( |
| 97 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 98 |
'#title' => t('Contact Forms Additional information'), |
'#title' => t('Default Additional Information for the individual contact pages'), |
| 99 |
'#weight' => 0, |
'#weight' => 0, |
| 100 |
'#default_value' => variable_get('contactforms_information', t('You can send !category a message using the contact form below.')), |
'#default_value' => variable_get('contactforms_information', t('You can send !category a message using the contact form below.')), |
| 101 |
'#description' => t('Information to show on the individual <a href="!form">contact pages</a>. Can be anything from submission guidelines to your postal address or telephone number. To place the category name in your message use the wildcard "!category" e.g. You can send !category a message using the contact form below.', array('@form' => url('contact/'.$name))), |
'#description' => t('If a category doesn\'t have additional information specified this will be shown. To place the category name in your message use the wildcard "!category" e.g. You can send !category a message using the contact form below.', array('@form' => url('contact/'.$name))), |
| 102 |
); |
); |
| 103 |
|
|
| 104 |
$form['contactform_redirect'] = array( |
$form['contactform_redirect'] = array( |
| 120 |
'#description' => t('The title you would like displayed on the <a href="!form">contact page</a>. To place the category name in the title use the wildcard "!category".', array('!form' => url('contact/'.$name))), |
'#description' => t('The title you would like displayed on the <a href="!form">contact page</a>. To place the category name in the title use the wildcard "!category".', array('!form' => url('contact/'.$name))), |
| 121 |
'#required' => true, |
'#required' => true, |
| 122 |
); |
); |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
} |
} |
| 127 |
} |
} |
| 128 |
/** |
/** |
| 130 |
*/ |
*/ |
| 131 |
function contact_forms_menu_alter(&$items) { |
function contact_forms_menu_alter(&$items) { |
| 132 |
$items['contact/%'] = $items['contact']; |
$items['contact/%'] = $items['contact']; |
| 133 |
|
} |
| 134 |
|
/** |
| 135 |
|
* Implementation of hook_schema_alter |
| 136 |
|
*/ |
| 137 |
|
function contact_forms_schema_alter(&$schema) { |
| 138 |
|
// Add field to existing schema. |
| 139 |
|
$schema['contact']['fields']['page_info'] = array( |
| 140 |
|
'type' => 'text', |
| 141 |
|
'not null' => FALSE, |
| 142 |
|
'size' => 'big', |
| 143 |
|
'description' => 'Category Page Information Displayed on the individual category pages', |
| 144 |
|
); |
| 145 |
} |
} |