function pay_node_node_insert in Pay 7
Implements hook_node_insert().
File
- modules/
pay_node/ pay_node.module, line 121
Code
function pay_node_node_insert($node) {
// Create a record that links this payment form to this node.
if ($node->nid && isset($node->pay_node)) {
$method = variable_get('pay_node_method_' . $node->type, '');
$record = array(
'nid' => $node->nid,
'method' => $method,
);
// Link to an existing pay_form using its id.
if (is_scalar($node->pay_node) && $node->pay_node) {
$record['pfid'] = $node->pay_node;
db_delete('pay_form_node')
->condition('nid', $node->nid)
->condition('method', $method)
->execute();
drupal_write_record('pay_form_node', $record);
}
else {
foreach ($node->pay_node as $pay_form) {
if ($pay_form->new) {
$record['pfid'] = $pay_form->pfid;
drupal_write_record('pay_form_node', $record);
}
}
}
}
}