Creating roles without Vocabulary Prefix

el_rob - December 13, 2007 - 09:26
Project:Taxorole
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:codex.gr
Status:needs review
Description

I have a vocabulary with the terms AAA, BBB, CCC, DDD which I want to use as roles. If I uncheck "Prefix role with vocabulary name" in the Taxorole settings, it doesn't create the roles correctly. Instead of having the roles AAA, BBB, CCC, DDD in creates AAA, AAABBB, AAABBBCCC, AAABBBCCCDDD.

To resolve this, change

drupal_set_message(t('Created role ').$newrole.'.');

to

drupal_set_message(t('Created role ').$newrole.'.');
unset($newrole);

on line 143.

#1

surge_martin - January 9, 2008 - 14:24

Wouldn't it make more sense to unset $newrole at line 148, at the end of the foreach loop? Otherwise you run the risk of adding blank categories to mass contact.

#2

codex.gr - January 16, 2008 - 21:46
Assigned to:Anonymous» codex.gr
Status:needs review» closed

Done, patch committed, thanks.

#3

repolainen - June 15, 2008 - 19:11
Version:5.x-1.x-dev» 5.x-2.x-dev
Status:closed» needs review

Still does it in 2.x -version. The unset is in a wrong place:

Now:

.
.
.
drupal_set_message(t('Created role ').$newrole.'.');
  if (module_exists('mass_contact') && $form_values['taxorole_add_mass_contact_category'] == 1) {
  taxorole_mass_contact_add_category($newrole, $newrid);
  drupal_set_message(t('Added category ').$newrole.t(' in Mass Contact categories.'));
  unset($newrole);
  }
}

Should be:

.
.
.
drupal_set_message(t('Created role ').$newrole.'.');
  if (module_exists('mass_contact') && $form_values['taxorole_add_mass_contact_category'] == 1) {
  taxorole_mass_contact_add_category($newrole, $newrid);
  drupal_set_message(t('Added category ').$newrole.t(' in Mass Contact categories.'));
  }
unset($newrole);
}

This way it works for those who don't have mass_contact -module enabled.

 
 

Drupal is a registered trademark of Dries Buytaert.