Invio Email
This commit is contained in:
61
administrator/src/Service/Notifier.php
Normal file
61
administrator/src/Service/Notifier.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @version CVS: 1.0.0
|
||||
* @package Com_Circolari
|
||||
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
|
||||
* @copyright 2025 Tommaso Cippitelli
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Pcrt\Component\Circolari\Administrator\Controller;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Pcrt\Component\Circolari\Administrator\Service\Notifier;
|
||||
|
||||
/**
|
||||
* Circolare controller class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class CircolareController extends FormController
|
||||
{
|
||||
protected $view_list = 'circolares';
|
||||
protected $view_item = 'circolare';
|
||||
|
||||
|
||||
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
$this->registerTask('apply', 'save');
|
||||
$this->registerTask('save2new', 'save');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
$app = \Joomla\CMS\Factory::getApplication();
|
||||
$input = $app->input;
|
||||
$post = $input->get('jform', [], 'array');
|
||||
$notify= (int)($post['notify'] ?? 0);
|
||||
|
||||
$result = parent::save($key, $urlVar);
|
||||
|
||||
if ($result && $notify) {
|
||||
$model = $this->getModel('Circolare');
|
||||
$id = (int) $model->getState($model->getName().'.id') ?: (int)($post['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
$db = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
|
||||
$id = (int) $db->insertid();
|
||||
}
|
||||
if ($id > 0) {
|
||||
(new Notifier())->sendForCircolare($id, ['onlyIfFirmaObbligatoria' => true]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user