? region_visibility-459926.patch
Index: region_visibility.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/region_visibility/region_visibility.install,v
retrieving revision 1.1
diff -u -p -r1.1 region_visibility.install
--- region_visibility.install	11 May 2009 17:48:24 -0000	1.1
+++ region_visibility.install	11 May 2009 23:48:15 -0000
@@ -51,6 +51,10 @@ function region_visibility_schema() {
         'not null' => TRUE,
         'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.',
       ),
+      'roles' => array(
+        'type' => 'text',
+        'not null' => FALSE,
+      ),
     ),
     'primary key' => array('rid'),
     'unique keys' => array(
@@ -66,4 +70,16 @@ function region_visibility_schema() {
 function region_visibility_uninstall() {
   drupal_uninstall_schema('region_visibility');
   cache_clear_all('region_visibility:*', 'cache', TRUE);
+}
+
+/**
+ * Update 1
+ * Adding roles field
+ */
+function region_visibility_update_1() {
+  $ret = array();
+  
+  db_add_field($ret, 'region_visibility', 'roles', array('type' => 'text', 'not null' => FALSE));
+  
+  return $ret;
 }
\ No newline at end of file
Index: region_visibility.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/region_visibility/region_visibility.module,v
retrieving revision 1.1
diff -u -p -r1.1 region_visibility.module
--- region_visibility.module	11 May 2009 17:48:24 -0000	1.1
+++ region_visibility.module	11 May 2009 23:48:15 -0000
@@ -144,6 +144,21 @@ function region_visibility_theme_form(&$
 
     $form['regions'][$region]['region'] = array('#type' => 'value', '#value' => $region);
     $form['regions'][$region]['theme_key'] = array('#type' => 'value', '#value' => $theme_key);
+    
+    // Role-based visibility settings
+    $default_role_options = unserialize($records[$region]['roles']);
+    if (!is_array($default_role_options)) {
+      $default_role_options = array();
+    }
+    $role_options = user_roles();
+
+    $form['regions'][$region]['roles'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Show region for specific roles'),
+      '#default_value' => $default_role_options,
+      '#options' => $role_options,
+      '#description' => t('Show this region only for the selected role(s). If you select no roles, the region will be visible to all users.'),
+    );
 
     // Set up options and description.
     $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'));
@@ -182,6 +197,7 @@ function region_visibility_theme_form_su
   foreach($regions as $region) {
     $theme_key = $region['theme_key'];
     $region['pages'] = trim($region['pages']);
+    $region['roles'] = serialize(array_filter($region['roles']));
     region_visibility_record_save($region);
   }
   cache_clear_all('region_visibility:'. $theme_key, 'cache', TRUE);
