function flashnode_update_4 in Flash Node 5.6
Same name and namespace in other branches
- 5.2 flashnode.install \flashnode_update_4()
- 5.3 flashnode.install \flashnode_update_4()
Update node entries - replace [flash] macros with [flashnode] Note - check for [flash|nid=] to avoid clashing with flash_filter which is a separate module!
File
- ./
flashnode.install, line 124
Code
function flashnode_update_4() {
// Initialise the return array
$ret = array();
// Get all existing nodes that contain flashnode macros
$result = db_query("SELECT nid, vid, body, teaser FROM {node_revisions} WHERE body LIKE '%[flash|nid=%' OR teaser LIKE '%[flash|nid=%'");
// Iterate through the results
while ($node = db_fetch_object($result)) {
// Amend the body and teaser
$node->body = str_replace('[flash|nid=', '[flashnode|nid=', $node->body);
$node->teaser = str_replace('[flash|nid=', '[flashnode|nid=', $node->teaser);
// Update the database with the changes
if (db_query("UPDATE {node_revisions} SET body='%s', teaser='%s' WHERE vid=%d", $node->body, $node->teaser, $node->vid)) {
$ret[] = array(
'success' => 1,
'query' => 'Updated filter in node ' . $node->nid,
);
}
else {
$ret[] = array(
'success' => 0,
'query' => 'Failed to update filter in node ' . $node->nid,
);
}
}
// Reset the cache to ensure any pages using filters are updated
cache_clear_all('*', 'cache_filter', true);
return $ret;
}