3

In a D6 site, when a user goes to node/add/forum, they find that the dropdown "Forums" just shows "Please choose" but there is nothing in that menu.

There is nothing in the PHP error log or in the watchdog.

I am sure the user has correct privileges - after all, the form does show. It's just that the dropdown that otherwise (for admin) shows all the different forums on the site, is empty, and the form cannot be submitted without it.

I've seen pretty much all the web searching for a solution, without success. Hope there's somebody in this new slick interface who will show me the right answer or direction.

2

Right, so I tried all sorts of illogical things, one of which was deactivating and uninstalling Forum Access module (http://drupal.org/project/forum_access).

I did not have to - because the form was accessible - but I did anyway, out of desperation.

Then I enabled it again. Set all permissions again.

And things work!

BUT this is not a proper solution. Something in Forum Access was screwed up badly and ideally this issue should've been solved at its root, not by a workaround like mine.

1

Since you report that Forum Access is also installed, did you check that the logged in user was allowed to add a post in at least one of the forum defined for the website?
As the module purpose is to control which users are allowed to view, edit, and update each forum, that could be the cause of the drop down list not being populated.

In fact, the following hook is the responsible of changing the values contained on the select form field that allows to select to which forum a forum post is associated with:

/**
 * Implementation of hook_form_alter().
 *
 * Alter the node/comment create/edit forms and various admin forms.
 */
function forum_access_form_alter(&$form, &$form_state, $form_id) {
  //dpm($form, "form_id($form_id)");
  if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
    module_load_include('node.inc', 'forum_access');
    _forum_access_node_form($form, $form_state);
  }
  // …
}

/**
 * Rewrite the taxonomy item on the node form.
 */
function _forum_access_node_form(&$form, &$form_state) {
  global $user;
  $vid = _forum_access_get_vid();

  if (!isset($form['taxonomy'][$vid]['#options'])) {
    return;
  }

  // True node administrators are all powerful and do NOT get their forms rewritten here.
  if (user_access('administer nodes') && empty($user->_forum_access_moderator)) {
    return;
  }

  $roles = array_keys($user->roles);
  $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles);
  while ($obj = db_fetch_object($result)) {
    $tids[$obj->tid] = $obj->tid;
  }

  // Also get all forums they happen to be able to moderate.
  $result = db_query("SELECT a.number AS tid FROM {acl} a INNER JOIN {acl_user} u ON a.acl_id = u.acl_id WHERE a.module = 'forum_access' AND u.uid = %d", $user->uid);
  while ($obj = db_fetch_object($result)) {
    $tids[$obj->tid] = $obj->tid;
  }

  // Ensure the forum they're trying to post to directly is allowed, otherwise
  // there will be much confusion.
  $forum_tid = arg(3);
  if (isset($forum_tid) && is_numeric($forum_tid) && !isset($tids[$forum_tid])) {
    drupal_access_denied();
    module_invoke_all('exit');
    exit;
  }
  • well, no, logged in users who did have the correct permissions were not able to add posts in forums because of the problem above: they could access the form at node/add/forum (meaning they did have access to it!) but they could not post anything because the dropdown, which is a required field, was empty. – Vacilando Mar 14 '11 at 15:24
  • @Vacilando: As far as I know, Forum Access doesn't change the access callback associated with "node/add/forum"; it changes the value shown in the select form field that allows to select to which forum the post is associated with. That is the reason why users can still see the forum post edit form, but then they are not able to create forum posts. – kiamlaluno Mar 14 '11 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.