CVS edit link for minghui.yu

Background:

Many academic and administrative units in University of British Columbia (UBC) start to use Drupal. University of British Columbia has an in-house built single sign-on service called Campus Wide Login (CWL). This module is to use CWL as Drupal's external authentication engine.

About the module:

The module itself is not a complex module. .module file is 306 lines, .install file is 37 lines.

A few notes:

1. Because some units websites' users are not from UBC and they do not have CWL. Hence, I provide an option to let users login via CWL and Drupal's built-in authentication engine.

2. Because this module will be used in many existed Drupal sites, to make user accounts migration smoothly, I provide an option to let users associate their current user account with their CWL Id.

Thank you for your time,

Cheers,

Minghui Yu

Demo: http://ikblc.drupaldev.library.ubc.ca/

Comments

minghui.yu’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new5.22 KB

Hi,

This request is based on http://drupal.org/node/570056. My last request for a CVS account was declined because I did not reply in a timely manner.

Attached is the latest version.

Thank you.

Minghui Yu

minghui.yu’s picture

Please note:

The demo site does not show this (CWL Integration) function at this time. That site is under active development.

Thanks.

avpaderno’s picture

Issue tags: +Module review

The previous application was #570056: minghui.yu [minghuiyu].

avpaderno’s picture

Status: Needs review » Needs work
  1. When a module needs to verify that some conditions are verified at runtime (which includes the value of a Drupal variable), it should implement hook_requirements()
  2. The code uses <br /> in the description given for a form field when that is not necessary.
  3. What I reported before about the functions to use is still valid. Is there a reason to not follow what said from the coding standards about the functions a module should use?
  4.   $form['cwl_admin_cwlid'] = array(
        '#title' => t("Your site's super amdin's CWL ID"),
        '#description' => t("We suggest you to set this value to site super admin's CWL ID. Site super admin is the user whose user id is 1. Based on database record, this site's super admin's username is: %username and its CWL ID (if have) is: %adminid. Please make sure you enter the correct CWL ID from site super admin. Otherwise, someone whose CWL is the one you input here will gain unlimited access to your Drupal site", array('%username' => $user->name, '%adminid' => $userone_cwlid)),
        '#maxlength' => 8,
        '#size' => 10,
        '#type' => 'textfield',
        '#default_value' => $superadmin_cwlid,
      );
    

    The code is showing information about the user #1 without to verify if it is showing them to that user; I am not sure it is a good idea.

  5.   $form['user_register'] = array(
        '#title' => t('User Registration Option'),
        '#type' => 'select',
        '#description' => t('Please choose one from the list. Please note: this option will disable "Require e-mail verification when a visitor creates an account" option. To adjust this setting, please go to admin/user/settings'),
        '#options' => array(2 => t('Visitors can create accounts but administrator approval is required.'), 0 => t('Only site administrators can create new user accounts'), 1 => t('Visitors can create accounts and no administrator approval is required')),
        '#default_value' => variable_get('user_register', 2),
      );
    

    The code is duplicating the settings already used by Drupal; should not the code just use the settings already set in a Drupal settings page?

  6.   $uri = parse_url(check_url($form_state['values']['cwl_xmlrpc_path']));
    

    check_url(), which calls check_plain() should not be called, in this case; the function alters the URL, which could be not useful anymore.

minghui.yu’s picture

"What I reported before about the functions to use is still valid. Is there a reason to not follow what said from the coding standards about the functions a module should use? "

Could you please tell me the link to "the coding standards about the functions a module should use" ? I check http://drupal.org/coding-standards and its sub sections and cannot find info about it.

Functions in the module are:

  1. cwlintegration_menu
  2. cwlintegration_perm
  3. cwlintegration_admin
  4. cwlintegration_admin_settings
  5. cwlintegration_admin_settings_validate
  6. cwlintegration_admin_settings_submit
  7. cwlintegration_form_alter
  8. cwlintegration_authenticate

Please let me know which one is the problem.

Thanks,

avpaderno’s picture

See the section about Unicode string functions.
Generally speaking, a module should prefer a Drupal core function over PHP functions.

I think I have already said too much.

minghui.yu’s picture

