/[drupal]/contributions/modules/advcache/advcache.module
ViewVC logotype

Contents of /contributions/modules/advcache/advcache.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Thu Feb 26 13:39:12 2009 UTC (9 months ago) by mikejoconnor
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.10: +6 -22 lines
File MIME type: text/x-php
#242121 Merging the DRUPAL-5 branch with head
1 <?php
2 // $Id: advcache.module,v 1.1.2.10 2009/02/26 13:02:45 mikejoconnor Exp $
3
4 function advcache_taxonomy($op, $type, $object=NULL) {
5 if (is_null($object)) {
6 return;
7 }
8 $object = (array)$object;
9
10 switch ($type) {
11 case 'term':
12 $keys[] = 'term::'. $object['tid'];
13 if ($op == 'insert' || $op == 'delete' || $op == 'update') {
14 cache_clear_all('*', 'cache_taxonomy', TRUE);
15 if (module_exists('forum') && $object['vid'] == _forum_get_vid()) {
16 cache_clear_all('*', 'cache_forum', TRUE);
17 }
18 }
19 break;
20
21 case 'vocabulary':
22 $keys[] = 'tree::'. $object['vid'];
23 $keys[] = 'vocabulary::'. $object['vid'];
24
25 if ($op == 'insert' || $op == 'delete' || $op == 'update') {
26 if (module_exists('forum') && $object['vid'] == _forum_get_vid()) {
27 cache_clear_all('*', 'cache_forum', TRUE);
28 }
29 }
30 break;
31
32 // we only know how to handle 'term' and 'vocabulary', so return otherwise.
33 default:
34 return;
35 }
36 switch ($op) {
37 case 'delete':
38 case 'update':
39 foreach ($keys as $key) {
40 cache_clear_all($key, 'cache_taxonomy');
41 }
42 break;
43 }
44
45 }
46
47 function advcache_nodeapi($node, $op) {
48 switch ($op) {
49 case 'update':
50 case 'insert':
51 case 'delete':
52 cache_clear_all("node/{$node->nid}", 'cache_node');
53
54 // It is unfortunate that we have to use the wildcard here, but it
55 // comes from the fact that the signature to taxonomy_node_get_terms
56 // has a $key parameter which goes into building the cache key, which
57 // we can't reliably reconstruct here.
58 cache_clear_all('node::'. $node->nid, 'cache_taxonomy', TRUE);
59 if ($node->type == 'forum') {
60 cache_clear_all('*', 'cache_forum', TRUE);
61 }
62 break;
63 }
64 }
65
66 function advcache_comment($a1, $op) {
67 switch ($op) {
68 case 'delete':
69 case 'update':
70 case 'insert':
71 case 'publish':
72 case 'unpublish':
73 // hook_comment is inconsistent with the type it passes in.
74 $a1 = (object)$a1;
75
76 $nid = $a1->nid;
77
78 cache_clear_all('nid-'. $nid, 'cache_comment', TRUE);
79
80 $node = node_load($nid);
81 if ($node->type == 'forum') {
82 cache_clear_all('*', 'cache_forum', TRUE);
83 }
84 break;
85 }
86 }
87 function advcache_devel_caches() {
88 return array('cache_advcache_block', 'cache_comment', 'cache_forum', 'cache_node', 'cache_path', 'cache_search', 'cache_taxonomy');
89 }

  ViewVC Help
Powered by ViewVC 1.1.2