mirror of
https://github.com/Karaka-Management/oms-Messages.git
synced 2026-02-12 07:18:41 +00:00
add template list, fix template install bug
This commit is contained in:
parent
707f2243f0
commit
b26dab36a8
|
|
@ -93,6 +93,21 @@
|
||||||
"pid": "/",
|
"pid": "/",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"subtype": 1,
|
"subtype": 1,
|
||||||
|
"name": "Templates",
|
||||||
|
"uri": "{/base}/messages/templates?{?}",
|
||||||
|
"target": "self",
|
||||||
|
"icon": null,
|
||||||
|
"order": 30,
|
||||||
|
"from": "Messages",
|
||||||
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
|
"parent": 1001201001,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1001208001,
|
||||||
|
"pid": "/",
|
||||||
|
"type": 3,
|
||||||
|
"subtype": 1,
|
||||||
"name": "Settings",
|
"name": "Settings",
|
||||||
"uri": "{/base}/messages/settings?{?}",
|
"uri": "{/base}/messages/settings?{?}",
|
||||||
"target": "self",
|
"target": "self",
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,11 @@
|
||||||
"name": "messages_mail_charset",
|
"name": "messages_mail_charset",
|
||||||
"type": "VARCHAR(255)",
|
"type": "VARCHAR(255)",
|
||||||
"null": false
|
"null": false
|
||||||
|
},
|
||||||
|
"messages_mail_template": {
|
||||||
|
"name": "messages_mail_template",
|
||||||
|
"type": "TINYINT(1)",
|
||||||
|
"null": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ final class Installer extends InstallerAbstract
|
||||||
$request->setData('body', $data['body'] ?? '');
|
$request->setData('body', $data['body'] ?? '');
|
||||||
$request->setData('bodyalt', $data['bodyalt'] ?? '');
|
$request->setData('bodyalt', $data['bodyalt'] ?? '');
|
||||||
$request->setData('send', $data['send'] ?? false);
|
$request->setData('send', $data['send'] ?? false);
|
||||||
|
$request->setData('template', true);
|
||||||
|
|
||||||
$module->apiEmailCreate($request, $response);
|
$module->apiEmailCreate($request, $response);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,17 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'^.*/messages/templates.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\Messages\Controller\BackendController:viewMessageTemplates',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => BackendController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::MESSAGE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
'^.*/messages/mail/create.*$' => [
|
'^.*/messages/mail/create.*$' => [
|
||||||
[
|
[
|
||||||
'dest' => '\Modules\Messages\Controller\BackendController:viewMessageCreate',
|
'dest' => '\Modules\Messages\Controller\BackendController:viewMessageCreate',
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
|
|
||||||
|
$email->isTemplate = $request->getData('template') ?? false;
|
||||||
|
|
||||||
if ($request->hasData('from')) {
|
if ($request->hasData('from')) {
|
||||||
$from = $request->getDataJson('from');
|
$from = $request->getDataJson('from');
|
||||||
$email->setFrom($from['address'] ?? '', $from['name'] ?? '');
|
$email->setFrom($from['address'] ?? '', $from['name'] ?? '');
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Messages\Controller;
|
namespace Modules\Messages\Controller;
|
||||||
|
|
||||||
|
use Modules\Messages\Models\EmailL11nMapper;
|
||||||
|
use Modules\Messages\Models\EmailMapper;
|
||||||
use phpOMS\Contract\RenderableInterface;
|
use phpOMS\Contract\RenderableInterface;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
|
|
@ -51,6 +53,36 @@ final class BackendController extends Controller
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing end-point for application behaviour.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return RenderableInterface
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function viewMessageTemplates(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
|
||||||
|
{
|
||||||
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
|
$view->setTemplate('/Modules/Messages/Theme/Backend/mail-templates');
|
||||||
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001201001, $request, $response));
|
||||||
|
|
||||||
|
$templates = EmailMapper::getAll()
|
||||||
|
->with('l11n')
|
||||||
|
->where('isTemplate', true)
|
||||||
|
->where('account', $request->header->account)
|
||||||
|
->where('l11n/language', $response->getLanguage())
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$view->setData('templates', $templates);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing end-point for application behaviour.
|
* Routing end-point for application behaviour.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class Email extends MailEmail implements \JsonSerializable
|
||||||
|
|
||||||
public array $l11n = [];
|
public array $l11n = [];
|
||||||
|
|
||||||
|
public bool $isTemplate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -72,7 +74,7 @@ class Email extends MailEmail implements \JsonSerializable
|
||||||
public function getL11nByLanguage(string $language) : EmailL11n
|
public function getL11nByLanguage(string $language) : EmailL11n
|
||||||
{
|
{
|
||||||
foreach ($this->l11n as $l11n) {
|
foreach ($this->l11n as $l11n) {
|
||||||
if ($l11n->language->getLanguage() === $language) {
|
if ($l11n->language === $language) {
|
||||||
return $l11n;
|
return $l11n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class EmailL11n implements \JsonSerializable
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $language = ISO639x1Enum::_EN;
|
public string $language = ISO639x1Enum::_EN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title.
|
* Title.
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ final class EmailMapper extends DataMapperFactory
|
||||||
'messages_mail_encoding' => ['name' => 'messages_mail_encoding', 'type' => 'string', 'internal' => 'encoding'],
|
'messages_mail_encoding' => ['name' => 'messages_mail_encoding', 'type' => 'string', 'internal' => 'encoding'],
|
||||||
'messages_mail_contenttype' => ['name' => 'messages_mail_contenttype', 'type' => 'string', 'internal' => 'contentType'],
|
'messages_mail_contenttype' => ['name' => 'messages_mail_contenttype', 'type' => 'string', 'internal' => 'contentType'],
|
||||||
'messages_mail_charset' => ['name' => 'messages_mail_charset', 'type' => 'string', 'internal' => 'charset'],
|
'messages_mail_charset' => ['name' => 'messages_mail_charset', 'type' => 'string', 'internal' => 'charset'],
|
||||||
|
'messages_mail_template' => ['name' => 'messages_mail_template', 'type' => 'bool', 'internal' => 'isTemplate'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,5 @@ return ['Navigation' => [
|
||||||
'Settings' => 'Settings',
|
'Settings' => 'Settings',
|
||||||
'Spam' => 'Spam',
|
'Spam' => 'Spam',
|
||||||
'Trash' => 'Trash',
|
'Trash' => 'Trash',
|
||||||
|
'Templates' => 'Templates',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
89
Theme/Backend/mail-templates.tpl.php
Executable file
89
Theme/Backend/mail-templates.tpl.php
Executable file
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package Modules\Messages
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use phpOMS\Uri\UriFactory;
|
||||||
|
|
||||||
|
/*
|
||||||
|
$mail = new \phpOMS\Message\Mail\Imap();
|
||||||
|
$mail->connect('{imap.gmail.com:993/imap/ssl}INBOX', 'dev.orange.management@gmail.com', 'DEV_PASSWORD');
|
||||||
|
$unseen = $mail->getInboxUnseen();
|
||||||
|
$seen = $mail->getInboxSeen();
|
||||||
|
$quota = $mail->getQuota();
|
||||||
|
*/
|
||||||
|
|
||||||
|
$messages = $this->getData('templates') ?? [];
|
||||||
|
|
||||||
|
$previous = empty($messages) ? 'messages/dashboard' : 'messages/dashboard?{?}&id=' . \reset($messages)->id . '&ptype=p';
|
||||||
|
$next = empty($messages) ? 'messages/dashboard' : 'messages/dashboard?{?}&id=' . \end($messages)->id . '&ptype=n';
|
||||||
|
|
||||||
|
echo $this->getData('nav')->render(); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-9">
|
||||||
|
<div class="portlet">
|
||||||
|
<div class="portlet-head"><?= $this->getHtml('Templates'); ?><i class="fa fa-download floatRight download btn"></i></div>
|
||||||
|
<table id="profileList" class="default">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td><span class="check"><input type="checkbox" name="profile-list"></span>
|
||||||
|
<td class="wf-100"><?= $this->getHtml('Subject'); ?>
|
||||||
|
<td><?= $this->getHtml('Date'); ?>
|
||||||
|
<tbody>
|
||||||
|
<?php $count = 0;
|
||||||
|
foreach ($messages as $key => $value) : ++$count;
|
||||||
|
$url = UriFactory::build('{/base}/messages/template/single?{?}&id=' . $value->id); ?>
|
||||||
|
<tr>
|
||||||
|
<td><span class="check"><input type="checkbox" name=""></span>
|
||||||
|
<td><a href="<?= $url; ?>"><?= $this->printHtml(empty($value->subject) ? $value->getL11nByLanguage($this->response->getLanguage())->subject : $value->subject); ?></a>
|
||||||
|
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($count === 0) : ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</table>
|
||||||
|
<div class="portlet-foot">
|
||||||
|
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
|
||||||
|
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xs-12 col-md-3">
|
||||||
|
<div class="box">
|
||||||
|
<a tabindex="0" class="button" href="<?= UriFactory::build('{/base}/messages/template/create'); ?>"><i class="fa fa-pencil"></i> <?= $this->getHtml('Create', '0', '0'); ?></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="portlet">
|
||||||
|
<div class="portlet-head"><?= $this->getHtml('Channels'); ?></div>
|
||||||
|
<div class="portlet-body">
|
||||||
|
asdf
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="portlet">
|
||||||
|
<div class="portlet-head"><?= $this->getHtml('Email'); ?></div>
|
||||||
|
<div class="portlet-body">
|
||||||
|
asdf
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="portlet">
|
||||||
|
<div class="portlet-head"><?= $this->getHtml('Chat'); ?></div>
|
||||||
|
<div class="portlet-body">
|
||||||
|
asdf
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue
Block a user