function cw_user_get_info($customer_id, $info_type = 0) { global $tables, $current_language, $default_user_profile_fields, $config; global $addons; $userinfo = \Customer\get($customer_id); if (empty($userinfo)) { return null; } $userinfo = array_merge($userinfo, (array) cw_query_first("SELECT membership, flag FROM {$tables['memberships']} WHERE membership_id = '{$userinfo['membership_id']}'")); # kornev, TOFIX if ($userinfo['usertype'] == 'B') { $userinfo['plan_id'] = cw_query_first_cell("SELECT plan_id FROM {$tables['salesman_commissions']} WHERE salesman_customer_id='{$userinfo['customer_id']}'"); } if ($info_type & 1) { $userinfo['addresses'] = cw_user_get_addresses($customer_id); $userinfo['main_address'] = cw_user_get_address($customer_id, 'main'); $userinfo['current_address'] = cw_user_get_address($customer_id, 'current'); $address = empty($userinfo['main_address']) ? $userinfo['current_address'] : $userinfo['main_address']; $userinfo['firstname'] = $address['firstname']; $userinfo['lastname'] = $address['lastname']; $userinfo['fullname'] = trim($address['firstname'] . ' ' . $address['lastname']); unset($address); } if ($info_type & 2) { cw_load('crypt'); // For security reason password must be left encrypted in userinfo data /* $userinfo['password'] = text_decrypt($userinfo['password']); if (is_null($userinfo['password'])) cw_log_flag("log_decrypt_errors", "DECRYPT", "Could not decrypt password for the user ".$userinfo['customer_id'], true); elseif ($userinfo['password'] !== false) $userinfo['password'] = stripslashes($userinfo['password']); */ } if ($info_type & 4) { $userinfo['cc_info'] = cw_user_get_current_ccinfo($customer_id); } if ($info_type & 8) { cw_load('profile_fields'); $userinfo['additional_fields'] = cw_profile_fields_get_additional($customer_id); } if ($info_type & 16) { if ($userinfo['usertype'] == 'B') { $userinfo['salesman_info'] = cw_get_salesman_info($customer_id); } } if ($info_type & 32) { $userinfo['system_info'] = cw_user_get_system_info($customer_id); } if ($info_type & 64) { $userinfo['additional_info'] = cw_user_get_addition_info($customer_id, $userinfo['usertype']); $userinfo['relations'] = cw_user_get_relations($customer_id); } if ($info_type & 256) { $userinfo['addresses'] = cw_user_get_addresses($customer_id); } if ($info_type & 1024) { $userinfo['custom_fields'] = cw_user_get_custom_fields($customer_id); } return $userinfo; }
function get_newslists_by_customer($customer_id, $direct_only = null) { global $tables; $user = \Customer\get($customer_id); if (empty($user)) { return null; } $direct = $indirect = array(); if (is_null($direct_only) || $direct_only === true) { $direct = cw_query_column("SELECT n.list_id FROM {$tables['newslist_subscription']} s\n INNER JOIN {$tables['newslists']} n ON n.list_id=s.list_id\n WHERE s.email='{$user['email']}'"); } if (is_null($direct_only) || $direct_only === false) { $indirect = cw_query_column("SELECT n.list_id FROM {$tables['newslists_memberships']} m\n INNER JOIN {$tables['newslists']} n ON n.list_id=m.list_id\n WHERE m.membership_id='{$user['membership_id']}'"); } $all = array_merge($indirect, $direct); $result = array(); foreach ($all as $lid) { $result[$lid] = array_merge(get_newslist($lid), array('direct' => intval(in_array($lid, $direct, true)), 'by_membership' => intval(in_array($lid, $indirect, true)))); } return $result; }