another functional bug:
I saw some posts that not showed in the forums but sender insist that he/she sent it.
I look at the db and i could find those posts.
But the strange thing is "approved" value is set to 2.
As far as i could find the approved should be -1,0,1
I could find 13 posts with "approved"=2 and one post with "approved"=98
when i change the value to 1 the post will show up in topic.
i just can found this setVar for approved value:
in newbb/post.php:
$approved = $topic_handler->getPermission($forum_obj, $topic_status, 'noapprove');
$post_obj->setVar('approved', $approved);
i follow the getPermission function here:
in newbb/class/topic.php
// get permission
// parameter: $type: 'post', 'view', 'reply', 'edit', 'delete', 'addpoll', 'vote', 'attach'
// $gperm_names = "'forum_can_post', 'forum_can_view', 'forum_can_reply', 'forum_can_edit', 'forum_can_delete', 'forum_can_addpoll', 'forum_can_vote', 'forum_can_attach', 'forum_can_noapprove'";
function getPermission($forum, $topic_locked = 0, $type = "view")
{
global $xoopsUser, $xoopsModule;
static $_cachedTopicPerms;
mod_loadFunctions("user", "newbb");
if (newbb_isAdmin($forum)) return 1;
$forum_id = is_object($forum) ? $forum->getVar('forum_id') : intval($forum);
if ( $forum_id < 1 ) return false;
if ($topic_locked && 'view' != $type) {
$permission = 0;
} else {
$perm_handler =& xoops_getmodulehandler('permission', 'newbb');
$permission = $perm_handler->getPermission("forum", $type, $forum_id);
}
return $permission;
}
So i follow the getPermission function here:
in newbb/class/permission.php
function getPermission($type, $gperm_name = "access", $id = 0)
{
global $xoopsUser, $xoopsModule;
if ($GLOBALS["xoopsUserIsAdmin"] && $xoopsModule->getVar("dirname") == "newbb") {
return true;
}
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
if ( !$groups ) return false;
if ( !$allowed_groups = $this->getGroups("{$type}_{$gperm_name}", $id) ) return false;
return count(array_intersect($allowed_groups, $groups));
}
It seems that count(array_intersect ... is doing the wrong job.
The user is belong to 5 different groups.
Im still investigate it to find a solution.
edit:
It seems it is because those users are belong to some groups that those groups have the permission to send post without approval.
So at the above function it count them double.
As a temporary solution i set the need approval permission for all forums to registered users group_no=2.
But i still think newbb should correctly do it even when a user have double or triple permission.
It is still a bug in my idea.
edit number 2:
eg change that line to the below:
if( count(array_intersect($allowed_groups, $groups)) ) {
return true;
} else {
return false;
}
I think the above solution is good. maybe need some alteration in codes.