forked from bitweaver/liberty
/
attachment_browser.php
53 lines (47 loc) · 1.67 KB
/
attachment_browser.php
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
<?php
/**
* attachment_browser
*
* @author spider <spider@steelsun.com>
* @version $Revision$
* @package liberty
* @subpackage functions
*/
/**
* bit setup
*/
require_once("../kernel/setup_inc.php");
global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem;
// we just want information about a single attachment
if (isset($_REQUEST['attachment_id']) && is_numeric($_REQUEST['attachment_id'])){
if ( !$gContent ){
$gContent = new LibertyMime();
}
// this is a hack to make it compatible with existing tpls for now
$attachment = $gContent->getAttachment($_REQUEST['attachment_id']);
$ret = array();
$ret[$attachment['attachment_id']] = $attachment;
$userAttachments = $ret;
$gContent->mStorage = $userAttachments;
$gBitSmarty->assign('gContent', $gContent);
}else{
// we want a list of user attachments
$listHash = $_REQUEST;
$listHash = array(
'page' => @BitBase::verifyId( $_REQUEST['pgnPage'] ) ? $_REQUEST['pgnPage'] : NULL,
'load_attached_to' => true,
);
$userAttachments = $gBitUser->getUserAttachments( $listHash );
// Fake the storage assignment for edit_storage_list.tpl
$gContent->mStorage = $userAttachments;
$gBitSmarty->assign('gContent', $gContent);
// pagination
$offset = @BitBase::verifyId( $_REQUEST['offset'] ) ? $_REQUEST['offset'] : 0;
$gBitSmarty->assign( 'curPage', $pgnPage = @BitBase::verifyId( $_REQUEST['pgnPage'] ) ? $_REQUEST['pgnPage'] : 1 );
$offset = ( $pgnPage - 1 ) * $gBitSystem->getConfig( 'max_records' );
// calculate page number
$numPages = ceil( $listHash['cant'] / $gBitSystem->getConfig( 'max_records' ) );
$gBitSmarty->assign( 'cant', $listHash['cant'] );
$gBitSmarty->assign( 'numPages', $numPages );
}
?>