Owner trouble

Author Message

Steph A

Monday 10 October 2005 3:11:53 am

Lets say I have a class called "ads". When a user logs into the userside, he can publish/edit or delete this class. This is no problem, the problem is to ONLY show the objects created by the user himself.

I tried to define a "role", so that all users only can "read" objects where they are the owner. But I then got a problem at the "main site" - the user logged in cant see the rest of the "ads" (created by other users).

So, anyone have any ideas for what to do?

Is it possible to do a fetch by a "active" user?

*I hope someone understand what I mean*

Kristof Coomans

Wednesday 12 October 2005 2:11:51 am

You can filter on owner_id, see http://pubsvn.ez.no/nextgen/stable/3.6/doc/features/3.6/content_tree_enhanced_filters.txt

You can get the current user object with the fetch function user - current_user.

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

Steph A

Thursday 13 October 2005 2:24:08 am

Well, I have tried the best I can, but I just dont seem to get it.....

How can I show the current users objects in a folder - and let him create/edit/remove it.

So far I have managed to let the current user create/edit and remove a object, but only with showing ALL objects (for all users).

How can i modify this code to ONLY show current users objects?

*Any help would be apreciated*

node/view/full templatecode:

{*?template charset=utf-8?*}
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
{literal}
function checkAll()
{
{/literal}
    if ( document.fullview.selectall.value == "{'Select all'|i18n('design/standard/node/view')}" )
{literal}
    {
{/literal}
        document.fullview.selectall.value = "{'Deselect all'|i18n('design/standard/node/view')}";
{literal}
        with (document.fullview) 
	{
            for (var i=0; i < elements.length; i++) 
	    {
                if (elements[i].type == 'checkbox' && elements[i].name == 'DeleteIDArray[]')
                     elements[i].checked = true;
	    }
        }
     }
     else
     {
{/literal}
         document.fullview.selectall.value = "{'Select all'|i18n('design/standard/node/view')}";
{literal}
         with (document.fullview) 
	 {
            for (var i=0; i < elements.length; i++) 
	    {
                if (elements[i].type == 'checkbox' && elements[i].name == 'DeleteIDArray[]')
                     elements[i].checked = false;
	    }
         }
     }
}
{/literal}
//-->
</SCRIPT>

{* Default object admin view template *}
{default with_children=true()
         is_editable=true()
	 is_standalone=true()}
{let page_limit=25
     list_count=and($with_children,fetch('content','list_count',hash(parent_node_id,$node.node_id,depth_operator,eq)))}
{default content_object=$node.object
         content_version=$node.contentobject_version_object
         node_name=$node.name}
{section show=$is_standalone}
<form name="fullview" method="post" action={"content/action"|ezurl}>
{/section}


<div class="object">
<h1>{$node_name|wash}</h1>
<input type="hidden" name="TopLevelNode" value="{$content_object.main_node_id}" />

    {default validation=false()}
    {section show=$validation}
      {include name=Validation uri='design:content/collectedinfo_validation.tpl' validation=$validation collection_attributes=$collection_attributes}
    {/section}
    {/default}

</div>

    {let related_objects=$content_version.related_contentobject_array}

      {section name=ContentObject  loop=$related_objects show=$related_objects  sequence=array(bglight,bgdark)}
        <div class="block">
        {content_view_gui view=text_linked content_object=$Object:ContentObject:item}
        </div>
      {/section}
    {/let}

    {section show=$is_standalone}
    {let content_action_list=$content_object.content_action_list}
        {section name=ContentAction loop=$content_action_list show=$content_action_list}
            <div class="block">
                <input type="submit" name="{$ContentAction:item.action}" value="{$ContentAction:item.name|wash}" />
            </div>
        {/section}
    {/let}
    {/section}

<div class="buttonblock">

{section show=$content_object.can_create}
         <input type="hidden" name="NodeID" value="{$node.node_id}" />
         <select name="ClassID">
	      
	      
	      
	      
	      {section name=Classes loop=$content_object.can_create_class_list}
	      <option value="{$:item.id}">{$:item.name|wash}</option>
	      
          
          
          
          {/section}
         </select>
         <input class="button" type="submit" name="NewButton" value="{'Lag ny annonse'}" />
{/section}
</div>


<input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
<input type="hidden" name="ContentObjectID" value="{$content_object.id}" />
<input type="hidden" name="ViewMode" value="full" />


{section show=$with_children}

{let name=Child
     children=fetch('content','list',hash(parent_node_id,$node.node_id,sort_by,$node.sort_array,limit,$page_limit,offset,$view_parameters.offset,depth_operator,eq))
     can_remove=false() can_edit=false() can_create=false() can_copy=false()}

