Forums / General / Owner trouble

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

eZ debug

Timing: Jan 18 2025 11:34:59
Script start
Timing: Jan 18 2025 11:34:59
Module start 'content'
Timing: Jan 18 2025 11:35:00
Module end 'content'
Timing: Jan 18 2025 11:35:00
Script end

Main resources:

Total runtime0.8961 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 587.5313180.8594
Module start 'content' 0.00590.7581 768.3906574.9219
Module end 'content' 0.76400.1320 1,343.3125340.7813
Script end 0.8960  1,684.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00490.5432210.0002
Check MTime0.00150.1646210.0001
Mysql Total
Database connection0.00090.105410.0009
Mysqli_queries0.824592.01461970.0042
Looping result0.00200.22501950.0000
Template Total0.866196.720.4331
Template load0.00190.213820.0010
Template processing0.864296.440120.4321
Template load and register function0.00020.016910.0002
states
state_id_array0.00090.105010.0009
state_identifier_array0.00140.154720.0007
Override
Cache load0.00170.1880220.0001
Sytem overhead
Fetch class attribute can translate value0.00150.167930.0005
Fetch class attribute name0.00110.125350.0002
XML
Image XML parsing0.00090.103130.0003
class_abstraction
Instantiating content class attribute0.00000.001050.0000
General
dbfile0.00310.3485270.0001
String conversion0.00000.000630.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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