1
|
|
|
<?php |
2
|
|
|
//------------------------------------------------------------------------- |
3
|
|
|
// OVIDENTIA http://www.ovidentia.org |
4
|
|
|
// Ovidentia is free software; you can redistribute it and/or modify |
5
|
|
|
// it under the terms of the GNU General Public License as published by |
6
|
|
|
// the Free Software Foundation; either version 2, or (at your option) |
7
|
|
|
// any later version. |
8
|
|
|
// |
9
|
|
|
// This program is distributed in the hope that it will be useful, but |
10
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
// See the GNU General Public License for more details. |
13
|
|
|
// |
14
|
|
|
// You should have received a copy of the GNU General Public License |
15
|
|
|
// along with this program; if not, write to the Free Software |
16
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
17
|
|
|
// USA. |
18
|
|
|
//------------------------------------------------------------------------- |
19
|
|
|
/** |
20
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
21
|
|
|
* @copyright Copyright (c) 2009 by CANTICO ({@link http://www.cantico.fr}) |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The app_AccessManager class |
29
|
|
|
* |
30
|
|
|
* @method Func_App App() |
31
|
|
|
*/ |
32
|
|
|
class app_AccessManager implements app_Object_Interface |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var Func_App |
36
|
|
|
*/ |
37
|
|
|
private $App = null; |
|
|
|
|
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param Func_App $app |
42
|
|
|
*/ |
43
|
|
|
public function __construct(Func_App $app) |
44
|
|
|
{ |
45
|
|
|
$this->setApp($app); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Forces the Func_App object to which this object is 'linked'. |
50
|
|
|
* |
51
|
|
|
* @param Func_App $app |
52
|
|
|
* @return self |
53
|
|
|
*/ |
54
|
|
|
public function setApp(Func_App $app) |
55
|
|
|
{ |
56
|
|
|
$this->app = $app; |
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get APP object to use with this SET |
62
|
|
|
* |
63
|
|
|
* @return Func_App |
64
|
|
|
*/ |
65
|
|
|
public function App() |
66
|
|
|
{ |
67
|
|
|
return $this->app; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* |
73
|
|
|
* @param app_RecordSet $recordSet |
74
|
|
|
* @param string $accessType |
75
|
|
|
* @param int $user |
76
|
|
|
*/ |
77
|
|
|
public function getAccessCriterion(app_RecordSet $recordSet, $accessType, $user = null) |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
return $recordSet->none(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* |
84
|
|
|
* @param app_Record $record |
85
|
|
|
* @param string $accessType |
86
|
|
|
* @param int $user |
87
|
|
|
*/ |
88
|
|
|
public function getAccess(app_Record $record, $accessType, $user = null) |
89
|
|
|
{ |
90
|
|
|
$recordSet = $record->getParentSet(); |
91
|
|
|
$criterion = $this->getAccessCriterion($recordSet, $accessType, $user); |
92
|
|
|
|
93
|
|
|
$matches = $recordSet->select($criterion->_AND_($recordSet->id->is($record->id))); |
|
|
|
|
94
|
|
|
|
95
|
|
|
return ($matches->count() !== 0); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|