Overview

This module allows admins to create rules. Each of these rules will prevent a user from adding one particular content type unless the user has finished adding a specified number of another content type. The number can be specified by the admin.

Example

  • You want a user to add a company page for the user to be able to start adding a products page
  • Your user needs to add his profile before he can start posting blogs

Details

Project page: https://drupal.org/sandbox/neerajskydiver/2134689
Checkout: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/neerajskydiver/2134689.git content_type_dependency

Manual reviews of other projects

https://drupal.org/comment/8178663#comment-8178663
https://drupal.org/node/2135793#comment-8179545
https://drupal.org/comment/8187293#comment-8187293
https://drupal.org/comment/8198077#comment-8198077
https://drupal.org/comment/8198199#comment-8198199
https://drupal.org/node/2138865#comment-8199157

Comments

neerajskydiver’s picture

Issue summary: View changes

Added code review link

PA robot’s picture

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.

neerajskydiver’s picture

Issue summary: View changes
nitesh pawar’s picture

Hi eerajskydiver,

There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732

idebr’s picture

Status: Needs review » Needs work

Hi Neeraj,

Great idea and a great module! Just a few things before you release:

  1. You can help other developers find the module configuration by adding a 'configure' line in your .info file, check out this page for more information: https://drupal.org/node/542202
  2. You can add your page callbacks for the admin interface to a seperate file, so they can be loaded when needed. Your .module file should be a small as reasonably possible to reduce memory load. You can read more on how to include files for page callbacks in hook_menu
  3. There is no need to call drupal_uninstall_schema in content_type_dependency_uninstall() in code, as it is called automatically on uninstall
  4. You should add 'node' as dependency in your .info file, just to be sure :)
  5. Instead of calling onClick="return confirm(\'Are you sure to delete ?\')">Delete' on a link, you can use confirm_form to make sure the editor does not delete an entry by accident.
neerajskydiver’s picture

Thanks Niteshp & idebr

#4

Master branch has deleted

#5

1. configure line added in .info file
2. .admin.inc file created & loaded to hook_menu
3. Deleted hook_uninstall_schema.
4. Dependency node is added to .info file
5. Confirm form was created for delete option

neerajskydiver’s picture

Issue summary: View changes
Status: Needs work » Needs review
asghar’s picture

I have installed and Configured it and check it different users. Also review your module code and it is working fine.

neerajskydiver’s picture

Issue summary: View changes

Added code review link

neerajskydiver’s picture

Issue summary: View changes
neerajskydiver’s picture

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

Status: Needs review » Needs work
README.txt
Please take a moment to make your README.txt follow the guidelines for in-project documentation.

You can make content_type_dependency_form_node_form_alter() a lot simpler.

  • First off, don't use backticks (`) in the sql query - not all servers are configured that way. Use {} instead, that's the Drupal standard.
  • Second, instead of loading every rule, just load the rule that applies to the content type currently being created.
  • Third, only load enabled rules. All together your db_query would look like this:
  db_query('SELECT * FROM {content_type_dependency} WHERE to_create = "%s" AND status = 1', $form['#node']->type);
  • In content_type_dependency.admin.inc your docblocks are wrong, those is not an implementation of hook_form, and hook_form_validate and hook_form_submit don't exist. Just document those functions normally.
  • All user facing text must be passed through t().
  • In content_type_dependency_list(), don't use inline-css, create a .css file and include it instead.

Setting to "needs work" for the number of issues. You might want to consider actually integrating this module with the Rules API, I think it would get you a lot more flexibility and a simpler module.

----
Top Shelf Modules - Crafted, Curated, Contributed.

neerajskydiver’s picture

Hi Karl,
Thank you for detailed comments.

Have updated README.txt as explained in guidelines for in-project documentation.

