forked from cosmocode/dokuwiki-plugin-struct
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to restrict users/groups that can autocomplete usernames
By default this is set to @ALL, so the behaviour is backwards-compatible. Tests of this new feature have been added.
- Loading branch information
1 parent
fc61ec9
commit 624b85e
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,19 @@ public function test_validate_success() | |
|
||
public function test_ajax() | ||
{ | ||
global $INPUT; | ||
global $INFO, $INPUT, $USERINFO; | ||
include(__DIR__ . '/../../conf/default.php'); | ||
$default_allow_autocomplete = $conf['allow_username_autocomplete']; | ||
unset($conf); | ||
|
||
global $conf; | ||
$conf['plugin']['struct']['allow_username_autocomplete'] = $default_allow_autocomplete; | ||
$_SERVER['REMOTE_USER'] = 'john'; | ||
$USERINFO['name'] = 'John Smith'; | ||
$USERINFO['mail'] = '[email protected]'; | ||
$USERINFO['grps'] = ['user', 'test']; | ||
//update info array | ||
$INFO['userinfo'] = $USERINFO; | ||
|
||
$user = new User( | ||
[ | ||
|
@@ -56,6 +68,21 @@ public function test_ajax() | |
$INPUT->set('search', 'd'); // under mininput | ||
$this->assertEquals([], $user->handleAjax()); | ||
|
||
// Check restrictions on who can access username data are respected | ||
$conf['plugin']['struct']['allow_username_autocomplete'] = 'john'; | ||
$INPUT->set('search', 'dent'); | ||
$this->assertEquals([['label' => 'Arthur Dent [testuser]', 'value' => 'testuser']], $user->handleAjax()); | ||
|
||
$conf['plugin']['struct']['allow_username_autocomplete'] = '@user'; | ||
$INPUT->set('search', 'dent'); | ||
$this->assertEquals([['label' => 'Arthur Dent [testuser]', 'value' => 'testuser']], $user->handleAjax()); | ||
|
||
$conf['plugin']['struct']['allow_username_autocomplete'] = '@not_in_group,not_this_user'; | ||
$INPUT->set('search', 'dent'); | ||
$this->assertEquals([], $user->handleAjax()); | ||
|
||
$conf['plugin']['struct']['allow_username_autocomplete'] = $default_allow_autocomplete; | ||
|
||
$user = new User( | ||
[ | ||
'autocomplete' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters