What is this?

State Transition Control (STC) module enable workflow control on select list fields. If you enable state transition control on a field, you can set each (current) value of this field that which values can be set in next time (if the field current value is a particular one). If you didn't set any transition for a value than all values can be selected.

State Transition Control module can be very useful in case tracker systems or in any other systems with a special form where it's necessary to control the value transitions of a field (ex.: an administration field).

Module settings can be exported with Features module.

If you want to test this:

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mxr576/2150643.git
OR
http://simplytest.me/project/2150643

Project page: https://drupal.org/sandbox/mxr576/2150643

Reviews of other projects
https://www.drupal.org/node/2304051#comment-9030947
https://www.drupal.org/node/2275135#comment-9030721
https://www.drupal.org/node/2315539#comment-9030663

https://www.drupal.org/node/2267611#comment-9030987
https://www.drupal.org/node/2304051#comment-9047377
https://www.drupal.org/node/2327911#comment-9097273

Comments

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.

hayashi’s picture

Hi @mxr576
I tried your module and find some issues.

・README.txt is missing.
https://drupal.org/node/161085

・Following messages is shown when save field setting.
Try to make 'Allowed values list' empty and save.

Notice: Undefined index: field_workflow_control_fieldset in field_workflow_control_form_field_ui_field_edit_form_validate() (line 70 of /var/www/drupal7/sites/all/modules/field_workflow_control/field_workflow_control.module).
Warning: Invalid argument supplied for foreach() in field_workflow_control_form_field_ui_field_edit_form_validate() (line 70 of /var/www/drupal7/sites/all/modules/field_workflow_control/field_workflow_control.module).

・Undesired item is shown.
Allowed values list:
0|State 0
1|State 1
2|State 2

Workflow control settings:
State 0: State 0, State 1
State 1: State 1, State 2
State 2: State 2

Edit node, set field value to 'State 2' and save.
Edit node again, only 'State 2' should be shown but 'State 0' is also selectable.

j.branson’s picture

Status: Needs review » Needs work

Outside of the comment above, I ran this through PAreview.sh (http://pareview.sh/pareview/httpgitdrupalorgsandboxmxr5762150643git). As far as code review goes, it looks like you're basically good to go, but for two things: 1) There is still a master branch, you should switch default to 7.x-1x and delete the master branch. 2) Do you need to extract the keys in the foreach under field_workflow_control_features_export_alter? Having the keys doesn't affect the functionality one way or another, but it does leave two unused variables, which is odd.

...Nice job!

PA robot’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 (see also the project application workflow).

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

mxr576’s picture

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

First of all thank you guys for your reviews!

Sorry, because I disappeared, but I've some school related works to do. But now I've some free time and I've made a big rework of this module. I think this version has more user friendlier UI than the previous one. (Of course I've fixed bugs too! :))

Please test this module again and provide some feedback.

Regards: mxr576

mxr576’s picture

Issue summary: View changes
mxr576’s picture

Issue summary: View changes
mxr576’s picture

Issue summary: View changes
mxr576’s picture

Issue summary: View changes
pushpinderchauhan’s picture

@mxr576, thanks for your contribution.

I saw your module and also installed and tested functionality, working as expected. Its looks like a great improvement from your previous code. Good Work!

Your git command is not correct, it should be

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mxr576/2150643.git

Automated Review:
http://pareview.sh/pareview/httpgitdrupalorgsandboxmxr5762150643git reported following two minor issues.

FILE: /var/www/drupal-7-pareview/pareview_temp/field_workflow_control.install
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
5 | ERROR | Doc comment short description must be on a single line, further
| | text should be a separate paragraph
--------------------------------------------------------------------------------

FILE: /var/www/drupal-7-pareview/pareview_temp/field_workflow_control.module
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
5 | ERROR | Doc comment short description must be on a single line, further
| | text should be a separate paragraph
196 | ERROR | Missing parameter type
--------------------------------------------------------------------------------

Manual Review:
1. In Readme.txt file some special character is coming in following line, fix it.
If you didn’t set any transition for value than all values can be selected
2. Your module name is field_workflow_control that sound like it is something similar to Workflow module but in your case you are just managing field values as a states. There can be a better name for this module, something related to states as this is my personal opinion, might be other people find this name good :).
3. hook_help() function is missing in your module.
4. Inline comments looks good in your code.

Certainly your module looks good to me.

Thanks again!

mxr576’s picture

Thanks for your review and your kind words @er.pushpinderrana!

