Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -198,19 +198,32 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
parent::set__enabled( $enabled );
|
||||
|
||||
if ( $enabled )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( static::$contentItemClass, $this->_id, NULL, $this->searchIndexPermissions() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( static::$contentItemClass, $this->_id, NULL, '' );
|
||||
}
|
||||
static::updateSearchIndexOnEnableDisable( $this, (bool) $enabled );
|
||||
|
||||
/* Trash widgets so files in this category are not viewable in widgets */
|
||||
\IPS\Widget::deleteCaches( NULL, 'downloads' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the search index on enable / disable of a category
|
||||
*
|
||||
* @param \IPS\downloads\Category $node The Category
|
||||
* @param bool $enabled Enabled / Disable
|
||||
* @return void
|
||||
*/
|
||||
protected static function updateSearchIndexOnEnableDisable( \IPS\downloads\Category $node, $enabled )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( static::$contentItemClass, $node->_id, NULL, ( $enabled ) ? $node->searchIndexPermissions() : '' );
|
||||
|
||||
if ( $node->hasChildren( NULL ) )
|
||||
{
|
||||
foreach( $node->children( NULL ) AS $child )
|
||||
{
|
||||
static::updateSearchIndexOnEnableDisable( $child, $enabled );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
@@ -565,10 +578,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*
|
||||
* @param mixed $permission A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
|
||||
* @param \IPS\Member|\IPS\Member\Group|NULL $member The member or group to check (NULL for currently logged in member)
|
||||
* @param array $where Additional WHERE clause
|
||||
* @return bool
|
||||
* @throws \OutOfBoundsException If $permission does not exist in static::$permissionMap
|
||||
*/
|
||||
public static function canOnAny( $permission, $member=NULL )
|
||||
public static function canOnAny( $permission, $member=NULL, $where = array() )
|
||||
{
|
||||
$member = ( $member === NULL ) ? \IPS\Member::loggedIn() : $member;
|
||||
|
||||
@@ -577,7 +591,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return parent::canOnAny( $permission, $member );
|
||||
return parent::canOnAny( $permission, $member, $where );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -678,7 +692,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
$file = \IPS\downloads\File::constructFromData( \IPS\Db::i()->select( '*', 'downloads_files', array( 'file_cat=? AND file_open=1', $this->id ), 'file_submitted DESC', 1 )->first() );
|
||||
$file = \IPS\downloads\File::constructFromData( \IPS\Db::i()->select( '*', 'downloads_files', array( 'file_cat=? AND file_open=1', $this->id ), 'file_submitted DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first() );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
@@ -777,5 +791,21 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$this->name_furl = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
|
||||
}
|
||||
|
||||
if ( !$this->_id )
|
||||
{
|
||||
$this->save();
|
||||
\IPS\File::claimAttachments( 'downloads-new-cat', $this->id, NULL, 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Files in clubs the member can view
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function filesInClubNodes()
|
||||
{
|
||||
return \IPS\downloads\File::getItemsWithPermission( array( array( static::$databasePrefix . static::clubIdColumn() . ' IS NOT NULL' ) ), NULL, 1, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE, FALSE, FALSE, TRUE );
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* File Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Shareable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Shareable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
|
||||
@@ -25,7 +25,6 @@ class _File extends \IPS\Content\Item implements
|
||||
\IPS\Content\Permissions,
|
||||
\IPS\Content\Tags,
|
||||
\IPS\Content\Followable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\ReadMarkers,
|
||||
\IPS\Content\Views,
|
||||
\IPS\Content\Hideable, \IPS\Content\Featurable, \IPS\Content\Pinnable, \IPS\Content\Lockable,
|
||||
@@ -34,7 +33,7 @@ class _File extends \IPS\Content\Item implements
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
@@ -252,7 +251,7 @@ class _File extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'downloads' ), 'rows' );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'downloads', 'front' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,6 +358,57 @@ class _File extends \IPS\Content\Item implements
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Purchasable?
|
||||
*
|
||||
* @param bool $checkPaid Check if the file is a paid file
|
||||
* @return bool
|
||||
*/
|
||||
public function isPurchasable( $checkPaid = TRUE )
|
||||
{
|
||||
/* If it's not a paid file, then it's not purchasable */
|
||||
if ( $checkPaid and !$this->isPaid() )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (bool) $this->purchasable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can enable purchases?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member Member to check, or NULL for currently logged in member
|
||||
* @return bool
|
||||
*/
|
||||
public function canEnablePurchases( \IPS\Member $member = NULL )
|
||||
{
|
||||
if ( !$this->isPaid() )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return (bool) $member->modPermission('can_make_purchasable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can disable purchases?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member Member to check, or NULL for currently logged in member
|
||||
* @return bool
|
||||
*/
|
||||
public function canDisablePurchases( \IPS\Member $member = NULL )
|
||||
{
|
||||
if ( !$this->isPaid() )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return (bool) $member->modPermission('can_make_unpurchasable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Price
|
||||
*
|
||||
@@ -396,7 +446,8 @@ class _File extends \IPS\Content\Item implements
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
|
||||
catch ( \OutOfBoundsException $e ) { }
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -572,14 +623,14 @@ class _File extends \IPS\Content\Item implements
|
||||
{
|
||||
$images = array();
|
||||
$count = 0;
|
||||
foreach( $this->screenshots() as $image )
|
||||
foreach( $this->screenshots( 0, FALSE ) as $image )
|
||||
{
|
||||
if ( $count == $limit )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$images[] = array( 'downloads_Screenshots' => (string) $image);
|
||||
$images[] = array( 'downloads_Screenshots' => (string) $image );
|
||||
$count++;
|
||||
}
|
||||
|
||||
@@ -719,13 +770,13 @@ class _File extends \IPS\Content\Item implements
|
||||
|
||||
if( isset( $this->_fieldData[ $fieldId ] ) )
|
||||
{
|
||||
$v = str_replace( '{content}', htmlspecialchars( $v, \IPS\HTMLENTITIES, 'UTF-8', FALSE ), $thisField->displayValue( $v ) );
|
||||
$v = str_replace( '{content}', htmlspecialchars( $v, ENT_DISALLOWED, 'UTF-8', FALSE ), $thisField->displayValue( $v ) );
|
||||
$v = str_replace( '{member_id}', \IPS\Member::loggedIn()->member_id, $v );
|
||||
$v = str_replace( '{title}', \IPS\Member::loggedIn()->language()->addToStack( 'downloads_field_' . $fieldId ), $v );
|
||||
}
|
||||
else
|
||||
{
|
||||
$v = htmlspecialchars( $v, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
$v = htmlspecialchars( $v, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,7 +840,7 @@ class _File extends \IPS\Content\Item implements
|
||||
{
|
||||
if ( $container and $container->bitoptions['moderation'] and !$member->group['g_avoid_q'] )
|
||||
{
|
||||
return TRUE;
|
||||
return !static::modPermission( 'approve', $member, $container );
|
||||
}
|
||||
|
||||
return parent::moderateNewItems( $member, $container );
|
||||
@@ -1238,7 +1289,7 @@ class _File extends \IPS\Content\Item implements
|
||||
$return = parent::formElements( $item, $container );
|
||||
|
||||
/* Description */
|
||||
$return['description'] = new \IPS\Helpers\Form\Editor( 'file_desc', $item ? $item->desc : NULL, TRUE, array( 'app' => 'downloads', 'key' => 'Downloads', 'autoSaveKey' => 'downloads-new-file', 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'desc' ) ) ) );
|
||||
$return['description'] = new \IPS\Helpers\Form\Editor( 'file_desc', $item ? $item->desc : NULL, TRUE, array( 'app' => 'downloads', 'key' => 'Downloads', 'autoSaveKey' => 'downloads-new-file', 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'desc' ) ) ), '\IPS\Helpers\Form::floodCheck' );
|
||||
|
||||
/* Primary screenshot */
|
||||
if ( $item )
|
||||
@@ -1351,8 +1402,13 @@ class _File extends \IPS\Content\Item implements
|
||||
public function processForm( $values )
|
||||
{
|
||||
parent::processForm( $values );
|
||||
$new = FALSE;
|
||||
|
||||
if ( !$this->_new )
|
||||
if ( $this->_new )
|
||||
{
|
||||
$new = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oldContent = $this->desc;
|
||||
}
|
||||
@@ -1412,7 +1468,14 @@ class _File extends \IPS\Content\Item implements
|
||||
foreach ( $this->container()->cfields as $field )
|
||||
{
|
||||
$helper = $field->buildHelper();
|
||||
$cfields[ "field_{$field->id}" ] = $helper::stringValue( $values[ "downloads_field_{$field->id}" ] );
|
||||
if ( $helper instanceof \IPS\Helpers\Form\Upload )
|
||||
{
|
||||
$cfields[ "field_{$field->id}" ] = (string) $values[ "downloads_field_{$field->id}" ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$cfields[ "field_{$field->id}" ] = $helper::stringValue( $values[ "downloads_field_{$field->id}" ] );
|
||||
}
|
||||
|
||||
if ( $helper instanceof \IPS\Helpers\Form\Editor )
|
||||
{
|
||||
@@ -1426,7 +1489,7 @@ class _File extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/* Update Category */
|
||||
$this->container()->setLastFile();
|
||||
$this->container()->setLastFile( $new ? $this : NULL );
|
||||
$this->container()->save();
|
||||
}
|
||||
|
||||
@@ -1787,7 +1850,7 @@ class _File extends \IPS\Content\Item implements
|
||||
$queueData['category_id'] = $category->$categoryIdColumn;
|
||||
$queueData['member_id'] = $member->member_id;
|
||||
|
||||
\IPS\Task::queue( 'downloads', 'Follow', $queueData );
|
||||
\IPS\Task::queue( 'downloads', 'Follow', $queueData, 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1936,7 +1999,7 @@ class _File extends \IPS\Content\Item implements
|
||||
if ( $count > static::NOTIFICATIONS_PER_BATCH )
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
\IPS\Task::queue( 'core', 'Follow', array( 'class' => get_class( $this ), 'item' => $this->$idColumn, 'extra' => 'update', 'exclude' => array() ) );
|
||||
\IPS\Task::queue( 'core', 'Follow', array( 'class' => get_class( $this ), 'item' => $this->$idColumn, 'extra' => 'update', 'exclude' => array() ), 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2180,7 +2243,7 @@ class _File extends \IPS\Content\Item implements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function syncTopic()
|
||||
public function syncTopic()
|
||||
{
|
||||
/* Existing topic */
|
||||
if ( $this->topicid )
|
||||
@@ -2202,6 +2265,13 @@ class _File extends \IPS\Content\Item implements
|
||||
}
|
||||
$topic->save();
|
||||
$firstPost = $topic->comments( 1 );
|
||||
|
||||
/* If the first post of the topic is missing, NULL will be returned */
|
||||
if( $firstPost === NULL )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$content = \IPS\Theme::i()->getTemplate( 'submit', 'downloads', 'front' )->topic( $this );
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $content );
|
||||
$firstPost->post = $content;
|
||||
@@ -2326,6 +2396,7 @@ class _File extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @param array $backup If provided, will output for a particular version - provide row from downloads_filebackup
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
@@ -2350,25 +2421,26 @@ class _File extends \IPS\Content\Item implements
|
||||
* @apiresponse bool pinned File is pinned
|
||||
* @apiresponse bool featured File is featured
|
||||
* @apiresponse string url URL
|
||||
* @apiresponse \IPS\forums\Topic topic The topic
|
||||
*/
|
||||
public function apiOutput( $backup=NULL )
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL, $backup=NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'title' => $backup ? $backup['b_filetitle'] : $this->name,
|
||||
'category' => $this->container()->apiOutput(),
|
||||
'author' => $this->author()->apiOutput(),
|
||||
'category' => $this->container()->apiOutput( $authorizedMember ),
|
||||
'author' => $this->author()->apiOutput( $authorizedMember ),
|
||||
'date' => \IPS\DateTime::ts( $backup ? $backup['b_backup'] : $this->submitted )->rfc3339(),
|
||||
'description' => $backup ? $backup['b_filedesc'] : $this->content(),
|
||||
'version' => $backup ? $backup['b_version'] : $this->version,
|
||||
'changelog' => $backup ? $backup['b_changelog'] : $this->changelog,
|
||||
'files' => array_values( array_map( function( $file ) {
|
||||
return $file->apiOutput();
|
||||
'files' => array_values( array_map( function( $file ) use ( $authorizedMember ) {
|
||||
return $file->apiOutput( $authorizedMember );
|
||||
}, iterator_to_array( $this->files( $backup ? $backup['b_id'] : NULL ) ) ) ),
|
||||
'screenshots' => array_values( array_map( function( $file ) {
|
||||
return $file->apiOutput();
|
||||
'screenshots' => array_values( array_map( function( $file ) use ( $authorizedMember ) {
|
||||
return $file->apiOutput( $authorizedMember );
|
||||
}, iterator_to_array( $this->screenshots( 0, TRUE, $backup ? $backup['b_id'] : NULL ) ) ) ),
|
||||
'primaryScreenshot' => $this->primary_screenshot ? ( $this->primary_screenshot->apiOutput() ) : null,
|
||||
'primaryScreenshot' => $this->primary_screenshot ? ( $this->primary_screenshot->apiOutput( $authorizedMember ) ) : null,
|
||||
'downloads' => $this->downloads,
|
||||
'comments' => $this->comments,
|
||||
'reviews' => $this->reviews,
|
||||
@@ -2380,6 +2452,7 @@ class _File extends \IPS\Content\Item implements
|
||||
'pinned' => (bool) $this->mapped('pinned'),
|
||||
'featured' => (bool) $this->mapped('featured'),
|
||||
'url' => (string) $this->url(),
|
||||
'topic' => $this->topicid ? $this->topic()->apiOutput( $authorizedMember ) : NULL,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* File Review Model
|
||||
*/
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
@@ -63,6 +63,7 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
'votes_helpful' => 'votes_helpful',
|
||||
'votes_data' => 'votes_data',
|
||||
'approved' => 'approved',
|
||||
'author_response' => 'author_response',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user