Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+93 -15
View File
@@ -2,9 +2,9 @@
/**
* @brief Entry Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Blog
* @since 3 Mar 2014
* @version SVN_VERSION_NUMBER
@@ -89,7 +89,8 @@ class _Entry extends \IPS\Content\Item implements
'cover_photo' => 'cover_photo',
'cover_photo_offset' => 'cover_offset',
'is_future_entry' => 'is_future_entry',
'future_date' => 'publish_date'
'future_date' => 'publish_date',
'status' => 'status',
);
/**
@@ -151,7 +152,7 @@ class _Entry extends \IPS\Content\Item implements
public function set_name( $name )
{
$this->_data['name'] = $name;
$this->_data['name_seo'] = \IPS\Http\Url::seoTitle( $name );
$this->_data['name_seo'] = \IPS\Http\Url\Friendly::seoTitle( $name );
}
/**
@@ -163,11 +164,11 @@ class _Entry extends \IPS\Content\Item implements
{
if( !$this->_data['name_seo'] )
{
$this->name_seo = \IPS\Http\Url::seoTitle( $this->name );
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( $this->name );
$this->save();
}
return $this->_data['name_seo'] ?: \IPS\Http\Url::seoTitle( $this->name );
return $this->_data['name_seo'] ?: \IPS\Http\Url\Friendly::seoTitle( $this->name );
}
/**
@@ -248,6 +249,11 @@ class _Entry extends \IPS\Content\Item implements
/* This will throw an exception of the row does not exist */
try
{
if( !$member->member_id )
{
return FALSE;
}
$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 )
@@ -266,7 +272,7 @@ class _Entry extends \IPS\Content\Item implements
* @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 mixed $includeHiddenItems Include hidden items? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
* @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)
@@ -278,9 +284,10 @@ class _Entry extends \IPS\Content\Item implements
* @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
* @param bool $showMovedLinks If true, moved item links are included in the results
* @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 )
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=\IPS\Content\Hideable::FILTER_AUTOMATIC, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE, $showMovedLinks=FALSE )
{
if ( in_array( $permissionKey, array( 'view', 'read' ) ) )
{
@@ -295,7 +302,7 @@ class _Entry extends \IPS\Content\Item implements
$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 );
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
}
/**
@@ -330,7 +337,7 @@ class _Entry extends \IPS\Content\Item implements
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 ) ) ) );
$return['entry'] = new \IPS\Helpers\Form\Editor( 'blog_entry_content', $item ? $item->content : NULL, TRUE, array( 'app' => 'blog', 'key' => 'Entries', 'autoSaveKey' => ( $item === NULL ) ? 'blog-entry-' . $container->id : 'blog-edit-' . $item->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id ) ) ) );
/* Gallery album association */
if( \IPS\Application::appIsEnabled( 'gallery' ) )
@@ -483,31 +490,43 @@ class _Entry extends \IPS\Content\Item implements
$blog->save();
}
}
/**
* Syncing to run when publishing something previously pending publishing
*
* @param \IPS\Member|NULL|FALSE $member The member doing the action (NULL for currently logged in member, FALSE for no member)
* @return void
*/
public function onPublish()
public function onPublish( $member )
{
$this->status = 'published';
$this->save();
parent::onPublish();
parent::onPublish( $member );
/* The blog system is slightly different from the \Content future entry stuff. Future entries are treated as drafts,
so do count towards entries but parent::onPublish will try and increment item count again after publish */
$this->container()->resetCommentCounts();
$this->container()->save();
}
/**
* Syncing to run when unpublishing an item (making it a future dated entry when it was already published)
*
* @param \IPS\Member|NULL|FALSE $member The member doing the action (NULL for currently logged in member, FALSE for no member)
* @return void
*/
public function onUnpublish()
public function onUnpublish( $member )
{
$this->status = 'draft';
$this->save();
parent::onUnpublish();
parent::onUnpublish( $member );
/* The blog system is slightly different from the \Content future entry stuff. Future entries are treated as drafts,
so do count towards entries but parent::onUnpublish will try and decrement item count after unpublish */
$this->container()->resetCommentCounts();
$this->container()->save();
}
/**
@@ -586,4 +605,63 @@ class _Entry extends \IPS\Content\Item implements
return parent::searchIndexPermissions();
}
/**
* WHERE clause for getting items for sitemap (permissions are already accounted for)
*
* @return array
*/
public static function sitemapWhere()
{
return array( array( 'blog_entries.entry_is_future_entry=0 AND blog_entries.entry_status!=?', 'draft' ) );
}
/**
* Get output for API
*
* @return array
* @apiresponse int id ID number
* @apiresponse string title Title
* @apiresponse \IPS\blog\Blog blog Blog
* @apiresponse \IPS\Member author The member that created the entry
* @apiresponse bool draft If this entry is a draft
* @apiresponse datetime date Date
* @apiresponse string entry Entry content
* @apiresponse int comments Number of comments
* @apiresponse int views Number of posts
* @apiresponse string prefix The prefix tag, if there is one
* @apiresponse [string] tags The tags
* @apiresponse bool locked Entry is locked
* @apiresponse bool hidden Entry is hidden
* @apiresponse bool future Will be published at a future date?
* @apiresponse bool pinned Entry is pinned
* @apiresponse bool featured Entry is featured
* @apiresponse \IPS\Poll poll Poll data, if there is one
* @apiresponse string url URL
* @apiresponse float rating Average Rating
*/
public function apiOutput()
{
return array(
'id' => $this->id,
'title' => $this->name,
'blog' => $this->container()->apiOutput(),
'author' => $this->author()->apiOutput(),
'draft' => $this->status == 'draft',
'date' => \IPS\DateTime::ts( $this->date )->rfc3339(),
'entry' => $this->content(),
'comments' => $this->num_comments,
'views' => $this->views,
'prefix' => $this->prefix(),
'tags' => $this->tags(),
'locked' => (bool) $this->locked(),
'hidden' => (bool) $this->hidden(),
'future' => $this->isFutureDate(),
'pinned' => (bool) $this->mapped('pinned'),
'featured' => (bool) $this->mapped('featured'),
'poll' => $this->poll_state ? \IPS\Poll::load( $this->poll_state )->apiOutput() : null,
'url' => (string) $this->url(),
'rating' => $this->averageRating(),
);
}
}