We use a couple of modules that use the arg function ( http://api.drupal.org/api/function/arg/6 ) to determine what to do. For example, the Taxonomy Access Control module uses it in hook_db_rewrite_sql like this.

$op = (arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit')) ? 'create' : 'list';

When HS is used during node creation for example, arg(0) becomes hierarchical_select_json. The Multistep module also uses arg to determine the current step it is on. This causes problems using HS and these modules together.

Is there a way to determine what the original path was when hierarchical_select_json is called? This way I could modify the Taxonomy Access Control and Multistep modules to check if arg(0) is hierarchical_select_json, then use some other way to find the same information the arg function would have given us. Perhaps there is a better way to do this?

Thanks

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Fixed

I've been out of my game for a while, but I'd say that using arg() to steer form logic in a uniform manner (including for AHAH/AJAX forms) is wrong. You should rely on the form id instead.

Let me know if that doesn't work out, I'll help you find a solid method.

drenton’s picture

Status: Fixed » Active

Hi Wim, thanks for the info. Form id is not available in hook_db_rewrite_sql, unless I use $_POST. Would you recommend using $_POST ?

In the meantime I have changed the HS path like this in hook_form_alter.

$form['taxonomy'][30]['#config']['path'] = $form['taxonomy'][30]['#config']['path'] . request_uri();

Then in taxonomy_access_db_rewrite_sql I did this.

if (arg(0) == 'hierarchical_select_json') {
  $op = (arg(1) == 'node' && (arg(2) == 'add' || arg(3) == 'edit')) ? 'create' : 'list';
} else {
  $op = (arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit')) ? 'create' : 'list';
}

Thanks

wim leers’s picture

Status: Active » Fixed

I think that's a safe work-around :)

Status: Fixed » Closed (fixed)

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