Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 64
SyntaxHighlighte... 51
Newsletters v4.03 114
Facebook Like Box 132
Newsletters v4.02 60
Metro 171
Facebook Connect 173
Shoutbox Panel 129
Redactor for PHP... 107
MI Floating Side... 109
Facebook Login/R... 156
Avatar Studio v2.03 180
Relationship Sta... 98
Sexual Orientati... 116
Fisherman 144
Popular Addons
iTheme2 5808
Arise 5808
User Control v1.23 4623
Event Calendar 4053
Photowidget panel 3888
Radio-Theme red2... 3359
Highslide Gallery 3315
CSS/JavaScript D... 3234
Facebook Connect... 2992
Dynamic Menu 2895
Slideshow Lightb... 2727
L-AMANT 2660
Enigma 2637
2Dark 2608
Black 2580
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Panels and Infusions
Who is here? 1 guest(s)
 Print Thread
How to check if user is admin?
jodlajodla
Hello,

I'm writing some infusion for user warnings and before inserting in database I would like to check if the user is administrator. This is my first time writing an infusion and I don't know much about the functions in PHP-Fusion that I can use. How to do that?

Where can I write new function for one file in infusion?
If I would like to use this function in file my_infusion.php (this name is just for example), can I write it next to include of language file or somewhere else?

Thanks! Smile

P.S.: Is there any documentation with functions or something like that for PHP-Fusion Infusions?
 
Yodix
To check whether the user is an administrator is definition iADMIN , but it is better to check permissions checkrights(); function.
Happy Hunger Games! And may the odds be ever in your favor.
 
http://www.on-deck.eu
jodlajodla
Which rights do I have to check, to know this is admin?
 
Craig
In infusion.php, the inf admin panel array is where you define the access rights for that infusion.

Like so...

Download source  Code
$inf_adminpanel[1] = array(
    "title" => "An Infusion",
    "image" => "image.gif",
    "panel" => "admin/index.php",
    "rights" => "RIG"
);





Where you see...

Download source  Code
 "rights" => "RIG"




That's the admin access rights for it.

Then in the page you wish only the admin who has RIG rights to see, like the settings for your infusion or whatever page, you would then add in the top of the file usually after the maincore.php and admin_header.php include. Just like so...

Download source  Code
if (!checkrights("RIG") || !defined("iAUTH") || !isset($_GET['aid']) || $_GET['aid'] != iAUTH) redirect("../index.php");




There you can see only admins with the checkrights RIG will be able to enter that page.

Please note that ../index.php is just an example for the redirection page if not got the access rights sometimes this might be different depending on which folder your index.php lies in.
 
http://www.fusiontube.co.uk/
jodlajodla
Thanks!

What means $row in dbresult($query, $row) if:
$query = "SELECT infusion_id FROM DB WHERE user_id=20"?

Is there any documentation with functions or something like that for PHP-Fusion Infusions?

EDIT: What about user_level? I see the administrators have bigger user_level than members - can I check administrators with this? (I need to check if user with name from input is administrator, so checkrights there will not work properly)
 
Craig
I'll let this article do all the talking for now...

http://www.php-fu...icle_id=27
 
http://www.fusiontube.co.uk/
jodlajodla
Where can I see some example for checking functions and for dbresult() (in which file are these functions written)?
 
Craig
Function dbrows
Download source  Code
function dbrows($query) {
   $result = @mysql_num_rows($query);
   return $result;
}




Example Usage
Download source  Code
$result = dbquery("SELECT * FROM ".DB_YOURS." WHERE a_id !='0'");
if (dbrows($result > 0)) {
   while ($data = dbarray($result)) {
      echo $data['a_id'];
   }
} else {
   die("FAIL");
}



 
http://www.fusiontube.co.uk/
jodlajodla
What about example for checkgroup()/checkrights() if I need to check other user (which I choose after I type it in input box) than me?

EDIT: In which files are these functions written?
Edited by jodlajodla on 05-08-2012 13:47
 
Craig
Look in maincore.php
 
http://www.fusiontube.co.uk/
jodlajodla
I looked into file, but I can't find function that I need or I don't know how to use it. Now I will explain you, what I need.

First of all I type somebody's username into input box and set few (currently unimportant) things. When I send the form, infusion checks if username exist (normally SQL statement - SELECT, FROM, WHERE). If this username exist, than insert it into database. But before insertion in database, I'd like to check if this user is administrator and if it's, the infusion must return error.

What's the way to do checking for administration rights?
 
Craig
jodlajodla wrote:

If this username exist, than insert it into database.


You sure about that? Frown

Also what's the difference between this and registration?
 
http://www.fusiontube.co.uk/
jodlajodla
Craig wrote:

jodlajodla wrote:

If this username exist, than insert it into database.


You sure about that? Frown


Yes, because instead of username the script insert user id into database.

Craig wrote:
Also what's the difference between this and registration?


User is just number (user id) in database in my case, at registration user gets inserted all information that it provide.

So...
jodlajodla wrote:
What's the way to do checking for administration rights?


Merged on Aug 07 2012 at 22:18:26:
One more question... Can I set checking if the user is administrator depending on user level?

I see that normal members have user level 101, administrators 102 and super administrator 103.
Edited by jodlajodla on 07-08-2012 22:18
 
PolarFox
user is administrator depending on user level?

yes
user level 101, administrators 102 and super administrator 103.

right
 
http://unlogic.info
Craig
jodlajodla wrote:
Merged on Aug 07 2012 at 22:18:26:
One more question... Can I set checking if the user is administrator depending on user level?


Yes
 
http://www.fusiontube.co.uk/
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Adding items to user profiles Ideas for Modifications and Requests 2 24-05-2013 11:50
A new admin interface Roadmap 5 23-05-2013 13:55
Register user fields User Administration 3 15-05-2013 10:49
PM to Admin when new user Content Administration 4 11-05-2013 22:50
Check theme before setting it Roadmap 1 09-05-2013 15:14
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue