Forums / Cotonti / Extensions / Support / Question about plugin

tensh
#1 2009-07-27 19:00
Hi;

I'm developing a plugin which has parts divided by "switch" statement. How can I make one 'switch' disabled for regular users but enabled for admin?
What I have by now is:

$IsAdmin = sed_auth('plug', 'myplug', 'A');

(...)

switch($s)
{ 

	case edit:

if ($IsAdmin) 
        {
        (...)
        }
}
	break;

When I go to plug.php?e=myplug&s=edit as a guest, I see blank page, but I'd like to display a message "you're not allowed to do it". How can I call it?
This post was edited by tensh (2009-07-27 19:58, 14 years ago)
Kilandor
#2 2009-07-27 19:43
First thing to note, you don't have to use sed_auth in a standalone plugin as it is already loaded for you.

switch($s)
{
	case 'edit':
		sed_block($usr['isadmin']); //Blocks anyone who isn't an admin - if value is false it blocks them
		/* your code */
	break;
}
tensh
#3 2009-07-27 19:55
Oh, didn't know that... Thanks! :-X

Added 1 day later:

By the way, I have another question about Cotonti POST forms protection. I notices the hidden field named "x" in e.g. search form, with a value. I suppose it's a sort of defense from external attacks. How can I use it in forms in other plugins?
This post was edited by tensh (2009-07-29 18:12, 14 years ago)
Trustmaster
#4 2009-07-29 18:27
In POST forms it is applied automatically, you don't need to care about it. Only GET forms (which normally shouldn't be used) there is a special way to check them.
May the Source be with you!
tensh
#5 2009-07-29 18:34
That's so cooool! :) I didn't even notice that :)