Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

+97 -27
View File
@@ -32,7 +32,8 @@ class _File extends \IPS\Content\Item implements
\IPS\Content\Searchable,
\IPS\Content\Embeddable,
\IPS\Content\MetaData,
\IPS\Content\EditHistory
\IPS\Content\EditHistory,
\IPS\Content\Anonymous
{
use \IPS\Content\Reactable, \IPS\Content\Reportable, \IPS\Content\ItemTopic
{
@@ -85,6 +86,7 @@ class _File extends \IPS\Content\Item implements
public static $databaseColumnMap = array(
'container' => 'cat',
'author' => 'submitter',
'author_name' => 'author_name',
'views' => 'views',
'title' => 'name',
'content' => 'desc',
@@ -111,6 +113,7 @@ class _File extends \IPS\Content\Item implements
'edit_member_name' => 'edit_name',
'edit_show' => 'append_edit',
'edit_reason' => 'edit_reason',
'is_anon' => 'is_anon'
);
/**
@@ -781,7 +784,7 @@ class _File extends \IPS\Content\Item implements
$this->_primaryScreenshotThumb = NULL;
return $this->_primaryScreenshotThumb;
}
/**
* @brief Custom Field Cache
*/
@@ -1117,6 +1120,48 @@ class _File extends \IPS\Content\Item implements
return $this->canDownload;
}
/**
* @brief Requires download confirmation? Used to determine if CSRF key should be included in download URL.
*/
protected $requiresDownloadConfirmation = NULL;
/**
* Can the member download this file?
*
* @param \IPS\Member|NULL $member The member to check or NULL for currently logged in member
* @return bool
*/
public function requiresDownloadConfirmation( \IPS\Member $member = NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if ( $this->requiresDownloadConfirmation === NULL )
{
$this->requiresDownloadConfirmation = FALSE;
$category = $this->container();
if( $category->message('disclaimer') and \in_array( $category->disclaimer_location, [ 'download', 'both' ] ) )
{
$this->requiresDownloadConfirmation = TRUE;
}
$files = $this->files( isset( \IPS\Request::i()->version ) ? \IPS\Request::i()->version : NULL );
if( \count( $files ) > 1 AND !isset( \IPS\Request::i()->r ) )
{
$this->requiresDownloadConfirmation = TRUE;
}
if( $member->group['idm_wait_period'] AND ( !$this->isPaid() OR $member->group['idm_paid_restrictions'] ) )
{
$this->requiresDownloadConfirmation = TRUE;
}
}
return $this->requiresDownloadConfirmation;
}
/**
* Can the member buy this file?
@@ -1408,19 +1453,6 @@ class _File extends \IPS\Content\Item implements
return $member->group['idm_view_downloads'];
}
/**
* Build form to edit
*
* @return \IPS\Helpers\Form
*/
public function buildEditForm()
{
$form = parent::buildEditForm();
$form->class = 'ipsPadding ipsForm_vertical';
return $form;
}
/**
* Get elements for add/edit form
*
@@ -1779,6 +1811,11 @@ class _File extends \IPS\Content\Item implements
{
$topic->logDelete( $member );
}
if ( $this->hasPendingVersion() )
{
\IPS\downloads\File\PendingVersion::load( $this->id, 'pending_file_id' )->delete();
}
}
/**
@@ -1841,7 +1878,13 @@ class _File extends \IPS\Content\Item implements
\IPS\Db::i()->delete( 'downloads_filebackup', array( 'b_fileid=?', $this->id ) );
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_file_id=?', $this->id ) );
\IPS\Db::i()->delete( 'downloads_files_notify', array( 'notify_file_id=?', $this->id ) );
/* Delete pending version */
if( $this->hasPendingVersion() )
{
\IPS\downloads\File\PendingVersion::load($this->id, 'pending_file_id' )->delete();
}
/* Update Category */
$this->container()->setLastFile();
$this->container()->save();
@@ -1854,7 +1897,7 @@ class _File extends \IPS\Content\Item implements
* @param string $url Record location
* @param string $handler File storage handler key
*/
public function deleteRecords( $ids, string $url=NULL, string $handler=NULL ): void
public function deleteRecords( $ids, string $url=NULL, string $handler=NULL )
{
if( $ids AND $handler AND $url )
{
@@ -1879,13 +1922,13 @@ class _File extends \IPS\Content\Item implements
}
}
/**
* URL Blacklist Check
*
* @param array $val URLs to check
* @return void
* @throws \DomainException
*/
/**
* URL Blacklist Check
*
* @param array $val URLs to check
* @return void
* @throws \DomainException
*/
public static function blacklistCheck( $val )
{
if ( \is_array( $val ) )
@@ -2295,6 +2338,7 @@ class _File extends \IPS\Content\Item implements
{
$this->sendUpdateNotifications();
}
$this->sendAuthorApprovalNotification();
}
/**
@@ -2368,7 +2412,7 @@ class _File extends \IPS\Content\Item implements
* @param string $view 'expanded' or 'condensed'
* @return callable
*/
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $view )
{
$screenshot = NULL;
if ( isset( $itemData['extra'] ) )
@@ -2466,7 +2510,7 @@ class _File extends \IPS\Content\Item implements
'canDownload' => $authorizedMember ? (bool) $this->canDownload( $authorizedMember ) : NULL,
'canBuy' => $authorizedMember ? (bool) $this->canBuy( $authorizedMember ) : NULL,
'canReview' => (bool) $authorizedMember ? ( $this->canReview( $authorizedMember ) AND !$this->hasReviewed( $authorizedMember ) ) : NULL,
'rating' => $this->rating,
'rating' => $this->averageReviewRating(),
'purchases' => $this->purchaseCount(),
'renewalTerm' => $this->isPaid() ? $this->renewalTerm() : NULL,
'hasPendingVersion' => ( !$authorizedMember OR $this->canEdit( $authorizedMember ) ) ? $this->hasPendingVersion() : NULL
@@ -2628,8 +2672,34 @@ class _File extends \IPS\Content\Item implements
* @param \IPS\Helpers\Form $form
* @return void
*/
public function newVersionFormElements( \IPS\Helpers\Form &$form ): void
public function newVersionFormElements( \IPS\Helpers\Form &$form )
{
}
/**
* Do Moderator Action
*
* @param string $action The action
* @param \IPS\Member|NULL $member The member doing the action (NULL for currently logged in member)
* @param string|NULL $reason Reason (for hides)
* @param bool $immediately Delete immediately
* @return void
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
*/
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL, $immediately = FALSE )
{
if ( $action == 'delete' )
{
/* Delete pending version */
if( $this->hasPendingVersion() )
{
\IPS\downloads\File\PendingVersion::load($this->id, 'pending_file_id' )->delete();
$this->_pendingVersion = FALSE;
}
}
return parent::modAction( $action, $member, $reason, $immediately );
}
}