-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalias_old.batch.inc
More file actions
36 lines (31 loc) · 952 Bytes
/
alias_old.batch.inc
File metadata and controls
36 lines (31 loc) · 952 Bytes
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
<?php
/**
* Batch process callback.
*/
function alias_old_change_alias($nid, &$context) {
$node = node_load($nid);
$path = "'node/$nid'";
// Get alias path
$alias = db_query("SELECT alias FROM url_alias WHERE source = ".$path." LIMIT 1");
while($record = $alias->fetchAssoc()) {
// New alias path
$alias_path = $record['alias'].'-old';
}
// Set alias path
if(!(substr($alias_path, -4) == '-old')) {
db_query("UPDATE url_alias SET alias = '".$alias_path."' WHERE source = ".$path);
}
$context['results']['titles'][] = $node->title;
$context['message'] = 'Обновлена дата у материала <em>' . check_plain($node->title) . '</em>';
}
/**
* Batch finish callback.
*/
function alias_old_finished($success, $results, $operations) {
if ($success) {
drupal_set_message('Завершено');
}
else {
drupal_set_message('Завершено с ошибками.', 'error');
}
}