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

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.

eZ debug

Timing: Jan 20 2025 04:03:25
Script start
Timing: Jan 20 2025 04:03:25
Module start 'content'
Timing: Jan 20 2025 04:03:25
Module end 'content'
Timing: Jan 20 2025 04:03:25
Script end

Main resources:

Total runtime0.1482 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.2109180.7969
Module start 'content' 0.00660.0059 770.0078102.1016
Module end 'content' 0.01250.1356 872.1094529.8594
Script end 0.1481  1,401.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.4070200.0002
Check MTime0.00161.0605200.0001
Mysql Total
Database connection0.00120.787110.0012
Mysqli_queries0.103569.84841410.0007
Looping result0.00110.70861390.0000
Template Total0.135291.210.1352
Template load0.00080.572110.0008
Template processing0.134390.621910.1343
Override
Cache load0.00060.402710.0006
Sytem overhead
Fetch class attribute can translate value0.00080.513210.0008
XML
Image XML parsing0.00030.201710.0003
General
dbfile0.00493.2786200.0002
String conversion0.00000.003930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs