1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 11:20:15 +02:00

v2.9 distatch userforms

This commit is contained in:
trendschau
2024-09-01 15:09:16 +02:00
parent bb2da02182
commit 756f90dd47
3 changed files with 31 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ use Typemill\Models\Validation;
use Typemill\Models\User;
use Typemill\Static\Translations;
use Typemill\Static\Session;
use Typemill\Events\OnUserfieldsLoaded;
class ControllerApiSystemUsers extends Controller
{
@@ -223,13 +224,18 @@ class ControllerApiSystemUsers extends Controller
# check if loginlink is activated
$loginlink = false;
if($userdata['userrole'] == 'guest' && isset($this->settings['loginlink']) && $this->settings['loginlink'])
if(isset($userdata['userrole']) && $userdata['userrole'] == 'guest' && isset($this->settings['loginlink']) && $this->settings['loginlink'])
{
$loginlink = true;
}
# we have to validate again because of additional dynamic fields
$formdefinitions = $user->getUserFields($this->c->get('acl'), $request->getAttribute('c_userrole'), NULL, $loginlink);
$customfields = $this->c->get('dispatcher')->dispatch(new OnUserfieldsLoaded($formdefinitions), 'onUserfieldsLoaded')->getData();
if($customfields)
{
$formdefinitions = $customfields;
}
$validatedOutput = $validate->recursiveValidation($formdefinitions, $userdata);
if(!empty($validate->errors))
{
@@ -275,8 +281,13 @@ class ControllerApiSystemUsers extends Controller
return $response->withHeader('Content-Type', 'application/json')->withStatus(400);
}
$user = new User();
$userform = $user->getUserFields($this->c->get('acl'), $userrole,$inspectorrole = $request->getAttribute('c_userrole'));
$user = new User();
$userform = $user->getUserFields($this->c->get('acl'), $userrole,$inspectorrole = $request->getAttribute('c_userrole'));
$customfields = $this->c->get('dispatcher')->dispatch(new OnUserfieldsLoaded($userfields), 'onUserfieldsLoaded')->getData();
if($customfields)
{
$userform = $customfields;
}
# fix the standard form
$userform['password']['label'] = 'Password';
@@ -325,6 +336,11 @@ class ControllerApiSystemUsers extends Controller
# additional validation for extra fields and image handling
$user = new User();
$formdefinitions = $user->getUserFields($this->c->get('acl'), $userdata['userrole'],$inspectorrole = $request->getAttribute('c_userrole'));
$customfields = $this->c->get('dispatcher')->dispatch(new OnUserfieldsLoaded($formdefinitions), 'onUserfieldsLoaded')->getData();
if($customfields)
{
$formdefinitions = $customfields;
}
unset($formdefinitions['username']['readonly']);
$validatedOutput = $validate->recursiveValidation($formdefinitions, $userdata);
if(!empty($validate->errors))

View File

@@ -9,6 +9,7 @@ use Typemill\Models\Extension;
use Typemill\Models\User;
use Typemill\Models\License;
use Typemill\Models\Settings;
use Typemill\Events\OnUserfieldsLoaded;
class ControllerWebSystem extends Controller
{
@@ -270,6 +271,11 @@ class ControllerWebSystem extends Controller
$userdata = $user->getUserData();
$userfields = $user->getUserFields($this->c->get('acl'), $userdata['userrole']);
$customfields = $this->c->get('dispatcher')->dispatch(new OnUserfieldsLoaded($userfields), 'onUserfieldsLoaded')->getData();
if($customfields)
{
$userfields = $customfields;
}
return $this->c->get('view')->render($response, 'system/account.twig', [
'settings' => $this->settings,
@@ -365,6 +371,11 @@ class ControllerWebSystem extends Controller
$loginlink = true;
}
$userfields = $user->getUserFields($this->c->get('acl'), $userdata['userrole'], $inspector, $loginlink);
$customfields = $this->c->get('dispatcher')->dispatch(new OnUserfieldsLoaded($userfields), 'onUserfieldsLoaded')->getData();
if($customfields)
{
$userfields = $customfields;
}
return $this->c->get('view')->render($response, 'system/user.twig', [
'settings' => $this->settings,

View File

@@ -1,5 +1,5 @@
name: Cyanine Theme
version: 2.3.1
version: 2.3.2
description: 'Cyanine is a modern and flexible multi-purpose theme and the standard theme for Typemill.'
author: Trendschau
homepage: https://trendschau.net