/[drupal]/contributions/modules/pathauto/pathauto_user.inc
ViewVC logotype

Contents of /contributions/modules/pathauto/pathauto_user.inc

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


Revision 1.31 - (show annotations) (download) (as text)
Fri Jul 11 20:01:22 2008 UTC (16 months, 2 weeks ago) by greggles
Branch: MAIN
CVS Tags: HEAD
Changes since 1.30: +3 -3 lines
File MIME type: text/x-php
bug #278980 by bforchhammer: improper use of Token API led to inappropriate warning messages for user and contact page tokens.
1 <?php
2 // $Id: pathauto_user.inc,v 1.30 2008/06/28 15:41:15 freso Exp $
3
4 /**
5 * @file
6 * Hook implementations for user module integration.
7 *
8 * @ingroup pathauto
9 */
10
11 /**
12 * Implementation of hook_pathauto() for user aliases.
13 */
14 function user_pathauto($op) {
15 switch ($op) {
16 case 'settings':
17 $settings = array();
18 $settings['module'] = 'user';
19 $settings['token_type'] = 'user';
20 $settings['groupheader'] = t('User path settings');
21 $settings['patterndescr'] = t('Pattern for user account page paths');
22 $settings['patterndefault'] = t('users/[user-raw]');
23 $patterns = token_get_list('user');
24 foreach ($patterns as $type => $pattern_set) {
25 if ($type != 'global') {
26 foreach ($pattern_set as $pattern => $description) {
27 $settings['placeholders']['['. $pattern .']'] = $description;
28 }
29 }
30 }
31
32 $settings['bulkname'] = t('Bulk generate aliases for users that are not aliased');
33 $settings['bulkdescr'] = t('Generate aliases for all existing user account pages which do not already have aliases.');
34 return (object) $settings;
35 default:
36 break;
37 }
38 }
39
40 /**
41 * Implementation of hook_pathauto() for blog aliases.
42 */
43 function blog_pathauto($op) {
44 switch ($op) {
45 case 'settings':
46 $settings = array();
47 $settings['module'] = 'blog';
48 $settings['token_type'] = 'user';
49 $settings['groupheader'] = t('Blog path settings');
50 $settings['patterndescr'] = t('Pattern for blog page paths');
51 $settings['patterndefault'] = t('blogs/[user-raw]');
52 $patterns = token_get_list('user');
53 foreach ($patterns['user'] as $pattern => $description) {
54 $settings['placeholders']['['. $pattern .']'] = $description;
55 }
56 $settings['supportsfeeds'] = 'feed';
57 $settings['bulkname'] = t('Bulk generate aliases for blogs that are not aliased');
58 $settings['bulkdescr'] = t('Generate aliases for all existing blog pages which do not already have aliases.');
59 return (object) $settings;
60 default:
61 break;
62 }
63 }
64
65 /**
66 * Implementation of hook_pathauto() for user-tracker aliases.
67 */
68 function tracker_pathauto($op) {
69 switch ($op) {
70 case 'settings':
71 $settings = array();
72 $settings['module'] = 'tracker';
73 $settings['token_type'] = 'user';
74 $settings['groupheader'] = t('User-tracker path settings');
75 $settings['patterndescr'] = t('Pattern for user-tracker page paths');
76 $settings['patterndefault'] = t('users/[user-raw]/track');
77 $patterns = token_get_list('user');
78 foreach ($patterns['user'] as $pattern => $description) {
79 $settings['placeholders']['['. $pattern .']'] = $description;
80 }
81 $settings['supportsfeeds'] = 'feed';
82 $settings['bulkname'] = t('Bulk generate aliases for user-tracker paths that are not aliased');
83 $settings['bulkdescr'] = t('Generate aliases for all existing user-tracker pages which do not already have aliases.');
84 return (object) $settings;
85 default:
86 break;
87 }
88 }
89
90 /**
91 * Implementation of hook_pathauto() for contact form aliases.
92 */
93 function contact_pathauto($op) {
94 switch ($op) {
95 case 'settings':
96 $settings = array();
97 $settings['module'] = 'contact';
98 $settings['token_type'] = 'user';
99 $settings['groupheader'] = t('User contact form path settings');
100 $settings['patterndescr'] = t('Pattern for the user contact form paths');
101 $settings['patterndefault'] = t('users/[user-raw]/contact');
102 $patterns = token_get_list('user');
103 foreach ($patterns['user'] as $pattern => $description) {
104 $settings['placeholders']['['. $pattern .']'] = $description;
105 }
106 $settings['bulkname'] = t('Bulk generate aliases for user contact form paths that are not aliased');
107 $settings['bulkdescr'] = t('Generate aliases for all existing user contact form pages which do not already have aliases.');
108 return (object) $settings;
109 default:
110 break;
111 }
112 }
113
114 /**
115 * Bulk generate aliases for all users without aliases.
116 */
117 function user_pathauto_bulkupdate() {
118 $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT('user/', CAST(uid AS CHAR)) = src WHERE uid > 0 AND src IS NULL";
119 $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
120
121 $count = 0;
122 $placeholders = array();
123 while ($user = db_fetch_object($result)) {
124 $placeholders = pathauto_get_placeholders('user', $user);
125 $src = 'user/'. $user->uid;
126 if (pathauto_create_alias('user', 'bulkupdate', $placeholders, $src, $user->uid)) {
127 $count++;
128 }
129 }
130
131 drupal_set_message(format_plural($count,
132 'Bulk generation of users completed, one alias generated.',
133 'Bulk generation of users completed, @count aliases generated.'));
134 }
135
136 /**
137 * Bulk generate aliases for all blogs without aliases.
138 */
139 function blog_pathauto_bulkupdate() {
140 $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT('blog/', CAST(uid AS CHAR)) = src WHERE uid > 0 AND src IS NULL";
141 $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
142
143 $count = 0;
144 $placeholders = array();
145 while ($user = db_fetch_object($result)) {
146 $placeholders = pathauto_get_placeholders('user', $user);
147 $src = 'blog/'. $user->uid;
148 if (pathauto_create_alias('blog', 'bulkupdate', $placeholders, $src, $user->uid)) {
149 $count++;
150 }
151 }
152
153 drupal_set_message(format_plural($count,
154 'Bulk generation of user blogs completed, one alias generated.',
155 'Bulk generation of user blogs completed, @count aliases generated.'));
156 }
157
158 /**
159 * Bulk generate aliases for user trackers without aliases.
160 */
161 function tracker_pathauto_bulkupdate() {
162 // We do the double CONCAT because Pgsql8.1 doesn't support more than three arguments to CONCAT
163 // Hopefully some day we can remove that.
164 $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT(CONCAT('user/', CAST(uid AS CHAR)), '/track') = src WHERE uid > 0 AND src IS NULL";
165 $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
166
167 $count = 0;
168 $placeholders = array();
169 while ($user = db_fetch_object($result)) {
170 $placeholders = pathauto_get_placeholders('user', $user);
171 $src = 'user/'. $user->uid .'/track';
172 if (pathauto_create_alias('tracker', 'bulkupdate', $placeholders, $src, $user->uid)) {
173 $count++;
174 }
175 }
176
177 drupal_set_message(format_plural($count,
178 'Bulk generation of user tracker pages completed, one alias generated.',
179 'Bulk generation of user tracker pages completed, @count aliases generated.'));
180 }
181
182 /**
183 * Bulk generate aliases for all users without aliases
184 */
185 function contact_pathauto_bulkupdate() {
186 $query = "SELECT uid, name, src, dst FROM {users} LEFT JOIN {url_alias} ON CONCAT(CONCAT('user/', CAST(uid AS CHAR)), '/contact') = src WHERE uid > 0 AND src IS NULL";
187 $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
188
189 $count = 0;
190 $placeholders = array();
191 while ($user = db_fetch_object($result)) {
192 $placeholders = pathauto_get_placeholders('user', $user);
193 $src = 'user/'. $user->uid .'/contact';
194 if (pathauto_create_alias('contact', 'bulkupdate', $placeholders, $src, $user->uid)) {
195 $count++;
196 }
197 }
198
199 drupal_set_message(format_plural($count,
200 'Bulk generation of contact pages completed, one alias generated.',
201 'Bulk generation of contact pages completed, @count aliases generated.'));
202 }

  ViewVC Help
Powered by ViewVC 1.1.2