how fetch all objects which can be editted by current user?

Author Message

Vytautas Germanavičius

Friday 08 April 2005 5:55:42 am

how fetch all objects which can be edited by current user? (from tree)

:/ Is it so hard, I'm waiting for answer more than week.

{set-block scope=root variable=cache_ttl}0{/set-block}

Sebastiaan van der Vliet

Thursday 14 April 2005 3:40:38 am

Hi,

I'm not sure about fetching everything from a tree,
but to fetch all publications owned by the current user you could use the following function:

function fetchPublicationList( $class_id, $offset, $limit )
{
	$userID = eZUser::currentUserID();
	$publicationList = & eZPersistentObject::fetchObjectList( eZContentObject::definition(),
	null, array(  'owner_id' => $userID,
	'status' => EZ_VERSION_STATUS_PUBLISHED,
	'contentclass_id' => $class_id ),
	null, array( 'length' => $limit, 'offset' => $offset ),
	true );
	return array( 'result' => &$publicationList );
}

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Vytautas Germanavičius

Thursday 14 April 2005 5:08:51 am

Thank you for replay. I need this function too. but... how to use it?

Should i write it to template, or to any PHP file? or it is already there?

{set-block scope=root variable=cache_ttl}0{/set-block}

Sebastiaan van der Vliet

Thursday 14 April 2005 5:41:40 am

Hi,

The best solution would be to integrate this functionality as a template plugin in your site. However, for a number of reasons I choose to modify the kernel. Among others because I wanted to set up a "http://mysite/content/publication_list" or "Contributions" page that displays an overview all contributions (owned) by the user.

This is what I did:

1. To /kernel/content/ezcontentfunctioncollection.php I added:

function fetchPublicationList( $class_id, $offset, $limit )
{
$userID = eZUser::currentUserID();
$publicationList = & eZPersistentObject::fetchObjectList( eZContentObject::definition(),
null, array(  'owner_id' => $userID,
'status' => EZ_VERSION_STATUS_PUBLISHED,
'contentclass_id' => $class_id ),
null, array( 'length' => $limit, 'offset' => $offset ),
true );
return array( 'result' => &$publicationList );
}

2. To /kernel/content/function_definition.php I added:

$FunctionList['publication_list'] = array( 'name' => 'publication_list',
'operation_types' => array( 'read' ),
'call_method' => array( 'include_file' => 'kernel/content/ezcontentfunctioncollection.php',
'class' => 'eZContentFunctionCollection',
'method' => 'fetchPublicationList' ),
'parameter_type' => 'standard',
'parameters' => array( array('name' => 'class_id',
	'type' => 'integer',
	'required' => true),
array( 'name' => 'offset',
     'type' => 'integer',
     'required' => false,
     'default' => false ),
array( 'name' => 'limit',
     'type' => 'integer',
     'required' => false,
     'default' => false ) ) );

3. Inside the template I call the function as follows:

{section loop=fetch( 'content', 'can_instantiate_class_list' )}
{let publication_list=fetch('content', 'publication_list', hash(class_id, $:item.id, limit, 100, offset, 0))}
	{section loop=$publication_list sequence=array(bgdark,bglight)}
		[..etc...]
	{/section}	
{/let}
{/section}

The code above displays all classes, but you can restrict it to only articles. It is not a real elegant solution, in terms of upgrading etc.

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Xavier Dutoit

Thursday 14 April 2005 6:26:32 am

Hi Sebastiaan,

Have you tried to create a module in extension/contentuser (for instance) with a list function (the one you've wrote).

Have a look at the doc if you haven't already, not complicated.

Then, intead of using /contentuser/list you could add a url rewrite (from the back office) between content/contribution_list and contentuser/list ?

X+

http://www.sydesy.com

Sebastiaan van der Vliet

Thursday 14 April 2005 6:39:55 am

Hi Xavier,

That sounds like a better solution-I'll give it a try and report back here...

Thanks!

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

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 19 2025 04:24:45
Script start
Timing: Jan 19 2025 04:24:45
Module start 'layout'
Timing: Jan 19 2025 04:24:45
Module start 'content'
Timing: Jan 19 2025 04:24:45
Module end 'content'
Timing: Jan 19 2025 04:24:45
Script end

Main resources:

Total runtime0.9615 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 589.4141152.6563
Module start 'layout' 0.00450.0024 742.070339.5078
Module start 'content' 0.00690.9533 781.5781628.7031
Module end 'content' 0.96020.0013 1,410.281320.0938
Script end 0.9615  1,430.3750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3317160.0002
Check MTime0.00130.1377160.0001
Mysql Total
Database connection0.00060.060710.0006
Mysqli_queries0.896693.2424680.0132
Looping result0.00070.0681660.0000
Template Total0.931896.920.4659
Template load0.00210.214920.0010
Template processing0.929796.692720.4649
Template load and register function0.00010.009210.0001
states
state_id_array0.00140.143210.0014
state_identifier_array0.00180.183320.0009
Override
Cache load0.00170.1803400.0000
Sytem overhead
Fetch class attribute can translate value0.00050.050130.0002
Fetch class attribute name0.00210.219490.0002
XML
Image XML parsing0.00140.145030.0005
class_abstraction
Instantiating content class attribute0.00000.0025120.0000
General
dbfile0.00170.1739290.0001
String conversion0.00000.000840.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/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
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs