Overview

And UserPoints, OG, Rules integration.
Each og has own's userpoints branding.
When workflows changes with rules module, updating points to the og by og_group_ref.

Features

  • If og node create, automatic create term in userpoints category, and related to this og node.
  • Have a batch page, batch the old og node.
  • At the config page, you can customize userpoints category term 'name, this is userpoints branding in this og.
  • Rules integration, create actions in the rules, the new data selector is 'node:userpoints-og-tid', When workflows changes with rules module, updating points to the og by og_group_ref.
  • ...

Example

1)

A user in og1, og2, og3, he add a news to the og1 and add a comment to the og2, his og1 points increase 100 and og2 points decrease 20.

2)

Add a news(og content nodetype) to the og1, user in og1 points increase 100.

  • 1)Go to admin/config/workflow/rules/reaction/add, add rules.
  • 2)React on event, select optgroup of Node and Comment.
  • Node:
    -After deleting content
    -After saving new content
    -After updating existing content
    ...
    Comment:
    -A comment is viewed
    -After deleting a comment
    -After saving a new comment

  • 3)Add actions, Select the action is "grant points to a user".
  • 4)Data selector is "site:current-user", Points category is click
    the "Switch to data selection", if you event is "Node" optgroup,
    select "node:userpoints-og-tid", if you event is "Comment" optgroup,
    select "comment:node:userpoints-og-tid".
  • 5)Other settings according to your needs.

If action execute, points is add to the og userpoints category term tid.

Sandbox URL

https://www.drupal.org/sandbox/willietse/2294987

Git Repository

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/willietse/2294987.git

Code Review

http://pareview.sh/pareview/httpgitdrupalorgsandboxwillietse2294987git

Manual reviews of other projects:

https://www.drupal.org/node/2143157#comment-8931363
https://www.drupal.org/node/2295595#comment-8932427
https://www.drupal.org/node/2238015#comment-8941011
https://www.drupal.org/node/2275511#comment-8990151

Comments

willietse’s picture

Issue summary: View changes
willietse’s picture

Issue summary: View changes
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.

gisle’s picture

Status: Active » Needs review

"Active" is not used in this issue queue. You set status to "Needs review" to request a review.

willietse’s picture

Issue summary: View changes

I have a reviews. edit to body.

willietse’s picture

Assigned: willietse » Unassigned

Change assigned.

willietse’s picture

Issue summary: View changes

Example change.

willietse’s picture

Issue summary: View changes
willietse’s picture

Issue summary: View changes

Edit add PAReview: review bonus.

willietse’s picture

Title: UserPoints OG » [D7] UserPoints OG
willietse’s picture

Issue summary: View changes
willietse’s picture

Issue summary: View changes
willietse’s picture

Issue summary: View changes
willietse’s picture

er.pushpinderrana’s picture

@willietse, thanks for your contribution.

Your module looks good to me and given are my assumptions after manual review:

1. In .module file, following code use variable_get() function twice but it can be used once.

  $vid = variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '');
    if (!empty($vid) || taxonomy_vocabulary_load($vid)) {
      $term = (object) array(
        'name' => t('Points'),
        'vid' => variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, ''), // Use $vid variable here.
      );

Load $vid = variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, ''); once and use $vid at 102 line.

2. You are using batch api and defining same operation number of times in loop.

$operations = array();
  for ($i = 0; $i < ceil($node_count / 20); $i++) {
    $operations[] = array('userpoints_og_batch_old_group_op', array());
  }

I am not sure whether it's correct because it's looks like a wrong approach to define the same operation number of times. It is recommend at number of places, you should only add the operation once, and let the operation iterate over a set number of results.
please add your comment on this.

Rest looks good to me, thanks again!

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

Assigning to myself for next review.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Status: Needs review » Needs work
Issue tags: +PAreview: security

Automated Review

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

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: /home/matt/PAR/pareview_temp/userpoints_og.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     170 | WARNING | Format should be "* Implements hook_foo().", "* Implements
         |         | hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements
         |         | hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", or "*
         |         | Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.".
     171 | ERROR   | There must be exactly one blank line before the tags in a doc
         |         | comment
    --------------------------------------------------------------------------------
    
    
    
  • 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
What does this do that you can't do already with the Rules integration in OG?
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. Could be improved, though.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
No. If "no", list security issues identified.

In userpoints_og_config_edit_title(), $group->title is user input that needs to be sanitized. The proper thing to do here
is to pass $group->title as a parameter to the t() call instead of using string concatenation.

Coding style & Drupal API usage

Why is the PK in your schema composite? You only seem to be using nid as a condition, so I think only nid needs to be the PK.

You can add foreign key definitions to your hook_schema. D7 doesn't use them, but they can be handy for documentation.

In userpoints_og_requirements(), is using the `!` portable SQL? I honest't don't know.

Why the path check in userpoints_og_help? Comment needed.

Your helper functions need proper docblocks. See https://www.drupal.org/coding-standards/docs

The query in userpoints_og_config_load() is static, you can change this to a db_query(). See https://www.drupal.org/node/310072

The docblock on userpoints_og_entity_property_info_alter is incorrect; you don't need the 'on top of comment module'. See link above.

In userpoints_og_property_tid, is it always appropriate to use LANGUAGE_NONE for $node->og_group_ref instead of the node's language? Can you use the Field API for this?

(+) In userpoints_og_node_insert() and userpoints_og_batch_old_group_op(), when you save a new term, use the untranslated name. Translation gets done for output. This also appears in

In userpoints_og_node_insert(), you should check $term->tid and not just $term to see if the term actually saved.

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.

PA robot’s picture

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

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

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