|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Provides XML file handling for database schemas |
|
5
|
|
|
* |
|
6
|
|
|
* PHP Version 5 |
|
7
|
|
|
* |
|
8
|
|
|
* @category Core |
|
9
|
|
|
* @package XML |
|
10
|
|
|
* @author Hans-Joachim Piepereit <[email protected]> |
|
11
|
|
|
* @copyright 2013 cSphere Team |
|
12
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
|
13
|
|
|
* @link http://www.csphere.eu |
|
14
|
|
|
**/ |
|
15
|
|
|
|
|
16
|
|
|
namespace csphere\core\xml; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Provides XML file handling for access schemas |
|
20
|
|
|
* |
|
21
|
|
|
* @category Core |
|
22
|
|
|
* @package XML |
|
23
|
|
|
* @author Daniel Schalla <[email protected]> |
|
24
|
|
|
* @copyright 2013 cSphere Team |
|
25
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
|
26
|
|
|
* @link http://www.csphere.eu |
|
27
|
|
|
**/ |
|
28
|
|
|
|
|
29
|
|
|
class Driver_Access extends Base |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Determine the driver specific source file |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $type Type of target, e.g. plugin |
|
35
|
|
|
* @param string $name Directory name of the target |
|
36
|
|
|
* @param string $lang Language if more than one is possible |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
**/ |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
protected function file($type, $name, $lang) |
|
42
|
|
|
{ |
|
43
|
|
|
unset($lang); |
|
44
|
|
|
|
|
45
|
|
|
$file = ''; |
|
46
|
|
|
|
|
47
|
|
|
if ($type == 'plugin') { |
|
48
|
|
|
|
|
49
|
|
|
$file = 'csphere/plugins/' . $name . '/access.xml'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $file; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Change data array for easier usage |
|
58
|
|
|
* |
|
59
|
|
|
* @param array $array Formated array generated earlier |
|
60
|
|
|
* |
|
61
|
|
|
* @throws \ErrorException if the access file is malformed |
|
62
|
|
|
* @return array |
|
63
|
|
|
**/ |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
protected function change(array $array) |
|
66
|
|
|
{ |
|
67
|
|
|
$ret = []; |
|
68
|
|
|
|
|
69
|
|
|
foreach ($array['permission'] as $permission) { |
|
70
|
|
|
|
|
71
|
|
|
if (!isset($permission['attr'][0]['name']) |
|
72
|
|
|
|| !isset($permission['type'][0]['value']) |
|
73
|
|
|
) { |
|
74
|
|
|
throw new \ErrorException( |
|
75
|
|
|
"Malformed Access File of Plugin: " . $this->path |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$tmp = []; |
|
80
|
|
|
$tmp['type'] = $permission['type'][0]['value']; |
|
81
|
|
|
|
|
82
|
|
|
$ret[$permission['attr'][0]['name']] = $tmp; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return $ret; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|