function cw_user_delete($params) { global $var_dirs, $tables, $config; global $addons; global $smarty; extract($params); // damn extract // $customer_id, $send_mail, $is_redirect = true $customer_id = isset($customer_id) ? $customer_id : 0; $send_mail = isset($send_mail) ? $send_mail : false; $is_redirect = isset($is_redirect) ? $is_redirect : true; cw_load('files', 'product', 'mail'); $olduser_info = cw_user_get_info($customer_id, 65535); $to_customer = $olduser_info['language']; $usertype = $olduser_info['usertype']; if ($usertype == "A") { $users_count = cw_query_first_cell("SELECT COUNT(*) FROM {$tables['customers']} WHERE usertype='A'"); if ($users_count == 1) { if ($is_redirect) { cw_header_location("index.php?target=error_message&error=last_admin"); } return false; } } /* # kornev, TOFIX if ($usertype == "B" && cw_query_first_cell("SELECT COUNT(*) FROM $tables[addons] WHERE addon='Salesman'") > 0) { include $app_main_dir."/addons/Salesman/init.php"; db_query("delete FROM $tables[salesman_clicks] WHERE salesman_customer_id='$customer_id'"); db_query("delete FROM $tables[salesman_commissions] WHERE salesman_customer_id='$customer_id'"); db_query("delete FROM $tables[salesman_payment] WHERE salesman_customer_id='$customer_id'"); db_query("delete from $tables[salesman_views] WHERE salesman_customer_id='$customer_id'"); db_query("UPDATE $tables[customers_salesman_info] SET parent_customer_id=0 WHERE customer_id = '$customer_id' AND usertype = 'B'"); } */ \Customer\delete($customer_id); $main_tables = array('register_fields_values', 'customers_ccinfo', 'customers_settings', 'customers_relations', 'customers_salesman_info', 'customers_customer_info', 'customers_warehouse_info', 'customers_system_info'); foreach ($main_tables as $v) { db_query("delete from " . $tables[$v] . " where customer_id='{$customer_id}'"); } $smarty->assign('userinfo', $olduser_info); $anonymous_user = cw_is_anonymous($olduser_info['email']); if (!$anonymous_user && $config['Email']['eml_profile_deleted'] == 'Y' && $send_mail) { cw_call('cw_send_mail', array($config['Company']['users_department'], $olduser_info['email'], 'mail/profile_deleted_subj.tpl', 'mail/profile_deleted.tpl')); } if (!$anonymous_user && $config['Email']['eml_profile_deleted_admin'] == 'Y' && $send_mail) { cw_call('cw_send_mail', array($olduser_info['email'], $config['Company']['users_department'], 'mail/profile_deleted_subj.tpl', 'mail/profile_admin_deleted.tpl', $config['default_admin_language'])); } }
} cw_include('include/check_userdata.php'); if ($current_area == 'A') { $merchant_password =& cw_session_register("merchant_password"); } $is_merchant_password = ''; $is_anonymous = 0; if ($customer_id && AREA_TYPE != 'Y') { if ($current_area == 'A') { if ($config['mpassword'] != md5($merchant_password) && $merchant_password || !$merchant_password) { $merchant_password = ''; } else { $is_merchant_password = '******'; } } if (!empty($customer_id) && $current_area == 'C' && cw_is_anonymous($user_account['email'])) { $is_anonymous = 1; } } //cw_var_dump(cw_is_anonymous($user_account['email']), $current_area, $customer_id); $smarty->assign('is_anonymous', $is_anonymous); $smarty->assign('anonymous_customer_id', $is_anonymous); // compatibility with old skins if ($addons['now_online'] && !defined('IS_ROBOT')) { cw_include('addons/now_online/users_online.php'); } $smarty->assign('is_merchant_password', $is_merchant_password); if ($customer_id && $current_area == 'C') { $real_usertype = cw_user_get_real_usertype(); $smarty->assign('real_usertype', $real_usertype); }
if ($total_items) { $page = $data['page']; $user_search_query = cw_db_generate_query($fields, $from_tbls, $query_joins, $where, $groupbys, $having, $orderbys); $users = cw_query($q = "{$user_search_query} LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}"); if ($action == 'export_emails') { $export_columns_names = array('firstname' => 'Firstname', 'lastname' => 'Lastname', 'email' => 'Email'); $delimiter = $config['General']['user_emails_export_delimiter']; header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=customers_emails.csv"); print implode($delimiter, $export_columns_names) . "\n"; $u_keys = array(); $result = mysql_query($user_search_query); while ($row = mysql_fetch_assoc($result)) { $exp_line = array(); $row['email'] = strtolower($row['email']); if (cw_is_anonymous($row['email'])) { $row['email'] = cw_real_mail_address($row['email']); } foreach ($export_columns_names as $colname => $coltitle) { $exp_line[$colname] = $row[$colname]; } $u_key = md5($row['email']); if (!isset($u_keys[$u_key])) { $u_keys[$u_key] = 1; print implode($delimiter, $exp_line) . "\n"; } } exit; } if ($save_search_id > 0) { cw_array2update('saved_search', array("sql_query" => addslashes($user_search_query)), "ss_id = '{$save_search_id}'");
$message = cw_query_first("SELECT * FROM {$tables['newsletter']} WHERE news_id='{$messageid}'"); if (empty($news_send_data[$messageid]['lastpos'])) { # kornev, simple subscribers on the first step $tmp = cw_query("SELECT email FROM {$tables['newslist_subscription']} WHERE list_id='{$list_id}' ORDER BY email"); if (is_array($tmp)) { foreach ($tmp as $v) { if (!empty($v['email'])) { $recipients[] = $v['email']; } } } } } // Cleanup or translate anonymous emails foreach ($recipients as $k => $v) { if (cw_is_anonymous($v)) { if (defined('NEWS_SEND_TO_ANONYMOUS') && constant('NEWS_SEND_TO_ANONYMOUS')) { $recipients[$k] = cw_real_mail_address($v); } else { unset($recipients[$k]); } } } $recipients = array_unique($recipients); if (count($recipients) > 0) { cw_call('cw_spam', array($message, $recipients, $list_lng, $list_id)); if (!$do_not_update_status) { db_query("UPDATE {$tables['newsletter']} SET status = 'S', send_date = '" . time() . "' WHERE news_id = '{$message['news_id']}'"); } } if (!empty($limit) && count($recipients) > 0) {