function guestbook_form_entry_form in Guestbook 6.2
Same name and namespace in other branches
- 5.2 guestbook.module \guestbook_form_entry_form()
- 5 guestbook.module \guestbook_form_entry_form()
- 6 guestbook.module \guestbook_form_entry_form()
- 7.2 guestbook.module \guestbook_form_entry_form()
Form builder function for guestbook post form.
2 string references to 'guestbook_form_entry_form'
- guestbook_form_entry in ./
guestbook.module - Retrieve a guestbook post form.
- guestbook_page in ./
guestbook.module - Output a guestbook page; menu callback.
File
- ./
guestbook.module, line 441
Code
function guestbook_form_entry_form($form_state, $uid, $display = '', $entry_id = NULL) {
global $user;
$entry = array();
if (isset($entry_id) && _guestbook_access('moderate', $uid) && user_access('moderate own guestbook')) {
$entry = db_fetch_array(db_query("SELECT * FROM {guestbook} WHERE id = %d", $entry_id));
}
$form = array();
if (!empty($entry)) {
$form['entry_id'] = array(
'#type' => 'value',
'#value' => $entry['id'],
);
$form['author'] = array(
'#type' => 'value',
'#value' => $entry['author'],
);
// Re-route form submission to guestbook entry edit form submit handler.
$form['#submit'] = array(
'guestbook_form_entry_form_edit_submit',
);
}
// Fields for anonymous users.
$anonymous_fields_access = !$user->uid || isset($entry['author']) && $entry['author'] == 0;
$anonymous_fields = (array) variable_get('guestbook_anonymous_fields', array(
'email',
'website',
));
$form['anonname'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#required' => TRUE,
'#default_value' => !empty($entry['anonname']) ? $entry['anonname'] : '',
'#size' => 32,
'#maxlength' => 64,
'#access' => $anonymous_fields_access,
);
$form['anonemail'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#default_value' => !empty($entry['anonemail']) ? $entry['anonemail'] : '',
'#size' => 32,
'#maxlength' => 128,
'#access' => $anonymous_fields_access && in_array('email', $anonymous_fields),
);
$form['anonwebsite'] = array(
'#type' => 'textfield',
'#title' => t('Homepage'),
'#default_value' => !empty($entry['anonwebsite']) ? $entry['anonwebsite'] : '',
'#size' => 32,
'#maxlength' => 128,
'#access' => $anonymous_fields_access && in_array('website', $anonymous_fields),
);
$filter_tips = variable_get('guestbook_filter_tips', TRUE) ? _guestbook_form_filter_tips() : NULL;
$form['message'] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#cols' => 32,
'#rows' => GUESTBOOK_TEXTAREA_ROWS,
'#description' => $filter_tips,
'#required' => TRUE,
'#default_value' => !empty($entry['message']) ? $entry['message'] : '',
);
$form['status'] = array(
'#type' => 'checkbox',
'#title' => t('Published'),
'#default_value' => isset($entry['status']) ? $entry['status'] : variable_get('guestbook_entry_default_status', 1),
'#access' => !empty($entry),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send'),
);
$form['uid'] = array(
'#type' => 'value',
'#value' => $uid,
);
if (!empty($entry)) {
// Need to explicitly check for moderate when editing an existing post,
// because FAPI will output a WSOD (NULL) otherwise.
$form['#access'] = _guestbook_access('moderate', $uid) ? TRUE : FALSE;
}
else {
$form['#access'] = in_array(_guestbook_access('post', $uid), array(
'allowed',
'own guestbook',
));
}
if (variable_get('guestbook_form_location', 'above') == 'separate page') {
$form['#redirect'] = !empty($_GET['destination']) ? $_GET['destination'] : guestbook_path($uid);
}
$form['display'] = array(
'#type' => 'value',
'#value' => $display,
);
return $form;
}