-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd8ux.module
312 lines (269 loc) · 7.75 KB
/
d8ux.module
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
/**
* Implements hook_permission().
*/
function d8ux_permission() {
return array(
'administer d8ux' => array(
'title' => t('Administer D8UX'),
),
);
}
/**
* Implements hook_menu().
*/
function d8ux_menu() {
$items['admin/config/user-interface/d8ux'] = array(
'title' => 'D8UX settings',
'description' => 'Configure D8UX.',
'page callback' => 'drupal_get_form',
'page arguments' => array('d8ux_admin_settings'),
'access arguments' => array('administer d8ux'),
'file' => 'd8ux.admin.inc',
'weight' => -10,
);
return $items;
}
/**
* Implements hook_FORM_ID_alter().
*/
function d8ux_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
$forms = array(
'block',
'contact',
'locale',
'overlay_control',
'picture',
'signature_settings',
'timezone',
);
if (variable_get('d8ux_consistent_fieldsets', 0)) {
foreach ($forms as $f) {
$form[$f]['#collapsible'] = TRUE;
}
if (variable_get('d8ux_fieldsets_collapsed', 0)) {
foreach ($forms as $f) {
$form[$f]['#collapsed'] = TRUE;
}
}
}
/*
$form['d8ux'] = array(
'#type' => 'vertical_tabs',
'#title' => 'D8UX',
);
$form['d8ux_example'] = array(
'#type' => 'fieldset',
'#title' => 'test tab',
'#group' => 'd8ux',
);
$form['d8ux_example2'] = array(
'#type' => 'fieldset',
'#title' => 'test tab 2',
'#group' => 'group_account_settings',
);
*/
/*$form['#groups']['group_account_settings']['d8ux_example2'] = array(
'#type' => 'fieldset',
'#title' => 'test tab 2',
'#group' => 'd8ux',
);*/
//$form['#groups']['group_account_settings']->children[] = 'd8ux_example2';
//debug($form['#groups']['group_account_settings']->children);
//
}
/*function d8ux_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
global $user;
if (variable_get('d8ux_edit_account_vertical_tabs', 0)) {
$account = $form['#user'];
$register = ($form['#user']->uid > 0 ? FALSE : TRUE);
$admin = user_access('administer users');
$js = drupal_get_path('module', 'd8ux') . '/d8ux.js';
if ($form['#user_category'] == 'account') {
// Create vertical tabs group
$form['d8ux_user_settings'] = array(
'#title' => t('User Settings'),
'#type' => 'vertical_tabs',
'#weight' => 50,
);
// Put username/password to fieldset
$form['account'] += array(
'#title' => t('Username and password'),
'#type' => 'fieldset',
);
// Move Roles and status to vertical tabs
$form['account_roles_status'] = array(
'#title' => t('Roles and status'),
'#type' => 'fieldset',
'#group' => 'd8ux_user_settings',
'#access' => $admin,
'#weight' => -10,
);
$form['account_roles_status']['status'] = $form['account']['status'];
$form['account_roles_status']['roles'] = $form['account']['roles'];
$form['account_roles_status'] += array(
'#attributes' => array(
'class' => array('d8ux-user-form-account-roles-status'),
),
'#attached' => array(
'js' => array($js),
),
);
$form['account']['roles'] = '';
$form['account']['status'] = '';
// Signature settings
$form['signature_settings'] += array(
'#group' => 'd8ux_user_settings',
);
// Picture settings
$form['picture'] += array(
'#group' => 'd8ux_user_settings',
);
// Personal contact form settings
if (module_exists('contact')) {
$form['contact']['#collapsible'] = FALSE;
$form['contact']['#group'] = 'd8ux_user_settings';
$form['contact'] += array(
'#attributes' => array(
'class' => array('d8ux-user-form-personal-contact-form'),
),
'#attached' => array(
'js' => array($js),
),
);
}
// Administrative overlay
if (module_exists('overlay')) {
$form['overlay_control']['#group'] = 'd8ux_user_settings';
$form['overlay_control']['#collapsible'] = FALSE;
$form['overlay_control'] += array(
'#attributes' => array(
'class' => array('d8ux-user-form-administrative-overlay'),
),
'#attached' => array(
'js' => array($js),
),
);
}
// Custom blocks
if (module_exists('block')) {
$form['block']['#group'] = 'd8ux_user_settings';
$form['block']['#collapsible'] = FALSE;
}
// Timezone
$form['timezone']['#group'] = 'd8ux_user_settings';
$form['timezone']['#collapsible'] = FALSE;
$form['timezone'] += array(
'#attributes' => array(
'class' => array('d8ux-user-form-timezone'),
),
);
//$form['#groups']['group_d8ux_user_settings']['#group'] = 'd8ux_user_settigs';
}
}
//debug($form);
}*/
/**
* Implements hook_page_alter().
* see http://cyrve.com/d7render
*/
function d8ux_page_alter(&$page) {
if (module_exists('toolbar')) {
if (variable_get('d8ux_toolbar_edit_account_link', 0)) {
$page['page_top']['toolbar']['#pre_render'][0] = 'd8ux_toolbar_pre_render';
}
}
}
/**
* Implements hook_pre_render().
*/
function d8ux_toolbar_pre_render($toolbar) {
global $user;
$build = toolbar_view();
$module_path = drupal_get_path('module', 'd8ux');
if ($user->uid) {
$links = array(
'account' => array(
'title' => t('Hello <strong>@username</strong>', array('@username' => format_username($user))),
'href' => 'user',
'html' => TRUE,
'attributes' => array(
'title' => t('User account'),
'class' => array(
'' => 'parent',
),
),
),
'account edit' => array(
'title' => 'Edit account',
'href' => "user/$user->uid/edit",
'html' => true,
'attributes' => array('title' => 'Edit user account'),
),
'logout' => array(
'title' => t('Log out'),
'href' => 'user/logout',
),
);
}
else {
$links = array(
'login' => array(
'title' => t('Log in'),
'href' => 'user',
),
);
}
$build['toolbar_user']['#links'] = $links;
$build['#attached']['css'][] = $module_path . '/d8ux_toolbar.css';
$toolbar = array_merge($toolbar, $build);
return $toolbar;
}
/**
* Implements hook_field_extra_fields().
*/
function d8ux_field_extra_fields() {
if (module_exists('overlay')) {
$extra['user']['user']['form']['overlay_control'] = array(
'label' => 'Administrative overlay',
'description' => t('Overlay module form element.'),
'weight' => 0,
);
}
if (module_exists('block')) {
$extra['user']['user']['form']['block'] = array(
'label' => 'Personalize blocks',
'description' => t('Block module form element.'),
'weight' => 0,
);
}
if (module_exists('contact')) {
$extra['user']['user']['form']['contact'] = array(
'label' => 'Contact',
'description' => t('Contact module form element.'),
'weight' => 0,
);
}
if (module_exists('locale')) {
$extra['user']['user']['form']['locale'] = array(
'label' => 'Language settings',
'description' => t('Locale module form element.'),
'weight' => 0,
);
}
if (variable_get('user_pictures', 1) == 1) {
$extra['user']['user']['form']['picture'] = array(
'label' => 'User picture',
'description' => t('User module picture form element.'),
'weight' => 0,
);
}
if (variable_get('user_signatures', 1) == 1) {
$extra['user']['user']['form']['signature_settings'] = array(
'label' => 'User signature',
'description' => t('User module signature form element.'),
'weight' => 0,
);
}
return $extra;
}