contact_mail_user
- Versions
- 4.6 – 4.7
contact_mail_user()- 5
contact_mail_user($recipient)- 6
contact_mail_user(&$form_state, $recipient)
Personal contact page.
Code
modules/contact.module, line 298
<?php
function contact_mail_user() {
global $user;
if ($account = user_load(array('uid' => arg(1)))) {
$admin_access = user_access('administer users');
if (!$account->status && !$admin_access) {
drupal_access_denied();
}
else if (!$account->contact && !$admin_access) {
$output = t('%name is not accepting e-mails.', array('%name' => check_plain($account->name)));
}
else if (!$user->uid) {
$output = t('Please <a href="%login">login</a> or <a href="%register">register</a> to send %name a message.', array('%login' => url('user/login'), '%register' => url('user/register'), '%name' => check_plain($account->name)));
}
else if (!valid_email_address($user->mail)) {
$output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="%url">user information</a> and try again.', array('%url' => url("user/$user->uid/edit")));
}
else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
$output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
}
else {
drupal_set_title(check_plain($account->name));
$form['#token'] = $user->name . $user->mail;
$form['from'] = array('#type' => 'item',
'#title' => t('From'),
'#value' => check_plain($user->name) .' <'. $user->mail .'>',
);
$form['to'] = array('#type' => 'item',
'#title' => t('To'),
'#value' => check_plain($account->name),
);
$form['subject'] = array('#type' => 'textfield',
'#title' => t('Subject'),
'#maxlength' => 50,
'#required' => TRUE,
);
$form['message'] = array('#type' => 'textarea',
'#title' => t('Message'),
'#rows' => 15,
'#required' => TRUE,
);
$form['copy'] = array('#type' => 'checkbox',
'#title' => t('Send me a copy.'),
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Send e-mail'),
);
$output = drupal_get_form('contact_mail_user', $form);
}
return $output;
}
else {
drupal_not_found();
}
}
?>Login or register to post comments 