Closed (fixed)
Project:
OG Contact
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2008 at 02:57 UTC
Updated:
18 Mar 2009 at 05:20 UTC
My client wanted the ability to add custom introductory text to the contact form for a group.
I created a new field for each group contact form
Index: modules/og_contact/og_contact.install
===================================================================
@@ -31,6 +31,21 @@
/**
* Implementation(s) of hook_update_N().
*/
+function og_contact_update_5003() {
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql("ALTER TABLE {og_contact} ADD intro longtext");
+ case 'pgsql':
+ // $ret[] = update_sql("ALTER TABLE {og_contact} ADD COLUMN notpublic numeric(2) NOT NULL DEFAULT 0");
+ break;
+ }
+ return $ret;
+}
+
+/**
+ * Implementation(s) of hook_update_N().
+ */
and altered the edit form and form display to show the intro text if present
Index: modules/og_contact/og_contact.module
===================================================================
@@ -262,6 +263,14 @@
'#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['intro'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Form introduction'),
+ '#default_value' => $edit['intro'],
+ '#description' => t('Introductory text to be displayed above the contact form for this group.'),
+ );
+
$form['return'] = array('#type' => 'hidden',
'#value' => $return,
);
@@ -304,7 +313,7 @@
function og_contact_admin_edit_submit($form_id, $form_values) {
$name = og_contact_get_group_name($form_values['group']);
drupal_set_title('Edit '.$name.'\'s Contact');
- db_query("UPDATE {og_contact} SET reply = '%s', noadmin = %d, recipients = '%s' WHERE gid = %d", $form_values['reply'], $form_values['no_admin'], $form_values['recipients'], $form_values['group']);
+ db_query("UPDATE {og_contact} SET reply = '%s', noadmin = %d, recipients = '%s', intro = '%s' WHERE gid = %d", $form_values['reply'], $form_values['no_admin'], $form_values['recipients'], $form_values['intro'], $form_values['group']);
drupal_set_message(t('Contact form for %group has been updated.', array('%group' => $name)));
watchdog('mail', t('OG Contact: Form for %group updated.', array('%group' => $name)), WATCHDOG_NOTICE, l(t('view'), 'admin/og/contact'));
if ($form_values['return'] == 'admin') {
@@ -423,6 +432,17 @@
if ($gid && og_contact_group_has_form($gid) == TRUE && arg(2) == 'contact') {
$form['#token'] = $user->name . $user->mail;
$form['og_contact_information'] = array('#value' => $edit . filter_xss_admin(variable_get('og_contact_form_information', t('You can leave a message using the contact form below.'))));
+
+ // Get group contact info
+ $group_contact = db_fetch_object(db_query("SELECT * FROM {og_contact} WHERE gid = %d", $gid));
+ if (!empty($group_contact->intro)) {
+ $form['intro'] = array(
+ '#value' => filter_xss_admin($group_contact->intro),
+ );
+ }
+
$form['name'] = array('#type' => 'textfield',
'#title' => t('Your name'),
'#maxlength' => 255,
Comments
Comment #1
gnat commentedThis patch is lots of good work in the right direction. There's a few important pieces that I think are missing.
I'm thinking that there needs to be some configuration options on the main admin settings page. Custom intros must be able to be turned off, site wide and per group. There should be the ability to write a default intro text, and optionally fall back to it if the group doesn't have one. Another possible thing to offer site admins is the ability to not let group admins edit the intro even if they can edit the rest of the form.
With these changes this feature will be generic enough to cover several different use cases for this module.
I definitely like the idea of this patch, and its a good base for the building this feature into OG Contact.
Comment #2
gnat commentedThis feature is part of the D6 version of OG Contact.