[SOLVED] How to figure out that I am in admin panel?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Sonya

[SOLVED] How to figure out that I am in admin panel?

Post by Sonya »

Hello,

The question above.  :) While loading module I need to figure out if I it is called from admin panel or from the front end to execute different tasks. Something like this
class MyClass extends CMSModule
{
function __construct() {
parent::__construct();
if (in_admin_panel) {
do this;
} else {
do that;
}
}
...
}
My question is how to realize this condition if (in_admin_panel)?

Thank you for your help,
Sonya
Last edited by Sonya on Sat Aug 23, 2008 3:53 pm, edited 1 time in total.
Sonya

Re: How to figure out that I am in admin panel?

Post by Sonya »

I have just figured it out:
class MyClass extends CMSModule
{
function __construct() {
parent::__construct();
global $CMS_ADMIN_PAGE;
if (!isset($CMS_ADMIN_PAGE)) {
do this;
} else {
do that;
}
}
...
}
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [SOLVED] How to figure out that I am in admin panel?

Post by calguy1000 »

Or, in any action, if the returnid is empty, then you are in an admin page.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Sonya

Re: [SOLVED] How to figure out that I am in admin panel?

Post by Sonya »

calguy1000 wrote: Or, in any action, if the returnid is empty, then you are in an admin page.
Thank you! :)
Post Reply

Return to “Developers Discussion”