Device Detector is a simple, PHP-based browser and device(Desktop & Mobile)feature-detection module that can detect devices & browsers on its own without the need to pull from a central database of browser information and adds configuration classes to "" tag.

  • This module provides an admin configuration section, where the user can provide different class names for different conditions(browser & device wise).
  • This class names are then added to the html “” tag, while the page gets rendered from the server end.
  • The class names for browsers are rendered based on the the admin configurations, using a browser’s(mainly) unique user-agent string as a key.
  • Mobile Detect Class, included in in the module itself, is used to collect and record any useful information's(like OS or device name) the user-agent string may contain, for rendering classes for device(Desktop & Mobile).


Available community modules :
- Detector
- Mobile Detect
- Browser Detection
Note *: All these solutions somehow have certain dependency on other community modules or have to add some extra libraries.
Apart from this, Device Detector provides separate configuration pages for browser and devices with various set of configurations available to customize the detection process based on the requirement.

Usage of jQuery Plugins.
Note *: Leads to client end dependency and loading issue for slow connectivity.

Dependencies

No such dependencies present. Simply install the module and do your stuffs.


Project : "https://www.drupal.org/sandbox/nathmonoj2014/2523140"

Git Clone Url : "git://git.drupal.org/sandbox/nathmonoj2014/2523140.git"
Clone the repository and you may rename the folder "2523140" with "device_detector".

Manual reviews of other projects

First Round of Review ::
https://www.drupal.org/node/2155969#comment-10361115
https://www.drupal.org/node/2264953#comment-10361173
https://www.drupal.org/node/2267323#comment-10361209
Second Round of Review ::
https://www.drupal.org/node/2365671#comment-10416481
https://www.drupal.org/node/2364165#comment-10416499
https://www.drupal.org/node/2267611#comment-10416515

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

monojnath created an issue. See original summary.

monojnath’s picture

monojnath’s picture

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/httpgitdrupalorgsandboxnathmonoj20142523140git

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.

dishabhadra’s picture

I review it's working fine for me

formatC'vt’s picture

monojnath’s picture

Thanks for your reviews.
I am working on the automated test.
I will fix all the syntax issues within 2 days..

monojnath’s picture

Issue summary: View changes
monojnath’s picture

monojnath’s picture

Status: Needs work » Needs review
monojnath’s picture

Priority: Normal » Major
jnavane’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +Security improvements
FileSize
12.78 KB
23.47 KB

Hi,

Could you please validate the input fields where you should not accept any special characters?

I tried to add special chars in "Body Common Class Name/Names " field, its accepting. But In your case, as you are going to use this as class name in tag, you should avoid special chars if I am right.

I have attached the screenshots.

Thanks,
Navaneeth

monojnath’s picture

Thanks a lot @Navaneethakrishnan for your valuable feedback.

I have fixed the issue and also have put some extra checks on the check boxes condition.
Hope it will do the job.!!

monojnath’s picture

Status: Needs work » Needs review
monojnath’s picture

monojnath’s picture

Issue tags: -PAreview: review bonus
monojnath’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
kalpeshhiran’s picture

Hi monojnath,

When I configure "Device Detector Settings" and try to "Add Custom class specific to the browser :: Google Chrome" I get below error
Please provide Chrome specific Class Name/Names in required format

I tried it with class1,class2 and other comma separated class names as per examples you have given. And I am getting same error for other browser options.

Can you please look into it.

monojnath’s picture

Hi kalpeshhiran ,

Thanks for reviewing my module and providing your valuable feedback.

I am sorry as I have mentioned the example classnames as Class1,Class2.
But there was note that states not to mention any alphanumeric numeric class name ::
*Note: Don't include any Number or Special Character(eg.'\/~`!@#$%^&*()_-+=\{}[]|;:"<>,.?) in your class name.!!

Still I have changed the example clases as Class1, Class2.

Hence the updated field description looks like :

Add class names, comma(,) separated for multiple class names to be added to every page on body
eg. classA,classB....
*Note: Don't include any Number or Special Character(eg.'\/~`!@#$%^&*()_-+=\{}[]|;:"<>,.?) in your class name.!!

kalpeshhiran’s picture

Status: Needs review » Needs work
FileSize
47.52 KB

@monojnath

Your description says

Add class names, comma(,) separated for multiple class names to be added to every page on body
eg. classA,classB....

Single class name work perfectly for me. But when I add comma(,) it gives me an validation error. Please check attached screenshot.

Only local images are allowed.

monojnath’s picture

Hi kalpeshhiran ,

Thanks for having your patience and reviewing my module and providing your valuable feedback.

I am realy sorry for the misconfusion arised.

I have made the validation fixes for ',' check and checked it again.

The extra validation checks implemented is that "You cannot start or end the class names with a ','".

I am waiting for your valuable feedback.

I hope it runs correctly this time in your end. :)

