Some form theming would make the admin page a lot easier on the eye -- make one row per country and put the radio buttons along that in three cells.

At the same time, the form code could really do with refactoring:

$form['countryban_afghanistan'] = array('#type' => 'radios', '#title' => t('Afghanistan'), '#default_value' => variable_get('countryban_afghanistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_albania'] = array('#type' => 'radios', '#title' => t('Albania'), '#default_value' => variable_get('countryban_albania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
// etc etc etc

200 lines of that!!?!? OMG my eyes!!!! :/

Comments

jboukes’s picture

Assigned: Unassigned » jboukes

This is "partially" fixed as of 1.4 - the brute force method of creating the table is now correct.

mclinn’s picture

Great module! Thank you to the developer, works well for me.

I tweaked the code a little bit to add fieldsets to the admin page, makes it easier to find a country in the list.

In countryban.module starting at line 47 (I'm using v. 6.4) I replaced the "foreach ($countries as $country)" block with the following:

$n = 0;
$cnt = 12;
foreach ($countries as $country) { 
  $country_name = $country['printable_name'];  		
  if ($n % $cnt == 0)  {
  	$fset = $country_name;
    $form[$fset]= array(
	'#title' => $country_name,
     '#type' => 'fieldset',
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
     );   		
  	}
  $variable_name = "countryban_" . $country['iso2']; 
  $form[$fset][$variable_name] = array('#type' => 'radios', '#title' => t($country_name), '#default_value' => variable_get($variable_name, 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
  $n++;
}

PHP tags used here for highlighting, obviously not needed if inserting into existing code. Adjust $cnt to control # of country rows within each fieldset. The title is pretty basic, just the name of the first country in the fieldset, but easy enough to use... kinda like the phone book except the 2d half of the range is the next fieldset title.

I also added a "watchdog" entry to record countries and IP addresses that have been blocked.

One of these days I hope to sit down and do something similar for the block admin page -- I have a zillion blocks, takes forever to scroll through them all. The collapsible fieldsets are a godsend to highly complex pages as far as I am concerned. (If someone has done this for D6 I would love to know about it!)

Thanks again for a great module.