Facebook 

SMFHacks.com - Celebrating 20 Years!

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4341
Latest: jmac32here
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 44306
Total Topics: 7676
Most Online Today: 293
Most Online Ever: 27044
(May 30, 2026, 09:10:16 pm)
Users Online
Members: 0
Guests: 206
Total: 206

Author Topic: Permissions query  (Read 11700 times)

0 Members and 1 Guest are viewing this topic.

Permissions query
« on: »
I created a new group 'New' that has the permission profile set to 'inherit from:
Regular Members'.

These members are set to download certain categories, let's call them 'Cups' in the 'Downloads'

In their profiles under account settings they are set to

Primary Membergroup - (no primary membergroup)
Additional Membergroups - (New)

The way I see it (no primary membergroup) means they are regarded as 'Regular Members *' for everything else to do with the forum.

The problem is that if I set them to those settings then they cannot download items from the 'Cups' downloads area, yet if I set them to 'Primary Membergroup - New' then they can download items.

This seems to be wrong to me as the 'Additional Membergroups' setting should allow them to download even if their account is set to Primary Membergroup - (no primary membergroup).

Anyone who has Primary Membergroup - (no primary membergroup) would not be able to download.

I should add that obviously the 'New' group has permissions set in the downloads for 'Cups' but the '* Full Member, Hero Member, Jr. Member and Newbie are not.

If you're following me so far; what's your thoughts?

Re: Permissions query
« Reply #1 on: »
I probably can come up with a code to allow a member with the allow permission in any of groups/additional groups

Currently it is set for any deny statement to override any allow permission on the category

Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Re: Permissions query
« Reply #2 on: »
That would be good, thank you VB.

The only reason this came up is now the 'Announcement' issue, which I reported on SMF, has ben resolved in 2.1.3 I sent out a test announcement and omitted one group, Regular Members, but sent it to everyone else but the 'New' group who were included didn't get the email.


Re: Permissions query
« Reply #3 on: »
This is experimental but if it looks good will update the permissions code in all my mods to use this same logic.

Quick overview on permissions and how it works in this setup.
download admins always have full access.
The global permissions under admin -> permissions must be set to allowed in order for users to get access via category level permissions.

If no category level permission is setup access is assumed allowed!  If any category permissions setup in the category then you must grant each group access via category level permissions. An allowed in any membergroup overrides a deny


Open
Sources\Downloads2.php around line(6030):
Replace the whole function ending in }
Code: [Select]
function Downloads_GetCatPermission($cat, $perm, $return = false, $checkpostGroup = false, $checkAdditonal = true, $groupID = 0)

with
Code: [Select]

function Downloads_GetCatPermission($cat, $perm, $return = false, $checkpostGroup = false, $checkAdditonal = true, $groupID = 0)
{
global $smcFunc, $txt, $user_info;

$manage = allowedTo('downloads_manage');
// They can manage the downloads so let them have access to everything
if ($manage == true)
return true;
$cat = (int) $cat;
    $groupList = array();

if ($user_info['is_guest'] == 1)
{
$groupList[] = -1;
}
else
{
$request = $smcFunc['db_query']('', '
SELECT id_group,additional_groups
FROM {db_prefix}members
WHERE id_member = ' . $user_info['id'],
);

while ($row = $smcFunc['db_fetch_assoc']($request))
{

if (empty($row['additional_groups']))
$groupList = array($row['id_group']);
else
$groupList = array_merge(
array($row['id_group']),
explode(',', $row['additional_groups'])
);

}
}

// Handle case if no permissions set
    $request = $smcFunc['db_query']('', "
SELECT
count(*) as total
FROM {db_prefix}down_catperm as c
WHERE c.ID_CAT = $cat ");
    $row = $smcFunc['db_fetch_assoc']($request);
if ($row['total'] == 0)
return true;

// check for permissions
$request = $smcFunc['db_query']('', "
SELECT
count(*) as total
FROM {db_prefix}down_catperm as c
WHERE c.ID_GROUP IN(" . implode(',',$groupList ) . ") AND c.ID_CAT = $cat AND c." . $perm . " = 1");
$row = $smcFunc['db_fetch_assoc']($request);
if ($row['total'] > 0)
return true;
else
{

if ($perm == 'view')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_view'],false);
else
return false;

}
else if ($perm == 'download')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_download'],false);
else
return false;

}
else if ($perm == 'addfile')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_add'],false);
else
return false;

}
else if ($perm == 'editfile')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_edit'],false);
else
return false;

}
else if ($perm == 'delfile')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_delete'],false);
else
return false;

}
else if ($perm == 'ratefile')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_ratefile'],false);
else
return false;

}
else if ($perm == 'addcomment')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_addcomment'],false);
else
return false;

}
else if ($perm == 'editcomment')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_editcomment'],false);
else
return false;

}
else if ($perm == 'report')
{
if ($return == false)
fatal_error($txt['downloads_perm_no_report'],false);
else
return false;

}

}

}
« Last Edit: November 29, 2022, 01:19:24 pm by SMFHacks »
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Re: Permissions query
« Reply #4 on: »
Thanks VB I'll test it out on my test site first

