forked from easyting/ding_user_profile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathding_user_profile.module
More file actions
executable file
·78 lines (65 loc) · 2.22 KB
/
ding_user_profile.module
File metadata and controls
executable file
·78 lines (65 loc) · 2.22 KB
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
<?php
/**
* @file
* Profile extensive features main file.
*/
/**
* Implements hook_menu().
*/
function ding_user_profile_menu() {
$menu = array();
$menu['admin/config/ding/user_profile'] = array(
'title' => 'Ding user profile',
'description' => 'Manage the user profile features',
'access arguments' => array('manage user profile features'),
'page callback' => 'drupal_get_form',
'page arguments' => array('ding_user_profile_admin_form'),
'file' => 'ding_user_profile.admin.inc',
);
return $menu;
}
/**
* Implements hook_permission().
*/
function ding_user_profile_permission() {
$perm = array();
$perm['manage user profile features'] = array(
'title' => t('User profile features'),
);
return $perm;
}
/**
* Implements hook_form_alter().
*
* This will override the description in some specific manner.
*
* Since the fields have slightly different structure, #suffix is used
* instead. Standard #description is blanked and not used here.
*
* Especially this counts for date-select fields, where #description is used
* as a field #title.
*/
function ding_user_profile_form_profile2_form_alter(&$form, &$form_state) {
global $user;
if (ding_user_is_provider_user($user)) {
$profile_type = ding_user_get_provider_profile_type();
if ($form_state['profile2']->type == $profile_type->type) {
$description = variable_get('user_profile_pass', '');
$form['pass']['#suffix'] = '<div class="description">' . t($description) . '</div>';
$form['pass']['#description'] = '';
$profile = 'profile_' . $profile_type->type;
foreach (element_children($form[$profile]) as $element) {
// Skip hidden fields.
if (in_array('field-widget-hidden', $form[$profile][$element]['#attributes']['class'])) {
continue;
}
$description = variable_get('user_profile_' . $element, '');
if (empty($form[$profile][$element][LANGUAGE_NONE]['#suffix'])) {
$form[$profile][$element][LANGUAGE_NONE]['#suffix'] = '';
}
$form[$profile][$element][LANGUAGE_NONE]['#suffix'] .= '<div class="description">' . t($description) . '</div>';
$form[$profile][$element][LANGUAGE_NONE]['#description'] = '';
}
}
}
}