Completed mailing templates management
This commit is contained in:
88
core/lib/Thelia/Core/Event/MessageChangeEvent.php
Normal file
88
core/lib/Thelia/Core/Event/MessageChangeEvent.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageChangeEvent extends MessageCreateEvent
|
||||
{
|
||||
protected $message_id;
|
||||
|
||||
protected $text_message;
|
||||
protected $html_message;
|
||||
protected $subject;
|
||||
|
||||
public function __construct($message_id)
|
||||
{
|
||||
$this->setMessageId($message_id);
|
||||
}
|
||||
|
||||
public function getMessageId()
|
||||
{
|
||||
return $this->message_id;
|
||||
}
|
||||
|
||||
public function setMessageId($message_id)
|
||||
{
|
||||
$this->message_id = $message_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTextMessage()
|
||||
{
|
||||
return $this->text_message;
|
||||
}
|
||||
|
||||
public function setTextMessage($text_message)
|
||||
{
|
||||
$this->text_message = $text_message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHtmlMessage()
|
||||
{
|
||||
return $this->html_message;
|
||||
}
|
||||
|
||||
public function setHtmlMessage($html_message)
|
||||
{
|
||||
$this->html_message = $html_message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
82
core/lib/Thelia/Core/Event/MessageCreateEvent.php
Normal file
82
core/lib/Thelia/Core/Event/MessageCreateEvent.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageCreateEvent extends MessageEvent
|
||||
{
|
||||
protected $message_name;
|
||||
protected $locale;
|
||||
protected $title;
|
||||
protected $secured;
|
||||
|
||||
// Use message_name to prevent conflict with Event::name property.
|
||||
public function getMessageName()
|
||||
{
|
||||
return $this->message_name;
|
||||
}
|
||||
|
||||
public function setMessageName($message_name)
|
||||
{
|
||||
$this->message_name = $message_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecured()
|
||||
{
|
||||
return $this->secured;
|
||||
}
|
||||
|
||||
public function setSecured($secured)
|
||||
{
|
||||
$this->secured = $secured;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/MessageDeleteEvent.php
Normal file
48
core/lib/Thelia/Core/Event/MessageDeleteEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageDeleteEvent extends MessageEvent
|
||||
{
|
||||
protected $message_id;
|
||||
|
||||
public function __construct($message_id)
|
||||
{
|
||||
$this->setMessageId($message_id);
|
||||
}
|
||||
|
||||
public function getMessageId()
|
||||
{
|
||||
return $this->message_id;
|
||||
}
|
||||
|
||||
public function setMessageId($message_id)
|
||||
{
|
||||
$this->message_id = $message_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
47
core/lib/Thelia/Core/Event/MessageEvent.php
Normal file
47
core/lib/Thelia/Core/Event/MessageEvent.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageEvent extends ActionEvent
|
||||
{
|
||||
protected $message;
|
||||
|
||||
public function __construct(Message $message = null)
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage($message)
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -193,4 +193,21 @@ final class TheliaEvents
|
||||
|
||||
const BEFORE_DELETECONFIG = "action.before_deleteConfig";
|
||||
const AFTER_DELETECONFIG = "action.after_deleteConfig";
|
||||
|
||||
|
||||
// -- Messages management ---------------------------------------------
|
||||
|
||||
const MESSAGE_CREATE = "action.createMessage";
|
||||
const MESSAGE_MODIFY = "action.changeMessage";
|
||||
const MESSAGE_DELETE = "action.deleteMessage";
|
||||
|
||||
const BEFORE_CREATEMESSAGE = "action.before_createMessage";
|
||||
const AFTER_CREATEMESSAGE = "action.after_createMessage";
|
||||
|
||||
const BEFORE_CHANGEMESSAGE = "action.before_changeMessage";
|
||||
const AFTER_CHANGEMESSAGE = "action.after_changeMessage";
|
||||
|
||||
const BEFORE_DELETEMESSAGE = "action.before_deleteMessage";
|
||||
const AFTER_DELETEMESSAGE = "action.after_deleteMessage";
|
||||
|
||||
}
|
||||
|
||||
129
core/lib/Thelia/Core/Template/Loop/Message.php
Normal file
129
core/lib/Thelia/Core/Template/Loop/Message.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
* Message loop, to access messageuration variables
|
||||
*
|
||||
* - id is the message id
|
||||
* - name is the message name
|
||||
* - hidden filters by hidden status (yes, no, both)
|
||||
* - secured filters by secured status (yes, no, both)
|
||||
* - exclude is a comma separated list of message IDs that will be excluded from output
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Message extends BaseI18nLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createAnyTypeArgument('variable'),
|
||||
Argument::createBooleanOrBothTypeArgument('hidden'),
|
||||
Argument::createBooleanOrBothTypeArgument('secured')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$id = $this->getId();
|
||||
$name = $this->getVariable();
|
||||
$secured = $this->getSecured();
|
||||
|
||||
$search = MessageQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
'TITLE',
|
||||
'SUBJECT',
|
||||
'TEXT_MESSAGE',
|
||||
'HTML_MESSAGE'
|
||||
)
|
||||
);
|
||||
|
||||
if (! is_null($id))
|
||||
$search->filterById($id);
|
||||
|
||||
if (! is_null($name))
|
||||
$search->filterByName($name);
|
||||
|
||||
if (! is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
if (! is_null($secured) && $secured != BooleanOrBothType::ANY)
|
||||
$search->filterBySecured($secured ? 1 : 0);
|
||||
|
||||
$search->orderByName(Criteria::ASC);
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("NAME" , $result->getName())
|
||||
->set("IS_TRANSLATED", $result->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("SUBJECT" , $result->getVirtualColumn('i18n_SUBJECT'))
|
||||
->set("TEXT_MESSAGE" , $result->getVirtualColumn('i18n_TEXT_MESSAGE'))
|
||||
->set("HTML_MESSAGE" , $result->getVirtualColumn('i18n_HTML_MESSAGE'))
|
||||
->set("SECURED" , $result->getSecured())
|
||||
->set("CREATE_DATE" , $result->getCreatedAt())
|
||||
->set("UPDATE_DATE" , $result->getUpdatedAt())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user