public function canChangeEmail() { if (in_array('email', AuthClientHelpers::getSyncAttributesByUser($this->getIdentity()))) { return false; } return true; }
/** * Returns the Profile as CForm */ public function getFormDefinition() { $definition = array(); $definition['elements'] = array(); $syncAttributes = []; if ($this->user !== null) { $syncAttributes = \humhub\modules\user\authclient\AuthClientHelpers::getSyncAttributesByUser($this->user); } $safeAttributes = $this->safeAttributes(); foreach (ProfileFieldCategory::find()->orderBy('sort_order')->all() as $profileFieldCategory) { $category = array('type' => 'form', 'title' => Yii::t($profileFieldCategory->getTranslationCategory(), $profileFieldCategory->title), 'elements' => array()); foreach (ProfileField::find()->orderBy('sort_order')->where(['profile_field_category_id' => $profileFieldCategory->id])->all() as $profileField) { $profileField->editable = true; if (!in_array($profileField->internal_name, $safeAttributes)) { if ($profileField->visible && $this->scenario != 'registration') { $profileField->editable = false; } else { continue; } } // Dont allow editing of ldap syned fields - will be overwritten on next ldap sync. if (in_array($profileField->internal_name, $syncAttributes)) { $profileField->editable = false; } $fieldDefinition = $profileField->fieldType->getFieldFormDefinition(); $category['elements'] = array_merge($category['elements'], $fieldDefinition); $profileField->fieldType->loadDefaults($this); } $definition['elements']['category_' . $profileFieldCategory->id] = $category; } return $definition; }