--- url_access.module	Thu Oct 02 10:29:12 2008
+++ url_access.module.new	Thu Oct 02 10:30:02 2008
@@ -91,7 +91,8 @@
  * Implementation of hook_form_alter
  */
 function url_access_form_alter($form_id, &$form) {
-  // We're only modifying node forms, if the type field isn't set we don't need
+  // We're only modifying node forms and content-type form, 
+  //if the type field isn't set we don't need
   // to bother; otherwise, store it for later retrieval.
   if (isset($form['type'])) {
     $type = $form['type']['#value'];
@@ -99,25 +100,55 @@
   elseif (isset($form['orig_type'])) {
     $type = $form['orig_type']['#value'];
   }
+  elseif (isset($form['identity']['type'])) {
+  	 $type = $form['#node_type']->type;
+  }
   else {
     return;
   }
   
   switch($form_id) {
+  	//Node form
     case $type . '_node_form':
+    	switch(variable_get('url_access_visibility_'.$type, 'user_choice'))
+    	{
+    		case 'hide_off':
+    			$hide = true;	$value = false;	break;
+    		case 'hide_on' :
+    			$hide = true;	$value = true;	break;
+    		case 'user_choice':
+    		default:
+    			$hide = false;	$value = $form['#node']->url_access;	break;
+    	}		
+    	
       $form['url_access_set'] = array(
         '#type' => 'fieldset',
         '#title' => t('URL Access Restrictions'),
         '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
+        '#collapsed' => true,
       );
+      
       $form['url_access_set']['url_access'] = array(
         '#type' => 'checkbox',
         '#title' => t('Require unique URL for access'),
         '#description' => t('If enabled, only administrators and those with the correct URL
           will be able to view this node.'),
-        '#default_value' => $form['#node']->url_access,
+        '#default_value' => $value,
+        '#access' => !$hide,
       );
+      if($hide && $form['#node']->url_access){
+      	$form['url_access_set']['url_access_status'] = array(
+          '#value' => t('This node is currently <b>protected</b>.').' '.($value?'':t('It will become <b>public</b> in agreement with the new setting for this content-type when this node will be saved.')),
+          '#prefix' => '<p>',
+          '#suffix' => '</p>',
+        );
+      }elseif($hide){
+      	$form['url_access_set']['url_access_status'] = array(
+          '#value' => t('This node is currently <b>public</b>.').' '.($value?t('It will become <b>protected</b> in agreement with the new setting for this content-type when this node will be saved.'):''),
+          '#prefix' => '<p>',
+          '#suffix' => '</p>',
+        );
+      }
       if ($form['#node']->url_access) {
         $url = 'protected/' . $form['#node']->url_access;
         $form['url_access_set']['url_access_path'] = array(
@@ -129,8 +160,29 @@
         );
       }
       break;
+    //Content-type form
+	case 'node_type_form':
+		$form['url_access_set'] = array(
+	      '#type' => 'fieldset',
+	      '#title' => t('URL Access'),
+	      '#collapsible' => TRUE,
+	      '#collapsed' => true,
+	    );
+	    $form['url_access_set']['url_access_visibility'] = array(
+	      '#type' => 'radios',
+	      '#title' => t('Visibility'),
+	      '#default_value' => variable_get('url_access_visibility_'.$type, 'user_choice'),
+	      '#options' => array(
+	        'hide_off' => t('Always <b>public</b> for this kind of content-type'),
+	        'hide_on' => t('Always <b>private</b> for this kind of content-type'),
+	        'user_choice' => t('Let the author decide for each node'), 
+	      ),
+	      '#description' => t('This option sets the visibility of the Url Access block for this content type.<br /><b>Warning:</b> If you change this setting on an existing content-type, you must re-save any of your nodes to take this parameter into account.'),
+	    );
+	    break;
   }
 }
+
 
 /**
  * Return a UUID generated by the database.
