--- time_sheet/time_sheet.module	2011-03-23 17:21:47.000000000 -0700
+++ time_sheet/time_sheet.module	2011-03-23 17:05:29.000000000 -0700
@@ -15,10 +15,10 @@ function time_sheet_init() {
  */
 function time_sheet_perm() {
   if (module_exists('casetracker')) {
-    return array('administer time sheet', 'view time sheet entries', 'enter time on time sheet for casetracker cases');
+    return array('administer time sheet', 'view all time sheet entries', 'view own time sheet entries', 'enter time on time sheet for casetracker cases');
   }
   else {
-    return array('administer time sheet', 'view time sheet entries');
+    return array('administer time sheet', 'view all time sheet entries', 'view own time sheet entries');
   }
 }
 
@@ -35,7 +35,8 @@ function time_sheet_menu() {
     'description' => 'My Time Sheet',
     'page callback' => 'time_sheet_page',
     'page arguments' => array(1),
-    'access arguments' => array('view time sheet entries'),
+    'access callback' => 'time_sheet_view_access',
+    'access arguments' => array(1),
     'type' => MENU_LOCAL_TASK,
   );
   $items['time_sheet/add_time'] = array(
@@ -55,6 +56,22 @@ function time_sheet_menu() {
   return $items;
 }
 
+function time_sheet_view_access($account) {
+  // The user is not blocked and logged in at least once.
+  if (!$account->access || !$account->status) {
+    return false;
+  }
+  if ($account && $account->uid) {
+    if (user_access('view all time sheet entries') || user_access('administer users')) {
+      return true;
+    }
+    if (user_access('view own time sheet entries') && $GLOBALS['user']->uid == $account->uid) {
+      return true;
+    }
+  }
+  return false;
+}
+
 /**
  * Implementation of hook_form().
  */
