--- ./profile_blog_info.module	2008-08-04 06:24:03.000000000 -0400
+++ ./profile_blog_info-NEW.module	2009-05-13 19:32:37.000000000 -0400
@@ -24,6 +24,8 @@ function profile_blog_info_menu() {
     'file' => 'profile_blog_info.forms.inc',
   );
   
+  $category = variable_get('profile_blog_info_profile_category', '');
+  
   return $items;
 }
 
@@ -47,7 +49,7 @@ function profile_blog_info_user($op, &$e
     case 'validate':
       return profile_blog_info_validate_profile($edit, $category);
     case 'categories':
-      return profile_blog_info_categories();
+    	return profile_blog_info_categories();
     case 'delete':
       $f = db_fetch_array(db_query('SELECT fid FROM {profile_blog_info} WHERE uid = %d', $user->uid));
       profile_blog_info_save_feed($f);
@@ -115,12 +117,30 @@ function profile_blog_info_categories() 
       'name' => $category,
       'title' => $category,
       'weight' => 3,
+      'access callback' => 'profile_blog_info_category_access',
+      'access arguments' => array(1, 'access blog account')
     );
   }
   return $data;
 }
 
+
+/**
+ * Menu item access callback - check if a user has access to a profile category.
+ */
+function profile_blog_info_category_access($account, $category) {
+  if (user_access('access blog account') && $account->uid > 0) {
+    return TRUE;
+  }
+  else {
+    return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE category = '%s' AND visibility <> %d", $category, PROFILE_HIDDEN));
+  }
+}
+
 function profile_blog_info_view_profile(&$user) {
+
+	if ( user_access( 'access blog account') )
+	{
   $category = variable_get('profile_blog_info_profile_category', '');
   if (!empty($user->profile_blog_info_blog_url)&& !empty($user->profile_blog_info_title)) {
     $user->content['summary']['profile_blog_info_title'] = array(
@@ -128,6 +148,7 @@ function profile_blog_info_view_profile(
       '#value' => l($user->profile_blog_info_title, $user->profile_blog_info_blog_url),
     );
   }
+  }
 }
 
 function profile_blog_info_validate_profile($edit, $category) {
@@ -149,6 +170,7 @@ function profile_blog_info_validate_prof
 }
 
 function profile_blog_info_save_profile($edit, $user, $category) {
+
   if ($fid = db_result(db_query('SELECT fid FROM {profile_blog_info} WHERE uid = %d', $user->uid))) {
     $feed = aggregator_feed_load($fid);
   }
@@ -208,4 +230,12 @@ function profile_blog_info_save_feed($ed
     }
   }
   return $edit['fid'];
-}
\ No newline at end of file
+}
+
+
+/**
+ * Implementation of hook_perm()
+ */
+function profile_blog_info_perm() {
+	return array('access blog account');
+}
