]> git.andy128k.dev Git - ipf.git/commitdiff
edit extra fields of user
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 14 Sep 2014 09:00:24 +0000 (12:00 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 14 Sep 2014 09:00:24 +0000 (12:00 +0300)
ipf/auth/admin.php

index 69ff322b2bd876b972a91eb395575d02f868b890..87b9c5ae73c23a6bc9cd73579d5557f4a1a99821 100644 (file)
@@ -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()