This is my first D7 module.
This module extends the Webform module and allows your users to create new Webform Submissions pre filled with the data from previous Webform Submissions. When your users click the "Prefill new" link from the results, they will be redirected to a brand new Webform Submission in "draft" mode, pre filled with the values from whichever submission they chose, allowing them to change whichever data may differ in the new submission and submit it.This can be specially useful in cases where your users need to fill the same Webform periodically with little to no changes.
Prefill submission has its own permissions, as users may or may not be allowed to create new prefilled forms, but not to edit existing ones, etc.

http://git.drupal.org/sandbox/Vyz/1647506.git

Comments

misc’s picture

Hi, and welcome with your application!

It could take some time to get a review, we have a lot of waiting applications in the queue. Meanwhile please take a look at the coding standards issues: http://ventral.org/pareview/httpgitdrupalorgsandboxvyz1647506git and also you should not work in the master branch but 7.x-1.x.

chintan.vyas’s picture

Here are some suggestions :

  1. Do not work directly on master branch. Create branch/tag, Take a look at creating branches/tags Here
  2. Add README.txt to module directory which would contain detailed description about module and other information if any.
  3. Remove unnecessary Comment //function webform_prefill_submission_permission() from line number 36 in webform_prefill_submission.module. Also remove unnecessary code comment from line 49,66,90,100
  4. Try to add more inline comments within function and also more description for all functions.

Regards,
Chintan Vyas.

chintan.vyas’s picture

Status: Needs review » Needs work
a_thakur’s picture

Hi,

You are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

Normally when a hook is implemented, convention used to comment the implementation is as follows.

/**
 * Implements hook_help().
  */

So please change these accordingly in the .module file. Line # 13, #25, #94.

There are lot of unnecessary comments in the code.
For example in the line #36, #49, #66, #96, #97, #100 in the .module file. Please remove these or make it more appropriate.
According to coding standards. There must be a space between the // and the start of the comment. And the comment should be ended with a full stop.
Example.

// Correct.
//Incorrect

Most of lines in the code are exceeding margin line of 80 characters: http://drupal.org/coding-standards#linelength.
Set your editor to show the magic print margin line of 80 characters. Keeping these short assists code readability among other things.

In the implementation of hook_menu(). Line # 73.

/**
 * Implementation of hook_menu()
 */
function webform_prefill_submission_menu() {

  $items = array();

  $items['node/%webform_menu/submission/%webform_menu_submission/prefill'] = array(
    'title' => 'Prefill new',
    'load arguments' => array(1),
    'page callback' => 'webform_clone',
    'page arguments' => array(1, 3),
    'access callback' => 'webform_prefill_submission_access',
    'access arguments' => array(1, 3, 'prefill'),
    'weight' => 1,
    'file' => 'includes/webform.clone.inc',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

There $items = array() is not required. And It is best to avoid underscores in the menu items. So change to

/**
 * Implement hook_menu().
 */
function webform_prefill_submission_menu() {
  $items['node/%webform_menu/submission/%webform-menu-submission/prefill'] = array(
    'title' => 'Prefill new',
    'load arguments' => array(1),
    'page callback' => 'webform_clone',
    'page arguments' => array(1, 3),
    'access callback' => 'webform_prefill_submission_access',
    'access arguments' => array(1, 3, 'prefill'),
    'weight' => 1,
    'file' => 'includes/webform.clone.inc',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

The files have random new line at the end of the file. 2 in .module, 3 in .info and none in .inc file. Just add a single new line to the end of the file. This causes additional lines in GIT patches.
Will post more review soon. Would be good you could look at these for the time being.

Not really sure whether this applies for you. But you could have a look at this too: http://groups.drupal.org/node/195848

a_thakur’s picture

A bit more.
Line #24 to #36.

/**
 * Implementation of hook_permission
 */
function webform_prefill_submission_permission() {
  return array(
    'prefill from all webform submissions' => array(
      'title' => t('Prefill from all Webform Submissions'),
	  'description' => t('Allows prefilling from any webform submission by any user. Generally an administrative permission.')),
	'prefill from own webform submissions' => array(
      'title' => t('Prefill from own Webform Submissions') // Should be ended with a full stop.
    ) // There should be a comma here.
  );
}//function webform_prefill_submission_permission()

Change to

/**
 * Implement hook_permission().
 */
function webform_prefill_submission_permission() {
  return array(
    'prefill from all webform submissions' => array(
      'title' => t('Prefill from all Webform Submissions'),
      'description' => t('Allows prefilling from any webform submission by any user. Generally an administrative permission.')),
    'prefill from own webform submissions' => array('title' => t('Prefill from own Webform Submissions.')),
  );
}
a_thakur’s picture

Hi,
The link http://git.drupal.org/sandbox/Vyz/1647506.git in the Issue summary does not work.

In the webform.clone.inc

function webform_clone($node, $submission) {
  unset($submission->sid);
  $submission->submitted=time(); // There should be a space here.
  $submission->is_draft=1; // There should be a space here.
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  webform_submission_insert($node, $submission);
  $path='node/' . $submission->nid; // There should be a space here.
  drupal_goto($path, array(), $http_response_code = 301);
 }

Change to

function webform_clone($node, $submission) {
  unset($submission->sid);
  $submission->submitted = time();
  $submission->is_draft = 1;
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  webform_submission_insert($node, $submission);
  $path = 'node/' . $submission->nid;
  drupal_goto($path, array(), $http_response_code = 301);
}
misc’s picture

@a_thakur please review older applications, it is better to review the oldest ones in the queue to get a better workflow in the issue queue.

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.