-
Notifications
You must be signed in to change notification settings - Fork 0
/
soe_intranet_helper.module
55 lines (49 loc) · 1.69 KB
/
soe_intranet_helper.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Implements hook_page_alter(&$page).
*/
function soe_intranet_helper_page_alter(&$page) {
// If the page doesn't have a sidebar and it is displaying a node, it might
// need the cache cleared.
//
// This requires refreshing the page twice for the page to render properly.
if (!isset($page['sidebar_first'])) {
if (isset ($page['content']['system_main']['nodes'])) {
$key = key($page['content']['system_main']['nodes']);
$bundle = $page['content']['system_main']['nodes'][$key]['#bundle'];
$settings = soe_intranet_helper_get_settings();
// If it is not a blacklisted node or bundle then flush the cache.
if ((!in_array($key, $settings['node_blacklist'])) &&
(!in_array($bundle, $settings['bundle_blacklist']))) {
watchdog('soe_intranet_helper',
'First sidebar is missing. Page is: node/%key',
array('%key' => $key),
WATCHDOG_DEBUG);
drupal_flush_all_caches();
}
}
}
}
/**
* Default settings wrapper for variable_get
* @return array
* Persistent settings for this module.
*
*/
function soe_intranet_helper_get_settings() {
$default_settings = array(
// These are the nodes that don't have first sidebars.
// node/628 - Information Technology
// node/148 - Home page
// node/1225 - Connect-links
// node/632 - Job Aids Too
// node/80 - page not found
// node/164 - Resources Overview
// node/90 - Resources
// node/78 - Programs
'node_blacklist' => array(628, 148, 1225, 632, 80, 164, 90, 78),
'bundle_blacklist' => array('stanford_person'),
);
$settings = variable_get('soe_intranet_helper_settings', $default_settings );
return $settings;
}