From 16d5d720ec8240050c3150e0ec866b78355c3bb6 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 14 Sep 2014 12:00:24 +0300 Subject: [PATCH] edit extra fields of user --- ipf/auth/admin.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ipf/auth/admin.php b/ipf/auth/admin.php index 69ff322..87b9c5a 100644 --- a/ipf/auth/admin.php +++ b/ipf/auth/admin.php @@ -75,6 +75,19 @@ class UserForm extends \IPF_ObjectForm 'help_text' => __('Designates that this user has all permissions without explicitly assigning them.'), )); + $r = new \ReflectionClass(\PFF\Container::auth()->userModel); + $extra_fields = array(); + foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) { + $name = $p->getName(); + if (in_array($name, array('id', 'username', 'password', 'email', 'is_active', 'is_staff', 'is_superuser', 'last_login')) || $name[0] === '_') + continue; + + $this->fields[$name] = new \IPF_Form_Field_Varchar(array( + 'label' => \IPF_Utils::humanTitle($name), + )); + $extra_fields[] = $name; + } + $permissions = array('is_active', 'is_staff', 'is_superuser'); if (\IPF_Auth_App::ArePermissionsEnabled()) { $permissions[] = 'permissions'; @@ -100,6 +113,10 @@ class UserForm extends \IPF_ObjectForm array('fields' => array('username', 'password1', 'password2', 'email')), array('fields' => $permissions, 'label' => __('Permissions')), ); + + if ($extra_fields) { + $this->field_groups[] = array('fields' => $extra_fields, 'label' => __('Extra')); + } } public function clean() -- 2.49.0