Removed back ticks (`) and instead used {}

  • Second, instead of loading every rule, just load the rule that applies to the content type currently being created.
  • Third, only load enabled rules. All together your db_query would look like this:

Made the changes and now loading enabled rules only.

In content_type_dependency.admin.inc your docblocks are wrong, those is not an implementation of hook_form, and hook_form_validate and hook_form_submit don't exist. Just document those functions normally.

Updated doc blocks in content_type_dependency.admin.inc.

All user facing text must be passed through t().

Rechecked t() in all form title and description

In content_type_dependency_list(), don't use inline-css, create a .css file and include it instead.

My mistake, removed inline css

I have not thought about Rules API, will look into.

neerajskydiver’s picture

Status: Needs work » Needs review
neerajskydiver’s picture

Issue summary: View changes

Added code review link

balagan’s picture

StatusFileSize
new9.42 KB

I do not think dependencies[]= node makes any sense, although I saw the comment recommending it.
I have uploaded a patch, where I have corrected lots of typos.
I see you have created a whole new edit form. I would use only one form, where I set the default values from the URL. If you change any strings (or fix typos), now you have to do it twice on two forms.
Regarding the confirm_form, I could not find it.

neerajskydiver’s picture

balaban, Thank you for your valuable input regarding typos used in the module. Would review and incorporate your suggestions.

neerajskydiver’s picture

Status: Needs review » Needs work
neerajskydiver’s picture

Changed typo as suggested by balagan.
Also now only one form for both editing & new rule.

neerajskydiver’s picture

Status: Needs work » Needs review
akshat.khariwal’s picture

Assigned: Unassigned » akshat.khariwal
Status: Needs review » Active
akshat.khariwal’s picture

Assigned: akshat.khariwal » Unassigned
Status: Active » Needs work

Cloned the project from git (http://git.drupal.org/sandbox/neerajskydiver/2134689.git), but was not able to find the changes suggested in comment #12 and #16.

Additionally, I'd like to suggest you to use EntityFieldQuery in 'content_type_dependency_node_count()' instead of 'db_query()'.

neerajskydiver’s picture

Hi akshat.khariwal, Thank you for your valuable input.
Have made changes as suggested

  $result = db_query('SELECT n.nid FROM {node} n WHERE n.uid = :uid AND n.type = :type', array(':uid' => $uid, ':type' => $c_t));
  return $result->rowCount();

to

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $c_t)
    ->propertyCondition('uid', $uid)
    ->count();
  return $query->execute();
neerajskydiver’s picture

akshat.khariwal, also try downloading from git again. Have tested for both comments you have mentioned.

neerajskydiver’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new53.23 KB
klausi’s picture

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

manual review:

  1. content_type_dependency_schema(): please provide meaningful descriptions to each DB column.
  2. "$msg = 'Enabled';": all user facing text must run through t() for translation. Same for "'#prefix' => 'Would you like to continue with deleting .." and others, please check all your strings.
  3. admin/config/content/content_type_dependency/list: this is vulnerable to XSS exploits. If I enter a message <script>alert('XSS');</script> for a dependency I get a nasty javascript popup. You need to sanitize all user provided text before printing. Make sure to read https://drupal.org/node/28984 again. Same for content_type_dependency_form_node_form_alter(), you need to sanitize $record->message first. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
  4. content_type_dependency_modify(): this is vulnerable to CSRF attacks. You must never perform write operations on GET requests, either use confirmation forms or a security token in the URL. See also http://epiqo.com/en/all-your-pants-are-danger-csrf-explained
neerajskydiver’s picture

Hi klausi, Thank you for your review.

1. Done. Have updated descriptions of DB column.
2. Done. Have updated all user facing text with t() function.
3. Done.
4. Done. Have used confirmation form for deleting and security tokens for enable/disable rule.

neerajskydiver’s picture

Status: Needs work » Needs review
klausi’s picture

Assigned: Unassigned » cweagans
Status: Needs review » Reviewed & tested by the community

manual review:

  1. "$content_types[''] = '- SELECT -';": all user facing text must run through t() for translation.
  2. content_type_dependency_modify(): the check_plain of the $content_types array is not necessary here since the select boxes #options arrays will do the sanitization for you. See https://drupal.org/node/28984
  3. '<a href="' . $url . '">Disable</a>', '<a href="' . $url_edit . '">Edit</a> / <a href="' . $url_delete . '" ">Delete</a>');: Disable and Delete should also run through t() for translation, please check all your strings.
  4. "$header_table1 = array('To create', 'Must have', 'No of', 'Message', '', '');": same here.
  5. content_type_dependency_list(): do not call theme() here, just return a render array. Drupal will render the table array later for you.

That are not critical application blockers, so I think this is RTBC otherwise.

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

neerajskydiver’s picture

Thanks klausi for your feedback and updating project review status.

  1. Double checked and updated all user facing text with t() function.
  2. Deleted check_plain function.
  3. Made necessary changes for content_type_dependency_list()
ram4nd’s picture

  • Use abstraction layer instead of queries, it makes it friendlier for different kind of databases.
  • Use l function instead of writing a tag.
  • Use single quotes everywhere for consistency.
  • Predefine $items in hook_menu to avoid notices in some cases.
neerajskydiver’s picture

Hi ram4nd, thanks for reviewing.
Definately i would consider using abstraction later in next version. Will check for consistency regarding single quote.

neerajskydiver’s picture

  • Used l functions instead of writing a tag.
  • Used possible single quotes for consistency.
klausi’s picture

Status: Reviewed & tested by the community » Fixed

no other objections for more than a week, so ...

Thanks for your contribution, neerajskydiver!

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.

neerajskydiver’s picture

Hi klausi,

Thank you for the approval.

Thanks also to ram4nd, Niteshp, idebr, asghar, kscheirer, balagan, akshat.khariwal for your help with the review and helping in improving project!.

Best
Neeraj

Status: Fixed » Closed (fixed)

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