monojnath’s picture

Status: Needs work » Needs review
kalpeshhiran’s picture

Status: Needs review » Reviewed & tested by the community

Hi,

I have reviewed your module manually. There are few recommendations you might want to consider.

Automatic Review

http://pareview.sh/pareview/httpgitdrupalorgsandboxnathmonoj20142523140git
looks good, though no automated test cases written.

Manual Review

Individual user account
Yes: Follows
No duplication
Yes: Follows
Master Branch
Yes: Follows
Licensing
Yes: Follows
3rd party assets/code
Yes: Follows
README.txt/README.md
Yes: Follows
Code long/complex enough for review
Yes: Follows
Secure code
Yes: Follows
Coding style & Drupal API usage
Just some recommendations:
  1. Change configuration example class1,class2 to classA,classB in Body Common Class Name/Names also.
  2. If I add capital letters in Body Common Class Name/Names, it gets converted to lowercase.

This review uses the Project Application Review Template.

monojnath’s picture

Hi kalpeshhiran ,

Thanks for having your patience and changing the status to reviewed and tested by community.

And, I have made all the required changes as per your suggestions.

Please find the below updates on your suggestions :

1. Change configuration example class1,class2 to classA,classB in Body Common Class Name/Names also.
- Done.
2. If I add capital letters in Body Common Class Name/Names, it gets converted to lowercase.
- Done.

I hope that everything goes well, and my module gets accepted. :)

kalpeshhiran’s picture

Hi monojnath,

I have checked your changes and they are fixed now.

Also remove comma(,) from your examples eg.'\/~`!@#$%^&*()_-+=\{}[]|;:"<>,.?

Everything else looks good.

monojnath’s picture

Hi kalpeshhiran ,

Thanks for your continuous evaluations and feedbacks.

The ',' is not to be used as a part of the class name, but it is used as a separator between two class names.
So it is mentioned in the examples eg.'\/~`!@#$%^&*()_-+=\{}[]|;:"<>,.?'.

I hope that i have clarified the point to you. :)

kalpeshhiran’s picture

Oh yes. I got confused. Those are 2 different things.

No need to remove comma(,) from examples.

monojnath’s picture

Thanks Kalpeshhiran... :)

Can you tell me what goes next.
I mean what are next processes/steps to be followed?

dishabhadra’s picture

monojnath’s picture

Hi Dishabhadra,

I couldn't find the changes/updates that you made in the issue. :(

Can I know the same? :)

rahul.shinde’s picture

Status: Reviewed & tested by the community » Needs work

Followings are few observations,

  1. You have already converted path to lower in device_detector.module LN#122 and again converting coverted string at device_detector.common.inc LN#18
  2. I'll encourage you to set 'device_detector_node_urls' variable converting all paths to lowecase to avoid doing so while prerocessing html device_detector.common.inc LN#21 & LN#25
  3. Please update comment or correct the assignment
      // Body class container array.
      $body_classes = '';
      
  4. Please remove
    default:
              break;

    from device_detector.module LN#198

  5. Is it possible to prefix module name to following variables to have a consistency
    1. is_body_settings_chkd will change to device_detector_is_body_settings_chkd
    2. is_brwsr_settings_chkd will change to device_detector_is_brwsr_settings_chkd
    3. is_dsktp_settings_chkd will change to device_detector_is_dsktp_settings_chkd
    4. is_dvc_settings_chkd will change to device_detector_is_dvc_settings_chkd

Please lemme know if you need more info on above suggested changes.

naveenvalecha’s picture

Status: Needs work » Needs review

Thanks for the review rahul,I have not found any blocker above, so moving to needs review

rahul.shinde’s picture

Thanks @naveenvalecha for correcting the status.

monojnath’s picture

Hi Naveen/Rahul,

Thanks for your time and valuable feedback's for my module.

I have made all the changes as per mentioned by you.

Can you please check and provide your feedback's.

Thanks in advance...:)

rahul.shinde’s picture

Status: Needs review » Needs work

@monojnath, please address preview.sh comments.

Following is being copied from http://pareview.sh/pareview/httpgitdrupalorgsandboxnathmonoj20142523140git
Review of the 7.x-1.x branch (commit c8e882e):

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.


FILE: ...w/drupal-7-pareview/pareview_temp/includes/device_detector.common.inc
---------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------
 73 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 73 | ERROR | [x] Inline comments must start with a capital letter
 73 | ERROR | [x] Inline comments must end in full-stops, exclamation
    |       |     marks, or question marks
 74 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 84 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 84 | ERROR | [x] Inline comments must start with a capital letter
 84 | ERROR | [x] Inline comments must end in full-stops, exclamation
    |       |     marks, or question marks
 85 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 86 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------


