summaryrefslogtreecommitdiff
path: root/mime_view.php
blob: c14d5078034202a7089ccf5c6201555141cb71d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
 * @version      $Header: /cvsroot/bitweaver/_bit_liberty/Attic/mime_view.php,v 1.4 2008/05/29 09:04:35 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' );

$feedback = array();

// fetch the attachment details
if( @!BitBase::verifyId( $_REQUEST['attachment_id'] ) || !( $attachment = LibertyMime::getAttachment( $_REQUEST['attachment_id'], $_REQUEST ))) {
	$gBitSystem->fatalError( tra( "The Attachment ID given is not valid" ));
}

// 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();

if( !empty( $_REQUEST['plugin_submit'] )) {
	// now that we have data for a plugin, we'll simply feed it back to the update function of that plugin
	foreach( $_REQUEST['plugin'][$attachment['attachment_id']] as $guid => $data ) {
		if( $gContent->updateAttachmentParams( $_REQUEST['attachment_id'], $guid, $data )) {
			$feedback['success'] = tra( "The data was successfully updated." );
		} else {
			$feedback['error'] = $gContent->mErrors;
		}
	}
	// reload the attachment
	$attachment = LibertyMime::getAttachment( $_REQUEST['attachment_id'] );
}

$gBitSmarty->assign( 'attachment', $attachment );
$gBitSmarty->assign( 'gContent', $gContent );
$gBitSmarty->assign( 'feedback', $feedback );

// what template are we going to use to display this attachment
$gBitSmarty->assign( 'view_template', LibertyMime::getMimeTemplate( 'view', $attachment['attachment_plugin_guid'] ));
$gBitSmarty->assign( 'edit_template', LibertyMime::getMimeTemplate( 'edit', $attachment['attachment_plugin_guid'] ));

$gBitSystem->display( 'bitpackage:liberty/mime_view.tpl', tra( "View File" ));
?>