function contact_mail_user in Drupal 4
Same name and namespace in other branches
- 5 modules/contact/contact.module \contact_mail_user()
- 6 modules/contact/contact.pages.inc \contact_mail_user()
Personal contact page.
1 string reference to 'contact_mail_user'
- contact_menu in modules/
contact.module - Implementation of hook_menu().
File
- modules/
contact.module, line 298 - Enables the use of personal and site-wide contact forms.
Code
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();
}
}