function bakery_form_alter in Bakery Single Sign-On System 7.4
Same name and namespace in other branches
- 8.2 bakery.module \bakery_form_alter()
- 6.2 bakery.module \bakery_form_alter()
- 6 bakery.module \bakery_form_alter()
- 7.2 bakery.module \bakery_form_alter()
- 7.3 bakery.module \bakery_form_alter()
Implements hook_form_alter().
File
- ./
bakery.module, line 133
Code
function bakery_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_profile_form':
case 'user_edit_form':
if (!variable_get('bakery_is_master', 0) && !user_access('administer users')) {
$init_url = _bakery_init_field_url($form['#user']->init);
$index = key($form);
if (isset($form['account'])) {
drupal_set_message(t('You can change the name, mail, and password <a href="!url">at the master site</a>.', array(
'!url' => check_url($init_url),
)), 'status', FALSE);
$form['account']['#access'] = FALSE;
$form['account']['name']['#access'] = FALSE;
$form['account']['pass']['#access'] = FALSE;
$form['account']['mail']['#access'] = FALSE;
}
foreach (variable_get('bakery_supported_fields', array(
'mail' => 'mail',
'name' => 'name',
)) as $type => $value) {
if ($value) {
switch ($type) {
case 'mail':
case 'name':
break;
case 'picture':
if (isset($form['picture'])) {
$form['picture']['picture_delete']['#access'] = FALSE;
$form['picture']['picture_upload']['#access'] = FALSE;
$form['picture']['#description'] = t('You can change the image <a href="!url">at the master site</a>.', array(
'!url' => check_url($init_url),
));
}
break;
case 'language':
if (isset($form['locale'][$type])) {
$form['locale'][$type]['#disabled'] = TRUE;
$form['locale'][$type]['#description'] .= ' ' . t('You can change the language setting <a href="!url">at the master site</a>.', array(
'!url' => check_url($init_url),
));
}
break;
case 'signature':
if (isset($form['signature_settings'][$type])) {
$form['signature_settings'][$type]['#disabled'] = TRUE;
$form['signature_settings'][$type]['#description'] .= ' ' . t('You can change the signature <a href="!url">at the master site</a>.', array(
'!url' => check_url($init_url),
));
}
break;
default:
if (isset($form[$type])) {
$form[$type]['#disabled'] = TRUE;
}
if (isset($form[$type][$type])) {
$form[$type][$type]['#disabled'] = TRUE;
$form[$type][$type]['#description'] .= ' ' . t('You can change this setting <a href="!url">at the master site</a>.', array(
'!url' => check_url($init_url),
));
}
break;
}
}
}
}
break;
case 'user_register_form':
// Provide register ability on the slave sites.
if (!variable_get('bakery_is_master', FALSE)) {
if (arg(0) == 'admin') {
// Admin create user form. Add a note about account synchronization.
$form['account']['bakery_help'] = array(
'#value' => t('<strong>Note:</strong> Only use this form to create accounts for users who exist on <a href="!url">@master</a> and not on this site. Be sure to use the exact same username and e-mail for the account here that they have on @master.', array(
'!url' => variable_get('bakery_master', 'https://drupal.org'),
'@master' => variable_get('bakery_master', 'https://drupal.org'),
)),
'#weight' => -100,
);
}
else {
// @todo: provide a link to the master site.
$form = array();
}
}
break;
case 'user_pass':
// @todo: provide a link to the master site.
if (!variable_get('bakery_is_master', FALSE)) {
$form = array();
}
break;
case 'user_pass_reset':
// @todo: provide a link to the master site.
if (!variable_get('bakery_is_master', FALSE)) {
$form = array();
}
break;
case 'user_login_block':
case 'user_login':
// @todo: provide a link to the master site.
if (!variable_get('bakery_is_master', FALSE)) {
$form = array();
}
break;
default:
break;
}
}