diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-07-13 22:29:12 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-07-13 22:29:12 +0200 |
commit | 2015e32e3bd6922d0697a875ecdc810243c887f0 (patch) | |
tree | b35758dd8f133f2d81e1f63e6a15177e230c5af9 /application | |
parent | 0d173835ee7f411cbfe39b8d0d3bb9dbd8a0acda (diff) |
duser: add get_email()
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r-- | application/libraries/Duser/Duser.php | 7 | ||||
-rw-r--r-- | application/libraries/Duser/drivers/Duser_db.php | 20 | ||||
-rw-r--r-- | application/models/muser.php | 9 |
3 files changed, 35 insertions, 1 deletions
diff --git a/application/libraries/Duser/Duser.php b/application/libraries/Duser/Duser.php index 3bc492b71..19d1bfa09 100644 --- a/application/libraries/Duser/Duser.php +++ b/application/libraries/Duser/Duser.php @@ -92,4 +92,11 @@ class Duser extends CI_Driver_Library { return $this->{$this->_adapter}->username_exists($username); } + + public function get_email($userid) + { + $this->require_implemented(__FUNCTION__); + + return $this->{$this->_adapter}->get_email($userid); + } } diff --git a/application/libraries/Duser/drivers/Duser_db.php b/application/libraries/Duser/drivers/Duser_db.php index 48fbc007d..1258ec585 100644 --- a/application/libraries/Duser/drivers/Duser_db.php +++ b/application/libraries/Duser/drivers/Duser_db.php @@ -12,7 +12,8 @@ class Duser_db extends Duser_Driver { public $optional_functions = array( 'username_exists', 'can_reset_password', - 'can_register_new_users' + 'can_register_new_users', + 'get_email', ); public function login($username, $password) @@ -60,4 +61,21 @@ class Duser_db extends Duser_Driver { } } + public function get_email($userid) + { + $CI =& get_instance(); + + $query = $CI->db->query(" + SELECT email + FROM users + WHERE id = ? + ", array($userid))->row_array(); + + if (empty($query)) { + show_error("Failed to get email address from db"); + } + + return $query["email"]; + } + } diff --git a/application/models/muser.php b/application/models/muser.php index 29c5a453f..947b87d97 100644 --- a/application/models/muser.php +++ b/application/models/muser.php @@ -108,6 +108,15 @@ class Muser extends CI_Model { return $this->session->userdata("userid"); } + function get_email($userid) + { + if (!$this->duser->is_implemented("get_email")) { + return false; + } + + return $this->duser->get_email($userid); + } + function require_access() { if ($this->logged_in()) { |