Summary

Report builder defines a custom view display, and takes those view results as a data input. It allows users to create a table or chart whose data points are the result of that view. The user can then alter the exposed filters for each individual data point. This allows users to control dynamic reports without knowing any SQL and without needing to have the Views UI exposed. For example, a simple view could be set up that aggregates the total number of nodes on the site, with an exposed filter for creation date. A user could easily put together a 4 column table showing the number of nodes on the site over the last 4 months by changing the exposed filter's date for each of the table's four columns. Similarly, that same view could be set up with a sticky / not sticky exposed filter. A two-bar bar chart could be created with one bar showing the total number of sticky nodes, and the other showing the un-sticky node total.

While sometimes these reports could be generated more efficiently with a single query, Report Builder provides for the flexibility of filtering the data points in a multitude of ways that isn't always possible in a single query. And it exposes the functionality to more novice users than those ready to get into the Views UI.

Integrates with the chart, ctools, and views modules.

Project Page

http://drupal.org/sandbox/mkadin/1447772

PAReview.sh

Link

Git Command

git clone --branch master mkadin@git.drupal.org:sandbox/mkadin/1447772.git

Drupal Version

Drupal 7

Reviews of Other Projects

http://drupal.org/node/1403766#comment-5636562
http://drupal.org/node/1449530#comment-5636526
http://drupal.org/node/1445918#comment-5636500

Reviews of Other Projects Round II

http://drupal.org/node/1268340#comment-5641304
http://drupal.org/node/1449530#comment-5641216
http://drupal.org/node/1254718#comment-5641190

But wait...there's more!

http://drupal.org/node/1452328#comment-5662004
http://drupal.org/node/1457206#comment-5655404
http://drupal.org/node/1454106#comment-5662046

CommentFileSizeAuthor
#12 drupalcs-result.txt1.73 KBklausi

Comments

mkadin’s picture

Just some notes as I clean up this project:
1) I've finished the PAReview.sh review process and committed all of the necessary style changes.
2) I've added a sample report builder default view as an example of what views incorporated into report builder could look like. I've also added a bit to the install hook to generate 2 example reports so new users can get the idea.

mkadin’s picture

Issue summary: View changes

Made some formatting changes and added link to PAReview.sh for this project.

mkadin’s picture

Issue tags: +PAreview: review bonus
klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

manual review:

  • project page is a bit short, see http://drupal.org/node/997024
  • "$report['data'] = unserialize($report['data']);": you should define the db field as 'serialize' in hook_schema(), then you don't need to do that yourself.
  • "'#title' => t($report['title']),": title is not sanitized here, what if I enter a javascript snippet es title? Is this XSS vulnerable then?
  • "$title = $form_state['input']['title'];": why don't you access $form_state['values'] here?
  • report_builder_get_title(): this function is not used anywhere? Also it does not do really something useful?
  • "ctools_modal_text_button('Change Filters'..." all user facing text should run through t() for translation, or does ctools handle that for you?
  • "'#title' => 'Report title',": same here, use t().
  • "<em>@title</em>": use the "%" placeholder, it will generate em tags for you.
  • "'<h2 id="report-builder-title">' . $report['title'] . '</h2>'": again, the title should be sanitized here.
  • "'#value' => 'Update',": again, use t() here. Please check all your strings.
  • "drupal_deliver_html_page(render($page));": why do you need that? Shouldn't be returning the $page renderable array be enough, and Drupal takes care of the rendering itself?

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

mkadin’s picture

Thanks, I've made the requested changes.

A note: as best I can tell, using 'serialize' => TRUE in hook_schema serializes the data when its stored, but it does not unserialize it when the data is read back out. So I have included the change in hook_schema, and removed the serializing in report_builder_save(). But I left in unserialize() in report_builder_load despite your suggestion.

mkadin’s picture

Issue summary: View changes

added Reviews of Other Projects section for priority reviewing.

mkadin’s picture

Status: Needs work » Needs review
Issue tags: +PAreview: review bonus
valeriod’s picture

