'activeHelper_liveHelp_restrictedCountriesList', 'register' => 'activeHelper_liveHelp_restrictedCountriesRegister', ); if (!empty($_REQUEST['action']) && isset($actions[$_REQUEST['action']])) return $actions[$_REQUEST['action']](); return $actions['list'](); } function activeHelper_liveHelp_restrictedCountriesPost() { $actions = array( 'delete' => 'activeHelper_liveHelp_restrictedCountriesDeletePost', 'register' => 'activeHelper_liveHelp_restrictedCountriesRegisterPost' ); if (!empty($_REQUEST['action']) && isset($actions[$_REQUEST['action']])) return $actions[$_REQUEST['action']](); } function activeHelper_liveHelp_restrictedCountriesDeletePost() { global $wpdb, $activeHelper_liveHelp; $_REQUEST['id'] = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; if (empty($_REQUEST['id'])) { wp_redirect('admin.php?page=' . strtolower('activeHelper_liveHelp_restrictedCountries') . '&miss'); exit; } $wpdb->query(" DELETE FROM {$wpdb->prefix}livehelp_not_allowed_countries WHERE id = {$_REQUEST['id']} LIMIT 1 "); wp_redirect('admin.php?page=' . strtolower('activeHelper_liveHelp_restrictedCountries') . '&delete'); exit; } function activeHelper_liveHelp_restrictedCountriesList() { global $wpdb, $activeHelper_liveHelp; $restrictionsList = $wpdb->get_results(" SELECT jlnac.id AS restriction_id, jld.id_domain AS domain_id, jld.name AS domain_name, jlc.name AS country FROM {$wpdb->prefix}livehelp_not_allowed_countries AS jlnac, {$wpdb->prefix}livehelp_countries AS jlc, {$wpdb->prefix}livehelp_domains AS jld WHERE jlnac.id_domain = jld.id_domain AND jlnac.code = jlc.code GROUP BY 1 DESC ORDER BY jlnac.id ", ARRAY_A); echo '

LiveHelp » ' . __('Not allowed countries', 'activehelper_livehelp') . ' ' . __('add new', 'activehelper_livehelp') . '

'; if (isset($_GET['register'])) echo '

' . sprintf(__('The %s was successfully registered.', 'activehelper_livehelp'), __('restriction', 'activehelper_livehelp')) . '

'; if (isset($_GET['delete'])) echo '

' . sprintf(__('The %s was deleted permanently.', 'activehelper_livehelp'), __('restriction', 'activehelper_livehelp')) . '

'; if (isset($_GET['miss'])) echo '

' . sprintf(__('The %s was not found.', 'activehelper_livehelp'), __('restriction', 'activehelper_livehelp')) . '

'; echo '
'; if (empty($restrictionsList)) echo ' '; else { $alternate = false; foreach ($restrictionsList as $restriction) { echo ' '; $alternate = !$alternate; } } echo '
' . __('Restriction ID', 'activehelper_livehelp') . ' ' . __('Domain ID', 'activehelper_livehelp') . ' ' . __('Domain name', 'activehelper_livehelp') . ' ' . __('Country', 'activehelper_livehelp') . ' ' . __('Delete', 'activehelper_livehelp') . '
' . __('Restriction ID', 'activehelper_livehelp') . ' ' . __('Domain ID', 'activehelper_livehelp') . ' ' . __('Domain name', 'activehelper_livehelp') . ' ' . __('Country', 'activehelper_livehelp') . ' ' . __('Delete', 'activehelper_livehelp') . '

' . sprintf(__('No %s found.', 'activehelper_livehelp'), __('restrictions', 'activehelper_livehelp')) . '

' . $restriction['restriction_id'] . ' ' . $restriction['domain_id'] . ' ' . $restriction['domain_name'] . ' ' . $restriction['country'] . ' ' . __('Delete', 'activehelper_livehelp') . '
'; } function activeHelper_liveHelp_restrictedCountriesRegisterPost() { global $wpdb, $activeHelper_liveHelp; $_POST['domain'] = !empty($_POST['domain']) ? (int) $_POST['domain'] : ''; $_POST['country'] = !empty($_POST['country']) ? (string) $_POST['country'] : ''; $errors = array(); $activeHelper_liveHelp['errors'] = &$errors; while (isset($_POST['submit'])) { unset($_POST['submit']); // errors ... if (!empty($errors)) break; $wpdb->query(" INSERT INTO {$wpdb->prefix}livehelp_not_allowed_countries ( id_domain, code ) VALUES ( '{$_POST['domain']}', '{$_POST['country']}' ) "); wp_redirect('admin.php?page=' . strtolower('activeHelper_liveHelp_restrictedCountries') . '®ister'); exit; } } function activeHelper_liveHelp_restrictedCountriesRegister() { global $wpdb, $activeHelper_liveHelp; if (!empty($activeHelper_liveHelp['errors'] ) ) $errors = $activeHelper_liveHelp['errors']; $domainsList = $wpdb->get_results(" SELECT id_domain, name FROM {$wpdb->prefix}livehelp_domains ORDER BY id_domain ", ARRAY_A); $countriesList = $wpdb->get_results(" SELECT code, name FROM {$wpdb->prefix}livehelp_countries ORDER BY name ", ARRAY_A); $tabindex = 1; echo '

LiveHelp » ' . __('Restrictions', 'activehelper_livehelp') . ' » ' . __('Add new', 'activehelper_livehelp') . '


' . __('Add new', 'activehelper_livehelp') . '


' . __('Domain', 'activehelper_livehelp') . '


' . __('Country', 'activehelper_livehelp') . '


'; echo '
'; }