diff --git a/class2.php b/class2.php index 202e9bc5d..8ca5a9d32 100644 --- a/class2.php +++ b/class2.php @@ -1355,12 +1355,34 @@ function getperms($arg, $ap = ADMINPERMS) /** * Get the user data from user and user_extended tables + * SO MUCH DEPRECATED! + * * * @return array */ function get_user_data($uid, $extra = '') { - $e107 = e107::getInstance(); + if(e107::getPref('developer')) + { + e107::getAdminLog()->log_event( + 'Deprecated call - get_user_data()', + 'Call to deprecated function get_user_data() (class2.php)', + E_LOG_INFORMATIVE, + 'DEPRECATED' + ); + // TODO - debug screen Deprecated Functions (e107) + e107::getMessage()->addDebug('Deprecated get_user_data() backtrace:
'."\n".print_r(debug_backtrace(), true).''); + } + + $var = array(); + $user = e107::getSystemUser($uid, true); + if($user) + { + $var = $user->getUserData(); + } + return $var; + + /*$e107 = e107::getInstance(); $uid = (int)$uid; $var = array(); if($uid == 0) { return $var; } @@ -1421,6 +1443,7 @@ function get_user_data($uid, $extra = '') } } + if ($var['user_perms'] == '0.') $var['user_perms'] = '0'; // Handle some legacy situations //=========================================================== $var['user_baseclasslist'] = $var['user_class']; // Keep track of which base classes are in DB @@ -1431,6 +1454,7 @@ function get_user_data($uid, $extra = '') cachevars("userdata_{$uid}", $var); return $var; + */ } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// @@ -1439,6 +1463,18 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '') { global $pref, $user_pref, $tp, $PrefCache, $sql, $eArrayStorage, $theme_pref; + if(e107::getPref('developer')) + { + e107::getAdminLog()->log_event( + 'Deprecated call - save_prefs()', + 'Call to deprecated function save_prefs() (class2.php)', + E_LOG_INFORMATIVE, + 'DEPRECATED' + ); + // TODO - debug screen Deprecated Functions (e107) + e107::getMessage()->addDebug('Deprecated save_prefs() backtrace:
'."\n".print_r(debug_backtrace(), true).''); + } + switch($table) { case 'core': diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index f2a9b9ef3..8f3aa561c 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -294,6 +294,22 @@ class e_user_model extends e_front_model return $editor->isAdmin(); } + /** + * Bad but required (BC) method of retrieving all user data + * It's here to be used from get_user_data() core function. + * DON'T USE IT unless you have VERY good reason to do it. + * + * @return array + */ + public function getUserData() + { + $ret = array_merge($this->getExtendedModel()->getExtendedData(), $this->getData()); + if ($ret['user_perms'] == '0.') $ret['user_perms'] = '0'; + $ret['user_baseclasslist'] = $ret['user_class']; + $ret['user_class'] = $this->getClassList(true); + return $ret; + } + /** * Get User value * @@ -1142,6 +1158,30 @@ class e_user_extended_model extends e_front_model return $this->getUser()->getEditor(); } + /** + * Bad but required (BC) method of retrieving all user data + * It's here to be used from get_user_data() core function. + * DON'T USE IT unless you have VERY good reason to do it. + * + * @return array + */ + public function getExtendedData() + { + $ret = array(); + + $fields = $this->getExtendedStructure()->getFieldTree(); + foreach ($fields as $id => $field) + { + $value = $this->getValue($field->getValue('name')); + if(null !== $value) $ret[$field->getValue('name')] = $value; + } + + $ret['user_extended_id'] = $this->getId(); + $ret['user_hidden_fields'] = $this->get('user_hidden_fields'); + + return $ret; + } + /** * Get User extended field value * Returns NULL when field/default value not found or not enough permissions @@ -1228,8 +1268,8 @@ class e_user_extended_model extends e_front_model public function checkRead($field) { $hidden = $this->get('user_hidden_fields'); - $editor = $this->getEditor(); - if($this->getId() !== $editor->getId() && !empty($hidden) && strpos($hidden, $field) !== false) return false; + $editor = $this->getEditor();//var_dump($field, $this->_struct_index[$field], $this->getEditor()->getId(), $this->checkApplicable($field)); + if(!empty($hidden) && $this->getId() !== $editor->getId() && strpos($hidden, '^'.$field.'^') !== false) return false; return ($this->checkApplicable($field) && $editor->checkClass($this->_memberlist_access) && $editor->checkClass(varset($this->_struct_index[$field]['read']))); } @@ -1268,7 +1308,7 @@ class e_user_extended_model extends e_front_model */ public function checkApplicable($field) { - return $this->getUser()->checkClass(varset($this->_struct_index[$field]['applicable'])); + return $this->getUser()->checkClass(varset($this->_struct_index[$field]['apply'])); } /** @@ -1585,6 +1625,15 @@ class e_user_extended_structure_tree extends e_tree_model return $this->_array_intersect_key($this->getTree(), array_combine($this->_category_index, $this->_category_index)); } + /** + * Get collection of nodes of type field + * @return array + */ + public function getFieldTree() + { + return array_diff_key($this->getTree(), array_combine($this->_category_index, $this->_category_index)); + } + /** * Get collection of nodes assigned to a specific category * @param integer $category_id @@ -1607,10 +1656,7 @@ class e_user_extended_structure_tree extends e_tree_model ->setParam('model_class', 'e_user_extended_structure_model') ->setParam('db_order', 'user_extended_struct_order ASC'); parent::load($force); - print_a($this->_category_index); - print_a($this->_parent_index); - print_a($this->_name_index); - print_a($this->getTreeByCategory(4)); + return $this; }