This module can be used to implement a rating system based on external sources.
What that means is that the actual rate, vote or whatever action, happens on
an external application (for example on Facebook), and the results are fetched
into your system.

The module by itself provides a mechanism to register new external sources, that
are plugins and are managed using ctools, and it also gets the rating
results from the external sources. It has no frontend interface, so other modules
can and should use its API (actually, there are just a few functions at the moment
that can be called to register an entity for rating, to get a total rating, etc..).

Any type of entity can be rated. Moreover, there can be multiple ratings per
each entity (for example you can rate the same entity every day, so that you can
have a statistic per day for the ratings).

As mentioned, the module by itself does not have any frontend interface, it
has only a backend configuration. By default, it implements two external rating
sources: Facebook likes and Twitter tweets. To install the module, just go to the
Modules page and check the checkbox near it. After the module is installed,
a configuration form can be found here: Structure -> Entity External Rating.
From here, you can enable or disable certain plugins, and do some basic
configurations. Each plugin can have its own configuration form (click on the
edit link after each plugin name). The two default plugins have only the
API url that is used to get the ratings.

There is also an example module that demonstrates how to create a new plugin
in your custom modules.

The first step for using this module is to add entities into the rating queue.
You can do that using the function: entity_ext_rating_add_to_queue(). By doing
this you basically register an entity so that the module will try to get its rating
periodically at the next cronjobs. A very important parameter is the $rating_id.
This is different than the entity_id because you can have more ratings for the
same entity. Then, the $params contain any parameters that the external rating
system uses for rating. For example, for Facebook and Twitter, the URL is the
parameter. So, a real example of how to call the function:

<?php
entity_ext_rating_add_to_queue('node_100_1', 100, 'node', array('url' => 'http://www.example.com/node/100?day=1'), time()+86400);
?>

The last parameter is a timestamp that is used to determine when the entry will
be deleted from the queue, so no more calls will be made to the external rating
sources.

Then, you can get the total rating for a rating id, using the
entity_ext_rating_get_total_rating() function and you get get the html widgets
to be printed into the page, to allow your users to rate, vote, share, etc..
the entity.

The project page ca be found here: http://drupal.org/sandbox/vasi/1323440

Direct link to repository: git clone --branch master vasi@git.drupal.org:sandbox/vasi/1323440.git

The module is made right now only for Drupal 7, but back-porting to Drupal 6 should be really easy if needed.

CommentFileSizeAuthor
#1 coder-result.txt3.94 KBklausi

Comments

klausi’s picture