Re: #5 The code is duplicating the settings already used by Drupal; should not the code just use the settings already set in a Drupal settings page?

This setting is here because

1) The feedback I received from users is that they want to modify user settings on the same page of Campus Wide Login (CWL) setting page. After using this module on existed sites, depending on if the site is open to all authenticated CWL users or to some of them (ie: open to students only, open to students in some faculties only, etc), the site admin needs to modify user registration option right away. Right now, most Drupal sites in the university require admin to approve user registration. With this module, some sites do not need to have site admin involved because they want all authenticated users to get accounts.

2) if a user is authenticated by CWL, it is no need to validate this user's email; especially in the forth coming future, after authenticated by CWL, a user's email registered with that CWL will be returned too. That is why I override email setting ( variable_set('user_email_verification', 0); ) in _submit

minghui.yu’s picture

Re: #4 The code is showing information about the user #1 without to verify if it is showing them to that user; I am not sure it is a good idea.

Hi KiamLaLuno,

Yes, you are very right that it is not a very good idea to show user #1 info without verifying. However, in university Drupal sites, it is not rare that user #1 is not the person who manages the site on a daily basis. Usually, someone (often students) developed a site and make himself user #1 and then left; a staff then took over and very often he thinks he is the super admin but in fact he is not. The description servers as a reminder here.

Thanks,

avpaderno’s picture

However, in university Drupal sites, it is not rare that user #1 is not the person who manages the site on a daily basis.

Bear in mind that a module present in Drupal.org needs to work for anybody.

To report the name of the user #1 is not a problem as that is available to anybody who has access to the user profiles (do you know who is the user #1 on Drupal.org? ;-))
I am not sure if it is a problem to show the other data, which is taken from the user profile data. The code should at least respect the settings for that field (which means that if I set that field to not be visible to anybody, the code should not show it to anybody).

Anyway, it is easier for a Drupal user to know if it is the super user, without any reminder. Just to make an example, do you think I am the super user?

avpaderno’s picture

If you think it's more correct to report to the currently logged user s/he is not the super user, why doesn't the code explicitly says to the user you are not the super user (or a similar sentence)?
A module should be able to verify if a user is the super user, should not it?

minghui.yu’s picture

Status: Needs work » Needs review
StatusFileSize
new5.37 KB

Hi KiamLaLuno,

Thank you for your comments. Please see the attachment for latest version.

A couple of changes per your comments:

1. replace substr with drupal_substr
2. use hook_requirements to check if clean_url is enabled when installing
3. do not display user #1's CWL id; instead, display user #1's username and currently logged in user's username to remind if current user is user #1
4. remove <br /> from form fields description
5. remove check_url from $uri = parse_url(check_url($form_state['values']['cwl_xmlrpc_path'])) and it is $uri = parse_url($form_state['values']['cwl_xmlrpc_path']) now.

Thanks,

avpaderno’s picture

Status: Needs review » Needs work
  if (xmlrpc_error()) {
    drupal_set_message('CWL communication error:'. t(xmlrpc_error_msg()), 'error');
    return FALSE;
  }

The string passed to drupal_set_message() is not translatable, and the first argument passed to t() needs to be a literal string, not a dynamic string.

minghui.yu’s picture

Status: Needs work » Needs review

Thank you.

I changed this and also changed the other two occurrences of drupal_set_message which did not use t

I also removed code below since the module now uses hook_requirements.

if ((variable_get('clean_url', 0)) == 0) {
    drupal_set_message('Clean URL feature must be enabled otherwise this module will not work', 'error');
  }

Thanks,

avpaderno’s picture

Status: Needs review » Needs work

You didn't upload the new code.

minghui.yu’s picture

Status: Needs work » Needs review
StatusFileSize
new5.32 KB

Oops!

Here it is

Thanks,

minghui.yu’s picture

Please note the demo site is down.

Thanks,

minghui.yu’s picture

Any update?

Thanks,

avpaderno’s picture

Status: Needs review » Fixed

I would remove the phrase As of writing: using in the description of some form fields; it should add something more in the description.

The error messages shown from the validate function should end with a period.

minghui.yu’s picture

THANK YOU, KiamLaLuno!

:)

Status: Fixed » Closed (fixed)
Issue tags: -Module review

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

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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