mirror of
https://github.com/Karaka-Management/oms-Profile.git
synced 2026-02-11 05:18:40 +00:00
Started to implement profile admin functionality
This commit is contained in:
parent
9c98588780
commit
df181b3a8d
|
|
@ -59,5 +59,50 @@
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1000304001,
|
||||||
|
"pid": "/backend/admin/module/settings",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Overview",
|
||||||
|
"uri": "/{/lang}/backend/admin/module/settings?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 1,
|
||||||
|
"from": "Profile",
|
||||||
|
"permission": { "type": null, "element": null },
|
||||||
|
"parent": 1000300000,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1000304002,
|
||||||
|
"pid": "/backend/admin/module/settings",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Settings",
|
||||||
|
"uri": "/{/lang}/backend/admin/module/settings/profile/settings?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 1,
|
||||||
|
"from": "Profile",
|
||||||
|
"permission": { "type": null, "element": null },
|
||||||
|
"parent": 1000300000,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1000304003,
|
||||||
|
"pid": "/backend/admin/module/settings",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
|
"name": "Create",
|
||||||
|
"uri": "/{/lang}/backend/admin/module/settings/profile/create?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 2,
|
||||||
|
"from": "Profile",
|
||||||
|
"permission": { "type": null, "element": null },
|
||||||
|
"parent": 1000300000,
|
||||||
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
20
Admin/Routes/Web/Api.php
Normal file
20
Admin/Routes/Web/Api.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use phpOMS\Router\RouteVerb;
|
||||||
|
use phpOMS\Account\PermissionType;
|
||||||
|
use Modules\Profile\Models\PermissionState;
|
||||||
|
use Modules\Profile\Controller;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'^.*/api/profile.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\Profile\Controller:apiProfileCreate',
|
||||||
|
'verb' => RouteVerb::PUT,
|
||||||
|
'permission' => [
|
||||||
|
'module' => Controller::MODULE_NAME,
|
||||||
|
'type' => PermissionType::CREATE,
|
||||||
|
'state' => PermissionState::PROFILE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
@ -39,4 +39,26 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'^.*/backend/admin/module/settings/profile/settings.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\Profile\Controller:viewProfileAdminSettings',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => Controller::MODULE_NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionState::PROFILE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'^.*/backend/admin/module/settings/profile/create.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\Profile\Controller:viewProfileAdminCreate',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => Controller::MODULE_NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionState::PROFILE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Profile;
|
namespace Modules\Profile;
|
||||||
|
|
||||||
|
use Modules\Profile\Models\Profile;
|
||||||
use Modules\Profile\Models\ProfileMapper;
|
use Modules\Profile\Models\ProfileMapper;
|
||||||
use Modules\Profile\Models\PermissionState;
|
use Modules\Profile\Models\PermissionState;
|
||||||
|
use Modules\Admin\Models\AccountMapper;
|
||||||
|
|
||||||
use phpOMS\Account\PermissionType;
|
use phpOMS\Account\PermissionType;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
|
|
@ -170,4 +173,99 @@ final class Controller extends ModuleAbstract implements WebInterface
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return \Serializable
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewProfileAdminSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||||
|
{
|
||||||
|
$view = new View($this->app, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/Profile/Theme/Backend/modules-settings');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000300000, $request, $response));
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return \Serializable
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewProfileAdminCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||||
|
{
|
||||||
|
$view = new View($this->app, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/Profile/Theme/Backend/modules-create');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000300000, $request, $response));
|
||||||
|
|
||||||
|
$accGrpSelector = new \Modules\Profile\Theme\Backend\Components\AccountGroupSelector\BaseView($this->app, $request, $response);
|
||||||
|
$view->addData('accGrpSelector', $accGrpSelector);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function apiProfileCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
|
{
|
||||||
|
$profiles = $this->createProfilesFromRequest($request);
|
||||||
|
$created = [];
|
||||||
|
|
||||||
|
foreach ($profiles as $profile) {
|
||||||
|
ProfileMapper::create($profile);
|
||||||
|
$created[] = $profile->jsonSerialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->set($request->getUri()->__toString(), $created);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create profile from request.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<Profile>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private function createProfilesFromRequest(RequestAbstract $request) : array
|
||||||
|
{
|
||||||
|
$profiles = [];
|
||||||
|
$accounts = \json_decode($request->getData('iaccount-idlist') ?? '[]', true);
|
||||||
|
|
||||||
|
if ($accounts === false) {
|
||||||
|
return $profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\is_int($accounts)) {
|
||||||
|
$accounts = [$accounts];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($accounts as $account) {
|
||||||
|
$account = AccountMapper::get((int) $account);
|
||||||
|
$profiles[] = new Profile(AccountMapper::get((int) $account));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $profiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,11 @@ class Profile
|
||||||
|
|
||||||
private $location = [];
|
private $location = [];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(Account $account = null)
|
||||||
{
|
{
|
||||||
$this->image = new NullMedia();
|
$this->image = new NullMedia();
|
||||||
$this->birthday = new \DateTime('now');
|
$this->birthday = new \DateTime('now');
|
||||||
$this->account = new Account();
|
$this->account = $account ?? new Account();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() : int
|
public function getId() : int
|
||||||
|
|
@ -92,4 +92,11 @@ class Profile
|
||||||
{
|
{
|
||||||
return $this->birthday;
|
return $this->birthday;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
<input type="hidden" id="<?= $this->printHtml($this->getId()); ?>-idlist"<?= $this->isRequired() ? ' required' : ''; ?>>
|
<input type="hidden" id="<?= $this->printHtml($this->getId()); ?>-idlist"<?= $this->isRequired() ? ' required' : ''; ?>>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="ipt-second"><button><?= $this->getHtml('Add', 0, 0); ?></button></div>
|
<div class="ipt-second"><button><?= $this->getHtml('Select', 0, 0); ?></button></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box taglist" id="<?= $this->printHtml($this->getId()); ?>-taglist" data-action='[
|
<div class="box taglist" id="<?= $this->printHtml($this->getId()); ?>-taglist" data-action='[
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
*/
|
*/
|
||||||
return ['Navigation' => [
|
return ['Navigation' => [
|
||||||
'List' => 'List',
|
'List' => 'List',
|
||||||
|
'Overview' => 'Overview',
|
||||||
'Profile' => 'Profile',
|
'Profile' => 'Profile',
|
||||||
'Profiles' => 'Profiles',
|
'Profiles' => 'Profiles',
|
||||||
|
'Settings' => 'Settings',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
*/
|
*/
|
||||||
return ['Profile' => [
|
return ['Profile' => [
|
||||||
|
'Account' => 'Account',
|
||||||
'Account/Group' => 'Account/Group',
|
'Account/Group' => 'Account/Group',
|
||||||
'Activity' => 'Activity',
|
'Activity' => 'Activity',
|
||||||
'Area' => 'Area',
|
'Area' => 'Area',
|
||||||
|
|
@ -18,6 +19,7 @@ return ['Profile' => [
|
||||||
'ContactInformation' => 'Contact Information',
|
'ContactInformation' => 'Contact Information',
|
||||||
'Community' => 'Community',
|
'Community' => 'Community',
|
||||||
'Country' => 'Country',
|
'Country' => 'Country',
|
||||||
|
'CreateProfile' => 'Create Profile',
|
||||||
'Currency' => 'Currency',
|
'Currency' => 'Currency',
|
||||||
'Customized' => 'Customized',
|
'Customized' => 'Customized',
|
||||||
'DecimalPoint' => 'Decimal Point',
|
'DecimalPoint' => 'Decimal Point',
|
||||||
|
|
|
||||||
23
Theme/Backend/modules-create.tpl.php
Normal file
23
Theme/Backend/modules-create.tpl.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo $this->getData('nav')->render();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-4">
|
||||||
|
<section class="box wf-100">
|
||||||
|
<header><h1><?= $this->getHtml('CreateProfile'); ?></h1></header>
|
||||||
|
|
||||||
|
<div class="inner">
|
||||||
|
<form id="fProfileCreate" method="PUT" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/profile?{?}&csrf={$CSRF}'); ?>">
|
||||||
|
<table class="layout wf-100" style="table-layout: fixed">
|
||||||
|
<tbody>
|
||||||
|
<tr><td><label for="iAccount"><?= $this->getHtml('Account') ?></label>
|
||||||
|
<tr><td><?= $this->getData('accGrpSelector')->render('iAccount', true); ?>
|
||||||
|
<tr><td><input type="submit" value="<?= $this->getHtml('Create', 0, 0); ?>">
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
4
Theme/Backend/modules-settings.tpl.php
Normal file
4
Theme/Backend/modules-settings.tpl.php
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo $this->getData('nav')->render();
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user