You are here

function guestbook_form_entry_form_edit_submit in Guestbook 6.2

Same name and namespace in other branches
  1. 5.2 guestbook.module \guestbook_form_entry_form_edit_submit()
  2. 7.2 guestbook.module \guestbook_form_entry_form_edit_submit()

Submit handler for editing guestbook entries.

1 string reference to 'guestbook_form_entry_form_edit_submit'
guestbook_form_entry_form in ./guestbook.module
Form builder function for guestbook post form.

File

./guestbook.module, line 613

Code

function guestbook_form_entry_form_edit_submit($form, &$form_state) {
  if (_guestbook_access('moderate', $form_state['values']['uid']) && $form_state['values']['submit'] == t('Send') && user_access('moderate own guestbook')) {
    if ($form_state['values']['author'] == 0) {

      // Post's author is an anonymous user.
      db_query("UPDATE {guestbook} SET status = %d, anonname = '%s', anonemail = '%s', anonwebsite = '%s', message = '%s' WHERE id = %d", $form_state['values']['status'], $form_state['values']['anonname'], $form_state['values']['anonemail'], $form_state['values']['anonwebsite'], $form_state['values']['message'], $form_state['values']['entry_id']);
    }
    else {
      if ($form_state['values']['author'] > 0) {

        // Post's author is a registered user.
        db_query("UPDATE {guestbook} SET status = %d, message = '%s' WHERE id = %d", $form_state['values']['status'], $form_state['values']['message'], $form_state['values']['entry_id']);
      }
    }
  }

  // Notify other modules of the new guestbook entry.
  $entry = db_fetch_array(db_query("SELECT * FROM {guestbook} WHERE id = %d", $form_state['values']['entry_id']));
  module_invoke_all('guestbook', 'update', $entry);
  $form_state['redirect'] = guestbook_path($form_state['values']['uid']);
  cache_clear_all();
}