How to check if user logged in from plugin? How to check if user logged in from plugin?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How to check if user logged in from plugin?

Started by monkeyboy, April 13, 2006, 08:36:07 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

monkeyboy

I have found various threads with examples of how to check if a user is curently logged in. However, none of them seem to work from my pluggin.

ex>
If (defined('GALLERY_ADMIN_MODE') ) ...
or
If (USER_ID) ...

I tried my own hack by settng a $_SESSION var in the login page and checking in my plugin. It appears that $_SESSION gets destroyed before getting to the plugin code.

Any help would be appreciated.

One more question, is there a config file in coppermine which defines directory paths? This would be useful.

Nibbler

USER_ID will work so long as you are not trying to use it before authentication has occured. Check the order of things in include/init.inc.php. What directory paths are you looking for ?

monkeyboy

Not sure what you mean by 'before authentication has occured'. The idea behind my plugin is to disable specific menu and submenu button depending on whether or not the user is logged in. Do you have a clean way of checking for this in a plugin?

monkeyboy

Can you tell me at what point in coppermine workflow the plugin (if exist) are called in?

Nibbler

Plugins are designed to connect to hooks and filters in the code. If your plugins runs as soon as it is loaded then the code will run before Coppermine authenticates the user. Look at the existing plugins and include/init.inc.php to see how things work.

monkeyboy

Is there ANY documentation on how to code a plugin?

I have no idea what the functionality is behind the following:

$thisplugin->add_action('page_start','xxx');

$thisplugin->add_filter('page_html','yyy');

i.e.- what do the methods, add_action and add_filter do and where are these classes located???????? ???

Joachim Müller

There's no plugin documentation available yet, see http://forum.coppermine-gallery.net/index.php?topic=24358.0

Why do you try to write a plugin? Just edit themes/yourtheme/theme.php and add a regular if/then switch. I'm not trying to discourage you, but writing a plugin is only recommended for experienced coders who know their way around in coppermine.

ruckerz

Monkeyboy,

I imagine the plugin API works much like wordpress. $thisplugin->add_action('page_start','xxx'); inserts an action at the hook page_start, the action is defined in the function xxx in the plugin file.

There are hooks throughout the source code. They are defined CPGPluginAPI::filter('hook_name', $input), CPGPluginAPI::action('hook_name',null), actions are null because they don't return anything, they perform an action.


Yeah the plugin documentation is pretty scarce, it'd be nice if there was a list of hooks available in coppermine, but right now you can probably search for them using grep -r "CPGPluginAPI::filter" * in your coppermine dir. This can be slow if your albums are stored in that directory too.

FR




Quote from: monkeyboy on April 13, 2006, 11:26:25 PM
Is there ANY documentation on how to code a plugin?

I have no idea what the functionality is behind the following:

$thisplugin->add_action('page_start','xxx');

$thisplugin->add_filter('page_html','yyy');

i.e.- what do the methods, add_action and add_filter do and where are these classes located???????? ???