Advertisement:

ManagePermissions.php Question

Aloittaja The Wizard, elokuu 19, 2013, 09:16:08 AP

« edellinen - seuraava »

The Wizard

Hello:

I don't know a great deal about the Manage Permissions section so keep that in mind please.
I am working on my own version of the smf shop mod and they have the following in their install.xml file -




<file name="$sourcedir/ManagePermissions.php">
<operation>
<search position="before"><![CDATA[
'profile_remote_avatar',
'profile_remove_own',
]]></search>
<add><![CDATA[
// Begin SMFShop code
'shop_main',
'shop_buy',
'shop_invother',
'shop_sendmoney',
'shop_senditems',
'shop_bank',
// End SMFShop code
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
'pm_read' => array(false, 'pm', 'use_pm_system'),]]></search>
<add><![CDATA[
// Begin SMFShop code
'shop_main' => array(false, 'shop', 'shop'),
'shop_buy' => array(false, 'shop', 'shop'),
'shop_invother' => array(false, 'shop', 'shop'),
'shop_sendmoney' => array(false, 'shop', 'shop'),
'shop_senditems' => array(false, 'shop', 'shop'),
'shop_bank' => array(false, 'shop', 'shop'),
'shop_trade' => array(false, 'shop', 'shop'),
// End SMFShop code]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
$context['non_guest_permissions'] = array(]]></search>
<add><![CDATA[
$context['non_guest_permissions'] = array(
// Begin SMFShop code
'shop_main',
'shop_buy',
'shop_invother',
'shop_sendmoney',
'shop_senditems',
'shop_bank',
// End SMFShop code]]></add>
</operation>
</file>


Since I created a hook file (see below) do I still have to include the code above in the Manage Permissions file?


function wizards_smf_shop_add_hook(&$actionArray)
{
$actionArray['shop_buy'] = array('Subs-Wizards_Shop_User.php', 'ShopBuy');
$actionArray['shop_display'] = array('Subs-Wizards_Shop_User.php', 'ShopDisplay');
$actionArray['shop_inv'] = array('Subs-Wizards_Shop_User.php', 'ShopInv');
$actionArray['shop_main'] = array('Subs-Wizards_Shop_User.php', 'ShopMain');
$actionArray['shop_trade'] = array('Subs-Wizards_Shop_User.php', 'ShopTrade');
$actionArray['shop_sendmoney'] = array('Subs-Wizards_Shop_User.php', 'ShopSendmoney');
$actionArray['shop_senditems'] = array('Subs-Wizards_Shop_User.php', 'ShopSenditems');
$actionArray['shop_creditcenter'] = array('Subs-Wizard_Creditcenter.php', 'ShopCreditcenter');
$actionArray['shop_invother'] = array('Subs-Wizards_Shop_User.php', 'ShopInvother');
$actionArray['shop_bank'] = array('Subs-Wizards_Shop_User.php', 'ShopBank');

$actionArray['shop_admin_settings'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminSettings');
$actionArray['shop_admin_items_add'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminItemsadd');
$actionArray['shop_admin_items_edit'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminItemsedit');
$actionArray['shop_admin_items_remove'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminItemsRemove');
$actionArray['shop_admin_restock'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminRestock');
$actionArray['shop_admin_categories'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminCategories');
$actionArray['shop_admin_inv'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminInv');
$actionArray['shop_admin_usergroup'] = array('Subs-Wizards_Shop_Admin.php', 'ShopAdminUsergroup');
}


Thanks

Wiz

All Colours Sam

There is indeed a hook for adding permissions, however the hook you posted doesn't do that, the one you want is integrate_load_permissions, the hook passes two vars, $permissionGroups and $permissionList, on your hook function do a print_r() to see whats the exact structure of both arrays or take a look at the array itself on the Source file.

It basically pass the entire permissions array, once you have it, you just need to append your new permissions.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

The Wizard

Thanks Suki and it's nice to see you again  :)

Wiz

All Colours Sam

Something tells me you didn't get the idea behind the permissions hook, there is/was a topic explaining how that system works, unfortunately I can't find it at the moment.

When using the hook for permissions you would also gonna need to add some text strings, these text strings needs to have a particular key name otherwise it just won't help, heres a simple static method I use to add permissions:


public static function permissions(&$permissionGroups, &$permissionList)
{
$permissionGroups['membergroup']['simple'] = array('breeze_per_simple');
$permissionGroups['membergroup']['classic'] = array('breeze_per_classic');

$permissionList['membergroup']['breeze_deleteStatus'] = array(
false,
'breeze_per_classic',
'breeze_per_simple');
$permissionList['membergroup']['breeze_deleteComments'] = array(
false,
'breeze_per_classic',
'breeze_per_simple');
$permissionList['membergroup']['breeze_postStatus'] = array(
false,
'breeze_per_classic',
'breeze_per_simple');
$permissionList['membergroup']['breeze_postComments'] = array(
false,
'breeze_per_classic',
'breeze_per_simple');
}


And the text strings used:


$txt['permissiongroup_simple_breeze_per_simple'] = 'Breeze mod permissions';
$txt['permissiongroup_breeze_per_classic'] = 'Breeze mod permissions';
$txt['permissionname_breeze_deleteStatus'] = 'Delete all status on any wall';
$txt['permissionname_breeze_deleteComments'] = 'Delete all comments on any wall';
$txt['permissionname_breeze_postStatus'] = 'Post new Status on any wall';
$txt['permissionname_breeze_postComments'] = 'Post new Comments on any wall';
$txt['permissionname_breeze_edit_settings_any'] = 'Edit the user settings of any wall';


In this case I used "breeze" as a unique identifier, you would have to do the same and pick a unique name for you permissions.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: