summaryrefslogtreecommitdiff
path: root/edit_storage_inc.php
blob: b14ae581a6db0b48650835e88c12bde5723902d4 (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
51
52
53
54
55
56
<?php
/**
 * @version  $Header: /cvsroot/bitweaver/_bit_liberty/edit_storage_inc.php,v 1.38 2009/04/01 14:32:19 tekimaki_admin Exp $
 *
 * edit_storage_inc
 * @author   spider <spider@steelsun.com>
 * @package  liberty
 * @subpackage functions
 */
global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gBitThemes, $gLibertySystem;

// if we have active plugins with an upload function, we call them:
foreach( $gLibertySystem->getPluginFunctions( 'upload_function' ) as $guid => $func ) {
	$func( $gContent );
}

// set up base arguments
$getArgs = split( '&', $_SERVER['QUERY_STRING'] );
$attachmentBaseArgs = '';
foreach( $getArgs as $arg ) {
	$parts = split( '=', $arg );
	if( $parts[0] != 'deleteAttachment' ) {
		$attachmentBaseArgs .= $arg."&amp;";
	}
}
$gBitSmarty->assign( 'attachmentBaseArgs', $attachmentBaseArgs );

// delete attachment if requested
if( !empty( $_REQUEST['deleteAttachment'] )) {

	// $gContent is empty when we're editing our personal webpage
	// this is a brutish hack but it seems to work without adverse effeects
	if( empty( $gContent )) {
		$gContent = $gBitUser;
	}

	$attachmentId = $_REQUEST['deleteAttachment'];
	$attachmentInfo = $gContent->getAttachment( $attachmentId );

	// the second part of this check seems odd (never used?) to me, but I'll leave it in for now - spiderr 10/17/2007
	if( $gContent->hasAdminPermission() || ( $gContent->isOwner( $attachmentInfo ) && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) {
		$gContent->expungeAttachment( $attachmentId );
	}

	// in case we have deleted attachments
	// seems like there should be a better way to do this -- maybe original assign should have been by reference?
	$gBitSmarty->clear_assign( 'gContent' );
	$gBitSmarty->assign( 'gContent', $gContent );
}

// make sure js is being loaded
if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) {
	$gBitThemes->loadAjax( 'mochikit', array( 'Iter.js', 'DOM.js' ) );
	$gBitThemes->loadJavascript( LIBERTY_PKG_PATH.'scripts/LibertyAttachment.js', TRUE );
}
?>