Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -100,7 +100,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit&_step=select_category', 'front', 'downloads_submit' ) );
|
||||
}
|
||||
|
||||
if( !$category->can('add') )
|
||||
if( !$category->can('add') OR !\IPS\Member::loggedIn()->group['idm_max_size'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'add_files_no_perm', '3D286/1', 403, '' );
|
||||
}
|
||||
@@ -177,7 +177,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
if ( $category->bitoptions['allowss'] )
|
||||
{
|
||||
$image = TRUE;
|
||||
if ( $category->maxdims )
|
||||
if ( $category->maxdims and $category->maxdims != '0x0' )
|
||||
{
|
||||
$maxDims = explode( 'x', $category->maxdims );
|
||||
$image = array( 'maxWidth' => $maxDims[0], 'maxHeight' => $maxDims[1] );
|
||||
@@ -495,10 +495,17 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
if ( $category->bitoptions['allowss'] )
|
||||
{
|
||||
$existing[ $key ] = iterator_to_array( new \IPS\File\Iterator( \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_post_key=? AND record_type=?', md5( "{$data['postKey']}-{$key}" ), 'ssupload' ) )->setValueField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } )->setKeyField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } ), 'downloads_Screenshots' ) );
|
||||
|
||||
|
||||
$image = TRUE;
|
||||
if ( $category->maxdims and $category->maxdims != '0x0' )
|
||||
{
|
||||
$maxDims = explode( 'x', $category->maxdims );
|
||||
$image = array( 'maxWidth' => $maxDims[0], 'maxHeight' => $maxDims[1] );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Upload( "screenshots_{$key}", $existing[ $key ], ( $category->bitoptions['reqss'] and !\IPS\Member::loggedIn()->group['idm_linked_files'] ), array(
|
||||
'storageExtension' => 'downloads_Screenshots',
|
||||
'image' => $category->maxssdims ? explode( 'x', $category->maxssdims ) : TRUE,
|
||||
'image' => $image,
|
||||
'maxFileSize' => $category->maxss ? ( $category->maxss / 1024 ) : NULL,
|
||||
'multiple' => TRUE
|
||||
) ) );
|
||||
|
||||
@@ -148,7 +148,7 @@ class _view extends \IPS\Content\Controller
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => \IPS\Member::load( $this->file->submitter )->name,
|
||||
'image' => \IPS\Member::load( $this->file->submitter )->get_photo()
|
||||
'image' => \IPS\Member::load( $this->file->submitter )->get_photo( TRUE, TRUE )
|
||||
),
|
||||
'interactionStatistic' => array(
|
||||
array(
|
||||
@@ -314,7 +314,7 @@ class _view extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
/* Have we accepted the terms? */
|
||||
if ( $downloadTerms = $this->file->container()->message('disclaimer') and \in_array( $this->file->container()->disclaimer_location, [ 'purchase', 'both'] ) and !isset( \IPS\Request::i()->confirm ) )
|
||||
if ( $downloadTerms = $this->file->container()->message('disclaimer') and \in_array( $this->file->container()->disclaimer_location, [ 'purchase', 'both' ] ) and !isset( \IPS\Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->purchaseTerms( $this->file, $downloadTerms, $this->file->url('buy')->csrf()->setQueryString( 'confirm', 1 ) );
|
||||
return;
|
||||
@@ -401,15 +401,16 @@ class _view extends \IPS\Content\Controller
|
||||
*/
|
||||
protected function download()
|
||||
{
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
/* No direct linking check */
|
||||
if ( \IPS\Settings::i()->idm_antileech )
|
||||
if ( \IPS\Settings::i()->idm_antileech AND !$this->file->requiresDownloadConfirmation() )
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->csrfKey ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->file->url() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
}
|
||||
|
||||
@@ -453,7 +454,7 @@ class _view extends \IPS\Content\Controller
|
||||
$files = $this->file->files( isset( \IPS\Request::i()->version ) ? \IPS\Request::i()->version : NULL );
|
||||
|
||||
/* Have we accepted the terms? */
|
||||
if ( $downloadTerms = $category->message('disclaimer') and \in_array( $this->file->container()->disclaimer_location, [ 'download', 'both'] ) and !isset( \IPS\Request::i()->confirm ) )
|
||||
if ( $downloadTerms = $category->message('disclaimer') and \in_array( $category->disclaimer_location, [ 'download', 'both' ] ) and !isset( \IPS\Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->download( $this->file, $downloadTerms, null, $confirmUrl, \count( $files ) > 1 );
|
||||
return;
|
||||
@@ -860,7 +861,7 @@ class _view extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_submit.js', 'downloads', 'front' ) );
|
||||
|
||||
/* Permission check */
|
||||
if ( !$this->file->canEdit() OR $this->file->hasPendingVersion() )
|
||||
if ( !$this->file->canEdit() OR !$this->file->container()->can('add') OR $this->file->hasPendingVersion() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2D161/C', 403, '' );
|
||||
}
|
||||
@@ -903,7 +904,7 @@ class _view extends \IPS\Content\Controller
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'file_version', $this->file->version, ( $category->version_numbers == 2 ) ? TRUE : FALSE, array( 'maxLength' => 32 ) ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'file_changelog', NULL, FALSE, array( 'app' => 'downloads', 'key' => 'Downloads', 'autoSaveKey' => "downloads-{$this->file->id}-changelog", 'allowAttachments' => FALSE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'file_changelog', NULL, $category->require_changelog, array( 'app' => 'downloads', 'key' => 'Downloads', 'autoSaveKey' => "downloads-{$this->file->id}-changelog", 'allowAttachments' => FALSE ) ) );
|
||||
|
||||
$defaultFiles = iterator_to_array( $this->file->files( NULL, FALSE ) );
|
||||
if( !$category->multiple_files )
|
||||
@@ -952,9 +953,16 @@ class _view extends \IPS\Content\Controller
|
||||
$screenshots[ $this->file->_primary_screenshot ] = array( 'fileurl' => $screenshots[ $this->file->_primary_screenshot ], 'default' => true );
|
||||
}
|
||||
|
||||
$image = TRUE;
|
||||
if ( $category->maxdims and $category->maxdims != '0x0' )
|
||||
{
|
||||
$maxDims = explode( 'x', $category->maxdims );
|
||||
$image = array( 'maxWidth' => $maxDims[0], 'maxHeight' => $maxDims[1] );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'screenshots', $screenshots, ( $category->bitoptions['reqss'] and !\IPS\Member::loggedIn()->group['idm_linked_files'] ), array(
|
||||
'storageExtension' => 'downloads_Screenshots',
|
||||
'image' => $category->maxssdims ? explode( 'x', $category->maxssdims ) : TRUE,
|
||||
'image' => $image,
|
||||
'maxFileSize' => $category->maxss ? ( $category->maxss / 1024 ) : NULL,
|
||||
'multiple' => TRUE,
|
||||
'retainDeleted' => TRUE,
|
||||
@@ -1023,6 +1031,7 @@ class _view extends \IPS\Content\Controller
|
||||
{
|
||||
$existingRecords = array_unique( iterator_to_array( \IPS\Db::i()->select( 'record_id, record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=?', $this->file->id, 'upload', 0 ) )->setKeyField('record_id')->setValueField('record_location') ) );
|
||||
$existingScreenshots = array_unique( iterator_to_array( \IPS\Db::i()->select( 'record_id, record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=?', $this->file->id, 'ssupload', 0 ) )->setKeyField('record_id')->setValueField('record_location') ) );
|
||||
$existingThumbnails = array_unique( iterator_to_array( \IPS\Db::i()->select( 'record_id, record_thumb', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=?', $this->file->id, 'ssupload', 0 ) )->setKeyField('record_id')->setValueField('record_thumb') ) );
|
||||
$existingLinks = array_unique( iterator_to_array( \IPS\Db::i()->select( 'record_id, record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=?', $this->file->id, 'link', 0 ) )->setKeyField('record_id')->setValueField('record_location') ) );
|
||||
$existingScreenshotLinks = array_unique( iterator_to_array( \IPS\Db::i()->select( 'record_id, record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=?', $this->file->id, 'sslink', 0 ) )->setKeyField('record_id')->setValueField('record_location') ) );
|
||||
}
|
||||
@@ -1124,6 +1133,11 @@ class _view extends \IPS\Content\Controller
|
||||
), array( 'record_id=?', $_key ) );
|
||||
|
||||
unset( $existingScreenshots[ $key ] );
|
||||
|
||||
if( isset( $existingThumbnails[ $key ] ) )
|
||||
{
|
||||
unset( $existingThumbnails[ $key ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1202,7 +1216,7 @@ class _view extends \IPS\Content\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$deletions = array( 'records' => array(), 'links' => array() );
|
||||
$deletions = array( 'records' => array(), 'links' => array(), 'thumbs' => array() );
|
||||
|
||||
/* Delete any we're not using anymore */
|
||||
foreach ( $existingRecords as $recordId => $url )
|
||||
@@ -1213,11 +1227,13 @@ class _view extends \IPS\Content\Controller
|
||||
{
|
||||
$deletions['records'][ $recordId ] = array( 'handler' => 'downloads_Screenshots', 'url' => $url );
|
||||
}
|
||||
foreach ( array_merge( $existingLinks, $existingScreenshotLinks ) as $id => $url )
|
||||
foreach ( ( $existingLinks + $existingScreenshotLinks ) as $id => $url )
|
||||
{
|
||||
$deletions['links'][ $id ] = $id;
|
||||
}
|
||||
|
||||
$deletions['thumbs'] = $existingThumbnails;
|
||||
|
||||
if( $requireApproval )
|
||||
{
|
||||
$fileObj->record_deletions = $deletions;
|
||||
@@ -1229,6 +1245,15 @@ class _view extends \IPS\Content\Controller
|
||||
});
|
||||
$fileObj->deleteRecords( $deletions['links'] );
|
||||
|
||||
foreach( $deletions['thumbs'] as $url )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'downloads_Screenshots', $url )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
|
||||
/* Set the new details */
|
||||
$fileObj->version = ( isset( $values['file_version'] ) ) ? $values['file_version'] : NULL;
|
||||
$fileObj->changelog = $values['file_changelog'];
|
||||
|
||||
Reference in new issue
Block a user