Пример #1
0
            $ownerNodeAssignments = $owner->attribute('assigned_nodes');
            $nodeAssignments = array_merge($nodeAssignments, $ownerNodeAssignments);
        }
    }
}
// If exists location that current user has access to and location is visible.
$canAccess = false;
$isContentDraft = $contentObject->attribute('status') == eZContentObject::STATUS_DRAFT;
foreach ($nodeAssignments as $nodeAssignment) {
    if (eZContentObjectTreeNode::showInvisibleNodes() || !$nodeAssignment->attribute('is_invisible') and $nodeAssignment->canRead()) {
        $canAccess = true;
        break;
    }
}
if (!$canAccess && !$isContentDraft) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// If $version is not current version (published)
// we should check permission versionRead for the $version.
if ($version != $currentVersion || $isContentDraft) {
    $versionObj = eZContentObjectVersion::fetchVersion($version, $contentObjectID);
    if (is_object($versionObj) and !$versionObj->canVersionRead()) {
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
}
$fileHandler = eZBinaryFileHandler::instance();
$result = $fileHandler->handleDownload($contentObject, $contentObjectAttribute, eZBinaryFileHandler::TYPE_FILE);
if ($result == eZBinaryFileHandler::RESULT_UNAVAILABLE) {
    eZDebug::writeError("The specified file could not be found.");
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
 function fileHandler()
 {
     return eZBinaryFileHandler::instance();
 }
 function downloadURL($contentObject, $contentObjectAttribute)
 {
     $contentObjectID = $contentObject->attribute('id');
     $contentObjectAttributeID = $contentObjectAttribute->attribute('id');
     $downloadType = eZBinaryFileHandler::downloadType($contentObject, $contentObjectAttribute);
     $downloadObject = eZBinaryFileHandler::downloadFileObject($contentObject, $contentObjectAttribute);
     $name = '';
     switch ($downloadType) {
         case self::TYPE_FILE:
             $name = $downloadObject->attribute('original_filename');
             break;
         case self::TYPE_MEDIA:
             $name = $downloadObject->attribute('original_filename');
             break;
         default:
             eZDebug::writeWarning("Unknown binary file type '{$downloadType}'", 'eZBinaryFileHandler::downloadURL');
             break;
     }
     $url = "/content/download/{$contentObjectID}/{$contentObjectAttributeID}/{$downloadType}/{$name}";
     return $url;
 }
 function __construct()
 {
     parent::__construct(self::HANDLER_ID, "PHP passthrough", eZBinaryFileHandler::HANDLE_DOWNLOAD);
 }