Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -12,6 +12,10 @@
|
||||
namespace IPS\downloads;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
@@ -673,7 +677,7 @@ class _File extends \IPS\Content\Item implements
|
||||
/* Ignore future versions */
|
||||
$where[] = array( 'record_hidden=?', $pendingVersion );
|
||||
|
||||
$iterator = \IPS\Db::i()->select( 'record_id, record_location, record_thumb, record_no_watermark, record_default, record_type, record_realname, record_size', 'downloads_files_records', $where )->setKeyField( 'record_id' );
|
||||
$iterator = \IPS\Db::i()->select( 'record_id, record_location, record_thumb, record_no_watermark, record_default, record_type, record_realname, record_size', 'downloads_files_records', $where, 'record_time DESC' )->setKeyField( 'record_id' );
|
||||
$iterator = new \IPS\File\Iterator( $iterator, 'downloads_Screenshots', $valueField, FALSE, 'record_realname', $fileSizeField );
|
||||
$iterator = new \CachingIterator( $iterator, \CachingIterator::FULL_CACHE );
|
||||
|
||||
@@ -822,6 +826,7 @@ class _File extends \IPS\Content\Item implements
|
||||
{
|
||||
$return = array();
|
||||
$fields = $this->container()->cfields;
|
||||
$guest = new \IPS\Member;
|
||||
|
||||
if( $topic === TRUE AND $this->_fieldData === NULL )
|
||||
{
|
||||
@@ -1622,6 +1627,13 @@ class _File extends \IPS\Content\Item implements
|
||||
$customFieldValues = $item ? $item->customFields() : array();
|
||||
foreach ( $container->cfields as $k => $field )
|
||||
{
|
||||
/* Does the user have permission to enter data into this field? */
|
||||
$perm = $item ? 'edit' : 'add';
|
||||
if( !$field->can( $perm ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$_id = $field->id;
|
||||
$field->id = "{$bulkKey}{$field->id}";
|
||||
if ( $field->type === 'Editor' )
|
||||
@@ -1682,6 +1694,11 @@ class _File extends \IPS\Content\Item implements
|
||||
}
|
||||
foreach ( $this->container()->cfields as $field )
|
||||
{
|
||||
if( !array_key_exists( "downloads_field_{$field->id}", $values ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$helper = $field->buildHelper( NULL, NULL, $new ? NULL : $this );
|
||||
if ( $helper instanceof \IPS\Helpers\Form\Upload )
|
||||
{
|
||||
@@ -1755,6 +1772,11 @@ class _File extends \IPS\Content\Item implements
|
||||
$cfields = array();
|
||||
foreach ( $this->container()->cfields as $field )
|
||||
{
|
||||
if( !array_key_exists( "downloads_field_{$field->id}", $values ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$helper = $field->buildHelper( NULL, NULL, $new ? NULL : $this );
|
||||
if ( $helper instanceof \IPS\Helpers\Form\Upload )
|
||||
{
|
||||
@@ -2512,9 +2534,30 @@ class _File extends \IPS\Content\Item implements
|
||||
* @apiresponse int purchases Number of purchases
|
||||
* @apiresponse array renewalTerm File renewal term
|
||||
* @apiresponse bool hasPendingVersion Whether file has a new version pending. Will be NULL for client requests where the authorized member cannot upload new versions.
|
||||
* @apiresponse [\IPS\downloads\Field] customFields Custom field values for this file
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL, $backup=NULL )
|
||||
{
|
||||
/* Figure out custom fields if any */
|
||||
$fields = array();
|
||||
try
|
||||
{
|
||||
$fieldValues = Db::i()->select( '*', 'downloads_ccontent', [ 'file_id=?', $this->id ] )->first();
|
||||
|
||||
foreach( new ActiveRecordIterator(
|
||||
Db::i()->select( '*', 'downloads_cfields', null, 'cf_position' ),
|
||||
Field::class
|
||||
) as $field )
|
||||
{
|
||||
if( !$authorizedMember or $field->canView( $authorizedMember ) )
|
||||
{
|
||||
$fields[ $field->id ] = $field->apiOutput( $authorizedMember, $fieldValues );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) { }
|
||||
|
||||
|
||||
$return = array(
|
||||
'id' => $this->id,
|
||||
'title' => $backup ? $backup['b_filetitle'] : $this->name,
|
||||
@@ -2554,7 +2597,8 @@ class _File extends \IPS\Content\Item implements
|
||||
'rating' => $this->averageReviewRating(),
|
||||
'purchases' => $this->purchaseCount(),
|
||||
'renewalTerm' => $this->isPaid() ? $this->renewalTerm() : NULL,
|
||||
'hasPendingVersion' => ( !$authorizedMember OR $this->canEdit( $authorizedMember ) ) ? $this->hasPendingVersion() : NULL
|
||||
'hasPendingVersion' => ( !$authorizedMember OR $this->canEdit( $authorizedMember ) ) ? $this->hasPendingVersion() : NULL,
|
||||
'customFields' => $fields
|
||||
);
|
||||
|
||||
return $return;
|
||||
|
||||
Reference in new issue
Block a user