From 054d6f4647d4452cdac08a03a91b6191285b6492 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Sun, 6 Sep 2015 22:22:48 +0200 Subject: [PATCH 1/5] No need to replace tokens again (see #75) --- library/NotificationCenter/Util/String.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/NotificationCenter/Util/String.php b/library/NotificationCenter/Util/String.php index 8028a6f9..04fa1ec1 100644 --- a/library/NotificationCenter/Util/String.php +++ b/library/NotificationCenter/Util/String.php @@ -155,8 +155,6 @@ public static function compileRecipients($strRecipients, $arrTokens) foreach ((array) trimsplit(',', $strRecipients) as $strAddress) { if ($strAddress != '') { - $strAddress = static::recursiveReplaceTokensAndTags($strAddress, $arrTokens, static::NO_TAGS | static::NO_BREAKS); - list($strName, $strEmail) = \String::splitFriendlyEmail($strAddress); // Address could become empty through invalid insert tag From c5dd4db3f491453d3e9c5367da2edd2af1cc6e91 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Thu, 10 Sep 2015 18:27:19 +0200 Subject: [PATCH 2/5] Cronjob did not work when installed via composer --- bin/queue | 11 ++++++++++- languages/en/tl_nc_gateway.php | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/queue b/bin/queue index 8daf0492..e1396f49 100755 --- a/bin/queue +++ b/bin/queue @@ -12,7 +12,16 @@ */ define('TL_MODE', 'FE'); -require __DIR__ . '/../../../initialize.php'; + +if (file_exists(__DIR__ . '/../../../initialize.php')) { + // Regular way + require_once(__DIR__ . '/../../../initialize.php'); +} else { + // Try composer location (see #77) + require_once(__DIR__ . '/../../../../../system/initialize.php'); +} + + $queueManager = $GLOBALS['NOTIFICATION_CENTER']['QUEUE_MANAGER']; $queueManager->sendFromQueue($argv[2], $argv[4]); diff --git a/languages/en/tl_nc_gateway.php b/languages/en/tl_nc_gateway.php index f3cd2934..dd0aceaa 100644 --- a/languages/en/tl_nc_gateway.php +++ b/languages/en/tl_nc_gateway.php @@ -83,4 +83,10 @@
5 * * * * /path/to/contao/system/modules/notification_center/bin/queue -s {gateway_id} -n 30

If you don\'t have access to real cronjobs then you can enable the poor man\'s cron. Note that it doesn\'t provide the same flexibility in terms of interval settings and it is subject to the web execution context and thus certainly affected by -PHP configurations such as the maximum execution time. Thus, try to keep the number of messages sent per invocation as low as possible.'; +PHP configurations such as the maximum execution time. Thus, try to keep the number of messages sent per invocation as low as possible. +

+Note: When you installed the notification center using Composer, the path to the binary differs: +
+/path/to/contao/composer/vendor/terminal42/notification_center/bin/queue +
+'; From 40144599cfbe4b6f3766c9b433d8e1e2e1384844 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Tue, 23 Jun 2015 12:12:39 +0200 Subject: [PATCH 3/5] Allow simple token conditions in email fields --- classes/tl_nc_language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/tl_nc_language.php b/classes/tl_nc_language.php index ef744ba6..09554187 100644 --- a/classes/tl_nc_language.php +++ b/classes/tl_nc_language.php @@ -155,7 +155,7 @@ public function validateEmailList($varValue, \DataContainer $dc) foreach ($chunks as $chunk) { // Skip string with tokens or inserttags - if (strpos($chunk, '##') !== false || strpos($chunk, '{{') !== false) { + if (strpos($chunk, '##') !== false || strpos($chunk, '{{') !== false|| strpos($chunk, '{if') !== false) { continue; } From 03209ec5bd9e345afe55e4461397ffb0b4f8ac86 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Wed, 16 Sep 2015 11:29:14 +0200 Subject: [PATCH 4/5] We don't need namespace-class-loader with composer --- composer.json | 8 +++++--- config/autoload.php | 30 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index cca7bca0..8841a668 100644 --- a/composer.json +++ b/composer.json @@ -14,16 +14,18 @@ "php":">=5.3.2", "contao/core":"^3.2", "contao-community-alliance/composer-plugin":"2.*", - "terminal42/contao-namespace-class-loader":"^1.0.1", "codefog/contao-haste":"4.*", "terminal42/dcawizard":"2.*" }, "autoload":{ "psr-0": { "NotificationCenter\\": [ - "/library" + "library/" ] - } + }, + "classmap": [ + "classes/" + ] }, "replace": { "contao-legacy/notification_center": "self.version" diff --git a/config/autoload.php b/config/autoload.php index ad16b5c2..0a021719 100644 --- a/config/autoload.php +++ b/config/autoload.php @@ -11,24 +11,28 @@ /** * Register PSR-0 namespace */ -NamespaceClassLoader::add('NotificationCenter', 'system/modules/notification_center/library'); +if (class_exists('NamespaceClassLoader')) { + NamespaceClassLoader::add('NotificationCenter', 'system/modules/notification_center/library'); +} /** * Register classes outside the namespace folder */ -NamespaceClassLoader::addClassMap(array -( - // DCA Helpers - 'NotificationCenter\tl_form' => 'system/modules/notification_center/classes/tl_form.php', - 'NotificationCenter\tl_member' => 'system/modules/notification_center/classes/tl_member.php', - 'NotificationCenter\tl_module' => 'system/modules/notification_center/classes/tl_module.php', - 'NotificationCenter\tl_nc_gateway' => 'system/modules/notification_center/classes/tl_nc_gateway.php', - 'NotificationCenter\tl_nc_notification' => 'system/modules/notification_center/classes/tl_nc_notification.php', - 'NotificationCenter\tl_nc_language' => 'system/modules/notification_center/classes/tl_nc_language.php', - 'NotificationCenter\tl_nc_message' => 'system/modules/notification_center/classes/tl_nc_message.php', - 'NotificationCenter\tl_nc_queue' => 'system/modules/notification_center/classes/tl_nc_queue.php' -)); +if (class_exists('NamespaceClassLoader')) { + NamespaceClassLoader::addClassMap(array + ( + // DCA Helpers + 'NotificationCenter\tl_form' => 'system/modules/notification_center/classes/tl_form.php', + 'NotificationCenter\tl_member' => 'system/modules/notification_center/classes/tl_member.php', + 'NotificationCenter\tl_module' => 'system/modules/notification_center/classes/tl_module.php', + 'NotificationCenter\tl_nc_gateway' => 'system/modules/notification_center/classes/tl_nc_gateway.php', + 'NotificationCenter\tl_nc_notification' => 'system/modules/notification_center/classes/tl_nc_notification.php', + 'NotificationCenter\tl_nc_language' => 'system/modules/notification_center/classes/tl_nc_language.php', + 'NotificationCenter\tl_nc_message' => 'system/modules/notification_center/classes/tl_nc_message.php', + 'NotificationCenter\tl_nc_queue' => 'system/modules/notification_center/classes/tl_nc_queue.php' + )); +} /** From ea2febd9a1b66d3f8d09f685f2a95c003d89130f Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 9 Oct 2015 11:43:28 +0200 Subject: [PATCH 5/5] Some methods have been moved to Haste 4.10 --- .gitignore | 5 +- classes/tl_form.php | 7 +- composer.json | 2 +- library/NotificationCenter/Gateway/Base.php | 8 +- library/NotificationCenter/Gateway/File.php | 4 +- .../MessageDraft/EmailMessageDraft.php | 12 +- library/NotificationCenter/Util/String.php | 118 +++++------------- 7 files changed, 53 insertions(+), 103 deletions(-) diff --git a/.gitignore b/.gitignore index 9c6d3c32..bfdce806 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,7 @@ Thumbs.db nbproject/ # Transifex -.tx/ \ No newline at end of file +.tx/ + +# Composer +vendor/ diff --git a/classes/tl_form.php b/classes/tl_form.php index 1fdec747..c34ca78d 100644 --- a/classes/tl_form.php +++ b/classes/tl_form.php @@ -79,12 +79,12 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles, $arrTokens['raw_data'] = ''; foreach ($arrData as $k => $v) { - $this->flatten($v, 'form_'.$k, $arrTokens); + \Haste\Util\StringUtil::flatten($v, 'form_'.$k, $arrTokens); $arrTokens['raw_data'] .= (isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k)) . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n"; } foreach ($arrForm as $k => $v) { - $this->flatten($v, 'formconfig_'.$k, $arrTokens); + \Haste\Util\StringUtil::flatten($v, 'formconfig_'.$k, $arrTokens); } // Administrator e-mail @@ -104,6 +104,9 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles, * @param mixed $varValue * @param string $strKey * @param array $arrData + * + * @deprecated Deprecated since version 1.3.1, to be removed in version 2. + * Use Haste\Util\StringUtil::flatten() instead. */ public function flatten($varValue, $strKey, &$arrData) { diff --git a/composer.json b/composer.json index 8841a668..e8c105f0 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php":">=5.3.2", "contao/core":"^3.2", "contao-community-alliance/composer-plugin":"2.*", - "codefog/contao-haste":"4.*", + "codefog/contao-haste":"^4.10.0", "terminal42/dcawizard":"2.*" }, "autoload":{ diff --git a/library/NotificationCenter/Gateway/Base.php b/library/NotificationCenter/Gateway/Base.php index 49d450cb..8064eba9 100644 --- a/library/NotificationCenter/Gateway/Base.php +++ b/library/NotificationCenter/Gateway/Base.php @@ -68,18 +68,18 @@ protected function compileRecipients($strRecipients, $arrTokens) } /** - * @deprecated Use String::recursiveReplaceTokensAndTags() + * @deprecated Use \Haste\Util\StringUtil::recursiveReplaceTokensAndTags() */ protected function recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags = 0) { - return String::recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags); } /** - * @deprecated Use String::convertToText() + * @deprecated Use \Haste\Util\StringUtil::convertToText() */ protected function convertToText($varValue, $options) { - return String::convertToText($varValue, $options); + return \Haste\Util\StringUtil::convertToText($varValue, $options); } } diff --git a/library/NotificationCenter/Gateway/File.php b/library/NotificationCenter/Gateway/File.php index 8df46146..1bb94b0e 100644 --- a/library/NotificationCenter/Gateway/File.php +++ b/library/NotificationCenter/Gateway/File.php @@ -44,7 +44,7 @@ public function send(Message $objMessage, array $arrTokens, $strLanguage = '') return false; } - $strFileName = String::recursiveReplaceTokensAndTags( + $strFileName = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags( $objLanguage->file_name, $arrTokens, String::NO_TAGS | String::NO_BREAKS @@ -58,7 +58,7 @@ public function send(Message $objMessage, array $arrTokens, $strLanguage = '') } // Preserve all tags here as this is pretty useful in XML :-) - $strContent = String::recursiveReplaceTokensAndTags( + $strContent = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags( $objLanguage->file_content, $arrTokens ); diff --git a/library/NotificationCenter/MessageDraft/EmailMessageDraft.php b/library/NotificationCenter/MessageDraft/EmailMessageDraft.php index 39f6ff87..51514aa3 100644 --- a/library/NotificationCenter/MessageDraft/EmailMessageDraft.php +++ b/library/NotificationCenter/MessageDraft/EmailMessageDraft.php @@ -56,7 +56,7 @@ public function getSenderEmail() { $strSenderAddress = $this->objLanguage->email_sender_address ?: $GLOBALS['TL_ADMIN_EMAIL']; - return String::recursiveReplaceTokensAndTags($strSenderAddress, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strSenderAddress, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -67,7 +67,7 @@ public function getSenderName() { $strSenderName = $this->objLanguage->email_sender_name ?: $GLOBALS['TL_ADMIN_NAME']; - return String::recursiveReplaceTokensAndTags($strSenderName, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strSenderName, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -104,7 +104,7 @@ public function getBccRecipientEmails() public function getReplyToEmail() { if ($this->objLanguage->email_replyTo) { - return String::recursiveReplaceTokensAndTags($this->objLanguage->email_replyTo, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($this->objLanguage->email_replyTo, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } return ''; @@ -116,7 +116,7 @@ public function getReplyToEmail() */ public function getSubject() { - return String::recursiveReplaceTokensAndTags($this->objLanguage->email_subject, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($this->objLanguage->email_subject, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -140,7 +140,7 @@ public function getPriority() public function getTextBody() { $strText = $this->objLanguage->email_text; - $strText = String::recursiveReplaceTokensAndTags($strText, $this->arrTokens, String::NO_TAGS); + $strText = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strText, $this->arrTokens, String::NO_TAGS); return \Controller::convertRelativeUrls($strText, '', true); } @@ -159,7 +159,7 @@ public function getHtmlBody() // Prevent parseSimpleTokens from stripping important HTML tags $GLOBALS['TL_CONFIG']['allowedTags'] .= '