Common functionalities
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Email;
|
||||
|
||||
use \App\Core\Template\Output as Output;
|
||||
use \App\Core\Email\Classes\Email as Email;
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
class EmailController extends \DefaultController
|
||||
{
|
||||
|
||||
protected $_class = Email::class;
|
||||
protected $_baseUrl = '/email';
|
||||
|
||||
/**
|
||||
* Index
|
||||
* Show the main Email list
|
||||
*/
|
||||
function index()
|
||||
{
|
||||
Output::render('index');
|
||||
/*
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
// Server settings
|
||||
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // for detailed debug output
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.gmail.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = 587;
|
||||
|
||||
$mail->Username = 'ahwelp@universo.univates.br';
|
||||
$mail->Password = '********';
|
||||
|
||||
// Sender and recipient settings
|
||||
$mail->setFrom('ahwelp@universo.univates.br', 'Sender Name');
|
||||
$mail->addAddress('ahwelp@univates.br', 'Receiver Name');
|
||||
$mail->addReplyTo('ahwelp@universo.univates.br', 'Sender Name');
|
||||
|
||||
// Setting the email content
|
||||
$mail->IsHTML(true);
|
||||
$mail->Subject = "Send email using Gmail SMTP and PHPMailer";
|
||||
$mail->Body = 'HTML message body. <b>Gmail</b> SMTP email body.';
|
||||
$mail->AltBody = 'Plain text message body for non-HTML email client. Gmail SMTP email body.';
|
||||
|
||||
$mail->send();
|
||||
echo "Email message sent.";*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Render the main Email formulary
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
Output::render('form', ['id' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Email $email
|
||||
*/
|
||||
function store(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Email $email
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show
|
||||
*
|
||||
* Render one register
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function show(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* Render the formular for a database Email
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function edit(Email $email)
|
||||
{
|
||||
Output::render('form', $email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
* Store the changes of the param on the database
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function update(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy
|
||||
* If the object has soft delete.
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function destroy(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge
|
||||
* Remove object even with soft delete.
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function purge(Email $email)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Email;
|
||||
|
||||
use App\Common\Email\Classes\EmailTemplate;
|
||||
use \App\Core\Template\Output as Output;
|
||||
use \App\Core\Email\Classes\Email as Email;
|
||||
|
||||
class EmailTemplateController extends \DefaultController
|
||||
{
|
||||
|
||||
protected $_class = EmailTemplate::class;
|
||||
protected $_baseUrl = '/email';
|
||||
|
||||
/**
|
||||
* Index
|
||||
* Show the main Email list
|
||||
*/
|
||||
function index()
|
||||
{
|
||||
//Output::render('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Render the main Email formulary
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
Output::render('templateForm', ['id' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Email $email
|
||||
*/
|
||||
function store(Email $email)
|
||||
{
|
||||
var_dump($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Email $email
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show
|
||||
*
|
||||
* Render one register
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function show(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* Render the formular for a database Email
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function edit(Email $email)
|
||||
{
|
||||
Output::render('form', $email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
* Store the changes of the param on the database
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function update(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy
|
||||
* If the object has soft delete.
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function destroy(Email $email)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge
|
||||
* Remove object even with soft delete.
|
||||
*
|
||||
* @param Email $email
|
||||
*/
|
||||
function purge(Email $email)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Template\Output as Output;
|
||||
use Routes\RouteCollection as RouteCollection;
|
||||
|
||||
//Menu itens
|
||||
RouteCollection::get('*', function() {
|
||||
Output::addOnSubmenu('config', '/email', "Emails", "", ['class' => 'nav-link']);
|
||||
}, -10)->doIgnore();
|
||||
|
||||
RouteCollection::group("/email", function(){
|
||||
RouteCollection::get ("/", "\App\Common\Email\EmailController@index");
|
||||
RouteCollection::get ("/form", "\App\Common\Email\EmailController@create");
|
||||
RouteCollection::post ("/", "\App\Common\Email\EmailController@store");
|
||||
RouteCollection::post ("/search", "\App\Common\Email\EmailController@search");
|
||||
RouteCollection::get ("/[i:id]", "\App\Common\Email\EmailController@show");
|
||||
RouteCollection::get ("/[i:id]/edit", "\App\Common\Email\EmailController@edit");
|
||||
RouteCollection::put ("/[i:id]/edit", "\App\Common\Email\EmailController@update");
|
||||
RouteCollection::delete("/[i:id]", "\App\Common\Email\EmailController@destroy");
|
||||
|
||||
//RouteCollection::get ("/template", "\App\Common\Email\EmailTemplateController@index");
|
||||
RouteCollection::get ("/template/form", "\App\Common\Email\EmailTemplateController@create");
|
||||
RouteCollection::post ("/template", "\App\Common\Email\EmailTemplateController@store");
|
||||
RouteCollection::get ("/template/[i:id]", "\App\Common\Email\EmailTemplateController@show");
|
||||
RouteCollection::get ("/template/[i:id]/edit", "\App\Common\Email\EmailTemplateController@edit");
|
||||
RouteCollection::put ("/template/[i:id]/edit", "\App\Common\Email\EmailTemplateController@update");
|
||||
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Email\Classes;
|
||||
|
||||
use ORM\Entity as Entity;
|
||||
|
||||
class Email extends Entity {
|
||||
|
||||
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
|
||||
|
||||
const _tableName = "emails";
|
||||
|
||||
/*const _properties = Array(
|
||||
"id" => ['listable' => true, 'searcheble' => false, 'orderable' => false],
|
||||
"name" => ['listable' => true, 'searcheble' => true]);
|
||||
*/
|
||||
|
||||
const _properties = Array(
|
||||
'id',
|
||||
'name',
|
||||
'description'
|
||||
);
|
||||
|
||||
/*protected $_ignore = Array(
|
||||
|
||||
);*/
|
||||
|
||||
const _listable = Array(
|
||||
'id',
|
||||
'name'
|
||||
);
|
||||
|
||||
const _searchable = Array(
|
||||
'name'
|
||||
);
|
||||
|
||||
const _orderable = Array(
|
||||
|
||||
);
|
||||
|
||||
/*const _datatables = Array(
|
||||
|
||||
);*/
|
||||
|
||||
//const _timestamps = true;
|
||||
//const _softdelete = true;
|
||||
|
||||
//const _connectionName = "";
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Email\Classes;
|
||||
|
||||
use ORM\Entity as Entity;
|
||||
|
||||
class EmailConfigs extends Entity {
|
||||
|
||||
const _tableName = "common_emails_configs";
|
||||
const _timestamps = true;
|
||||
const _softdelete = true;
|
||||
|
||||
const _properties = Array(
|
||||
'id',
|
||||
'name',
|
||||
'description'
|
||||
);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Email\Classes;
|
||||
|
||||
use ORM\Entity as Entity;
|
||||
|
||||
class EmailTemplate extends Entity {
|
||||
|
||||
const _tableName = "common_emails_templates";
|
||||
const _timestamps = true;
|
||||
const _softdelete = true;
|
||||
|
||||
const _properties = Array(
|
||||
'id',
|
||||
'name',
|
||||
'description'
|
||||
);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Schema\Wrapper as Wrapper;
|
||||
use App\Core\Sanity\MigratorController as Migrator;
|
||||
|
||||
//https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-types
|
||||
function common_email_upgrade($pluginversion) {
|
||||
if ($pluginversion < "0.0.1") {
|
||||
|
||||
$table = Wrapper::get_table("common_emails_config");
|
||||
$table->addColumn("name", "string", Array("null" => false));
|
||||
$table->addColumn("smtphosts", "string", Array("null" => false));
|
||||
$table->addColumn("smtpsecure", "integer", Array("null" => false, "default" => 0));
|
||||
$table->addColumn("smtpauthtype", "integer", Array("null" => false, "default" => 0));
|
||||
$table->addColumn("smtpuser", "string", Array("null" => false));
|
||||
$table->addColumn("smtppass", "string", Array("null" => false));
|
||||
$table->addColumn("smtpmaxbulk", "integer", Array("null" => false, "default" => 1));
|
||||
$table->addColumn("noreplyaddress", "string", Array("null" => false, "default" => ''));
|
||||
$table->addColumn("sitemailcharset", "string", Array("null" => false, "default" => 'UTF-8'));
|
||||
$table->addTimestamps();
|
||||
$table->addSoftDelete();
|
||||
$table->create();
|
||||
|
||||
$table = Wrapper::get_table("common_emails_templates");
|
||||
$table->addColumn("name", "string", Array("null" => false));
|
||||
$table->addColumn("title", "string", Array("null" => false));
|
||||
$table->addColumn("body", "text");
|
||||
$table->addTimestamps();
|
||||
$table->addSoftDelete();
|
||||
$table->create();
|
||||
|
||||
$table = Wrapper::get_table("common_emails");
|
||||
$table->addColumn("name", "string", Array("null" => false));
|
||||
$table->addColumn("template", "integer", Array());
|
||||
$table->addColumn("title", "text");
|
||||
$table->addColumn("body", "text");
|
||||
$table->addColumn("timesent", "timestamp", Array());
|
||||
$table->create();
|
||||
|
||||
Migrator::getInstance()->update_plugin_version("common_email", "1.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
//if ($pluginversion < "0.0.2") {
|
||||
//$table = Wrapper::get_table("common_emails");
|
||||
//Migrator::getInstance()->update_plugin_version("common_email", "1.0.1");
|
||||
//return;
|
||||
//}
|
||||
}
|
||||
|
||||
function common_email_rollback($pluginversion) {
|
||||
if($pluginversion > "0.0.1"){
|
||||
$table = Wrapper::get_table("common_emails");
|
||||
$table->drop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["email"]["module_name"] = "Email";
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["email"]["module_name"] = "Email";
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$plugin->name = "common_email";
|
||||
$plugin->version = "0.0.0";
|
||||
|
||||
//$plugin->require = Array( ["name" => "plugin_name", "version" => "x.x.x"] );
|
||||
@@ -0,0 +1,62 @@
|
||||
{{#id}}
|
||||
<form method="POST" action="/email/{{id}}/edit">
|
||||
<input type="hidden" name="id" value="{{id}}" />
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
{{/id}}
|
||||
{{^id}}
|
||||
<form method="POST" action="/email">
|
||||
<input type="hidden" name="id" value="" />
|
||||
{{/id}}
|
||||
<div class='row'>
|
||||
<div class="col-md-8 col-xs-12 g-3">
|
||||
<div class="card">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-xs-12 col-3">
|
||||
<label class="form-label">Código</label>
|
||||
<input type="text" class="form-control" name='code' value="{{code}}">
|
||||
</div>
|
||||
<div class="col-xs-12 col-9">
|
||||
<label class="form-label">Nome</label>
|
||||
<input type="text" class="form-control" name='name' value="{{name}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 g-3">
|
||||
<label class="form-label">Descrição</label>
|
||||
<textarea class="form-control" name="descricao">{{description}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class="col-md-8 col-xs-12 g-3">
|
||||
<div class="card">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-xs-12 col-3">
|
||||
<label class="form-label">Código</label>
|
||||
<input type="text" class="form-control" name='code' value="{{code}}">
|
||||
</div>
|
||||
<div class="col-xs-12 col-9">
|
||||
<label class="form-label">Nome</label>
|
||||
<input type="text" class="form-control" name='name' value="{{name}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 g-3">
|
||||
<label class="form-label">Descrição</label>
|
||||
<textarea class="form-control" name="descricao">{{description}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,2 @@
|
||||
<a class="btn btn-primary" href="/email/template/form"> Adicionar modelo</a>
|
||||
<a class="btn btn-primary" href="/email/config/form"> Adicionar configuração</a>
|
||||
@@ -0,0 +1,48 @@
|
||||
<h2> {{#string}} emailTemplates,email {{/string}} </h2>
|
||||
|
||||
{{#id}}
|
||||
<form method="POST" action="/email/template/{{id}}/edit">
|
||||
<input type="hidden" name="id" value="{{id}}" />
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
{{/id}}
|
||||
{{^id}}
|
||||
<form method="POST" action="/email/template">
|
||||
<input type="hidden" name="id" value="" />
|
||||
{{/id}}
|
||||
<div class='row'>
|
||||
<div class="col-12 g-3">
|
||||
<div class="card">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-xs-12 col-3">
|
||||
<label class="form-label">{{#string}} name {{/string}}</label>
|
||||
<input type="text" class="form-control" name='code' value="{{code}}">
|
||||
</div>
|
||||
<div class="col-xs-12 col-9">
|
||||
<label class="form-label">{{#string}} title {{/string}}</label>
|
||||
<input type="text" class="form-control" name='name' value="{{name}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 g-3">
|
||||
<label class="form-label">{{#string}} content {{/string}}</label>
|
||||
<textarea id="wysiwyg" name="descricao">{{description}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 g-3"> <input class="btn btn-success btn-block" type="submit" value="Salvar">
|
||||
</div>
|
||||
<div class="col-md-6 g-3"> <a class="btn btn-danger btn-block" href="/people">Cancelar</a> </div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$('#wysiwyg').trumbowyg();
|
||||
</script>
|
||||
Reference in New Issue
Block a user