]> BookStack Code Mirror - bookstack/commitdiff
Merge bugfixes from branch 'v0.14'
authorDan Brown <redacted>
Sun, 5 Feb 2017 21:24:15 +0000 (21:24 +0000)
committerDan Brown <redacted>
Sun, 5 Feb 2017 21:24:15 +0000 (21:24 +0000)
1  2 
app/helpers.php
tests/PublicActionTest.php

diff --combined app/helpers.php
index f69f2c174c3ec08ee1ad4107518a5e3f6007cd63,e68e29d132a80af4caec8084bd642e59ca6395f6..153f1e49fcc0a572dd5463e38c9cc4bc572c9332
@@@ -37,6 -37,15 +37,15 @@@ function user(
      return auth()->user() ?: \BookStack\User::getDefault();
  }
  
+ /**
+  * Check if current user is a signed in user.
+  * @return bool
+  */
+ function signedInUser()
+ {
+     return auth()->user() && !auth()->user()->isDefault();
+ }
  /**
   * Check if the current user has a permission.
   * If an ownable element is passed in the jointPermissions are checked against
@@@ -64,7 -73,7 +73,7 @@@ function userCan($permission, Ownable $
   */
  function setting($key = null, $default = false)
  {
 -    $settingService = app(\BookStack\Services\SettingService::class);
 +    $settingService = resolve(\BookStack\Services\SettingService::class);
      if (is_null($key)) return $settingService;
      return $settingService->get($key, $default);
  }
@@@ -117,16 -126,6 +126,16 @@@ function redirect($to = null, $status 
      return app('redirect')->to($to, $status, $headers, $secure);
  }
  
 +function icon($name, $attrs = []) {
 +    $iconPath = resource_path('assets/icons/' . $name . '.svg');
 +    $attrString = ' ';
 +    foreach ($attrs as $attrName => $attr) {
 +        $attrString .=  $attrName . '="' . $attr . '" ';
 +    }
 +    $fileContents = file_get_contents($iconPath);
 +    return  str_replace('<svg', '<svg' . $attrString, $fileContents);
 +}
 +
  /**
   * Generate a url with multiple parameters for sorting purposes.
   * Works out the logic to set the correct sorting direction
@@@ -157,4 -156,4 +166,4 @@@ function sortUrl($path, $data, $overrid
      if (count($queryStringSections) === 0) return $path;
  
      return baseUrl($path . '?' . implode('&', $queryStringSections));
 -}
 +}
index 422511dbfc6ecf30c9c6bc28b7494afa2087f24d,4e242fc7d6d34e9dadcd670771e326f225a0906f..62a321b5e18dbd563e85f53977475e514067338e
@@@ -1,6 -1,6 +1,6 @@@
 -<?php
 +<?php namespace Tests;
  
 -class PublicActionTest extends TestCase
 +class PublicActionTest extends BrowserKitTest
  {
  
      public function test_app_not_public()
          ]);
      }
  
+     public function test_content_not_listed_on_404_for_public_users()
+     {
+         $page = \BookStack\Page::first();
+         $this->asAdmin()->visit($page->getUrl());
+         Auth::logout();
+         view()->share('pageTitle', '');
+         $this->forceVisit('/cats/dogs/hippos');
+         $this->dontSee($page->name);
+     }
  }