Index: menu_stp.module
===================================================================
--- menu_stp.module	(revision 168)
+++ menu_stp.module	(working copy)
@@ -42,6 +42,21 @@
         '#options' => user_roles(1),
         '#default_value' => _menu_stp_roles($form['mid']['#value'])
       );
+	  if (module_exists('acl')) {
+	    $form['menu_stp']['acl'] = array(
+	      '#type' => 'fieldset',
+	      '#title' => t('User access control lists'),
+	      '#description' => t('These settings allow you to grant access to specific users.'),
+	      '#collapsible' => TRUE,
+	      '#tree' => TRUE,
+	    );
+		$acl_id = acl_get_id_by_name('menu_stp', $form['mid']['#value']);
+		if (!$acl_id) { // create one
+			$acl_id = acl_create_new_acl('menu_stp', $form['mid']['#value']);
+		}
+		$form['menu_stp']['acl']['access'] = acl_edit_form($acl_id, 'Grant menu access');
+		$form['menu_stp']['acl']['access']['#collapsed'] = !isset($_POST['menu_stp']['acl']['access']['add_button']) && !isset($_POST['menu_stp']['acl']['access']['delete_button']);
+      }
 
       // TODO: more options for other auth-methods like ACL and organic groups
       // probably only links to forms here, so this form doesn't get too big
@@ -118,11 +133,20 @@
  * @returns array with the menu-ids as keys, values: 1 for subtree-roots, 2 for editable items below
  */
 function _menu_stp_editable_mids_by_roles(&$rids) {
+  global $user;
   $mids = array();
   $res = db_query("SELECT DISTINCT mid FROM {menu_stp_roles} WHERE rid IN (".implode(',',$rids).");");
   while($row = db_fetch_array($res)) {
     $mids["{$row['mid']}"] = 1; // for the roots of the editable parts
   }
+  if (module_exists('acl')) {
+  	$result = db_query("SELECT acl_id, name FROM {acl} WHERE module = 'menu_stp'");
+  	while ($acl = db_fetch_object($result)) {
+  	  if (db_result(db_query("SELECT uid FROM {acl_user} aclu WHERE uid={$user->uid} AND acl_id = %d", $acl->acl_id))) {
+	    $mids[$acl->name] = 1;
+  	  }
+  	}
+  }
   // and now start adding the children
   $new_mids = array_keys($mids);
   while ($new_mids) {
@@ -274,6 +298,9 @@
       }
       // else no change in permission for this role
     }
+    if (module_exists('acl') && isset($form['acl']['access'])) {
+      acl_save_form($form['acl']['access']);
+    }
     break;
   }
 }
