summaryrefslogtreecommitdiff
path: root/download_file.php
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2008-06-10 18:43:54 +0000
committerMax Kremmel <xing@synapse.plus.com>2008-06-10 18:43:54 +0000
commit3825d5183fedd98fd55e06ee093904fb03040063 (patch)
tree628e3425e2c89295eeb799da0f78216c56020352 /download_file.php
parent6a637ab6810183f98587db74feb6862eae11c20b (diff)
downloadliberty-3825d5183fedd98fd55e06ee093904fb03040063.tar.gz
liberty-3825d5183fedd98fd55e06ee093904fb03040063.tar.bz2
liberty-3825d5183fedd98fd55e06ee093904fb03040063.zip
rename files again
Diffstat (limited to 'download_file.php')
-rw-r--r--download_file.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/download_file.php b/download_file.php
new file mode 100644
index 0000000..fdd6c55
--- /dev/null
+++ b/download_file.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/download_file.php,v 1.1 2008/06/10 18:43:54 squareing Exp $
+ *
+ * @author xing <xing@synapse.plus.com>
+ * @package treasury
+ * @copyright 2003-2006 bitweaver
+ * @license LGPL {@link http://www.gnu.org/licenses/lgpl.html}
+ **/
+
+/**
+ * Setup
+ */
+require_once( '../bit_setup_inc.php' );
+require_once( LIBERTY_PKG_PATH.'LibertyMime.php' );
+
+// fetch the attachment details
+$attachment = LibertyMime::getAttachment( $_REQUEST['attachment_id'] );
+$gBitSmarty->assign( 'attachment', $attachment );
+
+// first we need to check the permissions of the content the attachment belongs to since they inherit them
+$gContent = LibertyBase::getLibertyObject( $attachment['content_id'] );
+$gContent->verifyViewPermission();
+$gBitSmarty->assign( 'gContent', $gContent );
+
+if( $download_function = LibertyMime::getPluginFunction( $attachment['attachment_plugin_guid'], 'download_function' )) {
+ if( $download_function( $attachment )) {
+ die;
+ } else {
+ if( !empty( $attachment['errors'] )) {
+ $msg = '';
+ foreach( $attachment['errors'] as $error ) {
+ $msg .= $error.'<br />';
+ }
+ $gBitSystem->fatalError( tra( $msg ));
+ } else {
+ $gBitSystem->fatalError( tra( 'There was an undetermined problem trying to prepare the file for download.' ));
+ }
+ }
+} else {
+ $gBitSystem->fatalError( tra( "No suitable download function found." ));
+}
+?>