FILE: ...review/pareview_temp/includes/device_detector.admin.config.device.inc
---------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------
 65 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 65 | ERROR | [x] There should be no white space before a closing ")"
 71 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 71 | ERROR | [x] There should be no white space before a closing ")"
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------


FILE: ...eview/pareview_temp/includes/device_detector.admin.config.browser.inc
---------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 7 LINES
---------------------------------------------------------------------------
 286 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 286 | ERROR | [x] There should be no white space before a closing ")"
 311 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 311 | ERROR | [x] There should be no white space before a closing ")"
 326 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 326 | ERROR | [x] There should be no white space before a closing ")"
 336 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 336 | ERROR | [x] There should be no white space before a closing ")"
 346 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 346 | ERROR | [x] There should be no white space before a closing ")"
 356 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 356 | ERROR | [x] There should be no white space before a closing ")"
 366 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
 366 | ERROR | [x] There should be no white space before a closing ")"
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------

Time: 674ms; Memory: 16.75Mb

Source: http://pareview.sh/ - PAReview.sh online service

monojnath’s picture

I am extremely sorry for the harassment... :(

I forgot to run the review after I submitted the updated code.

I have run the review and checked it.

Waiting eagerly for your valuable feedback's. :)

monojnath’s picture

Status: Needs work » Needs review
rahul.shinde’s picture

Status: Needs review » Reviewed & tested by the community

No blockers. Marking this as RTBC

naveenvalecha’s picture

Assigned: Unassigned » er.pushpinderrana

great thanks for your time Rahul!
Manoj, Nice Module,there is a module which looks similar to this,mobile_detector can you check out and post its similarities and differences on the project page and issue summary.

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

  • 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.

Source: http://pareview.sh/ - PAReview.sh online service

Manual Review :

  • Readme.txt is nice. Please remove a trailing slash from https://www.drupal.org/user/3015343/ and using the full namespace would be better https://www.drupal.org/u/monojnath
  • device_detector_install : What's the need of setting the variables values here ? can't you use those as default values
  • device_detector_browser_settings_form : $form['body_class_details']['device_detector_node_spfc_class'] : Where will this wrapper testprb_replace_field_div exist/come from ?
  • device_detector_browser_settings_form_submit : The values that are saving in variables in this function is in complicated way. can't we decouple the code. similarly in device_detector_device_settings_form_submit
  • DeviceDetectorMobileDetect : The constants are deprecated. Since this is your written code ? do those required ?
  • DeviceDetectorMobileDetect : Nice list of $phoneDevices and tablet devices ? can you make them configurable? its a feature request not a blocker

Not found any blocker. I don't have d7 setup available, so did manual review from code scan. Assinging to er.pushpinderrana to do full & final review if he has time.

monojnath’s picture

Issue summary: View changes
monojnath’s picture

Issue summary: View changes
monojnath’s picture

Also Naveen,

I have posted the similarities and differences about the other available modules on the project page and issue summary. :)

I am eagerly waiting for your kind response. :)

I hope this module gets a release permission from you all...

er.pushpinderrana’s picture

Assigned: er.pushpinderrana » Unassigned
Priority: Major » Normal
Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: security

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. None

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

  • 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
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follow the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
(*)No: List of security issues identified.
  1. device_detector_preprocess_html(): Below snippet code looks like its vulnerable to XSS exploits.
    $current_path = drupal_get_path_alias(current_path());
    $url_breakup = explode('/', $current_path);
    $last_arg = trim(implode(' ', $url_breakup));
    $body_classes .= ' ' . ((!(drupal_is_front_page())) ? strtolower($last_arg) : 'home');
     // To remove repeating classes.
        $body_classes = implode(' ', array_unique(explode(' ', $body_classes)));
        // Adding classes to html <body> tag.
        $vars['classes_array'][] = rtrim($body_classes);

    You are passing the $last_arg unsanitized to $vars['classes_array'].You need to apply check_plain() to the $last_arg. This is a security blocker. Please make sure to read https://www.drupal.org/node/28984 again.

Coding style & Drupal API usage
  1. You should also really have a hook_help() with some basic info about the module.
  2. HTML is better to take out of t() function.

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.

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

monojnath’s picture

Hi Pushpinderrana,

Thanks a lot for reviewing my module and providing your valuable feedbacks.

I have made all the required changes as mentioned above and tested it.

Hope this time there would be no blocker for the module.

I am eagerly waiting for your kind response. :)

monojnath’s picture

Status: Needs work » Needs review
er.pushpinderrana’s picture

Status: Needs review » Reviewed & tested by the community

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. None

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

  • 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

My blocking issues have been addressed.
Nothing major jumped out at me when I read `git diff b8ca344..`

Been sitting at RTBC for a while now, so...

er.pushpinderrana’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, Monoj Nath!

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.

monojnath’s picture

Thanks a lot Pushpinder and all other reviewer's for your support... :)

Status: Fixed » Closed (fixed)

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