Synopsis

Hovercard is a module which is based on hovercard which is a free light weight jQuery plugin that enables you to display related information with the hovered label, link, or any html element of your choice. This module extends Drupal to provide Hovercard for the users of the website.

  • Easy to install and use.
  • Works on all user links with username as their class.
  • Simply install it and see the magic!

Special thanks to Prashant Chaudhary for such a charming jQuery Hovercard Plugin!

Project Page

This is the project page link for Hover Card

Clone Repository

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/RishiKulshreshtha/2308117.git hover_card

Dependencies

Installation

The Hover Card module is very similar to other Drupal modules which requires Libraries Module to use for the 3rd party code integration. Hence, for installation of the Hover Card module please follow the below mentioned steps:

  1. Install as usual, see https://www.drupal.org/node/1294804 for further information.
  2. Download and install the Libraries Module - 2.x and after the module installation create a new folder called libraries under your sites/all/ folder. (Creating this folder will help us to locate our 3rd party code integration.)
  3. Download the compressed version of jQuery Hovercard Plugin and extract the files into sites/all/libraries/hover_card/
  4. Now, in your sites/all/modules/sandbox/ directory download the Hover Card module using GIT clone code git clone --branch 7.x-1.x http://git.drupal.org/sandbox/RishiKulshreshtha/2308117.git hover_card.
  5. Enable the Hover Card module.

Configuration

  • After enabling it please check your admin/reports/status where there should a new option showing Hover Card Plugin - v1.0 installed with a success (Green) status.
  • This module has menu or modifiable settings. There is configuration link for this which you can access at admin/config/people/hover-card. When enabled and configured properly, this module will display the hover card to the user links with 'username' as class to their anchor tags. To disable the hover card from user links, disable the module and clear caches.

Code Review

pareview.sh

There is a similar sandbox project called User Hover Card by Yannick Leyendecker which is dependent on Tipsy module. This module displays the user detail on a tooltip.

Preview

Module Preview on Bartik Theme

Reviews of other projects

https://www.drupal.org/node/2256993#comment-9196695
https://www.drupal.org/node/2347967#comment-9198771
https://www.drupal.org/node/2086333#comment-9193001
https://www.drupal.org/node/1914020#comment-9192875
https://www.drupal.org/node/2328917#comment-9235289
https://www.drupal.org/node/2370863#comment-9330763
https://www.drupal.org/node/2369363#comment-9333113

Comments

rishi.kulshreshtha’s picture

Issue summary: View changes
PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxRishiKulshreshtha2308...

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.

rishi.kulshreshtha’s picture

Issue summary: View changes
Priority: Normal » Major
Status: Needs work » Needs review

As per the automated message, I've fixed all of the errors from the error list. Thanks.

sawtell’s picture

Status: Needs review » Needs work

Hi Rishi,

As your module is using a 3rd party library, you should look at using the Libraries module to include the hovercard plugin. https://www.drupal.org/project/libraries

I'm not sure what the best practice is for callback URL structures but you may want to change this to reduce the chances of a conflict with content aliases.

hover_card.js

Including a CSS file rather than inline styles would be preferable.

Lastly, you may want to consider using theme functions to return the contents of the hover card. This will allow developers to alter the display without need to hack the module.

Good luck with your submission,

Louis

rishi.kulshreshtha’s picture

Issue summary: View changes

Updated the Description of the page according to the new version.

rishi.kulshreshtha’s picture

Status: Needs work » Needs review

I've implemented solutions for all the mentioned points by Louis (ls206).

Thanks for sharing them! :-)

laceysanderson’s picture

Status: Needs review » Needs work

Hi Rishi,

Automated Review

You still need to set the default branch of your repository. To do this edit your sandbox project and click on the green "Default branch" tab near the top. Then just select the 7.x-1.x branch and save. Other than that the review is clean :)

Manual Review

Individual user account: Yes.
Master Branch: Follows guidelines. Mentioned setting the default branch above.
Licensing: None included (Follows guidelines).
3rd party code: Doesn't look to contain any. Uses the Libraries API to load an external jQuery library.
README.txt/README.md: You should add a configuration section even if no configuration is needed; See https://www.drupal.org/node/2181737 under "Configuration".
Security: Not any that I see...
Code long/complex enough for review: Yes. Meets minimum requirement of 5 functions and >120 lines.
Coding style & Drupal API usage: Passes the automated reviews. Also, uses the libraries API and various other Drupal hooks.

In reference to the hover_card() callback:
I think the description of this callback isn't as clear as it could be. What you appear to be doing is using "Drupal Magic" to fetch the user data via the Menu System %user argument and then rendering that content into a hover card. There does not appear to be any JSON involved. Also, you use the $user_fields variable when you should use the $user variable to make it clear that this is the $user object loaded via the menu system. The code on lines 98-100 looks incorrect/brittle to me - a short comment could go a long way here. What do you expect to be in the second position of the users roles & how are you sure it will always be there? Also, I think the brackets around $value are unnecessary; is this correct?

Additional Minor Comments

  • Your template file could use some additional whitespace to keep the line length closer to 80 characters. Also, why do you feel the need to not include the footer? Could you add a comment in the code explaining the use of this very rarely used function: drupal_exit()?
  • You should add a file doc block to your JS file. Furthermore, in-line comments do wonders for making jQuery readable ;-)
rishi.kulshreshtha’s picture

Issue summary: View changes

Updating the Description as per the changes.

rishi.kulshreshtha’s picture

Status: Needs work » Needs review

Thanks for such a good and detailed review Lacey Sanderson. I'll always appreciate your effort :-)

I've implemented the changes according to the Automated Review provided by you.

Regarding the Manual Review:

  • Fixed README.txt, added a new section called CONFIGURATION and also made the required changes essential in the README.txt according to this node https://www.drupal.org/node/2181737
  • I really apologize for the old/incorrect description of the hover_card() callback I've replaced this with the new one, please check.
  • I've fixed the $user_fields to $user (For making it clear that this is the $user object loaded via the menu system)
  • For line no 98-100, as we know in Drupal for Authenticated User the default ID is set to [2], since the hover card is going to work only for the Authenticated User indeed we're not willing to show the users that they are Authenticated User too. Hence we're disabling [2] => authenticated user from our list.
  • Removed unnecessary round brackets from $value on line no. 103
  • For drupal_exit(). We need to prevent the system from calling drupal_page_footer() as its going to include the footer which is not required with card theme.
  • Added @file doc block to the JS file and also some essential inline comments too.

Overall, once again thanks to Lacey Sanderson and all other mates for reviewing this module.

pushpinderchauhan’s picture

Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new16.26 KB
new16.68 KB

@ Rishi Kulshreshtha, thankyou for your contribution!

Your module well worked for me, Good Job!

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. Just one minor

FILE: ...w/drupal-7-pareview/pareview_temp/templates/hover-card-template.tpl.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
29 | ERROR | [x] Whitespace found at end of line
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY

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
  1. Do add hook_help() in your module, would be useful.
  2. Project page looks good to me including Readme.txt, very well organised.
  3. In hover_card function, you are using $array variable to hold user data, better to use some meaningful name like $user_data or vice-versa.
  4. I tested this module functionality for logged in and anonymous users. I have also attached screenshot of both to make it more understandable for other reviewers.
    Admin User:


    Seven Theme Hover

    Anonymous User:


    Anonymous User

    It work fine as intended. Personally one more thing you can enhance here, If you look into source code for anonymous user, would found every js and css of this module loading on every page that are unused. I think it can be improved to load all necessary files only for logged in users :)

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.

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

As there is no blocker found, so moving to RTBC.

But I would give one suggestion to you, if you implement your JS file logic with Drupal Ajax framework would be nice. Ajax framework commands provides every possible commands that your require to implement your ajax logic.

Thanks Again for contributing this nice module.

rishi.kulshreshtha’s picture

Hearty thanks to Pushpinder Rana for reviewing the module and notifying me the issues.

I have fixed all the points mentioned by Pushpinder, which are as follows:

  • Fixed the Automated Review
  • Implemented hook_help()
  • In hover_card function, replaced $array variable which is used to hold user data with $user_data as its more meaningful. Thanks Pushpinder for suggesting this.
  • Fixed the loading of Hover Card JS and CSS file only where they are required.
rishi.kulshreshtha’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
rishi.kulshreshtha’s picture

Issue summary: View changes
rishi.kulshreshtha’s picture

Issue summary: View changes
rishi.kulshreshtha’s picture

Issue summary: View changes
madhusudanmca’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Hi Rishi Kulshreshtha,

Thanks for your contribution.

I don't see any blockers for this module, however I see one PII (Personally identifiable information) concern here, as we are not giving any options to show/hide user data on that information overlay and directly exposing user's email address to other users.
I suggest you to edit your project page and clearly mention that "If you have PII compliance then do not use this module" or provide options show/hide user data.

Thanks

rishi.kulshreshtha’s picture

Issue summary: View changes

Thanks for the suggestion @Madhusudan, I've updated the code and created a new section "Configuration" where now its upto user whether to display the Emails or not.

rishi.kulshreshtha’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review

Updated the code as per the requirement and also updated the "Configuration" with the updated details.

rishi.kulshreshtha’s picture

Status: Needs review » Reviewed & tested by the community

As there is no blocker found, so moving to RTBC.

pushpinderchauhan’s picture

Status: Reviewed & tested by the community » Needs review

Please don't RTBC your own issues, see the workflow: https://www.drupal.org/node/532400.

Please treat these rules with understanding and be patient.

rishi.kulshreshtha’s picture

My bad, thanks for informing Pushpinder.

rishi.kulshreshtha’s picture

Issue summary: View changes
rishi.kulshreshtha’s picture

Issue summary: View changes

Fixed conditioning in tpl.php in the latest Commit ID #b6466e4. What I've found that though the user picture was not present but still the HTML with class name user-image was getting generated, hence its fixed now.

sendinblue’s picture

Status: Needs review » Reviewed & tested by the community

Automated Review

No issues.

Manual Review

Individual user account
Yes.
No duplication
No any duplication.
Master Branch
Yes
Licensing
No Licensing file. ok
3rd party code
No any ard party code. ok
README.txt/README.md
Yes.
Code long/complex enough for review
Yes.
Secure code
Yes.
klausi’s picture

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

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

  • 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. hover_card_init(): why do you need hook_init(), it does not make sense to load your library on drush invocations for example? Why don't you load the library when you actually need it? You already have hover_card_page_build() anyway, so you can remove hook_init() and load the library there.
  2. hover_card_page_build(): why is this only done for logged in users? Please add a comment.
  3. hover_card_page_build(): you have a render array with $page available, so you should use #attached in it for your JS and CSS instead of drupal_add_js/css(). See https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
  4. hover_card_page_build(): if I understand correctly then you only want to add your JS/CSS when a user name is printed on the page, correct? Then you should implement a preprocess hook for theme_username instead of hook_page_build(), so that it is only added when actually needed.
  5. hover_card_menu(): The path hover-card/%user is not protected at all with a permission and reveals sensitive information such as the user picture or email address. This needs to use at least the "access user profiles" permission. And we consider email addresses private information in Drupal (so that they are not harvested by spammers) which means that the default value to show the email address should never be TRUE. This is an access bypass security issue. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
  6. hover-card-template.tpl.php: All user facing text like "Roles", "Email" etc. need to run through t() for translation.
  7. hover-card-template.tpl.php: drupal_exit() is wrong in a template, that should be done in the page callback function if you have to.
  8. hover_card_theme(): the template does not specify the variables that will be passed to it? See https://api.drupal.org/api/drupal/modules!system!system.api.php/function...
  9. hover_card(): this is vulnerable to XSS exploits. User name, roles, email is user provided data and you need to sanitize it before printing to HTML. Make sure to read https://www.drupal.org/node/28984 again.
  10. "variable_get('hover_card_user_email_display_status', TRUE)": all variables defined by your module need to be removed in hook_uninstall().
sendinblue’s picture

Hello @klausi

I found one problem in your manual review.

10. "variable_get('hover_card_user_email_display_status', TRUE)": all variables defined by your module need to be removed in hook_uninstall().

Please check following article.
-----------------------------------------------------------

https://www.drupal.org/node/1187664#issues

Your module doesn't remove the Drupal variables it defines.
Drupal 6 modules can implement hook_uninstall() to remove Drupal variables it defines, and the database tables it installed; in Drupal 7, database tables defined from a module are automatically removed.

-------------------------------------------------------------

As you see in the article, I think Drupal 7 automatically remove all varialbes used in module when uninstall it.
Am I wrong?