Re: Permissions query
« Reply #5 on: »
Thank you again VB, that has done exactly what I thought it should have done in the first place, that's no disrespect you you by btw. Members in the 'New' group can see downloads and their primary group is set to (no primary membergroup) and they are now in the 'Additional Membergroups'.

I tested the announcements and the 'New' group now got the email although they weren't included in the list, I only selected regular members and the admin

Slightly off topic.

I'm not sure if this is related to Downloads or SMF but I tried to install the latest version 6.1.4 on my fresh install test site and got the errors as below. Would you have any idea why it would do that?

I should add that I deleted the old database and all files etc and started from new. I have also now tested installing other mods and they are fine. I've tried installing various versions from 6.0.1 up to the latest.


Code: [Select]
array(16) { [0]=> array(3) { ["file"]=> string(88) "***testing/Sources/Subs-Db-mysql.php" ["line"]=> int(590) ["function"]=> string(9) "log_error" } [1]=> array(3) { ["file"]=> string(88)
 "***testing/Sources/Subs-Db-mysql.php" ["line"]=> int(494) ["function"]=> string(12) "smf_db_error" } [2]=> array(3) { ["file"]=> string(81)
 "***testing/Sources/Errors.php" ["line"]=> int(138) ["function"]=> string(12) "smf_db_query" } [3]=> array(3) { ["file"]=> string(81)
 "***testing/Sources/Errors.php" ["line"]=> int(301) ["function"]=> string(9) "log_error" } [4]=> array(1) { ["function"]=> string(17)
 "smf_error_handler" } [5]=> array(3) { ["file"]=> string(88) "***testing/Sources/Subs-Db-mysql.php" ["line"]=> int(1027) ["function"]=> string(22)
 "mysqli_stmt_bind_param" } [6]=> array(3) { ["file"]=> string(81) "***testing/Sources/Errors.php" ["line"]=> int(129) ["function"]=> string(19)
 "smf_db_error_insert" } [7]=> array(3) { ["file"]=> string(88) "***testing/Sources/Subs-Db-mysql.php" ["line"]=> int(590) ["function"]=> string(9)
 "log_error" } [8]=> array(3) { ["file"]=> string(88) "***testing/Sources/Subs-Db-mysql.php" ["line"]=> int(494) ["function"]=> string(12)
 "smf_db_error" } [9]=> array(3) { ["file"]=> string(79) "***testing/Sources/Subs.php" ["line"]=> int(5824) ["function"]=> string(12)
 "smf_db_query" } [10]=> array(3) { ["file"]=> string(88) "***testing/Packages/temp/dohooks.php" ["line"]=> int(40) ["function"]=> string(24)
 "add_integration_function" } [11]=> array(4) { ["file"]=> string(83) "***testing/Sources/Packages.php" ["line"]=> int(1028) ["args"]=> array(1) { [0]=> string(88)
 "***testing/Packages/temp/dohooks.php" } ["function"]=> string(7) "require" } [12]=> array(3) { ["file"]=> string(79)
 "***testing/Sources/Subs.php" ["line"]=> int(6016) ["function"]=> string(14) "PackageInstall" } [13]=> array(3) { ["file"]=> string(83)
 "***testing/Sources/Packages.php" ["line"]=> int(91) ["function"]=> string(11) "call_helper" } [14]=> array(3) { ["file"]=> string(80)
 "***testing/Sources/Admin.php" ["line"]=> int(499) ["function"]=> string(8) "Packages" } [15]=> array(3) { ["file"]=> string(72)
 "***testing/index.php" ["line"]=> int(191) ["function"]=> string(9) "AdminMain" } } Error loop.
