helpers
1 week ago
tables
1 week ago
aIProviderInterface.php
1 week ago
assets.php
1 week ago
baseObject.php
1 week ago
builderBlock.php
1 week ago
controller.php
1 week ago
date.php
1 week ago
db.php
1 week ago
dispatcher.php
1 week ago
errors.php
1 week ago
field.php
1 week ago
fieldAdapter.php
1 week ago
frame.php
1 week ago
helper.php
1 week ago
html.php
1 week ago
installer.php
1 week ago
installerDbUpdater.php
1 week ago
integration.php
1 week ago
modInstaller.php
1 week ago
model.php
1 week ago
module.php
1 week ago
req.php
1 week ago
response.php
1 week ago
table.php
1 week ago
uri.php
1 week ago
user.php
1 week ago
utils.php
1 week ago
validator.php
1 week ago
view.php
1 week ago
user.php
60 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | class WaicUser { |
| 6 | protected $_data = array(); |
| 7 | protected $_curentID = 0; |
| 8 | protected $_dataLoaded = false; |
| 9 | public function init() { |
| 10 | /*load model and other preload data goes here*/ |
| 11 | } |
| 12 | public function loadUserData() { |
| 13 | return $this->getCurrent(); |
| 14 | } |
| 15 | public function isAdmin() { |
| 16 | if (!function_exists('wp_get_current_user')) { |
| 17 | WaicFrame::_()->loadPlugins(); |
| 18 | } |
| 19 | return current_user_can( WaicFrame::_()->getModule('adminmenu')->getMainCap() ); |
| 20 | } |
| 21 | public function getCurrentUserPosition() { |
| 22 | if ($this->isAdmin()) { |
| 23 | return WAIC_ADMIN; |
| 24 | } else if ($this->getCurrentID()) { |
| 25 | return WAIC_LOGGED; |
| 26 | } else { |
| 27 | return WAIC_GUEST; |
| 28 | } |
| 29 | } |
| 30 | public function getCurrent() { |
| 31 | return wp_get_current_user(); |
| 32 | } |
| 33 | |
| 34 | public function getCurrentID() { |
| 35 | $this->_loadUserData(); |
| 36 | return $this->_curentID; |
| 37 | } |
| 38 | protected function _loadUserData() { |
| 39 | if (!$this->_dataLoaded) { |
| 40 | if (!function_exists('wp_get_current_user')) { |
| 41 | WaicFrame::_()->loadPlugins(); |
| 42 | } |
| 43 | $user = wp_get_current_user(); |
| 44 | $this->_data = $user->data; |
| 45 | $this->_curentID = $user->ID; |
| 46 | $this->_dataLoaded = true; |
| 47 | } |
| 48 | } |
| 49 | public function getAdminsList() { |
| 50 | global $wpdb; |
| 51 | $admins = WaicDb::get('SELECT * FROM #__users |
| 52 | INNER JOIN #__usermeta ON #__users.ID = #__usermeta.user_id |
| 53 | WHERE #__usermeta.meta_key = "#__capabilities" AND #__usermeta.meta_value LIKE "%administrator%"'); |
| 54 | return $admins; |
| 55 | } |
| 56 | public function isLoggedIn() { |
| 57 | return is_user_logged_in(); |
| 58 | } |
| 59 | } |
| 60 |