Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Feb 2, 2017
2 parents d6038f5 + 87c0db4 commit fc8855c
Show file tree
Hide file tree
Showing 36 changed files with 621 additions and 388 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Notification Center Changelog
===========================

Version 1.4.0 (2017-02-02)
--------------------------

### New
- Added a verification for valid token characters (#68)
- Support embedding images in e-mails (#109)
- Support for different flatten delimiter in core form notification (#111)


Version 1.3.6 (2016-05-04)
--------------------------

Expand Down
12 changes: 7 additions & 5 deletions classes/tl_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public function sendFormNotification($arrData, $arrForm, $arrFiles, $arrLabels)
return;
}

/** @var Model\Notification $objNotification */
$objNotification->send(
$this->generateTokens(
(array) $arrData,
(array) $arrForm,
(array) $arrFiles,
(array) $arrLabels
(array) $arrLabels,
$objNotification->flatten_delimiter ?: ','
),
$GLOBALS['TL_LANGUAGE']
);
Expand All @@ -70,21 +70,23 @@ public function sendFormNotification($arrData, $arrForm, $arrFiles, $arrLabels)
* @param array $arrForm
* @param array $arrFiles
* @param array $arrLabels
* @param string $delimiter
*
* @return array
*/
public function generateTokens(array $arrData, array $arrForm, array $arrFiles, array $arrLabels)
public function generateTokens(array $arrData, array $arrForm, array $arrFiles, array $arrLabels, $delimiter)
{
$arrTokens = array();
$arrTokens['raw_data'] = '';

foreach ($arrData as $k => $v) {
\Haste\Util\StringUtil::flatten($v, 'form_'.$k, $arrTokens);
\Haste\Util\StringUtil::flatten($v, 'form_'.$k, $arrTokens, $delimiter);
$arrTokens['formlabel_'.$k] = isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k);
$arrTokens['raw_data'] .= (isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k)) . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n";
}

foreach ($arrForm as $k => $v) {
\Haste\Util\StringUtil::flatten($v, 'formconfig_'.$k, $arrTokens);
\Haste\Util\StringUtil::flatten($v, 'formconfig_'.$k, $arrTokens, $delimiter);
}

// Administrator e-mail
Expand Down
27 changes: 4 additions & 23 deletions classes/tl_member.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
<?php

/**
* Contao Open Source CMS
* Copyright (C) 2005-2011 Leo Feyer
* notification_center extension for Contao Open Source CMS
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, please visit the Free
* Software Foundation website at <http://www.gnu.org/licenses/>.
*
* PHP version 5
* @copyright terminal42 gmbh 2013
* @copyright Copyright (c) 2008-2015, terminal42
* @author terminal42 gmbh <info@terminal42.ch>
* @license LGPL
*/

Expand All @@ -31,12 +14,10 @@ class tl_member
{
/**
* Store the personal data in session
* @param \DataContainer
* @return array
*/
public function storePersonalData()
{
if (TL_MODE == 'FE' && FE_USER_LOGGED_IN)
if ('FE' === TL_MODE && true === FE_USER_LOGGED_IN)
{
$_SESSION['PERSONAL_DATA'] = \FrontendUser::getInstance()->getData();
}
Expand Down
6 changes: 4 additions & 2 deletions classes/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class tl_module extends \Backend
{
/**
* Get notification choices
* @param \DataContainer
* @return array
*
* @param \DataContainer $dc
*
* @return array
*/
public function getNotificationChoices(\DataContainer $dc)
{
Expand Down
30 changes: 16 additions & 14 deletions classes/tl_nc_gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ public function loadSettingsLanguageFile()

/**
* Check the FTP connection
* @param \DataContainer
*
* @param \DataContainer $dc
*/
public function checkFileServerConnection(\DataContainer $dc)
{
if ($dc->activeRecord->type != 'ftp' || $dc->activeRecord->file_connection != 'ftp') {
if ('ftp' !== $dc->activeRecord->type || 'ftp' !== $dc->activeRecord->file_connection) {
return;
}

$strClass = $GLOBALS['NOTIFICATION_CENTER']['FTP'][$dc->activeRecord->ftp_type];
// Try to connect
if (($ftp = @ftp_connect($dc->activeRecord->file_host, (int) ($dc->activeRecord->file_port ?: 21), 5)) === false) {
\Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_connect']);

if (!class_exists($strClass)) {
\Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_class']);
return;
}

$objHandler = new $strClass();
// Try to login
if (false === @ftp_login($ftp, $dc->activeRecord->file_username, $dc->activeRecord->file_password)) {
@ftp_close($ftp);
\Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_login']);

try {
$objHandler->connect($dc->activeRecord);
} catch (\Exception $e) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_connect'], $e->getMessage()));
return;
}

Expand All @@ -55,10 +55,10 @@ public function checkFileServerConnection(\DataContainer $dc)
/**
* Gets the back end list label
*
* @param array $row
* @param string $label
* @param \DataContainer $dc
* @param array $args
* @param array $row
* @param string $label
* @param \DataContainer $dc
* @param array $args
*
* @return string
*/
Expand All @@ -79,6 +79,8 @@ public function executeLabelCallback($row, $label, \DataContainer $dc, $args)
* Gets the cron job explanation
*
* @param \DataContainer $dc
*
* @return string
*/
public function queueCronjobExplanation(\DataContainer $dc)
{
Expand Down
45 changes: 27 additions & 18 deletions classes/tl_nc_language.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ class tl_nc_language extends \Backend
{

/**
* Modifies the palette for the queue gateway so it takes the one from the
* target gateway
* Modifies the palette for the queue gateway so it takes the one from the target gateway
*
* @param \DataContainer $dc
*/
public function modifyPalette(\DataContainer $dc)
{
if (\Input::get('act') != 'edit') {
if ('edit' !== \Input::get('act')) {
return;
}

$language = Language::findByPk($dc->id);
$message = $language->getRelated('pid');
$gateway = $message->getRelated('gateway');

if ($gateway !== null && $gateway->type == 'queue') {
if ($gateway !== null && 'queue' === $gateway->type) {
$targetGateway = Gateway::findByPk($gateway->queue_targetGateway);
$GLOBALS['TL_DCA']['tl_nc_language']['palettes']['queue'] =
$GLOBALS['TL_DCA']['tl_nc_language']['palettes'][$targetGateway->type];
Expand All @@ -41,14 +40,15 @@ public function modifyPalette(\DataContainer $dc)

/**
* Save gateway type in language when creating new record
* @param string
* @param int
* @param array
* @param DataContainer
*
* @param string $strTable
* @param int $insertID
* @param array $arrSet
* @param \DataContainer $dc
*/
public function insertGatewayType($strTable, $insertID, $arrSet, $dc)
{
if ($strTable == 'tl_nc_language') {
if ('tl_nc_language' === $strTable) {
\Database::getInstance()->prepare("
UPDATE tl_nc_language SET gateway_type=(SELECT type FROM tl_nc_gateway WHERE id=(SELECT gateway FROM tl_nc_message WHERE id=?)) WHERE id=?
")->execute($arrSet['pid'], $insertID);
Expand All @@ -57,9 +57,12 @@ public function insertGatewayType($strTable, $insertID, $arrSet, $dc)

/**
* Generate a list for the dcaWizard displaying the languages
* @param \Database_Result
* @param string
* @return string
*
* @param \Database\Result $objRecords
* @param string $strId
* @param \DcaWizard $widget
*
* @return string
*/
public function generateWizardList($objRecords, $strId, $widget)
{
Expand Down Expand Up @@ -96,8 +99,10 @@ public function generateWizardList($objRecords, $strId, $widget)

/**
* Check if the language field is unique per message
* @param mixed
* @param \DataContainer
*
* @param mixed $varValue
* @param \DataContainer $dc
*
* @return mixed
* @throws \Exception
*/
Expand All @@ -118,8 +123,10 @@ public function validateLanguageField($varValue, \DataContainer $dc)

/**
* Make sure the fallback field is a fallback per message
* @param mixed
* @param \DataContainer
*
* @param mixed $varValue
* @param \DataContainer $dc
*
* @return mixed
* @throws \Exception
*/
Expand All @@ -142,8 +149,10 @@ public function validateFallbackField($varValue, \DataContainer $dc)

/**
* Validate e-mail addresses in the comma separated list
* @param mixed
* @param \DataContainer
*
* @param mixed $varValue
* @param \DataContainer $dc
*
* @return mixed
* @throws \Exception
*/
Expand Down
37 changes: 20 additions & 17 deletions classes/tl_nc_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@ class tl_nc_message extends \Backend
protected $arrGateways = array();

/**
* Modifies the palette for the queue gateway so it takes the one from the
* target gateway
* Modifies the palette for the queue gateway so it takes the one from the target gateway
*
* @param \DataContainer $dc
*/
public function modifyPalette(\DataContainer $dc)
{
if (\Input::get('act') != 'edit') {
if ('edit' !== \Input::get('act')) {
return;
}

$message = Message::findByPk($dc->id);
$gateway = $message->getRelated('gateway');

if ($gateway !== null && $gateway->type == 'queue') {
if ($gateway !== null && 'queue' === $gateway->type) {
$targetGateway = Gateway::findByPk($gateway->queue_targetGateway);
$GLOBALS['TL_DCA']['tl_nc_message']['palettes']['queue'] =
$GLOBALS['TL_DCA']['tl_nc_message']['palettes'][$targetGateway->type];
Expand All @@ -51,15 +50,17 @@ public function modifyPalette(\DataContainer $dc)

/**
* child_record_callback
* @param array
* @return string
*
* @param array $arrRow
*
* @return string
*/
public function listRows($arrRow)
{
if (empty($this->arrTranslations)) {
if (0 === count($this->arrTranslations)) {
$this->arrTranslations = \System::getLanguages();
}
if (empty($this->arrGateways)) {
if (0 === count($this->arrGateways)) {
$objGateways = \Database::getInstance()->execute('SELECT id,title FROM tl_nc_gateway');
while ($objGateways->next()) {
$this->arrGateways[$objGateways->id] = $objGateways->title;
Expand All @@ -84,12 +85,14 @@ public function listRows($arrRow)

/**
* Return the "toggle visibility" button
* @param array
* @param string
* @param string
* @param string
* @param string
* @param string
*
* @param array $row
* @param string $href
* @param string $label
* @param string $title
* @param string $icon
* @param string $attributes
*
* @return string
*/
public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
Expand All @@ -101,7 +104,7 @@ public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
exit;
}

$this->redirect($this->getReferer());
\Controller::redirect(\System::getReferer());
}

$href .= '&amp;tid=' . $row['id'] . '&amp;state=' . ($row['published'] ? '' : 1);
Expand All @@ -110,7 +113,7 @@ public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
$icon = 'invisible.gif';
}

return '<a href="' . $this->addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> ';
return '<a href="' . \Backend::addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . \Image::getHtml($icon, $label) . '</a> ';
}

/**
Expand Down Expand Up @@ -139,6 +142,6 @@ public function toggleVisibility($intId, $blnVisible)
->execute($intId);

$objVersions->create();
$this->log('A new version of record "tl_nc_message.id=' . $intId . '" has been created', __METHOD__, TL_GENERAL);
\System::log('A new version of record "tl_nc_message.id=' . $intId . '" has been created', __METHOD__, TL_GENERAL);
}
}
Loading

0 comments on commit fc8855c

Please sign in to comment.