Commit feec3ef8 authored by Gábor Hojtsy's avatar Gábor Hojtsy

avoid insert hook name clash, and also remove schedule values, if a node is deleted

parent 724a75e2
......@@ -49,7 +49,7 @@ function scheduler_write($node, $op, $arg) {
// No schedule needs to take place (works for update and insert too)
if (array_sum($conds) == 0) {
$result = db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid);
scheduler_remove_schedule();
return;
}
......@@ -63,20 +63,24 @@ function scheduler_write($node, $op, $arg) {
db_query('UPDATE {scheduler} SET %s WHERE nid = %d', implode(', ', $update_conds), $node->nid);
}
else {
scheduler_insert($node, $conds);
scheduler_insert_schedule($node, $conds);
}
}
else {
scheduler_insert($node, $conds);
scheduler_insert_schedule($node, $conds);
}
}
}
function scheduler_insert($node, $conds) {
function scheduler_insert_schedule($node, $conds) {
$conds['nid'] = $node->nid;
db_query('INSERT {scheduler} (%s) VALUES (%s)', implode(', ', array_keys($conds)), implode(', ', array_values($conds)));
}
function scheduler_remove_schedule($node) {
db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid);
}
/**
* Implementation of hook_nodeapi().
*/
......@@ -122,6 +126,9 @@ function scheduler_nodeapi(&$node, $op, &$arg) {
case 'update':
scheduler_write($node, $op, $arg);
break;
case 'delete':
scheduler_remove_schedule($node);
break;
case 'form pre':
if (user_access('schedule nodes')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment