Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -247,7 +247,6 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
default:
|
||||
return $club->canRead( $member );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->social_group )
|
||||
@@ -312,7 +311,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
if ( $club->type == $club::TYPE_PUBLIC or $club->type == $club::TYPE_READONLY or $club->type == $club::TYPE_OPEN)
|
||||
{
|
||||
return 'ca';
|
||||
return '*';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -429,6 +428,10 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
'subnodes' => FALSE,
|
||||
), NULL, NULL, NULL, 'blog_category_id' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->hiddenValues['blog_category_id'] = \IPS\Request::i()->parent;
|
||||
}
|
||||
|
||||
$groups = array();
|
||||
foreach ( \IPS\Member\Group::groups() as $k => $v )
|
||||
@@ -461,7 +464,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
},
|
||||
NULL, NULL, 'blog_member_id' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'blog_groupblog_ids', $this->id ? explode( ',', $this->groupblog_ids ) : array(), FALSE, array( 'options' => $groups, 'multiple' => TRUE ), NULL, NULL, NULL, 'blog_groupblog_ids' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'blog_groupblog_ids', $this->id ? explode( ',', $this->groupblog_ids ) : array(), FALSE, array( 'options' => $groups, 'multiple' => TRUE ), NULL, NULL, NULL, 'blog_groupblog_ids' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_groupblog_name', NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_groupblog_name_{$this->id}" : NULL ) ), function( $value ) {
|
||||
if ( \IPS\Request::i()->blog_type === 'group' )
|
||||
{
|
||||
@@ -542,6 +545,8 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rss', $this->id ? $this->settings['allowrss'] : TRUE ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_anonymous_comments', $this->id ? $this->allow_anonymous : FALSE, FALSE, array() ) );
|
||||
|
||||
/* Categories */
|
||||
if ( $public and $this->id )
|
||||
{
|
||||
@@ -558,8 +563,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
{
|
||||
|
||||
if ( isset( $values['blog_category_id'] ) and $values[ 'blog_category_id' ] )
|
||||
if ( isset( $values['blog_category_id'] ) and \is_object( $values[ 'blog_category_id' ] ) )
|
||||
{
|
||||
$values[ 'blog_category_id' ] = \intval( $values[ 'blog_category_id' ]->id );
|
||||
}
|
||||
@@ -589,6 +593,12 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
unset( $values['blog_type'] );
|
||||
}
|
||||
|
||||
if( isset( $values['allow_anonymous_comments'] ) )
|
||||
{
|
||||
$values['allow_anonymous'] = ( $values['allow_anonymous_comments'] ? 2 : 0 );
|
||||
unset( $values['allow_anonymous_comments'] );
|
||||
}
|
||||
|
||||
$this->massUpdateIndex = FALSE;
|
||||
if ( isset( $values['blog_privacy'] ) and $values['blog_privacy'] === 'private' )
|
||||
{
|
||||
@@ -622,7 +632,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
|
||||
if( $values['blog_member_id'] )
|
||||
{
|
||||
\IPS\File::claimAttachments( 'blogs-new-blog', $this->id, NULL, 'description', TRUE );
|
||||
\IPS\File::claimAttachments( 'blogs-new-blog', $this->id, NULL, 'description' );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -766,6 +776,12 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( 'IPS\blog\Entry', $this->id, NULL, $this->searchIndexPermissions() );
|
||||
}
|
||||
|
||||
/* If this was a new blog, fire the webhook */
|
||||
if ( $this->newBlog )
|
||||
{
|
||||
\IPS\Api\Webhook::fire( 'blogBlog_create', $this, $this->webhookFilters() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1096,6 +1112,11 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'blog' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remember if this is a new blog so we can fire the webhook if so
|
||||
*/
|
||||
protected $newBlog = NULL;
|
||||
|
||||
/**
|
||||
* Save Changed Columns
|
||||
@@ -1104,14 +1125,12 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$new = $this->_new;
|
||||
if( $this->newBlog === NULL )
|
||||
{
|
||||
$this->newBlog = $this->_new;
|
||||
}
|
||||
|
||||
parent::save();
|
||||
|
||||
if ( $new )
|
||||
{
|
||||
\IPS\Api\Webhook::fire( 'blogBlog_create', $this, $this->webhookFilters() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1150,6 +1169,9 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
/* Delete Follows */
|
||||
\IPS\Db::i()->delete( 'core_follow', array( "follow_app=? AND follow_area=? AND follow_rel_id=?", 'blog', 'blog', $this->_id ) );
|
||||
|
||||
/* Delete Entry categories */
|
||||
\IPS\Db::i()->delete( 'blog_entry_categories', array( "entry_category_blog_id = ?", $this->_id ) );
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
@@ -1285,6 +1307,9 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public function clubForm( \IPS\Helpers\Form $form )
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'blog', 'front' ) );
|
||||
|
||||
$form->addTab( 'blog_settings' );
|
||||
$itemClass = static::$contentItemClass;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'club_node_name', $this->_id ? $this->_title : \IPS\Member::loggedIn()->language()->addToStack( 'blogs_sg' ), TRUE, array( 'maxLength' => 255 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'club_node_description', $this->_id ? \IPS\Member::loggedIn()->language()->get( static::$titleLangPrefix . $this->_id . '_desc' ) : NULL, FALSE, array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blog-{$this->id}" : "blogs-new-blog" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ) ) );
|
||||
@@ -1292,6 +1317,14 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rss', $this->id ? $this->settings['allowrss'] : TRUE ) );
|
||||
}
|
||||
|
||||
/* Categories */
|
||||
if ( $this->id )
|
||||
{
|
||||
$form->addTab( 'blog_entry_categories' );
|
||||
$form->addHtml( \IPS\Theme::i()->getTemplate( 'view', 'blog', 'front' )->manageCategories( $this ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1392,9 +1425,10 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
* Get last comment time
|
||||
*
|
||||
* @note This should return the last comment time for this node only, not for children nodes
|
||||
* @param \IPS\Member|NULL $member MemberObject
|
||||
* @return \IPS\DateTime|NULL
|
||||
*/
|
||||
public function getLastCommentTime()
|
||||
public function getLastCommentTime( \IPS\Member $member = NULL )
|
||||
{
|
||||
return $this->last_edate ? \IPS\DateTime::ts( $this->last_edate ) : NULL;
|
||||
}
|
||||
|
||||
@@ -252,4 +252,75 @@ class _Category extends \IPS\Node\Model
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the content item count
|
||||
*
|
||||
* @param null|array $data Data array for mass move/delete
|
||||
* @return null|int
|
||||
*/
|
||||
public function getContentItemCount( $data=NULL )
|
||||
{
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
|
||||
$idColumn = static::$databaseColumnId;
|
||||
|
||||
$where = array( array( 'blog_blogs.blog_category_id=?', $this->$idColumn ) );
|
||||
|
||||
if( $data )
|
||||
{
|
||||
$where = array_merge_recursive( $where, $this->massMoveorDeleteWhere( $data ) );
|
||||
}
|
||||
|
||||
$select = \IPS\Db::i()->select( 'COUNT(*)', $contentItemClass::$databaseTable, $where )->join( 'blog_blogs', "blog_entries.entry_blog_id=blog_blogs.blog_id" );
|
||||
|
||||
return (int) $select->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve content items (if applicable) for a node.
|
||||
*
|
||||
* @param int $limit The limit
|
||||
* @param int $offset The offset
|
||||
* @param array $additional Where Additional where clauses
|
||||
* @param int $countOnly If TRUE, will get the number of results
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function getContentItems( $limit, $offset, $additionalWhere = array(), $countOnly=FALSE )
|
||||
{
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
throw new \BadMethodCallException;
|
||||
}
|
||||
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
|
||||
$where = array();
|
||||
$where[] = array( 'blog_blogs.blog_category_id=?', $this->_id );
|
||||
|
||||
if ( \count( $additionalWhere ) )
|
||||
{
|
||||
foreach( $additionalWhere AS $clause )
|
||||
{
|
||||
$where[] = $clause;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $countOnly )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', $contentItemClass::$databaseTable, $where )->join( 'blog_blogs', "blog_entries.entry_blog_id=blog_blogs.blog_id" )->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
$limit = ( $offset !== NULL ) ? array( $offset, $limit ) : NULL;
|
||||
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $contentItemClass::$databaseTable, $where, $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId, $limit )->join( 'blog_blogs', "blog_entries.entry_blog_id=blog_blogs.blog_id" ), $contentItemClass );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Blog Entry Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -58,7 +58,8 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_member_name',
|
||||
'edit_show' => 'edit_show',
|
||||
'approved' => 'approved'
|
||||
'approved' => 'approved',
|
||||
'is_anon' => 'is_anon'
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,8 @@ class _Entry extends \IPS\Content\Item implements
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\FuturePublishing,
|
||||
\IPS\Content\MetaData
|
||||
\IPS\Content\MetaData,
|
||||
\IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -95,7 +96,9 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_name',
|
||||
'edit_show' => 'append_edit',
|
||||
'edit_reason' => 'edit_reason'
|
||||
'edit_reason' => 'edit_reason',
|
||||
'is_anon' => 'is_anon',
|
||||
'last_comment_anon' => 'last_poster_anon',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -443,7 +446,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
$options[ $category->id ] = $category->name;
|
||||
}
|
||||
|
||||
$return[ 'entry_category_id' ] = new \IPS\Helpers\Form\Select( 'entry_category_id', ( $item AND $item->category_id ) ? $item->category_id : ( \IPS\Request::i()->cat ? \IPS\Request::i()->cat : NULL ), FALSE, array( 'options' => $options ), NULL, NULL, NULL, "entry_category_id" );
|
||||
$return[ 'entry_category_id' ] = new \IPS\Helpers\Form\Select( 'entry_category_id', ( $item AND $item->category_id ) ? $item->category_id : ( \IPS\Request::i()->cat ? \IPS\Request::i()->cat : NULL ), FALSE, array( 'options' => $options, 'parse' => 'normal' ), NULL, NULL, NULL, "entry_category_id" );
|
||||
}
|
||||
$return['blog_entry_new_category'] = new \IPS\Helpers\Form\Text( 'blog_entry_new_category', NULL, TRUE, array(), NULL, NULL, NULL, "blog_entry_new_category" );
|
||||
|
||||
@@ -736,6 +739,18 @@ class _Entry extends \IPS\Content\Item implements
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
|
||||
$this->coverPhoto()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for content tables
|
||||
*
|
||||
@@ -992,4 +1007,19 @@ class _Entry extends \IPS\Content\Item implements
|
||||
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move
|
||||
*
|
||||
* @param \IPS\Node\Model $container Container to move to
|
||||
* @param bool $keepLink If TRUE, will keep a link in the source
|
||||
* @return void
|
||||
*/
|
||||
public function move( \IPS\Node\Model $container, $keepLink=FALSE )
|
||||
{
|
||||
parent::move( $container, $keepLink );
|
||||
|
||||
$this->category_id = NULL;
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user