I needed a way for users to rate and provide feedback for articles similar to the way Microsoft TechNet or SitePoint and others do.

I started writing another module I was going to call "Node Feedback" (since "Feedback" is already taken) and then I realized you have already coded 85% of what I needed here, but there were still several small things that needed to change before I could use it.

Before I explain, I want to stress that I saw your module before and passed it up a couple times. The first time, I thought "User Review" meant it would be something like MySpace Comments, or HotOrNot.com. The second time, after reading into it, I realized what it actually was and also realized that you can accomplish the same thing using the jRating + Node Comment + CCK + Views modules which is much more flexible and aesthetic.

Things this patch changes, and my reasoning:

  • The javascript stuff was removed completely; it is non-conventional, ugly, and most importantly annoying.
  • The 0-10 rating became a 1-10 rating using conventional radio buttons instead of a select drop-down or the crazy js stuff that was there before.
  • "Userreview" became "User review"; without the space it's difficult to read and this is not the format used by most other modules (e.g. Book, Simplenews, etc.).
  • "review" became "Review"; capitalize proper nouns--your module's name is a proper noun.
  • The module's hook_node_info() description became substantially shorter, without the use of HTML; it's easier to read, and less annoying since Drupal was replacing it with HTML entities.
  • Two new permissions were added: 'create user reviews' and 'edit own user reviews'. In my case, the feedback is private and will only be viewed by the node's author. Also, the average rating is not going to be shown to everyone--only subscribed users.
  • Use node_get_types() to determine the Title textfield label, and the Body textarea label; I needed it to change the hard-coded 'Comments' label, and what you provided was too generic to use localization. Besides, it's just good practice. Now I can change it from Administer > Content Types > User review: Edit > Body title
  • Removed the description of the Body textarea; it wasn't something I could change from the Administration and I didn't like how it stated the obvious, so I removed it for simplicity. If you decide to keep it, you ought to provide a way to change it in admin/settings/userreview.
  • Added a 'userreview-form' class to the review form so that I could apply CSS styles to it and its child elements; there's probably other ways to accomplish this, but it works for me.

This changes may seem radical if this isn't the direction you were heading with the module, but it sort of seems like it, so I hope this helps!

CommentFileSizeAuthor
patch_156.txt8.92 KBms2011

Comments

ms2011’s picture

I forgot to add that in order to get it like TechNet and SitePoint, I needed to use two other modules in combination:

Automatic Nodetitles
http://drupal.org/project/auto_nodetitle

I used this to hide the Title field.

Filter by Node Type
http://drupal.org/project/filterbynodetype

I created a new Input Format filter called "Plain-text" which essentially does nothing to the text, and I set it as the default Input Format. Then I used this module to make it the only input format available to Userreview node types. This eliminates the Input Format collapsible fieldset for the simplistic approach I am going for.

csc4’s picture

Have you had any feedback on your proposals?

Would you be willing to post your revised version as a download for those of us rather patch limited?

jonnyp’s picture

I realized what it actually was and also realized that you can accomplish the same thing using the jRating + Node Comment + CCK + Views modules which is much more flexible and aesthetic.

Could you elaborate on the jrating + node comment solution? Wouldn't this mean each comment gets rated and not the node itself? How would you display an average rating? I'm looking for a neat way of offering either a full review or a quick rating option to the users but i'm not sure exactly how to do it. I guess you could put jRating on the node and rename the node comment type to review, but the module says it doesn't work in combination with the existing comments module which is a bit of a pain if you already use comments on other content types..

summit’s picture

Hi,

I used your altered code to be able to show the user reviews also to anonymous users, thanks for this.
Can this please be implemented in .dev, because this way my anonymous users can also see the reviews, and it is nicely been done through the admin interface.

I have one problem, though using this new code (and also with the .dev version).
When a anonymous user has made 1 user review, no other anonymous user can make a review. The line "Your Review" is then placed in the form, instead of the possibility to add a new review.
Please assist how to change this.

EDIT: I have something working. See beneath altered code for anonymous users:

function get_userreview_node($content_node, $uid = 0, $default = false) {
  global $user;
  $sql = 'select nid from {userreview} where content_id = %d and uid = %d';
  $result = db_fetch_object(db_query($sql, $content_node->nid, $uid));
+ //Added to be able to add more than one anonymous user review
+ if ($uid !== 0) {
    if (!$result) return $default;
    $userreview_node = node_load($result->nid);
    if ($uid == $user->uid) {
      $display_title = variable_get('userreview_currentuser_label', t('Your Review'));
    } else {
      $display_title = variable_get('userreview_otheruser_label', t('Review of %node_type: %node_title by %user_name'));
    }
    $display_title = str_replace('%node_type', node_get_types('name', $content_node), $display_title);
    $display_title = str_replace('%node_title', $content_node->title, $display_title);
    if (strpos($display_title, '%user_name') >= 0) {
      $user_criteria = array('uid'=>$uid);
      $reviewer_obj = user_load($user_criteria);
      $display_title = str_replace('%user_name', $reviewer_obj->name, $display_title);
    }
    $userreview_node->userreview_label = check_plain($display_title);
    return $userreview_node;
+  }
+  else {return $default;}
}

Is this the only place I have to look for the uid=0 [Anonymous user]?

Thanks in advance for your reply!
greetings,
Martijn

pomliane’s picture

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

This version of userreview is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.