liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file attachment_browser.php

Documentation is available at attachment_browser.php

  1. <?php
  2. /**
  3.  * attachment_browser
  4.  *
  5.  * @author   spider <spider@steelsun.com>
  6.  * @version  $Revision$
  7.  * @package  liberty
  8.  * @subpackage functions
  9.  */
  10.  
  11. /**
  12.  * bit setup
  13.  */
  14. require_once("../kernel/setup_inc.php");
  15.  
  16. global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem;
  17.  
  18. // we just want information about a single attachment
  19. if (isset($_REQUEST['attachment_id']) && is_numeric($_REQUEST['attachment_id'])){
  20.     if ( !$gContent ){
  21.         $gContent = new LibertyMime();
  22.     }
  23.     // this is a hack to make it compatible with existing tpls for now
  24.     $attachment = $gContent->getAttachment($_REQUEST['attachment_id']);
  25.     $ret = array();
  26.     $ret[$attachment['attachment_id']] = $attachment;
  27.     $userAttachments = $ret;
  28.     $gContent->mStorage = $userAttachments;
  29.     $gBitSmarty->assign('gContent', $gContent);
  30. }else{
  31. // we want a list of user attachments
  32.     $listHash = $_REQUEST;
  33.     $listHash = array(
  34.         'page' => @BitBase::verifyId( $_REQUEST['pgnPage'] ) ? $_REQUEST['pgnPage'] : NULL,
  35.         'load_attached_to' => true,
  36.     );
  37.     $userAttachments = $gBitUser->getUserAttachments( $listHash );
  38.  
  39.     // Fake the storage assignment for edit_storage_list.tpl
  40.     $gContent->mStorage = $userAttachments;
  41.     $gBitSmarty->assign('gContent', $gContent);
  42.  
  43.     // pagination
  44.     $offset = @BitBase::verifyId( $_REQUEST['offset'] ) ? $_REQUEST['offset'] : 0;
  45.     $gBitSmarty->assign( 'curPage', $pgnPage = @BitBase::verifyId( $_REQUEST['pgnPage'] ) ? $_REQUEST['pgnPage'] : 1 );
  46.     $offset = ( $pgnPage - 1 ) * $gBitSystem->getConfig( 'max_records' );
  47.  
  48.     // calculate page number
  49.     $numPages = ceil( $listHash['cant'] / $gBitSystem->getConfig( 'max_records' ) );
  50.     $gBitSmarty->assign( 'cant', $listHash['cant'] );
  51.     $gBitSmarty->assign( 'numPages', $numPages );
  52. }
  53. ?>

Documentation generated on Wed, 29 Jul 2015 13:55:35 +0000 by phpDocumentor 1.5.0-lsces