Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Node
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog;
|
||||
@@ -24,6 +23,8 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\ClubContainer;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -176,6 +177,26 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
$member = \IPS\Member::loggedIn();
|
||||
}
|
||||
|
||||
if ( $club = $this->club() )
|
||||
{
|
||||
if ( !$member->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch ( $permission )
|
||||
{
|
||||
case 'add':
|
||||
return $club->isModerator( $member );
|
||||
|
||||
case 'view':
|
||||
case 'read':
|
||||
default:
|
||||
return $club->canRead( $member );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->social_group )
|
||||
{
|
||||
@@ -235,7 +256,18 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
$return = parent::searchIndexPermissions();
|
||||
|
||||
if ( $this->social_group )
|
||||
if ( $club = $this->club() )
|
||||
{
|
||||
if ( $club->type == $club::TYPE_PUBLIC )
|
||||
{
|
||||
return 'ca';
|
||||
}
|
||||
else
|
||||
{
|
||||
return "cm,c{$club->id}";
|
||||
}
|
||||
}
|
||||
elseif ( $this->social_group )
|
||||
{
|
||||
$return = ( $return === '*' ) ? array() : explode( ',', $return );
|
||||
|
||||
@@ -258,15 +290,19 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public static function followWhere()
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$where = array( array( '( blog_blogs.blog_social_group IS NULL OR blog_blogs.blog_member_id=' . \IPS\Member::loggedIn()->member_id . ' OR ( ' . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) . ' ) )' ) );
|
||||
$where[] = array( '( blog_blogs.blog_social_group IS NULL OR blog_blogs.blog_member_id=' . \IPS\Member::loggedIn()->member_id . ' OR ( ' . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) . ' ) )' );
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', \IPS\Member::loggedIn()->clubs() ) . ' )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) );
|
||||
$where[] = \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() );
|
||||
$where[] = array( 'blog_blogs.blog_club_id IS NULL' );
|
||||
}
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -301,47 +337,27 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'blog_name', $this->id ? $this->_title : NULL, TRUE, array(), NULL, NULL, NULL, 'blog_name' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'blog_desc', $this->id ? $this->description : 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' ), NULL, NULL, NULL, 'blog_desc_wrap' ) );
|
||||
|
||||
/* Sidebar */
|
||||
if ( \IPS\Settings::i()->blog_enable_sidebar )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_sidebar_enabled', $this->sidebar ? TRUE : FALSE, FALSE, array( 'togglesOn' => array( 'blog_sidebar_wrap' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'blog_sidebar', $this->id ? $this->sidebar : NULL, FALSE, array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blogsidebar-{$this->id}" : "blogs-new-blog-sidebar" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'sidebar' ) : NULL ), NULL, NULL, NULL, 'blog_sidebar_wrap' ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addHeader( 'blog_settings' );
|
||||
|
||||
/* Owned blogs */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'blog_name', $this->id ? $this->_title : NULL, FALSE, array(), function( $value ) {
|
||||
if ( \IPS\Request::i()->blog_type === 'member' AND !$value )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_required' );
|
||||
}
|
||||
}, NULL, NULL, 'blog_name' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'blog_desc', $this->id ? $this->desc : NULL, FALSE, array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blog-{$this->id}m" : "blogs-new-blog" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ), NULL, NULL, NULL, 'blog_desc_wrap' ) );
|
||||
|
||||
/* Group blogs - only one or the other will show at any given time */
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_name_group', ( $this->id AND !$this->groupblog_ids ) ? $this->_title : NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_blog_{$this->id}" : NULL ) ), function( $value ) {
|
||||
if ( \IPS\Request::i()->blog_type !== 'member' AND !$value )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_required' );
|
||||
}
|
||||
}, NULL, NULL, 'blog_name_group' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_desc_group', NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_blog_{$this->id}_desc" : NULL ), 'editor' => array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blog-{$this->id}-group" : "blogs-new-blog-group" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ) ), NULL, NULL, NULL, 'blog_desc_group_wrap' ) );
|
||||
|
||||
$groups = array();
|
||||
foreach ( \IPS\Member\Group::groups() as $k => $v )
|
||||
{
|
||||
$groups[ $k ] = $v->name;
|
||||
}
|
||||
|
||||
$type = 'member';
|
||||
if ( $this->id )
|
||||
{
|
||||
if ( $this->groupblog_ids )
|
||||
{
|
||||
$type = 'group';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$id = $this->id ?: 'new';
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'blog_type', $type, TRUE, array(
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'blog_type', ( $this->id AND $this->groupblog_ids ) ? 'group' : 'member', TRUE, array(
|
||||
'options' => array(
|
||||
'member' => 'blog_type_normal',
|
||||
'group' => 'blog_type_group'
|
||||
@@ -365,7 +381,65 @@ 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\Translatable( 'blog_groupblog_name', NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_groupblog_name_{$this->id}" : NULL ) ), NULL, NULL, NULL, 'blog_groupblog_name' ) );
|
||||
$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' )
|
||||
{
|
||||
$hasTitle = FALSE;
|
||||
|
||||
foreach( $value as $_value )
|
||||
{
|
||||
if( $_value )
|
||||
{
|
||||
$hasTitle = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$hasTitle )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_required' );
|
||||
}
|
||||
}
|
||||
}, NULL, NULL, 'blog_groupblog_name' ) );
|
||||
|
||||
/* Owned blogs */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'blog_name', $this->id ? $this->_title : NULL, FALSE, array(), function( $value ) {
|
||||
if ( \IPS\Request::i()->blog_type === 'member' AND !$value )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_required' );
|
||||
}
|
||||
}, NULL, NULL, 'blog_name' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'blog_desc', $this->id ? $this->desc : NULL, FALSE, array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blog-{$this->id}m" : "blogs-new-blog" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ), NULL, NULL, NULL, 'blog_desc_wrap' ) );
|
||||
|
||||
/* Group blogs - only one or the other will show at any given time */
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_name_group', ( $this->id AND !$this->groupblog_ids ) ? $this->_title : NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_blog_{$this->id}" : NULL ) ), function( $value ) {
|
||||
if ( \IPS\Request::i()->blog_type === 'group' )
|
||||
{
|
||||
$hasTitle = FALSE;
|
||||
|
||||
foreach( $value as $_value )
|
||||
{
|
||||
if( $_value )
|
||||
{
|
||||
$hasTitle = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$hasTitle )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_required' );
|
||||
}
|
||||
}
|
||||
}, NULL, NULL, 'blog_name_group' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_desc_group', NULL, FALSE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_blog_{$this->id}_desc" : NULL ), 'editor' => array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blog-{$this->id}-group" : "blogs-new-blog-group" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ) ), NULL, NULL, NULL, 'blog_desc_group_wrap' ) );
|
||||
|
||||
/* Sidebar */
|
||||
if ( \IPS\Settings::i()->blog_enable_sidebar )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_sidebar_enabled', $this->sidebar ? TRUE : FALSE, FALSE, array( 'togglesOn' => array( 'blog_sidebar_wrap' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'blog_sidebar', $this->id ? $this->sidebar : NULL, FALSE, array( 'app' => 'blog', 'key' => 'Blogs', 'autoSaveKey' => ( $this->id ? "blogs-blogsidebar-{$this->id}" : "blogs-new-blog-sidebar" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'sidebar' ) : NULL ), NULL, NULL, NULL, 'blog_sidebar_wrap' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->group['g_blog_allowprivate'] )
|
||||
@@ -539,6 +613,12 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
unset( $values['blog_enable_rss'] );
|
||||
}
|
||||
|
||||
if( array_key_exists( 'blog_sidebar_enabled', $values ) )
|
||||
{
|
||||
$values['blog_sidebar'] = $values['blog_sidebar_enabled'] ? $values['blog_sidebar'] : NULL;
|
||||
unset( $values['blog_sidebar_enabled'] );
|
||||
}
|
||||
|
||||
/* Send to parent */
|
||||
if( array_key_exists( 'blog_member_id', $values ) )
|
||||
{
|
||||
@@ -896,7 +976,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public function get_settings()
|
||||
{
|
||||
$settings = json_decode( $this->_data['settings'], TRUE );
|
||||
$settings = isset( $this->_data['settings'] ) ? json_decode( $this->_data['settings'], TRUE ) : array();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
@@ -930,7 +1010,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
\IPS\Http\Url::external( 'http://rpc.pingomatic.com/RPC2' )
|
||||
->request()
|
||||
->setHeaders( array( 'Content-Type' => 'text/xml', 'User-Agent' => "InvisionPowerServices/" . \IPS\Application::load('core')->long_version ) )
|
||||
->setHeaders( array( 'Content-Type' => 'text/xml', 'User-Agent' => "InvisionCommunity/" . \IPS\Application::load('core')->long_version ) )
|
||||
->post( $xml->asXML() );
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
@@ -1003,6 +1083,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'blog', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'blog' )->embedBlogs( $this, $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
|
||||
@@ -1072,4 +1153,66 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
|
||||
{
|
||||
return array( 'view' => 'view', 'add' => 'add' );
|
||||
}
|
||||
|
||||
/* !Clubs */
|
||||
|
||||
/**
|
||||
* Get front-end language string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function clubFrontTitle()
|
||||
{
|
||||
return 'blogs_sg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set form for creating a node of this type in a club
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form Form object
|
||||
* @return void
|
||||
*/
|
||||
public function clubForm( \IPS\Helpers\Form $form )
|
||||
{
|
||||
$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' ) ) );
|
||||
if( \IPS\Settings::i()->blog_allow_rss )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rss', $this->id ? $this->settings['allowrss'] : TRUE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class-specific routine when saving club form
|
||||
*
|
||||
* @param \IPS\Member\Club $club The club
|
||||
* @param array $values Values
|
||||
* @return void
|
||||
*/
|
||||
public function _saveClubForm( \IPS\Member\Club $club, $values )
|
||||
{
|
||||
if( \IPS\Settings::i()->blog_allow_rss )
|
||||
{
|
||||
$settings = $this->settings;
|
||||
$settings['allowrss'] = $values['blog_enable_rss'];
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
if ( $values['club_node_name'] )
|
||||
{
|
||||
$this->seo_name = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission index permissions to a specific club
|
||||
*
|
||||
* @param \IPS\Member\Club $club The club
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissionsToClub( \IPS\Member\Club $club )
|
||||
{
|
||||
// Deliberately do nothing, Blog handles permissions differently
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog RSS/Atom feed active record
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 02 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Profile Table Helper
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 18 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Table Helper
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 18 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
@@ -99,6 +98,9 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
{
|
||||
$where[] = array( 'blog_social_group IS NULL' );
|
||||
}
|
||||
|
||||
/* Exclude club blogs */
|
||||
$where[] = array( 'blog_club_id IS NULL' );
|
||||
|
||||
/* Get Count */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*) as cnt', 'blog_blogs', $where )->first();
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Entry Comment Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Entry;
|
||||
@@ -22,8 +21,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Blog Entry Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Reputation, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -75,11 +76,6 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
*/
|
||||
public static $icon = 'file-text';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'comment_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
@@ -109,10 +105,12 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
if ( $member->member_id )
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_social_group IS NULL OR blog_blogs.blog_member_id=' . $member->member_id . ' OR ( ' . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . ' ) )' );
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', \IPS\Member::loggedIn()->clubs() ) . ' )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( "(" . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . " OR blog_blogs.blog_social_group IS NULL )" );
|
||||
$where[] = array( 'blog_blogs.blog_club_id IS NULL' );
|
||||
}
|
||||
}
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins );
|
||||
@@ -136,4 +134,26 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
|
||||
return parent::modPermission( $type, $member, $container );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'comment_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
*
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'blog', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'blog' )->embedEntryComment( $this, $this->item(), $this->item()->container(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Entry Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog;
|
||||
@@ -33,11 +32,13 @@ class _Entry extends \IPS\Content\Item implements
|
||||
\IPS\Content\Polls,
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\EditHistory,
|
||||
\IPS\Content\Reputation,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\FuturePublishing
|
||||
{
|
||||
\IPS\Content\FuturePublishing,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
@@ -91,6 +92,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'is_future_entry' => 'is_future_entry',
|
||||
'future_date' => 'publish_date',
|
||||
'status' => 'status',
|
||||
'meta_data' => 'meta_data',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -133,11 +135,6 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'reply' => 4,
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'entry_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
@@ -242,6 +239,15 @@ class _Entry extends \IPS\Content\Item implements
|
||||
{
|
||||
$return = TRUE;
|
||||
}
|
||||
|
||||
/* Club blog */
|
||||
if ( $club = $this->container()->club() )
|
||||
{
|
||||
if ( !$club->canRead( $member ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Private blog */
|
||||
if( $this->container()->social_group != 0 AND $this->container()->owner() != $member )
|
||||
@@ -296,10 +302,12 @@ class _Entry extends \IPS\Content\Item implements
|
||||
if ( $member->member_id )
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_member_id=' . $member->member_id . ' OR ( ' . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . ' ) OR blog_blogs.blog_social_group IS NULL )' );
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', \IPS\Member::loggedIn()->clubs() ) . ' )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( "(" . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . " OR blog_blogs.blog_social_group IS NULL )" );
|
||||
$where[] = array( 'blog_blogs.blog_club_id IS NULL' );
|
||||
}
|
||||
}
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
|
||||
@@ -318,10 +326,12 @@ class _Entry extends \IPS\Content\Item implements
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$where = array( array( '( blog_blogs.blog_social_group IS NULL OR blog_blogs.blog_member_id=' . \IPS\Member::loggedIn()->member_id . ' OR ( ' . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) . ' ) )' ) );
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', \IPS\Member::loggedIn()->clubs() ) . ' )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) );
|
||||
$where[] = array( 'blog_blogs.blog_club_id IS NULL' );
|
||||
}
|
||||
|
||||
return array_merge( parent::followWhere( $joinContainer, $joins ), $where );
|
||||
@@ -439,7 +449,12 @@ class _Entry extends \IPS\Content\Item implements
|
||||
|
||||
if ( $container )
|
||||
{
|
||||
if ( !in_array( $container->id, array_keys( $blogs ) ) )
|
||||
if ( $club = $container->club() )
|
||||
{
|
||||
$return = $club->isModerator( $member );
|
||||
$error = 'no_module_permission';
|
||||
}
|
||||
elseif ( !in_array( $container->id, array_keys( $blogs ) ) )
|
||||
{
|
||||
$return = FALSE;
|
||||
$error = 'no_module_permission';
|
||||
@@ -664,4 +679,107 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'rating' => $this->averageRating(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'entry_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported Meta Data Types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function supportedMetaDataTypes()
|
||||
{
|
||||
return array( 'core_FeaturedComments', 'core_ContentMessages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can perform an action on a message
|
||||
*
|
||||
* @param string The action
|
||||
* @param \IPS\Member|NULL The member, or NULL for currently logged in
|
||||
* @return bool
|
||||
* @todo Mod Log
|
||||
*/
|
||||
public function canOnMessage( $action, \IPS\Member $member = NULL )
|
||||
{
|
||||
$return = parent::canOnMessage( $action, $member );
|
||||
|
||||
if ( $return === FALSE )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( $member->member_id AND $member->member_id === $this->author()->member_id AND $member->group['g_blog_allowownmod'] )
|
||||
{
|
||||
$return = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can Feature a Comment
|
||||
*
|
||||
* @param \IPS\Member|NULL The member, or NULL for currently logged in
|
||||
* @return bool
|
||||
*/
|
||||
public function canFeatureComment( \IPS\Member $member = NULL )
|
||||
{
|
||||
$return = parent::canFeatureComment( $member );
|
||||
|
||||
if ( $return === FALSE )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( $member->member_id AND $member->member_id === $this->author()->member_id AND $member->group['g_blog_allowownmod'] )
|
||||
{
|
||||
$return = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can Unfeature a Comment
|
||||
*
|
||||
* @param \IPS\Member|NULL The member, or NULL for currently logged in
|
||||
* @return bool
|
||||
*/
|
||||
public function canUnfeatureComment( \IPS\Member $member = NULL )
|
||||
{
|
||||
$return = parent::canUnfeatureComment( $member );
|
||||
|
||||
if ( $return === FALSE )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( $member->member_id AND $member->member_id === $this->author()->member_id AND $member->group['g_blog_allowownmod'] )
|
||||
{
|
||||
$return = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
*
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'blog', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'blog' )->embedEntry( $this, $this->container(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user