Customizing SMF > Tips and Tricks

No attachment limit for admins

<< < (6/7) > >>

searchgr:
Any update here?

mybiafraland:
waiting for update as well

Kays:
Hi, look in Subs-Post.php for the same set of checks and make the recommended change to those also.
Except, instead of !$user_info['is_admin'] use !$context['user']['is_admin']

Elmacik:
A smoother way I told here:
http://www.simplemachines.org/community/index.php?topic=479722.0

dougiefresh:

--- Quote from: Chalky on March 17, 2012, 10:48:23 AM ---
--- Quote from: michaeloeser on March 02, 2012, 04:19:05 AM ---Doesn´t seem to work for me. I´m the main and only administrator of my forum and although I made the changes to Post.php I´m not able to upload more and bigger files as defined in the attachment settings. Using SMF 2.0.2.

Any ideas?

--- End quote ---

For me neither.  I'm using 2.0.2, just made exactly the edits shown above, but nothing happened...

--- End quote ---
The reason it doesn't work is it's incomplete.  Modifications must be made to the Themes/default/Post.template.php as well.... 

In Sources/Post.php, find and replace:

--- Code: (find) ---$context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit'])
--- End code ---

--- Code: (Replace) ---$context['num_allowed_attachments'] = ($user_info['is_admin'] || empty($modSettings['attachmentNumPerPostLimit']))
--- End code ---

In Sources/Subs-Post.php, find and replace:

--- Code: (Find) ---function createAttachment(&$attachmentOptions)
{
global
--- End code ---

--- Code: (Replace) ---function createAttachment(&$attachmentOptions)
{
global $user_info,
--- End code ---


--- Code: (Find) ---if (!empty($modSettings['attachmentSizeLimit']) && $attachmentOptions['size'] > $modSettings['attachmentSizeLimit'] * 1024)
--- End code ---

--- Code: (Replace) ---if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $attachmentOptions['size'] > $modSettings['attachmentSizeLimit'] * 1024)
--- End code ---

In Themes/default/Post.template.php, find and replace these:

--- Code: (Find) ---function template_main()
{
global
--- End code ---

--- Code: (Replace) ---function template_main()
{
global $user_info,
--- End code ---


--- Code: (Find) ---if ($context['num_allowed_attachments'] > 1)]]></search>
--- End code ---

--- Code: (Replace) ---if ($user_info['is_admin'] || $context['num_allowed_attachments'] > 1)
--- End code ---


--- Code: (Find) ---var allowed_attachments = ', $context['num_allowed_attachments'], ';
--- End code ---

--- Code: (Replace) ---var allowed_attachments = ', (empty($user_info['is_admin']) ? $context['num_allowed_attachments'] : 100), ';
--- End code ---


--- Code: (Find) ---if (!empty($modSettings['attachmentCheckExtensions']))
--- End code ---

--- Code: (Replace) ---if (!$user_info['is_admin'] && !empty($modSettings['attachmentCheckExtensions']))
--- End code ---


--- Code: (Find) ---if (!empty($context['attachment_restrictions']))
--- End code ---

--- Code: (Replace) ---if (!$user_info['is_admin'] && !empty($context['attachment_restrictions']))
--- End code ---


I've posted up a mod based on this thread with all my modifications (9 operations total) here: No Attachment Limit for Admins.  It hasn't been approved yet....

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version