-
Notifications
You must be signed in to change notification settings - Fork 0
/
realname.install
150 lines (138 loc) · 5.25 KB
/
realname.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
/**
* @file
* Installation file for Realname module.
*/
/**
* Implements hook_schema().
*/
function realname_schema() {
$schema['realname'] = array(
'description' => 'Computed Real Names to reduce overhead.',
'fields' => array(
'uid' => array(
'description' => 'User ID, links to User table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'realname' => array(
'description' => 'The generated real name of the user.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The UNIX timestamp of when the real name was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('uid'),
'indexes' => array(
'realname' => array('realname'),
),
'foreign keys' => array(
'users' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
return $schema;
}
/**
* Implements hook_requirements().
*/
function realname_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
if (!config_get('realname.settings','realname_suppress_user_name_mail_validation') && strpos(config_get('realname.settings','user_mail_register_admin_created_body'), '[user:name-raw]') === FALSE) {
$requirements['user_mail_register_admin_created_body'] = array(
'title' => $t('E-mail: "Welcome (new user created by administrator)" template'),
'value' => $t('Not configured'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('Replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in <a href="@people">e-mail</a> template, if using username for login.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-admin-created')))),
);
}
if (!config_get('realname.settings','realname_suppress_user_name_mail_validation') && strpos(config_get('realname.settings','user_mail_register_no_approval_required_body'), '[user:name-raw]') === FALSE) {
$requirements['user_mail_register_no_approval_required_body'] = array(
'title' => $t('E-mail: "Welcome (no approval required)" template'),
'value' => $t('Not configured'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('Replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in <a href="@people">e-mail</a> template, if using username for login.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-no-approval-required')))),
);
}
if (!config_get('realname.settings','realname_suppress_user_name_mail_validation') && strpos(config_get('realname.settings','user_mail_status_activated_body'), '[user:name-raw]') === FALSE) {
$requirements['user_mail_status_activated_body'] = array(
'title' => $t('E-mail: "Account activation" template'),
'value' => $t('Not configured'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('Replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in <a href="@people">e-mail</a> template, if using username for login.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-activated')))),
);
}
}
return $requirements;
}
/**
* Implements hook_disable().
*/
function realname_disable() {
backdrop_set_message(t('You need to replace the token <code>[user:name-raw]</code> with <code>[user:name]</code> in e-mail templates.'), 'warning');
}
/**
* Implements hook_uninstall().
*/
function realname_uninstall() {
// variable_del('realname_pattern');
// variable_del('realname_suppress_user_name_mail_validation');
}
/**
* Update the {realname} table for Drupal 7.
*/
function realname_update_7000() {
// Add the {realname}.created field if it doesn't already exist.
if (!db_field_exists('realname', 'created')) {
$fields['created'] = array(
'description' => 'The UNIX timestamp of when the real name was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
db_add_field('realname', 'created', $fields['created']);
}
$fields['realname'] = array(
'description' => 'The generated real name of the user.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
);
db_change_field('realname', 'realname', 'realname', $fields['realname']);
}
/**
* Remove variables from D6 that are no longer needed.
function realname_update_7001() {
variable_del('realname_fields');
variable_del('realname_homepage');
variable_del('realname_max_username');
variable_del('realname_myacct');
variable_del('realname_nodeapi');
variable_del('realname_nofollow');
variable_del('realname_notver');
variable_del('realname_profile_module');
variable_del('realname_recalculate');
variable_del('realname_search_enable');
variable_del('realname_search_login');
variable_del('realname_theme');
variable_del('realname_user_disable');
variable_del('realname_use_title');
variable_del('realname_view');
}
*/