function feedback_save in Feedback 7.2
Saves changes to a feedback entry or adds a new feedback entry.
Parameters
$entry: The feedback entry object to modify or add. If $entry->fid is omitted, a new entry will be added.
See also
3 calls to feedback_save()
- feedback_admin_view_form_submit in ./
feedback.admin.inc - Form submit callback for admin view form.
- feedback_entry_form_submit in ./
feedback.admin.inc - Form submit callback for entry edit form.
- feedback_form_submit in ./
feedback.module - Form submission handler for feedback_form().
File
- ./
feedback.module, line 528 - Allows site visitors and users to report issues about this site.
Code
function feedback_save($entry) {
global $user;
// Load the stored entity, if any.
if (!empty($entry->fid) && !isset($entry->original)) {
$entry->original = entity_load_unchanged('feedback', $entry->fid);
}
field_attach_presave('feedback', $entry);
// Allow modules to alter the feedback entry before saving.
module_invoke_all('feedback_presave', $entry);
module_invoke_all('entity_presave', $entry, 'feedback');
if (empty($entry->fid)) {
$entry->message = trim($entry->message);
$defaults = array(
'uid' => $user->uid,
'location_masked' => feedback_mask_path($entry->location),
'url' => url($entry->location, array(
'absolute' => TRUE,
)),
'timestamp' => REQUEST_TIME,
'useragent' => $_SERVER['HTTP_USER_AGENT'],
);
foreach ($defaults as $key => $default) {
if (!isset($entry->{$key})) {
$entry->{$key} = $default;
}
}
$status = drupal_write_record('feedback', $entry);
field_attach_insert('feedback', $entry);
module_invoke_all('feedback_insert', $entry);
module_invoke_all('entity_insert', $entry, 'feedback');
}
else {
$status = drupal_write_record('feedback', $entry, 'fid');
field_attach_update('feedback', $entry);
module_invoke_all('feedback_update', $entry);
module_invoke_all('entity_update', $entry, 'feedback');
}
unset($entry->original);
return $status;
}