returnt('Enables the use of personal contact forms.');
returnt('Enables the use of both personal and site-wide contact forms.');
case'admin/contact':
returnt('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more subjects. You can associate different recipients with each subject 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',NULL,NULL,TRUE)));
}
}
...
...
@@ -26,7 +28,23 @@ function contact_menu($may_cache) {
@@ -36,6 +54,14 @@ function contact_menu($may_cache) {
return$items;
}
/**
* Implementation of hook_settings().
*/
functioncontact_settings(){
$output=form_textarea(t('Additional information'),'contact_form_information',variable_get('contact_form_information',t('You can leave us a message using the contact form below.')),70,8,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'))));
return$output;
}
/**
* Implementation of hook_user().
*
...
...
@@ -106,7 +132,7 @@ function contact_mail_user() {
// Log the operation:
flood_register_event('contact');
watchdog('mail',t('%name-from sent %name-to an e-mail.',array('%name-from'=>$user->name,'%name-to'=>$account->name)));
watchdog('mail',t('%name-from sent %name-to an e-mail.',array('%name-from'=>theme('placeholder',$user->name),'%name-to'=>theme('placeholder',$account->name))));
// Set a status message:
drupal_set_message(t('Your message has been sent.'));
...
...
@@ -134,4 +160,150 @@ function contact_mail_user() {
}
}
functioncontact_admin_edit($subject=NULL){
if(isset($_POST['edit'])){
$edit=$_POST['edit'];
if(empty($edit['subject'])){
form_set_error('subject',t('You must enter a subject.'));
}
if(empty($edit['recipients'])){
form_set_error('recipients',t('You must enter one or more recipients.'));
}
if(!form_get_errors()){
db_query("DELETE FROM {contact} WHERE subject = '%s'",$subject);
db_query("INSERT INTO {contact} (subject, recipients, reply) VALUES ('%s', '%s', '%s')",$edit['subject'],$edit['recipients'],$edit['reply']);
drupal_goto('admin/contact');
}
}
$subject=db_fetch_object(db_query("SELECT * FROM {contact} WHERE subject = '%s'",$subject));
$form=form_textfield(t('Subject'),'subject',$subject->subject,50,255,t("Example: 'website feedback' or 'product information'."),NULL,TRUE);
$form.=form_textarea(t('Recipients'),'recipients',$subject->recipients,50,4,t("Example: 'webmaster@yoursite.com' or 'sales@yoursite.com'. To specify multiple repecients, separate each e-mail address with a comma."),NULL,TRUE);
$form.=form_textarea(t('Auto-reply'),'reply',$subject->reply,50,10,t("Optional auto-reply. Leave empty if you don't want to send the user an auto-reply message."));
$form.=form_submit(t('Submit'));
printtheme('page',form($form));
}
functioncontact_admin_delete($subject){
if($_POST['op']!=t('Delete')){
printtheme('page',theme('confirm',
t('Are you sure you want to delete %subject?',array('%subject'=>theme('placeholder',$subject))),
'admin/contact/delete/'.$subject,
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')));
}
else{
db_query("DELETE FROM {contact} WHERE subject = '%s'",$subject);
drupal_goto('admin/contact');
}
}
functioncontact_admin(){
$result=db_query('SELECT subject, recipients FROM {contact} ORDER BY subject');
watchdog('mail',t('%name-from sent an e-mail regarding %subject.',array('%name-from'=>theme('placeholder',$edit['name']." <$from>"),'%subject'=>theme('placeholder',$contact->subject))));
// Set a status message:
drupal_set_message(t('Your message has been sent.'));
// Jump to home page:
drupal_goto();
}
}
else{
$edit['name']=$user->name;
$edit['mail']=$user->mail;
}
$result=db_query('SELECT subject FROM contact ORDER BY subject');
while($subject=db_fetch_object($result)){
$subjects[$subject->subject]=$subject->subject;
}
if($subjects){
$output=variable_get('contact_form_information',t('You can leave us a message using the contact form below.'));
returnt('Enables the use of personal contact forms.');
returnt('Enables the use of both personal and site-wide contact forms.');
case'admin/contact':
returnt('This page lets you setup <a href="%form">your site-wide contact form</a>. To do so, add one or more subjects. You can associate different recipients with each subject 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',NULL,NULL,TRUE)));
}
}
...
...
@@ -26,7 +28,23 @@ function contact_menu($may_cache) {
@@ -36,6 +54,14 @@ function contact_menu($may_cache) {
return$items;
}
/**
* Implementation of hook_settings().
*/
functioncontact_settings(){
$output=form_textarea(t('Additional information'),'contact_form_information',variable_get('contact_form_information',t('You can leave us a message using the contact form below.')),70,8,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'))));
return$output;
}
/**
* Implementation of hook_user().
*
...
...
@@ -106,7 +132,7 @@ function contact_mail_user() {
// Log the operation:
flood_register_event('contact');
watchdog('mail',t('%name-from sent %name-to an e-mail.',array('%name-from'=>$user->name,'%name-to'=>$account->name)));
watchdog('mail',t('%name-from sent %name-to an e-mail.',array('%name-from'=>theme('placeholder',$user->name),'%name-to'=>theme('placeholder',$account->name))));
// Set a status message:
drupal_set_message(t('Your message has been sent.'));
...
...
@@ -134,4 +160,150 @@ function contact_mail_user() {
}
}
functioncontact_admin_edit($subject=NULL){
if(isset($_POST['edit'])){
$edit=$_POST['edit'];
if(empty($edit['subject'])){
form_set_error('subject',t('You must enter a subject.'));
}
if(empty($edit['recipients'])){
form_set_error('recipients',t('You must enter one or more recipients.'));
}
if(!form_get_errors()){
db_query("DELETE FROM {contact} WHERE subject = '%s'",$subject);
db_query("INSERT INTO {contact} (subject, recipients, reply) VALUES ('%s', '%s', '%s')",$edit['subject'],$edit['recipients'],$edit['reply']);
drupal_goto('admin/contact');
}
}
$subject=db_fetch_object(db_query("SELECT * FROM {contact} WHERE subject = '%s'",$subject));
$form=form_textfield(t('Subject'),'subject',$subject->subject,50,255,t("Example: 'website feedback' or 'product information'."),NULL,TRUE);
$form.=form_textarea(t('Recipients'),'recipients',$subject->recipients,50,4,t("Example: 'webmaster@yoursite.com' or 'sales@yoursite.com'. To specify multiple repecients, separate each e-mail address with a comma."),NULL,TRUE);
$form.=form_textarea(t('Auto-reply'),'reply',$subject->reply,50,10,t("Optional auto-reply. Leave empty if you don't want to send the user an auto-reply message."));
$form.=form_submit(t('Submit'));
printtheme('page',form($form));
}
functioncontact_admin_delete($subject){
if($_POST['op']!=t('Delete')){
printtheme('page',theme('confirm',
t('Are you sure you want to delete %subject?',array('%subject'=>theme('placeholder',$subject))),
'admin/contact/delete/'.$subject,
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')));
}
else{
db_query("DELETE FROM {contact} WHERE subject = '%s'",$subject);
drupal_goto('admin/contact');
}
}
functioncontact_admin(){
$result=db_query('SELECT subject, recipients FROM {contact} ORDER BY subject');
watchdog('mail',t('%name-from sent an e-mail regarding %subject.',array('%name-from'=>theme('placeholder',$edit['name']." <$from>"),'%subject'=>theme('placeholder',$contact->subject))));
// Set a status message:
drupal_set_message(t('Your message has been sent.'));
// Jump to home page:
drupal_goto();
}
}
else{
$edit['name']=$user->name;
$edit['mail']=$user->mail;
}
$result=db_query('SELECT subject FROM contact ORDER BY subject');
while($subject=db_fetch_object($result)){
$subjects[$subject->subject]=$subject->subject;
}
if($subjects){
$output=variable_get('contact_form_information',t('You can leave us a message using the contact form below.'));