1
|
|
|
<?php |
2
|
|
|
/****************************************************************** |
3
|
|
|
system.save.grantsarray.php Muze Ariadne |
4
|
|
|
------------------------------------------------------------------ |
5
|
|
|
Arguments: $path, $grants |
6
|
|
|
|
7
|
|
|
Grant needed: config |
8
|
|
|
Global variables: none |
9
|
|
|
|
10
|
|
|
This template saves changes to grants defined at the current |
11
|
|
|
object. It then updates the changes at the user/group object too. |
12
|
|
|
|
13
|
|
|
no result |
14
|
|
|
|
15
|
|
|
******************************************************************/ |
16
|
|
|
if ($this->CheckLogin("config") && $this->CheckConfig()) { |
17
|
|
|
include_once($this->store->get_config("code")."modules/mod_grant.php"); |
18
|
|
|
|
19
|
|
|
// some variable fetching stuff |
20
|
|
|
$userpath=$this->getvar("userpath"); |
21
|
|
|
$grants=$this->getvar("grants"); |
22
|
|
|
|
23
|
|
|
if (!$userpath || !is_array($grants)) { |
24
|
|
|
$this->error=$ARnls["err:missingparam"]; |
25
|
|
|
} |
26
|
|
|
if (!$this->error) { |
27
|
|
|
|
28
|
|
|
if ($userObj=current($this->get($userpath, "system.get.phtml"))) { |
29
|
|
|
if ($userObj->AR_implements("pgroup")) { |
30
|
|
|
$type="pgroup"; |
31
|
|
|
} else if ($userObj->AR_implements("puser")) { |
32
|
|
|
$type="puser"; |
33
|
|
|
} else { |
34
|
|
|
$this->error=sprintf($ARnls["err:nousergroup"],$userpath); |
35
|
|
|
} |
36
|
|
|
if (!$this->error) { |
37
|
|
|
if ($id=current($this->get($userpath, "system.get.login.phtml"))) { |
38
|
|
|
// first make sure that the object is clean (data can only be set via |
39
|
|
|
// the defined interface: $arCallArgs) |
40
|
|
|
$this->data=current($this->get(".","system.get.data.phtml")); |
41
|
|
|
if (count($grants)) { |
42
|
|
|
$this->data->config->grants[$type][$id] = $grants; |
43
|
|
|
} else { |
44
|
|
|
unset( $this->data->config->grants[$type][$id] ); |
45
|
|
|
} |
46
|
|
|
$this->save(); |
47
|
|
|
$result=current($this->get($userpath, "system.save.grants.user.phtml", array( |
48
|
|
|
"action" => "set", |
49
|
|
|
"path" => $this->path, |
50
|
|
|
"grants" => $grants |
51
|
|
|
))); |
52
|
|
|
} else { |
53
|
|
|
$this->error=sprintf($ARnls["err:notgetlogin"],$userpath); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
} else { |
57
|
|
|
$this->error=sprintf($ARnls["err:notfindusergroup"],$userpath); |
58
|
|
|
} |
59
|
|
|
if (!$this->error) { |
60
|
|
|
// clear public cache recursively |
61
|
|
|
$this->ClearCache($this->path, false, true); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
?> |
|
|
|
|
66
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.