« Last Edit: November 30, 2022, 06:32:43 am by davejo »

Re: Permissions query
« Reply #6 on: »
 Assuming SMF 2.13? anything else in the error log.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Re: Permissions query
« Reply #7 on: »
Assuming SMF 2.13? anything else in the error log.
No nothing in the error log at all...I have to admit the idea that it was 2.1.3 didn't occur to me VB. I'll uninstall the packages I've installed and then overwrite the Sources and Themes with 2.1.2 version and see if it happens...I'll get back to you


UPDATE: I have installed a fresh version of 2.1.2 and it's still doing it so my best guess is that it's my host or similar where the problem is.

I'll have to investigate further.

Thanks for the reply though
« Last Edit: November 30, 2022, 10:10:17 am by davejo »

Re: Permissions query
« Reply #8 on: »
Just found out what that issue was above. Although they denied knowledge of it, that error is caused by mod_security.

To prove it I added code to the .htaccess file to stop mod_security running and got the hosts to move my site to a new server in Europe, that way the server was restarted and the code took effect.

I then installed the latest version on all my sites that are with that host and it worked ok every time with no errors.

So if anyone else gets it now you know

« Last Edit: March 26, 2023, 05:57:07 am by davejo »

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
9340 Views
Last post August 19, 2008, 09:14:06 am
by gibbs
6 Replies
9861 Views
Last post February 09, 2009, 07:13:38 pm
by SMFHacks
6 Replies
10713 Views
Last post April 12, 2011, 03:31:19 pm
by bruno
3 Replies
5375 Views
Last post December 09, 2014, 12:35:39 pm
by shuban
12 Replies
8163 Views
Last post February 10, 2017, 08:56:57 am
by GeorG

+- Recent Topics

Registration - anti bot pattern matching by SMFHacks
November 01, 2026, 07:20:17 pm

EZPortal 8 by davejo
October 21, 2026, 01:01:54 pm

Downloads Pro 7.0 Released by SMFHacks
October 07, 2026, 07:35:30 pm

[Mod]ActivityPub Federation for SMF 2.1 by SMFHacks
October 01, 2026, 05:03:45 pm

Newsletter Pro 4.0 Released by SMFHacks
September 23, 2026, 08:08:24 pm

Can't remove or restore any item from the recycle bin by SMFHacks
September 22, 2026, 11:01:51 am

MCP Server for SMF 2.1 - let Claude, ChatGPT or Cursor run your admin chores by SMFHacks
September 12, 2026, 02:50:45 pm

Suggestions for improvements to Ultimate Shoutbox & Chatroom by davejo
September 02, 2026, 01:35:09 am

Automatic Sorting of Categories by Kiwi
August 31, 2026, 12:36:09 am

' appears as ' in Most Viewed (and Recent Items ?) by SMFHacks
August 22, 2026, 11:01:56 pm

Powered by EzPortal