{section show=$:children}

{section loop=$:children}
  {section show=$:item.object.can_remove}
    {set can_remove=true()}
  {/section} 
  {section show=$:item.object.can_edit}
    {set can_edit=true()}
  {/section} 
  {section show=$:item.object.can_create}
    {set can_create=true()}
  {/section} 
{/section}

{set can_copy=$content_object.can_create}



<table class="list" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    {section show=$:can_remove}
    <th width="1">
&nbsp;
    </th>
    {/section}
    <th>
      {"Name"|i18n("design/standard/node/view")}
    </th>
    <th>
      {"Type"}
    </th>
    {section show=eq($node.sort_array[0][0],'priority')}
    {/section}
    {section show=$:can_edit}
    {/section}
    {section show=$:can_copy}
    <th width="1">
      {"Rediger"}
    </th>
    {/section}
</tr>
{section loop=$:children sequence=array(bglight,bgdark)}
<tr class="{$Child:sequence}">
        {section show=$:can_remove}
	<td align="right" width="1">
	{section show=$:item.object.can_remove}
             <input type="checkbox" name="DeleteIDArray[]" value="{$Child:item.node_id}" />
        {/section} 
	</td>
        {/section} 
	<td>
        {node_view_gui view=listitem content_node=$:item}

{*        {node_view_gui view=line content_node=$:item} *}
	</td>
    <td>
        {$Child:item.object.class_name|wash}
	</td>
    {section show=eq($node.sort_array[0][0],'priority')}
	{/section}

        {section show=$:can_edit}
            <td width="1">
                {section show=$:item.object.can_edit}
                    <a href={concat("content/edit/",$Child:item.contentobject_id)|ezurl}><img src={"edit.gif"|ezimage} alt="Edit" /></a>
                {/section}
            </td>
        {/section}

</tr>
{/section}
</table>

    {section show=eq($node.sort_array[0][0],'priority')}
      {section show=and($content_object.can_edit,eq($node.sort_array[0][0],'priority'))}
         <input class="button" type="submit"  name="UpdatePriorityButton" value="{'Update'|i18n('design/standard/node/view')}" />
      {/section}
    {/section}
    {section show=$:can_edit}
    {/section}
    {section show=$:can_remove}
{*    {section show=fetch('content','list',hash(parent_node_id,$node.node_id,sort_by,$node.sort_array,limit,$page_limit,offset,$view_parameters.offset))}
    list_count*}
    {section show=$list_count}
            <input type="submit" name="RemoveButton" value="{'Remove'|i18n('design/standard/node/view')}" />
		<input name="selectall" onclick=checkAll() type="button" value="{'Select all'|i18n('design/standard/node/view')}">
    {/section}
    {/section}


{/section}
{/let}

{include name=navigator
         uri='design:navigator/google.tpl'
         page_uri=concat('/content/view','/full/',$node.node_id)
         item_count=$list_count
         view_parameters=$view_parameters
         item_limit=$page_limit}


{/section}


{section show=$is_standalone}
</form>
{/section}

{/default}
{/let}
{/default}

Steph A

Sunday 16 October 2005 10:57:07 pm

I made it work! ;) No problem

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 15:51:28
Script start
Timing: Jan 18 2025 15:51:28
Module start 'layout'
Timing: Jan 18 2025 15:51:28
Module start 'content'
Timing: Jan 18 2025 15:51:29
Module end 'content'
Timing: Jan 18 2025 15:51:29
Script end

Main resources:

Total runtime0.6151 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 594.5547152.6094
Module start 'layout' 0.00560.0038 747.164139.3984
Module start 'content' 0.00940.6043 786.5625569.8672
Module end 'content' 0.61380.0013 1,356.429720.2031
Script end 0.6151  1,376.6328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.5107160.0002
Check MTime0.00130.2141160.0001
Mysql Total
Database connection0.00070.114010.0007
Mysqli_queries0.565992.0013600.0094
Looping result0.00060.0924580.0000
Template Total0.585195.120.2926
Template load0.00210.348420.0011
Template processing0.583094.773720.2915
Template load and register function0.00020.033210.0002
states
state_id_array0.00150.240010.0015
state_identifier_array0.00060.103420.0003
Override
Cache load0.00180.2871220.0001
Sytem overhead
Fetch class attribute can translate value0.00060.096720.0003
Fetch class attribute name0.00100.168950.0002
XML
Image XML parsing0.00060.096620.0003
class_abstraction
Instantiating content class attribute0.00000.002150.0000
General
dbfile0.00090.1453160.0001
String conversion0.00000.001540.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/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: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs