View/Enter Board Permissions

Started by Arantor, December 15, 2009, 08:08:21 PM

Previous topic - Next topic

Stigmartyr

Quote from: sattninja on August 20, 2010, 10:55:26 PM
excellent mod man took me a minute to figure out how to set it up but it is awesome :) :)

Im finding it a little confusing to make this mod useful as well.

Originally I'd wanted to restrict posting to some boards until a post count was reached and I can't really figure out the best way to do that as the board only allows you to assign one kind of permission profile.

Anyone able to share some insight?

sattninja

i had a mod that worked on RC2 called view/enter board permission. I lost it when i updated to RC4 I have tried getting it to work and cannot i get tons of errors using RC2 emulation so my ??? is there a more current updated mod out there that will do what that mod does

I want members to be able to see boards but not enter them

any help will be greatly appreciated
Running Rc4

Illori

please use the support thread for that mod, and request the author to update it. you could also try http://custom.simplemachines.org/mods/index.php?mod=1332 which i have heard still works with current versions.

Arantor

Quoteplease use the support thread for that mod, and request the author to update it.

The original author will not update it, and the current maintainer doesn't seem to have time. I'm just glad I gave it away to be honest, caused much more trouble than it saved writing that mod, most people just didn't understand what it did, and why it looked like it broke their forum (when they just didn't read the instructions)

Spoogs

#125
I actually love this mod and have it updated for my use... ssems fairly easy to maintain... I've even wondered if I should ask to take it over.... hmmmmmmm, pondering.


Quote from: IncognitoMuse on January 07, 2011, 06:46:33 AM
most people just didn't understand what it did, and why it looked like it broke their forum (when they just didn't read the instructions)
Agreed I would get PM's even after explicitly stating that all board permissions will need to be redone... oh well.


@OP

Code ( sources/load.php FIND) Select

if ($user_info['is_admin'])
$user_info['query_see_board'] = '1=1';
// Otherwise just the groups in $user_info['groups'].
else
$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0' . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';


Code ( replace with) Select
loadBoardsVisibility();




Code ( themes/default/Maganeboards.template.php FIND) Select

</dd>
<dt>
<strong>', $txt['mboards_groups'], ':</strong><br />
<span class="smalltext">', $txt['mboards_groups_desc'], '</span>
</dt>
<dd>';

// List all the membergroups so the user can choose who may access this board.
foreach ($context['groups'] as $group)
echo '
<label for="groups_', $group['id'], '">
<input type="checkbox" name="groups[]" value="', $group['id'], '" id="groups_', $group['id'], '"', $group['checked'] ? ' checked="checked"' : '', ' class="input_check" />
<span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : '', $group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : '', '>
', $group['name'], '
</span>
</label><br />';
echo '
<em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[]\');" /><br />
<br />
</dd>';


Code ( replace with) Select
</dd>';
// We don't need membergroups, we don't need no DB control :P


sattninja

wow that is the exact edits i had to make but your a just a tad different I will try that when i get home

thanks alot

Running Rc4

Spoogs

the code is different between RC2 and RC4, the mod is telling you to look for the RC2 code ;)

sattninja

exactly i see that i am hopeful this will work

looks good


I won't know till later

I will update accordingly

thanks
Running Rc4

sattninja

ok i installed and made the edits and i get this error

Fatal error: Call to undefined function loadboardsvisibility() in /home/lostzer1/public_html/appfuzion.com/Sources/Load.php on line 566

I have attached the 2 files can you please take a look and see what is wrong



Running Rc4

Spoogs


sattninja

same error

Call to undefined function loadboardsvisibility() in /home/lostzer1/public_html/appfuzion.com/Sources/Load.php on line 566
Running Rc4

Spoogs

hmmm thats weird... are you sure you installed the mod?

try this

Arantor

One of the instructions was missed, that this has to go at the end of Load.php.



// Figure out what we can see. Note, because this sets up query_see_board, we cannot call boardsAllowedTo() :(
function loadBoardsVisibility() {
global $user_info, $smcFunc;

if($user_info['is_admin']) {
$user_info['query_see_board'] = '1=1';
$user_info['query_see_only_board'] = '1=1';
return;
}

// SLOW QUERY?
$query = $smcFunc['db_query']('', '
SELECT b.id_board, bp.permission, bp.add_deny
FROM {db_prefix}boards AS b INNER JOIN {db_prefix}board_permissions AS bp ON (b.id_profile = bp.id_profile)
WHERE id_group IN ({array_int:groups}) AND bp.permission IN ({array_string:permission})',
array(
'groups' => $user_info['groups'],
'permission' => array('view_board', 'enter_board'),
)
);

$boards = array(
'allow' => array(
'view_board' => array(),
'enter_board' => array(),
),
'deny' => array(
'view_board' => array(),
'enter_board' => array(),
)
);

while($row = $smcFunc['db_fetch_assoc']($query)) {
$area = $row['add_deny'] ? 'allow' : 'deny';
$boards[$area][$row['permission']][] = $row['id_board'];
}
$smcFunc['db_free_result']($query);

$allow = array_diff($boards['allow']['view_board'], $boards['deny']['view_board']);
$user_info['query_see_only_board'] = count($allow) > 0 ? 'b.id_board IN (' . implode(',', $allow) . ')' : '1=0';

$allow = array_diff($boards['allow']['enter_board'], $boards['deny']['enter_board']);
$user_info['query_see_board'] = count($allow) > 0 ? 'b.id_board IN (' . implode(',', $allow) . ')' : '1=0';
}

Spoogs

Ahh thats it... I hadnt looked that far down since that part doesnt fail on install

sattninja

that did it man thanks guys really appreciate it

it is working fine

you rock
Running Rc4

Spoogs

glad its working for ya now... I really should have checked all the edits tho (now I know better :) )

sattninja

no worries man there is no better community than the smf community

appreciate the help

Running Rc4

sattninja

i have one more question i have made a profile for guests to be able to view a board and enter it to see threads and it is half working it lets the guest see the board but when i try to go into it as a guest it kicks me to the register/login board
Running Rc4

Spoogs

double check the permissions... i just tried it and its working as intended.

Advertisement: