function connector_user_sync_form in Connector 7
1 string reference to 'connector_user_sync_form'
- connector_menu in ./
connector.module - Implements hook_menu().
File
- ./
connector.pages.inc, line 203 - Contains all non-admin pages for the Connector module
Code
function connector_user_sync_form($form, &$form_state, $account, $cid) {
module_load_include('inc', 'user', 'user.pages');
$form = user_profile_form($form, $form_state, $account);
$hooks = array(
'form',
'form_user_profile_form',
);
$form_id = 'form_user_profile_form';
drupal_alter($hooks, $form, $form_state, $form_id);
list($connector_name, $xuid) = explode('__', $cid);
$connector = _connector_get_connectors($connector_name);
drupal_set_title(t('Synchronize profile with @title', array(
'@title' => $connector['title'],
)));
$info = array();
if (is_callable($connector['information callback'])) {
$info = $connector['information callback']($connector, $xuid);
}
// We put access on false and explictly turn access on.
$children_keys = element_children($form);
foreach ($children_keys as $key) {
if ($key == 'account') {
$account_children_keys = element_children($form['account']);
foreach ($account_children_keys as $account_key) {
$form['account'][$account_key]['#access'] = FALSE;
}
}
else {
$form[$key]['#access'] = FALSE;
}
}
// only allow fields we can sync.
foreach ($info as $field) {
if (isset($field['sync']) && $field['sync']) {
if (isset($form['account'][$field['sync']])) {
$form['account'][$field['sync']]['#access'] = TRUE;
}
elseif (isset($form[$field['sync']])) {
$form[$field['sync']]['#access'] = TRUE;
}
}
}
// For some fields we need to supply the current password.
if (isset($form['account']['current_pass_required_values']['#value'])) {
foreach ($form['account']['current_pass_required_values']['#value'] as $key => $value) {
if (isset($form['account'][$key]['#access']) && $form['account'][$key]['#access']) {
$form['account']['current_pass']['#access'] = TRUE;
}
}
}
// Prefill.
_connector_prefill_user_form($form, $info);
array_unshift($form['#submit'], 'connector_user_sync_form_first_submit');
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save sync with @title', array(
'@title' => $connector['title'],
)),
);
return $form;
}