blob: 48f805921dd8a39e3cba614e10d19d37e384552e (
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
|
<?php
/**
* attachment_browser
*
* @author spider <spider@steelsun.com>
* @version $Revision$
* @package liberty
* @subpackage functions
*/
/**
* bit setup
*/
use Bitweaver\BitBase;
use Bitweaver\Liberty\LibertyMime;
require_once "../kernel/includes/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 = [];
$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 = [
'page' => BitBase::verifyId( $_REQUEST['pgnPage'] ?? 0 ) ? $_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'] ?? 0 ) ? $_REQUEST['offset'] : 0;
$gBitSmarty->assign( 'curPage', $pgnPage = BitBase::verifyId( $_REQUEST['pgnPage'] ?? 0 ) ? $_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 );
}
|