This module provides a way to add basic subscriptions functionality to Advanced Forums. It is a very lightweight alternative to installing the 4 modules: Subscriptions, Subscriptions Mail, Subscriptions UI and Taxonomy Subscriptions; if all you want is subscriptions for Forums.

It provides functions to subscribe to:
- All forums (global subscription, on the Forums page)
- Individual Forums (on the Forums page, not on the Topics page where the Subscriptions module puts it)
- Individual Topics (on the Forum Topics page)

Emails are sent to each user who is subscribed at the appropriate level when
- a new Forum is added
- a new Forum topic is added
- a new Forum topic comment is added

An additional tab is provided on the Forum tab menu to view your own subscriptions and optionally remove any subscriptions.

Answers to the usual questions:
Q: Why not contribute this code to Advanced Forum?
A: Advanced Forum 7.x-2.0 has reached RC state so feature set is locked. The maintainer will deal with major/critical bugs only.

Q: Can't this already be achieved with existing modules?
A: Yes and no. If you only want subscriptions for Forums then you must install the Subscriptions modules (with their relatively heavy payload) and disable all of its functionality for all content other than Forum content.
Also, the subscriptions module does not provide a link on the Forums page to subscribe to Forums, you need to go to a Topic within that Forum first.
And also, the subscriptions module does not provide functionality to subscribe to All Forums, ie. it does not have global subscription capabilities.

Project page: http://drupal.org/sandbox/Bagz/1465984
Git repository: git clone --branch 7.x-1.x Bagz@git.drupal.org:sandbox/Bagz/1465984.git

Comments

adammalone’s picture

Status: Needs review » Needs work

There are a few things that can be done to improve this module after passing it through pareview.

Your results from running through it are here: http://ventral.org/pareview/httpgitdrupalorgsandboxbagz1465984git

The most striking things are to get rid of LICENSE.txt and to move from the master branch in git.

Almost all of the errors appear to be CSS colour errors. Whereby you've used capital letters but drupal coding standards require lower case.
eg:
223 | ERROR | CSS colours must be defined in lowercase; expected #3c78a7 but | | found #3C78A7

Another error that can be easily resolved seems to be that you have extra lines at the end of your modules. Just remove all blank lines from the end of files and it will fulfill requirements!

Bagz’s picture

Issue summary: View changes

changed git instruction due to new branch 7.x-1.x-dev

Bagz’s picture

Status: Needs work » Needs review

Have fixed all of the issues identified by pareview, except for two false positives where two long query statements are incorrectly identified as array declarations.

michelle’s picture

Does this actually require Advanced Forum? Since AF builds on core forum and subscriptions are fairly low level, removing AF as a requirement would open this up to use by anyone using core forum.

I haven't actually looked at the code; no time now. I like the idea, though, and I think it's good to have it as a separate module.

Bagz’s picture

Interesting question Michelle, but no it basically extends much of the Advanced Forum functionality (it adds to the AF templates) and uses some of the AF functions. I never considered anyone would use core Forum rather than AF :-)

I will have a look at core forum and see what I would need to do to make this work for that as well.

michelle’s picture

Ah, I see. Yeah, some do use just core forum but that's usually people who want to keep things very simple, anyway.

I'll be keeping an eye on this to see if it could work with Artesian as well.

targoo’s picture

Hi

I like your code and think it is well written. I have done a first manual review of it :

1) advanced_forum_basic_subscriptions.install
/**
51 * Implements hook_uninstall().
52 */
53 function advanced_forum_basic_subscriptions_uninstall() {
54 }

Remove the function if empty

2) advanced_forum_basic_subscriptions.module
182 drupal_set_title($title);

drupal_set_title($node->title); // XSS vulnerability
drupal_set_title(check_plain($node->title)); // Correct

3) advanced_forum_basic_subscriptions.module
288 $message = "A new comment, $comment->subject, has been added to topic $node->title.";
You don't use this variable so you can remove it.

4) advanced_forum_basic_subscriptions.module
In advanced_forum_basic_subscriptions_subscribe and advanced_forum_basic_subscriptions_unsubscribe
you don't really check the input (arg(2)...).

5) advanced_forum_basic_subscriptions.module
490 $subscription = array();
Do you need it ?

FILE: .../pareview_temp/test_candidate/advanced_forum_basic_subscriptions.module
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
265 | ERROR | If the line declaring an array spans longer than 80 characters,
| | each element should be broken into its own line
301 | ERROR | If the line declaring an array spans longer than 80 characters,
| | each element should be broken into its own line
--------------------------------------------------------------------------------

Bagz’s picture

Thanks for the feedback, always good to have someone else review code to find loose ends.

Have addressed all of the issues you raised:
1 -> function removed
2 -> fixed (this code was copied verbatim from the advanced forum module, so perhaps the XSS vulnerability exists in that module as well?)
3 -> variable removed
4 -> both functions now validate arguments
5 -> statement removed
pareview -> code now 100% clean

michelle’s picture

this code was copied verbatim from the advanced forum module, so perhaps the XSS vulnerability exists in that module as well?

Where? I've grepped the source of AF for both drupal_set_title and $node->title and don't see it.

Bagz’s picture

