function domain_user in Domain Access 5
Same name and namespace in other branches
- 6.2 domain.module \domain_user()
Implement hook_user()
Attached domain_id records to all registering users. These are used to determine which 'domain_editor' group that users with the 'edit domain nodes' permission are in.
4 string references to 'domain_user'
- domain_prefix_disallow in domain_prefix/
domain_prefix.module - Names of tables explicitly not allowed to be copied
- domain_user_configure_form in domain_user/
domain_user.module - FormsAPI
- domain_user_uninstall in domain_user/
domain_user.install - Implement hook_uninstall()
- domain_user_user in domain_user/
domain_user.module - Implement hook_user()
File
- ./
domain.module, line 286 - Core module functions for the Domain Access suite.
Code
function domain_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'form':
case 'register':
if (is_null($category) || $category == 'account') {
global $_domain;
$result = db_query("SELECT domain_id, subdomain, sitename, scheme FROM {domain}");
$options = array();
// By default, the requesting domain is assigned.
if (empty($account->domain_user)) {
$_domain['domain_id'] == 0 ? $default = array(
-1,
) : ($default = array(
$_domain['domain_id'],
));
}
else {
$default = $account->domain_user;
}
$options[-1] = variable_get('domain_sitename', variable_get('site_name', 'Drupal'));
while ($data = db_fetch_array($result)) {
$options[$data['domain_id']] = check_plain($data['sitename']);
}
if (user_access('assign domain editors')) {
$form['domain_user'] = array(
'#type' => 'fieldset',
'#title' => t('Domain access'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => 1,
);
$form['domain_user']['domain_user'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#title' => t('Domain access setttings'),
'#description' => t('Select the affiliates that this user belongs to. Used to grant editing permissions for users with the "edit domain nodes" permission.'),
'#default_value' => $default,
);
}
else {
$form['domain_user'] = array(
'#type' => 'value',
'#value' => $default,
);
}
return $form;
}
break;
case 'validate':
return array(
'domain_user' => $edit['domain_user'],
);
break;
case 'insert':
case 'update':
// If our field element is missing, do nothing.
if (!isset($edit['domain_user'])) {
return;
}
break;
case 'view':
if (user_access('assign domain editors') && !empty($account->domain_user)) {
$output = '<ul>';
foreach ($account->domain_user as $id) {
if (abs($id) > 0) {
if ($id > 0) {
$domain = domain_lookup($id);
$output .= '<li>' . check_plain($domain['sitename']) . '</li>';
}
else {
$output .= '<li>' . check_plain(variable_get('domain_sitename', variable_get('site_name', 'Drupal'))) . '</li>';
}
}
}
$output .= '</ul>';
$items['domain'] = array(
'title' => t('Domain settings'),
'value' => $output,
'class' => 'status',
);
return array(
t('Domain status') => $items,
);
}
break;
}
}