pushpinderchauhan’s picture

@sendinblue

As you see in the article, I think Drupal 7 automatically remove all varialbes used in module when uninstall it.

In Drupal 7, database tables defined from a module are automatically removed, not variables. The variables that the module has set using variable_set() or system_settings_form() should remove on uninstall. Database tables defined by hook_schema() will be removed automatically.

See: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

sendinblue’s picture

@ er.pushpinderrana

Thanks very much for your info.
Really I'm a newbie for drupal. (my experience is 2 month) :)

I'll correct my sandbox project too as your info.

Regards

rishi.kulshreshtha’s picture

Status: Needs work » Needs review

@klausi,

I've fixed the issues mentioned in comment #25

Thanks for your review, great work!

rashid_786’s picture

StatusFileSize
new13.93 KB

> /**
* @file
* Install, update and uninstall functions for the hover_card module.
*/
unable to find install and update functions inside hover_card.install file as you mentioned in comments.

 if (!empty($user_picture)):
  ?>
    <div class="user-image">
    <?php print_r($user_picture); ?>
    </div>
  <?php endif; ?>

Why print_r() is being used to render $user_picture in hover-card-template.tpl.php and it would be nice if you say hover-card.tpl.php

* If i enable user picture and hover user profile name then it doesn't show any thing in username and email but roles as 'anonymous user' though already logged in as admin. Please find attached image for reference.

rishi.kulshreshtha’s picture

StatusFileSize
new53.63 KB

@rashid_786,

First of all thanks for your suggestions, I've taken them into consideration and I've fixed couple of things:

  1. Made changes in the @file section of hover_card.install file.
      /**
       * @file
       * Requirements and uninstall functions for the hover_card module.
       */
      
  2. Using print_r() was necessary as you can see that I've set $details['picture'] in $user_picture variable in my template file.
  3. As per your suggestion, I've changed hover-card-template.tpl.php to hover-card.tpl.php.
  4. The issue you were facing is fixed now, please check the attached proof.
klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

manual review:

  1. hover_card_uninstall(): the variable_get() call is not needed and can be removed.
  2. hover_card_menu(): The path hover-card/%user is not protected at all. You need to remove 'access callback' here so that default access callback user_access() is used.
  3. hover_card(): doc block is wrong, this is not a hook. See https://www.drupal.org/coding-standards/docs#functions , so the first line should use the description of a page callback.
  4. hover_card_ajax_callback(): same here with the docs, this is not a hook but a page callback.

The unprotected menu path is a security blocker right now. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

rishi.kulshreshtha’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
rishi.kulshreshtha’s picture

Status: Needs work » Needs review

@klausi, thanks for the review. I've fixed all the issues mentioned by you and I've updated the same. Adding a new review of other project.

rishi.kulshreshtha’s picture

Issue summary: View changes
klausi’s picture

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

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

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: /home/klausi/pareview_temp/hover_card.module
    --------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     109 | ERROR | Type hint "array" missing for $user
     146 | ERROR | Missing parameter type
    --------------------------------------------------------------------------------
    
    Time: 174ms; Memory: 6.25Mb
    
  • 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.

But otherwise looks good to me now.

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

sandeep.kumbhatil’s picture

Automated Review

FILE: /var/www/drupal-7-pareview/pareview_temp/hover_card.module
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
109 | ERROR | Type hint "array" missing for $user
146 | ERROR | Missing parameter type
--------------------------------------------------------------------------------

Manual Review

Individual user account
Yes: the guidelines for individual user accounts.
No duplication
Yes: module duplication and/or fragmentation.
Master Branch
Yes: the guidelines for master branch.
Licensing
Yes: the licensing requirements.
3rd party assets/code
Yes: the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:
  1. Nothing have been found. Only fix those issues found on pareview

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.

This review uses the Project Application Review Template.

rishi.kulshreshtha’s picture

@klausi & @sandeep.kumbhatil,

I've fixed the above mentioned issue, thanks for mentioning that.

stborchert’s picture

Thanks for your contribution, Rishi!

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.

Some small notes:

function hover_card($user = array()) { }

$user is not an array but should always be an object.

stborchert’s picture

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

Forgot to set status.

Status: Fixed » Closed (fixed)

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