144
144
if (($result = db_fetch_object(db_query("SELECT * FROM {xmlsitemap_user} WHERE uid = %d", $account->uid))) === FALSE) {
145
145
$row = new stdClass();
146
146
$row->uid = $account->uid;
147
$row->last_changed = time();
147
$row->changed = time();
151
$row->previously_changed = $row->last_changed;
152
$row->last_changed = time();
151
$row->previously_changed = $row->changed;
152
$row->changed = time();
154
154
if ($edit['xmlsitemap_user_priority'] != -2.0) {
155
155
$row->priority_override = $edit['xmlsitemap_user_priority'];
169
* Implementation of hook_xmlsitemap_database_batch_operation().
171
function xmlsitemap_user_xmlsitemap_database_batch_operation() {
173
'file' => 'xmlsitemap_user.batch.inc',
174
'add function' => 'xmlsitemap_user_update_database',
179
169
* Implementation of hook_xmlsitemap_links().
181
171
function xmlsitemap_user_xmlsitemap_links() {
196
184
if (count($frontpage) == 2 && $frontpage[0] == 'user' && is_numeric($frontpage[1])) {
197
185
$uid = $frontpage[1];
199
$result = db_query("SELECT u.uid, xu.last_changed, xu.previously_changed, xu.priority_override, SUM(xur.priority) as priority, $coalesce(ua.dst) AS alias
187
$result = db_query("SELECT u.uid, xu.changed, xu.previously_changed, xu.priority_override, SUM(xur.priority) as priority, $coalesce(ua.dst) AS alias
200
188
FROM {xmlsitemap_user} xu
201
189
INNER JOIN {users} u ON xu.uid = u.uid
202
190
LEFT JOIN {users_roles} ur ON xu.uid = ur.uid
203
191
LEFT JOIN {xmlsitemap_user_role} xur ON ur.rid = xur.rid
204
LEFT JOIN {url_alias} ua ON ua.src = CONCAT('user/', CAST(u.uid AS $cast))
192
LEFT JOIN {url_alias} ua ON ua.src = CONCAT('user/', u.uid)
205
193
WHERE u.status <> 0
207
GROUP BY u.uid, xu.last_changed, xu.previously_changed, xu.priority_override
195
GROUP BY u.uid, xu.changed, xu.previously_changed, xu.priority_override
208
196
HAVING MIN(xur.priority) <> -1 OR SUM(xur.priority) IS NULL",
211
199
while ($user = db_fetch_object($result)) {
212
$age = time() - $user->last_changed;
213
$interval = empty($user->previously_changed) ? 0 : $user->last_changed - $user->previously_changed;
200
$age = time() - $user->changed;
201
$interval = empty($user->previously_changed) ? 0 : $user->changed - $user->previously_changed;
214
202
if ($user->priority_override != -2.0) {
215
203
$priority = $user->priority_override;
218
206
$priority = min(isset($user->priority) ? $user->priority : variable_get('xmlsitemap_user_default_priority', 0.5), 1);
220
208
db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)",
221
xmlsitemap_url('user/'. $user->uid, $user->alias, NULL, NULL, TRUE),
222
$user->last_changed, max($age, $interval), $priority);
210
xmlsitemap_url('user/'. $user->uid, $user->alias, NULL, NULL, TRUE),
211
$user->changed, max($age, $interval), $priority,
219
* Implementation of hook_xmlsitemap_update_module_tables_batch_operations().
221
function xmlsitemap_user_xmlsitemap_update_module_tables_batch_operations() {
223
'_xmlsitemap_user_module_table_delete_rows',
224
'_xmlsitemap_user_module_table_add_rows',
227
228
/*****************************************************************************
228
229
* Menu callbacks / form builders, submit/validate functions.
229
230
****************************************************************************/
259
/*****************************************************************************
260
* Private functions - database batch operation.
261
****************************************************************************/
264
* Batch function used to update the module tables.
266
* The context parameter passed from batch_process().
268
function _xmlsitemap_user_module_table_add_rows(&$context) {
269
if (!isset($context['sandbox']['progress'])) {
270
$context['sandbox']['progress'] = 0;
271
$context['sandbox']['current_user'] = 0;
272
$context['sandbox']['max'] = (integer) db_result(db_query('SELECT COUNT(u.uid)
274
LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid
279
if ($context['sandbox']['max']) {
280
$result = db_query_range('SELECT u.uid, u.created AS changed
282
LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid
286
$context['sandbox']['current_user'], 0, 1
288
if ($row = db_fetch_object($result)) {
289
drupal_write_record('xmlsitemap_user', $row);
290
$context['sandbox']['progress']++;
291
$context['sandbox']['current_user'] = $row->uid;
292
$context['results']['added'] = $context['sandbox']['progress'];
294
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
295
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
301
* Batch function used to update the module tables.
303
* The context parameter passed from batch_process().
305
function _xmlsitemap_user_module_table_delete_rows(&$context) {
306
if (!isset($context['sandbox']['progress'])) {
307
$context['sandbox']['progress'] = 0;
308
$context['sandbox']['current_user'] = 0;
309
$context['sandbox']['max'] = (integer) db_result(db_query('SELECT COUNT(u.uid)
310
FROM {xmlsitemap_user} xu
311
LEFT JOIN {users} u ON u.uid = xu.uid
312
WHERE u.uid IS NULL')
315
if ($context['sandbox']['max']) {
317
db_query("SELECT xu.uid
318
FROM {xmlsitemap_user} xu
319
LEFT JOIN {users} u ON u.uid = xu.uid
322
$context['sandbox']['current_user']
325
if ($uid === FALSE) {
326
$context['finished'] = 1;
329
db_query('DELETE FROM {xmlsitemap_user} WHERE uid = %d', $uid);
330
$context['sandbox']['progress']++;
331
$context['sandbox']['current_user'] = $uid;
332
$context['results']['deleted'] = $context['sandbox']['progress'];
333
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
334
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
259
341
* @} End of "addtogroup xmlsitemap".