Download & Extend

Hide drop down forum list from non admins

Project:Advanced Forum
Version:6.x-2.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

When i want to create new content, i can go to Create new content->Forum Topic, so is logical that i can select the forum i will post my topic.
But when user is going to add topic to a forum where user is placed, user can get confused about the forum so , i want to hide select list in the post topic form.
have the Advanced Forum that option?
thanks

Comments

#1

Title:FORUM SELECT LIST DISPLAYING OPTIONALLY» Option to hide forum drop down when forum already selected
Category:support request» feature request

No, it isn't. It's a reasonable feature request but will need some thought. You don't want to hide it from moderators, for instance. So it would have to be role based or permission based of some sort.

Michelle

#2

oh yes you are right, so it comes a bit complicated so, you depend of current path and permissions, i know a lot of things have to be done first so i'll be patient
many thanks

#3

well i've hidden the list using formfilter this may be a solution, the problem is that it hide the list from both referer pages

http://drupal.org/project/formfilter

#4

Title:Option to hide forum drop down when forum already selected» Hide drop down forum list from non admins
Version:5.x-1.0-alpha10» 6.x-1.x-dev
Category:feature request» task
Assigned to:Anonymous» Michelle

Moving this to the to do list.

Michelle

#5

Status:active» postponed

Will revisit this in 2.x.

Michelle

#6

Version:6.x-1.x-dev» 6.x-1.0-beta1
Status:postponed» needs review

here's a patch for you. when patched, a new permission will be added that will allow roles to see the forum selector when a forum id is passed upon a new topic creation.

in the OP usecase scenario, when "create content > new forum" topic is clicked, the forum selector will show regardless of the permission setting, but when new topic is clicked, the select input becomes a hidden form element.

AttachmentSize
view_forum_selector.patch 1.4 KB

#7

Status:needs review» postponed

Thanks for the patched. As I said on IRC, though, this won't go in 1.x so it's still postponed. Also still need to figure out how to prevent it from hiding the selector by default. Given the IRC discussion, I guess it will need to be combined with a master setting to turn it on.

Michelle

#8

well according to system.install, you just need to directly update the permission rows for each role with the new permission which is trivial.

#9

Trivial, maybe, but icky. And what happens when they add new roles? I don't like that idea at all. I'd rather have a master switch to turn it on and then have permissions work normally at that point.

Michelle

#10

Version:6.x-1.0-beta1» 6.x-2.x-dev
Category:task» feature request
Assigned to:Michelle» Anonymous
Status:postponed» active

#11

There are a few things wrong with this approach, imo...

a) It hard-codes the forum's vocabulary as '1'. It should use variable_get('forum_nav_vocabulary', '')
b) It creates a new permission for viewing the selection box when we could easily re-use "administer nodes" or a similar, already-existing "smarter than the average bear" permission.
c) It assumes that forum topics are the only things that will ever be posted to forums. As of Drupal 6, any content type is allowed to be posted to the forum.

However, I used the basis of this patch to fix this same issue in DruBB, which you can find at #472672: form_alter() out the forum selection widget from post form if you're curious.

#12

Thanks, webchick. :)

Michelle

#13

webchick, thanks. though,

a) i repeatedly asked in #drupal about this problem over a few days as what i did seemed VERY dirty. i got no answer at all, so i did what i could to solve the problem in the time i wanted to spend on it.
b) i disagree.
c) excellent, if only that was widely known.

#14

I tried adding the patch and though the permissions come up, selecting them doesn't actually hide the drop down field. Am I missing something? I see there is some debate as to whether or not this should exist but it is exactly what I'm looking for. Is the patch posted here still the one to use, or is there another way to achieve the same functionality?

Thanks.

#15

Suscribe

#16

Status:active» postponed

This is going to hang out in the drubb project for now and will possibly become part of the upcoming moderation module rather than AF.

Michelle

#17

I am just curious on the status of this.

It has always seemed sort of odd to me that Drupal's forum module handles the selection of forums this way.

#18

The status is postponed. If you look at all those boxes right above the comment form, the status is the last one listed.

Michelle

#19

Title:Hide drop down forum list from non admins» You can fix this in your own module

Ive used the patch suggestion above and simply used my own module to alter forms in question:
I reused 'administer forums' permission. note that I created a new content type 'forum_comment' to be used by nodecomments as comments for my forum, hence the name of the second form('forum_comment_node_form'). Your comment form may be called differently.
I also wanted to hide shadow copy stuff.

<?php
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
   
// if editing/creating forum topic or comment
    // and user has no administer access
   
if(in_array($form_id, array('forum_node_form', 'forum_comment_node_form'))
            && !
user_access('administer forums'))
    {
       
$forumid="";
       
//if its a comment node, get the term from its parent node
       
if($form_id=='forum_comment_node_form')
        {
           
//get parent node
           
$node=node_load($form['comment_target_nid']['#value']);
           
//get forum term id from the parent node
           
$forumid=current($node->taxonomy)->tid;
        }
        else if(
$form_id=='forum_node_form')
        {
//if its a forum node and we're editing it
           
if(end(arg())=='edit')
            {
               
//get forum term id from node embedded in the form
               
$forumid = $form['#node']->forum_tid;
            }
            else
//if we're creating a topic
           
{
               
// get forum term id from the end of args
               
$forumid = end(arg());
            }
        }
       
//attempt to find forum term based on forum term id
       
$forum = forum_term_load($forumid);
       
//if forum is found
       
if($forum)
        {
               
//hide forum selection
               
$vocab = variable_get('forum_nav_vocabulary', '');

               
$default_term=$form['taxonomy'][$vocab]['#default_value'][0];
                
$form['taxonomy'][$vocab] = array(
                      
'#type' => 'hidden',
                      
'#default_value' =>     $forumid,
                 );
               
//hide shadow copy
               
$form['shadow']['#type'] = 'hidden';
        }
   
     }
}
?>

code updated to account for editing/creating comments/topic

Furthermore, i generate breadcrumbs based on node taxonomy in the template.php, so the user can tell where he is currently located.

#20

Title:You can fix this in your own module» Hide drop down forum list from non admins

#21

vladgur: so, how to use the code you posted? (in newbie terms I mean)

regards

#22

you create your own module and put this function in there.

#23

@vlagur: This would not work for me with D6, The error on submission is
"An illegal choice has been detected. Please contact the site administrator"
Watchdoc shows "Illegal choice 25 in taxonomy element."
Now 25 is the correct $forumid.

Reviewing the code, what is this line for?
$default_term=$form['taxonomy'][$vocab]['#default_value'][0];

I also tried setting
'#default_value' => array($forumid),
since dsm showed me that this usually an array.
No good eother "warning: preg_match() expects parameter 2 to be string"

The default_value value is important to ensure the posted it attributed to the correct forum.
That is why "$form['taxonomy']['#access'] = false;" is insufficient.
Also tried "$form['taxonomy']['#type'] = 'hidden';", which allowed a post to be created but was not visible in the forum..

#24

The default_value value is important to ensure the posted it attributed to the correct forum.
That is why "$form['taxonomy']['#access'] = false;" is insufficient.
Also tried "$form['taxonomy']['#type'] = 'hidden';", which allowed a post to be created but was not visible in the forum..

This is exactly what I am seeing.... I had to do a display none, but we all know that's just a hack!

Also, I should probably mention, that this is happening on a site that is not using advanced forums as well, so the issue is likely not with anything Advanced forum is doing...

#25

Status:postponed» closed (won't fix)

I'm not going to be doing this one in 2.x. It will likely happen in 7.x-3.x but in such a different way that this issue will be irrelevant.

Michelle

nobody click here