1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8/**
9 * Simple resolver always providing the same answer. Primarly
10 * used for testing purposes, but also used as the administrator
11 * resolver.
12 */
13class Perms_Resolver_Default implements Perms_Resolver
14{
15	private $value;
16
17	function __construct($value)
18	{
19		$this->value = (bool) $value;
20	}
21
22	function check($name, array $groups)
23	{
24		return $this->value;
25	}
26
27	function from()
28	{
29		return 'system';
30	}
31
32	function applicableGroups()
33	{
34		return ['Anonymous', 'Registered'];
35	}
36
37	function dump()
38	{
39		$result = [
40			'from' => $this->from(),
41			'perms' => [],
42		];
43		foreach ($this->applicableGroups as $group) {
44			$result['perms'][$this->value ? 'all' : 'none'][] = $group;
45		}
46		return $result;
47	}
48}
49