I've just installed this module and it appears to be working: while logged out I can make posts etc.
However, the front page of my site gives me this PHP error:

Fatal error: Call to undefined function user_roles() in D:\xampp\htdocs\drupal-events\sites\all\modules\ipAuthenticator\ipauth.module on line 19

Other pages load normally.

Comments

joachim’s picture

This happens on a unix system too, so it's not a Windows / clean URLs thing.

jonfrancisskydiver’s picture

Joachim, I tested the functionality on a fresh install of Drupal 5.7, posted a comment and viewed the frontpage while logged in and logged out out. I can't get that error to appear on my install. Perhaps the hook_init function is getting called before the user module has loaded on your install?

Try pasting the code below before this code $roles = user_roles(); in the ipauth_init() function.

  if (!function_exists("user_roles")) {
    drupal_load("module", "user");
  }

So once you finish that the ipauth_init function should look like:


function ipauth_init() {
  global $user;
  // Get all of the roles
  if (!function_exists("user_roles")) {
    drupal_load("module", "user");
  }
  $roles = user_roles();

  // Get the list of roles to assign based off of the IP
  $result = ipauth_get_ip_authenticators($_SERVER['REMOTE_ADDR'], "roles");
  
  // Loop through the results and apply the new roles.
  while ($row = db_fetch_array($result)) {
    $user->roles[$row['roles']] = $roles[$row['roles']];
  }  
} // end function ip_authenticator_init

joachim’s picture

Yup, pasting that in fixes the problem.
I forgot to say that it was appearing only for anonymous users whose IP was putting them into a role. When logged in as the admin user it was fine.
My install is a 5.6.

Just tested on a clean 5.7, and works fine without the page.
I assume between 5.6 and 5.7 the weighting of the user module was changed?

jonfrancisskydiver’s picture

Status: Active » Closed (fixed)
code rader’s picture

Version: 5.x-1.0 » 5.x-1.2
Status: Closed (fixed) » Active

I've got the same problem going on.

I saw the that the code checked for function_exists("user") and tried changing it to function_exists("user_roles"), but I'm getting the same error that is mentioned above.

code rader’s picture

nevermind - I didn't see that the patch was commented out. teach me to use an editor without highlighting.

but I did have to uncomment the patch to get it to work.

jonfrancisskydiver’s picture

Code Rader, I have updated the code to not be commented out.

jonfrancisskydiver’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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