-
Notifications
You must be signed in to change notification settings - Fork 0
/
bv_vopros.drush.inc
48 lines (40 loc) · 1.95 KB
/
bv_vopros.drush.inc
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
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @file
* Drush commands/hooks for Biblioteksvagten Vopros.
*/
/**
* Implements hook_drush_sql_sync_sanitize().
*/
function bv_vopros_drush_sql_sync_sanitize($site) {
$site_settings = drush_sitealias_get_record($site);
$databases = sitealias_get_databases_from_record($site_settings);
// Update the opensearch URL in the variables table.
$sanitize_query = "UPDATE variable SET value='" . serialize("http://opensearchadmin.addi.dk/next_2.0/") . "' WHERE name = 'osa_addi_soap_url';";
drush_sql_register_post_sync_op('opensearch_url', dt('Set opensearch URL'), $sanitize_query);
// Fix mailhandler mailbox email.
$boxes = drush_db_select('mailhandler_mailbox', array('mid', 'settings', 'admin_title'));
$i = 1;
while ($box = drush_db_fetch_object($boxes)) {
$settings = unserialize($box->settings);
if ($settings['mail'] == 'bv@biblioteksvagten.dk') {
// Replace the main address with test@.
$mail = 'test@biblioteksvagten.dk';
}
else {
// Replace the rest with test+<num>@.
$mail = 'test+' . $i++ . '@biblioteksvagten.dk';
}
$settings['name'] = $mail;
$sanitize_query = "UPDATE mailhandler_mailbox SET mail = '" . $mail . "', admin_title = '" . $mail . "', settings = '" . serialize($settings) . "' WHERE mid = " . $box->mid . ";";
drush_sql_register_post_sync_op('mailbox_' . $mail, dt('Fix mailbox @box', array('@box' => $box->admin_title)), $sanitize_query);
}
// Fix Solr server port number.
$servers = drush_db_select('search_api_server', array('id', 'options', 'name'));
while ($server = drush_db_fetch_object($servers)) {
$options = unserialize($server->options);
$options['port'] = '8983';
$sanitize_query = "UPDATE search_api_server SET options = '" . serialize($options) . "' WHERE id = " . $server->id . ";";
drush_sql_register_post_sync_op('search_api_' . $server->id, dt('Fix search_api server @server', array('@server' => $server->name)), $sanitize_query);
}
}