function mail_debugger_callback in Mail Debugger 7.2
Same name and namespace in other branches
- 7.3 includes/mail_debugger.callback.inc \mail_debugger_callback()
- 7 includes/mail_debugger.callback.inc \mail_debugger_callback()
Callback for drupal_get_form
_state
Parameters
array $form:
Return value
array
1 string reference to 'mail_debugger_callback'
- mail_debugger_menu in ./
mail_debugger.module - Implement hook_menu()
File
- includes/
mail_debugger.callback.inc, line 10
Code
function mail_debugger_callback($form, &$form_state) {
// basic form setup
$form = array(
'#tree' => TRUE,
'tab_group' => array(
'#type' => 'vertical_tabs',
'#default_tab' => user_variable_get('mail_debugger_default_tab'),
),
);
// add user section of the form
$form['user'] = array(
'#type' => 'fieldset',
'#title' => t('User'),
'#group' => 'tab_group',
'mail' => array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#default_value' => user_variable_get('mail_debugger_user_mail'),
'#autocomplete_path' => 'admin/config/development/mail_debugger/autocomplete_mail',
),
'type' => array(
'#type' => 'select',
'#title' => t('Message'),
'#options' => array(
'register_admin_created' => t('Welcome message for user created by the admin.'),
'register_no_approval_required' => t('Welcome message when user self-registers.'),
'register_pending_approval' => t('Welcome message, user pending admin approval.'),
'status_activated' => t('Account activated.'),
'status_blocked' => t('Account blocked.'),
'password_reset' => t('Password recovery request.'),
'cancel_confirm' => t('Account cancellation request.'),
'status_canceled' => t('Account canceled.'),
),
'#default_value' => user_variable_get('mail_debugger_user_type'),
),
'submit' => array(
'#type' => 'submit',
'#name' => 'user_mail',
'#value' => t('Send mail'),
'#submit' => array(
'mail_debugger_callback_submit_user_mail',
'mail_debugger_callback_submit',
),
'#validate' => array(
'mail_debugger_callback_valid_user_mail',
),
),
);
// Add our favorite! The plain old mail machine feature :-)
$form['custom'] = array(
'#type' => 'fieldset',
'#title' => t('Custom mail'),
'#group' => 'tab_group',
'#collapsed' => TRUE,
'to' => array(
'#type' => 'textfield',
'#title' => t('To'),
'#default_value' => user_variable_get('mail_debugger_custom_to'),
),
'subject' => array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => user_variable_get('mail_debugger_custom_subject'),
),
'body' => array(
'#type' => 'textarea',
'#title' => t('Message'),
'#default_value' => user_variable_get('mail_debugger_custom_body'),
),
'submit' => array(
'#type' => 'submit',
'#name' => 'custom_mail',
'#value' => t('Send mail'),
'#submit' => array(
'mail_debugger_callback_submit_custom_mail',
'mail_debugger_callback_submit',
),
'#validate' => array(
'mail_debugger_callback_valid_custom_mail',
),
),
);
// which modules implement hook_mail?
$modules = module_implements('mail');
$contributed_modules = array();
// loop and add to list of candidates
foreach ($modules as $module) {
// Find the human readable name
$filename = drupal_get_path('module', $module) . "/{$module}.info";
$info = drupal_parse_info_file($filename);
// add to the list of candidates
$contributed_modules[$module] = $info['package'] . ' | ' . $info['name'];
}
// I know... I know... there are allways modules that implement it, but
// you just can't asume anything when doing PHP...
if (count($contributed_modules)) {
// sort the values
asort($contributed_modules);
// add the module system name... for the geeks among us.
foreach ($contributed_modules as $module => $name) {
$contributed_modules[$module] = $name . ' (' . $module . ')';
}
// add contrib section of the form.
$form['contrib'] = array(
'#type' => 'fieldset',
'#title' => t('Contrib'),
'#group' => 'tab_group',
'#collapsed' => TRUE,
'info' => array(
'#markup' => '<p><big style="font-weight: bold;">Expirimental feature!</big></p>',
),
'to' => array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#default_value' => user_variable_get('mail_debugger_contrib_to'),
),
'module' => array(
'#type' => 'select',
'#title' => t('Module'),
'#default_value' => user_variable_get('mail_debugger_contrib_module'),
'#options' => $contributed_modules,
),
'key' => array(
'#type' => 'textfield',
'#title' => t('Mail key'),
'#default_value' => user_variable_get('mail_debugger_contrib_key'),
),
'param' => array(
'#type' => 'textarea',
'#title' => t('Param argument'),
'#description' => "PHP code to populate the \$param argument. do not use a <?php opening tag and return an array().",
'#default_value' => user_variable_get('mail_debugger_contrib_param'),
),
'language' => array(
'#type' => 'textfield',
'#title' => t('Language'),
'#default_value' => user_variable_get('mail_debugger_contrib_language'),
),
'from' => array(
'#type' => 'textfield',
'#title' => t('From'),
'#default_value' => user_variable_get('mail_debugger_contrib_from'),
),
'send' => array(
'#type' => 'checkbox',
'#title' => t('Send mail'),
'#default_value' => user_variable_get('mail_debugger_contrib_send'),
),
'submit' => array(
'#type' => 'submit',
'#name' => 'contrib_mail',
'#value' => t('Carefull please'),
'#submit' => array(
'mail_debugger_callback_submit_contrib_mail',
'mail_debugger_callback_submit',
),
'#validate' => array(
'mail_debugger_callback_valid_contrib_mail',
),
),
);
}
return $form;
}