News:

Wondering if this will always be free?  See why free is better.

Main Menu

How to disable a admin function!?

Started by nvcnvn, November 26, 2010, 08:10:58 AM

Previous topic - Next topic

nvcnvn

For some reason, I want disable the package function in admin panel.

I want when some one (another admin...) click on the Packages link, he will see some message instead of the normal page!!!

Please help me to do this!

Illori

this would require a mod, you should post in the mod request board.


Joker™

Try K@ method first, if that don't work as you have expected then try method mentioned below.

I haven't tested the code that much, so do make backup of your file before editing it

open Sources\Admin.php

Find: 'packages' => array(
'label' => $txt['package'],
'file' => 'Packages.php',
'function' => 'Packages',
'permission' => array('admin_forum'),
'icon' => 'packages.gif',
'subsections' => array(
'browse' => array($txt['browse_packages']),
'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'),
'installed' => array($txt['installed_packages']),
'perms' => array($txt['package_file_perms']),
'options' => array($txt['package_settings']),
),
),




Replace it with:
'packages' => ($context['user']['id'] == 1) ? array(
'label' => $txt['package'],
'file' => 'Packages.php',
'function' => 'Packages',
'permission' => array('admin_forum'),
'icon' => 'packages.gif',
'subsections' => array(
'browse' => array($txt['browse_packages']),
'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'),
'installed' => array($txt['installed_packages']),
'perms' => array($txt['package_file_perms']),
'options' => array($txt['package_settings']),
),
): array('label' => '', 'file' => '', 'function' => '', 'permission' => '', 'icon' => '', 'subsections' => ''),
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Norv

You could create a special "lower admin" membergroup, to which you can assign the permissions you wish (much more than global moderators have), but do not assign "Administrate forum and database" to them. Then add who you want to this group.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github


Illori

Sources/Admin.php
Code (find) Select

'packages' => array(
'label' => $txt['package'],
'file' => 'Packages.php',
'function' => 'Packages',
'permission' => array('admin_forum'),
'icon' => 'packages.gif',
'subsections' => array(
'browse' => array($txt['browse_packages']),
'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'),
'installed' => array($txt['installed_packages']),
'perms' => array($txt['package_file_perms']),
'options' => array($txt['package_settings']),
),


Code (replace) Select

'packages' => array(
'label' => $txt['package'],
'file' => 'Packages.php',
'function' => 'Packages',
'permission' => array('admin_packages'),
'icon' => 'packages.gif',
'subsections' => array(
'browse' => array($txt['browse_packages']),
'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'),
'installed' => array($txt['installed_packages']),
'perms' => array($txt['package_file_perms']),
'options' => array($txt['package_settings']),
),


Sources/Packages.php
Code (find) Select

isAllowedTo('admin_forum');


Code (replace) Select

isAllowedTo('admin_packages');


you will find that code 2 times replace both

$themedir/languages/ManagePermissions.english.php

Code (add) Select

$txt['permissionname_admin_packages'] = 'Administrate packages';


Sources/ManagePermissions.php

Code (find) Select

'admin_forum' => array(false, 'maintenance', 'administrate'),


Code (add after) Select

'admin_packages' => array(false, 'maintenance', 'administrate'),


Code (find) Select

$context['non_guest_permissions'] = array(
'make_bookmarks',
'delete_replies',
'karma_edit',
'poll_add_own',
'pm_read',
'pm_send',
'profile_identity',
'profile_extra',
'profile_title',
'profile_remove',
'profile_server_avatar',
'profile_upload_avatar',
'profile_remote_avatar',
'profile_view_own',
'mark_any_notify',
'mark_notify',
'admin_forum',
'manage_boards',
'manage_attachments',
'manage_smileys',
'edit_news',
'access_mod_center',
'moderate_forum',
'issue_warning',
'manage_membergroups',
'manage_permissions',
'manage_bans',
'move_own',
'modify_replies',
'send_mail',
'approve_posts',
);
}


Code (replace) Select

$context['non_guest_permissions'] = array(
'make_bookmarks',
'delete_replies',
'karma_edit',
'poll_add_own',
'pm_read',
'pm_send',
'profile_identity',
'profile_extra',
'profile_title',
'profile_remove',
'profile_server_avatar',
'profile_upload_avatar',
'profile_remote_avatar',
'profile_view_own',
'mark_any_notify',
'mark_notify',
'admin_forum',
'admin_packages',
'manage_boards',
'manage_attachments',
'manage_smileys',
'edit_news',
'access_mod_center',
'moderate_forum',
'issue_warning',
'manage_membergroups',
'manage_permissions',
'manage_bans',
'move_own',
'modify_replies',
'send_mail',
'approve_posts',
);
}


Code (find) Select

{
global $context;

$context['illegal_permissions'] = array();
if (!allowedTo('admin_forum'))
$context['illegal_permissions'][] = 'admin_forum';
if (!allowedTo('manage_membergroups'))
$context['illegal_permissions'][] = 'manage_membergroups';
if (!allowedTo('manage_permissions'))
$context['illegal_permissions'][] = 'manage_permissions';
}




Code (replace) Select

{
global $context;

$context['illegal_permissions'] = array();
if (!allowedTo('admin_forum'))
$context['illegal_permissions'][] = 'admin_forum';
if (!allowedTo('admin_packages'))
$context['illegal_permissions'][] = 'admin_packages';
if (!allowedTo('manage_membergroups'))
$context['illegal_permissions'][] = 'manage_membergroups';
if (!allowedTo('manage_permissions'))
$context['illegal_permissions'][] = 'manage_permissions';
}


Sources/PackageGet.php

Code (find) Select

isAllowedTo('admin_board');


Code (replace) Select

isAllowedTo('admin_packages');


this change will add a permission for the package manager. make sure you backup before attempting to apply this change.

nvcnvn

Thanks for all of your help! It's helpfull!

I will try the method of Joker and illori instead of using a mod.

The reason is....:
I going to share my hosting with my freinds, and install SMF for him.
But I do not belive him 100%, he a realy... disruptive. So I tring to disaple all the function which maybe help him do something wrong! Start with package manager!

Joker™

Quote from: nvcnvn on November 26, 2010, 11:30:17 PM
The reason is....:
I going to share my hosting with my freinds, and install SMF for him.
But I do not belive him 100%, he a realy... disruptive. So I tring to disaple all the function which maybe help him do something wrong! Start with package manager!
Just out of topic, do you really want to work with such person? as you must have 100% faith in your partner if you want to work with him/her.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

YogiBear

Oh Gawd, don't ever give admin powers to someone you cannot trust 100%

Once I'd left a forum where I used to be Site Admin a Mod was promoted, against my recommendation, whereupon he ran riot. Needless to say my account was first on his hit list!
SMF v2.1.3  Mods : Snow & Garland v1.4,  PHP  v.7.4.33

Advertisement: