function webform_protected_downloads_node_has_protected_files in Webform Protected Downloads 6
Same name and namespace in other branches
- 7 webform_protected_downloads.module \webform_protected_downloads_node_has_protected_files()
Checks if the given node has protected files
Parameters
int $nid :
Return value
void
4 calls to webform_protected_downloads_node_has_protected_files()
- webform_protected_downloads_component_delete_access in ./
webform_protected_downloads.module - Custom access callback that checks wheather a webform component can be deleted
- webform_protected_downloads_form_alter in ./
webform_protected_downloads.module - Implementation of hook_form_alter(). Doc says that $form_state is passed by reference, but that generates warnings: warning: Parameter 2 to webform_protected_downloads_form_alter() expected to be a reference, value given in /includes/common.inc on…
- webform_protected_downloads_nodeapi in ./
webform_protected_downloads.module - Implementation of hook_nodeapi().
- webform_protected_downloads_process_submissions in ./
webform_protected_downloads.module - Process unprocessed webform submissions
File
- ./
webform_protected_downloads.module, line 546 - This file contains hook declarations and functions for the Webform Protected Downloads module.
Code
function webform_protected_downloads_node_has_protected_files($nid) {
static $wpd_nodes;
if (!isset($wpd_nodes[$nid])) {
$files = webform_protected_downloads_get_attached_files($nid);
if (count($files)) {
// the node has attached files, so check if there are any protected ones
$sql = "SELECT COUNT(*) FROM {wpd_protected_files} WHERE nid = %d AND fid IN (%s)";
$args = array(
$nid,
implode(',', array_keys($files)),
);
$result = db_result(db_query($sql, $args));
$wpd_nodes[$nid] = $result > 0;
}
else {
// no files there, so there can't be any protected ones
$wpd_nodes[$nid] = FALSE;
}
}
return $wpd_nodes[$nid];
}