Looking at the previous issues

  • "$title = $form_state['input']['title'];": why don't you access $form_state['values'] here?

    the difference between the two is that $form_state['input'] is the raw user input and it shouldn't be used unless you understand possible security implications. Almost all the FAPI functions use $form_state['values'] for their processing. If $form_state['values'] doesn't work for you for whatever reason I think it's OK to use $form_state['input']
  • report_builder_get_title() is a callback for the report view page. The returned value $report['title'] should be sanitized because it goes directly into the page, I think.
mkadin’s picture

Status: Needs review » Needs work

Thanks for the clarifications @valeriod. I read up on the difference between ['input'] and ['values'] and the security implications. I'll look into these and fix them up where needed before undergoing another review. Don't want to waste the bonus when I know there could be security problems.

mkadin’s picture

Status: Needs work » Needs review

Switched over to values in most cases and added a few more check_plains in various places where user-entered data is outputted. Definitely more secure now.

mkadin’s picture

Status: Needs review » Needs work

Looks like 'values' unexpectedly caused some problems. Changing status.

valeriod’s picture

mkadin, it can happen, I have seen it before because FAPI processes these values. If using values doesn't work for you then use input, make sure that there are no security implications and add a note explaining why it has to be so.

mkadin’s picture

Status: Needs work » Needs review

Switched back over to values for all form elements with one exception where it caused problems. Noted in the comments that I had to use input there. A few other security fixes included (check_plain() on table headers). Ready for review.

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus
StatusFileSize
new1.73 KB

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

manual review:

  • "check_plain(t('Report has been saved'))": you don't need check_plain() here as no user provided input is involved.
  • "check_plain(t('Report %title has been deleted.', array('%title' => check_plain($report['title']))))": you don't need the 2 check_plain() here as the "%" placeholder will already sanitize the title for you. Double escaping is bad. Also in other places.
  • report_builder_list_reports(): do not concatenate translated strings, always use placeholders in one string, i.e. for links.
  • "'info' => check_plain('Report Builder Chart: ' . $report->title),": all user facing text should run through t() for translation, and you should use a placeholder for the title.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

mkadin’s picture

Status: Needs work » Needs review

Thanks for the suggestions. I've gone through the code an implemented them, being careful to use the placeholder functionality of t('') and checking for double escaping. I believe I've got them all.

mkadin’s picture

Issue summary: View changes

Added more reviews to the Reviews of other projects section.

mkadin’s picture

Issue tags: +PAreview: review bonus

Bing! Bonus!

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  • "'#default_value' => (($new) ? 500 : check_plain($report['data']['chart_data']['width'])),": The form API sanitizes #default_value for you, so no need for check_plain() here. See http://drupal.org/node/28984

Otherwise this looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

mkadin’s picture

Thanks @klausi, I've searched through the code and removed a few instances of the check_plain issue you describe. Thanks to you and everyone else for all your help in reviewing this module!

patrickd’s picture

Status: Reviewed & tested by the community » Fixed

So, let's get picky ;)

  1. .install, _schema(): Make sure all descriptions begin with a capital letter and end with a dot.
  2. drupal_write_record('report_builder', &$report); Oo! Call-time pass-by-reference has been deprecated! Be careful with copy and paste.
  3. while ($i < sizeof($values)) {don't do such, as it's a while loop it'll re-execute it's condition on every loop, so the sizeof will be executed over and over again
  4. The <> operator is normally only used in sql queries, it's unusual to see it in code, maybe you replace it with !=?
  5. Your functions are pretty well commented, what I'm missing are more inline-comment, you could definitely use more of them ;)

Beside that I had several warnings and notices during testing I couldn't really reproduce (tested on a clean local install), so consider creating an early alpha release first and do some more intensive testing with different configuration and on different environments.
As this is a quite big module there's probably more we've missed but I'm pretty sure there just minor issues and I think your definitely experienced enough to maintain your projects seriously.

So, thanks for your contribution and welcome to the community of project contributors on drupal.org!

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.

Thanks to the dedicated reviewer(s) as well.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added additional reviews of other projects for the bonus!