function track_field_changes_insert_db in Track Field Changes 7
Same name and namespace in other branches
- 8 track_field_changes.module \track_field_changes_insert_db()
2 calls to track_field_changes_insert_db()
- track_field_changes_node_insert in ./
track_field_changes.module - Implements hook_node_insert().
- track_field_changes_node_update in ./
track_field_changes.module - Implements hook_node_update().
File
- ./
track_field_changes.module, line 424 - The Track Field Changes module.
Code
function track_field_changes_insert_db($nid, $field_name, $old_field, $new_field, $type, $log) {
global $user;
$track_field_changes_disable_multiple = variable_get('track_field_changes_disable_multiple', array());
if ($track_field_changes_disable_multiple['checked'] === "checked") {
$result = db_select('track_field_changes_audit', 't')
->fields('t')
->condition('nid', $nid, '=')
->execute()
->fetchAssoc();
if ($result['nid'] == $nid) {
db_update('track_field_changes_audit')
->fields(array(
'nid' => $nid,
'timestamp' => REQUEST_TIME,
'uid' => $user->uid,
'field_name' => $field_name,
'before_value_text' => $old_field,
'after_value_text' => $new_field,
'type' => $type,
'log' => $log,
))
->condition('nid', $nid, '=')
->execute();
}
else {
db_insert('track_field_changes_audit')
->fields(array(
'nid' => $nid,
'timestamp' => REQUEST_TIME,
'uid' => $user->uid,
'field_name' => $field_name,
'before_value_text' => $old_field,
'after_value_text' => $new_field,
'type' => $type,
'log' => $log,
))
->execute();
}
}
else {
db_insert('track_field_changes_audit')
->fields(array(
'nid' => $nid,
'timestamp' => REQUEST_TIME,
'uid' => $user->uid,
'field_name' => $field_name,
'before_value_text' => $old_field,
'after_value_text' => $new_field,
'type' => $type,
'log' => $log,
))
->execute();
}
}