--- /Applications/MAMP/htdocs/drupal5/sites/all/webform_own_results/webform_own_results.module +++ webform_own_results.module @@ -1,20 +1,22 @@ -nid && $node->type == 'webform' && ($node->uid == $user->uid) && !user_access('access webform results') ) { - $items[]= array( - 'path' => 'node/'. $node->nid .'/ownresults', - 'title' => t('See Results'), - 'callback' => 'webform_own_results_results', - //'access' => user_access('access results from own webform'), - 'access' => user_access('access results from own webforms'), - 'type' => MENU_LOCAL_TASK, - 'weight' => 2); - $items[]= array( - 'path' => 'node/'. $node->nid .'/ownresults/submissions', 'title' => t('submissions'), - 'callback' => 'webform_own_results_results', - 'access' => user_access('access results from own webforms'), - 'weight' => 4, - 'type' => MENU_DEFAULT_LOCAL_TASK); - $items[]= array( - 'path' => 'node/'. $node->nid .'/ownresults/analysis', - 'title' => t('analysis'), - 'callback' => 'webform_own_results_results', - 'access' => user_access('access results from own webforms'), - 'weight' => 5, - 'type' => MENU_LOCAL_TASK); - $items[]= array( - 'path' => 'node/'. $node->nid .'/ownresults/table', - 'title' => t('table'), - 'callback' => 'webform_own_results_results', - 'access' => user_access('access results from own webforms'), - 'weight' => 6, - 'type' => MENU_LOCAL_TASK); - $items[]= array( - 'path' => 'node/'. $node->nid .'/ownresults/download', - 'title' => t('download'), - 'callback' => 'webform_own_results_results', - 'access' => user_access('access results from own webforms'), - 'weight' => 7, - 'type' => MENU_LOCAL_TASK); - + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults', + 'title' => t('See Results'), + 'callback' => 'webform_own_results_results', + 'access' => user_access('access results from own webforms'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2, + ); + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults/submissions', 'title' => t('submissions'), + 'callback' => 'webform_own_results_results', + 'access' => user_access('access results from own webforms'), + 'weight' => 4, + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults/analysis', + 'title' => t('analysis'), + 'callback' => 'webform_own_results_results', + 'access' => user_access('access results from own webforms'), + 'weight' => 5, + 'type' => MENU_LOCAL_TASK, + ); + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults/table', + 'title' => t('table'), + 'callback' => 'webform_own_results_results', + 'access' => user_access('access results from own webforms'), + 'weight' => 6, + 'type' => MENU_LOCAL_TASK, + ); + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults/download', + 'title' => t('download'), + 'callback' => 'webform_own_results_results', + 'access' => user_access('access results from own webforms'), + 'weight' => 7, + 'type' => MENU_LOCAL_TASK, + ); + $sid = (arg(2) == 'ownresults' && arg(3) == 'submission' && is_numeric(arg(4))) ? arg(4) : NULL; + if (isset($sid)) { + include_once(drupal_get_path('module', 'webform') ."/webform_submissions.inc"); + $submission = webform_get_submission($node->nid, $sid); + $items[] = array( + 'path' => 'node/'. $node->nid .'/ownresults/submission/'. $sid, + 'title' => t('Webform submission'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE), + 'access' => user_access('access results from own webforms'), + 'type' => MENU_CALLBACK, + ); + } } } } @@ -72,19 +90,19 @@ * function webform_results() is an allocator function that builds the page * under the 'Results' sub menu The function uses the URL tail to nominate * internal content. - + * * THIS VERSION: * just a copy of the original, but changed the if arg(2) test to look for our path */ function webform_own_results_results() { //drupal_set_message("welcome to webform_own_results_results"); - include_once (drupal_get_path('module', 'webform')."/webform.inc"); - include_once (drupal_get_path('module', 'webform')."/webform_report.inc"); + include_once(drupal_get_path('module', 'webform') ."/webform_submissions.inc"); + include_once(drupal_get_path('module', 'webform') ."/webform_report.inc"); - $nid= arg(1); - $node= node_load(array('nid' => $nid)); + $nid = arg(1); + $node = node_load(array('nid' => $nid)); - $title= $node->title; + $title = $node->title; drupal_set_title($title); if (arg(2) == 'ownresults') { @@ -92,25 +110,29 @@ switch (arg(3)) { case 'analysis' : - $content= _webform_results_analysis($nid); + $content = webform_results_analysis($node); break; case 'clear' : - $content= drupal_get_form('_webform_results_clear', $nid); + $content = drupal_get_form('_webform_results_clear', $nid); break; case 'delete' : $sid= arg(4); - $content= drupal_get_form('_webform_submission_delete', $nid, $sid); + $content = drupal_get_form('_webform_submission_delete', $nid, $sid); break; case 'table' : - $content= _webform_results_table($nid); + $content = webform_results_table($node); + // Change the submission paths to ones with different access. + $content = str_replace('/submission/', '/ownresults/submission/', $content); break; case 'download' : - $content= _webform_results_download($nid); + $content = webform_results_download($node); break; case 'submissions' : default : //drupal_set_message("looking to show submissions"); - $content= _webform_results_submissions($nid); + $content = webform_results_submissions($node); + // Change the submission paths to ones with different access. + $content = str_replace('/submission/', '/ownresults/submission/', $content); break; }