function mass_contact_admin_edit_submit in Mass Contact 5
Same name and namespace in other branches
- 5.2 mass_contact.module \mass_contact_admin_edit_submit()
- 6 mass_contact.module \mass_contact_admin_edit_submit()
- 7 mass_contact.admin.inc \mass_contact_admin_edit_submit()
Process the mass_contact category edit page form submission.
File
- ./
mass_contact.module, line 185 - Enables mass contact form to selected roles.
Code
function mass_contact_admin_edit_submit($form_id, $form_values) {
if ($form_values['selected']) {
// Unselect all other contact categories.
db_query('UPDATE {mass_contact} SET selected = 0');
}
//remove 0s for unselected roles, convert to csv
$recipients = $form_values['recipients'];
// if all authenticated users are already added, remove all roles
if ($recipients[2] == 2) {
foreach ($recipients as $checkr) {
if ($checkr > 2) {
$recipients[$checkr] = 0;
}
}
}
// remove roles that were not selected
foreach ($recipients as $recip) {
if ($recip != 0) {
$newformrec[] = $recip;
}
}
$form_values['recipients'] = implode(',', $newformrec);
if (arg(3) == 'add') {
db_query("INSERT INTO {mass_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' => $form_values['category'],
)));
watchdog('mass_contact', t('Mass Contact form: category %category added.', array(
'%category' => $form_values['category'],
)), WATCHDOG_NOTICE, l(t('view'), 'admin/build/mass_contact'));
}
else {
db_query("UPDATE {mass_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' => $form_values['category'],
)));
watchdog('mass_contact', t('Mass Contact form: category %category updated.', array(
'%category' => $form_values['category'],
)), WATCHDOG_NOTICE, l(t('view'), 'admin/build/mass_contact'));
}
return 'admin/build/mass_contact';
}