function nmoderation_moderation_form_submit($form_id, $form_values) { global $user; $content_type = $form_values['content_type']; $content_id = $form_values['content_id']; $value = $form_values['value']; $vote_id = $form_values['vote_id']; if ($vote_id) { // There's already a vote, we're editing. $vote = db_fetch_object(db_query("SELECT * FROM {votingapi_vote} WHERE vote_id=%d", $vote_id)); if ($vote->uid != $user->uid) { $account = user_load(array('uid' => $vote->uid)); } else { $account = $user; } } // Use the existing types, or the defaults if there was no original vote. $vote->tag = $vote->tag ? $vote->tag : NMODERATION_TAG; $vote->value_type = $vote->value_type ? $vote->value_type : NMODERATION_VOTE_TYPE; $vote->value = $value; votingapi_set_vote($content_type, $content_id, $vote, $account); nmoderation_set_promote($content_id, $content_type); if ($vote_id) { drupal_set_message(t('Vote edited.')); } else { drupal_set_message(t('Vote added.')); } }