Status: Needs review » Needs work
StatusFileSize
new3.94 KB

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

  • Run coder to check your style, some issues were found (please check the Drupal coding standards). See attachment.
  • README.txt is missing, see the guidelines for in-project documentation.
  • Comments: there should be a space after "//".
    entity_ext_rating.admin.inc:22:  //Show a set of checkboxes to enable or disable the plugins.
    entity_ext_rating.admin.inc:34:  //Select field for defining the timeframe for checking the external rating.
    entity_ext_rating.admin.inc:53:  //Edit the batch size for the requests to get the external rating.
    ... many other places ...
    
  • ./includes/EntityExtRatingSource.inc: comment lines should break at 80 characters, see http://drupal.org/node/1354#general
        //Every time a plugin is instantiated, make sure we also load its configuration
    
  • ./entity_ext_rating.cron.inc: comment lines should break at 80 characters, see http://drupal.org/node/1354#general
        //VERY IMPORTANT, flag that we made the check, or we are already in a check process.
          //$plugin_call_time = timer_start('plugin_call_time_'.$plugin->sourceName());
    ... many other places ...
    
  • ./entity_ext_rating.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function entity_ext_rating_menu() {
    function entity_ext_rating_source_load($id) {
    function entity_ext_rating_theme() {
    ... many other places ...
    
  • ./includes/EntityExtRatingSource.inc: The description for the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    17-   *  A string identifying the plugin class name.
    --
    20-   */
    --
    134-   * If the plugin cannot handle more than one URL at a time, then the $params array
    ... many other places ...
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

manual review:

vasi1186’s picture

Status: Needs work » Needs review

Hi,

I did the changes you highlighted in the previous comment, also made a dev branch that I am using now for working. One question for this: "all functions should be prefixed with your module/theme name to avoid name clashes". I actually could not find a function that does not start with "entity_ext_rating". Can you give me an example?

The other observations can be checked again.

attiks’s picture

Status: Needs review » Needs work

Automated test results:

coder on minor
I noticed some very small code style issues. Please run the Coder module on "minor" setting to help catch these. The coding standards have even more information in this area. I noticed things like ...

Please note: The Coder module currently has an unresolved flaw which will prompt you to add file declarations to your .info file even when it's not necessary to do so. Please do not try to make this warning go away by declaring files which do not contain classes or interfaces.

Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards

/entity_ext_rating.admin.inc:
 +23: [minor] There should be no trailing spaces
 +67: [critical] table names should be enclosed in {curly_brackets}

Status Messages:
 Coder found 13 projects, 13 files, 1 critical warnings, 1 minor warnings, 0 warnings were flagged to be ignored

coder_tough_love and comments on minor
This is optional.
Severity minor, Project application tests - Comments, Coder Tough Love

/plugins/TwitterRating.inc:
 +4: [minor] All comments should end with a ".".
 +5: [minor] All comments should end with a ".".
 +15: [normal] Separate comments from comment syntax by a space.
 +26: [minor] All comments should end with a ".".
 +29: [normal] Use sentence case, not title case, for end-user strings. (Wikipedia)
 +40: [minor] All comments should end with a ".".
 +50: [minor] All comments should end with a ".".
 +50: [normal] @param and @return syntax should not indicate the data type.
 +51: [minor] All comments should end with a ".".
 +54: [minor] All comments should end with a ".".
 +58: [minor] All comments should end with a ".".
 +59: [minor] All comments should end with a ".".
 +68: [minor] All comments should end with a ".".
 +69: [minor] All comments should start capitalized.
 +69: [minor] All comments should end with a ".".
 +81: [minor] All comments should end with a ".".
 +81: [normal] @param and @return syntax should not indicate the data type.
 +82: [minor] All comments should end with a ".".
 +85: [minor] All comments should end with a ".".
 +91: [minor] All comments should end with a ".".

/plugins/FacebookRating.inc:
 +4: [minor] All comments should end with a ".".
 +5: [minor] All comments should end with a ".".
 +14: [minor] All comments should end with a ".".
 +25: [minor] All comments should end with a ".".
 +28: [normal] Use sentence case, not title case, for end-user strings. (Wikipedia)
 +39: [minor] All comments should end with a ".".
 +49: [minor] All comments should end with a ".".
 +49: [normal] @param and @return syntax should not indicate the data type.
 +50: [minor] All comments should end with a ".".
 +53: [minor] All comments should end with a ".".
 +57: [minor] All comments should end with a ".".
 +58: [minor] All comments should end with a ".".
 +87: [minor] All comments should end with a ".".
 +87: [normal] @param and @return syntax should not indicate the data type.
 +88: [minor] All comments should end with a ".".
 +91: [minor] All comments should end with a ".".

/themes/entity_ext_rating_twitter_widget.tpl.php:
 +4: [minor] All comments should end with a ".".
 +8: [normal] Use the matching Drupal theme functions, not raw HTML.

/themes/entity_ext_rating_facebook_widget.tpl.php:
 +4: [minor] All comments should end with a ".".

/includes/EntityExtRatingSourceInterface.inc:
 +4: [minor] All comments should end with a ".".
 +10: [minor] All comments should end with a ".".
 +11: [minor] All comments should end with a ".".
 +37: [minor] All comments should end with a ".".
 +43: [minor] All comments should end with a ".".
 +49: [minor] All comments should end with a ".".

/includes/EntityExtRatingSource.inc:
 +4: [minor] All comments should end with a ".".
 +5: [minor] All comments should end with a ".".
 +7: [normal] Remove the empty commented line in your function documentation.
 +11: [minor] All comments should end with a ".".
 +17: [minor] All comments should end with a ".".
 +17: [normal] @param and @return syntax should not indicate the data type.
 +20: [minor] All comments should end with a ".".
 +21: [minor] All comments should end with a ".".
 +38: [minor] All comments should end with a ".".
 +39: [minor] All comments should start capitalized.
 +39: [minor] All comments should end with a ".".
 +74: [minor] All comments should end with a ".".
 +98: [minor] All comments should end with a ".".
 +116: [minor] All comments should end with a ".".
 +116: [normal] @param and @return syntax should not indicate the data type.
 +119: [minor] All comments should end with a ".".
 +119: [normal] @param and @return syntax should not indicate the data type.
 +122: [minor] All comments should end with a ".".
 +122: [normal] @param and @return syntax should not indicate the data type.
 +125: [minor] All comments should end with a ".".
 +125: [normal] @param and @return descriptions begin indented on the next line.
 +135: [minor] All comments should end with a ".".
 +142: [minor] All comments should end with a ".".
 +147: [minor] All comments should end with a ".".
 +150: [minor] All comments should end with a ".".
 +150: [normal] @param and @return syntax should not indicate the data type.
 +151: [minor] All comments should end with a ".".
 +152: [minor] All comments should end with a ".".
 +153: [minor] All comments should end with a ".".
 +155: [minor] All comments should end with a ".".
 +157: [minor] All comments should end with a ".".
 +160: [minor] All comments should end with a ".".
 +162: [minor] All comments should end with a ".".
 +165: [minor] All comments should end with a ".".
 +182: [minor] All comments should end with a ".".
 +183: [minor] All comments should end with a ".".
 +186: [minor] All comments should end with a ".".
 +186: [normal] @param and @return descriptions begin indented on the next line.
 +187: [minor] All comments should end with a ".".
 +189: [minor] All comments should end with a ".".
 +193: [minor] All comments should end with a ".".
 +194: [minor] All comments should end with a ".".
 +195: [minor] All comments should end with a ".".

/plugin_example/entity_ext_rating_plugin/ExamplePlugin.inc:
 +4: [minor] All comments should end with a ".".
 +8: [minor] All comments should end with a ".".
 +9: [minor] All comments should start capitalized.
 +9: [minor] All comments should end with a ".".
 +16: [minor] All comments should end with a ".".
 +21: [minor] All comments should end with a ".".
 +34: [minor] All comments should end with a ".".

/plugin_example/entity_ext_rating_plugin/entity_ext_rating_plugin.module:
 +-1: [minor] @file doc block is missing
 +4: [minor] All comments should end with a ".".
 +12: [minor] All comments should end with a ".".

/entity_ext_rating.cron.inc:
 +6: [minor] All comments should end with a ".".
 +14: [minor] All comments should end with a ".".
 +15: [minor] All comments should end with a ".".
 +20: [minor] All comments should end with a ".".
 +23: [minor] All comments should end with a ".".
 +25: [minor] All comments should end with a ".".
 +26: [minor] All comments should start capitalized.
 +26: [minor] All comments should end with a ".".
 +28: [minor] All comments should end with a ".".
 +31: [minor] All comments should end with a ".".
 +36: [minor] All comments should end with a ".".
 +37: [minor] All comments should end with a ".".
 +38: [minor] All comments should start capitalized.
 +38: [minor] All comments should end with a ".".
 +48: [minor] All comments should end with a ".".
 +50: [minor] All comments should end with a ".".
 +51: [minor] All comments should start capitalized.
 +51: [minor] All comments should end with a ".".
 +52: [minor] All comments should end with a ".".
 +59: [minor] All comments should end with a ".".
 +60: [minor] Lines in comments should not exceed 80 characters.
 +61: [minor] Lines in comments should not exceed 80 characters.
 +63: [minor] All comments should end with a ".".
 +64: [minor] Lines in comments should not exceed 80 characters.
 +67: [minor] All comments should end with a ".".
 +68: [minor] All comments should end with a ".".
 +71: [minor] All comments should end with a ".".
 +72: [minor] All comments should start capitalized.
 +72: [minor] All comments should end with a ".".
 +73: [minor] All comments should start capitalized.
 +73: [minor] All comments should end with a ".".
 +78: [minor] All comments should end with a ".".
 +79: [minor] All comments should end with a ".".
 +80: [minor] All comments should end with a ".".
 +92: [minor] Lines in comments should not exceed 80 characters.
 +92: [minor] All comments should start capitalized.
 +92: [minor] All comments should end with a ".".
 +95: [minor] All comments should end with a ".".
 +96: [minor] Lines in comments should not exceed 80 characters.
 +99: [minor] All comments should end with a ".".

/entity_ext_rating.install:
 +4: [minor] All comments should end with a ".".
 +9: [minor] All comments should end with a ".".
 +11: [normal] If you define a @param or @return, you should document it as well.
 +11: [normal] @param and @return syntax should not indicate the data type.

/entity_ext_rating.module:
 +-1: [minor] @file doc block is missing
 +7: [minor] All comments should end with a ".".
 +11: [normal] Use sentence case, not title case, for end-user strings. (Wikipedia)
 +18: [normal] Administrative menu items should have a description.
 +19: [normal] Use sentence case, not title case, for end-user strings. (Wikipedia)
 +30: [minor] All comments should end with a ".".
 +30: [normal] Function summaries should be one line only.
 +31: [minor] All comments should start capitalized.
 +33: [minor] All comments should end with a ".".
 +42: [minor] All comments should end with a ".".
 +58: [minor] All comments should end with a ".".
 +67: [minor] All comments should end with a ".".
 +80: [minor] All comments should end with a ".".
 +90: [minor] All comments should end with a ".".
 +91: [minor] All comments should end with a ".".
 +92: [minor] All comments should start capitalized.
 +103: [minor] All comments should end with a ".".
 +111: [minor] All comments should end with a ".".
 +114: [minor] All comments should end with a ".".
 +114: [normal] Doxygen uses @todo and @bug to markup things to be done.
 +115: [minor] All comments should start capitalized.
 +115: [minor] All comments should end with a ".".
 +131: [minor] All comments should end with a ".".
 +136: [minor] All comments should end with a ".".
 +136: [normal] If you define a @param or @return, you should document it as well.
 +136: [normal] @param and @return syntax should not indicate the data type.
 +139: [minor] All comments should end with a ".".
 +139: [normal] If you define a @param or @return, you should document it as well.
 +139: [normal] @param and @return syntax should not indicate the data type.
 +142: [minor] All comments should end with a ".".
 +142: [normal] If you define a @param or @return, you should document it as well.
 +142: [normal] @param and @return syntax should not indicate the data type.
 +143: [minor] All comments should end with a ".".
 +145: [minor] All comments should end with a ".".
 +145: [normal] If you define a @param or @return, you should document it as well.
 +145: [normal] @param and @return syntax should not indicate the data type.
 +146: [minor] All comments should end with a ".".
 +147: [minor] All comments should start capitalized.
 +147: [minor] All comments should end with a ".".
 +148: [minor] All comments should start capitalized.
 +150: [minor] All comments should end with a ".".
 +150: [normal] If you define a @param or @return, you should document it as well.
 +150: [normal] @param and @return syntax should not indicate the data type.
 +151: [minor] All comments should end with a ".".
 +152: [minor] All comments should start capitalized.
 +155: [minor] All comments should end with a ".".
 +189: [minor] All comments should end with a ".".
 +189: [normal] @param and @return syntax should not indicate the data type.
 +192: [minor] All comments should end with a ".".
 +206: [minor] All comments should end with a ".".
 +206: [normal] @param and @return syntax should not indicate the data type.
 +207: [minor] All comments should end with a ".".
 +208: [minor] All comments should start capitalized.
 +210: [minor] All comments should end with a ".".
 +210: [normal] @param and @return syntax should not indicate the data type.
 +211: [minor] All comments should end with a ".".
 +212: [minor] All comments should start capitalized.
 +214: [minor] All comments should end with a ".".
 +218: [minor] All comments should end with a ".".
 +227: [minor] All comments should end with a ".".
 +228: [minor] All comments should start capitalized.
 +228: [minor] All comments should end with a ".".

/entity_ext_rating.admin.inc:
 +4: [minor] All comments should end with a ".".
 +12: [minor] All comments should end with a ".".
 +22: [normal] Function summaries should be one line only.
 +23: [minor] All comments should end with a ".".
 +24: [minor] All comments should end with a ".".
 +24: [normal] @param and @return syntax should not indicate the data type.
 +25: [minor] All comments should end with a ".".
 +26: [minor] All comments should start capitalized.
 +28: [minor] All comments should end with a ".".
 +32: [minor] All comments should end with a ".".
 +44: [minor] All comments should end with a ".".
 +63: [minor] All comments should end with a ".".
 +71: [minor] All comments should end with a ".".
 +72: [minor] All comments should start capitalized.
 +72: [minor] All comments should end with a ".".
 +81: [minor] All comments should end with a ".".
 +82: [minor] All comments should end with a ".".
 +95: [minor] All comments should end with a ".".
 +95: [normal] If you define a @param or @return, you should document it as well.
 +95: [normal] @param and @return syntax should not indicate the data type.
 +96: [minor] All comments should end with a ".".
 +99: [minor] All comments should end with a ".".
 +103: [minor] All comments should end with a ".".
 +105: [minor] All comments should end with a ".".
 +106: [minor] All comments should end with a ".".
 +107: [minor] All comments should end with a ".".
 +118: [minor] All comments should end with a ".".
 +118: [normal] If you define a @param or @return, you should document it as well.
 +118: [normal] @param and @return descriptions begin indented on the next line.
 +119: [minor] All comments should end with a ".".
 +120: [minor] All comments should end with a ".".
 +123: [minor] All comments should end with a ".".
 +137: [minor] All comments should end with a ".".
 +146: [minor] All comments should end with a ".".

/entity_ext_rating.plugins.inc:
 +3: [minor] All comments should end with a ".".
 +10: [minor] All comments should end with a ".".
 +11: [minor] All comments should end with a ".".
 +12: [minor] All comments should start capitalized.
 +12: [minor] All comments should end with a ".".

Status Messages:
 Coder found 13 projects, 13 files, 42 normal warnings, 201 minor warnings, 0 warnings were flagged to be ignored

vasi1186’s picture

Status: Needs work » Needs review

I made a commit where I tried to solve these minor warnings, but for some of them (for example 'All comments should end with a ".".') the problem is that there are comments that span multiple lines and I used '//' for commenting. Probably the solution would be to use the multiple line comments (/* */), but is this a real must? because I have seen in many places in the Drupal core the '//' comments on multiple lines.

Then, there is a warning: "table names should be enclosed in {curly_brackets}" in entity_ext_rating.admin.inc, but I actually do not use any table name there... On the other hand, I solved a lot of minor warnings, changed quite a lot the commenting style of the functions so I think you can check it again.

Thank you.

attiks’s picture

You can ignore the warnings about the comments, our automated system is still a bit beta, the table name warning can also be ignored, since there's no table there, no idea what caused this to popup.

I had a quick look at the code, and it looks very solid, the problem is that it isn't easy to test, do you perhaps have a demo somewhere?

vasi1186’s picture

I don't have yet a demo (actually I have one but not allowed yet to publish it) so I will make another demo tomorrow and then you can have a look. I'll come back when the demo is done.

klausi’s picture

Status: Needs review » Needs work

Review of the 7.x-1.x branch:

  • Run coder to check your style, some issues were found (please check the Drupal coding standards):
    Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards
    
    sites/all/modules/pareview_temp/test_candidate/plugins/TwitterRating.inc:
     +51: [minor] @see should always be followed by a filename, a URL, class/interface name (optionally including method), or a function name including ().
     +51: [minor] @see references should be separated by "," followed by a single space and with no trailing punctuation
    
    sites/all/modules/pareview_temp/test_candidate/plugins/FacebookRating.inc:
     +50: [minor] @see should always be followed by a filename, a URL, class/interface name (optionally including method), or a function name including ().
     +50: [minor] @see references should be separated by "," followed by a single space and with no trailing punctuation
    
    sites/all/modules/pareview_temp/test_candidate/plugin_example/entity_ext_rating_plugin/ExamplePlugin.inc:
     +34: [minor] There should be no trailing spaces
     +50: [minor] @see should always be followed by a filename, a URL, class/interface name (optionally including method), or a function name including ().
     +50: [minor] @see references should be separated by "," followed by a single space and with no trailing punctuation
    
    sites/all/modules/pareview_temp/test_candidate/entity_ext_rating.admin.inc:
     +67: [critical] table names should be enclosed in {curly_brackets}
    
    Status Messages:
     Coder found 1 projects, 12 files, 1 critical warnings, 7 minor warnings, 0 warnings were flagged to be ignored
    
  • Lines in README.txt should not exceed 80 characters, see the guidelines for in-project documentation.
  • @file doc block is missing in the module file, see http://drupal.org/node/1354#files .
  • ./entity_ext_rating.cron.inc: comment lines should break at 80 characters, see http://drupal.org/node/1354#general
          // $plugin_call_time = timer_start('plugin_call_time_'.$plugin->sourceName());
          // $plugin_call_time = timer_stop('plugin_call_time_'.$plugin->sourceName());
        // watchdog('entity_ext_rating', 'Getting external ratings for entities was successful.');
    
  • ./includes/EntityExtRatingSource.inc: The description for the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    17-   *  A string identifying the plugin class name.
    150-   * If the plugin cannot handle more than one URL at a time, then the $params
    
  • ./entity_ext_rating.module: The description for the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    137- *  A unique identifier for the entry.
    140- *  The id of the entity.
    143- *  The type of the entity, for example "node" or "user".
    146- *  Any parameters that have to be used by the plugins to query the external
    151- *  An integer value representing the timestamp when this entry will not be
    
  • ./entity_ext_rating.admin.inc: The description for the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    96- *  The rating source plugin meta infomation, usually obtained after a call
    119- *  A plugin object, obtained after instatiating a class that implements the
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

manual review:

  • @param/@return can indicate the type, why did you remove that? The docs say "The data type of a parameter or return value MUST be specified in @param or @return directives, if it is not obvious or of a specific class or interface type." -- http://drupal.org/node/1354#functions
  • entity_ext_rating_menu(): your module should create its own permission and should not abuse "administer site configuration".
  • entity_ext_rating_theme(): indentation error on the array structure, always use 2 spaces per level.
  • entity_ext_rating_get_plugin(): the @return description should be indented on the second line. Also for other @param/@return descriptions on other functions.
  • "Implements hook_entity_ext_rating_plugins()": so you declare your own hooks somewhere? Would be cool to document that in a .api.php file, see also http://drupal.org/node/1354#hooks
  • entity_ext_rating.cron.inc: @file doc block should be at the top before any define() calls.
  • "Class constructor.": a little too obvious. does not provide any helpful information, so either remove the comment or replace it with something useful.
  • entity_ext_rating_facebook_widget.tpl.php: you are embedding a variable that must be a valid URL. Use check_url() to make sure you are actually getting a URL and to avoid XSS (I don't know if $params could be user generated data at this point).
  • same for entity_ext_rating_twitter_widget.tpl.php
  • the project page is a little overwhelming, tips for a great project page

Otherwise I'm pretty happy with the code base. Looks pretty clean and well documented. You seem to know all sorts of Drupal APIs already, so if you fix this minor issues you get a green light from me.

vasi1186’s picture

Hi again,

I created a demo page here: http://drupaldemos.net/entity_ext_rating

I know it is a bit hard to test the functionality... What you can see there is a view of articles that can be sorted by their rating. Now, the module itself is not integrated yet directly with the views module, so you cannot just put a filter from the view settings. The main purpose of the module at the moment is just to fetch the data from the different sources, and aggregate it afterwards. Then, you can do whatever you want with the results (I am thinking now to also write a module where I can show how this module can be used in live applications). What I did on the demo site was to create a field on the article content type, then update the field at cron with the data provided by the Entity External Rating module. In this way, I was able to create the filter. I also injected the rating widgets into the node full and teaser views. But these things I did from another custom module.

The ratings update occurs at cron, so for testing you will have to run the cron to have the latest results: http://drupaldemos.net/entity_ext_rating/cron.php?cron_key=20FQWMa1jQ1xA...

I've noticed that the facebook rates are updated in real time. If you click on the Like button, then run the cron, the values are immediately there. But, for twitter I saw that there are some strange delays sometimes... So, if you tweet, then also the counter for the button is not updated instantly, and the same happens with the results from their API. So, for twitter, the behavior can be quite strange in the beginning, but after a while, the results should be correct.

So, short summary for testing: click on facebook like and tweet buttons, then run the cron and then see the results (with the mention that the twitter results are not accurate immediately, so you may need to run the cron several times).

If you want to check the backend, I can make you an admin account. But, basically, from the backend you can just enable or disable certain plugins, edit the API URLs for them, and make some other small settings.

For the remaining issues, pointed in the last comment, I will try to solve them until tomorrow evening.

vasi1186’s picture

Status: Needs work » Needs review

I made again a commit with the latest changes that I made in the code. For

entity_ext_rating_facebook_widget.tpl.php: you are embedding a variable that must be a valid URL. Use check_url() to make sure you are actually getting a URL and to avoid XSS (I don't know if $params could be user generated data at this point).
same for entity_ext_rating_twitter_widget.tpl.php

I actually used urlencode(drupal_strip_dangerous_protocols()) because otherwise I was not able to use any query parameters in the link. And as I saw, the check_url uses also drupal_strip_dangerous_protocols() to prevent xss.

Then, the hook_entity_ext_rating_plugins() is called because I use the ctools plugin feature, so it is not like a hook created by my module. My module actually defines another hook, that is invoke right after the ratings are fetched from the external sources, so I added it in the api file. Should I also add the hook_entity_ext_rating_plugins()?

I also don't know what to repair for the @see references... I checked the doxygen and it looks ok to me...

I will also try to change the project page, I know it looks a bit overwhelming, I will think to a shorter and more concise description of the project.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Review of the 7.x-1.x branch:

  • ./includes/EntityExtRatingSource.inc: The description on the line after the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    17-   *  A string identifying the plugin class name.
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

manual review:

  • I think coder complains about the @see documentation because you append a description at the end. @see should stand on its own and you should do a description before.
  • yes, I think hook_entity_ext_rating_plugins() is also suitable for .api.php
  • Sorry, as urlencode() transforms dangerous characters anyway you are safe to output it this way. My mistake, check_url() does not fit here.

Otherwise I think this is RTBC.

vasi1186’s picture

Made the changes in the api file and also for the @see comments, but the warning is still there. May be that the file that implements the class is declared in the .info file, and thus is not loaded unless the class is instantiated?
So I think the only remained issue so far is to change a bit the project description page, which I hope to finish these days.

greggles’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, vasi1186! Welcome to the community of project contributors on drupal.org.

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

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.

As you continue to work on your module, keep in minde: Commit messages - providing history and credit and Release naming conventions.

Status: Fixed » Closed (fixed)

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

milenpat’s picture

Hi, I'm a relative newbie but understand the basics of Drupal. I have a project that would really benefit from your module but have no clue how to impliment it without the use of Views. Is there any way you could give me a quick run down on how I can actually impliment entitny external rating.

Thanks in advance.

This is a really useful module!

vasi1186’s picture

If you want to use the module without Views, then all what you have to do in your custom module is:
1. add nodes (or whatever other entities) to the rating queue.
2. use the rating table in your custom queries.
3. Show the widgets somewhere on your pages.

For 1: you have to use this function:

entity_ext_rating_add_to_queue()

For example:

entity_ext_rating_add_to_queue('article_' . $node_id, $node_id, 'node', array('url' => $url), $expire_time);

The first parameter is a sort of key, you can generate it how you want, but if you want to track nodes, it should somehow contain the node id, to be sure it is unique.
The second parameter is the id of the entity, and the third is the entity type.
The forth parameter is an array with special settings for each plugin. Right now, the only setting used by all is the url, that has to be queried. I suggest you do not use the url() function to generate it, because if you have url aliases you may experience some issues. I think something like this should work:

global $base_url;
$url = $base_url.'/node/'.$node_id;

The last parameter is a timestamp, that tell the system when it should stop querying the external system for new results. If is set to 0, it should query all the time.

For 2, just use the entity_ext_rating_total table to get the results.

For 3, to print the widgets, for example for a certain URL and some title (used by the Twitter plugin), you have this function:

entity_ext_rating_get_html_widgets(array('url' => $url, 'title' => $node->title))

Again, I suggest to not use the url() fuction to generate urls for nodes.

Hope this helps to understand how to use the module. If any other questsions, I'll be happy to answer them :)

vasi1186’s picture

Also, here is the project page ( https://drupal.org/project/entity_external_rating ) but probably you know it already.

patrickd’s picture

This issue is closed

Please do not use it for further discussions, if you have questions open a new issue in the project's issue queue!

milenpat’s picture

Hi thanks for the prompt reply. I appreciate it.

I'm clearly going to need to take a bit of time and have a play around custom modules etc. and see if I can figure out a way to get this working for me.

Thanks for the offer of further help. Will no doubt take you up on it at some point soon. Thanks.

milenpat’s picture

Hi,

sorry but this beyond my skills at the moment.

Ideally I would like to integrate this module with views if possible.

The things I don't understand is what you mean by, "custom module" do I need create a futher module that takes the information from EER and then displays it on my selected nodes?

Or use it in conjunction with another module?

Or do I need to edit the module file in the EER folder get it to display in a block that I then place where needed?

From the info so far it seems that you use the field inputs when creating content types and then call up the widgets to display the results. I'm sorry but I don't know how to do this, and going through all the combinations on my content creation pages hasn't brought me any closer.

Further more I would like to some how integrate some kind of user points into the overall score delivered. Is this a complicted thing to do? How could I start getting somewhere on this.

Would be great if you could just clarify these things for me or at least point me in the direction of where I can find out how to get this done. I'd like to make it an integral part of my website.

Thanks in advance for any help.

milenpat’s picture

Hi,

Could someone just drop a quick note about how to integrate this module into Views.

You say this done using custom module that populates fields in your content type.

How can you achieve this?

Thanks