function heartbeat_check_access_types in Heartbeat 6.4
Same name and namespace in other branches
- 6.3 heartbeat.module \heartbeat_check_access_types()
Check if there no new heartbeat access types available
2 calls to heartbeat_check_access_types()
- heartbeat_default_data in ./
heartbeat.module - Import and store default data
- heartbeat_install in ./
heartbeat.install - Implementation of hook_install().
File
- ./
heartbeat.module, line 1153
Code
function heartbeat_check_access_types() {
//variable_del('heartbeat_access_types');
// variable_set('heartbeat_access_types', array());
$used = variable_get('heartbeat_access_types', array());
// On install these default messages are not found,
// so append heartbeat for sure
if (!module_exists('heartbeat')) {
$types = array();
$types = heartbeat_heartbeat_register_access_types();
$types += module_invoke_all('heartbeat_register_access_types');
}
else {
$types = module_invoke_all('heartbeat_register_access_types');
}
drupal_alter('heartbeat_register_access_types', $types);
if (!empty($types)) {
$registered = array();
foreach ($types as $k => $type) {
heartbeat_include($type['class'], $type['module'], $type['path']);
// The unique key is the class
$key = drupal_strtolower($type['class']);
$registered[$key] = $type['class'];
if (!class_exists($type['class'])) {
watchdog('heartbeat', 'No class found for ' . $type['class'], array(), WATCHDOG_ERROR);
unset($types[$key]);
}
else {
// Add new found streams
if (!isset($used[$key])) {
$used[$key] = $type;
}
// Always take these settings as new.
$used[$key]['path'] = $type['path'];
$used[$key]['module'] = $type['module'];
$used[$key]['access'] = isset($type['access']) ? $type['access'] : HEARTBEAT_PUBLIC_TO_ALL;
// Add and override default properties with the ones already saved
$updated = _heartbeat_stream_defaults($used[$key]);
// Update the used after detecting changes
$used[$key] = $updated;
}
}
}
// Delete removed ones.
foreach ($used as $used_name => $used_type) {
$key = drupal_strtolower($used_type['class']);
if (!isset($registered[$key])) {
unset($used[$used_name]);
}
}
variable_set('heartbeat_access_types', $used);
}