diff --git a/webform.module b/webform.module
index 428de41..e50fba2 100644
--- a/webform.module
+++ b/webform.module
@@ -1741,6 +1741,64 @@ function webform_form_submit($form, &$form_state) {
 }
 
 /**
+ * Implements a function to check if user has access to a webform or not.
+ */
+function webform_check_access($node) {
+  global $user;
+  $enabled        = TRUE;
+  $page           = node_is_page($node);
+  $allowed_roles  = array();
+
+  // Check if webform is enabled or not.
+  if ($node->webform['status'] == 0) {
+    $enabled = FALSE;
+  }
+  else {
+    // Check if the user's role can submit this webform.
+    if (variable_get('webform_submission_access_control', 1)) {
+      foreach ($node->webform['roles'] as $rid) {
+        $allowed_roles[$rid] = isset($user->roles[$rid]) ? TRUE : FALSE;
+      }
+      if (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
+        $enabled = FALSE;
+      }
+    }
+  }
+
+  // Check if this page is cached or not.
+  $cached = $user->uid == 0 && (variable_get('cache', 0) || drupal_page_is_cacheable() === FALSE);
+
+  // Check if the user can add another submission.
+  if ($enabled && $node->webform['submit_limit'] != -1) { // -1: Submissions are never throttled.
+    module_load_include('inc', 'webform', 'includes/webform.submissions');
+    // Disable the form if the limit is exceeded and page cache is not active.
+    if (webform_submission_user_limit_check($node) && !$cached) {
+      $enabled = FALSE;
+    }
+  }
+
+  // Check if the user can add another submission if there is a limit on total
+  // submissions.
+  if ($enabled && $node->webform['total_submit_limit'] != -1) { // -1: Submissions are never throttled.
+    module_load_include('inc', 'webform', 'includes/webform.submissions');
+    // Disable the form if the limit is exceeded and page cache is not active.
+    if (webform_submission_total_limit_check($node) && !$cached) {
+      $enabled = FALSE;
+    }
+  }
+
+  // Check if this user has a draft for this webform.
+  if (($node->webform['allow_draft'] || $node->webform['auto_save']) && $user->uid != 0) {
+    // Draft found - display form with draft data for further editing.
+    if (_webform_fetch_draft_sid($node->nid, $user->uid)) {
+      $enabled = TRUE;
+    }
+  }
+
+  return $enabled;
+}
+
+/**
  * Implements hook_node_view().
  */
 function webform_node_view($node, $view_mode) {
