Download & Extend

Creating roles without Vocabulary Prefix

Project:Taxorole
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:codex.gr
Status:needs review

Issue Summary

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.

Comments

#1

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

Assigned to:Anonymous» codex.gr
Status:needs review» closed (fixed)

Done, patch committed, thanks.

#3

Version:5.x-1.x-dev» 5.x-2.x-dev
Status:closed (fixed)» 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.