Support custom permission denied message
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 7 Sep 2017 15:23:49 +0000 (17:23 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 7 Sep 2017 15:40:22 +0000 (17:40 +0200)
com.woltlab.wcf/templates/permissionDenied.tpl
wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php

index 15ef266d9241ce8dbfa05fc9c830abdfff115b83..ccd0e512fb994a71cf1aeeec1cd402f727f8f0ec 100644 (file)
@@ -4,7 +4,11 @@
 {include file='header' __disableAds=true}
 
 <div class="section">
-       <p>{lang}wcf.page.error.permissionDenied{/lang}</p>
+       {if $message|isset}
+               <p>{$message}</p>
+       {else}
+               <p>{lang}wcf.page.error.permissionDenied{/lang}</p>
+       {/if}
 </div>
 
 {event name='content'}
index 2b0cf4310891f4c38b207a8d57d6c1ff435e8cd7..15b0a86c20f6a80cf74c175f252268051976c6d5 100644 (file)
@@ -19,8 +19,9 @@ class PermissionDeniedException extends UserException {
        /**
         * Creates a new PermissionDeniedException object.
         */
-       public function __construct() {
-               parent::__construct(WCF::getLanguage()->getDynamicVariable('wcf.page.error.permissionDenied'));
+       public function __construct($message = null) {
+               if ($message === null) $message = WCF::getLanguage()->getDynamicVariable('wcf.page.error.permissionDenied');
+               parent::__construct($message);
        }
        
        /**
@@ -39,6 +40,7 @@ class PermissionDeniedException extends UserException {
                        'name' => get_class($this),
                        'file' => $this->getFile(),
                        'line' => $this->getLine(),
+                       'message' => $this->getMessage(),
                        'stacktrace' => $this->getTraceAsString(),
                        'templateName' => 'permissionDenied',
                        'templateNameApplication' => 'wcf'