Auto-configure contact form

webchick - May 14, 2007 - 03:49
Project:Drupal.org Testing
Version:5.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The Primary Links patch brought to light that we're not initializing any of the content that the menu items are pointing to. This issue is about auto-populating the contact form.

#1

webchick - May 14, 2007 - 04:04
Status:active» needs work

Not sure why this doesn't work, but it should be pretty close:

<?php
function _drupalorg_testing_configure_settings() {
 
$values = array (
   
'category' => 'Problems with this website',
   
'recipients' => 'webmasters@localhost',
   
'reply' => 'Thank you for contacting us!
 
  To discuss Drupal.org related issues, use the "Drupal.org infrastructure forum" at <a href="http://drupal.org/forum/12" title="http://drupal.org/forum/12" rel="nofollow">http://drupal.org/forum/12</a>. 
 
  If you encountered a problem on or with drupal.org that needs the attention of the website maintainers, please submit an issue to the "Drupal.org maintenance project" at <a href="http://drupal.org/project/issues/3202.
" title="http://drupal.org/project/issues/3202.
" rel="nofollow">http://drupal.org/project/issues/3202.
</a> 
  Thanks,
 
  --
  Drupal.org maintenance team'
,
   
'weight' => '-1',
   
'selected' => '0',
   
'cid' => 0,
  );

 
drupal_execute('contact_admin_edit', $values);

 
 
$values = array (
   
'category' => 'General inquiry (other)',
   
'recipients' => 'info@localhost',
   
'reply' => 'Thanks for contacting us. 
 
  Note that Drupal is not a commercial product and that drupal.org is run by volunteers.  As such, we do NOT provide support by e-mail.  All support or information requests should go through the official support channels found at <a href="http://drupal.org/support/" title="http://drupal.org/support/" rel="nofollow">http://drupal.org/support/</a>.  If your question is a support question, please ask your question in the forums at drupal.org, the support channel on IRC or the support mailing list.  Consult the services page at <a href="http://drupal.org/services/" title="http://drupal.org/services/" rel="nofollow">http://drupal.org/services/</a> if you are looking for commercial support.  Thanks.'
,
   
'weight' => '0',
   
'selected' => '0',
   
'cid' => 0,
  );
 
drupal_execute('contact_admin_edit', $values);

}
?>

#2

sirkitree - June 5, 2008 - 22:21
Version:<none>» 5.x-1.x-dev

anyone ever figure this out? I'm trying something similar, using macro module to try and create categories and change settings, but it looks like contact module does some arg() checking in the _submit handler and that is why the INSERT is not happening.

#3

aclight - October 12, 2008 - 17:10
Status:needs work» needs review

@sirkitree: Thanks for the information.

Attached patch successfully creates contact information and is based on webchick's code in comment 1. It gets around the problem in contact_admin_edit_submit() by doing direct db manipulation. I wrote an extensive comment about why it's necessary and also noted that I don't believe this will be necessary in the D6 version of the profile, as it looks like contact_admin_edit_submit() no longer uses arg().

Those of you with eagle eyes and who read the messages after installation might notice that the following looks a bit weird:

# Category Problems with this website has been updated.
# Category Problems with this website has been added.
# Category General inquiry (other) has been updated.
# Category General inquiry (other) has been added.

Mainly that the contact is updated before it is added. This again is due to the strange behavior in contact_admin_edit_submit(), and the call to drupal_set_message() that says a contact has been updated isn't dependent on the contact actually being added in the db_query() call in the line above.

I don't think there's any way around this unless we go without calling drupal_execute() at all in the D5 version of the profile. Personally, I would say to just live with those messages looking a bit strange for now.

AttachmentSize
143806_dot_contact_form_3.patch 4.09 KB
 
 

Drupal is a registered trademark of Dries Buytaert.