Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4267
Latest: ramiroelliot
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 43544
Total Topics: 7565
Most Online Today: 70
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 45
Total: 45

Author Topic: Permissions query  (Read 7099 times)

0 Members and 1 Guest are viewing this topic.

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Permissions query
« on: November 27, 2022, 09:59:51 am »
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?


Listen to Quizland radio here

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16563
    • View Profile
Re: Permissions query
« Reply #1 on: November 28, 2022, 08:53:23 pm »
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/

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Permissions query
« Reply #2 on: November 29, 2022, 01:31:46 am »
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.



Listen to Quizland radio here

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16563
    • View Profile
Re: Permissions query
« Reply #3 on: November 29, 2022, 01:15:30 pm »
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/

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Permissions query
« Reply #4 on: November 30, 2022, 01:15:05 am »
Thanks VB I'll test it out on my test site first


Listen to Quizland radio here

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Permissions query
« Reply #5 on: November 30, 2022, 05:55:12 am »
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 »


Listen to Quizland radio here

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16563
    • View Profile
Re: Permissions query
« Reply #6 on: November 30, 2022, 08:09:05 am »
 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/

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Permissions query
« Reply #7 on: November 30, 2022, 09:52:38 am »
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 »


Listen to Quizland radio here

Offline davejo

  • Downloads Pro Customer
  • Full Member
  • *****
  • Posts: 185
    • View Profile
    • Quizland
Re: Permissions query
« Reply #8 on: March 26, 2023, 04:43:48 am »
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 »


Listen to Quizland radio here

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
7352 Views
Last post February 09, 2009, 07:13:38 pm
by SMFHacks
6 Replies
8455 Views
Last post April 12, 2011, 03:31:19 pm
by bruno
3 Replies
3767 Views
Last post December 09, 2014, 12:35:39 pm
by shuban
1 Replies
3159 Views
Last post October 30, 2015, 11:13:23 pm
by nend
12 Replies
5655 Views
Last post February 10, 2017, 08:56:57 am
by GeorG

+- Recent Topics

Move picture from main gallery to user gallery by Lirorobert
Today at 03:08:26 pm

Gallery Pro reinstalation by Lirorobert
Today at 03:04:50 pm

quoting part of message by Lirorobert
October 04, 2024, 03:21:40 pm

Does SMF Gallery support by SMFHacks
October 02, 2024, 06:14:26 am

Restoring a deleted photo by Monocero
September 28, 2024, 04:12:20 am

Item count on Gallery Tab shows double by SMFHacks
September 26, 2024, 12:59:20 pm

Forum post missing when image over 4000x pixels is uploaded to gallery by Michel68
September 24, 2024, 01:37:17 pm

Setting a photo as invisible by Monocero
September 17, 2024, 02:11:56 pm

Two gallery names by SMFHacks
September 15, 2024, 02:17:49 pm

Bar during the regeneration of miniatures by Monocero
September 15, 2024, 12:35:08 pm

Powered by EzPortal