-
Notifications
You must be signed in to change notification settings - Fork 0
/
rw.install
150 lines (130 loc) · 4.05 KB
/
rw.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
function rw_install() {
theme_enable(array('bootstrap','seven'));
variable_set('theme_default', 'bootstrap');
theme_disable(array('bartik'));
$full_html_format = array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 1,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);
$types = array(
array(
'type' => 'page',
'name' => st('Basic page'),
'base' => 'node_content',
'description' => st("Static content, such as an 'About us' page."),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
array(
'type' => 'news',
'name' => st('News page'),
'base' => 'node_content',
'description' => st("Site news content"),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
array(
'type' => 'location',
'name' => st('Location'),
'base' => 'node_content',
'description' => st("Warehouse"),
'custom' => 1,
'modified' => 1,
'locked' => 0,
)
);
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
}
// Blocks
$blocks = array(
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'bootstrap',
'status' => 1,
'weight' => 0,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'commerce_cart',
'delta' => 'cart',
'theme' => 'bootstrap',
'status' => 1,
'weight' => 1,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
)
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($blocks as $block) {
$query->values($block);
}
$query->execute();
// User & Roles
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 10;
user_role_save($admin_role);
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
// Set this as the administrator role.
variable_set('user_admin_role', $admin_role->rid);
$arole = new stdClass();
$arole->name = 'api';
$arole->weight = 2;
user_role_save($arole);
$prole = new stdClass();
$prole->name = 'producthandler';
$prole->weight = 3;
user_role_save($prole);
$orole = new stdClass();
$orole->name = 'orderhandler';
$orole->weight = 4;
user_role_save($orole);
$wrole = new stdClass();
$wrole->name = 'warehouse';
$wrole->weight = 5;
user_role_save($wrole);
db_insert('users_roles')->fields(array('uid' => 1, 'rid' => $admin_role->rid))->execute();
// User role grants
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content','view any commerce_product entity'));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content','access checkout'));
// API Role grants
user_role_grant_permissions($arole->rid, array('get any binary files', 'save file information','create commerce_product entities', 'view any commerce_product entity'));
// Product handler
user_role_grant_permissions($prole->rid, array('create commerce_product entities', 'view any commerce_product entity'));
// Order handler
user_role_grant_permissions($orole->rid, array('view any commerce_customer_profile entity', 'view any commerce_customer_profile entity of bundle billing', 'view any commerce_product entity'));
// Warehouse handler
user_role_grant_permissions($prole->rid, array('create commerce_product entities', 'view any commerce_product entity'));
variable_set('admin_theme', 'seven');
variable_set('node_admin_theme', '1');
}