Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Sep 3, 2015
2 parents 618abfd + b43fb93 commit 13e5d8b
Show file tree
Hide file tree
Showing 55 changed files with 1,429 additions and 943 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Notification Center Changelog
===========================

Version 1.3.0 (2015-09-03)
---------------------------------

### New
- Added a sendNotificationMessage hook (#72)
- Allow recipient token to contain a list of recipients. (#75)

### Fixed
- Do not add a new line if file storage mode append but existing file was empty


Version 1.3.0-rc1 (2015-07-07)
---------------------------------

### New
- The Notification Center now provides a queue gateway that buffers messages and sends them based on cron job settings (#63)
- The "store to file" gateway now supports appending to an already existing file (#65)
- InsertTags as well as Simple Tokens are now allowed in sender e-mail name and sender e-mail address fields as well (#40 and #58)
- Added support for file uploads in form generator fields that can now use the upload attachment token (#39)


Versions previous to 1.3.0-rc1
---------------------------------

Changelog was not maintained in previous versions.
Try to use the git history for details.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,34 @@ if (null !== $objNotificationCollection) {
$objNotification->send($arrTokens, $strLanguage); // Language is optional
}
}
```
```

## Hooks

If you want to enrich each message being sent by some meta data or want to disable some messages being sent, you can
use the sendNotificationMessage hook:

```php

// config.php
$GLOBALS['TL_HOOKS']['sendNotificationMessage'][] = array('MyHook', 'execute');

// The hook
class MyHook
{
public function execute($objMessage, $arrTokens, $language, $objGatewayModel)
{
if (!$objMessage->regardUserSettings || !FE_USER_LOGGED_IN
|| $objMessage->getRelated('pid')->type !== 'custom_notification') {
return true;
}

$user = \MemberModel::findByPK($arrTokens['recipient']);
if (!$user || !$user->disableEmailNotifications) {
return true;
}

return false;
}
}
```
Binary file added assets/queue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/re-queue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions bin/queue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env php

<?php

/**
* Use as follows:
* $ queue -s <queue_gateway_id> -n <number of messages to be sent>
*
* E.g. to send 15 messages of source queue gateway ID 2, do this:
*
* $ queue -s 2 -n 15
*/

define('TL_MODE', 'FE');
require __DIR__ . '/../../../initialize.php';
$queueManager = $GLOBALS['NOTIFICATION_CENTER']['QUEUE_MANAGER'];

$queueManager->sendFromQueue($argv[2], $argv[4]);
34 changes: 14 additions & 20 deletions classes/tl_form.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
<?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 2014
* @copyright Copyright (c) 2008-2015, terminal42
* @author terminal42 gmbh <[email protected]>
* @license LGPL
*/

namespace NotificationCenter;

use NotificationCenter\Util\Form;

class tl_form extends \Backend
{

Expand Down Expand Up @@ -105,6 +90,11 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles,
// Administrator e-mail
$arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];

// Upload fields
foreach ($arrFiles as $fieldName => $file) {
$arrTokens['form_' . $fieldName] = Form::getFileUploadPathForToken($file);
}

return $arrTokens;
}

Expand All @@ -125,13 +115,17 @@ public function flatten($varValue, $strKey, &$arrData)
}

$blnAssoc = array_is_assoc($varValue);
$arrValues = array();

foreach ($varValue as $k => $v) {
if ($blnAssoc && !is_array($v)) {
$this->flatten($v, $strKey.'_'.$k, $arrData);
} else {
$arrData[$strKey.'_'.$v] = '1';
$arrValues[] = $v;
}
}

$arrData[$strKey] = implode(', ', $arrValues);
}
}
23 changes: 3 additions & 20 deletions classes/tl_module.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 2014
* @copyright Copyright (c) 2008-2015, terminal42
* @author terminal42 gmbh <[email protected]>
* @license LGPL
*/

Expand Down
66 changes: 45 additions & 21 deletions classes/tl_nc_gateway.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
<?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 2014
* @copyright Copyright (c) 2008-2015, terminal42
* @author terminal42 gmbh <[email protected]>
* @license LGPL
*/

namespace NotificationCenter;

use NotificationCenter\Gateway\LabelCallbackInterface;
use NotificationCenter\Model\Gateway;

class tl_nc_gateway extends \Backend
{
/**
Expand Down Expand Up @@ -65,4 +51,42 @@ public function checkFileServerConnection(\DataContainer $dc)

\Message::addConfirmation($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_confirm']);
}
}

/**
* Gets the back end list label
*
* @param array $row
* @param string $label
* @param \DataContainer $dc
* @param array $args
*
* @return string
*/
public function executeLabelCallback($row, $label, \DataContainer $dc, $args)
{
$model = Gateway::findByPk($row['id']);
$gateway = $model->getGateway();

if ($gateway instanceof LabelCallbackInterface) {

return $gateway->getLabel($row, $label,$dc, $args);
}

return $label;
}

/**
* Gets the cron job explanation
*
* @param \DataContainer $dc
*/
public function queueCronjobExplanation(\DataContainer $dc)
{
return sprintf('<div style="color: #4b85ba;
background: #eff5fa;
padding: 10px;
border-radius: 3px;">%s</div>',
str_replace('{gateway_id}', $dc->id, $GLOBALS['TL_LANG']['queueCronjobExplanation'])
);
}
}
48 changes: 27 additions & 21 deletions classes/tl_nc_language.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
<?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 2014
* @copyright Copyright (c) 2008-2015, terminal42
* @author terminal42 gmbh <[email protected]>
* @license LGPL
*/

namespace NotificationCenter;

use NotificationCenter\Model\Gateway;
use NotificationCenter\Model\Language;
use NotificationCenter\Model\Notification;

class tl_nc_language extends \Backend
{

/**
* 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') {
return;
}

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

if ($gateway !== null && $gateway->type == 'queue') {
$targetGateway = Gateway::findByPk($gateway->queue_targetGateway);
$GLOBALS['TL_DCA']['tl_nc_language']['palettes']['queue'] =
$GLOBALS['TL_DCA']['tl_nc_language']['palettes'][$targetGateway->type];
}
}

/**
* Save gateway type in language when creating new record
* @param string
Expand Down
Loading

0 comments on commit 13e5d8b

Please sign in to comment.