Customizing SMF > SMF Coding Discussion
Adding custom permissions
Alex4108:
Hey there SMF,
Today I'm trying to rewrite some of my old code to better utalize what SMF already has. So, I'm stuck at the following.
In the file Display.template.php there is an array for the Reply, Send, Print, (etc.) buttons called $normal_buttons
The syntax for each array key is something along the lines of this:
--- Code: ---'arraykey' => array(
'test' => 'PERMISSION',
'text' => '$txt MESSAGE',
'image' => 'I REALLY DONT KNOW WHAT THIS DOES -- NOT THE POINT',
'lang' => true, (Neither do I know what this does)
'url' => WHERE TO GO WHEN THE BUTTON IS CLICKED
--- End code ---
So, my question here is how do I go about adding a custom PERMISSION, so I can strongly enforce who gets the button and who doesnt?
Any help is appreciated :)
Arantor:
There's at least two ways to do it, and which one you use depends mostly on whether you want a nice admin interface or are prepared to just hard-code the list of groups into the item.
Ideally I'd like to be able to give you the exact code rather than just giving you some vague notes on it so more details about what you're trying to do exactly would be appreciated.
Alex4108:
--- Quote from: Arantor on July 06, 2012, 06:10:27 PM ---There's at least two ways to do it, and which one you use depends mostly on whether you want a nice admin interface or are prepared to just hard-code the list of groups into the item.
Ideally I'd like to be able to give you the exact code rather than just giving you some vague notes on it so more details about what you're trying to do exactly would be appreciated.
--- End quote ---
I run a clan, and our website is ran solely out of SMF. So hard-coding won't be much of a problem here.
These buttons are for our application center, where users post applications to join our clan. There is an approve button, pending button, and deny button. I already have it coded only to show up in the correct boards, but the permission would help out a little as far as making everything look nice
Arantor:
And where are these buttons going to link to, exactly?
Also, how exactly did you limit it by board?
Alex4108:
--- Quote from: Arantor on July 06, 2012, 06:16:38 PM ---And where are these buttons going to link to, exactly?
--- End quote ---
It links to a script that does a whole lot of stuff along the lines of setting member groups, telnet'ing our teamspeak server to set rank there, etc.
--- Quote from: Arantor on July 06, 2012, 06:16:38 PM ---Also, how exactly did you limit it by board?
--- End quote ---
Kinda choppy, but it gets the job done
--- Code: ---// Get the topic's forum ID
$result = $smcFunc['db_query']('','
SELECT *
FROM {db_prefix}messages
WHERE id_topic = ' . $smcFunc['db_escape_string']($_GET['topic']) .'
');
while($row = $smcFunc['db_fetch_assoc']($result)) {
$boardID = $row['id_board'];
}
if ($boardID == "14) {
// array with the special buttons
$normal_buttons = ......
}
else {
// array without the special buttons
$normal_buttons = ......
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version