mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php namespace System\Controllers;
|
|
|
|
use Str;
|
|
use Lang;
|
|
use File;
|
|
use Mail;
|
|
use Flash;
|
|
use Backend;
|
|
use Redirect;
|
|
use BackendMenu;
|
|
use BackendAuth;
|
|
use Backend\Classes\Controller;
|
|
use System\Models\MailTemplate;
|
|
use ApplicationException;
|
|
use System\Classes\SettingsManager;
|
|
use Exception;
|
|
|
|
/**
|
|
* Mail templates controller
|
|
*
|
|
* @package october\system
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
*/
|
|
class MailTemplates extends Controller
|
|
{
|
|
public $implement = [
|
|
'Backend.Behaviors.FormController',
|
|
'Backend.Behaviors.ListController'
|
|
];
|
|
|
|
public $requiredPermissions = ['system.manage_mail_templates'];
|
|
|
|
public $listConfig = ['templates' => 'config_templates_list.yaml', 'layouts' => 'config_layouts_list.yaml'];
|
|
public $formConfig = 'config_form.yaml';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
BackendMenu::setContext('October.System', 'system', 'settings');
|
|
SettingsManager::setContext('October.System', 'mail_templates');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
MailTemplate::syncAll();
|
|
$this->asExtension('ListController')->index();
|
|
$this->bodyClass = 'compact-container';
|
|
}
|
|
|
|
public function formBeforeSave($model)
|
|
{
|
|
$model->is_custom = true;
|
|
}
|
|
|
|
public function onTest($recordId)
|
|
{
|
|
try {
|
|
$model = $this->formFindModelObject($recordId);
|
|
$user = BackendAuth::getUser();
|
|
|
|
Mail::sendTo([$user->email => $user->full_name], $model->code);
|
|
|
|
Flash::success('The test message has been successfully sent.');
|
|
}
|
|
catch (Exception $ex) {
|
|
Flash::error($ex->getMessage());
|
|
}
|
|
}
|
|
}
|