1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * Install, update, and uninstall functions for Pathauto. |
---|
6 | * |
---|
7 | * @ingroup pathauto |
---|
8 | */ |
---|
9 | |
---|
10 | /** |
---|
11 | * Implements hook_install(). |
---|
12 | */ |
---|
13 | function pathauto_install() { |
---|
14 | // Set some default variables necessary for the module to perform. |
---|
15 | variable_set('pathauto_node_pattern', 'content/[title-raw]'); |
---|
16 | variable_set('pathauto_taxonomy_pattern', '[vocab-raw]/[catpath-raw]'); |
---|
17 | variable_set('pathauto_forum_pattern', '[vocab-raw]/[catpath-raw]'); |
---|
18 | variable_set('pathauto_user_pattern', 'users/[user-raw]'); |
---|
19 | variable_set('pathauto_blog_pattern', 'blogs/[user-raw]'); |
---|
20 | |
---|
21 | // Set the default separator character to replace instead of remove (default). |
---|
22 | variable_set('pathauto_punctuation_hyphen', 1); |
---|
23 | |
---|
24 | // Set the weight to 1 |
---|
25 | db_query("UPDATE {system} SET weight = 1 WHERE type = 'module' AND name = 'pathauto'"); |
---|
26 | } |
---|
27 | |
---|
28 | /** |
---|
29 | * Implements hook_uninstall(). |
---|
30 | */ |
---|
31 | function pathauto_uninstall() { |
---|
32 | // Delete all the pathauto variables and then clear the variable cache |
---|
33 | db_query("DELETE FROM {variable} WHERE name LIKE 'pathauto_%'"); |
---|
34 | cache_clear_all('variables', 'cache'); |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Set the weight a little heavier to allow taxonomy to do its work. |
---|
39 | */ |
---|
40 | function pathauto_update_1() { |
---|
41 | $ret = array(); |
---|
42 | $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE type = 'module' AND name = 'pathauto'"); |
---|
43 | return $ret; |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * pathauto_update_4 was a backport of a feature which is in core of Drupal 6 |
---|
48 | * hence it is removed from the 6.x branch even though the goal is to support |
---|
49 | * Pathauto 5.x-1.x -> 6.x-2.x upgrades. |
---|
50 | */ |
---|
51 | |
---|
52 | /** |
---|
53 | * Delete the pathauto_node_supportsfeeds. |
---|
54 | */ |
---|
55 | function pathauto_update_3() { |
---|
56 | // Do nothing, this update was a mistake |
---|
57 | return array(); |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * New style naming for the punctuation chars. |
---|
62 | */ |
---|
63 | function pathauto_update_4() { |
---|
64 | variable_set('pathauto_punctuation_quotes', variable_get('pathauto_quotes', 0)); |
---|
65 | variable_del('pathauto_quotes'); |
---|
66 | return array(); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * Remove the url_alias_extra table which wasn't used. |
---|
71 | */ |
---|
72 | function pathauto_update_7() { |
---|
73 | $ret = array(); |
---|
74 | if (db_table_exists('url_alias_extra')) { |
---|
75 | db_drop_table($ret, 'url_alias_extra'); |
---|
76 | } |
---|
77 | return $ret; |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Remove the unsupported user/%/contact and user/%/tracker pattern variables. |
---|
82 | */ |
---|
83 | function pathauto_update_6200() { |
---|
84 | variable_del('pathauto_contact_bulkupdate'); |
---|
85 | variable_del('pathauto_contact_pattern'); |
---|
86 | variable_del('pathauto_contact_supportsfeeds'); |
---|
87 | variable_del('pathauto_contact_applytofeeds'); |
---|
88 | variable_del('pathauto_tracker_bulkupdate'); |
---|
89 | variable_del('pathauto_tracker_pattern'); |
---|
90 | variable_del('pathauto_tracker_supportsfeeds'); |
---|
91 | variable_del('pathauto_tracker_applytofeeds'); |
---|
92 | return array(); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * Remove obsolete variables since batch API is now used. |
---|
97 | */ |
---|
98 | function pathauto_update_6201() { |
---|
99 | variable_del('pathauto_max_bulk_update'); |
---|
100 | variable_del('pathauto_node_bulkupdate'); |
---|
101 | variable_del('pathauto_taxonomy_bulkupdate'); |
---|
102 | variable_del('pathauto_forum_bulkupdate'); |
---|
103 | variable_del('pathauto_user_bulkupdate'); |
---|
104 | variable_del('pathauto_blog_bulkupdate'); |
---|
105 | variable_del('pathauto_modulelist'); |
---|
106 | variable_del('pathauto_indexaliases'); |
---|
107 | variable_del('pathauto_indexaliases_bulkupdate'); |
---|
108 | return array(); |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * Remove obsolete variables for removed feed handling. |
---|
113 | */ |
---|
114 | function pathauto_update_6202() { |
---|
115 | variable_del('pathauto_node_supportsfeeds'); |
---|
116 | variable_del('pathauto_node_applytofeeds'); |
---|
117 | variable_del('pathauto_taxonomy_supportsfeeds'); |
---|
118 | variable_del('pathauto_taxonomy_applytofeeds'); |
---|
119 | variable_del('pathauto_forum_supportsfeeds'); |
---|
120 | variable_del('pathauto_forum_applytofeeds'); |
---|
121 | variable_del('pathauto_user_supportsfeeds'); |
---|
122 | variable_del('pathauto_user_applytofeeds'); |
---|
123 | variable_del('pathauto_blog_supportsfeeds'); |
---|
124 | variable_del('pathauto_blog_applytofeeds'); |
---|
125 | return array(); |
---|
126 | } |
---|