Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: How to check if user logged in from plugin?  (Read 3752 times)

0 Members and 1 Guest are viewing this topic.

monkeyboy

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
How to check if user logged in from plugin?
« on: April 13, 2006, 08:36:07 pm »

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.
Logged

Nibbler

  • Guest
Re: How to check if user logged in from plugin?
« Reply #1 on: April 13, 2006, 08:43:31 pm »

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 ?
Logged

monkeyboy

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: How to check if user logged in from plugin?
« Reply #2 on: April 13, 2006, 09:08:37 pm »

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?
Logged

monkeyboy

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: How to check if user logged in from plugin?
« Reply #3 on: April 13, 2006, 09:10:17 pm »

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

Nibbler

  • Guest
Re: How to check if user logged in from plugin?
« Reply #4 on: April 13, 2006, 09:13:30 pm »

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.
Logged

monkeyboy

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: How to check if user logged in from plugin?
« Reply #5 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???????? ???
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How to check if user logged in from plugin?
« Reply #6 on: April 14, 2006, 12:03:50 am »

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.
Logged

ruckerz

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: How to check if user logged in from plugin?
« Reply #7 on: April 26, 2006, 04:21:54 am »

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




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???????? ???
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 16 queries.