Index: branches/RC/core/units/files/file_eh.php =================================================================== diff -u -r9598 -r9616 --- branches/RC/core/units/files/file_eh.php (.../file_eh.php) (revision 9598) +++ branches/RC/core/units/files/file_eh.php (.../file_eh.php) (revision 9616) @@ -2,6 +2,20 @@ class FileEventHandler extends kDBEventHandler { /** + * Allows to override standart permission mapping + * + */ + function mapPermissions() + { + parent::mapPermissions(); + $permissions = Array( + 'OnDownloadFile' => Array('subitem' => 'view'), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + + /** * [HOOK] Allows to apply file functionality to specific config * When main item is created, then #file config is cloned * @@ -50,6 +64,25 @@ $object->addFilter('active_filter', '%1$s.Status = '.STATUS_ACTIVE); } } + + /** + * Returns file contents associated with item + * + * @param kEvent $event + */ + function OnDownloadFile(&$event) + { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $file_helper =& $this->Application->recallObject('FileHelper'); + /* @var $file_helper FileHelper */ + + $filename = $object->GetField('FilePath', 'full_path'); + $file_helper->DownloadFile($filename); + + $event->status = erSTOP; + } } ?> \ No newline at end of file