Access an object containing a file, but not the file itself.

Author Message

Atle Pedersen

Thursday 04 January 2007 5:29:57 am

Hello!

A customer needs to upload files. The name and information about the files should be visible to all users, including anonymous users. However, it is required to log in before being allowed to download one of the uploaded files. That means I need partial access to an object. Or I need to allow reading of the object, men not downloading of files.

Is there a mechanism that allows this in eZ?

-----

I haven't been able to find one, so I went about making an extension with a new module containing a fetch function, thinking that the access restrictions were on module level. The function is very simple and looks like this:

  function get_Attrib( $nodeID ){
    $rootNode = eZContentObjectTreeNode::fetch( $nodeID);
    if ($rootNode===null) return false;
    $list =& $rootNode->subTree( );
    if ( $list === null ) return false;
    return array( 'result' => &$list );
  }

Even though I've granted all users full access to my new module including this function, it seems that the fetch function is still limited by the restrictions set for the content module. Am I doing something wrong, or is this a bug/feature?

Claudia Kosny

Thursday 04 January 2007 1:37:26 pm

Hi Atle

If you want to fetch a subtree no matter the permissions, you need add a parameter array(Limitation => array()) to the subtree function. Have a look at the code ofeZContentObjectTreeNode::subtree for clarification.

If you are not adverse to a bit of kernel hacking, you could try to change the module.php in kernel/content. Change the value of functions in the variable $ViewList['download'] to e.g 'my_download'. In the functionList below copy the entry for $FunctionList['read'] and change the key to 'my_download'. Now you can set the permissions for access to the download view the way you want. Please note that I have never tried this for the download, so test this first and keep a backup of the original module.php!

Claudia

Atle Pedersen

Friday 05 January 2007 5:41:21 am

Thank you Claudia, you give valuable help. My extension now works as required.

Betsy Gamrat

Saturday 20 January 2007 9:06:46 pm

Different idea:

Use a template to check if the user is logged in, and allow only authorized users to download the files.

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 21:08:33
Script start
Timing: Jan 18 2025 21:08:33
Module start 'layout'
Timing: Jan 18 2025 21:08:33
Module start 'content'
Timing: Jan 18 2025 21:08:34
Module end 'content'
Timing: Jan 18 2025 21:08:34
Script end

Main resources:

Total runtime0.7985 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 589.2891152.6563
Module start 'layout' 0.00530.0034 741.945339.5078
Module start 'content' 0.00880.7882 781.4531557.8672
Module end 'content' 0.79690.0016 1,339.320312.0938
Script end 0.7985  1,351.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4513160.0002
Check MTime0.00160.2057160.0001
Mysql Total
Database connection0.00090.116410.0009
Mysqli_queries0.742993.0392620.0120
Looping result0.00060.0807600.0000
Template Total0.764695.820.3823
Template load0.00240.294720.0012
Template processing0.762395.461520.3811
Template load and register function0.00010.013010.0001
states
state_id_array0.00110.141010.0011
state_identifier_array0.00130.160320.0006
Override
Cache load0.00200.2499230.0001
Sytem overhead
Fetch class attribute can translate value0.00070.082630.0002
Fetch class attribute name0.00150.193060.0003
XML
Image XML parsing0.00110.143430.0004
class_abstraction
Instantiating content class attribute0.00000.001870.0000
General
dbfile0.00190.2391220.0001
String conversion0.00000.001340.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs