/
wn_common.install
77 lines (66 loc) · 2.59 KB
/
wn_common.install
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Implementation of hook_install().
*/
function wn_common_install() {
// Unfortunately, we have to manually create the Menu block for displaying secondary navigation.
// Menu block configuration has been strongarmed in feature definition.
$module = 'menu_block';
$delta = '1';
db_query("INSERT INTO {blocks} (module, delta, theme, status) VALUES ('%s', %d, '%s', 1)", $module, $delta, 'watershed');
}
function wn_common_update_6000( &$sandbox ) {
//use relative URLs when inserting images
variable_set('insert_absolute_paths', FALSE);
//Refresh module list
module_list(TRUE);
module_rebuild_cache();
//include install_profile_api user functions
include($_SERVER['DOCUMENT_ROOT'] . '/profiles/watershednow/libraries/install_profile_api/core/user.inc');
//add feed permissions to staff and web admin
$new_permissions = array('staff' => array(
'administer feeds',
'clear update_feed feeds',
'import update_feed feeds',
));
$new_permissions['web admin'] = array_merge($new_permissions['staff'], array('administer nodes'));
foreach( $new_permissions as $role => $perms ) {
$role_rid = install_get_rid($role);
if( $role_rid ) {
install_add_permissions($role_rid,$perms);
}
}
// Install Mollom for spam protection
drupal_install_modules(array('mollom'));
// return empty array so Drupal does not complain about array_merge
return array();
}
function wn_common_update_6001( &$sandbox ) {
wn_common_configure_mollom(); // needs to be in a separate step from enabling mollom
// return empty array so Drupal does not complain about array_merge
return array();
}
function wn_common_configure_mollom() {
//add mollom captcha to comment forms
$mollom_form = array(
'form_id' => 'comment_form',
'mode' => MOLLOM_MODE_CAPTCHA,
'checks' => array('spam'),
'discard' => TRUE,
'enabled_fields' => array('subject','comment'),
'module' => 'comment'
);
$exists = db_result(db_query_range("SELECT 1 FROM {mollom_form} WHERE form_id = '%s'", $mollom_form['form_id'], 0, 1));
$status = drupal_write_record('mollom_form', $mollom_form, ($exists ? 'form_id' : array()));
//add mollom captcha to user registration forms
$mollom_form = array(
'form_id' => 'user_register',
'mode' => MOLLOM_MODE_CAPTCHA,
'checks' => array(),
'discard' => TRUE,
'enabled_fields' => array(),
'module' => 'user'
);
$exists = db_result(db_query_range("SELECT 1 FROM {mollom_form} WHERE form_id = '%s'", $mollom_form['form_id'], 0, 1));
$status = drupal_write_record('mollom_form', $mollom_form, ($exists ? 'form_id' : array()));
}