Index: og_read_only.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_read_only/og_read_only.module,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 og_read_only.module
--- og_read_only.module	24 Nov 2008 21:29:06 -0000	1.4.2.1
+++ og_read_only.module	1 Dec 2008 23:53:09 -0000
@@ -25,6 +25,14 @@ function og_read_only_form_alter(&$form,
       }
     }
     
+    // unset Read only content types set by site administrator
+    $master_types = og_read_only_master_types($node->type);
+    foreach(array_keys($options) as $og_type) {
+      if(in_array($og_type, $master_types)) {
+        unset($options[$og_type]);
+      }
+    }
+    
     if (count($options))
     {
       $default = array();
@@ -43,6 +51,10 @@ function og_read_only_form_alter(&$form,
       if (module_exists('og_access')) {
           $form['og_read_only_types']['#description'] .= ' '. t('Wiki group types can\'t be set to read only.');
         }
+      
+      if(count($master_types)) {
+        $form['og_read_only_types']['#description'] .= '<br/>'. t('Read only types set by the site administrator: %mastertypes', array('%mastertypes' => implode(', ', $master_types)));
+      }
     }
   }
   
@@ -116,9 +128,12 @@ function og_read_only_nodeapi(&$node, $o
       }
       break;
     case 'load':
-      $result = db_query('SELECT * FROM {og_read_only} WHERE nid=%d', $node->nid);
-      $read_only = db_fetch_array($result);
-      return array('og_read_only_types' => explode(',', $read_only['types']));
+      if (og_is_group_type(($node->type))) {
+        $result = db_query('SELECT * FROM {og_read_only} WHERE nid=%d', $node->nid);
+        $read_only = db_fetch_array($result);
+        $read_only_types = array_merge(explode(',',$read_only['types']), og_read_only_master_types($node->type));
+        return array('og_read_only_types' => $read_only_types);
+      }
       break;
     case 'delete':
       db_query('DELETE FROM {og_read_only} WHERE nid=%d', $node->nid);
@@ -150,4 +165,57 @@ function og_read_only_is_allowed_type($t
   
   $group = node_load($group);
   return empty($group->og_read_only_types) || !in_array($type, $group->og_read_only_types) || og_is_group_admin($group) || og_is_wiki_type($type);
+}
+
+/**
+ * hook_form_FORM_ID_alter
+ *
+ * Save master read only information
+ */
+
+function og_read_only_form_node_type_form_alter(&$form, &$form_state) {
+  $options = array();
+  $types = node_get_types();
+  foreach (og_get_types('group_post') as $og_type) {
+    if (!og_is_wiki_type($og_type)) {
+      $options[$og_type] = $types[$og_type]->name;
+    }
+  }
+ 
+  $defaults = og_read_only_master_types($form['#node_type']->type);
+  
+  $form['og']['og_read_only_master_types'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Read-only content types (for Group nodes)'),
+    '#default_value' => $defaults,
+    '#options' => $options,
+    '#description' => t('Here you can select content types that are read-only for this type of group. Read-only types can\'t be posted by simple group members but still can be posted by group managers and users with %permission permission. These are master settings for this group type. Any content types selected here will not appear as options on group node forms.', array('%permission' => t('administer nodes'))),
+  );
+  $form['#submit'][] = 'og_read_only_form_node_type_submit';
+  
+  if (module_exists('og_access')) {
+    $form['og_read_only_master_types']['#description'] .= ' '. t('Wiki group types can\'t be set to read only.');
+  }
+}
+
+/**
+ * node_type submission function. Saves any master read-only information
+ */
+
+function og_read_only_form_node_type_submit($form, &$form_state) {
+  $save[$form_state['values']['type']] = array_filter($form_state['values']['og_read_only_master_types']);
+  variable_set('og_read_only_master_types', $save);
+}
+
+/**
+ * Gets the content types the site administrator has flagged as read only
+ */
+
+function og_read_only_master_types($type) {
+  $all_master_types = variable_get('og_read_only_master_types', array());
+  if(isset($all_master_types[$type])) {
+    return $all_master_types[$type];
+  } else {
+    return array();
+  }
 }
\ No newline at end of file
