[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <15-Aug-2002 16:40:11 sp> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 include_once ( "kernel/classes/ezcontentobject.php" ); 28 include_once ( "kernel/classes/ezcontentobjectattribute.php" ); 29 include_once ( "kernel/classes/datatypes/ezbinaryfile/ezbinaryfile.php" ); 30 include_once ( "kernel/classes/ezbinaryfilehandler.php" ); 31 include_once ( "kernel/classes/datatypes/ezmedia/ezmedia.php" ); 32 33 $contentObjectID = $Params['ContentObjectID']; 34 $contentObjectAttributeID = $Params['ContentObjectAttributeID']; 35 $contentObject = eZContentObject::fetch( $contentObjectID ); 36 if ( !is_object( $contentObject ) ) 37 { 38 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 39 } 40 $currentVersion = $contentObject->attribute( 'current_version' ); 41 42 if ( isset( $Params['Version'] ) && is_numeric( $Params['Version'] ) ) 43 $version = $Params['Version']; 44 else 45 $version = $currentVersion; 46 47 $contentObjectAttribute = eZContentObjectAttribute::fetch( $contentObjectAttributeID, $version, true ); 48 if ( !is_object( $contentObjectAttribute ) ) 49 { 50 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 51 } 52 $contentObjectIDAttr = $contentObjectAttribute->attribute( 'contentobject_id' ); 53 if ( $contentObjectID != $contentObjectIDAttr or !$contentObject->attribute( 'can_read' ) ) 54 { 55 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 56 } 57 58 // Get locations. 59 $nodeAssignments =& $contentObject->attribute( 'assigned_nodes' ); 60 if ( count( $nodeAssignments ) === 0 ) 61 { 62 // oops, no locations. probably it's related object. Let's check his owners 63 $ownerList =& eZContentObject::reverseRelatedObjectList( false, $contentObjectID, false, false, false ); 64 foreach ( array_keys( $ownerList ) as $key ) 65 { 66 $owner =& $ownerList[$key]; 67 if ( is_object( $owner ) ) 68 { 69 $ownerNodeAssignments =& $owner->attribute( 'assigned_nodes' ); 70 $nodeAssignments = array_merge( $nodeAssignments, $ownerNodeAssignments ); 71 } 72 } 73 } 74 75 // If exists location that current user has access to and location is visible. 76 $canAccess = false; 77 foreach ( $nodeAssignments as $nodeAssignment ) 78 { 79 if ( ( eZContentObjectTreeNode::showInvisibleNodes() || !$nodeAssignment->attribute( 'is_invisible' ) ) and $nodeAssignment->canRead() ) 80 { 81 $canAccess = true; 82 break; 83 } 84 } 85 if ( !$canAccess ) 86 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 87 88 // If $version is not current version (published) 89 // we should check permission versionRead for the $version. 90 if ( $version != $currentVersion ) 91 { 92 $versionObj = eZContentObjectVersion::fetchVersion( $version, $contentObjectID ); 93 if ( is_object( $versionObj ) and !$versionObj->canVersionRead() ) 94 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 95 } 96 97 $fileHandler =& eZBinaryFileHandler::instance(); 98 $result = $fileHandler->handleDownload( $contentObject, $contentObjectAttribute, EZ_BINARY_FILE_TYPE_FILE ); 99 100 if ( $result == EZ_BINARY_FILE_RESULT_UNAVAILABLE ) 101 { 102 eZDebug::writeError( "The specified file could not be found." ); 103 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 104 } 105 106 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |