Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -26,7 +26,6 @@ class _Entry extends \IPS\Content\Item implements
|
||||
\IPS\Content\Tags,
|
||||
\IPS\Content\Followable,
|
||||
\IPS\Content\Shareable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\ReadMarkers,
|
||||
\IPS\Content\Views,
|
||||
\IPS\Content\Polls,
|
||||
@@ -37,7 +36,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
\IPS\Content\FuturePublishing,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
@@ -140,6 +139,16 @@ class _Entry extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static $hideLogKey = 'blog-entry';
|
||||
|
||||
/**
|
||||
* @brief [CoverPhoto] Storage extension
|
||||
*/
|
||||
public static $coverPhotoStorageExtension = 'blog_Entries';
|
||||
|
||||
/**
|
||||
* @brief Use a default cover photo
|
||||
*/
|
||||
public static $coverPhotoDefault = true;
|
||||
|
||||
/**
|
||||
* Set the title
|
||||
*
|
||||
@@ -298,17 +307,29 @@ class _Entry extends \IPS\Content\Item implements
|
||||
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 )' );
|
||||
$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' );
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->clubs )
|
||||
{
|
||||
$joins[] = array( 'from' => 'core_clubs', 'where' => 'core_clubs.id=blog_blogs.blog_club_id' );
|
||||
if ( $member->member_id )
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', $member->clubs() ) . ' OR core_clubs.type=? OR core_clubs.type=? )', \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_READONLY );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR core_clubs.type=? OR core_clubs.type=? )', \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_READONLY );
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
|
||||
}
|
||||
@@ -326,12 +347,23 @@ 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' );
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->clubs )
|
||||
{
|
||||
$joins[] = array( 'from' => 'core_clubs', 'where' => 'core_clubs.id=blog_blogs.blog_club_id' );
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR ' . \IPS\Db::i()->in( 'blog_blogs.blog_club_id', \IPS\Member::loggedIn()->clubs() ) . ' OR core_clubs.type=? OR core_clubs.type=? )', \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_READONLY );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( '( blog_blogs.blog_club_id IS NULL OR core_clubs.type=? OR core_clubs.type=? )', \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_READONLY );
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge( parent::followWhere( $joinContainer, $joins ), $where );
|
||||
@@ -358,6 +390,8 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'permissionCheck' => 'add',
|
||||
) );
|
||||
}
|
||||
|
||||
$return['image'] = new \IPS\Helpers\Form\Upload( 'blog_entry_cover_photo', ( ( $item AND $item->cover_photo ) ? \IPS\File::get( 'blog_Entries', $item->cover_photo ) : NULL ), FALSE, array( 'storageExtension' => 'blog_Entries', 'image' => array( 'maxWidth' => 4800, 'maxHeight' => 4800 ) ) );
|
||||
|
||||
$return['publish'] = new \IPS\Helpers\Form\YesNo( 'blog_entry_publish', $item ? $item->status : TRUE, FALSE, array( 'togglesOn' => array( 'blog_entry_date' ) ) );
|
||||
|
||||
@@ -411,6 +445,8 @@ class _Entry extends \IPS\Content\Item implements
|
||||
{
|
||||
$this->date = ( $values['blog_entry_date'] AND $values['blog_entry_publish'] ) ? $values['blog_entry_date']->getTimestamp() : time();
|
||||
}
|
||||
|
||||
$this->cover_photo = (string) $values['blog_entry_cover_photo'];
|
||||
|
||||
/* Gallery album association */
|
||||
if( \IPS\Application::appIsEnabled( 'gallery' ) AND $values['entry_gallery_album'] instanceof \IPS\gallery\Album )
|
||||
@@ -600,7 +636,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'blog' ), 'rows' );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'blog', 'front' ), 'rows' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -634,6 +670,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string title Title
|
||||
@@ -655,13 +692,13 @@ class _Entry extends \IPS\Content\Item implements
|
||||
* @apiresponse string url URL
|
||||
* @apiresponse float rating Average Rating
|
||||
*/
|
||||
public function apiOutput()
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'title' => $this->name,
|
||||
'blog' => $this->container()->apiOutput(),
|
||||
'author' => $this->author()->apiOutput(),
|
||||
'blog' => $this->container()->apiOutput( $authorizedMember ),
|
||||
'author' => $this->author()->apiOutput( $authorizedMember ),
|
||||
'draft' => $this->status == 'draft',
|
||||
'date' => \IPS\DateTime::ts( $this->date )->rfc3339(),
|
||||
'entry' => $this->content(),
|
||||
@@ -674,7 +711,7 @@ class _Entry extends \IPS\Content\Item implements
|
||||
'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,
|
||||
'poll' => $this->poll_state ? \IPS\Poll::load( $this->poll_state )->apiOutput( $authorizedMember ) : null,
|
||||
'url' => (string) $this->url(),
|
||||
'rating' => $this->averageRating(),
|
||||
);
|
||||
@@ -706,7 +743,6 @@ class _Entry extends \IPS\Content\Item implements
|
||||
* @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 )
|
||||
{
|
||||
@@ -770,6 +806,37 @@ class _Entry extends \IPS\Content\Item implements
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the content images
|
||||
*
|
||||
* @param int|null $limit Number of attachments to fetch, or NULL for all
|
||||
*
|
||||
* @return array|NULL
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function contentImages( $limit = NULL )
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$internal = NULL;
|
||||
$attachments = array();
|
||||
|
||||
if ( isset( static::$databaseColumnMap['content'] ) )
|
||||
{
|
||||
$internal = \IPS\Db::i()->select( 'attachment_id', 'core_attachments_map', array( 'location_key=? and id1=?', 'blog_Entries', $this->$idColumn ) );
|
||||
}
|
||||
|
||||
if ( $internal )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments', array( array( 'attach_id IN(?)', $internal ), array( 'attach_is_image=1' ) ), 'attach_id ASC', $limit ) as $row )
|
||||
{
|
||||
$attachments[] = array( 'core_Attachment' => $row['attach_location'] );
|
||||
}
|
||||
}
|
||||
|
||||
return count( $attachments ) ? $attachments : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
|
||||
Reference in new issue
Block a user