Moderator don't edit the content for his forum's category

snowwind - July 18, 2007 - 19:00
Project:Forum Access
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:snowwind
Status:patch (code needs work)
Description

I give the register user right of moderator for one forum's category. This category contain some forum's topics by another user, for example there have three topicls in here. The moderator can edit three topics and delete it. But i will don't let this user to make the moderator,delete his right. i don't have another choice for it, moderator is null. there will have lots of topics in this forum's category.
then i will let new user to make moderator to this forum's category. this time i found the bug that new moderator don't edit the topic
between after delete the old moderator and create the new moderator for same forum's category. so i need how to change it or may be need some configure to fix this bug in drupal's admin, please tell me something ,thank you. please.......

#1

salvis - July 18, 2007 - 21:06

I'm sorry, I don't understand exactly what you mean, but please make sure you have the latest ACL module installed: http://drupal.org/project/acl — it fixes at least one bug related to the moderator feature.

If this doesn't help, you may have to get someone to translate, or maybe there's someone here who can translate for you. What is your native language?

#2

snowwind - July 19, 2007 - 09:34

sorry, maybe my description is mess.
acl version: 5.x-1.4
forum_access version: 5.x-1.7
the moderator's right can edit one forum's topic by admin set,right?
there have a forum name is aaaa, and contain two topics in here.the title is mycontent, newcontent
For example step by step:
1.let user1 to make moderator for aaaa(it's not a container,it's a forum type). by then userone can edit mycontent and newcontent.
2.I'll remove the userone from moderator list and then post new topic in aaaa
3.add user2 to make moderator for aaaa, and try to edit the articl in aaaa,you'll find the bug that don't have right to edit everyone

#3

salvis - July 20, 2007 - 01:05

Yes, your step-by-step explanation has helped, and I was able to reproduce the issue:

1. have User1 as moderator
2. remove User1 from moderator list, post a topic as admin
3. add User2 as moderator

User2 cannot edit the topic. The topic has no node_access entry for the acl realm. If you post another topic now, this new topic will have the acl node_access entry.

It seems that assigning a moderator does not enable administering topics that were created while there was no moderator, but only topics that are created with a moderator in place. I'm not sure whether this is intentional or a bug...

#4

snowwind - July 20, 2007 - 02:41

I think it's a bug.
can you change this function that edit all topics be moderator?

#5

merlinofchaos - July 20, 2007 - 02:49

Ahh, I see what is happening now.

You can work around this bug by going to the node settings and rebuilding the node access table.

#6

snowwind - July 20, 2007 - 05:14

I already fixed this bug and text it. add new moderator and they will have right to edit all topics in this forum.
you need update this new code:

<?php

/**old code **/
  // mass update
 
$result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {term_node} tn ON tn.nid = n.nid WHERE tn.tid = %d", $form_values['tid']);
  while (
$node = db_fetch_object($result)) {   
   
node_access_write_grants($node, $grants, 'forum_access');
  }

/**add new code in here **/
  // mass update
 
$result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {term_node} tn ON tn.nid = n.nid WHERE tn.tid = %d", $form_values['tid']);
  while (
$node = db_fetch_object($result)) {   
   
$acl_id = db_result(db_query("SELECT acl_id FROM {acl_node} WHERE nid = %d",$node->nid));
   
$count_acluser = db_result(db_query("SELECT COUNT(*) FROM {acl_user} WHERE acl_id = %d", $acl_id));
    if (
$count_acluser != 0) {
       
$acl_sql = db_query("SELECT * FROM {acl_node} WHERE nid = %d",$node->nid);
        unset(
$grants_acl);
        while (
$row = db_fetch_object($acl_sql)){
           
$grants_acl[] = array(
               
'realm' => 'acl',
               
'gid' => $row->acl_id,
               
'grant_view' => $row->grant_view,
               
'grant_update' => $row->grant_update,
               
'grant_delete' => $row->grant_delete,
            );
        }
       
node_access_write_grants($node, $grants_acl);
    }
   
node_access_write_grants($node, $grants, 'forum_access');
  }
?>

I change the function when add new moderator by admin, and then will give moderator all right to this forum ,not just after create new topic in this forum.
If you find problem or new bug, please tell me :) right now. thank you everyone.

#7

merlinofchaos - July 20, 2007 - 06:52

Could you possibly submit this as a patch?

#8

snowwind - July 21, 2007 - 03:46
Assigned to:Anonymous» snowwind
Status:active» patch (reviewed & tested by the community)

of course, my pleasure

#9

salvis - July 23, 2007 - 23:50
Status:patch (reviewed & tested by the community)» active

I think merlinofchaos meant to upload a patch file (generated with diff -up, ensures perfect transmission) and then set the status to patch (code needs review).

#10

kirie - November 25, 2007 - 08:01
Status:active» patch (code needs work)

Created the patch based on code above.

AttachmentSize
forum_access_old-forums.patch1.21 KB

#11

salvis - November 25, 2007 - 17:49

Thank you. Have you tested it? In what way does it need work?

#12

wuyang - November 28, 2007 - 07:57

yes, what will happen if there 30,000 or 100,000 topics under forum, I think in this way it'll enhance load of server, and maybe crash server

#13

kirie - November 28, 2007 - 11:29

Yes, wuyang is right. It works ok for smaller sites, but once the site has a lot of topics it will run into trouble. Will look for an alternative solution.

#14

salvis - November 28, 2007 - 12:41
Version:5.x-1.7» 6.x-1.x-dev
Priority:critical» normal

This is definitely a problem. It's not done often and I don't think it could crash the server, because it's only one job, but it could time out and leave the database in an intermediate state. This could be said of the old code, too, but there's more processing done in the new code, so it's more likely to happen.

There seems to be no solution for handling time/memory-consuming operations such as this one under Drupal 5, and applying a patch like this one could push FA over the edge for large sites. This has to wait for Drupal 6.

see http://drupal.org/node/196002

 
 

Drupal is a registered trademark of Dries Buytaert.