Synopsis
This module is used to Show a count of nodes of a particular content-type
and also number of Users of particular role type.
This module will be used for statistical and dev purposes only.

Requirements:

You can view the report of the count for Node and count of user in the following relative URL after installation of Node Type count module

Node Count : "/admin/reports/node-type-count"
User Count : "/admin/reports/node-type-count/user"

Similar projects and how they are different

Count : https://www.drupal.org/project/count

Difference : Count module create a block for every content type. It make administrator to show less or more count of actual nodes.
Rather this module will give exact count of the nodes by its content type and User Count by its role.


Uses:

1. Will count the number of published and unpublished nodes in particular content type which will be useful in content audit to take the report of node status.

2. This module is used to count the number of users in particular Role

Note: This module is for statistical and development purpose only.

Git Clone URL : git clone --branch 7.x-1.x http://git.drupal.org/sandbox/devarajjohnson/2535180.git node_type_count

Sanbox URL : https://www.drupal.org/sandbox/devarajjohnson/2535180

Manual reviews of other projects

https://www.drupal.org/node/2298559#comment-10148088
https://www.drupal.org/node/2537108#comment-10141966
https://www.drupal.org/node/2155969#comment-10148122

pareview.sh URL: http://git.drupal.org/sandbox/devarajjohnson/2535180.git

Comments

devaraj johnson’s picture

Issue summary: View changes
PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxdevarajjohnson2535180git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

devaraj johnson’s picture

Status: Needs work » Needs review

Updated the changes in the module

devaraj johnson’s picture

Issue tags: +PAreview: review bonus
Vimala vinisha’s picture

Hi Devaraj johnson,
This module is working perfectly. Good job. :)

Thanks,
Vimala

neerajsingh’s picture

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

Hi Devaraj johnson,

I have reviewed your project, below are my findings:

In info file(Line no 5)
configure = admin/admin/reports/node-type-count
You have mentioned a configuration path but there is no items in hook menu for it.
In module file(Line no 36, 41, 47)
'access callback' => TRUE,
You have specified access callback to TRUE, which I feel is a security concern.

Hence, I am updating the status to 'Needs Work'.

Also note that, once you have completed 3 manual reviews of separate project applications then add the 'PAReview: review bonus' tag. For more on review Bonus Refer: https://www.drupal.org/node/1975228

Regards,
Neeraj Singh

ashish.verma85’s picture

Hi, the module works fine, one issue i found:
1) It is recommended to always implement hook_install(). Here you can find an example.

viswanathan6’s picture

Hi Devaraj,

This module is working fine.

devaraj johnson’s picture

Status: Needs work » Needs review

All mentioned changes are done.

devaraj johnson’s picture

Issue summary: View changes
devaraj johnson’s picture

Issue tags: +PAreview: review bonus
devaraj johnson’s picture

Issue summary: View changes

updated pareview.sh URL

devaraj johnson’s picture

pareview.sh URL updated

heykarthikwithu’s picture

StatusFileSize
new642 bytes

Reviewed by Coder module.

File name: node_type_count.install

Error:
Line 13: Potential problem: drupal_set_message() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_3]
drupal_set_message($t("Node Type Count Module settings are available under !link", array('!link' => l($t('Reports > Node Type Count'), 'admin/reports/node-type-count'))));

Solution: Find the attached patch.

ajay_reddy’s picture

Status: Needs review » Needs work

Hello Devaraj johnson,
This module is working perfectly in Drupal 7.38 . Good job.

Found small syntax issue in .install file

node_type_count.install

Line 13: Potential problem: drupal_set_message() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_3]
drupal_set_message($t("Node Type Count Module settings are available under !link", array('!link' => l($t('Reports > Node Type Count'), 'admin/reports/node-type-count'))));

and change it as

drupal_set_message(check_plain($t("Node Type Count Module settings are available under !link", array('!link' => l($t('Reports > Node Type Count'), 'admin/reports/node-type-count')))));

So changing status to Needs Work.

klausi’s picture

Status: Needs work » Needs review

@ajaykumarreddy1392: that is a false positive from the old coder review module. Since there is no user provided text involved you should NOT run check_plain() here. Make sure to read https://www.drupal.org/node/28984 again and don't blindly fix issues reported by the old coder review, since it has known false positives.

devaraj johnson’s picture

sanitized drupal_set_message()

drupal_set_message($t("Node Type Count Module settings are available under @link", array('@link' => l($t('Reports > Node Type Count'), 'admin/reports/node-type-count'))));

Torvald’s picture

Status: Needs review » Needs work

Hi Devaraj johnson,

I have reviewed your project.
This module is working perfectly.
Pareview / Coder review: OK

But below are my findings:

  • Please add PHP version into your .info file.
  • Please see what's what with the case letters on the help page :)

Thanks!

devaraj johnson’s picture

HI Torvald

Thanks for your review.

1. What do you mean by "Please see what's what with the case letters on the help page :)" please explain

2. "Please add PHP version into your .info file." its option not a mandatory one please refer https://www.drupal.org/node/542202#php for more details.

devaraj johnson’s picture

Status: Needs work » Needs review
Torvald’s picture

Devaraj,

I mean, it would be nice if you set words to one register ("published and Unpublished").
I think, it is not critical issue,but it would be better :)

I agree with the second point.

Thanks!

devaraj johnson’s picture

Hi Torvald,

Modified the changes

Thanks!

