'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 (\PFF\Container::auth()->arePermissionsEnabled()) {
$permissions[] = 'permissions';
array('fields' => $permissions, 'label' => __('Permissions')),
);
+ $extra_fields = call_user_func(array(\PFF\Container::auth()->userModel, 'adminExtraFields'));
if ($extra_fields) {
- $this->field_groups[] = array('fields' => $extra_fields, 'label' => __('Extra'));
+ $this->fields = array_merge($this->fields, $extra_fields);
+ $this->field_groups[] = array('fields' => array_keys($extra_fields), 'label' => __('Extra'));
}
}
->where(implode(' OR ', $cond), $params)
->fetchColumn() == count($params);
}
+
+ /* admin */
+
+ public static function adminExtraFields()
+ {
+ $r = new \ReflectionClass(get_called_class());
+ $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;
+
+ $extra_fields[$name] = new \IPF_Form_Field_Varchar(array(
+ 'label' => \IPF_Utils::humanTitle($name),
+ ));
+ }
+ return $extra_fields;
+ }
}
class Role extends DBObject