Newer
Older
aaronwinborn
committed
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
<?php
function drupal_hub_server_admin_settings() {
$form = array();
// Allow the admin to turn on or off all services offered by various Hub modules on the server.
$form['cck'] = array(
'#type' => 'fieldset',
'#title' => t('Content Types'),
'#collapsible' => true,
'#collapsed' => false,
);
$form['cck']['current'] = array(
'#type' => 'fieldset',
'#title' => t('Current Hub Listing Types'),
'#description' => t('The following content types have been set to store Hub client listings. You may configure them individually below.'),
'#collapsible' => true,
'#collapsed' => false,
);
$types = drupal_hub_server_type_load();
if (empty($types)) {
$form['cck']['current']['#description'] = t('No content types are currently configured to store Hub client listings. You may select one or more content types from below.');
}
$cck = content_types();
$defaults = array(0 => t('(No Automatic Value)'));
$defaults += module_invoke_all('hubapi', 'field defaults');
foreach ($types as $type) {
$form['cck']['current']['drupal_hub_server_type_' . $type['type']] = array(
'#type' => 'fieldset',
'#title' => $type['name'],
'#description' => $type['description'],
'#collapsible' => true,
'#collapsed' => false,
);
$form['cck']['current']['drupal_hub_server_type_' . $type['type']]['auto'] = array(
'#type' => 'fieldset',
'#title' => t('Automatic Values'),
'#description' => t('Please select the automatic values for each desired field here. When an automatic value has been selected, the client site will automatically enter its corresponding value of the appropriate variable.'),
'#collapsible' => true,
'#collapsed' => true,
);
if ($type['has_title']) {
$form['cck']['current']['drupal_hub_server_type_' . $type['type']]['auto']['drupal_hub_server_' . $type['type'] . '_auto_title'] = array(
'#type' => 'select',
'#title' => $type['title_label'],
'#options' => $defaults,
'#default_value' => variable_get('drupal_hub_server_' . $type['type'] . '_auto_title', 'v:site_name'),
);
}
if ($type['has_body']) {
$form['cck']['current']['drupal_hub_server_type_' . $type['type']]['auto']['drupal_hub_server_' . $type['type'] . '_auto_body'] = array(
'#type' => 'select',
'#title' => $type['body_label'],
'#options' => $defaults,
'#default_value' => variable_get('drupal_hub_server_' . $type['type'] . '_auto_body', 'v:site_mission'),
);
}
foreach($type['fields'] as $field) {
$form['cck']['current']['drupal_hub_server_type_' . $type['type']]['auto']['drupal_hub_server_' . $type['type'] . '_auto_' . $field['field_name']] = array(
'#type' => 'select',
'#title' => $field['widget']['label'],
'#options' => $defaults,
'#default_value' => variable_get('drupal_hub_server_' . $type['type'] . '_auto_' . $field['field_name'], '0'),
);
}
}
$options = array();
foreach ($cck as $type) {
$options[$type['type']] = $type['name'];
}
$form['cck']['drupal_hub_server_cck_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Add Hub Listing Types'),
'#options' => $options,
'#default_value' => variable_get('drupal_hub_server_cck_types', array()),
'#description' => t('To enable a content type as a Hub listing type, check the box for the type and hit submit. You will then be able to modify its specific settings above. Likewise, to remove a type, uncheck the box and submit. It will then be removed from the listings above.'),
);
return system_settings_form($form);
}
function drupal_hub_server_type_load($type_name = NULL) {
static $types = array();
if (empty($types)) {
$drupal_hub_types = variable_get('drupal_hub_server_cck_types', array());
foreach ($drupal_hub_types as $type => $value) {
if ($value) {
$cck_type = content_types($value);
$types[$cck_type['type']] = $cck_type;
}
}
}
if ($type_name) {
return $types[$type_name];
}
return $types;
}
/**
* This is called by a client hub as an xmlrpc to request registration info.
* The server will respond with an xmlrpc message to the client with the appropriate info.
*/
function _drupal_hub_server_test($bool) {
if ($bool) { $output = 'true'; } else { $output = 'false'; }
return $output . t(' testing drupal_hub_server_register_request');
}
/**
* This returns the Hub server's info, in response to a ping from client servers
* wishing to list basic information about why they should register with a particular
* Hub server.
*/
function _drupal_hub_server_info() {
return variable_get('drupal_hub_server_info', variable_get('site_mission', ''));
}
/**
* This xml function will return the descriptions of the cck listing types
*/
function _drupal_hub_server_register_info() {
return drupal_hub_server_type_load();
}
/**
* Implementation of hook_xmlrpc().
* call like:
* $url = 'http://drupalhub.org/xmlrpc.php';
* $xml = xmlrpc($url, 'hub.server.register.request', $arg1, $arg2, ..., $argN);
*/
function _drupal_hub_server_xmlrpc() {
// TODO
$xmlrpc = array();
$xmlrpc[] = array(
'hub.server.test',
'_drupal_hub_server_test',
array('string', 'boolean'), // array($return_value_type, $arg1, $arg2, ..., $argN);
t('Test Hub server'),
);
$xmlrpc[] = array(
'hub.server.info',
'_drupal_hub_server_info',
array('string'),
t('Request Hub server\'s info'),
);
$xmlrpc[] = array(
'hub.server.register.info',
'_drupal_hub_server_register_info',
array('struct'),
t('Request Hub server\'s info'),
);
/* $xmlrpc[] = array(
'drupal.login',
'drupal_login',
array('int', 'string', 'string'),
t('Logging into a Drupal site')
);*/
return $xmlrpc;
}