Index: contentblocker.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/contentblocker/contentblocker.module,v retrieving revision 1.9 diff -u -r1.9 contentblocker.module --- contentblocker.module 20 May 2007 03:07:31 -0000 1.9 +++ contentblocker.module 20 May 2007 03:17:12 -0000 @@ -177,15 +177,20 @@ // Determine value of join field. $data = contentblocker_get_data($type); $id = db_result(db_query("SELECT ". $data['primary_table_alias'] .".". $data['primary_id_field'] ." FROM {". $data['primary_table'] ."} ". $data['primary_table_alias'] ." INNER JOIN {node} n ON ". $data['primary_table_alias'] .".". $data['primary_id_field'] ." = n.". $data['node_field'] ." WHERE n.nid = %d", $node->nid)); + $has_block = contentblocker_has_block($type, $node); $property = 'contentblocker_'. $type; switch ($node->$property) { // Delete existing block. case 0: - db_query("DELETE FROM {contentblocker} WHERE uid = %d AND type = '%s' AND id = %d", $user->uid, isset($data['save_type']) ? $data['save_type'] : $type, $id); + if ($has_block) { + db_query("DELETE FROM {contentblocker} WHERE uid = %d AND type = '%s' AND id = %d", $user->uid, isset($data['save_type']) ? $data['save_type'] : $type, $id); + } break; // Insert a new block. case 1: - db_query("INSERT INTO {contentblocker} (uid, type, id) VALUES (%d, '%s', %d)", $user->uid, isset($data['save_type']) ? $data['save_type'] : $type, $id); + if (!$has_block) { + db_query("INSERT INTO {contentblocker} (uid, type, id) VALUES (%d, '%s', %d)", $user->uid, isset($data['save_type']) ? $data['save_type'] : $type, $id); + } break; } }