UserCompleteProfileController.php in Complete profile 7
File
includes/UserCompleteProfileController.php
View source
<?php
class UserCompleteProfileController implements CompleteProfileControllerInterface {
public static function isFieldEmpty($account, $field_name) {
if ($field = field_info_field($field_name)) {
return EntityCompleteProfileController::isFieldEmpty('user', $account, $field);
}
}
public static function hasEmptyRequiredFields($account) {
return EntityCompleteProfileController::hasEmptyRequiredFields('user', $account);
}
public static function getFieldsForm($account, array &$form_state) {
form_load_include($form_state, 'inc', 'user', 'user.pages');
$form = user_profile_form(array(), $form_state, $account);
$form['account']['name']['#access'] &= empty($account->name);
$form['account']['mail']['#access'] = empty($account->mail);
$form['account']['pass']['#access'] = FALSE;
$form['account']['current_pass']['#access'] = FALSE;
$form['account']['status']['#access'] = FALSE;
$form['account']['roles']['#access'] &= empty($account->roles);
$form['signature_settings']['#access'] = FALSE;
$form['picture']['#access'] &= empty($account->picture);
$instances = field_info_instances('user', 'user');
foreach ($instances as $field_name => $instance) {
if (isset($form[$field_name])) {
if (!empty($instance['required'])) {
if (!self::isFieldEmpty($account, $field_name)) {
$form[$field_name]['#access'] = FALSE;
}
}
elseif (empty($instance['user_register_form'])) {
$form[$field_name]['#access'] = FALSE;
}
}
}
$form['#user_category'] = 'register';
unset($form['actions']);
return $form;
}
}