Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+100
View File
@@ -0,0 +1,100 @@
<?php
/**
* @brief Member Groups API
* @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
* @since 4 Apr 2017
*/
namespace IPS\core\api;
/* 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;
}
/**
* @brief Member Groups API
*/
class _groups extends \IPS\Api\Controller
{
/**
* GET /core/groups
* Get list of groups
*
* @apiparam int page Page number
* @return \IPS\Api\PaginatedResponse<IPS\Member\Group>
*/
public function GETindex()
{
/* Where clause */
$where = array();
/* Return */
return new \IPS\Api\PaginatedResponse(
200,
\IPS\Db::i()->select( '*', 'core_groups', $where, "g_id asc", NULL, NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS ),
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
'IPS\Member\Group',
\IPS\Db::i()->select( 'COUNT(*)', 'core_groups', $where )->first()
);
}
/**
* GET /core/groups/{id}
* Get information about a specific group
*
* @param int $id ID Number
* @throws 1C358/1 INVALID_ID The group ID does not exist
* @return \IPS\Member\Group
*/
public function GETitem( $id )
{
try
{
$group = \IPS\Member\Group::load( $id );
if ( !$group->g_id )
{
throw new \OutOfRangeException;
}
return new \IPS\Api\Response( 200, $group->apiOutput() );
}
catch ( \OutOfRangeException $e )
{
throw new \IPS\Api\Exception( 'INVALID_ID', '1C358/1', 404 );
}
}
/**
* DELETE /core/groups/{id}
* Deletes a group
*
* @param int $id ID Number
* @throws 1C358/2 INVALID_ID The group ID does not exist
* @return void
*/
public function DELETEitem( $id )
{
try
{
$group = \IPS\Member\Group::load( $id );
if ( !$group->g_id )
{
throw new \OutOfRangeException;
}
$group->delete();
return new \IPS\Api\Response( 200, NULL );
}
catch ( \OutOfRangeException $e )
{
throw new \IPS\Api\Exception( 'INVALID_ID', '1C358/2', 404 );
}
}
}
+5 -6
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Hello API
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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
* @since 3 Dec 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\api;
@@ -30,7 +29,7 @@ class _hello extends \IPS\Api\Controller
* @return array
* @apiresponse string communityName The name of the community
* @apiresponse string communityUrl The community URL
* @apiresponse string ipsVersion The IPS Community Suite version number
* @apiresponse string ipsVersion The Invision Community version number
*/
public function GETindex()
{
+26 -24
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Members API
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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
* @since 3 Dec 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\api;
@@ -36,11 +35,11 @@ class _members extends \IPS\Api\Controller
{
/* Where clause */
$where = array();
/* Sort */
$sortBy = ( isset( \IPS\Request::i()->sortBy ) and in_array( \IPS\Request::i()->sortBy, array( 'name', 'joined' ) ) ) ? \IPS\Request::i()->sortBy : 'member_id';
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
/* Return */
return new \IPS\Api\PaginatedResponse(
200,
@@ -76,7 +75,7 @@ class _members extends \IPS\Api\Controller
throw new \IPS\Api\Exception( 'INVALID_ID', '1C292/2', 404 );
}
}
/**
* Create or update member
*
@@ -101,20 +100,21 @@ class _members extends \IPS\Api\Controller
throw new \IPS\Api\Exception( 'USERNAME_EXISTS', '1C292/4', 403 );
}
}
if ( isset( \IPS\Request::i()->email ) and \IPS\Request::i()->email != $member->email )
{
$existingEmail = \IPS\Member::load( \IPS\Request::i()->email, 'email' );
if ( !$existingEmail->member_id )
{
$member->email = \IPS\Request::i()->email;
$member->invalidateSessionsAndLogins();
}
else
{
throw new \IPS\Api\Exception( 'EMAIL_EXISTS', '1C292/5', 403 );
}
}
if ( isset( \IPS\Request::i()->group ) )
{
try
@@ -127,7 +127,7 @@ class _members extends \IPS\Api\Controller
throw new \IPS\Api\Exception( 'INVALID_GROUP', '1C292/6', 403 );
}
}
if ( isset( \IPS\Request::i()->password ) )
{
foreach ( \IPS\Login::handlers( TRUE ) as $handler )
@@ -138,6 +138,7 @@ class _members extends \IPS\Api\Controller
}
catch( \BadMethodCallException $e ){}
}
$member->invalidateSessionsAndLogins();
}
else
{
@@ -156,13 +157,13 @@ class _members extends \IPS\Api\Controller
{
$profileFields = array();
}
/* If \IPS\Db::i()->select()->first() has only one column, then the contents of that column is returned. We do not want this here. */
if ( !is_array( $profileFields ) )
{
$profileFields = array();
}
$profileFields['member_id'] = $member->member_id;
foreach ( \IPS\Request::i()->customFields as $k => $v )
@@ -171,13 +172,14 @@ class _members extends \IPS\Api\Controller
}
\IPS\Db::i()->replace( 'core_pfields_content', $profileFields );
$member->changedCustomFields = $profileFields;
$member->save();
}
return $member;
}
/**
* POST /core/members
* Create a member
@@ -201,7 +203,7 @@ class _members extends \IPS\Api\Controller
{
throw new \IPS\Api\Exception( 'NO_USERNAME_OR_EMAIL', '1C292/8', 403 );
}
/* This is required as there is no other way to allow the account to be authenticated when it is created via the API */
if ( !isset( \IPS\Request::i()->password ) )
{
@@ -210,12 +212,12 @@ class _members extends \IPS\Api\Controller
$member = new \IPS\Member;
$member->member_group_id = \IPS\Settings::i()->member_group;
$member = $this->_createOrUpdate( $member );
$member = $this->_createOrUpdate( $member );
return new \IPS\Api\Response( 201, $member->apiOutput() );
}
/**
* POST /core/members/{id}
* Edit a member
@@ -240,9 +242,9 @@ class _members extends \IPS\Api\Controller
{
throw new \OutOfRangeException;
}
$member = $this->_createOrUpdate( $member );
return new \IPS\Api\Response( 200, $member->apiOutput() );
}
catch ( \OutOfRangeException $e )
@@ -256,7 +258,7 @@ class _members extends \IPS\Api\Controller
* Deletes a member
*
* @param int $id ID Number
* @throws 1C292/3 INVALID_ID The member ID does not exist
* @throws 1C292/2 INVALID_ID The member ID does not exist
* @return void
*/
public function DELETEitem( $id )