Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+31 -3
View File
@@ -33,12 +33,14 @@ class _blogs extends \IPS\Node\Api\NodeController
* GET /blog/blogs
* Get list of blogs
*
* @note For requests using an OAuth Access Token for a particular member, only blogs that are not disabled and not belonging to a particular club or social group will be included
* @apiparam string owners Comma-delimited list of member IDs - if provided, only blogs owned by those members are returned (can be used in conjection with groups or set to 0 to exclude member-created blogs)
* @apiparam string groups Comma-delimited list of group IDs - if provided, only blogs owned by those groups are returned (can be used in conjection with members or set to 0 to exclude group blogs)
* @apiparam int pinned If 1, only blogs which are pinned are returned, if 0 only not pinned
* @apiparam string sortBy What to sort by. Can be 'count_entries' for number of entries, 'last_edate' for last entry date or do not specify for ID
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @return \IPS\Api\PaginatedResponse<IPS\blog\Entry>
*/
public function GETindex()
@@ -65,6 +67,12 @@ class _blogs extends \IPS\Node\Api\NodeController
{
$where[] = array( 'blog_pinned=?', intval( \IPS\Request::i()->pinned ) );
}
/* Permission */
if ( $this->member )
{
$where[] = array( 'blog_disabled=0 AND blog_social_group IS NULL AND blog_club_id IS NULL' );
}
/* Sort */
if ( isset( \IPS\Request::i()->sortBy ) and in_array( \IPS\Request::i()->sortBy, array( 'count_entries', 'last_edate' ) ) )
@@ -83,7 +91,9 @@ class _blogs extends \IPS\Node\Api\NodeController
\IPS\Db::i()->select( '*', 'blog_blogs', $where, "{$sortBy} {$sortDir}" ),
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
'IPS\blog\Blog',
\IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', $where )->first()
\IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', $where )->first(),
$this->member,
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
);
}
@@ -92,7 +102,7 @@ class _blogs extends \IPS\Node\Api\NodeController
* Get information about a specific blog
*
* @param int $id ID Number
* @throws 2B302/1 INVALID_ID The blog ID does not exist
* @throws 2B302/1 INVALID_ID The blog ID does not exist or the authorized user does not have permission to view it
* @return \IPS\blog\Blog
*/
public function GETitem( $id )
@@ -106,9 +116,27 @@ class _blogs extends \IPS\Node\Api\NodeController
*
* @param int $id ID Number
* @return void
* @throws 2B302/2 INVALID_ID The blog ID does not exist or the authorized user does not have permission to view it
* @throws 2B302/3 NO_PERMISSION The authorized user does not have permission to delete the blog
*/
public function DELETEitem( $id )
{
return $this->_delete( $id );
$class = $this->class;
try
{
$blog = $this->member ? $class::loadAndCheckPerms( $id ) : $class::load( $id );
if ( !$blog->canDelete( $this->member ) )
{
throw new \IPS\Api\Exception( 'INVALID_ID', '2B302/3', 404 );
}
$blog->delete();
return new \IPS\Api\Response( 200, NULL );
}
catch ( \OutOfRangeException $e )
{
throw new \IPS\Api\Exception( 'INVALID_ID', '2B302/2', 404 );
}
}
}
+67 -22
View File
@@ -30,18 +30,19 @@ class _comments extends \IPS\Content\Api\CommentController
/**
* GET /blog/comments
* Get list of comments
*
* @apiparam string blogs Comma-delimited list of calendar IDs
* @note For requests using an OAuth Access Token for a particular member, only comments the authorized user can view will be included, and all comments on draft entries are excluded
* @apiparam string blogs Comma-delimited list of blog IDs
* @apiparam string authors Comma-delimited list of member IDs - if provided, only topics started by those members are returned
* @apiparam int locked If 1, only comments from entries which are locked are returned, if 0 only unlocked
* @apiparam int hidden If 1, only comments which are hidden are returned, if 0 only not hidden
* @apiparam int pinned If 1, only posts from topics which are pinned are returned, if 0 only not pinned
* @apiparam int featured If 1, only comments from entries which are featured are returned, if 0 only not featured
* @apiparam int draft If 1, only draft entries are returned, if 0 only published
* @apiparam int draft If 1, only draft entries are returned, if 0 only published. Ignored for requests using an OAuth Access Token for a particular member
* @apiparam string sortBy What to sort by. Can be 'date', 'title' or leave unspecified for ID
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @return \IPS\Api\PaginatedResponse<IPS\blog\Entry\Comment>
*/
public function GETindex()
@@ -50,7 +51,11 @@ class _comments extends \IPS\Content\Api\CommentController
$where = array();
/* Draft */
if ( isset( \IPS\Request::i()->draft ) )
if ( $this->member )
{
$where[] = array( 'entry_status=?', 'published' );
}
elseif ( isset( \IPS\Request::i()->draft ) )
{
$where[] = array( 'entry_status=?', \IPS\Request::i()->draft ? 'draft' : 'published' );
}
@@ -64,14 +69,24 @@ class _comments extends \IPS\Content\Api\CommentController
* View information about a specific comment
*
* @param int $id ID Number
* @throws 2B301/1 INVALID_ID The comment ID does not exist
* @throws 2B301/1 INVALID_ID The comment ID does not exist or the authorized user does not have permission to view it
* @return \IPS\blog\Entry\Comment
*/
public function GETitem( $id )
{
try
{
return new \IPS\Api\Response( 200, \IPS\blog\Entry\Comment::load( $id )->apiOutput() );
$class = $this->class;
if ( $this->member )
{
$object = $class::loadAndCheckPerms( $id, $this->member );
}
else
{
$object = $class::load( $id );
}
return new \IPS\Api\Response( 200, $object->apiOutput( $this->member ) );
}
catch ( \OutOfRangeException $e )
{
@@ -83,21 +98,23 @@ class _comments extends \IPS\Content\Api\CommentController
* POST /blog/comments
* Create a comment
*
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, hidden will only be honoured if the authentictaed user has permission to hide content).
* @reqapiparam int entry The ID number of the entry the comment is for
* @reqapiparam int author The ID number of the member making the comment (0 for guest)
* @reqapiparam int author The ID number of the member making the comment (0 for guest). Required for requests made using an API Key or the Client Credentials Grant Type. For requests using an OAuth Access Token for a particular member, that member will always be the author
* @apiparam string author_name If author is 0, the guest name that should be used
* @reqapiparam string content The comment content as HTML (e.g. "<p>This is a comment.</p>")
* @apiparam datetime date The date/time that should be used for the comment date. If not provided, will use the current date/time
* @apiparam string ip_address The IP address that should be stored for the comment. If not provided, will use the IP address from the API request
* @reqapiparam string content The comment content as HTML (e.g. "<p>This is a comment.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
* @apiparam datetime date The date/time that should be used for the comment date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member
* @apiparam string ip_address The IP address that should be stored for the comment. If not provided, will use the IP address from the API request. Ignored for requests using an OAuth Access Token for a particular member
* @apiparam int hidden 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
* @throws 2B301/2 INVALID_ID The comment ID does not exist
* @throws 1B301/3 NO_AUTHOR The author ID does not exist
* @throws 1B301/4 NO_CONTENT No content was supplied
* @throws 2B301/8 NO_PERMISSION The authorized user does not have permission to comment on that blog entry
* @return \IPS\blog\Entry\Comment
*/
public function POSTindex()
{
/* Get topic */
/* Get entry */
try
{
$entry = \IPS\blog\Entry::load( \IPS\Request::i()->entry );
@@ -108,18 +125,29 @@ class _comments extends \IPS\Content\Api\CommentController
}
/* Get author */
if ( \IPS\Request::i()->author )
if ( $this->member )
{
$author = \IPS\Member::load( \IPS\Request::i()->author );
if ( !$author->member_id )
if ( !$entry->canComment( $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1B301/3', 404 );
throw new \IPS\Api\Exception( 'NO_PERMISSION', '2B301/8', 403 );
}
$author = $this->member;
}
else
{
$author = new \IPS\Member;
$author->name = \IPS\Request::i()->author_name;
if ( \IPS\Request::i()->author )
{
$author = \IPS\Member::load( \IPS\Request::i()->author );
if ( !$author->member_id )
{
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1B301/3', 404 );
}
}
else
{
$author = new \IPS\Member;
$author->name = \IPS\Request::i()->author_name;
}
}
/* Check we have a post */
@@ -136,13 +164,15 @@ class _comments extends \IPS\Content\Api\CommentController
* POST /blog/comments/{id}
* Edit a comment
*
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, hidden will only be honoured if the authentictaed user has permission to hide content).
* @param int $id ID Number
* @apiparam int author The ID number of the member making the comment (0 for guest)
* @apiparam int author The ID number of the member making the comment (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
* @apiparam string author_name If author is 0, the guest name that should be used
* @apiparam string content The comment content as HTML (e.g. "<p>This is a comment.</p>")
* @apiparam string content The comment content as HTML (e.g. "<p>This is a comment.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
* @apiparam int hidden 1/0 indicating if the topic should be hidden
* @throws 2B301/5 INVALID_ID The comment ID does not exist
* @throws 2B301/5 INVALID_ID The comment ID does not exist or the authorized user does not have permission to view it
* @throws 1B301/6 NO_AUTHOR The author ID does not exist
* @throws 2B301/9 NO_PERMISSION The authorized user does not have permission to edit the comment
* @return \IPS\blog\Entry\Comment
*/
public function POSTitem( $id )
@@ -151,6 +181,14 @@ class _comments extends \IPS\Content\Api\CommentController
{
/* Load */
$comment = \IPS\blog\Entry\Comment::load( $id );
if ( $this->member and !$comment->canView( $this->member ) )
{
throw new \OutOfRangeException;
}
if ( $this->member and !$comment->canEdit( $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_PERMISSION', '2B301/9', 403 );
}
/* Do it */
try
@@ -173,14 +211,21 @@ class _comments extends \IPS\Content\Api\CommentController
* Deletes a comment
*
* @param int $id ID Number
* @throws 2B301/7 INVALID_ID The comment ID does not exist
* @throws 2B301/7 INVALID_ID The comment ID does not exist
* @throws 2B301/A NO_PERMISSION The authorized user does not have permission to delete the comment
* @return void
*/
public function DELETEitem( $id )
{
try
{
\IPS\blog\Entry\Comment::load( $id )->delete();
$class = $this->class;
$object = $class::load( $id );
if ( $this->member and !$object->canDelete( $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_PERMISSION', '2B301/A', 403 );
}
$object->delete();
return new \IPS\Api\Response( 200, NULL );
}
+76 -28
View File
@@ -32,6 +32,7 @@ class _entries extends \IPS\Content\Api\ItemController
* GET /blog/entries
* Get list of entries
*
* @note For requests using an OAuth Access Token for a particular member, only entries that are published and in blogs that are not disabled and not belonging to a particular club or social group will be included
* @apiparam string blogs Comma-delimited list of blog IDs
* @apiparam string authors Comma-delimited list of member IDs - if provided, only entries started by those members are returned
* @apiparam int locked If 1, only entries which are locked are returned, if 0 only unlocked
@@ -42,6 +43,7 @@ class _entries extends \IPS\Content\Api\ItemController
* @apiparam string sortBy What to sort by. Can be 'date' for creation date, 'title' or leave unspecified for ID
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @return \IPS\Api\PaginatedResponse<IPS\blog\Entry>
*/
public function GETindex()
@@ -49,8 +51,12 @@ class _entries extends \IPS\Content\Api\ItemController
/* Where clause */
$where = array();
/* Draft */
if ( isset( \IPS\Request::i()->draft ) )
/* Permission */
if ( $this->member )
{
$where[] = array( 'entry_status=? AND blog_disabled=0 AND blog_social_group IS NULL AND blog_club_id IS NULL', 'published' );
}
elseif ( isset( \IPS\Request::i()->draft ) )
{
$where[] = array( 'entry_status=?', \IPS\Request::i()->draft ? 'draft' : 'published' );
}
@@ -85,7 +91,8 @@ class _entries extends \IPS\Content\Api\ItemController
*
* @param int $id ID Number
* @apiparam int page Page number
* @throws 2B300/1 INVALID_ID The entry ID does not exist
* @apiparam int perPage Number of results per page - defaults to 25
* @throws 2B300/1 INVALID_ID The entry ID does not exist or the authorized user does not have permission to view it
* @return \IPS\Api\PaginatedResponse<IPS\blog\Entry\Comment>
*/
public function GETitem_comments( $id )
@@ -104,15 +111,16 @@ class _entries extends \IPS\Content\Api\ItemController
* POST /blog/entries
* Create an entry
*
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authentictaed user has permission to lock topics).
* @reqapiparam int blog The ID number of the blog the entry should be created in
* @reqapiparam int author The ID number of the member creating the entry (0 for guest)
* @reqapiparam int author The ID number of the member creating the entry (0 for guest). Required for requests made using an API Key or the Client Credentials Grant Type. For requests using an OAuth Access Token for a particular member, that member will always be the author
* @reqapiparam string title The entry title
* @reqapiparam string entry The entry content as HTML (e.g. "<p>This is a blog entry.</p>")
* @reqapiparam string entry The entry content as HTML (e.g. "<p>This is a blog entry.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
* @apiparam bool draft If this is a draft
* @apiparam string prefix Prefix tag
* @apiparam string tags Comma-separated list of tags (do not include prefix)
* @apiparam datetime date The date/time that should be used for the entry date. If not provided, will use the current date/time
* @apiparam string ip_address The IP address that should be stored for the entry/post. If not provided, will use the IP address from the API request
* @apiparam datetime date The date/time that should be used for the entry date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member
* @apiparam string ip_address The IP address that should be stored for the entry/post. If not provided, will use the IP address from the API request. Ignored for requests using an OAuth Access Token for a particular member
* @apiparam int locked 1/0 indicating if the entry should be locked
* @apiparam int hidden 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
* @apiparam int pinned 1/0 indicating if the entry should be pinned
@@ -121,6 +129,7 @@ class _entries extends \IPS\Content\Api\ItemController
* @throws 1B300/3 NO_AUTHOR The author ID does not exist
* @throws 1B300/4 NO_TITLE No title was supplied
* @throws 1B300/5 NO_CONTENT No content was supplied
* @throws 1B300/A NO_PERMISSION The authorized user does not have permission to create an entry in that blog
* @return \IPS\blog\Entry
*/
public function POSTindex()
@@ -136,17 +145,28 @@ class _entries extends \IPS\Content\Api\ItemController
}
/* Get author */
if ( \IPS\Request::i()->author )
if ( $this->member )
{
$author = \IPS\Member::load( \IPS\Request::i()->author );
if ( !$author->member_id )
if ( !$blog->can( 'add', $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1B300/3', 400 );
throw new \IPS\Api\Exception( 'NO_PERMISSION', '1B300/A', 403 );
}
$author = $this->member;
}
else
{
$author = new \IPS\Member;
if ( \IPS\Request::i()->author )
{
$author = \IPS\Member::load( \IPS\Request::i()->author );
if ( !$author->member_id )
{
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1B300/3', 400 );
}
}
else
{
$author = new \IPS\Member;
}
}
/* Check we have a title and a description */
@@ -160,29 +180,31 @@ class _entries extends \IPS\Content\Api\ItemController
}
/* Do it */
return new \IPS\Api\Response( 201, $this->_create( $blog, $author )->apiOutput() );
return new \IPS\Api\Response( 201, $this->_create( $blog, $author )->apiOutput( $this->member ) );
}
/**
* POST /blog/entries/{id}
* Edit a blog entry
*
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authentictaed user has permission to lock topics).
* @reqapiparam int blog The ID number of the blog the entry should be created in
* @reqapiparam int author The ID number of the member creating the entry (0 for guest)
* @reqapiparam int author The ID number of the member creating the entry (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
* @reqapiparam string title The entry title
* @reqapiparam string entry The entry content as HTML (e.g. "<p>This is a blog entry.</p>")
* @reqapiparam string entry The entry content as HTML (e.g. "<p>This is a blog entry.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
* @apiparam bool draft If this is a draft
* @apiparam string prefix Prefix tag
* @apiparam string tags Comma-separated list of tags (do not include prefix)
* @apiparam datetime date The date/time that should be used for the entry date. If not provided, will use the current date/time
* @apiparam string ip_address The IP address that should be stored for the entry/post. If not provided, will use the IP address from the API request
* @apiparam datetime date The date/time that should be used for the entry date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member.
* @apiparam string ip_address The IP address that should be stored for the entry/post. If not provided, will use the IP address from the API request. Ignored for requests using an OAuth Access Token for a particular member.
* @apiparam int locked 1/0 indicating if the entry should be locked
* @apiparam int hidden 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
* @apiparam int pinned 1/0 indicating if the entry should be pinned
* @apiparam int featured 1/0 indicating if the entry should be featured
* @throws 2B300/6 INVALID_ID The entry ID is invalid
* @throws 1B300/7 NO_BLOG The blog ID does not exist
* @throws 2B300/6 INVALID_ID The entry ID is invalid or the authorized user does not have permission to view it
* @throws 1B300/7 NO_BLOG The blog ID does not exist or the authorized user does not have permission to post in it
* @throws 1B300/8 NO_AUTHOR The author ID does not exist
* @throws 1B300/B NO_PERMISSION The authorized user does not have permission to edit that blog entry
* @return \IPS\blog\Entry
*/
public function POSTitem( $id )
@@ -190,13 +212,26 @@ class _entries extends \IPS\Content\Api\ItemController
try
{
$entry = \IPS\blog\Entry::load( $id );
if ( $this->member and !$entry->can( 'read', $this->member ) )
{
throw new \OutOfRangeException;
}
if ( $this->member and !$entry->canEdit( $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_PERMISSION', '1B300/B', 403 );
}
/* New blog */
if ( isset( \IPS\Request::i()->blog ) and \IPS\Request::i()->blog != $entry->forum_id )
if ( isset( \IPS\Request::i()->blog ) and \IPS\Request::i()->blog != $entry->blog_id and ( !$this->member or $entry->canMove( $this->member ) ) )
{
try
{
$newBlog = \IPS\blog\Blog::load( \IPS\Request::i()->blog );
if ( $this->member and !$newBlog->can( 'add', $this->member ) )
{
throw new \OutOfRangeException;
}
$entry->move( $newBlog );
}
catch ( \OutOfRangeException $e )
@@ -206,7 +241,7 @@ class _entries extends \IPS\Content\Api\ItemController
}
/* New author */
if ( isset( \IPS\Request::i()->author ) )
if ( !$this->member and isset( \IPS\Request::i()->author ) )
{
try
{
@@ -225,11 +260,11 @@ class _entries extends \IPS\Content\Api\ItemController
}
/* Everything else */
$this->_createOrUpdate( $entry );
$this->_createOrUpdate( $entry, 'edit' );
/* Save and return */
$entry->save();
return new \IPS\Api\Response( 200, $entry->apiOutput() );
return new \IPS\Api\Response( 200, $entry->apiOutput( $this->member ) );
}
catch ( \OutOfRangeException $e )
{
@@ -241,9 +276,10 @@ class _entries extends \IPS\Content\Api\ItemController
* Create or update entry
*
* @param \IPS\Content\Item $item The item
* @param string $type add or edit
* @return \IPS\Content\Item
*/
protected function _createOrUpdate( \IPS\Content\Item $item )
protected function _createOrUpdate( \IPS\Content\Item $item, $type='add' )
{
/* Is draft */
if ( isset( \IPS\Request::i()->draft ) )
@@ -254,11 +290,16 @@ class _entries extends \IPS\Content\Api\ItemController
/* Content */
if ( isset( \IPS\Request::i()->entry ) )
{
$item->content = \IPS\Request::i()->entry;
$entryContents = \IPS\Request::i()->entry;
if ( $this->member )
{
$entryContents = \IPS\Text\Parser::parseStatic( $entryContents, TRUE, NULL, $this->member, 'blog_Entries' );
}
$item->content = $entryContents;
}
/* Pass up */
return parent::_createOrUpdate( $item );
return parent::_createOrUpdate( $item, $type );
}
/**
@@ -266,14 +307,21 @@ class _entries extends \IPS\Content\Api\ItemController
* Delete an entry
*
* @param int $id ID Number
* @throws 2B300/9 INVALID_ID The entry ID does not exist
* @throws 2B300/9 INVALID_ID The entry ID does not exist
* @throws 2B300/C NO_PERMISSION The authorized user does not have permission to delete the entry
* @return void
*/
public function DELETEitem( $id )
{
try
{
\IPS\blog\Entry::load( $id )->delete();
$item = \IPS\blog\Entry::load( $id );
if ( $this->member and !$item->canDelete( $this->member ) )
{
throw new \IPS\Api\Exception( 'NO_PERMISSION', '2B300/C', 404 );
}
$item->delete();
return new \IPS\Api\Response( 200, NULL );
}
+2 -2
View File
@@ -26,7 +26,7 @@
</p>
</td>
</tr>]]></template_content_html><template_data>$entry, $email</template_data><template_content_plaintext><![CDATA[{$email->language->addToStack("x_created_entry_in", FALSE, array( 'sprintf' => array( $entry->author()->name, $entry->container()->_title ) ) )}: {$entry->title} ({$entry->url()})
]]></template_content_plaintext></template><template><template_app>blog</template_app><template_name>digests__comment</template_name><template_content_html><![CDATA[<tr style='border-bottom: 1px solid #eeeeee'>
]]></template_content_plaintext><template_pinned>0</template_pinned></template><template><template_app>blog</template_app><template_name>digests__comment</template_name><template_content_html><![CDATA[<tr style='border-bottom: 1px solid #eeeeee'>
<td dir='{dir}' width='40' align='center' valign='top' class=' '>
<img src='{$comment->author()->get_photo( true, true )}' width='32' height='32' style='border: 1px solid #000; vertical-align: middle;'>
</td>
@@ -42,4 +42,4 @@
</div>
</td>
</tr>]]></template_content_html><template_data>$comment, $email</template_data><template_content_plaintext><![CDATA[{$email->language->addToStack("x_commented_entry", FALSE, array( 'sprintf' => array( $comment->author()->name ) ) )}: {$comment->item()->name} ({$comment->url()})
]]></template_content_plaintext></template></emails>
]]></template_content_plaintext><template_pinned>0</template_pinned></template></emails>
+38 -1
View File
@@ -1,6 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<javascript app="blog">
<file javascript_app="blog" javascript_location="front" javascript_path="controllers/browse" javascript_name="ips.browse.list.js" javascript_type="controller" javascript_version="102002" javascript_position="1000050">/**
<file javascript_app="blog" javascript_location="front" javascript_path="controllers/browse" javascript_name="ips.browse.grid.js" javascript_type="controller" javascript_version="103005" javascript_position="1000050"><![CDATA[/**
* Invision Community
* (c) Invision Power Services, Inc. - https://www.invisioncommunity.com
*
* ips.browse.list.js - Blog browse list controller
*
* Author: Rikki Tissier
*/
;( function($, _, undefined){
"use strict";
ips.controller.register('blog.front.browse.grid', {
initialize: function () {
this.on('click', '.cBlog_grid_item', this.clickNewsItem);
this.setup();
},
setup: function () {
},
clickNewsItem: function (e) {
var link = $( e.currentTarget ).find('[data-role="newsTitle"]');
if( $( e.target ).closest('a').length > 0 ){
return;
}
if( $( e.target ).closest('input').length > 0 ){
return;
}
window.location = link.attr('href');
}
});
}(jQuery, _));]]></file>
<file javascript_app="blog" javascript_location="front" javascript_path="controllers/browse" javascript_name="ips.browse.list.js" javascript_type="controller" javascript_version="103005" javascript_position="1000050">/**
* Invision Community
* (c) Invision Power Services, Inc. - https://www.invisioncommunity.com
*
+14 -3
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<language>
<app key="blog" version="102002">
<app key="blog" version="103005">
<word key="__app_blog" js="0">Blogs</word>
<word key="frontnavigation_blogs" js="0">Blogs</word>
<word key="__indefart_blog_entry_comment" js="0">a comment on a blog entry</word>
@@ -34,6 +34,13 @@
<word key="blog_allow_rssimport" js="0">Allow RSS imports</word>
<word key="blog_allow_rss" js="0">Allow RSS exports</word>
<word key="blog_allow_rss_desc" js="0"><![CDATA[Only content that is available to guests will be shown. For more options, create a <a href='{internal.app=core&module=discovery&controller=rss}'>Custom RSS Feed</a>]]></word>
<word key="blog_allow_grid" js="0">Enable grid view</word>
<word key="blog_allow_grid_desc" js="0">Grid view showcases blog entries as cards with space for a feature photo</word>
<word key="blog_view_mode" js="0">Default view</word>
<word key="blog_view_mode_grid" js="0">Grid of latest entries</word>
<word key="blog_view_mode_grid_desc" js="0">Displays entries as cards in a grid with space for a feature photo</word>
<word key="blog_view_mode_list" js="0">List of blogs</word>
<word key="blog_view_mode_list_desc" js="0">Displays blogs as a sortable and filterable list</word>
<word key="blogs" js="0">Blogs</word>
<word key="blog_word_custom" js="0">Blog Name</word>
<word key="blog_blog_member_id" js="0">Blog Author</word>
@@ -54,6 +61,8 @@
<word key="select_blog" js="0">Select Blog</word>
<word key="search_contextual_item_blogs" js="0">This Blog</word>
<word key="search_contextual_item_blog_entry" js="0">This Entry</word>
<word key="view_blogs_as_list" js="0">View Blogs</word>
<word key="view_blogs_as_grid" js="0">View Latest Entries</word>
<word key="blog_settings" js="0">Blog Settings</word>
<word key="blog_name" js="0">Name</word>
<word key="blog_name_group" js="0">Name</word>
@@ -80,7 +89,7 @@
<word key="submit_entry" js="0">Submit New Blog Entry</word>
<word key="blog_entry_title" js="0">Title</word>
<word key="blog_entry_tags" js="0">Tags</word>
<word key="blog_entry_auto_follow" js="0">Auto Follow</word>
<word key="blog_entry_auto_follow" js="0"></word>
<word key="blog_entry_auto_follow_suffix" js="0">Notify me when other comments are posted</word>
<word key="blog_entry_content" js="0">Content</word>
<word key="blog_entry_date" js="0">Publish Time</word>
@@ -157,6 +166,7 @@
<word key="unpin_blog" js="0">Unpin</word>
<word key="blog_by" js="0">A blog by %s</word>
<word key="group_blog_by" js="0">A group blog by %s</word>
<word key="club_blog_for" js="0">A club blog for %s</word>
<word key="contributors_to_this" js="0">Contributors to this blog</word>
<word key="num_contributors_to_this" js="0">{# [1:contributor][?:contributors]} to this blog</word>
<word key="about_this_blog" js="0">About this blog</word>
@@ -212,7 +222,7 @@
<word key="can_unhide_blog_entry" js="0">Can unhide entries?</word>
<word key="can_view_hidden_blog_entry" js="0">Can view hidden entries?</word>
<word key="can_move_blog_entry" js="0">Can move entries?</word>
<word key="can_move_blog_entry_desc" js="0">Will be able to move entries only between the blogs they have permission to moderate, not to any other blog.</word>
<word key="can_move_blog_entry_desc" js="0">Will be able to move entries only between the blogs they can create new content within.</word>
<word key="can_lock_blog_entry" js="0">Can lock entries?</word>
<word key="can_unlock_blog_entry" js="0">Can unlock entries?</word>
<word key="can_reply_to_locked_blog_entry" js="0">Can reply to locked entries?</word>
@@ -257,5 +267,6 @@
<word key="blog_sidebar_title" js="0">Blog Information</word>
<word key="blog_bm_filters" js="0">Blog</word>
<word key="mf_has_blog" js="0">Member has a Blog?</word>
<word key="blog_entry_cover_photo" js="0">Feature Photo</word>
</app>
</language>
+23 -4
View File
@@ -449,7 +449,9 @@
]
}
},
"collation": "utf8mb4_unicode_ci"
"collation": "utf8mb4_unicode_ci",
"comment": "",
"reporting": "count"
},
"blog_entries": {
"name": "blog_entries",
@@ -991,8 +993,22 @@
"length": [
null
]
},
"entry_author_id": {
"type": "key",
"name": "entry_author_id",
"columns": [
"entry_author_id",
"entry_last_update"
],
"length": [
null,
null
]
}
}
},
"comment": "",
"reporting": "count"
},
"blog_comments": {
"name": "blog_comments",
@@ -1219,7 +1235,9 @@
null
]
}
}
},
"comment": "",
"reporting": "count"
},
"blog_rss_import": {
"name": "blog_rss_import",
@@ -1395,7 +1413,8 @@
]
}
},
"comment": ""
"comment": "",
"reporting": "count"
},
"blog_rss_imported": {
"name": "blog_rss_imported",
+18 -4
View File
@@ -1,18 +1,32 @@
[
{
"key": "blog_allow_grid",
"default": "1",
"report": "full"
},
{
"key": "blog_allow_rss",
"default": "1"
"default": "1",
"report": "full"
},
{
"key": "blog_allow_rssimport",
"default": "1"
"default": "1",
"report": "full"
},
{
"key": "blog_enable_rating",
"default": "0"
"default": "0",
"report": "full"
},
{
"key": "blog_enable_sidebar",
"default": "0"
"default": "0",
"report": "full"
},
{
"key": "blog_view_mode",
"default": "grid",
"report": "bool"
}
]
File diff suppressed because it is too large. Load diff
+52 -1
View File
@@ -198,5 +198,56 @@
"101117": "4.2.0 Beta 8",
"102000": "4.2.0",
"102001": "4.2.0",
"102002": "4.2.0"
"102002": "4.2.0",
"102003": "4.2.0",
"102004": "4.2.1",
"102005": "4.2.2 Beta 1",
"102006": "4.2.2 Beta 2",
"102007": "4.2.2",
"102008": "4.2.2",
"102009": "4.2.2",
"102010": "4.2.3 Beta 1",
"102011": "4.2.3",
"102012": "4.2.3",
"102013": "4.2.3",
"102014": "4.2.4 Beta 1",
"102015": "4.2.4 Beta 2",
"102016": "4.2.4",
"102017": "4.2.4",
"102018": "4.2.4",
"102019": "4.2.4",
"102020": "4.2.4",
"102021": "4.2.5 Beta 1",
"102022": "4.2.5 Beta 2",
"102023": "4.2.5 Beta 3",
"102024": "4.2.5",
"102025": "4.2.5",
"102026": "4.2.5",
"102027": "4.2.5",
"102028": "4.2.5",
"102029": "4.2.5",
"102030": "4.2.6 Beta 1",
"102031": "4.2.6 Beta 1",
"102032": "4.2.6 Beta 2",
"102033": "4.2.6 Beta 3",
"102034": "4.2.6",
"102035": "4.2.6",
"102036": "4.2.6",
"102037": "4.2.7 Beta 1",
"102038": "4.2.7 Beta 2",
"102039": "4.2.7 Beta 3",
"102040": "4.2.7 Beta 4",
"102041": "4.2.7 Beta 5",
"102042": "4.2.7",
"102043": "4.2.7",
"102044": "4.2.7",
"102045": "4.2.7",
"102046": "4.2.7",
"102047": "4.2.8",
"102048": "4.2.8",
"103000": "4.3.0 Beta 1",
"103002": "4.3.0 Beta 2",
"103003": "4.3.0 Beta 3",
"103004": "4.3.0 Beta 4",
"103005": "4.3.0"
}
@@ -36,7 +36,7 @@ class _Blog
/**
* Constructor
*
* @param \IPS\Member|IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
* @param \IPS\Member|\IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
* @return void
*/
public function __construct( $member = NULL )
@@ -30,15 +30,31 @@ class _Entry
*/
public function getItems()
{
if ( \IPS\blog\Entry::canCreate( \IPS\Member::loggedIn() ) )
{
return array(
'blog_entry' => array(
'link' => \IPS\Http\Url::internal( "app=blog&module=blogs&controller=submit", 'front', 'blog_submit' ),
'extraData' => array( 'data-ipsDialog' => true, 'data-ipsDialog-size' => "narrow", ),
'title' => 'select_blog'
)
);
$blogs = \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn(), array( array( 'blog_disabled=?', 0 ) ) );
if (
count( $blogs )
or
( \IPS\Settings::i()->club_nodes_in_apps and count( \IPS\blog\Blog::clubNodes( 'add' ) ) )
) {
if ( !\IPS\Settings::i()->club_nodes_in_apps AND count( $blogs ) === 1 )
{
$ourBlog = array_shift( $blogs );
return array(
'blog_entry' => array(
'link' => \IPS\Http\Url::internal( "app=blog&module=blogs&controller=submit&id=" . $ourBlog->_id, 'front', 'blog_submit' ),
)
);
}
else
{
return array(
'blog_entry' => array(
'link' => \IPS\Http\Url::internal( "app=blog&module=blogs&controller=submit", 'front', 'blog_submit' ),
'extraData' => array( 'data-ipsDialog' => true, 'data-ipsDialog-size' => "narrow", ),
'title' => 'select_blog'
)
);
}
}
else
{
@@ -53,7 +53,7 @@ class _Blogs
$blogs = \IPS\Db::i()->select(
"*",
'blog_blogs',
array( "blog_club_id IS NULL AND ( (blog_member_id>? AND blog_name LIKE CONCAT( '%', ?, '%' ) ) OR ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? ) )", 0, $searchTerm, $searchTerm, \IPS\Member::loggedIn()->language()->id ),
array( "blog_club_id IS NULL AND ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? )", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
NULL,
array( 0, 500 )
)->join(
@@ -82,7 +82,7 @@ class _RebuildEntryImages
$file = \IPS\File::create( 'core_Attachment', $entry['entry_image'], NULL, NULL, FALSE, $filePath );
$attachment = $file->makeAttachment('', \IPS\Member::load( $entry['entry_author_id'] ) );
$fileName = htmlspecialchars( $attachment['attach_file'], \IPS\HTMLENTITIES, 'UTF-8', TRUE );
$fileName = htmlspecialchars( $attachment['attach_file'], ENT_DISALLOWED, 'UTF-8', TRUE );
$image = <<<IMAGE
<a href="<fileStore.core_Attachment>/{$file}" class="ipsAttachLink ipsAttachLink_image" style="float:left;"><img data-fileid="{$attachment['attach_id']}" src="<fileStore.core_Attachment>/{$file}" class="ipsImage ipsImage_thumbnailed" style="margin:10px;" alt="{$fileName}"></a>
@@ -47,7 +47,7 @@ class _blogs extends \IPS\Node\Controller
protected function manage()
{
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'blog_blogs', \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=blogs' ) );
$table = new \IPS\Helpers\Table\Db( 'blog_blogs', \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=blogs' ), array( array( 'blog_club_id IS NULL' ) ) );
$table->langPrefix = 'blog_';
/* Column stuff */
@@ -55,7 +55,7 @@ class _blogs extends \IPS\Node\Controller
$table->mainColumn = 'word_custom';
$table->joins = array(
array( 'select' => 'CASE WHEN blog_blogs.blog_member_id THEN blog_blogs.blog_name ELSE w.word_custom END as word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'blogs_blog_', blog_blogs.blog_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'blogs_blog_', blog_blogs.blog_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
);
/* Sort stuff */
@@ -72,11 +72,13 @@ class _blogs extends \IPS\Node\Controller
$table->parsers = array(
'blog_member_id' => function( $val, $row )
{
try
$member = \IPS\Member::load( $val );
if( $member->member_id )
{
return \IPS\Member::load( $val )->link();
return $member->link();
}
catch( \OutOfRangeException $e )
else
{
return NULL;
}
@@ -88,12 +90,7 @@ class _blogs extends \IPS\Node\Controller
return \IPS\Member::loggedIn()->language()->addToStack('blog_member_deleted');
}
if( $row['blog_member_id'] )
{
$val = htmlspecialchars( $val, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
}
return $val;
return htmlspecialchars( $val, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE );
}
);
@@ -45,6 +45,11 @@ class _settings extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rating', \IPS\Settings::i()->blog_enable_rating ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_sidebar', \IPS\Settings::i()->blog_enable_sidebar ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_allow_grid', \IPS\Settings::i()->blog_allow_grid, FALSE, array( 'togglesOn' => array( 'blog_view_mode' ) ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'blog_view_mode', \IPS\Settings::i()->blog_view_mode, FALSE, array( 'options' => array(
'grid' => 'blog_view_mode_grid',
'list' => 'blog_view_mode_list'
) ), NULL, NULL, NULL, 'blog_view_mode' ) );
$form->addHeader('blog_settings_rss');
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_allow_rssimport', \IPS\Settings::i()->blog_allow_rssimport ) );
@@ -31,26 +31,72 @@ class _browse extends \IPS\Dispatcher\Controller
protected function manage()
{
/* Featured stuff */
$featured = iterator_to_array( \IPS\blog\Entry::featured( 5, '_rand' ) );
/* Blogs table */
$table = new \IPS\blog\Blog\Table( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
$table->title = 'our_community_blogs';
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
/* Filters */
$table->filters = array(
'my_blogs' => array( '(' . \IPS\Db::i()->findInSet( 'blog_groupblog_ids', \IPS\Member::loggedIn()->groups ) . ' OR ' . 'blog_member_id=? )', \IPS\Member::loggedIn()->member_id ),
'blogs_with_content' => array( 'blog_count_entries>0' )
);
$featured = iterator_to_array( \IPS\blog\Entry::featured( 5, '_rand' ) );
$blogs = \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn(), array( array( 'blog_disabled=?', 0 ) ) );
if ( ! \IPS\Settings::i()->blog_allow_grid )
{
$viewMode = 'list';
}
else
{
$viewMode = ( isset( \IPS\Request::i()->view ) ) ? \IPS\Request::i()->view : ( isset( \IPS\Request::i()->cookie['blog_view'] ) ? \IPS\Request::i()->cookie['blog_view'] : \IPS\Settings::i()->blog_view_mode );
}
if ( isset( \IPS\Request::i()->view ) )
{
\IPS\Request::i()->setCookie( 'blog_view', \IPS\Request::i()->view, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
}
/* Grid view */
if ( $viewMode == 'grid' )
{
$perpage = 23;
$page = 1;
if ( \IPS\Request::i()->page )
{
$page = intval( \IPS\Request::i()->page );
if ( !$page OR $page < 1 )
{
$page = 1;
}
}
/* @note We cannot check individual member permissions here, so entries in draft status are excluded. */
$count = \IPS\blog\Entry::getItemsWithPermission( array( "entry_status!=?", 'draft' ), 'entry_date desc', NULL, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
$entries = \IPS\blog\Entry::getItemsWithPermission( array( "entry_status!=?", 'draft' ), 'entry_date desc', array( ( $perpage * ( $page - 1 ) ), $perpage ) );
$pagination = array(
'page' => $page,
'pages' => ceil( $count / $perpage ),
'perpage' => $perpage,
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' )
);
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'grid.css', 'blog', 'front' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->indexGrid( $entries, $featured, $blogs, $pagination, $viewMode );
}
else
{
/* Blogs table */
$table = new \IPS\blog\Blog\Table( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
$table->title = 'our_community_blogs';
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
/* Filters */
$table->filters = array(
'my_blogs' => array( '(' . \IPS\Db::i()->findInSet( 'blog_groupblog_ids', \IPS\Member::loggedIn()->groups ) . ' OR ' . 'blog_member_id=? )', \IPS\Member::loggedIn()->member_id ),
'blogs_with_content' => array( 'blog_count_entries>0' )
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs, $viewMode );
}
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_viewing_index' );
/* Display */
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_browse.js', 'blog', 'front' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('blogs');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs );
}
}
@@ -110,7 +110,7 @@ class _entry extends \IPS\Content\Controller
'@context' => "http://schema.org",
'@type' => "Blog",
'url' => (string) $this->entry->container()->url(),
'name' => htmlspecialchars( $this->entry->container()->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => $this->entry->container()->_title,
'description' => strip_tags( $this->entry->container()->description ),
'commentCount' => $this->entry->container()->_comments,
'interactionStatistic' => array(
@@ -140,21 +140,21 @@ class _entry extends \IPS\Content\Controller
'@type' => "BlogPosting",
'url' => (string) $this->entry->url(),
'mainEntityOfPage' => (string) $this->entry->url(),
'name' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'headline' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => $this->entry->mapped('title'),
'headline' => $this->entry->mapped('title'),
'articleBody' => strip_tags( $this->entry->truncated() ),
'commentCount' => $this->entry->mapped('num_comments'),
'dateCreated' => \IPS\DateTime::ts( $this->entry->date )->format( \IPS\DateTime::ISO8601 ),
'datePublished' => \IPS\DateTime::ts( $this->entry->publish_date )->format( \IPS\DateTime::ISO8601 ),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => \IPS\Member::load( $this->entry->mapped('author') )->name,
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo()
),
'publisher' => array(
'@type' => 'Organization',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => \IPS\Member::load( $this->entry->mapped('author') )->name,
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo(),
'logo' => array(
@@ -182,6 +182,15 @@ class _entry extends \IPS\Content\Controller
)
);
if( $this->entry->averageRating() )
{
\IPS\Output::i()->jsonLd['blog']['blogPost']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $this->entry->averageRating(),
'ratingCount' => $this->entry->numberOfRatings(),
);
}
if( $this->entry->container()->coverPhoto()->file )
{
\IPS\Output::i()->jsonLd['blog']['image'] = (string) $this->entry->container()->coverPhoto()->file->url;
@@ -191,7 +200,7 @@ class _entry extends \IPS\Content\Controller
{
\IPS\Output::i()->jsonLd['blog']['author'] = array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->container()->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => \IPS\Member::load( $this->entry->container()->member_id )->name,
'url' => (string) \IPS\Member::load( $this->entry->container()->member_id )->url(),
'image' => \IPS\Member::load( $this->entry->container()->member_id )->get_photo()
);
@@ -235,6 +244,8 @@ class _entry extends \IPS\Content\Controller
}
/* File does not exist */
catch( \RuntimeException $e ) {}
/* Image is invalid */
catch( \InvalidArgumentException $e ){}
}
/* Display */
@@ -41,8 +41,8 @@ class _submit extends \IPS\Dispatcher\Controller
$this->blog = \IPS\blog\Blog::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e ) {}
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
}
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
parent::execute();
}
@@ -84,7 +84,7 @@ class _submit extends \IPS\Dispatcher\Controller
}
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', $this->blog->member_id ? array( $this->blog->_title => FALSE ) : array( "blogs_blog_{$this->blog->id}" => TRUE ) );
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', array( $this->blog->_title => FALSE ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submit( $formTemplate, $this->blog );
}
catch ( \OutOfRangeException $e )
@@ -95,7 +95,8 @@ class _submit extends \IPS\Dispatcher\Controller
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
'class' => 'IPS\blog\Blog',
'permissionCheck' => 'add',
'forceOwner' => \IPS\Member::loggedIn(),
'forceOwner' => \IPS\Member::loggedIn(),
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
) ) );
if ( $values = $form->values() )
+16 -6
View File
@@ -63,14 +63,24 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
/* Build table */
$where = array();
if ( !in_array( $this->blog->id, array_keys( \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn() ) ) ) )
if ( !in_array( $this->blog->id, array_keys( \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn() ) ) ) AND !\IPS\blog\Entry::canViewHiddenItems( \IPS\Member::loggedIn(), $this->blog ) )
{
$where[] = array( "entry_status!='draft'" );
}
$table = new \IPS\Helpers\Table\Content( 'IPS\blog\Entry', $this->blog->url(), $where, $this->blog );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'blogTable' );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rows' );
if ( \IPS\Settings::i()->blog_allow_grid )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'grid.css', 'blog', 'front' ) );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rowsGrid' );
}
else
{
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rows' );
}
$table->title = \IPS\Member::loggedIn()->language()->addToStack('entries_in_this_blog');
$table->sortBy = \IPS\Request::i()->sortby ?: 'date';
@@ -85,7 +95,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
);
/* Online User Location */
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', $this->blog->member_id ? array( $this->blog->_title => FALSE ) : array( "blogs_blog_{$this->blog->id}" => TRUE ) );
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', array( "blogs_blog_{$this->blog->id}" => TRUE ) );
/* Output */
\IPS\Output::i()->title = $this->blog->_title;
@@ -100,7 +110,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
'@context' => "http://schema.org",
'@type' => "Blog",
'url' => (string) $this->blog->url(),
'name' => htmlspecialchars( $this->blog->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => $this->blog->_title,
'description' => strip_tags( $this->blog->description ),
'commentCount' => $this->blog->_comments,
'interactionStatistic' => array(
@@ -136,7 +146,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
\IPS\Output::i()->jsonLd['blog']['author'] = array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->blog->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => \IPS\Member::load( $this->blog->member_id )->name,
'url' => (string) \IPS\Member::load( $this->blog->member_id )->url(),
'image' => \IPS\Member::load( $this->blog->member_id )->get_photo()
);
@@ -313,7 +323,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_auth_pass', $feed ? $feed->auth_pass : NULL, FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_auth_pass' ) );
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_show_link', $feed->import_show_link ?: \IPS\Member::loggedIn()->language()->addToStack('blog_rss_import_show_link_default' ), FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_show_link' ) );
$options = array( 'autocomplete' => array( 'unique' => TRUE, 'source' => \IPS\Content\Item::definedTags( $this->blog ), 'freeChoice' => ( \IPS\Settings::i()->tags_open_system ? TRUE : FALSE ) ) );
$options = array( 'autocomplete' => array( 'unique' => TRUE, 'minimized' => FALSE, 'source' => \IPS\Content\Item::definedTags( $this->blog ), 'freeChoice' => ( \IPS\Settings::i()->tags_open_system ? TRUE : FALSE ) ) );
if ( \IPS\Settings::i()->tags_force_lower )
{
$options['autocomplete']['forceLower'] = TRUE;
@@ -0,0 +1,37 @@
{
"1": {
"method": "addIndex",
"params": [
"blog_entries",
{
"type": "key",
"name": "entry_author_id",
"columns": [
"entry_author_id"
],
"length": [
null
]
}
]
},
"2": {
"method": "changeIndex",
"params": [
"blog_entries",
"entry_author_id",
{
"type": "key",
"name": "entry_author_id",
"columns": [
"entry_author_id",
"entry_last_update"
],
"length": [
null,
null
]
}
]
}
}
@@ -0,0 +1,43 @@
<?php
/**
* @brief 4.3.0 Beta 1 Upgrade Code
* @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 Blogs
* @since 04 Jan 2018
*/
namespace IPS\blog\setup\upg_103000;
/* 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;
}
/**
* 4.3.0 Beta 1 Upgrade Code
*/
class _Upgrade
{
/**
* ...
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function step1()
{
/* Move blog names into language system */
foreach( \IPS\Db::i()->select( '*', 'blog_blogs', array( 'blog_name IS NOT NULL' ) ) as $blog )
{
if ( ! empty( $blog['blog_name'] ) )
{
\IPS\Lang::saveCustom( 'blog', 'blogs_blog_' . $blog['blog_id'], $blog['blog_name'] );
}
}
return TRUE;
}
}
+89 -62
View File
@@ -102,6 +102,11 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
* @brief Cover Photo Storage Extension
*/
public static $coverPhotoStorageExtension = 'blog_Blogs';
/**
* @brief Use a default cover photo
*/
public static $coverPhotoDefault = true;
/**
* Columns needed to query for search result / stream view
@@ -111,7 +116,6 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
public static function basicDataColumns()
{
$return = parent::basicDataColumns();
$return[] = 'blog_name';
$return[] = 'blog_member_id';
return $return;
}
@@ -123,7 +127,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
*/
public static function contentTableTemplate()
{
return array( \IPS\Theme::i()->getTemplate( 'browse', 'blog' ), 'rows' );
return array( \IPS\Theme::i()->getTemplate( 'browse', 'blog', 'front' ), 'rows' );
}
/**
@@ -149,19 +153,6 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
return FALSE;
}
/**
* Get title from index data
*
* @param array $indexData Data from the search index
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
* @param array|NULL $containerData Basic data about the author. Only includes columns returned by container::basicDataColumns()
* @return \IPS\Http\Url
*/
public static function titleFromIndexData( $indexData, $itemData, $containerData )
{
return ( $containerData['blog_member_id'] ) ? $containerData['blog_name'] : parent::titleFromIndexData( $indexData, $itemData, $containerData );
}
/**
* Check permissions
*
@@ -258,7 +249,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
if ( $club = $this->club() )
{
if ( $club->type == $club::TYPE_PUBLIC )
if ( $club->type == $club::TYPE_PUBLIC or $club->type == $club::TYPE_READONLY )
{
return 'ca';
}
@@ -286,21 +277,33 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
/**
* Additional WHERE clauses for Follow view
*
* @param array $joins Joins
* @return array
*/
public static function followWhere()
public static function followWhere( &$joins )
{
$where = array();
if ( \IPS\Member::loggedIn()->member_id )
{
$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[] = \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 $where;
@@ -409,7 +412,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
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' ) );
$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}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 ) {
@@ -552,12 +555,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
unset( $values[ $fieldKey ] );
}
}
if( array_key_exists( 'blog_name', $values ) )
{
unset( $values['blog_name'] );
}
if( array_key_exists( 'blog_desc', $values ) )
{
unset( $values['blog_desc'] );
@@ -584,13 +582,18 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
}
}
\IPS\Lang::saveCustom( 'blog', "blogs_blog_{$this->id}", $values['blog_name'] );
/* This is here in case an admin changes a group blog to a member blog */
\IPS\Lang::deleteCustom( 'blog', "blogs_blog_{$this->id}" );
\IPS\Lang::deleteCustom( 'blog', "blogs_blog_{$this->id}_desc" );
\IPS\Lang::deleteCustom( 'blog', "blogs_groupblog_name_{$this->id}" );
$values['seo_name'] = \IPS\Http\Url\Friendly::seoTitle( $values['blog_name'] );
}
if( array_key_exists( 'blog_name', $values ) )
{
unset( $values['blog_name'] );
}
if( array_key_exists( 'blog_name_group', $values ) )
{
@@ -758,7 +761,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
try
{
/* @note entry_hidden is flipped to map to "approved" */
/* @note entry_hidden is flipped to map to "approved" and that this method will always only return the latest, visible, entry. */
$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;
}
@@ -783,7 +786,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
$select = \IPS\Db::i()->select(
"entry_author_id, count( entry_id ) as contributions",
'blog_entries',
array( "entry_blog_id=? AND entry_author_id !=?", $this->id, 0 ),
array( "entry_blog_id=? AND entry_author_id !=? AND entry_hidden!=?", $this->id, 0, -2 ),
"contributions DESC",
NULL,
array( 'entry_author_id' )
@@ -932,33 +935,6 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
$this->count_entries_future = $val;
}
/**
* Returns the title
*
* @return string
*/
protected function get__title()
{
return $this->member_id ? $this->name : \IPS\Member::loggedIn()->language()->addToStack( static::$titleLangPrefix . $this->_id );
}
/**
* Node titles can contain HTML. Apparently.
*
* @return string
*/
public function get__stripTagsTitle()
{
if ( $this->member_id )
{
return $this->name;
}
else
{
return \IPS\Member::loggedIn()->language()->addToStack( static::$titleLangPrefix . $this->_id, NULL, array( 'striptags' => true ) );
}
}
/**
* Returns the title
*
@@ -968,7 +944,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
{
return $this->member_id ? $this->desc : \IPS\Member::loggedIn()->language()->addToStack( static::$titleLangPrefix . $this->_id . static::$descriptionLangSuffix );
}
/**
* Get settings
*
@@ -1074,6 +1050,16 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
$photo->overlay = \IPS\Theme::i()->getTemplate( 'view', 'blog' )->coverPhotoOverlay( $this );
return $photo;
}
/**
* Produce a random hex color for a background
*
* @return string
*/
public function coverPhotoBackgroundColor()
{
return $this->staticCoverPhotoBackgroundColor( $this->titleForLog() );
}
/**
* Get content for embed
@@ -1105,6 +1091,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
/**
* 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 name Name
@@ -1116,7 +1103,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
* @apiresponse int comments Number of comments
* @apiresponse string url URL
*/
public function apiOutput()
public function apiOutput( \IPS\Member $authorizedMember = NULL )
{
$groups = array();
if ( $this->groupblog_ids )
@@ -1125,7 +1112,7 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
{
try
{
$groups[] = \IPS\Member\Group::load( $groupId )->apiOutput();
$groups[] = \IPS\Member\Group::load( $groupId )->apiOutput( $authorizedMember );
}
catch ( \OutOfRangeException $e ) { }
}
@@ -1134,8 +1121,8 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
return array(
'id' => $this->id,
'name' => $this->_title,
'description' => $this->member_id ? $this->desc : \IPS\Member::loggedIn()->language()->addToStack("blogs_blog_{$this->id}_desc"),
'owner' => $this->member_id ? $this->owner()->apiOutput() : null,
'description' => \IPS\Member::loggedIn()->language()->addToStack("blogs_blog_{$this->id}_desc"),
'owner' => $this->member_id ? $this->owner()->apiOutput( $authorizedMember ) : null,
'groups' => $groups,
'pinned' => (bool) $this->pinned,
'entries' => $this->count_entries,
@@ -1203,6 +1190,12 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
{
$this->seo_name = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
}
if ( !$this->_id )
{
$this->save();
\IPS\File::claimAttachments( 'blogs-new-blog', $this->id, NULL, 'description' );
}
}
/**
@@ -1215,4 +1208,38 @@ class _Blog extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\E
{
// Deliberately do nothing, Blog handles permissions differently
}
/**
* Fetch All Nodes in Clubs
*
* @param string|NULL $permissionCheck The permission key to check for or NULl to not check permissions
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
* @param mixed $where Additional WHERE clause
* @return array
*/
public static function clubNodes( $permissionCheck='view', $member=NULL, $where=array() )
{
$member = $member ?: \IPS\Member::loggedIn();
if ( $member->modPermission('can_access_all_clubs') )
{
return static::nodesWithPermission( NULL, $member, $where );
}
else
{
$where[] = array( 'blog_club_id IS NOT NULL' );
if ( $permissionCheck === 'add' )
{
$statuses = array( \IPS\Member\Club::STATUS_LEADER, \IPS\Member\Club::STATUS_MODERATOR );
}
else
{
$statuses = array( \IPS\Member\Club::STATUS_LEADER, \IPS\Member\Club::STATUS_MODERATOR, \IPS\Member\Club::STATUS_MEMBER );
}
$where[] = array( \IPS\Db::i()->in( 'status', $statuses ) );
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'blog_blogs', $where )->join( 'core_clubs_memberships', array( 'club_id=blog_club_id AND member_id=?', \IPS\Member::loggedIn()->member_id ) ), get_called_class() );
}
}
}
+13 -3
View File
@@ -67,7 +67,7 @@ class _Feed extends \IPS\Patterns\ActiveRecord
$i = 0;
$request = $request->decodeXml();
if( !( $request instanceof \IPS\Xml\RssOne ) AND !( $request instanceof \IPS\Xml\Rss ) AND !( $request instanceof \IPS\Xml\Atom ) )
if( !( $request instanceof \IPS\Xml\Rss1 ) AND !( $request instanceof \IPS\Xml\Rss ) AND !( $request instanceof \IPS\Xml\Atom ) )
{
throw new \RuntimeException( 'rss_import_invalid' );
}
@@ -76,6 +76,12 @@ class _Feed extends \IPS\Patterns\ActiveRecord
{
if ( !in_array( $guid, $previouslyImportedGuids ) )
{
/* Don't post entries in the future */
if( $article['date']->getTimestamp() > time() )
{
$article['date'] = \IPS\DateTime::create();
}
$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'], TRUE );
@@ -100,7 +106,7 @@ class _Feed extends \IPS\Patterns\ActiveRecord
$linkRelPart = 'rel="' . implode($rel, ' ') . '"';
}
$link = htmlspecialchars( $this->import_show_link, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
$link = htmlspecialchars( $this->import_show_link, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE );
$entry->content .= "<br><p><a href='{$article['link']}' {$linkRelPart}>{$link}</a></p>";
}
@@ -109,7 +115,11 @@ class _Feed extends \IPS\Patterns\ActiveRecord
/* Add to search index */
\IPS\Content\Search\Index::i()->index( $entry );
/* Send notifications */
$entry->sendNotifications();
$entry->setTags( json_decode( $this->tags, TRUE ) );
$inserts[] = array(
+23 -2
View File
@@ -99,8 +99,29 @@ class _Table extends \IPS\Helpers\Table\Table
$where[] = array( 'blog_social_group IS NULL' );
}
/* Exclude club blogs */
$where[] = array( 'blog_club_id IS NULL' );
/* Exclude club blogs unless we have permission to view them */
if ( \IPS\Settings::i()->club_nodes_in_apps )
{
if ( \IPS\Member::loggedIn()->member_id )
{
$where[] = array(
'( blog_club_id IS NULL OR blog_club_id IN(?) OR blog_club_id IN(?) )',
\IPS\Db::i()->select( 'id', 'core_clubs', array( \IPS\Db::i()->in( 'type', array( \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_OPEN, \IPS\Member\Club::TYPE_READONLY ) ) ) ),
\IPS\Db::i()->select( 'club_id', 'core_clubs_memberships', array( "member_id=? AND status IN('" . \IPS\Member\Club::STATUS_MEMBER . "','" . \IPS\Member\Club::STATUS_MODERATOR . "','" . \IPS\Member\Club::STATUS_LEADER . "')", \IPS\Member::loggedIn()->member_id ) ),
);
}
else
{
$where[] = array(
'( blog_club_id IS NULL OR blog_club_id IN(?) )',
\IPS\Db::i()->select( 'id', 'core_clubs', array( \IPS\Db::i()->in( 'type', array( \IPS\Member\Club::TYPE_PUBLIC, \IPS\Member\Club::TYPE_OPEN, \IPS\Member\Club::TYPE_READONLY ) ) ) ),
);
}
}
else
{
$where[] = array( 'blog_club_id IS NULL' );
}
/* Get Count */
$count = \IPS\Db::i()->select( 'COUNT(*) as cnt', 'blog_blogs', $where )->first();
+16 -4
View File
@@ -21,9 +21,9 @@ 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\Searchable, \IPS\Content\Embeddable
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
{
use \IPS\Content\Reactable;
use \IPS\Content\Reactable, \IPS\Content\Reportable;
/**
* @brief [ActiveRecord] Multiton Store
@@ -105,13 +105,25 @@ 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' );
}
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 );
}
+79 -12
View File
@@ -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
+1 -1
View File
@@ -107,7 +107,7 @@ class _blogs extends \IPS\Widget\PermissionCache
'blog_last_edate' => 'widget__blog_edate',
'blog_count_entries' => 'widget__blog_count_entries',
'blog_count_comments' => 'widget__blog_count_comments'
) ) ), NULL, NULL, NULL, 'widget_feed_sort_on' );
) ), NULL, NULL, NULL, 'widget_feed_sort_on' ) );
$form->add( new \IPS\Helpers\Form\Select( 'widget_feed_sort_dir', isset( $this->configuration['widget_feed_sort_dir'] ) ? $this->configuration['widget_feed_sort_dir'] : 'desc', FALSE, array(
'options' => array(