1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
FreeIPA library for PHP |
4
|
|
|
Copyright (C) 2015 Tobias Sette <[email protected]> |
5
|
|
|
|
6
|
|
|
This program is free software: you can redistribute it and/or modify |
7
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
8
|
|
|
the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
(at your option) any later version. |
10
|
|
|
|
11
|
|
|
This program is distributed in the hope that it will be useful, |
12
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
GNU Lesser General Public License for more details. |
15
|
|
|
|
16
|
|
|
You should have received a copy of the GNU Lesser General Public License |
17
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
// Dependencies: |
|
|
|
|
21
|
|
|
//require_once('Connection.php'); |
22
|
|
|
//require_once('User.php'); |
23
|
|
|
//require_once('Group.php'); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Classes for access to FreeIPA API |
27
|
|
|
* @since 0.1 |
28
|
|
|
*/ |
29
|
|
|
namespace FreeIPA\APIAccess; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Façade class to access all implemented methods and resources on this lib |
33
|
|
|
* |
34
|
|
|
* @author Tobias Sette <[email protected]> |
35
|
|
|
* @copyright Copyright (c) 2015 Tobias Sette <[email protected]> |
36
|
|
|
* @license LGPLv3 |
37
|
|
|
* @package php-freeipa |
38
|
|
|
* @since GIT 0.1.0 |
39
|
|
|
* @version GIT: 0.2.0 |
40
|
|
|
*/ |
41
|
|
|
class Main |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* |
45
|
|
|
* @var \FreeIPA\APIAccess\Connection |
46
|
|
|
*/ |
47
|
|
|
protected $_connection = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @var \FreeIPA\APIAccess\User |
52
|
|
|
*/ |
53
|
|
|
protected $_user = null; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* @var \FreeIPA\APIAccess\Group |
58
|
|
|
*/ |
59
|
|
|
protected $_group = null; |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function __construct($server = null, $certificate = null) |
63
|
|
|
{ |
64
|
|
|
$this->_connection = $this->connection($server, $certificate); |
65
|
|
|
$this->_user = new \FreeIPA\APIAccess\User($this->_connection); |
66
|
|
|
$this->_group = $this->_group = new \FreeIPA\APIAccess\Group($this->_connection); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* |
71
|
|
|
* @param string $server |
72
|
|
|
* @param string $certificate |
73
|
|
|
* @return \FreeIPA\APIAccess\Connection |
74
|
|
|
*/ |
75
|
|
|
public function connection($server = null, $certificate = null) |
76
|
|
|
{ |
77
|
|
|
if (! $this->_connection) { |
78
|
|
|
$this->_connection = \FreeIPA\APIAccess\Connection::getInstance($server, $certificate); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
return($this->_connection); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* |
85
|
|
|
* @return \FreeIPA\APIAccess\User |
86
|
|
|
*/ |
87
|
|
|
public function user() |
88
|
|
|
{ |
89
|
|
|
return($this->_user); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* |
94
|
|
|
* @return \FreeIPA\APIAccess\Group |
95
|
|
|
*/ |
96
|
|
|
public function group() |
97
|
|
|
{ |
98
|
|
|
return($this->_group); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.