get_user($id); if ($controls->is_action('save')) { $email = $module->normalize_email($controls->data['email']); if (empty($email)) { $controls->errors = __('Wrong email address', 'newsletter'); } else { $controls->data['email'] = $email; } if (empty($controls->errors)) { $u = $module->get_user($controls->data['email']); if ($u && $u->id != $id) { $controls->errors = __('The email address is already in use', 'newsletter'); } } if (empty($controls->errors)) { // For unselected preferences, force the zero value for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) { if (!isset($controls->data['list_' . $i])) { $controls->data['list_' . $i] = 0; } } if (empty($controls->data['token'])) { $controls->data['token'] = $module->get_token(); } $controls->data['id'] = $id; $user = $module->save_user($controls->data); $module->add_user_log($user, 'edit'); if ($user === false) { $controls->errors = __('Error. Check the log files.', 'newsletter'); } else { $controls->add_message_saved(); $controls->data = (array) $user; } } } if ($controls->is_action('delete')) { $module->delete_user($id); $controls->js_redirect($module->get_admin_page_url('index')); return; } if (!$controls->is_action()) { $controls->data = (array) $user; } $options_profile = NewsletterSubscription::instance()->get_options('profile'); function percent($value, $total) { if ($total == 0) { return '-'; } return sprintf("%.2f", $value / $total * 100) . '%'; } function percentValue($value, $total) { if ($total == 0) { return 0; } return round($value / $total * 100); } ?>