\includes\core-overrides.inc, line 65

michelle’s picture

Term title and node title are very different. I suppose if you let random users add forums, this could be an issue (though I didn't check if it is sanitized elsewhere so it may be moot). But node titles of forum topics are normally entered by (potentially) untrusted users so that is a much more serious issue.

Bagz’s picture

Item 2 is not correct. It makes forum titles like "John's Forum" display as "John's Forum".

This is a common issue that happens with using check_plain twice, and after investigating this further I found it happens because the drupal_set_title function already does a check_plain itself.

I have reverted that line of code back to how it was.

prashantgoel’s picture

Status: Needs review » Needs work

please visit http://ventral.org/pareview/httpgitdrupalorgsandboxbagz1465984git for the list of errors being generated.

patrickd’s picture

Status: Needs work » Needs review

don't block in-depht reviews because of these minor issues

Bagz’s picture

Thank you prashantgoel for the feedback. However, it is a bit over the top to refer to this as "errors". They are not errors, they are just trivial semantic non-conformances to standards (however important they are) that do not impact on the functionality of this module whatsoever.

I have modified all of the non-conformances that PAReview identified.

Bagz’s picture

Thank you patrickd for injecting a bit of sanity back into the "review" process.

SebCorbin’s picture

Status: Needs review » Needs work

I see no security issues here, but some variables are loaded but not used and could be affecting performance a bit.
You can see these by configuring your IDE code inspections.

I've installed the module and it gives me errors in advanced_forum_basic_subscriptions_preprocess_advanced_forum_topic_list_view() because my path are aliased by pathauto, the hack should be earlier, not in preprocess.

But I'm not sure if this count in project application review...

Bagz’s picture

Status: Needs work » Needs review

Unused variables have been removed.

No information has been provided on the errors which means I have nothing to go on. Will need more detailed information as to where any errors occur and in what scenario.

SebCorbin’s picture

Scenario:

  1. Enable Path module
  2. Install Advanced Forum Basic Subscriptions module
  3. Create Forum with aliased path
  4. Bug occurs when viewing forum
Bagz’s picture

Thanks for the pointers. The function has been modified so that it now works for both unaliased and aliased nodes.

shawn_smiley’s picture

Status: Needs review » Needs work

A couple minor issues.

  1. Documentation comments for non-hook functions are missing documentation on parameters and return values. See http://drupal.org/node/1354#functions.
    In particular, the following functions should have their parameter/return values documented:
    • advanced_forum_basic_subscriptions_page
    • advanced_forum_basic_subscriptions_makelink
    • advanced_forum_basic_subscriptions_bulk_mail (just add a @see entry pointing at drupal_mail)
    • advanced_forum_basic_subscriptions_subscribe (there is a typo in the description here too)
    • advanced_forum_basic_subscriptions_unsubscribe (there is a typo in the description here too)
  2. In function advanced_forum_basic_subscriptions_page() the result of calls to advanced_forum_basic_subscriptions_subscribe() are assigned to a variable, but that variable is never used. I would recommend adding a check for $result == FALSE and display a message to the user if the subscribe/unsubscribe fails.
  3. In function advanced_forum_basic_subscriptions_comment_insert(), you are calling node_load twice in a row with the same argument and not doing anything with the result after the first call. You should remove one of the node_load() calls.
Bagz’s picture

Status: Needs work » Needs review

Thanks Shawn.

I have addressed all of the issues you identified and updated the repository.

shawn_smiley’s picture

Status: Needs review » Needs work

Make sure you specify the default branch on your project page and remove the master branch from your git repo. See http://drupal.org/node/1659588.

I'd like to see your callbacks to subscribe/unsubscribe be separate from the rendering of the page. As it's currently implemented you leave open the possibility of a user bookmarking a subscribe/unsubscribe operation. So I would recommend making the following changes related to this:

  • In your hook_menu() implementation, have separate callback functions for the subscribe/unsubscribe links
  • In your callback functions for subscribe/unsubscribe, do a drupal_goto() back to the original page (using the destination argument) so that the page URL doesn't change.
  • When building your action links for subscribe/unsubscribe use drupal_get_destination() to append a return URL to your action link.

Other than that, I think this is getting close to a release. Thanks for your contributions.

Bagz’s picture

Status: Needs work » Needs review

Excellent suggestion regarding the menu callbacks. I have improved the code to do exactly as you suggest.
The good thing is that it also allowed me to streamline things a bit and cut out the function advanced_forum_basic_subscriptions_page as well as the the hook_menu_alter function as they were no longer required.

vensires’s picture

Status: Needs review » Needs work

I manually checked the code and couldn't find any particular errors. You seem to know how to properly use the db_query() function with the improvements found in the Drupal 7 version and that's really good. Knowing the tools you have in your possession and how to use them, makes you a better programmer by its own.

But make sure you clear the errors listed in http://ventral.org/pareview/httpgitdrupalorgsandboxbagz1465984git-7x-1x before settings this to "needs review". They are many and maybe boring at the beginning, but fixing these errors in my own project was more and more fun until the whole list cleared. I hope your list will also be empty as soon as possible and you will also have fun!

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.

klausi’s picture

Issue summary: View changes

fixed git branch