-
Notifications
You must be signed in to change notification settings - Fork 0
/
memberdb.admin.inc
99 lines (90 loc) · 3.45 KB
/
memberdb.admin.inc
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
<?php
/**
* MemberDB settings form.
*/
function memberdb_admin_settings() {
// This whole thing will fail if there is no 'memberdb' $db_url in settings.php.
// So check for that first.
global $db_url;
if (!is_array($db_url) || empty($db_url['memberdb'])) {
drupal_set_message(t('This module requires additional configuration. No $db_url named memberdb was found in your settings.php file. Please add one.'), 'error');
$config = FALSE;
}
else {
drupal_set_message(t('Your settings.php file contains a $db_url named memberdb.'));
$config = TRUE;
}
// If the memberdb db_url wasn't found, expand this help section.
$form = array();
$form['help'] = array(
'#type' => 'fieldset',
'#title' => 'Help',
'#collapsible' => TRUE,
'#collapsed' => $config,
);
$form['help']['memberdb_help'] = array(
'#type' => 'markup',
'#value' => memberdb_admin_settings_help(),
);
if ($config == FALSE) {
return system_settings_form($form);
}
$form['memberdb'] = array(
'#type' => 'fieldset',
'#title' => 'Drupal Integration',
'#description' => t('Please configure the MemberDB integration options below. These will ensure the correct member data is displayed on the user profile.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['memberdb']['memberdb_organisation'] = array(
'#type' => 'select',
'#title' => 'Organisation',
'#description' => t('Select the MemberDB organisation for which you want to display data on this site.'),
'#options' => memberdb_get_organisations(TRUE),
'#default_value' => variable_get('memberdb_organisation', 0),
);
$form['memberdb']['memberdb_type'] = array(
'#type' => 'select',
'#title' => 'Member',
'#description' => t('Select the MemberDB membership type that is assigned to all members.'),
'#options' => memberdb_get_types(TRUE),
'#default_value' => variable_get('memberdb_type', 0),
);
$form['memberdb']['memberdb_role'] = array(
'#type' => 'select',
'#title' => 'Member Role',
'#description' => t('Select the Drupal role that should be assigned to current MemberDB members when they login.'),
'#options' => user_roles(TRUE),
'#default_value' => variable_get('memberdb_role', array()),
);
return system_settings_form($form);
}
/**
* Creates the help text for the MemberDB settings page
*
* @return
* HTML with the help text
*/
function memberdb_admin_settings_help() {
return t('
<p>To make use of the <em>memberdbtoboggan</em> module, Drupal needs to be able to access the MemberDB backend database.</p>
<p>You can configure this database by editing your settings.php file.</p>
<p>Modify the $db_url variable, so that instead of a string it is an array. The array should have at least a \'default\' key that contains the existing url for the Drupal database.
First, change:
<pre>
$db_url = \'mysqli://username:password@localhost/database\';
</pre>
<p>To:</p>
<pre>
$db_url = array();
$db_url[\'default\'] = \'mysqli://username:password@localhost/database\';
</pre>
<p>You can now append the database url for the MemberDB database below the default url. You should give it the key \'memberdb\'.
<pre>
$db_url = array();
$db_url[\'default\'] = \'mysqli://username:password@localhost/database\';
$db_url[\'radius\'] = \'mysqli://memberdb:secret@localhost/memberdb\';
</pre>
<p>The <em>memberdb</em> account needs to be able to read from and write to the table with account credentials and attributes.</p>
');
}