Forums / Developer / Change siteaccess in eZ CLI PHP script

Change siteaccess in eZ CLI PHP script

Author Message

Fabio Carissimi

Monday 10 July 2006 2:03:40 am

Hi,

I am using CLI scripts to import or update objects in EZPublish like explained in this post :
http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists

What I want to do is read an object in one site (one siteaccess, one db) and update the object in another
site (other siteaccess, other db). But I can't change the siteaccess within the script.

I use a script object and when I want to change the siteaccess, it does not work :

$script =& eZScript::instance(...);
$script->setUseSiteAccess('siteaccess1');

I also tried with the method in EzPublish's index.php :

include_once( "access.php" );
$access = array('name'=> 'siteaccess1',"type"=> EZ_ACCESS_TYPE_HTTP_HOST);
$access = changeAccess( $access );
eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' );
$GLOBALS['eZCurrentAccess'] =& $access;

and I tried also with 2 eZScript instances :

$script2 =& eZScript::instance(...);
$script2->setUseSiteAccess('siteaccess2');

but always no success
my first question is : is it possible ?
if it is, does somebody did it and can help me ? if not, does somebody knows a workaround ?

Thanks for help

Kristof Coomans

Monday 10 July 2006 2:17:34 am

Hello Fabio

Calling <i>$script->setUseSiteAccess('siteaccess1');</i> only works before <i>$script->initialize();</i>.

Have you tried the second method you mentioned with EZ_ACCESS_TYPE_STATIC instead of EZ_ACCESS_TYPE_HTTP_HOST?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Fabio Carissimi

Monday 10 July 2006 3:04:37 am

Hello,

I knew that and take care of calling $script->setUseSiteAccess('siteaccess1'); before $script->initialize();.
I tried every available access method from 1 to 8 (see access.php for details)

It seems that when siteaccess is selected, it can't be changed in the script ... ???