Change siteaccees temporarily

Author Message

Davide Garzetti

Tuesday 03 November 2009 9:02:02 am

Hello I need help to complete an important program part of a new extension I will delivery as GPL for all ezPublish users probably this month.It's the last thing left open.

Inside a module program I need to change a site access then do some work and then restore the previuos site access. I have relized this piece of code that works:

//begin code snippet

$old_access = $GLOBALS['eZCurrentAccess'];

$new_access = array( 'name' => 'newaccess', 'type' => EZ_ACCESS_TYPE_DEFAULT );

require_once( "access.php" );
$access = changeAccess( $new_access);

//do some php work

$restored_access = changeAccess($old_access);

.....

//end code snippet

The problem arise when in my "do some php work" I fetch a template so this doesn't work:

//begin code snippet

$old_access = $GLOBALS['eZCurrentAccess'];

$new_access = array( 'name' => 'newaccess', 'type' => EZ_ACCESS_TYPE_DEFAULT );

require_once( "access.php" );
$access = changeAccess( $new_access);

$templ_tpl = templateInit();
$templ_tpl->setVariable( "module", $module );

$result['text']=$templ_tpl->fetch( "design:/mytpl.tpl");

$restored_access = changeAccess($old_access);

....

//end code snippet

The fetch function works but the program doesn't restore to the previuos siteaccess.

Before post this I've already searched inside EzPublish code but without success.

Thanks for your help.

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 18 2025 05:14:06
Script start
Timing: Jan 18 2025 05:14:06
Module start 'layout'
Timing: Jan 18 2025 05:14:06
Module start 'content'
Timing: Jan 18 2025 05:14:07
Module end 'content'
Timing: Jan 18 2025 05:14:07
Script end

Main resources:

Total runtime0.5827 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 587.9141152.6250
Module start 'layout' 0.00770.0041 740.539139.4453
Module start 'content' 0.01180.5695 779.9844427.3984
Module end 'content' 0.58130.0014 1,207.38288.1641
Script end 0.5827  1,215.5469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.7911160.0003
Check MTime0.00230.3934160.0001
Mysql Total
Database connection0.00110.197010.0011
Mysqli_queries0.527890.5646460.0115
Looping result0.00050.0801440.0000
Template Total0.547594.020.2737
Template load0.00230.400920.0012
Template processing0.545193.549220.2726
Template load and register function0.00030.044510.0003
states
state_id_array0.00120.210210.0012
state_identifier_array0.00100.168920.0005
Override
Cache load0.00200.3399470.0000
Sytem overhead
Fetch class attribute can translate value0.00080.131510.0008
Fetch class attribute name0.00100.170010.0010
XML
Image XML parsing0.00020.034010.0002
class_abstraction
Instantiating content class attribute0.00000.000910.0000
General
dbfile0.00170.2954100.0002
String conversion0.00000.001940.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
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
17content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs