summaryrefslogtreecommitdiffstats
path: root/lib/User.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-01-19 10:01:37 +0100
committerAleksander Machniak <alec@alec.pl>2012-01-19 10:01:37 +0100
commit1cbeff7c95c444e64c0179c5d74c4ce1f3f3e8e9 (patch)
treee7ed7583d2fa1e5febdd6780664fb4048afab792 /lib/User.php
parent852dfa881c482449eef173569d27cd0e6025d50f (diff)
downloadwebadmin-1cbeff7c95c444e64c0179c5d74c4ce1f3f3e8e9.tar.gz
CS fixes
Diffstat (limited to 'lib/User.php')
-rw-r--r--lib/User.php169
1 files changed, 87 insertions, 82 deletions
diff --git a/lib/User.php b/lib/User.php
index db456bf..2e0ea21 100644
--- a/lib/User.php
+++ b/lib/User.php
@@ -3,114 +3,119 @@
// @require_once($_SERVER["DOCUMENT_ROOT"] . "../bin/lib/User/LDAP.php");
// @require_once($_SERVER["DOCUMENT_ROOT"] . "../bin/lib/User/SQL.php");
- require_once('Auth.php');
+require_once 'Auth.php';
- class User
- {
+class User
+{
+ private $_authenticated = FALSE;
+ private $auth;
- private $_authenticated = FALSE;
+ private $username = NULL;
+ private $password = NULL;
- private $auth;
+ private $_groups = FALSE;
- private $username = NULL;
- private $password = NULL;
+ private $domain;
+ private $working_domain;
- private $_groups = FALSE;
+ public function get_username()
+ {
+ // Who's asking?
+ return $this->username;
+ }
- private $domain;
- private $working_domain;
+ public function _get_information()
+ {
+ // Return an array of information about this user. For one, the auth method.
+ $user['information'] = array(
+ 'email_address' => $this->_auth_method->_get_email_address(),
+ 'username' => $this->username,
+ 'password' => $this->password,
+ );
+ }
- public function get_username()
- {
- // Who's asking?
- return $this->username;
- }
+ public function authenticate($username, $password, $method = FALSE)
+ {
+ $this->auth = Auth::get_instance();
- public function _get_information()
- {
- // Return an array of information about this user. For one, the auth method.
- $user['information'] = Array(
- 'email_address' => $this->_auth_method->_get_email_address(),
- 'username' => $this->username,
- 'password' => $this->password,
- );
- }
+ $result = $this->auth->authenticate($username, $password);
- public function authenticate($username, $password, $method = FALSE)
- {
- $this->auth = Auth::get_instance();
+ if ($result) {
+ $this->_authenticated = TRUE;
+ $this->username = $username;
+ $this->password = $password;
+ $this->domain = $this->auth->domain;
+// $this->_groups = $this->groups();
+ }
- $result = $this->auth->authenticate($username, $password);
+ return $this->_authenticated;
+ }
- if ($result) {
- $this->_authenticated = TRUE;
- $this->username = $username;
- $this->password = $password;
- $this->domain = $this->auth->domain;
-# $this->_groups = $this->groups();
- }
+ public function authenticated()
+ {
+ return $this->_authenticated;
+ }
- return $this->_authenticated;
+ public function get_domain()
+ {
+ if ($this->working_domain) {
+ return $this->working_domain;
}
-
- public function authenticated() {
- return $this->_authenticated;
+ else if ($this->domain) {
+ return $this->domain;
}
-
- public function get_domain() {
- if ($this->working_domain) {
- return $this->working_domain;
- } elseif ($this->domain) {
- return $this->domain;
- } else {
- throw new Exception("No domain selected to work on", 1024);
- }
+ else {
+ throw new Exception("No domain selected to work on", 1024);
}
+ }
- public function groups() {
- #error_log("Called " . __FUNCTION__ . " on line " . __LINE__ . " of " . __FILE__);
- #debug_print_backtrace();
+ public function groups()
+ {
+ //error_log("Called " . __FUNCTION__ . " on line " . __LINE__ . " of " . __FILE__);
+ //debug_print_backtrace();
- if ($this->_groups || (is_array($this->_groups) && count($this->_groups) >= 1))
- return $this->_groups;
+ if ($this->_groups || (is_array($this->_groups) && count($this->_groups) >= 1)) {
+ return $this->_groups;
+ }
- $this->_groups = Array();
- $this->auth = Auth::get_instance();
+ $this->_groups = array();
+ $this->auth = Auth::get_instance();
- $entry = $this->auth->user_find_by_attribute(Array('mail' => $this->username));
+ $entry = $this->auth->user_find_by_attribute(array('mail' => $this->username));
- if ($entry) {
- foreach ($entry as $dn => $attributes) {
- if (array_key_exists('memberof', $attributes)) {
- $this->_groups = (array)($attributes['memberof']);
- } else {
- $this->_groups = $this->auth->find_user_groups($dn);
- }
+ if ($entry) {
+ foreach ($entry as $dn => $attributes) {
+ if (array_key_exists('memberof', $attributes)) {
+ $this->_groups = (array)($attributes['memberof']);
+ }
+ else {
+ $this->_groups = $this->auth->find_user_groups($dn);
}
- } else {
- $this->_groups = Array();
}
-
- return $this->_groups;
}
-
- public function reset_domain() {
- // Validate domain
- // Validate access to domain
- // Set $this->working_domain
- $this->working_domain = $this->domain;
- return TRUE;
+ else {
+ $this->_groups = array();
}
- public function set_domain($domain) {
- // Validate domain
- // Validate access to domain
- // Set $this->working_domain
- $this->working_domain = $domain;
- return TRUE;
- }
+ return $this->_groups;
+ }
+ public function reset_domain()
+ {
+ // Validate domain
+ // Validate access to domain
+ // Set $this->working_domain
+ $this->working_domain = $this->domain;
+ return TRUE;
}
-?>
+ public function set_domain($domain)
+ {
+ // Validate domain
+ // Validate access to domain
+ // Set $this->working_domain
+ $this->working_domain = $domain;
+ return TRUE;
+ }
+}