devaraj johnson’s picture

Issue summary: View changes
devaraj johnson’s picture

Issue summary: View changes
devaraj johnson’s picture

Priority: Normal » Major
pravin ajaaz’s picture

Status: Needs review » Reviewed & tested by the community

Manual Review:

In .install file:

  • In the file comment block, it states "This Install file is for Node Type Count" better change it to something like "Install/Enable functions for Node type count".
  • Also prefer using hook_enable instead of hook_install. Because hook_install is mostly used to set variables or update DB.
  • And when I install the module, the link is just displayed as HTML anchor tag instead of link. So consider changing it to something like this:
  $config_link = url() . 'admin/reports/node-type-count';
  drupal_set_message($t("Node Type Count Module settings are available under <a href='@link'>Reports > Node Type</a>", array('@link' => $config_link)));

In .module file:

  • In hook_help(), please make these small changes > "This Module is used to count the number of published and unpublished nodes in all content types and counts the number of users in Every User Role".
  • Change the first line of hooks as just "Implements hook_help()" and "Implements hook_menu()", instead of "This hook Implements hook_menu() for Node Type Count module"

In .admin.inc file:

  • Consider changing the Tables column names "Title" and "Type" into "Content type" and "Machine name".

These are just minor changes and I couldn't see any blockers here. So setting the status to RTBC, for the final review by a git admin.

devaraj johnson’s picture

Hi Pravin Ajaaz,

Thanks for the review, Requested changes are implemented. Waiting for the final review

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

I'll look at this tonight or tomorrow.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Priority: Major » Normal
Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: security

Automated Review

Review of the 7.x-1.x branch (commit 1beef7e):

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. You have to get a review bonus to get a review from me.


FILE: /Users/matt/PAR/pareview_temp/node_type_count.install
---------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------
 12 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
 12 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
 13 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
 13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
 14 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
 14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 3
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------


FILE: /Users/matt/PAR/pareview_temp/node_type_count.module
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------
 15 | WARNING | Hook implementations should not duplicate @param
    |         | documentation
 17 | WARNING | Hook implementations should not duplicate @param
    |         | documentation
---------------------------------------------------------------------------

Time: 212ms; Memory: 5.75Mb

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Maybe: Causes module duplication and/or fragmentation. Not sure if this can just be accomplished with Views. Not a blocker.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code

(*) theme_table() does not sanitize output. The content type name and user role name are both user input and need to be run through check_plain().
Test this by using.

  <script>alert('XSS');</script>
  

for each.

Coding style & Drupal API usage
Reviews 7.x-1.x branch. 8.x-1.x branch appears identical.

node_type_count_page_node() doesn't need to call theme. It can just build up and return a render array.

node_type_count_page_user() doesn't need to call theme. It can just build up and return a render array.

The row headers are untranslated. Run them through t().

node_type_count_published(), use NODE_PUBLISHED and NODE_NOT_PUBLISHED instead of the values.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

devaraj johnson’s picture

Hi Matthew Donadio,

Automated Review:

1. Fixed Coder Sniffer error

Manual Review:

1. The content type name and user role name run through check_plain() - Fixed
2. Reviews 7.x-1.x branch. 8.x-1.x branch appears identical - Removed branch 8.x-1.x
3. node_type_count_page_node() doesn't need to call theme. It can just build up and return a render array. - Fixed
4. node_type_count_page_user() doesn't need to call theme. It can just build up and return a render array. - Fixed
5. The row headers are untranslated. Run them through t(). - Fixed
6. node_type_count_published(), use NODE_PUBLISHED and NODE_NOT_PUBLISHED instead of the values. - Fixed

devaraj johnson’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Needs work

manual review:

  1. project page: please add the differences to existing projects to the project page.
  2. node_type_count_page_node(): this is vulnerable to XSS exploits. If I ahve a content type with the name <script>alert('XSS');</script> then I will get a nasty javascript popup. You need to sanitize user provided text before printing, make sure to read https://www.drupal.org/node/28984 again. Strictly speaking this is not a big security problem because it requires a trusted permission to create that content type, but this should be fixed anyway.
devaraj johnson’s picture

Issue summary: View changes
devaraj johnson’s picture

Issue summary: View changes
Status: Needs work » Needs review

Hi Klausi,
Thank you for reviewing.

1. I have added the difference in the project description.

2. I have changed the above requested changes. If my Understanding is correct I have changed the $content['title'] in the node_type_count_page_node() function with check_plain($content['title']), Since content title can have <script>alert('XSS');</script> as a content type name. I have added check_plain to this part.

klausi’s picture

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

I meant that you add the difference to existing projects to the project page of the sandbox (your later full project page), not the issue summary here.

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

Assigning to mpdonadio as he might have time to take a final look at this.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned

Automated Review

Review of the 7.x-1.x branch (commit c73b11e):

  • No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

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. You have to get a review bonus to get a review from me.

Manual Review

My XSS concerns were addressed and explicitly tested. Read `git diff 1beef7e` and changes look good.

Don't see any blocking issues.

mpdonadio’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, Devaraj johnson!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

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.

Thanks to the dedicated reviewer(s) as well.

devaraj johnson’s picture

Thanks Matthew Donadio :)

heykarthikwithu’s picture

Status: Fixed » Closed (fixed)
devaraj johnson’s picture

Issue summary: View changes
devaraj johnson’s picture

StatusFileSize
new14.7 KB

Just adding image