/[drupal]/contributions/modules/webform_own_results/webform_own_results.module
ViewVC logotype

Contents of /contributions/modules/webform_own_results/webform_own_results.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Oct 3 17:32:44 2007 UTC (2 years, 1 month ago) by suydam
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Changes since 1.1: +12 -3 lines
File MIME type: text/x-php
Removed debugging messages.  Fixed .info file  Commented .module file.
1 <?php
2 // $Id$
3
4 /**
5 *
6 * This module add "download results from own webforms" to the already outstanding webforms module
7 *
8 **/
9
10 function webform_own_results_perm() {
11 return array("access results from own webforms");
12 }
13
14 /* re-create the Results menu, but have it point here instead so we can take over access control */
15 /* only display *our* menu when the real one doesnt' display */
16 /* for all menu items, call back to our version of the webform_results function... a total copy of
17 the real one, but with our access control hacked in */
18 function webform_own_results_menu($may_cache) {
19 global $user;
20 $items = array();
21 if ( !$may_cache ) {
22 // is this a node, is it a webform and do i own it?
23 if (arg(0) == 'node' && is_numeric(arg(1))) {
24 $node = node_load(arg(1));
25 if ($node->nid && $node->type == 'webform' && ($node->uid == $user->uid) && !user_access('access webform results') ) {
26 $items[]= array(
27 'path' => 'node/'. $node->nid .'/ownresults',
28 'title' => t('See Results'),
29 'callback' => 'webform_own_results_results',
30 //'access' => user_access('access results from own webform'),
31 'access' => user_access('access results from own webforms'),
32 'type' => MENU_LOCAL_TASK,
33 'weight' => 2);
34 $items[]= array(
35 'path' => 'node/'. $node->nid .'/ownresults/submissions', 'title' => t('submissions'),
36 'callback' => 'webform_own_results_results',
37 'access' => user_access('access results from own webforms'),
38 'weight' => 4,
39 'type' => MENU_DEFAULT_LOCAL_TASK);
40 $items[]= array(
41 'path' => 'node/'. $node->nid .'/ownresults/analysis',
42 'title' => t('analysis'),
43 'callback' => 'webform_own_results_results',
44 'access' => user_access('access results from own webforms'),
45 'weight' => 5,
46 'type' => MENU_LOCAL_TASK);
47 $items[]= array(
48 'path' => 'node/'. $node->nid .'/ownresults/table',
49 'title' => t('table'),
50 'callback' => 'webform_own_results_results',
51 'access' => user_access('access results from own webforms'),
52 'weight' => 6,
53 'type' => MENU_LOCAL_TASK);
54 $items[]= array(
55 'path' => 'node/'. $node->nid .'/ownresults/download',
56 'title' => t('download'),
57 'callback' => 'webform_own_results_results',
58 'access' => user_access('access results from own webforms'),
59 'weight' => 7,
60 'type' => MENU_LOCAL_TASK);
61
62 }
63 }
64 }
65 return $items;
66 }
67
68
69
70 /**
71 * ORIGINAL VERSION:
72 * function webform_results() is an allocator function that builds the page
73 * under the 'Results' sub menu The function uses the URL tail to nominate
74 * internal content.
75
76 * THIS VERSION:
77 * just a copy of the original, but changed the if arg(2) test to look for our path
78 */
79 function webform_own_results_results() {
80 //drupal_set_message("welcome to webform_own_results_results");
81 include_once (drupal_get_path('module', 'webform')."/webform.inc");
82 include_once (drupal_get_path('module', 'webform')."/webform_report.inc");
83
84 $nid= arg(1);
85 $node= node_load(array('nid' => $nid));
86
87 $title= $node->title;
88 drupal_set_title($title);
89
90 if (arg(2) == 'ownresults') {
91 //drupal_set_message("Looking for ownresults");
92
93 switch (arg(3)) {
94 case 'analysis' :
95 $content= _webform_results_analysis($nid);
96 break;
97 case 'clear' :
98 $content= drupal_get_form('_webform_results_clear', $nid);
99 break;
100 case 'delete' :
101 $sid= arg(4);
102 $content= drupal_get_form('_webform_submission_delete', $nid, $sid);
103 break;
104 case 'table' :
105 $content= _webform_results_table($nid);
106 break;
107 case 'download' :
108 $content= _webform_results_download($nid);
109 break;
110 case 'submissions' :
111 default :
112 //drupal_set_message("looking to show submissions");
113 $content= _webform_results_submissions($nid);
114 break;
115 }
116
117 return $content;
118 }
119 }

  ViewVC Help
Powered by ViewVC 1.1.2