function filefield_filefield_paths_update in File (Field) Paths 5
Same name and namespace in other branches
- 6 modules/filefield.inc \filefield_filefield_paths_update()
Implementation of hook_filefield_paths_batch_update().
File
- modules/
filefield.inc, line 86 - Provides FileField Paths integration with the FileField module.
Code
function filefield_filefield_paths_update($field_name, $type_name) {
if (!empty($field_name)) {
$field = content_fields($field_name, $type_name);
$db_info = content_database_info($field);
$result = db_query("SELECT c.nid FROM {%s} c LEFT JOIN {node} n ON c.nid = n.nid WHERE c.%s IS NOT NULL\n AND n.type = '%s'", $db_info['table'], $db_info['columns']['fid']['column'], $type_name);
while ($data = db_fetch_object($result)) {
$node = node_load($data->nid);
// Flag files for update.
if (isset($node->{$field_name})) {
foreach ($node->{$field_name} as &$file) {
if (empty($file['filepath'])) {
continue;
}
$file['data']['process'] = TRUE;
}
}
// Set Form ID.
$node->form_id = $node->type . '_node_form';
// Process Node.
filefield_paths_nodeapi($node, 'update', NULL, NULL);
}
}
}