Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\forums\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -32,6 +32,7 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
* GET /forums/forums
|
||||
* Get list of forums
|
||||
*
|
||||
* @apiparam int clubs 0|1 Include club forums, default: 1
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @note For requests using an OAuth Access Token for a particular member, only forums the authorized user can view will be included
|
||||
@@ -77,10 +78,20 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
* @apiparam int sitemap_priority 1-9 1 highest priority
|
||||
* @apiparam int min_content The minimum amount of posts to be able to view
|
||||
* @apiparam int can_see_others 0|1 Users can see topics posted by other users?
|
||||
* @apiparam object permissions An object with the keys as permission options (view, read, add, reply, attachments) and values as permissions to use (which may be * to grant access to all groups, or an array of group IDs to permit access to)
|
||||
* @apiparam string redirect_url If creating a redirect forum, the URL to redirect too.
|
||||
* @return \IPS\forums\Forum
|
||||
* @throws 1F363/2 NO_TITLE A title for the forum must be supplied
|
||||
* @throws 1F363/3 NO_REDIRECT_URL No redirect URL supplied.
|
||||
* @throws 1F363/4 INVALID_TYPE Invalid type of forum.
|
||||
*/
|
||||
public function POSTindex()
|
||||
{
|
||||
if ( !\IPS\Request::i()->title )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_TITLE', '1F363/2', 400 );
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 201, $this->_create()->apiOutput( $this->member ) );
|
||||
}
|
||||
|
||||
@@ -98,14 +109,19 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
* @apiparam int sitemap_priority 1-9 1 highest priority
|
||||
* @apiparam int min_content The minimum amount of posts to be able to view
|
||||
* @apiparam int can_see_others 0|1 Users can see topics posted by other users?
|
||||
* @apiparam object permissions An object with the keys as permission options (view, read, add, reply, attachments) and values as permissions to use (which may be * to grant access to all groups, or an array of group IDs to permit access to)
|
||||
* @apiparam string redirect_url If editing a redirect forum, the URL to redirect too.
|
||||
* @param int $id ID Number
|
||||
* @return \IPS\forums\Forum
|
||||
* @throws 1F363/3 NO_REDIRECT_URL No redirect URL supplied.
|
||||
* @throws 1F363/4 INVALID_TYPE Invalid type of forum.
|
||||
*/
|
||||
public function POSTitem( $id )
|
||||
{
|
||||
$class = $this->class;
|
||||
$forum = $class::load( $id );
|
||||
|
||||
return new \IPS\Api\Response( 201, $this->_createOrUpdate( $forum )->apiOutput( $this->member ) );
|
||||
return new \IPS\Api\Response( 200, $this->_createOrUpdate( $forum )->apiOutput( $this->member ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,27 +129,26 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
* Delete a forum
|
||||
*
|
||||
* @apiclientonly
|
||||
* @param int $id ID Number
|
||||
* @param int $id ID Number
|
||||
* @apiparam int deleteChildrenOrMove The ID number of the new parent or -1 to delete all child nodes.
|
||||
* @return void
|
||||
* @throws 1S359/1 INVALID_ID The node ID does not exist
|
||||
* @throws 1S359/2 INVALID_TARGET The target node cannot be deleted because the new parent node does not exist
|
||||
* @throws 1S359/3 HAS_CHILDREN The target node cannot be deleted because it has children (pass deleteChildrenOrMove in the request to specify how to handle the children)
|
||||
*/
|
||||
public function DELETEitem( $id )
|
||||
{
|
||||
return $this->_delete( $id );
|
||||
return $this->_delete( $id, \IPS\Request::i()->deleteChildrenOrMove ?? NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update node
|
||||
*
|
||||
* @param \IPS\Node\Model $node The node
|
||||
* @param \IPS\Node\Model $forum The node
|
||||
* @return \IPS\Node\Model
|
||||
*/
|
||||
protected function _createOrUpdate( \IPS\Node\Model $forum )
|
||||
{
|
||||
if ( !\IPS\Request::i()->title )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_TITLE', '', 400 );
|
||||
}
|
||||
|
||||
foreach ( array( 'title' => "forums_forum_{$forum->id}", 'description' => "forums_forum_{$forum->id}_desc" ) as $fieldKey => $langKey )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->$fieldKey ) )
|
||||
@@ -147,7 +162,47 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
}
|
||||
}
|
||||
|
||||
$forum->parent_id = (int) \IPS\Request::i()->parent?: -1;
|
||||
$forum->parent_id = (int) \IPS\Request::i()->parent ?: -1;
|
||||
|
||||
if ( !isset( \IPS\Request::i()->type ) )
|
||||
{
|
||||
if ( $forum->parent_id === -1 )
|
||||
{
|
||||
\IPS\Request::i()->type = 'category';
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->type = 'normal';
|
||||
}
|
||||
}
|
||||
|
||||
switch( \IPS\Request::i()->type )
|
||||
{
|
||||
case 'category':
|
||||
$forum->sub_can_post = 0;
|
||||
break;
|
||||
|
||||
case 'normal':
|
||||
$forum->sub_can_post = 1;
|
||||
break;
|
||||
|
||||
case 'qa':
|
||||
$forum->forums_bitoptions['bw_enable_answers'] = TRUE;
|
||||
break;
|
||||
|
||||
case 'redirect':
|
||||
if ( !isset( \IPS\Request::i()->redirect_url ) )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_REDIRECT_URL', '1F363/3', 400 );
|
||||
}
|
||||
|
||||
$forum->redirect_on = 1;
|
||||
$forum->redirect_url = \IPS\Request::i()->redirect_url;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \IPS\Api\Exception( 'INVALID_TYPE', '1F363/4', 400 );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->password ) )
|
||||
{
|
||||
@@ -159,6 +214,21 @@ class _forums extends \IPS\Node\Api\NodeController
|
||||
$forum->skin_id = \IPS\Request::i()->theme;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->sitemap_priority ) )
|
||||
{
|
||||
$forum->ipseo_priority = \IPS\Request::i()->sitemap_priority;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->min_content ) )
|
||||
{
|
||||
$forum->min_content = \IPS\Request::i()->min_content;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->can_see_others ) )
|
||||
{
|
||||
$forum->can_view_others = \IPS\Request::i()->can_see_others;
|
||||
}
|
||||
|
||||
return parent::_createOrUpdate( $forum );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user