I've fixed all mentioned problems, after that left only this one. I'm not sure how to solve this in my case. (I've read this part of documentation.)

FILE: /var/www/drupal-7-pareview/pareview_temp/field_workflow_control.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
214 | ERROR | Type hint "array" missing for $all_values
--------------------------------------------------------------------------------

I'm also understand your problems with my module name. This name was born when we have started to work on our issue tracker and we were need a module that could control the value transition of select fields (ex.: issue statuses). That's why the module renamed their first name to something that contains "workflow", because it is something that surrounding with an issue tracker.

The original name was "Field Value Transition Control" which were not sounds as good as Field Workflow Control, but it's describe much better what my module could do. What do you think about this name or "Select Value Transition Control"? Any other idea or I can stay in the current name?

mxr576’s picture

Issue summary: View changes
j.branson’s picture

Status: Needs review » Needs work

Hey,

For line 214 - you just need to define that the $all_values parameter accepts only an array. So: function _field_workflow_control_get_selected_values(array $all_values) {...}

That should do the trick.

For more on type hinting: http://php.net/manual/en/language.oop5.typehinting.php

mxr576’s picture

Title: [D7] Field Workflow Control » [D7] State Transition Control
Issue summary: View changes
mxr576’s picture

Hi!

Thanks, your idea worked! I thought the problem in the comment part not in the code. Now I know how to solve this warnings.

Also, the module renamed to State Transition Control, maybe it will be a better name for this module. (@see #10-11).

There is no errors now on paraview.sh .

mxr576’s picture

Status: Needs work » Needs review
pushpinderchauhan’s picture

Status: Needs review » Reviewed & tested by the community

Looks better module name this time.

Automated Review

PAReview came up clean.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No multiple applications
Yes: No multiple application found.
No duplication
Yes: Not found any similar project.
Master Branch
Yes: Follows the guidelines for master branch.
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt
No. The format of README.txt does not follow the guidelines for in-project documentation. In particular, see the README.txt Template.
Code long/complex enough for review
Yes. About 300 lines. Follows the guidelines for project length and complexity.
Secure code
Yes.
Coding style & Drupal API usage

1. Your code looks good to me.
2. It would be good, if you extend Project page little bit more.
3. Similarly Readme.txt file need to be enhanced.
4. Inline comments looks good to me.

It looks RTBC from my side.

As I am not a git administrator, so I would recommend you, please help to review other project applications to get a review bonus. This will put you on the high priority list, then git administrators will take a look at your project right away :-)

mxr576’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
klausi’s picture

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

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

  • 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:

  1. The Git commits are not connected to your user account. You need to specify an email address. See https://www.drupal.org/node/1022156 and https://www.drupal.org/node/1051722
  2. Users can easily setup workflows with https://www.drupal.org/project/rules or https://www.drupal.org/project/workbench . Please describe the differences to existing projects on your project page and follow https://www.drupal.org/node/997024 .
  3. state_transition_control_install(): why do you increase the module weight, that should be documented in the comment. Also, juggling with module weights can be unreliable, so I would recommend to use hook_module_implements_alter() if you need to run before/after a specific other hook implementation.
  4. _state_transition_control_field_edit_form_ajax_callback(): why is this function needed if it doesn't do anything? Please add a comment.
  5. _state_transition_control_modify_existing_form_add_checkboxes(): this is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as possible field value then I will get a nasty javascript popup. You need to sanitize user provided text before printing. In your case you must use an "@" placeholder with t(). Make sure to read https://www.drupal.org/node/28984 again. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.

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

mxr576’s picture

Status: Needs work » Needs review

Dear @klausi!

Thanks for your detailed review. I think I've managed to fix all missing stuff as you can in here and here.

Special thanks for XSS notice which somehow I've overlooked.

mxr576’s picture

Status: Needs review » Reviewed & tested by the community
pushpinderchauhan’s picture

Status: Reviewed & tested by the community » Needs review

@mxr576, you can not switch status to RTBC yourself, moving back to Needs Review :).

Also I would recommend you, please help to review other project applications to get a review bonus back. This will put you on the high priority list, then git administrators will take a look at your project right away :)

Thanks to you for your hard work and patience.

mxr576’s picture

Issue summary: View changes
potop’s picture

Status: Needs review » Needs work

Seems like you fixed all the issues found by the previous review and module works just like it is described.

I just have one usability suggestion: when selecting possible transitions on field settings page, it would make sence to make mandatory transition (from "state 1" to "state 1") checkboxes "readonly" so user have no chance to deselect them by mistake.

mxr576’s picture

Status: Needs work » Needs review

Thanks your idea potop!

Honestly, I also have the same idea when I've made this module, but I've sadly seen that "checkboxes" form elements can not be manipulated easily. I've try to set the mandatory ones to disabled, but I couldn't do it inside the checkboxes form element if I remember well . Maybe I could write a little jQuery hack around this later, but now I think it isn't a release blocker issue, because the validator function prevents from unchecking the mandatory transitions.

mxr576’s picture

Issue summary: View changes
mxr576’s picture

Issue tags: -PAreview: security +PAReview: security PAReview: review bonus
mxr576’s picture

Issue tags: -PAReview: security PAReview: review bonus +PAreview: security, +PAreview: review bonus
klausi’s picture

Status: Needs review » Needs work

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

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    FILE: /home/klausi/pareview_temp/state_transition_control.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     112 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
  • 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:

  1. _state_transition_control_modify_existing_form_add_checkboxes(): there is still one "!value" in the translatable string which needs to be replaced.
  2. state_transition_control_form_field_ui_field_edit_form_validate(): this is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as possible field value then I will get a nasty javascript popup as soon as the form error triggers. You need to sanitize user provided text before printing. In your case you must use an "@" placeholder with t(). Make sure to read https://www.drupal.org/node/28984 again.
mxr576’s picture

Status: Needs work » Needs review

Thanks for reviewing (again) @klausi!

I'm sorry because I've missed the "same type of bugs" in the code as you have mentioned before.
I have to confess that I've focused only those things that have been mentioned in the previous comment because I was quite busy nowadays.

I hope that everything is OK from now.

Regards, mxr576

klausi’s picture

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

Looks RTBC to me now after a manual review.

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

mpdonadio’s picture

Automated Review

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

  • 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

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes. If "no", list security issues identified.
Coding style & Drupal API usage
Not a fan of using explicit strong elements for the descriptions. Let the theme handle this.

The code is pretty dense. It could use a little vertical whitespace between logical breaks.

Will this be translation safe with all of the LANGUAGE_NONE usage? Double check this.

Not seeing any blockers here. Placeholders all look appropriate.

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.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, mxr576!

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.

Status: Fixed » Closed (fixed)

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