Add {$username} and ${email} placeholders for notices
authorMatthias Schmidt <gravatronics@live.com>
Mon, 14 Mar 2016 16:56:37 +0000 (17:56 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 14 Mar 2016 16:56:37 +0000 (17:56 +0100)
com.woltlab.wcf/templates/userNotice.tpl
wcfsetup/install/files/acp/templates/noticeAdd.tpl
wcfsetup/install/files/lib/data/notice/Notice.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 34c7e7d06fd9864ecaf7da2e973d91245aff7f7d..3d7bc20dadc6fe62b15d4e5a5f8a980903173c3e 100644 (file)
@@ -30,7 +30,7 @@
                                                <span class="icon icon16 fa-times pointer jsDismissNoticeButton jsTooltip" data-object-id="{$notice->noticeID}" title="{lang}wcf.notice.button.dismiss{/lang}"></span>
                                        {/if}
                                        
-                                       {if $notice->noticeUseHtml}{@$notice->notice|language}{else}{@$notice->notice|language|htmlspecialchars|nl2br}{/if}
+                                       {@$notice}
                                </p>
                        {/foreach}
                {/content}
index 22be48ecd3ccc413230e3f052bc01f0e3640ac51..617d44db37406ee0293b8fb5419cd10a497b7965 100644 (file)
@@ -80,6 +80,7 @@
                                                        {/if}
                                                </small>
                                        {/if}
+                                       <small>{lang}wcf.acp.notice.notice.description{/lang}</small>
                                </dd>
                        </dl>
                        {include file='multipleLanguageInputJavascript' elementIdentifier='notice' forceSelection=false}
index 21bd84cff65fdedf98458f90a8cc69496c25c5c6..07739a8757773bf29f8b92ed8f4831c42926be16 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\data\notice;
+use wcf\data\condition\Condition;
 use wcf\data\DatabaseObject;
 use wcf\system\condition\ConditionHandler;
 use wcf\system\request\IRouteController;
@@ -10,7 +11,7 @@ use wcf\system\WCF;
  * Represents a notice.
  * 
  * @author     Matthias Schmidt
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.notice
@@ -24,26 +25,42 @@ class Notice extends DatabaseObject implements IRouteController {
        protected $isDismissed = null;
        
        /**
-        * @see \wcf\data\DatabaseObject::$databaseTableName
+        * @inheritDoc
         */
        protected static $databaseTableName = 'notice';
        
        /**
-        * @see \wcf\data\DatabaseObject::$databaseIndexName
+        * @inheritDoc
         */
        protected static $databaseTableIndexName = 'noticeID';
        
+       /**
+        * Returns the textual representation of the notice.
+        * 
+        * @return      string
+        */
+       public function __toString() {
+               // replace `{$username}` with the active user's name and the `{$email}` with the active users' email address
+               $text = str_replace(['{$username}', '{$email}'], [WCF::getUser()->username, WCF::getUser()->email], WCF::getLanguage()->get($this->notice));
+               
+               if (!$this->noticeUseHtml) {
+                       $text = nl2br(htmlspecialchars($text));
+               }
+               
+               return $text;
+       }
+       
        /**
         * Returns the conditions of the notice.
         * 
-        * @return      array<\wcf\data\condition\Condition>
+        * @return      Condition[]
         */
        public function getConditions() {
                return ConditionHandler::getInstance()->getConditions('com.woltlab.wcf.condition.notice', $this->noticeID);
        }
        
        /**
-        * @see \wcf\data\ITitledObject::getTitle()
+        * @inheritDoc
         */
        public function getTitle() {
                return $this->noticeName;
index 78bede918edd50d0083f394604937dcbedabc95f..f5a7042b80e2edfac25b35e88c66efcda21a4e94 100644 (file)
                <item name="wcf.acp.notice.isDismissible.description"><![CDATA[Ein einmal von einem Benutzer ausgeblendeter Hinweis wird bei erneutem Seitenaufruf nicht mehr angezeigt.]]></item>
                <item name="wcf.acp.notice.list"><![CDATA[Hinweise]]></item>
                <item name="wcf.acp.notice.notice"><![CDATA[Hinweis]]></item>
+               <item name="wcf.acp.notice.notice.description"><![CDATA[<code>{literal}{$username}{/literal}</code> wird durch den Namen und <code>{literal}{$email}</code> durch die Email-Adresse des aktuellen Benutzers ersetzt.]]></item>
                <item name="wcf.acp.notice.noticeUseHtml"><![CDATA[HTML im Hinweis verwenden]]></item>
                <item name="wcf.acp.notice.resetIsDismissed"><![CDATA[Ausgeblendete Hinweise erneut anzeigen]]></item>
                <item name="wcf.acp.notice.resetIsDismissed.description"><![CDATA[Der Hinweis wird jenen Benutzern wieder angezeigt, die die ursprüngliche Version bereits ausgeblendet haben. Gästen, die den Hinweis bereits ausgeblendet haben, wird dieser nur in einer neuen Session erneut angezeigt.]]></item>
index 4d805692770a1a29f8de20d5eb5434af36c7ac7f..05b96a7ea0b11d5840cd26a31d905437fe1614d7 100644 (file)
@@ -677,6 +677,7 @@ Examples for medium ID detection:
                <item name="wcf.acp.notice.isDismissible.description"><![CDATA[A notice one dismissed by a user will not be shown again for them.]]></item>
                <item name="wcf.acp.notice.list"><![CDATA[Notices]]></item>
                <item name="wcf.acp.notice.notice"><![CDATA[Notice]]></item>
+               <item name="wcf.acp.notice.notice.description"><![CDATA[<code>{literal}{$username}{/literal}</code> will be replaced by the name and <code>{literal}{$email}{/literal}</code> by the mail address of the active user.]]></item>
                <item name="wcf.acp.notice.noticeUseHtml"><![CDATA[Enable HTML code in notice]]></item>
                <item name="wcf.acp.notice.resetIsDismissed"><![CDATA[Dismissed notices will be shown again]]></item>
                <item name="wcf.acp.notice.resetIsDismissed.description"><![CDATA[The notice will be shown again to users who dismissed the previous version. Guests who dismissed the notice will only see it in a new session.]]></item>