Apropriate way to retrieve data on currently logged in user

Author Message

Michel Pfirter

Tuesday 19 February 2008 9:04:12 am

Hello All

I am quite new to eZ Publish and have therefore a basic question. I try to extend the class eZFilePassthroughHandler so it logs (to database) some information on the downloaded file.
The current logged in user should also be saved, and thats where my question comes in.
<b>Whats the apropriat way the get the current logged in users id inside of an other class?</b> I found the id in the Session and aswell a method in eZUser class to get the id, that is mentioned in the forums too.

            /* ... inside eZFilePassthroughHandler ... */
            require_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
            $user =& eZUser::currentUser();

Unfortunately this returns me nothing.

Thank you for your input and help.

Michel

Piotrek Karaƛ

Tuesday 19 February 2008 11:53:12 am

For example (eZ 4.0):

$currentUserObject = eZUser::instance();
$currentUserID = $currentUserObject->currentUserID();

?

Welcome to the community!

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Michel Pfirter

Wednesday 20 February 2008 1:09:33 am

Hi Piotrek

Thank you, that's it :)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:22:41
Script start
Timing: Jan 31 2025 01:22:41
Module start 'layout'
Timing: Jan 31 2025 01:22:41
Module start 'content'
Timing: Jan 31 2025 01:22:42
Module end 'content'
Timing: Jan 31 2025 01:22:42
Script end

Main resources:

Total runtime1.0078 sec
Peak memory usage8,192.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.3906151.2422
Module start 'layout' 0.00520.0045 739.6328220.7500
Module start 'content' 0.00970.9971 960.38284,441.2656
Module end 'content' 1.00680.0009 5,401.648411.7813
Script end 1.0077  5,413.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3390160.0002
Check MTime0.00130.1247160.0001
Mysql Total
Database connection0.00080.083310.0008
Mysqli_queries0.926791.9573570.0163
Looping result0.00070.0740550.0000
Template Total0.957595.020.4787
Template load0.00190.191820.0010
Template processing0.955594.816320.4778
Template load and register function0.00140.137210.0014
states
state_id_array0.00100.101610.0010
state_identifier_array0.00120.121320.0006
Override
Cache load0.00160.1612200.0001
Sytem overhead
Fetch class attribute can translate value0.00190.189720.0010
Fetch class attribute name0.00180.177740.0004
XML
Image XML parsing0.00070.069720.0004
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00160.1632170.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs