Does any module handle the event / logic between transferring from one URL to another inside a drupal site?

zanhsieh - June 18, 2009 - 21:07

Hi,

I am looking for the module as the title described. My scenario is:

1. A user register and fill his/her survey questions.
2. If a user deletes his/her survey questions, the system will lock him/her down. This means no matter which drupal site URL he/she tries to go to, the site will redirect to the form URL he/she supposed to fill up in real time, except the user account page for changing the password.

I have tried:
- r4032login
- login_destination
- logintoboggin

None of them fits my requirement. Also I did some research on hook_user, the $op only has:
- categories, delete, form, submit, insert, login, logout, load, register, update, validate, view

It does not include any operation that I could program my logic during URL transferring. Please tip me out.

Thanks a lot.

How about a different

nevets - June 18, 2009 - 22:19

How about a different approach.

From what you have said it sounds like a user can only view content if they have filled in a survey.

If the survey is a content type

Create two roles, one for people who can view content (can_view), one for people who can not (need_survey). Make sure need_survey role has permission to create content of type survey.

Use the rules module so when people add a survey (save new content, condition on content type) it deletes the need_survey role and adds the can_view role. Add another rule for when a survey is deleted to do the opposite, delete can_view role, add need_survey role.

For people who have the need_survey role since they can not view content they should get a 403 (access denied) error. Under admin/settings/error-reporting you can define a path for handling 403 errors. If your content type is survey, you could use 'node/add/survey'

Re: How about a different

zanhsieh - June 22, 2009 - 22:11

Hi nevets,

There are things encountered while I tried to implement your approach:

1. My site allows the user to choose their role during registration (the user cannot change his/her role once registered), so I have to hide my unwilling-to-show roles during the registration.
2. The survey is the webform module, which does not have any rule event written for rule module use.
3. In addition to anonymous and authenticated user, I have 4 user roles. Supposed 4 roles are the final state of a user, so I am required to add another 4 roles, which will be total 8 roles. The 4 user roles cannot overlapped since each role has its own form needs to fill.

I think #2 is more difficult than I thought, and might be easier than adding a non-existing system / core state.

Thanks a lot for your input. I will try the way you provided.

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

It ends up I took menu per role module and tweak on function _menu_per_role_access($mlid):

<?php
// $Id: menu_per_role.module,v 1.6.2.4 2008/12/28 10:06:46 alexiswilke Exp $

/**
* @file
* Allows restricting access to menu items per role
*/

/*
* Determines access for a give menu item id
*
* \warning
* This function is NOT called automatically. You need to apply the
* patch provided in this module so it actually works. See file:
*
* drupal-6.6-menu_per_role.patch
*/
function _menu_per_role_access($mlid) {
  global $user;

  if ($user->uid == 1 || empty($mlid)) {
    // Admins do not lose access whatever this module would otherwise say
    // Also, if the menu link identifier is not set, ignore the request
    return;
  }

  $rids = _menu_per_role_get_roles($mlid); 
  $submission_count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE uid = %d', $user->uid));
  // $mlid is the menu link you would like to hide in case the user does not submit anything
  if ($submission_count <= 0 && $mlid == 115) {
    return FALSE;
  }
  else {
    // NULL means that you can try some more and FALSE you're definitively out
    return !empty($rids) && count(array_intersect($rids, array_keys($user->roles))) == 0 ? FALSE : NULL;
  }
}

Leave a note here in case somebody having the same issue as I had before.

-MX

 
 

Drupal is a registered trademark of Dries Buytaert.