'#description'=>t("Example: 'website feedback' or 'product information'."),
'#required'=>TRUE,
);
$form['recipients']=array('#type'=>'textarea',
'#title'=>t('Recipients'),
'#default_value'=>$contact['recipients'],
'#description'=>t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com'. To specify multiple recipients, separate each e-mail address with a comma."),
'#required'=>TRUE,
);
$form['reply']=array('#type'=>'textarea',
'#title'=>t('Auto-reply'),
'#default_value'=>$contact['reply'],
'#description'=>t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
);
$form['weight']=array('#type'=>'weight',
'#title'=>t('Weight'),
'#default_value'=>$contact['weight'],
'#description'=>t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
);
$form['selected']=array('#type'=>'select',
'#title'=>t('Selected'),
'#options'=>array('0'=>t('No'),'1'=>t('Yes')),
'#default_value'=>$contact['selected'],
'#description'=>t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
);
$form['cid']=array('#type'=>'value',
'#value'=>$contact['cid'],
);
$form['submit']=array('#type'=>'submit',
'#value'=>t('Submit'),
);
return$form;
}
/**
* Validate the contact category edit page form submission.
returnconfirm_form($form,t('Are you sure you want to delete %category?',array('%category'=>$contact['category'])),'admin/build/contact',t('This action cannot be undone.'),t('Delete'),t('Cancel'));
'#default_value'=>variable_get('contact_form_information',t('You can leave a message using the contact form below.')),
'#description'=>t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.',array('@form'=>url('contact'))),
$edit=db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d",$cid));
}
else{
$edit=array(
'category'=>'',
'recipients'=>'',
'reply'=>'',
'weight'=>0,
'selected'=>0,
'cid'=>NULL,
);
}
$form['category']=array('#type'=>'textfield',
'#title'=>t('Category'),
'#maxlength'=>255,
'#default_value'=>$edit['category'],
'#description'=>t("Example: 'website feedback' or 'product information'."),
'#required'=>TRUE,
);
$form['recipients']=array('#type'=>'textarea',
'#title'=>t('Recipients'),
'#default_value'=>$edit['recipients'],
'#description'=>t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com'. To specify multiple recipients, separate each e-mail address with a comma."),
'#required'=>TRUE,
);
$form['reply']=array('#type'=>'textarea',
'#title'=>t('Auto-reply'),
'#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['weight']=array('#type'=>'weight',
'#title'=>t('Weight'),
'#default_value'=>$edit['weight'],
'#description'=>t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
);
$form['selected']=array('#type'=>'select',
'#title'=>t('Selected'),
'#options'=>array('0'=>t('No'),'1'=>t('Yes')),
'#default_value'=>$edit['selected'],
'#description'=>t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
);
$form['cid']=array('#type'=>'value',
'#value'=>$edit['cid'],
);
$form['submit']=array('#type'=>'submit',
'#value'=>t('Submit'),
);
return$form;
}
/**
* Validate the contact category edit page form submission.
if($info=db_fetch_object(db_query("SELECT category FROM {contact} WHERE cid = %d",$cid))){
$form['category']=array('#type'=>'value',
'#value'=>$info->category,
);
returnconfirm_form($form,t('Are you sure you want to delete %category?',array('%category'=>$info->category)),'admin/build/contact',t('This action cannot be undone.'),t('Delete'),t('Cancel'));
}
else{
drupal_set_message(t('Category not found.'),'error');
'#default_value'=>variable_get('contact_form_information',t('You can leave a message using the contact form below.')),
'#description'=>t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.',array('@form'=>url('contact'))),
'#description'=>t('Default status of the personal contact form for new users.'),
);
returnsystem_settings_form($form);
}
/**
* Personal contact page.
*/
functioncontact_user_page($account){
global$user;
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")));
$output=t('You cannot contact more than %number users per hour. Please try again later.',array('%number'=>variable_get('contact_hourly_threshold',3)));
$output=t("You cannot send more than %number messages per hour. Please try again later.",array('%number'=>variable_get('contact_hourly_threshold',3)));
}
else{
$output=drupal_get_form('contact_mail_page');
}
return$output;
}
functioncontact_mail_page(){
global$user;
$result=db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');
while($category=db_fetch_object($result)){
$categories[$category->cid]=$category->category;
if($category->selected){
$default_category=$category->cid;
}
}
if(count($categories)>0){
$form['#token']=$user->name.$user->mail;
$form['contact_information']=array('#value'=>filter_xss_admin(variable_get('contact_form_information',t('You can leave a message using the contact form below.'))));
$form['name']=array('#type'=>'textfield',
'#title'=>t('Your name'),
'#maxlength'=>255,
'#default_value'=>$user->uid?$user->name:'',
'#required'=>TRUE,
);
$form['mail']=array('#type'=>'textfield',
'#title'=>t('Your e-mail address'),
'#maxlength'=>255,
'#default_value'=>$user->uid?$user->mail:'',
'#required'=>TRUE,
);
$form['subject']=array('#type'=>'textfield',
'#title'=>t('Subject'),
'#maxlength'=>255,
'#required'=>TRUE,
);
if(count($categories)>1){
// If there is more than one category available and no default category has been selected,
// prepend a default placeholder value.
if(!isset($default_category)){
$categories=array(t('--'))+$categories;
}
$form['cid']=array('#type'=>'select',
'#title'=>t('Category'),
'#default_value'=>$default_category,
'#options'=>$categories,
'#required'=>TRUE,
);
}
else{
// If there is only one category, store its cid.
$category_keys=array_keys($categories);
$form['cid']=array('#type'=>'value',
'#value'=>array_shift($category_keys),
);
}
$form['message']=array('#type'=>'textarea',
'#title'=>t('Message'),
'#required'=>TRUE,
);
// We do not allow anonymous users to send themselves a copy
// because it can be abused to spam people.
if($user->uid){
$form['copy']=array('#type'=>'checkbox',
'#title'=>t('Send yourself a copy.'),
);
}
$form['submit']=array('#type'=>'submit',
'#value'=>t('Send e-mail'),
);
}
else{
drupal_set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.',array('@add'=>url('admin/build/contact/add'))),'error');