Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,812 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Node
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blog Node
|
||||
*/
|
||||
class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\Embeddable
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'blog_blogs';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'blog_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'author' => 'member_id',
|
||||
'title' => 'name',
|
||||
'views' => 'num_views',
|
||||
'pinned' => 'pinned',
|
||||
'featured' => 'featured',
|
||||
'date' => 'last_edate',
|
||||
'cover_photo' => 'cover_photo',
|
||||
'cover_photo_offset' => 'cover_photo_offset'
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'blogs';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'blogs_blog_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Description suffix. If specified, will look for a language key with "{$titleLangPrefix}_{$id}_{$descriptionLangSuffix}" as the key
|
||||
*/
|
||||
public static $descriptionLangSuffix = '_desc';
|
||||
|
||||
/**
|
||||
* @brief [Node] Moderator Permission
|
||||
*/
|
||||
public static $modPerm = 'blogs';
|
||||
|
||||
/**
|
||||
* @brief Content Item Class
|
||||
*/
|
||||
public static $contentItemClass = 'IPS\blog\Entry';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'file-text-o';
|
||||
|
||||
/**
|
||||
* @brief [Node] If the node can be "owned", the owner "type" (typically "member" or "group") and the associated database column
|
||||
*/
|
||||
public static $ownerTypes = array( 'member' => 'member_id', 'group' => array( 'ids' => 'groupblog_ids', 'name' => 'groupblog_name' ) );
|
||||
|
||||
/**
|
||||
* @brief [Node] By mapping appropriate columns (rating_average and/or rating_total + rating_hits) allows to cache rating values
|
||||
*/
|
||||
public static $ratingColumnMap = array(
|
||||
'rating_average' => 'rating_average',
|
||||
'rating_total' => 'rating_total',
|
||||
'rating_hits' => 'rating_count',
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Cover Photo Storage Extension
|
||||
*/
|
||||
public static $coverPhotoStorageExtension = 'blog_Blogs';
|
||||
|
||||
/**
|
||||
* Get template for content tables
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'blog' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can create blog?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public static function canCreate( \IPS\Member $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( $member->member_id and $member->group['g_blog_allowlocal'] )
|
||||
{
|
||||
if ( $member->group['g_blog_maxblogs'] )
|
||||
{
|
||||
return ( \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', array( 'blog_member_id=?', $member->member_id ) )->first() < $member->group['g_blog_maxblogs'] );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 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)
|
||||
* @return bool
|
||||
* @throws \OutOfBoundsException If $permission does not exist in static::$permissionMap
|
||||
*/
|
||||
public function can( $permission, $member=NULL )
|
||||
{
|
||||
if ( $this->social_group )
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id !== $this->member_id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $this->social_group, \IPS\Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $permission === 'add' )
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
elseif ( \IPS\Member::loggedIn()->member_id === $this->member_id )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->groupblog_ids )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->inGroup( explode( ',', $this->groupblog_ids ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::can( $permission, $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Index Permissions
|
||||
*
|
||||
* @return string Comma-delimited values or '*'
|
||||
* @li Number indicates a group
|
||||
* @li Number prepended by "m" indicates a member
|
||||
* @li Number prepended by "s" indicates a social group
|
||||
*/
|
||||
public function searchIndexPermissions()
|
||||
{
|
||||
$return = parent::searchIndexPermissions();
|
||||
|
||||
if ( $this->social_group )
|
||||
{
|
||||
$return = ( $return === '*' ) ? array() : explode( ',', $return );
|
||||
|
||||
if ( $this->member_id )
|
||||
{
|
||||
$return[] = "m{$this->member_id}";
|
||||
}
|
||||
$return[] = "s{$this->social_group}";
|
||||
|
||||
$return = implode( ',', array_unique( $return ) );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional WHERE clauses for Follow view
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function followWhere()
|
||||
{
|
||||
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() ) . ' ) )' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) );
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Does the currently logged in user have permission to delete this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete()
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( 'data', 'core_queue', array( 'app=? AND `key`=?', 'core', 'DeleteOrMoveContent' ) ) as $row )
|
||||
{
|
||||
$data = json_decode( $row, TRUE );
|
||||
if ( $data['class'] === get_class( $this ) and $data['id'] == $this->_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return static::restrictionCheck( 'delete' ) or ( $this->member_id === \IPS\Member::loggedIn()->member_id and \IPS\Member::loggedIn()->group['g_blog_allowdelete'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form, $public=FALSE )
|
||||
{
|
||||
if( $public )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'blog_name', $this->id ? $this->_title : NULL, TRUE ) );
|
||||
$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' ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addHeader( 'blog_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_name', NULL, TRUE, array( 'app' => 'blog', 'key' => ( $this->id ? "blogs_blog_{$this->id}" : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'blog_desc', 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}" : "blogs-new-blog" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'blog_desc_placeholder' ) ) ) );
|
||||
|
||||
$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(
|
||||
'options' => array(
|
||||
'member' => 'blog_type_normal',
|
||||
'group' => 'blog_type_group'
|
||||
),
|
||||
'toggles' => array(
|
||||
'member' => array( 'blog_member_id' ),
|
||||
'group' => array( 'blog_groupblog_ids', 'blog_groupblog_name' )
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'blog_member_id', $this->member_id ? \IPS\Member::load( $this->member_id ) : NULL, FALSE, array(), function( $member ) use ( $form )
|
||||
{
|
||||
if ( \IPS\Request::i()->blog_type === 'member' )
|
||||
{
|
||||
if( !is_object( $member ) or !$member->member_id )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'no_blog_author_selected' );
|
||||
}
|
||||
}
|
||||
},
|
||||
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' ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->group['g_blog_allowprivate'] )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'blog_privacy', $this->social_group ? 'private' : 'open', FALSE, array(
|
||||
'options' => array(
|
||||
'open' => 'blog_privacy_open',
|
||||
'private' => 'blog_privacy_private'
|
||||
),
|
||||
'toggles' => array(
|
||||
'private' => array( 'blog_social_group' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\SocialGroup( 'blog_social_group', $this->social_group, NULL, array( 'owner' => $this->owner() ), NULL, NULL, NULL, 'blog_social_group' ) );
|
||||
}
|
||||
|
||||
if( \IPS\Settings::i()->blog_allow_rss )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rss', $this->id ? $this->settings['allowrss'] : TRUE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Format form values from add/edit form for save
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
{
|
||||
$this->member_id = 0;
|
||||
if( isset( $values['blog_type'] ) and $values['blog_type'] == 'member' and isset( $values['blog_member_id'] ) and is_object( $values['blog_member_id'] ) )
|
||||
{
|
||||
$values['blog_member_id']->create_menu = NULL;
|
||||
$values['blog_member_id']->save();
|
||||
$values['blog_member_id'] = $values['blog_member_id']->member_id;
|
||||
$this->member_id = $values['blog_member_id'];
|
||||
}
|
||||
else if ( !isset( $values['blog_type'] ) )
|
||||
{
|
||||
$values['blog_member_id'] = \IPS\Member::loggedIn()->member_id;
|
||||
\IPS\Member::loggedIn()->create_menu = NULL;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
$this->member_id = $values['blog_member_id'];
|
||||
}
|
||||
|
||||
if( isset( $values['blog_type'] ) )
|
||||
{
|
||||
unset( $values['blog_type'] );
|
||||
}
|
||||
|
||||
$this->massUpdateIndex = FALSE;
|
||||
if ( isset( $values['blog_privacy'] ) and $values['blog_privacy'] === 'private' )
|
||||
{
|
||||
if ( $this->id and !$this->social_group )
|
||||
{
|
||||
$this->massUpdateIndex = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->id and $this->social_group )
|
||||
{
|
||||
$this->massUpdateIndex = TRUE;
|
||||
|
||||
\IPS\Db::i()->delete( 'core_sys_social_groups', array( 'group_id=?', $this->social_group ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_social_group_members', array( 'group_id=?', $this->social_group ) );
|
||||
}
|
||||
|
||||
$values['blog_social_group'] = NULL;
|
||||
}
|
||||
|
||||
if( isset($values['blog_privacy'] ) )
|
||||
{
|
||||
unset( $values['blog_privacy'] );
|
||||
}
|
||||
|
||||
if ( !$this->id )
|
||||
{
|
||||
$this->save();
|
||||
\IPS\File::claimAttachments( 'blogs-new-blog', $this->id, NULL, 'description', TRUE );
|
||||
}
|
||||
|
||||
foreach ( array( 'blog_name' => "blogs_blog_{$this->id}", 'blog_desc' => "blogs_blog_{$this->id}_desc", 'blog_groupblog_name' => "blogs_groupblog_name_{$this->id}" ) as $fieldKey => $langKey )
|
||||
{
|
||||
if ( isset( $values[ $fieldKey ] ) )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'blog', $langKey, $values[ $fieldKey ] );
|
||||
|
||||
if ( $fieldKey === 'blog_name' )
|
||||
{
|
||||
$values['seo_name'] = \IPS\Http\Url::seoTitle( ( is_array( $values[ $fieldKey ] ) ) ? $values[ $fieldKey ][ \IPS\Lang::defaultLanguage() ] : $values[ $fieldKey ] );
|
||||
}
|
||||
|
||||
unset( $values[ $fieldKey ] );
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $values['blog_enable_rss'] ) )
|
||||
{
|
||||
$values['settings'] = array( 'allowrss' => $values['blog_enable_rss'] );
|
||||
unset( $values['blog_enable_rss'] );
|
||||
}
|
||||
|
||||
/* Send to parent */
|
||||
if( isset( $values['blog_member_id'] ) )
|
||||
{
|
||||
unset( $values['blog_member_id'] );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mass update search index after changes
|
||||
*/
|
||||
protected $massUpdateIndex = FALSE;
|
||||
|
||||
/**
|
||||
* [Node] Perform actions after saving the form
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return void
|
||||
*/
|
||||
public function postSaveForm( $values )
|
||||
{
|
||||
/* Update index? */
|
||||
if ( $this->massUpdateIndex )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( 'IPS\blog\Entry', $this->id, NULL, $this->searchIndexPermissions() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached URL
|
||||
*/
|
||||
protected $_url = NULL;
|
||||
|
||||
/**
|
||||
* Get SEO name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_seo_name()
|
||||
{
|
||||
if( !$this->_data['seo_name'] )
|
||||
{
|
||||
$this->seo_name = \IPS\Http\Url::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'blogs_blog_' . $this->id ) );
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this->_data['seo_name'] ?: \IPS\Http\Url::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'blogs_blog_' . $this->id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
if( $this->_url === NULL )
|
||||
{
|
||||
$this->_url = \IPS\Http\Url::internal( "app=blog&module=blogs&controller=view&id={$this->_id}", 'front', 'blogs_blog', array( $this->seo_name ) );
|
||||
}
|
||||
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached latest entry
|
||||
*/
|
||||
protected $latestEntry = NULL;
|
||||
|
||||
/**
|
||||
* Get latest entry
|
||||
*
|
||||
* @return \IPS\blog\Entry|NULL
|
||||
*/
|
||||
public function latestEntry()
|
||||
{
|
||||
if( $this->latestEntry !== NULL )
|
||||
{
|
||||
return $this->latestEntry;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
/* @note entry_hidden is flipped to map to "approved" */
|
||||
$this->latestEntry = \IPS\blog\Entry::constructFromData( \IPS\Db::i()->select( '*', 'blog_entries', array( 'entry_blog_id=? AND entry_is_future_entry=0 AND entry_hidden=1 AND entry_status!=?', $this->_id, 'draft' ), 'entry_date DESC', 1 )->first() );
|
||||
return $this->latestEntry;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Contributors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function contributors()
|
||||
{
|
||||
$contributors = array();
|
||||
|
||||
try
|
||||
{
|
||||
$select = \IPS\Db::i()->select(
|
||||
"core_members.*, count( blog_entries.entry_id ) as contributions",
|
||||
'blog_entries',
|
||||
array( "entry_blog_id=?", $this->id ),
|
||||
"contributions DESC",
|
||||
NULL,
|
||||
array( 'member_id' )
|
||||
)->join(
|
||||
'core_members',
|
||||
"blog_entries.entry_author_id=core_members.member_id"
|
||||
);
|
||||
|
||||
/* Get em! */
|
||||
foreach( $select as $row )
|
||||
{
|
||||
$contributors[] = array ( 'member' => \IPS\Member::constructFromData( $row ), 'contributions' => $row['contributions'] );
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
|
||||
return $contributors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve recent entries
|
||||
*
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
*/
|
||||
public function get__recentEntries()
|
||||
{
|
||||
return \IPS\blog\Entry::getItemsWithPermission( array( array( 'entry_blog_id=? AND entry_is_future_entry=0 AND entry_status!=?', $this->id, 'draft' ) ), NULL, 5 );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__items()
|
||||
{
|
||||
return $this->count_entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content comments
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__comments()
|
||||
{
|
||||
return $this->count_comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__unnapprovedItems()
|
||||
{
|
||||
return $this->count_entries_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content comments
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__unapprovedComments()
|
||||
{
|
||||
return $this->count_comments_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of items
|
||||
*
|
||||
* @param int $val Items
|
||||
* @return void
|
||||
*/
|
||||
protected function set__items( $val )
|
||||
{
|
||||
$this->count_entries = (int) $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of items
|
||||
*
|
||||
* @param int $val Comments
|
||||
* @return void
|
||||
*/
|
||||
protected function set__comments( $val )
|
||||
{
|
||||
$this->count_comments = (int) $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content items
|
||||
*
|
||||
* @param int $val Unapproved Items
|
||||
* @return void
|
||||
*/
|
||||
protected function set__unapprovedItems( $val )
|
||||
{
|
||||
$this->count_entries_hidden = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content comments
|
||||
*
|
||||
* @param int $val Unapproved Comments
|
||||
* @return void
|
||||
*/
|
||||
protected function set__unapprovedComments( $val )
|
||||
{
|
||||
$this->count_comments_hidden = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of future publishing items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__futureItems()
|
||||
{
|
||||
return $this->count_entries_future;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content items
|
||||
*
|
||||
* @param int $val Unapproved Items
|
||||
* @return void
|
||||
*/
|
||||
protected function set__futureItems( $val )
|
||||
{
|
||||
$this->count_entries_future = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get__title()
|
||||
{
|
||||
return htmlentities( \IPS\Member::loggedIn()->language()->get( static::$titleLangPrefix . $this->_id ), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_settings()
|
||||
{
|
||||
$settings = json_decode( $this->_data['settings'], TRUE );
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set settings
|
||||
*
|
||||
* @param array $values Values
|
||||
* @return void
|
||||
*/
|
||||
public function set_settings( $values )
|
||||
{
|
||||
$this->_data['settings'] = json_encode( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping Ping-o-matic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ping()
|
||||
{
|
||||
$xml = \IPS\Xml\SimpleXML::create('methodCall');
|
||||
|
||||
$methodName = $xml->addChild( 'methodName', 'weblogUpdates.ping' );
|
||||
$params = $xml->addChild( 'params' );
|
||||
$params->addChild( 'param' )->addChild( 'value', $this->_title );
|
||||
$params->addChild( 'param' )->addChild( 'value', $this->url() );
|
||||
|
||||
try
|
||||
{
|
||||
\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 ) )
|
||||
->post( $xml->asXML() );
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for node tables
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function nodeTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'blog' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Db::i()->delete( 'blog_rss_import', array( "rss_blog_id=?", $this->_id ) );
|
||||
|
||||
foreach ( array( 'blog_groupblog_name' => "blogs_groupblog_name_{$this->id}" ) as $fieldKey => $langKey )
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'blog', $langKey );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::load( $this->member_id );
|
||||
$member->create_menu = NULL;
|
||||
$member->save();
|
||||
|
||||
\IPS\File::unclaimAttachments( 'blog_Blogs', $this->id );
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cover Photo
|
||||
*
|
||||
* @return \IPS\Helpers\CoverPhoto
|
||||
*/
|
||||
public function coverPhoto()
|
||||
{
|
||||
$photo = parent::coverPhoto();
|
||||
$photo->overlay = \IPS\Theme::i()->getTemplate( 'view', 'blog' )->coverPhotoOverlay( $this );
|
||||
return $photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
*
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'blog' )->embedBlogs( $this, $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set last comment
|
||||
*
|
||||
* @param \IPS\Content\Comment $comment The latest comment or NULL to work it out
|
||||
* @return void
|
||||
*/
|
||||
public function setLastComment( \IPS\Content\Comment $comment=NULL )
|
||||
{
|
||||
if ( $comment === NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* @note entry_hidden is flipped to map to "approved" */
|
||||
$entry = \IPS\blog\Entry::constructFromData( \IPS\Db::i()->select( '*', 'blog_entries', array( 'entry_blog_id=? AND entry_status=? AND entry_hidden=1 and entry_is_future_entry=0', $this->id, 'published' ), 'entry_date DESC', 1 )->first() );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$this->last_edate = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry = $comment->item();
|
||||
}
|
||||
|
||||
$this->last_edate = $entry->mapped('date');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog RSS/Atom feed active record
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 02 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blog RSS/Atom feed active record
|
||||
*/
|
||||
class _Feed extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'blog_rss_import';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'rss_';
|
||||
|
||||
/**
|
||||
* Run
|
||||
*
|
||||
* @return void
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$previouslyImportedGuids = iterator_to_array( \IPS\Db::i()->select( 'rss_imported_guid', 'blog_rss_imported', array( 'rss_imported_impid=?', $this->id ) ) );
|
||||
|
||||
$request = \IPS\Http\Url::external( $this->url )->request();
|
||||
if ( $this->auth_user or $this->auth_pass )
|
||||
{
|
||||
$request = $request->login( $this->auth_user, $this->auth_pass );
|
||||
}
|
||||
$request = $request->get();
|
||||
|
||||
$container = \IPS\blog\Blog::load( $this->blog_id );
|
||||
|
||||
$inserts=array();
|
||||
$i = 0;
|
||||
foreach ( $request->decodeXml()->articles( $this->id ) as $guid => $article )
|
||||
{
|
||||
if ( !in_array( $guid, $previouslyImportedGuids ) )
|
||||
{
|
||||
$entry = \IPS\blog\Entry::createItem( \IPS\Member::load( $this->member ), NULL, $article['date'], $container );
|
||||
$entry->name = $article['title'];
|
||||
$entry->content = \IPS\Text\Parser::parseStatic( $article['content'] );
|
||||
|
||||
if ( $article['link'] )
|
||||
{
|
||||
$link = htmlentities( $this->import_show_link, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
$entry->content .= "<br><p><a href='{$article['link']}'>{$link}</a></p>";
|
||||
}
|
||||
|
||||
$entry->status = 'published';
|
||||
$entry->save();
|
||||
|
||||
/* Add to search index */
|
||||
\IPS\Content\Search\Index::i()->index( $entry );
|
||||
|
||||
$entry->setTags( json_decode( $this->tags, TRUE ) );
|
||||
|
||||
$inserts[] = array(
|
||||
'rss_imported_guid' => $guid,
|
||||
'rss_imported_entry_id' => $entry->id,
|
||||
'rss_imported_impid'=> $this->id
|
||||
);
|
||||
|
||||
$i++;
|
||||
|
||||
if ( $i >= 10 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $inserts ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'blog_rss_imported', $inserts );
|
||||
}
|
||||
|
||||
$this->last_import = time();
|
||||
$this->save();
|
||||
|
||||
$container->setLastComment();
|
||||
$container->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Db::i()->delete( 'blog_rss_import', array( 'rss_id=?', $this->id ) );
|
||||
return parent::delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Profile Table Helper
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 18 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blog Profile Table Helper
|
||||
*/
|
||||
class _ProfileTable extends Table
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url Base URL
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL )
|
||||
{
|
||||
parent::__construct( $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @param array $advancedSearchValues Values from the advanced search form
|
||||
* @return array
|
||||
*/
|
||||
public function getRows( $advancedSearchValues )
|
||||
{
|
||||
$rows = parent::getRows( $advancedSearchValues );
|
||||
|
||||
$return = array();
|
||||
foreach( $rows AS $row )
|
||||
{
|
||||
if ( $row->owner() instanceof \IPS\Member )
|
||||
{
|
||||
$return['owner'][ $row->id ] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['contributor'][ $row->id ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Table Helper
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 18 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Blog;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blog Table Helper
|
||||
*/
|
||||
class _Table extends \IPS\Helpers\Table\Table
|
||||
{
|
||||
/**
|
||||
* @brief Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url Base URL
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL )
|
||||
{
|
||||
/* Init */
|
||||
parent::__construct( $url );
|
||||
$this->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'blog' ), 'rows' );
|
||||
|
||||
/* Set available sort options */
|
||||
foreach ( array( 'last_edate', 'rating_total', 'num_views' ) as $k )
|
||||
{
|
||||
$this->sortOptions[ $k ] = 'blog_' . $k;
|
||||
}
|
||||
|
||||
if ( !$this->sortBy )
|
||||
{
|
||||
$this->sortBy = 'blog_last_edate';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set owner
|
||||
*
|
||||
* @param \IPS\Member $member The member to filter by
|
||||
* @return void
|
||||
*/
|
||||
public function setOwner( \IPS\Member $member )
|
||||
{
|
||||
$this->where[] = array( '(' . \IPS\Db::i()->findInSet( 'blog_groupblog_ids', $member->groups ) . ' OR ' . 'blog_member_id=? )', $member->member_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @param array $advancedSearchValues Values from the advanced search form
|
||||
* @return array
|
||||
*/
|
||||
public function getRows( $advancedSearchValues )
|
||||
{
|
||||
/* Init */
|
||||
$class = "IPS\\blog\\Blog";
|
||||
$subquery = NULL;
|
||||
|
||||
/* Check sortBy */
|
||||
$this->sortBy = in_array( $this->sortBy, $this->sortOptions ) ? $this->sortBy : 'blog_name';
|
||||
|
||||
/* What are we sorting by? */
|
||||
$sortBy = 'blog_pinned DESC, ' . $this->sortBy . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
|
||||
|
||||
/* Specify filter in where clause */
|
||||
$where = isset( $this->where ) ? is_array( $this->where ) ? $this->where : array( $this->where ) : array();
|
||||
$where[] = array( 'blog_disabled=0' );
|
||||
if ( $this->filter and isset( $this->filters[ $this->filter ] ) )
|
||||
{
|
||||
$where[] = is_array( $this->filters[ $this->filter ] ) ? $this->filters[ $this->filter ] : array( $this->filters[ $this->filter ] );
|
||||
}
|
||||
|
||||
/* Exclude private blogs unless we have permission to view them */
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$where[] = array( '( blog_social_group IS NULL OR blog_member_id=? OR blog_social_group IN(?) )', \IPS\Member::loggedIn()->member_id, \IPS\Db::i()->select( 'group_id', 'core_sys_social_group_members', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'blog_social_group IS NULL' );
|
||||
}
|
||||
|
||||
/* Get Count */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*) as cnt', 'blog_blogs', $where )->first();
|
||||
$this->pages = ceil( $count / $this->limit );
|
||||
|
||||
/* Get results */
|
||||
$it = \IPS\Db::i()->select( '*', 'blog_blogs', $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ) );
|
||||
$rows = iterator_to_array( $it );
|
||||
|
||||
foreach( $rows as $index => $row )
|
||||
{
|
||||
$rows[ $index ] = \IPS\blog\Blog::constructFromData( $row );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table headers
|
||||
*
|
||||
* @param array|NULL $advancedSearchValues Advanced search values
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders( $advancedSearchValues )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Blog Entry Comment Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog\Entry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\blog\Entry';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'blog_comments';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'comment_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'item' => 'entry_id',
|
||||
'author' => 'member_id',
|
||||
'author_name' => 'member_name',
|
||||
'content' => 'text',
|
||||
'date' => 'date',
|
||||
'ip_address' => 'ip_address',
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_member_name',
|
||||
'edit_show' => 'edit_show',
|
||||
'approved' => 'approved'
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'blog';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'blog_entry_comment';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'file-text-o';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'comment_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'blog-entries';
|
||||
|
||||
/**
|
||||
* Get items with permisison check
|
||||
*
|
||||
* @param array $where Where clause
|
||||
* @param string $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array $limit Limit clause
|
||||
* @param string $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index
|
||||
* @param bool|NULL $includeHiddenItems Include hidden files? Boolean or NULL to detect if currently logged member has permission
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinComments If true, will join comment data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinReviews If true, will join review data (set to TRUE if your $where clause depends on this data)
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
*/
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=NULL, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL )
|
||||
{
|
||||
if ( in_array( $permissionKey, array( 'view', 'read' ) ) )
|
||||
{
|
||||
$joinContainer = TRUE;
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
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 ) . ' ) )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( "(" . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . " OR blog_blogs.blog_social_group IS NULL )" );
|
||||
}
|
||||
}
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Moderator Permission
|
||||
*
|
||||
* @param string $type 'edit', 'hide', 'unhide', 'delete', etc.
|
||||
* @param \IPS\Member|NULL $member The member to check for or NULL for the currently logged in member
|
||||
* @param \IPS\Node\Model|NULL $container The container
|
||||
* @return bool
|
||||
*/
|
||||
public static function modPermission( $type, \IPS\Member $member = NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
if ( in_array( $type, array( 'edit', 'delete', 'lock' ) ) and $container and $container->member_id === $member->member_id )
|
||||
{
|
||||
return $member->group['g_blog_allowownmod'];
|
||||
}
|
||||
|
||||
return parent::modPermission( $type, $member, $container );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,597 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Entry Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Blog
|
||||
* @since 3 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\blog;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry Model
|
||||
*/
|
||||
class _Entry extends \IPS\Content\Item implements
|
||||
\IPS\Content\Pinnable, \IPS\Content\Lockable, \IPS\Content\Hideable, \IPS\Content\Featurable,
|
||||
\IPS\Content\Tags,
|
||||
\IPS\Content\Followable,
|
||||
\IPS\Content\Shareable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\ReadMarkers,
|
||||
\IPS\Content\Views,
|
||||
\IPS\Content\Polls,
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\EditHistory,
|
||||
\IPS\Content\Reputation,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\FuturePublishing
|
||||
{
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'blog';
|
||||
|
||||
/**
|
||||
* @brief Module
|
||||
*/
|
||||
public static $module = 'blogs';
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
public static $databaseTable = 'blog_entries';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'entry_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'author' => 'author_id',
|
||||
'author_name' => 'author_name',
|
||||
'content' => 'content',
|
||||
'container' => 'blog_id',
|
||||
'date' => 'date',
|
||||
'updated' => 'last_update',
|
||||
'title' => 'name',
|
||||
'num_comments' => 'num_comments',
|
||||
'unapproved_comments' => 'queued_comments',
|
||||
'hidden_comments' => 'hidden_comments',
|
||||
'last_comment_by' => 'last_comment_mid',
|
||||
'last_comment' => 'last_update', // Same as updated above
|
||||
'views' => 'views',
|
||||
'approved' => 'hidden',
|
||||
'pinned' => 'pinned',
|
||||
'poll' => 'poll_state',
|
||||
'featured' => 'featured',
|
||||
'ip_address' => 'ip_address',
|
||||
'locked' => 'locked',
|
||||
'cover_photo' => 'cover_photo',
|
||||
'cover_photo_offset' => 'cover_offset',
|
||||
'is_future_entry' => 'is_future_entry',
|
||||
'future_date' => 'publish_date'
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'blog_entry';
|
||||
|
||||
/**
|
||||
* @brief Node Class
|
||||
*/
|
||||
public static $containerNodeClass = 'IPS\blog\Blog';
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] Comment Class
|
||||
*/
|
||||
public static $commentClass = 'IPS\blog\Entry\Comment';
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] First "comment" is part of the item?
|
||||
*/
|
||||
public static $firstCommentRequired = FALSE;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Language prefix for forms
|
||||
*/
|
||||
public static $formLangPrefix = 'blog_entry_';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'file-text-o';
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'read' => 2,
|
||||
'add' => 3,
|
||||
'reply' => 4,
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'entry_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'blog-entry';
|
||||
|
||||
/**
|
||||
* Set the title
|
||||
*
|
||||
* @param string $title Title
|
||||
* @return void
|
||||
*/
|
||||
public function set_name( $name )
|
||||
{
|
||||
$this->_data['name'] = $name;
|
||||
$this->_data['name_seo'] = \IPS\Http\Url::seoTitle( $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SEO name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name_seo()
|
||||
{
|
||||
if( !$this->_data['name_seo'] )
|
||||
{
|
||||
$this->name_seo = \IPS\Http\Url::seoTitle( $this->name );
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this->_data['name_seo'] ?: \IPS\Http\Url::seoTitle( $this->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the album HTML, if there is one associated
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get__album()
|
||||
{
|
||||
if( \IPS\Application::appIsEnabled( 'gallery' ) AND $this->gallery_album )
|
||||
{
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::loadAndCheckPerms( $this->gallery_album );
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery.css', 'gallery', 'front' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery_responsive.css', 'gallery', 'front' ) );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'browse', 'gallery', 'front' )->miniAlbum( $album );
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
catch( \UnderflowException $e ){}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached URLs
|
||||
*/
|
||||
protected $_url = array();
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
{
|
||||
$_key = md5( $action );
|
||||
|
||||
if( !isset( $this->_url[ $_key ] ) )
|
||||
{
|
||||
$this->_url[ $_key ] = \IPS\Http\Url::internal( "app=blog&module=blogs&controller=entry&id={$this->id}", 'front', 'blog_entry', $this->name_seo );
|
||||
|
||||
if ( $action )
|
||||
{
|
||||
$this->_url[ $_key ] = $this->_url[ $_key ]->setQueryString( 'do', $action );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_url[ $_key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Can view this entry
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member or NULL for currently logged in member.
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
$return = parent::canView( $member );
|
||||
|
||||
if ( $this->status == 'draft' AND !static::canViewHiddenItems( $member, $this->container() ) AND !in_array( $this->container()->id, array_keys( \IPS\blog\Blog::loadByOwner( $member ) ) ) )
|
||||
{
|
||||
$return = FALSE;
|
||||
}
|
||||
|
||||
/* Is this a future publish entry and we are the owner of the blog? */
|
||||
if ( $this->status == 'draft' AND $this->is_future_entry == 1 AND in_array( $this->container()->id, array_keys( \IPS\blog\Blog::loadByOwner( $member ) ) ) )
|
||||
{
|
||||
$return = TRUE;
|
||||
}
|
||||
|
||||
/* Private blog */
|
||||
if( $this->container()->social_group != 0 AND $this->container()->owner() != $member )
|
||||
{
|
||||
/* This will throw an exception of the row does not exist */
|
||||
try
|
||||
{
|
||||
$member = \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $this->container()->social_group, $member->member_id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get items with permisison check
|
||||
*
|
||||
* @param array $where Where clause
|
||||
* @param string $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array $limit Limit clause
|
||||
* @param string|NULL $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
|
||||
* @param bool|NULL $includeHiddenItems Include hidden files? Boolean or NULL to detect if currently logged member has permission
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinComments If true, will join comment data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinReviews If true, will join review data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $countOnly If true will return the count
|
||||
* @param array|null $joins Additional arbitrary joins for the query
|
||||
* @param mixed $skipPermission If you are getting records from a specific container, pass the container to reduce the number of permission checks necessary or pass TRUE to skip conatiner-based permission. You must still specify this in the $where clause
|
||||
* @param bool $joinTags If true, will join the tags table
|
||||
* @param bool $joinAuthor If true, will join the members table for the author
|
||||
* @param bool $joinLastCommenter If true, will join the members table for the last commenter
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
*/
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=NULL, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE )
|
||||
{
|
||||
if ( in_array( $permissionKey, array( 'view', 'read' ) ) )
|
||||
{
|
||||
$joinContainer = TRUE;
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
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 )' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( "(" . \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', $member ) . " OR blog_blogs.blog_social_group IS NULL )" );
|
||||
}
|
||||
}
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional WHERE clauses for New Content view
|
||||
*
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param array $joins Other joins
|
||||
* @return array
|
||||
*/
|
||||
public static function vncWhere( &$joinContainer, &$joins )
|
||||
{
|
||||
$joinContainer = TRUE;
|
||||
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() ) . ' ) )' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( \IPS\Content::socialGroupGetItemsWithPermissionWhere( 'blog_blogs.blog_social_group', \IPS\Member::loggedIn() ) );
|
||||
}
|
||||
|
||||
return array_merge( parent::vncWhere( $joinContainer, $joins ), $where );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elements for add/edit form
|
||||
*
|
||||
* @param \IPS\Content\Item|NULL $item The current item if editing or NULL if creating
|
||||
* @param int $container Container (e.g. forum) ID, if appropriate
|
||||
* @return array
|
||||
*/
|
||||
public static function formElements( $item=NULL, \IPS\Node\Model $container=NULL )
|
||||
{
|
||||
$return = parent::formElements( $item, $container );
|
||||
$return['entry'] = new \IPS\Helpers\Form\Editor( 'blog_entry_content', $item ? $item->content : NULL, TRUE, array( 'app' => 'blog', 'key' => 'Entries', 'autoSaveKey' => 'blog-entry-' . $container->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id ) ) ) );
|
||||
|
||||
/* Gallery album association */
|
||||
if( \IPS\Application::appIsEnabled( 'gallery' ) )
|
||||
{
|
||||
$return['album'] = new \IPS\Helpers\Form\Node( 'entry_gallery_album', ( $item AND $item->gallery_album ) ? $item->gallery_album : NULL, FALSE, array(
|
||||
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
|
||||
'class' => 'IPS\gallery\Album',
|
||||
'permissionCheck' => 'add',
|
||||
) );
|
||||
}
|
||||
|
||||
$return['publish'] = new \IPS\Helpers\Form\YesNo( 'blog_entry_publish', $item ? $item->status : TRUE, FALSE, array( 'togglesOn' => array( 'blog_entry_date' ) ) );
|
||||
|
||||
/* Publish date needs to go near the bottom */
|
||||
$date = NULL;
|
||||
if ( isset( $return['date'] ) )
|
||||
{
|
||||
$date = $return['date'];
|
||||
unset( $return['date'] );
|
||||
|
||||
$return['date'] = $date;
|
||||
}
|
||||
|
||||
/* Poll always needs to go on the end */
|
||||
$poll = NULL;
|
||||
if ( isset( $return['poll'] ) )
|
||||
{
|
||||
$poll = $return['poll'];
|
||||
unset( $return['poll'] );
|
||||
|
||||
$return['poll'] = $poll;
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process create/edit form
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
public function processForm( $values )
|
||||
{
|
||||
parent::processForm( $values );
|
||||
|
||||
if ( !$this->_new )
|
||||
{
|
||||
$oldContent = $this->content;
|
||||
}
|
||||
$this->content = $values['blog_entry_content'];
|
||||
if ( !$this->_new )
|
||||
{
|
||||
$this->sendAfterEditNotifications( $oldContent );
|
||||
}
|
||||
|
||||
$this->status = $values['blog_entry_publish'] ? 'published' : 'draft';
|
||||
|
||||
if ( isset( $values['blog_entry_date'] ) )
|
||||
{
|
||||
$this->date = ( $values['blog_entry_date'] AND $values['blog_entry_publish'] ) ? $values['blog_entry_date']->getTimestamp() : time();
|
||||
}
|
||||
|
||||
/* Gallery album association */
|
||||
if( \IPS\Application::appIsEnabled( 'gallery' ) AND $values['entry_gallery_album'] instanceof \IPS\gallery\Album )
|
||||
{
|
||||
$this->gallery_album = $values['entry_gallery_album']->_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->gallery_album = NULL;
|
||||
}
|
||||
|
||||
if ( $this->date > time() )
|
||||
{
|
||||
$this->status = 'draft';
|
||||
}
|
||||
|
||||
/* Ping */
|
||||
$this->container()->ping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a given member create this type of content?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Node\Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @return bool
|
||||
*/
|
||||
public static function canCreate( \IPS\Member $member, \IPS\Node\Model $container=NULL, $showError=FALSE )
|
||||
{
|
||||
parent::canCreate( $member, $container, $showError );
|
||||
|
||||
$return = TRUE;
|
||||
|
||||
$blogs = \IPS\blog\Blog::loadByOwner( $member );
|
||||
|
||||
if ( $container )
|
||||
{
|
||||
if ( !in_array( $container->id, array_keys( $blogs ) ) )
|
||||
{
|
||||
$return = FALSE;
|
||||
$error = 'no_module_permission';
|
||||
}
|
||||
|
||||
if ( $container->disabled )
|
||||
{
|
||||
$return = FALSE;
|
||||
$error = 'no_module_permission';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !count( $blogs ) )
|
||||
{
|
||||
$return = FALSE;
|
||||
$error = 'no_module_permission';
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
if ( $showError and !$return )
|
||||
{
|
||||
\IPS\Output::i()->error( $error, '1B203/1', 403, '' );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process created object AFTER the object has been created
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The first comment
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processAfterCreate( $comment, $values )
|
||||
{
|
||||
parent::processAfterCreate( $comment, $values );
|
||||
|
||||
\IPS\File::claimAttachments( 'blog-entry-' . $this->container()->id, $this->id );
|
||||
|
||||
if ( $this->status == 'published' )
|
||||
{
|
||||
$blog = $this->container();
|
||||
$lastUpdateColumn = $blog::$databaseColumnMap['date'];
|
||||
$blog->$lastUpdateColumn = time();
|
||||
$blog->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncing to run when publishing something previously pending publishing
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onPublish()
|
||||
{
|
||||
$this->status = 'published';
|
||||
$this->save();
|
||||
|
||||
parent::onPublish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncing to run when unpublishing an item (making it a future dated entry when it was already published)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onUnpublish()
|
||||
{
|
||||
$this->status = 'draft';
|
||||
$this->save();
|
||||
|
||||
parent::onUnpublish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can comment?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canComment( $member=NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return parent::canComment( $member ) and $member->group['g_blog_allowcomment'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Can set items to be published in the future?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param \IPS\Node\Model|null $container Container
|
||||
* @return bool
|
||||
*/
|
||||
public static function canFuturePublish( $member=NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return (boolean) $member->member_id > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Moderator Permission
|
||||
*
|
||||
* @param string $type 'edit', 'hide', 'unhide', 'delete', etc.
|
||||
* @param \IPS\Member|NULL $member The member to check for or NULL for the currently logged in member
|
||||
* @param \IPS\Node\Model|NULL $container The container
|
||||
* @return bool
|
||||
*/
|
||||
public static function modPermission( $type, \IPS\Member $member = NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$result = parent::modPermission( $type, $member, $container );
|
||||
|
||||
if ( $result !== TRUE )
|
||||
{
|
||||
if ( in_array( $type, array( 'edit', 'delete', 'lock', 'unlock' ) ) and $container and $container->member_id === $member->member_id )
|
||||
{
|
||||
$result = $member->group['g_blog_allowownmod'];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for content tables
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'blog' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Index Permissions
|
||||
*
|
||||
* @return string Comma-delimited values or '*'
|
||||
* @li Number indicates a group
|
||||
* @li Number prepended by "m" indicates a member
|
||||
* @li Number prepended by "s" indicates a social group
|
||||
*/
|
||||
public function searchIndexPermissions()
|
||||
{
|
||||
if ( $this->status == 'draft' )
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
|
||||
return parent::searchIndexPermissions();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user