Fixing Preferred Format

Kiam's picture

preferred_format.module is a module that permits any user which has been enabled to choose the default format used for any content type, or for the comments.
It's a useful module that helps when adding content to a Drupal-powered site which makes available more input formats, and avoids the user insert the content in a format which is not compatible with the default input filter selected by the web site administrator.

I installed it on my web site, and until now it didn't cause any problem, even if it's a development snapshot.
The only "bug" I found is that it shows its settings form in any tab present under user/<user>/edit (where <user> is any valid ID for a registered user) which is a little confusing.

The issue is caused by preferred_format_user() which doesn't check the $category parameter which is passed to any implementation of hook_user().
It is sufficient to change the following code lines from:

  switch ($op) {
    case 'form' :
      // Add the user can choose it's own preferred input format,
      // append the user edit form with the necessary form field.
      if (user_access('set preferred format')) {

to:
  switch ($op) {
    case 'form' :
      // Add the user can choose it's own preferred input format,
      // append the user edit form with the necessary form field.
      if ($category == 'account' && user_access('set preferred format')) {

and the module settings will appear only once under user/<user>/edit/account.

ATTENTION
The files you can download using the links below are not the official releases made from the authors of the module; they are just my personal modifications I made to correct some bugs, or to optimize the code. The authors of the module are not responsible for any modifications I made to the code.
Any problems you get from the files I make available here MUST be reported only on this website.

Your rating: None

Comments

Re: Fixing Preferred Format

preferred_format.module works only with the body field of the node editing form; it does not have any integration with CCK for those fields that permit to select a input format for their content.
That would be something interesting to see.

-- Kiam