Created
September 24, 2014 13:41
-
-
Save morales2k/8ac80e7cb57989761635 to your computer and use it in GitHub Desktop.
PHP-Fusion class to fetch user data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*-------------------------------------------------------+ | |
| PHP-Fusion Content Management System | |
| Copyright (C) PHP-Fusion Inc | |
| https://www.php-fusion.co.uk/ | |
+--------------------------------------------------------+ | |
| Filename: UserDataHelper.php | |
| Author: Jorge Morales (Elvenelf / EffectiX.Net) | |
+--------------------------------------------------------+ | |
| This program is released as free software under the | |
| Affero GPL license. You can redistribute it and/or | |
| modify it under the terms of this license which you | |
| can read by viewing the included agpl.txt or online | |
| at www.gnu.org/licenses/agpl.html. Removal of this | |
| copyright header is strictly prohibited without | |
| written permission from the original author(s). | |
+--------------------------------------------------------*/ | |
if (!defined("IN_FUSION")) { die("Access Denied"); } | |
class UserDataHelper{ | |
protected $requested_user_data = array(); | |
public function __construct($id=0){ | |
if($id > 0) $this->fetchUserData($id); | |
} | |
public function getUserData(){ | |
return $this->requested_user_data; | |
} | |
public function getUserName(){ | |
return $this->requested_user_data['user_name']; | |
} | |
public function getUserEmail(){ | |
return $this->requested_user_data['user_email']; | |
} | |
public function getUserLevel(){ | |
return $this->requested_user_data['user_level']; | |
} | |
protected function fetchUserData($id){ | |
if(!is_numeric($id)) { | |
setError(256, 'Provided ID was not a number. Id\'s MUST be numbers. Always.'); | |
return false; | |
}else{ | |
$requestedUserData = dbarray(dbquery("SELECT user_id, user_name, user_email, user_offset, user_posts, user_threads, user_joined, user_lastvisit, user_ip, user_ip_type, user_rights, user_level, user_groups, user_status, user_theme, user_tel, user_company, user_location FROM ".DB_PREFIX."users WHERE user_id='{$id}' LIMIT 1")); | |
if(count($requestedUserData)>0){ | |
$this->requested_user_data = $requestedUserData; | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment