Skip to content

Commit

Permalink
Merge pull request #270 from GM-Alex/next
Browse files Browse the repository at this point in the history
Merge next. Bump 2.1.12
  • Loading branch information
GM-Alex authored Jan 20, 2019
2 parents d88c3cb + de80b0f commit 556c7b3
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- composer install
- npm install
script:
- ./vendor/bin/phpcs -p --standard=PSR2 ./src ./tests
- ./vendor/bin/phpcs -p --standard=PSR2 ./src ./tests --ignore=./tests/bootstrap.php
- ./scripts/phpunit.sh
- ./scripts/humbug.sh
- ./scripts/build.sh
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "User Access Manager plugin for Wordpress",
"type": "wordpress-plugin",
"license": "GPL-2.0",
"version": "2.1.11",
"version": "2.1.12",
"authors": [
{
"name": "Alexander Schneider",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "user-access-manager",
"version": "2.1.11",
"version": "2.1.12",
"description": "[![Build Status](https://travis-ci.org/GM-Alex/user-access-manager.svg)](https://travis-ci.org/GM-Alex/user-access-manager)",
"main": "index.js",
"directories": {
Expand Down
6 changes: 4 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: GM_Alex
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=1947052
Tags: admin, access, member area, members, member, member access, page, pages, post, posts, private, privacy, restrict, user, user access manager, user management
Requires at least: 4.7
Tested up to: 4.9
Stable tag: 2.1.11
Tested up to: 5.0
Stable tag: 2.1.12

With the "User Access Manager"-plugin you can manage the access to your posts, pages and files.

Expand Down Expand Up @@ -59,6 +59,8 @@ Here you found the changes in each version.

Version Date Changes

2.1.12 2019/01/08 Fix multi site file handling issue. #222

2.1.11 2018/03/16 Fix missing got_mod_rewrite function. #212
Fix wrong media urls. #207
Fix wrong post counts at the admin panel.
Expand Down
13 changes: 10 additions & 3 deletions src/File/ApacheFileProtection.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ private function getFileContent($directory)
* Creates the file content if permalinks are active.
*
* @param string $objectType
* @param bool $isSubSite
*
* @return string
*/
private function getPermalinkFileContent($objectType)
private function getPermalinkFileContent($objectType, $isSubSite = false)
{
if ($objectType === null) {
$objectType = ObjectHandler::ATTACHMENT_OBJECT_TYPE;
Expand All @@ -115,7 +116,10 @@ private function getPermalinkFileContent($objectType)
$content = "RewriteEngine On\n";
$content .= "RewriteBase {$homeRoot}\n";
$content .= "RewriteRule ^index\\.php$ - [L]\n";
$content .= "RewriteCond %{REQUEST_URI} !.*\/sites\/[0-9]+\/.*\n";

if ($isSubSite === false) {
$content .= "RewriteCond %{REQUEST_URI} !.*\/sites\/[0-9]+\/.*\n";
}

$directoryMatch = $this->getDirectoryMatch();

Expand Down Expand Up @@ -162,7 +166,10 @@ public function create($directory, $objectType = null)
$content = $this->getFileContent($directory);
$this->createPasswordFile(true, $directory);
} else {
$content = $this->getPermalinkFileContent($objectType);
$content = $this->getPermalinkFileContent(
$objectType,
preg_match('/.*\/sites\/[0-9]+\/$/', $directory) !== 0
);
}

// save files
Expand Down
12 changes: 10 additions & 2 deletions src/UserAccessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use UserAccessManager\Config\ConfigParameterFactory;
use UserAccessManager\Controller\Backend\DynamicGroupsController;
use UserAccessManager\Controller\Backend\PostObjectController;
use UserAccessManager\Controller\Backend\SetupController;
use UserAccessManager\Controller\Backend\TermObjectController;
use UserAccessManager\Controller\Backend\UserObjectController;
use UserAccessManager\Controller\ControllerFactory;
Expand All @@ -33,6 +32,7 @@
use UserAccessManager\Object\ObjectHandler;
use UserAccessManager\ObjectMembership\ObjectMembershipHandlerFactory;
use UserAccessManager\Setup\SetupHandler;
use UserAccessManager\UserGroup\UserGroupAssignmentHandler;
use UserAccessManager\UserGroup\UserGroupFactory;
use UserAccessManager\User\UserHandler;
use UserAccessManager\UserGroup\UserGroupHandler;
Expand All @@ -48,7 +48,7 @@
*/
class UserAccessManager
{
const VERSION = '2.1.11';
const VERSION = '2.1.12';
const DB_VERSION = '1.6.1';

/**
Expand Down Expand Up @@ -96,6 +96,11 @@ class UserAccessManager
*/
private $userGroupHandler;

/**
* @var UserGroupAssignmentHandler
*/
private $userGroupAssignmentHandler;

/**
* @var AccessHandler
*/
Expand Down Expand Up @@ -293,6 +298,9 @@ public function getUserHandler()
return $this->userHandler;
}

/**
* @return UserGroupHandler
*/
public function getUserGroupHandler()
{
return $this->userGroupHandler;
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Controller/Backend/ObjectControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use UserAccessManager\Controller\Backend\UserObjectController;
use UserAccessManager\Object\ObjectHandler;
use UserAccessManager\Tests\Unit\UserAccessManagerTestCase;
use UserAccessManager\UserGroup\UserGroupAssignmentException;
use Vfs\FileSystem;
use Vfs\Node\Directory;
use Vfs\Node\File;
Expand Down
17 changes: 12 additions & 5 deletions tests/Unit/File/ApacheFileProtectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ public function testCreate()
*/
$rootDir = $this->root->get('/');
$rootDir->add('testDir', new Directory());
$rootDir->add('secondTestDir', new Directory([
'sites' => new Directory([
'2' => new Directory()
])
]));
$testDir = 'vfs://testDir';
$secondTestDir = 'vfs://secondTestDir/sites/2/';

$apacheFileProtection = new ApacheFileProtection(
$this->getPhp(),
Expand All @@ -173,8 +179,8 @@ public function testCreate()
$this->getUtil()
);

$file = 'vfs://testDir/'.ApacheFileProtection::FILE_NAME;
$passwordFile = 'vfs://testDir/'.ApacheFileProtection::PASSWORD_FILE_NAME;
$file = $testDir.'/'.ApacheFileProtection::FILE_NAME;
$passwordFile = $testDir.'/'.ApacheFileProtection::PASSWORD_FILE_NAME;

self::assertTrue($apacheFileProtection->create($testDir));
self::assertTrue(file_exists($file));
Expand Down Expand Up @@ -240,19 +246,20 @@ public function testCreate()
file_get_contents($file)
);

self::assertTrue($apacheFileProtection->create($testDir, 'objectType'));
$secondFile = $secondTestDir.'/'.ApacheFileProtection::FILE_NAME;

self::assertTrue($apacheFileProtection->create($secondTestDir, 'objectType'));
self::assertEquals(
"<IfModule mod_rewrite.c>\n"
."RewriteEngine On\n"
."RewriteBase /path/\n"
."RewriteRule ^index\.php$ - [L]\n"
."RewriteCond %{REQUEST_URI} !.*\/sites\/[0-9]+\/.*\n"
."RewriteRule ^([^?]*)$ /path/index.php?uamfiletype=objectType&uamgetfile=$1 [QSA,L]\n"
."RewriteRule ^(.*)\\?(((?!uamfiletype).)*)$ "
."/path/index.php?uamfiletype=objectType&uamgetfile=$1&$2 [QSA,L]\n"
."RewriteRule ^(.*)\\?(.*)$ /path/index.php?uamgetfile=$1&$2 [QSA,L]\n"
."</IfModule>\n",
file_get_contents($file)
file_get_contents($secondFile)
);

self::assertFalse($apacheFileProtection->create('invalid', 'invalid'));
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/UserAccessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use UserAccessManager\Controller\Backend\DynamicGroupsController;
use UserAccessManager\Controller\Backend\ObjectController;
use UserAccessManager\Controller\Backend\PostObjectController;
use UserAccessManager\Controller\Backend\SetupController;
use UserAccessManager\Controller\Backend\TermObjectController;
use UserAccessManager\Controller\Backend\UserObjectController;
use UserAccessManager\Controller\Frontend\FrontendController;
Expand Down
4 changes: 4 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../vendor/autoload.php');
}

require_once __DIR__.'/defines.php';
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../includes/language.php';
Expand Down
2 changes: 1 addition & 1 deletion user-access-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: User Access Manager
* Plugin URI: https://wordpress.org/plugins/user-access-manager/
* Author URI: https://twitter.com/GM_Alex
* Version: 2.1.11
* Version: 2.1.12
* Author: Alexander Schneider
* Description: Manage the access to your posts, pages, categories and files.
* Text Domain: user-access-manager
Expand Down

0 comments on commit 556c7b3

Please sign in to comment.